From 9e48045e45df7e3e205575a4eb3dc39d634b05aa Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 3 Jul 2003 10:07:04 +0000 Subject: Patch from Russell Coker: I've attached my latest SE Linux patch for busybox against the latest CVS version of busybox. --- libbb/find_pid_by_name.c | 4 ++++ libbb/procps.c | 14 +++++++++++++- libbb/run_shell.c | 15 +++++++++++++-- 3 files changed, 30 insertions(+), 3 deletions(-) (limited to 'libbb') diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c index b6602b9..b8490b7 100644 --- a/libbb/find_pid_by_name.c +++ b/libbb/find_pid_by_name.c @@ -41,7 +41,11 @@ extern long* find_pid_by_name( const char* pidName) procps_status_t * p; pidList = xmalloc(sizeof(long)); +#ifdef CONFIG_SELINUX + while ((p = procps_scan(0, 0, NULL)) != 0) { +#else while ((p = procps_scan(0)) != 0) { +#endif if (strcmp(p->short_cmd, pidName) == 0) { pidList=xrealloc( pidList, sizeof(long) * (i+2)); pidList[i++]=p->pid; diff --git a/libbb/procps.c b/libbb/procps.c index 7df0718..44103fa 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -16,7 +16,11 @@ #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; @@ -53,6 +57,14 @@ extern procps_status_t * procps_scan(int save_user_arg0) 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); diff --git a/libbb/run_shell.c b/libbb/run_shell.c index 49e8a76..4855d76 100644 --- a/libbb/run_shell.c +++ b/libbb/run_shell.c @@ -36,14 +36,20 @@ #include #include #include "libbb.h" - +#ifdef CONFIG_SELINUX +#include +#endif /* Run SHELL, or DEFAULT_SHELL if SHELL is empty. If COMMAND is nonzero, pass it to the shell with the -c option. If ADDITIONAL_ARGS is nonzero, pass it to the shell as more arguments. */ -void run_shell ( const char *shell, int loginshell, const char *command, const char **additional_args ) +void run_shell ( const char *shell, int loginshell, const char *command, const char **additional_args +#ifdef CONFIG_SELINUX + , security_id_t sid +#endif +) { const char **args; int argno = 1; @@ -71,6 +77,11 @@ void run_shell ( const char *shell, int loginshell, const char *command, const c args [argno++] = *additional_args; } args [argno] = 0; +#ifdef CONFIG_SELINUX + if(sid) + execve_secure(shell, (char **) args, environ, sid); + else +#endif execv ( shell, (char **) args ); bb_perror_msg_and_die ( "cannot run %s", shell ); } -- cgit v1.1