diff options
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 @@ | |||
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 | ||
35 | static const int TERMINAL_WIDTH = 79; /* not 80 in case terminal has linefold bug */ | 40 | static 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 |
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) | |||
501 | /* read process IDs & status for all the processes */ | 501 | /* read process IDs & status for all the processes */ |
502 | procps_status_t * p; | 502 | procps_status_t * p; |
503 | 503 | ||
504 | #ifdef CONFIG_SELINUX | ||
505 | while ((p = procps_scan(0, 0, NULL) ) != 0) { | ||
506 | #else | ||
504 | while ((p = procps_scan(0)) != 0) { | 507 | while ((p = procps_scan(0)) != 0) { |
508 | #endif | ||
505 | int n = ntop; | 509 | int n = ntop; |
506 | 510 | ||
507 | top = xrealloc(top, (++ntop)*sizeof(procps_status_t)); | 511 | top = xrealloc(top, (++ntop)*sizeof(procps_status_t)); |