diff options
author | Eric Andersen <andersen@codepoet.org> | 2003-07-03 14:07:04 +0400 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2003-07-03 14:07:04 +0400 |
commit | 9e48045e45df7e3e205575a4eb3dc39d634b05aa (patch) | |
tree | e8f993dffc34380fbcc54cc858c81da594bdb95b /procps | |
parent | c48d49ad988a4163cff7f38ee4bd1f9886d0ed11 (diff) |
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')
-rw-r--r-- | procps/ps.c | 33 | ||||
-rw-r--r-- | procps/top.c | 4 |
2 files changed, 37 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 @@ #include <termios.h> #include <sys/ioctl.h> #include "busybox.h" +#ifdef CONFIG_SELINUX +#include <fs_secure.h> +#include <ss.h> +#include <flask_util.h> /* for is_flask_enabled() */ +#endif static const int TERMINAL_WIDTH = 79; /* not 80 in case terminal has linefold bug */ @@ -47,6 +52,13 @@ extern int ps_main(int argc, char **argv) #define terminal_width TERMINAL_WIDTH #endif +#ifdef CONFIG_SELINUX + int use_selinux = 0; + security_id_t sid; + if(is_flask_enabled() && argv[1] && !strcmp(argv[1], "-c") ) + use_selinux = 1; +#endif + #ifdef CONFIG_FEATURE_AUTOWIDTH ioctl(fileno(stdout), TIOCGWINSZ, &win); @@ -54,10 +66,31 @@ extern int ps_main(int argc, char **argv) terminal_width = win.ws_col - 1; #endif +#ifdef CONFIG_SELINUX + if(use_selinux) + printf(" PID Context Stat Command\n"); + else +#endif printf(" PID Uid VmSize Stat Command\n"); +#ifdef CONFIG_SELINUX + while ((p = procps_scan(1, use_selinux, &sid)) != 0) { +#else while ((p = procps_scan(1)) != 0) { +#endif char *namecmd = p->cmd; +#ifdef CONFIG_SELINUX + if(use_selinux) + { + char sbuf[128]; + len = sizeof(sbuf); + if(security_sid_to_context(sid, (security_context_t)&sbuf, &len)) + strcpy(sbuf, "unknown"); + + len = printf("%5d %-32s %s ", p->pid, sbuf, p->state); + } + else +#endif if(p->rss == 0) len = printf("%5d %-8s %s ", p->pid, p->user, p->state); else diff --git a/procps/top.c b/procps/top.c index b70a42a72..2e1bd3286 100644 --- a/procps/top.c +++ b/procps/top.c @@ -501,7 +501,11 @@ int top_main(int argc, char **argv) /* read process IDs & status for all the processes */ procps_status_t * p; +#ifdef CONFIG_SELINUX + while ((p = procps_scan(0, 0, NULL) ) != 0) { +#else while ((p = procps_scan(0)) != 0) { +#endif int n = ntop; top = xrealloc(top, (++ntop)*sizeof(procps_status_t)); |