[BusyBox-cvs] busybox/procps ps.c,1.48,1.49 top.c,1.6,1.7
Erik Andersen
andersen at busybox.net
Thu Jul 3 10:07:07 UTC 2003
Update of /var/cvs/busybox/procps
In directory winder:/tmp/cvs-serv27387/procps
Modified Files:
ps.c top.c
Log Message:
Patch from Russell Coker:
I've attached my latest SE Linux patch for busybox against the latest CVS
version of busybox.
Index: ps.c
===================================================================
RCS file: /var/cvs/busybox/procps/ps.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- ps.c 5 Dec 2002 07:24:06 -0000 1.48
+++ ps.c 3 Jul 2003 10:07:03 -0000 1.49
@@ -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 @@
#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 @@
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
Index: top.c
===================================================================
RCS file: /var/cvs/busybox/procps/top.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- top.c 19 Mar 2003 09:12:49 -0000 1.6
+++ top.c 3 Jul 2003 10:07:03 -0000 1.7
@@ -501,7 +501,11 @@
/* 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));
More information about the busybox-cvs
mailing list