aboutsummaryrefslogtreecommitdiff
path: root/procps/ps.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2003-07-03 10:07:04 +0000
committerEric Andersen <andersen@codepoet.org>2003-07-03 10:07:04 +0000
commit9e48045e45df7e3e205575a4eb3dc39d634b05aa (patch)
treee8f993dffc34380fbcc54cc858c81da594bdb95b /procps/ps.c
parentc48d49ad988a4163cff7f38ee4bd1f9886d0ed11 (diff)
downloadbusybox-w32-9e48045e45df7e3e205575a4eb3dc39d634b05aa.tar.gz
busybox-w32-9e48045e45df7e3e205575a4eb3dc39d634b05aa.tar.bz2
busybox-w32-9e48045e45df7e3e205575a4eb3dc39d634b05aa.zip
Patch from Russell Coker:
I've attached my latest SE Linux patch for busybox against the latest CVS version of busybox.
Diffstat (limited to 'procps/ps.c')
-rw-r--r--procps/ps.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/procps/ps.c b/procps/ps.c
index 5ccac7a95..691f490c7 100644
--- a/procps/ps.c
+++ b/procps/ps.c
@@ -31,6 +31,11 @@
31#include <termios.h> 31#include <termios.h>
32#include <sys/ioctl.h> 32#include <sys/ioctl.h>
33#include "busybox.h" 33#include "busybox.h"
34#ifdef CONFIG_SELINUX
35#include <fs_secure.h>
36#include <ss.h>
37#include <flask_util.h> /* for is_flask_enabled() */
38#endif
34 39
35static const int TERMINAL_WIDTH = 79; /* not 80 in case terminal has linefold bug */ 40static const int TERMINAL_WIDTH = 79; /* not 80 in case terminal has linefold bug */
36 41
@@ -47,6 +52,13 @@ extern int ps_main(int argc, char **argv)
47#define terminal_width TERMINAL_WIDTH 52#define terminal_width TERMINAL_WIDTH
48#endif 53#endif
49 54
55#ifdef CONFIG_SELINUX
56 int use_selinux = 0;
57 security_id_t sid;
58 if(is_flask_enabled() && argv[1] && !strcmp(argv[1], "-c") )
59 use_selinux = 1;
60#endif
61
50 62
51#ifdef CONFIG_FEATURE_AUTOWIDTH 63#ifdef CONFIG_FEATURE_AUTOWIDTH
52 ioctl(fileno(stdout), TIOCGWINSZ, &win); 64 ioctl(fileno(stdout), TIOCGWINSZ, &win);
@@ -54,10 +66,31 @@ extern int ps_main(int argc, char **argv)
54 terminal_width = win.ws_col - 1; 66 terminal_width = win.ws_col - 1;
55#endif 67#endif
56 68
69#ifdef CONFIG_SELINUX
70 if(use_selinux)
71 printf(" PID Context Stat Command\n");
72 else
73#endif
57 printf(" PID Uid VmSize Stat Command\n"); 74 printf(" PID Uid VmSize Stat Command\n");
75#ifdef CONFIG_SELINUX
76 while ((p = procps_scan(1, use_selinux, &sid)) != 0) {
77#else
58 while ((p = procps_scan(1)) != 0) { 78 while ((p = procps_scan(1)) != 0) {
79#endif
59 char *namecmd = p->cmd; 80 char *namecmd = p->cmd;
60 81
82#ifdef CONFIG_SELINUX
83 if(use_selinux)
84 {
85 char sbuf[128];
86 len = sizeof(sbuf);
87 if(security_sid_to_context(sid, (security_context_t)&sbuf, &len))
88 strcpy(sbuf, "unknown");
89
90 len = printf("%5d %-32s %s ", p->pid, sbuf, p->state);
91 }
92 else
93#endif
61 if(p->rss == 0) 94 if(p->rss == 0)
62 len = printf("%5d %-8s %s ", p->pid, p->user, p->state); 95 len = printf("%5d %-8s %s ", p->pid, p->user, p->state);
63 else 96 else