automatic update by autodist [release 22.21-1mamba;Sat Feb 22 2014]

This commit is contained in:
Automatic Build System 2024-01-06 10:34:11 +01:00
parent 371d0916b2
commit fca1e04f21
3 changed files with 380 additions and 0 deletions

View File

@ -1,2 +1,7 @@
# psmisc
The psmisc package contains utilities for managing processes on your system: pstree, killall and fuser.
The pstree command displays a tree structure of all of the running processes on your system.
The killall command sends a specified signal (SIGTERM if nothing is specified) to processes identified by name.
The fuser command identifies the PIDs of processes that are using specified files or filesystems.

View File

@ -0,0 +1,259 @@
commit 89fa40f0a55096a62809e852244d7db3f445b0cd
Author: Craig Small <csmall@enc.com.au>
Date: Sun Oct 7 10:52:46 2012 +1100
pstree compiles with SE Linux
pstree failed to compile with SE Linux enabled because one of the
scontext was missed and without it enabled the bug doesn't appear.
pstree is now re-worked so scontext is defined as a dummy meaning
most of the code except the reall SE Linux specific stuff is compilied
meaning this sort of thing shouldn't happen too much again.
Bug-Gentoo: https://bugs.gentoo.org/show_bug.cgi?id=437332
Bug-Sourceforge: https://sourceforge.net/p/psmisc/bugs/54/
diff --git a/src/pstree.c b/src/pstree.c
index db57244..b9a01cf 100644
--- a/src/pstree.c
+++ b/src/pstree.c
@@ -47,6 +47,8 @@
#ifdef WITH_SELINUX
#include <selinux/selinux.h>
+#else
+typedef void* security_context_t; /* DUMMY to remove most ifdefs */
#endif /*WITH_SELINUX */
extern const char *__progname;
@@ -81,9 +83,7 @@ typedef struct _proc {
pid_t pid;
pid_t pgid;
uid_t uid;
-#ifdef WITH_SELINUX
security_context_t scontext;
-#endif /*WITH_SELINUX */
char flags;
struct _child *children;
struct _proc *parent;
@@ -131,16 +131,14 @@ static int *more = NULL;
static int print_args = 0, compact = 1, user_change = 0, pids = 0, pgids = 0,
show_parents = 0, by_pid = 0, trunc = 1, wait_end = 0;
-#ifdef WITH_SELINUX
static int show_scontext = 0;
-#endif /*WITH_SELINUX */
static int output_width = 132;
static int cur_x = 1;
static char last_char = 0;
static int dumped = 0; /* used by dump_by_user */
static int charlen = 0; /* length of character */
-static void fix_orphans(void);
+static void fix_orphans(security_context_t scontext);
/*
* Allocates additional buffer space for width and more as needed.
* The first call will allocate the first buffer.
@@ -229,15 +227,12 @@ static int out_int(int x)
return digits;
}
-#ifdef WITH_SELINUX
static void out_scontext(security_context_t scontext)
{
out_string("`");
out_string(scontext);
out_string("'");
}
-#endif /*WITH_SELINUX */
-
static void out_newline(void)
{
@@ -259,12 +254,8 @@ static PROC *find_proc(pid_t pid)
return NULL;
}
-#ifdef WITH_SELINUX
static PROC *new_proc(const char *comm, pid_t pid, uid_t uid,
security_context_t scontext)
-#else /*WITH_SELINUX */
-static PROC *new_proc(const char *comm, pid_t pid, uid_t uid)
-#endif /*WITH_SELINUX */
{
PROC *new;
@@ -279,9 +270,7 @@ static PROC *new_proc(const char *comm, pid_t pid, uid_t uid)
new->flags = 0;
new->argc = 0;
new->argv = NULL;
-#ifdef WITH_SELINUX
new->scontext = scontext;
-#endif /*WITH_SELINUX */
new->children = NULL;
new->parent = NULL;
new->next = list;
@@ -364,24 +353,14 @@ rename_proc(PROC *this, const char *comm, uid_t uid)
}
}
}
-#ifdef WITH_SELINUX
static void
add_proc(const char *comm, pid_t pid, pid_t ppid, pid_t pgid, uid_t uid,
const char *args, int size, char isthread, security_context_t scontext)
-#else /*WITH_SELINUX */
-static void
-add_proc(const char *comm, pid_t pid, pid_t ppid, pid_t pgid, uid_t uid,
- const char *args, int size, char isthread)
-#endif /*WITH_SELINUX */
{
PROC *this, *parent;
if (!(this = find_proc(pid)))
-#ifdef WITH_SELINUX
this = new_proc(comm, pid, uid, scontext);
-#else /*WITH_SELINUX */
- this = new_proc(comm, pid, uid);
-#endif /*WITH_SELINUX */
else {
rename_proc(this, comm, uid);
}
@@ -393,11 +372,7 @@ add_proc(const char *comm, pid_t pid, pid_t ppid, pid_t pgid, uid_t uid,
if (isthread)
this->flags |= PFLAG_THREAD;
if (!(parent = find_proc(ppid))) {
-#ifdef WITH_SELINUX
parent = new_proc("?", ppid, 0, scontext);
-#else /*WITH_SELINUX */
- parent = new_proc("?", ppid, 0);
-#endif
}
if (pid != 0) {
add_child(parent, this);
@@ -494,12 +469,10 @@ dump_tree(PROC * current, int level, int rep, int leaf, int last,
else
(void) out_int(current->uid);
}
-#ifdef WITH_SELINUX
if (show_scontext) {
out_char(info++ ? ',' : '(');
out_scontext(current->scontext);
}
-#endif /*WITH_SELINUX */
if ((swapped && print_args && current->argc < 0) || (!swapped && info))
out_char(')');
if ((current->flags & PFLAG_HILIGHT) && (tmp = tgetstr("me", NULL)))
@@ -520,11 +493,7 @@ dump_tree(PROC * current, int level, int rep, int leaf, int last,
}
}
}
-#ifdef WITH_SELINUX
if (show_scontext || print_args || !current->children)
-#else /*WITH_SELINUX */
- if (print_args || !current->children)
-#endif /*WITH_SELINUX */
{
while (closing--)
out_char(']');
@@ -533,11 +502,7 @@ dump_tree(PROC * current, int level, int rep, int leaf, int last,
ensure_buffer_capacity(level);
more[level] = !last;
-#ifdef WITH_SELINUX
if (show_scontext || print_args)
-#else /*WITH_SELINUX */
- if (print_args)
-#endif /*WITH_SELINUX */
{
width[level] = swapped + (comm_len > 1 ? 0 : -1);
count=0;
@@ -653,8 +618,8 @@ static void read_proc(void)
pid_t pid, ppid, pgid;
int fd, size;
int empty;
-#ifdef WITH_SELINUX
security_context_t scontext = NULL;
+#ifdef WITH_SELINUX
int selinux_enabled = is_selinux_enabled() > 0;
#endif /*WITH_SELINUX */
@@ -726,21 +691,12 @@ static void read_proc(void)
while ((dt = readdir(taskdir)) != NULL) {
if ((thread = atoi(dt->d_name)) != 0) {
if (thread != pid) {
-#ifdef WITH_SELINUX
if (print_args)
add_proc(threadname, thread, pid, pgid, st.st_uid,
threadname, strlen (threadname) + 1, 1,scontext);
else
add_proc(threadname, thread, pid, pgid, st.st_uid,
NULL, 0, 1, scontext);
-#else /*WITH_SELINUX */
- if (print_args)
- add_proc(threadname, thread, pid, pgid, st.st_uid,
- threadname, strlen (threadname) + 1, 1);
- else
- add_proc(threadname, thread, pid, pgid, st.st_uid,
- NULL, 0, 1);
-#endif /*WITH_SELINUX */
}
}
}
@@ -749,11 +705,7 @@ static void read_proc(void)
}
free(taskpath);
if (!print_args)
-#ifdef WITH_SELINUX
add_proc(comm, pid, ppid, pgid, st.st_uid, NULL, 0, 0, scontext);
-#else /*WITH_SELINUX */
- add_proc(comm, pid, ppid, pgid, st.st_uid, NULL, 0, 0);
-#endif /*WITH_SELINUX */
else {
sprintf(path, "%s/%d/cmdline", PROC_BASE, pid);
if ((fd = open(path, O_RDONLY)) < 0) {
@@ -770,13 +722,8 @@ static void read_proc(void)
size--;
if (size)
buffer[size++] = 0;
-#ifdef WITH_SELINUX
add_proc(comm, pid, ppid, pgid, st.st_uid,
buffer, size, 0, scontext);
-#else /*WITH_SELINUX */
- add_proc(comm, pid, ppid, pgid, st.st_uid,
- buffer, size, 0);
-#endif /*WITH_SELINUX */
}
}
}
@@ -787,7 +734,7 @@ static void read_proc(void)
}
}
(void) closedir(dir);
- fix_orphans();
+ fix_orphans(scontext);
if (print_args)
free(buffer);
if (empty) {
@@ -796,7 +743,7 @@ static void read_proc(void)
}
}
-static void fix_orphans(void)
+static void fix_orphans(security_context_t scontext)
{
/* When using kernel 3.3 with hidepid feature enabled on /proc
* then we need fake root pid and gather all the orphan processes
@@ -807,11 +754,7 @@ static void fix_orphans(void)
PROC *root, *walk;
if (!(root = find_proc(ROOT_PID))) {
-#ifdef WITH_SELINUX
root = new_proc("?", ROOT_PID, 0, scontext);
-#else /*WITH_SELINUX */
- root = new_proc("?", ROOT_PID, 0);
-#endif
}
for (walk = list; walk; walk = walk->next) {
if (walk->pid == 1 || walk->pid == 0)

116
psmisc.spec Normal file
View File

@ -0,0 +1,116 @@
Name: psmisc
Version: 22.21
Release: 1mamba
Summary: Small utilities that use the /proc filesystem
Group: System/Tools
Vendor: openmamba
Distribution: openmamba
Packager: Silvan Calarco <silvan.calarco@mambasoft.it>
URL: http://psmisc.sourceforge.net/
Source: http://downloads.sourceforge.net/psmisc/psmisc-%{version}.tar.gz
Patch0: psmisc-22.20-selinux-scontext.patch
License: GPL
## AUTOBUILDREQ-BEGIN
BuildRequires: glibc-devel
BuildRequires: libncurses-devel
%if "%{stage1}" != "1"
BuildRequires: libselinux-devel
%endif
## AUTOBUILDREQ-END
BuildRequires: gettext-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
The psmisc package contains utilities for managing processes on your system: pstree, killall and fuser.
The pstree command displays a tree structure of all of the running processes on your system.
The killall command sends a specified signal (SIGTERM if nothing is specified) to processes identified by name.
The fuser command identifies the PIDs of processes that are using specified files or filesystems.
%prep
%setup -q
#%patch0 -p1
%build
%configure \
%if "%{stage1}" != "1"
--enable-selinux \
%endif
%if "%{_host}" != "%{_build}"
ac_cv_func_malloc_0_nonnull=yes \
ac_cv_func_realloc_0_nonnull=yes
%endif
%make
%install
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%makeinstall
install -d %{buildroot}/bin
mv %{buildroot}%{_bindir}/fuser %{buildroot}/bin/fuser
%find_lang %{name}
%clean
[ "%{buildroot}" != / ] && rm -rf "%{buildroot}"
%files -f %{name}.lang
%defattr(-,root,root)
/bin/fuser
%{_bindir}/peekfd
%{_bindir}/killall
%{_bindir}/prtstat
%{_bindir}/pstree
%{_bindir}/pstree.x11
%{_mandir}/man1/fuser.1.gz
%{_mandir}/man1/killall.1.gz
%{_mandir}/man1/prtstat.1.gz
%{_mandir}/man1/pstree.1.gz
%{_mandir}/man1/peekfd.1.gz
%changelog
* Sat Feb 22 2014 Automatic Build System <autodist@mambasoft.it> 22.21-1mamba
- automatic update by autodist
* Sat Jun 29 2013 Silvan Calarco <silvan.calarco@mambasoft.it> 22.20-2mamba
- arm: rebuild with recent ncurses to fix undefined symbol: __aeabi_idiv
* Fri Jan 18 2013 Automatic Build System <autodist@mambasoft.it> 22.20-1mamba
- automatic version update by autodist
* Fri Aug 10 2012 Automatic Build System <autodist@mambasoft.it> 22.19-1mamba
- automatic version update by autodist
* Sun Jun 26 2011 Automatic Build System <autodist@mambasoft.it> 22.14-1mamba
- automatic update by autodist
* Sun Oct 03 2010 Automatic Build System <autodist@mambasoft.it> 22.13-1mamba
- automatic update by autodist
* Sat Jul 31 2010 Automatic Build System <autodist@mambasoft.it> 22.12-1mamba
- automatic update by autodist
* Fri Jun 25 2010 Automatic Build System <autodist@mambasoft.it> 22.11-1mamba
- automatic update by autodist
* Tue Jun 03 2008 Silvan Calarco <silvan.calarco@mambasoft.it> 22.6-1mamba
- update to 22.6
- removed fuser-ipv6 patch applied upstream
* Tue Mar 27 2007 Davide Madrisan <davide.madrisan@qilinux.it> 22.3-2qilnx
- fuser moved to the /bin directory (should be in /sbin but users need it)
* Fri Mar 23 2007 Davide Madrisan <davide.madrisan@qilinux.it> 22.3-1qilnx
- update to version 22.3 by autospec
- fuser moved to /sbin for lsb compliance
* Thu Dec 15 2005 Stefano Cotta Ramusino <stefano.cotta@qilinux.it> 21.8-1qilnx
- update to version 21.8 by autospec
- specfile updated and fixed
- fixed package group
* Mon Jun 16 2003 Silvan Calarco <silvan.calarco@qinet.it> 21.3-1qilnx
- changed location of files
* Mon Apr 09 2003 Alessandro Ramazzina <alessandro.ramazzina@qinet.it>
- creation of psmisc package