summaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
Diffstat (limited to 'procps')
-rw-r--r--procps/ps.c33
-rw-r--r--procps/top.c4
2 files changed, 37 insertions, 0 deletions
diff --git a/procps/ps.c b/procps/ps.c
index 5ccac7a..691f490 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 b70a42a..2e1bd32 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));