*
*/
-#include "libbb.h"
-
-#if ! defined CONFIG_FEATURE_USE_DEVPS_PATCH
#include <dirent.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <asm/page.h>
+#include "libbb.h"
-extern procps_status_t * procps_scan(int save_user_arg0)
+extern procps_status_t * procps_scan(int save_user_arg0
+#ifdef CONFIG_SELINUX
+ , int use_selinux , security_id_t *sid
+#endif
+ )
{
static DIR *dir;
struct dirent *entry;
if (!dir) {
dir = opendir("/proc");
if(!dir)
- error_msg_and_die("Can't open /proc");
+ bb_error_msg_and_die("Can't open /proc");
}
for(;;) {
if((entry = readdir(dir)) == NULL) {
sprintf(status, "/proc/%d/stat", pid);
if((fp = fopen(status, "r")) == NULL)
continue;
+#ifdef CONFIG_SELINUX
+ if(use_selinux)
+ {
+ if(fstat_secure(fileno(fp), &sb, sid))
+ continue;
+ }
+ else
+#endif
if(fstat(fileno(fp), &sb))
continue;
my_getpwuid(curstatus.user, sb.st_uid);
curstatus.rss <<= (PAGE_SHIFT - 10); /* 2**10 = 1kb */
- sprintf(status, "/proc/%d/cmdline", pid);
if(save_user_arg0) {
+ sprintf(status, "/proc/%d/cmdline", pid);
if((fp = fopen(status, "r")) == NULL)
continue;
- if(fgets(buf, sizeof(buf), fp) != NULL) {
- name = strchr(buf, '\n');
- if(name != NULL)
- *name = 0;
+ if((n=fread(buf, 1, sizeof(buf)-1, fp)) > 0) {
+ if(buf[n-1]=='\n')
+ buf[--n] = 0;
+ name = buf;
+ while(n) {
+ if(((unsigned char)*name) < ' ')
+ *name = ' ';
+ name++;
+ n--;
+ }
+ *name = 0;
if(buf[0])
curstatus.cmd = strdup(buf);
/* if NULL it work true also */
}
}
-#endif /* CONFIG_FEATURE_USE_DEVPS_PATCH. Else this file is empty */
-
/* END CODE */
/*
Local Variables: