diff options
author | Rob Landley <rob@landley.net> | 2005-05-03 06:25:50 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2005-05-03 06:25:50 +0000 |
commit | 60158cb93eb0b3207dd1084cdf5bdd9226bd9e89 (patch) | |
tree | fe97ec71775deb1f3078c6db0cb8db554bc6b76f /libbb | |
parent | 988a78c61cffe91b005d37f0b7d6e2cb2c5ea713 (diff) | |
download | busybox-w32-60158cb93eb0b3207dd1084cdf5bdd9226bd9e89.tar.gz busybox-w32-60158cb93eb0b3207dd1084cdf5bdd9226bd9e89.tar.bz2 busybox-w32-60158cb93eb0b3207dd1084cdf5bdd9226bd9e89.zip |
A patch from Takeharu KATO to update/fix SE-Linux support.
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/find_pid_by_name.c | 7 | ||||
-rw-r--r-- | libbb/procps.c | 15 | ||||
-rw-r--r-- | libbb/run_shell.c | 43 |
3 files changed, 37 insertions, 28 deletions
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c index 930710f32..570e7bd93 100644 --- a/libbb/find_pid_by_name.c +++ b/libbb/find_pid_by_name.c | |||
@@ -45,11 +45,8 @@ extern long* find_pid_by_name( const char* pidName) | |||
45 | procps_status_t * p; | 45 | procps_status_t * p; |
46 | 46 | ||
47 | pidList = xmalloc(sizeof(long)); | 47 | pidList = xmalloc(sizeof(long)); |
48 | #ifdef CONFIG_SELINUX | 48 | while ((p = procps_scan(0)) != 0) |
49 | while ((p = procps_scan(0, 0, NULL)) != 0) { | 49 | { |
50 | #else | ||
51 | while ((p = procps_scan(0)) != 0) { | ||
52 | #endif | ||
53 | if (strncmp(p->short_cmd, pidName, COMM_LEN-1) == 0) { | 50 | if (strncmp(p->short_cmd, pidName, COMM_LEN-1) == 0) { |
54 | pidList=xrealloc( pidList, sizeof(long) * (i+2)); | 51 | pidList=xrealloc( pidList, sizeof(long) * (i+2)); |
55 | pidList[i++]=p->pid; | 52 | pidList[i++]=p->pid; |
diff --git a/libbb/procps.c b/libbb/procps.c index e405fb7ef..72f627f15 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
@@ -16,11 +16,7 @@ | |||
16 | 16 | ||
17 | #include "libbb.h" | 17 | #include "libbb.h" |
18 | 18 | ||
19 | extern procps_status_t * procps_scan(int save_user_arg0 | 19 | extern procps_status_t * procps_scan(int save_user_arg0) |
20 | #ifdef CONFIG_SELINUX | ||
21 | , int use_selinux , security_id_t *sid | ||
22 | #endif | ||
23 | ) | ||
24 | { | 20 | { |
25 | static DIR *dir; | 21 | static DIR *dir; |
26 | struct dirent *entry; | 22 | struct dirent *entry; |
@@ -60,16 +56,9 @@ extern procps_status_t * procps_scan(int save_user_arg0 | |||
60 | my_getpwuid(curstatus.user, sb.st_uid, sizeof(curstatus.user)); | 56 | my_getpwuid(curstatus.user, sb.st_uid, sizeof(curstatus.user)); |
61 | 57 | ||
62 | sprintf(status, "/proc/%d/stat", pid); | 58 | sprintf(status, "/proc/%d/stat", pid); |
59 | |||
63 | if((fp = fopen(status, "r")) == NULL) | 60 | if((fp = fopen(status, "r")) == NULL) |
64 | continue; | 61 | continue; |
65 | #ifdef CONFIG_SELINUX | ||
66 | if(use_selinux) | ||
67 | { | ||
68 | if(fstat_secure(fileno(fp), &sb, sid)) | ||
69 | continue; | ||
70 | } | ||
71 | else | ||
72 | #endif | ||
73 | name = fgets(buf, sizeof(buf), fp); | 62 | name = fgets(buf, sizeof(buf), fp); |
74 | fclose(fp); | 63 | fclose(fp); |
75 | if(name == NULL) | 64 | if(name == NULL) |
diff --git a/libbb/run_shell.c b/libbb/run_shell.c index 993b4e711..67ff2a5f8 100644 --- a/libbb/run_shell.c +++ b/libbb/run_shell.c | |||
@@ -37,7 +37,33 @@ | |||
37 | #include <ctype.h> | 37 | #include <ctype.h> |
38 | #include "libbb.h" | 38 | #include "libbb.h" |
39 | #ifdef CONFIG_SELINUX | 39 | #ifdef CONFIG_SELINUX |
40 | #include <proc_secure.h> | 40 | #include <selinux/selinux.h> /* for setexeccon */ |
41 | #endif | ||
42 | |||
43 | #ifdef CONFIG_SELINUX | ||
44 | static security_context_t current_sid=NULL; | ||
45 | |||
46 | void | ||
47 | renew_current_security_context(void) | ||
48 | { | ||
49 | if (current_sid) | ||
50 | freecon(current_sid); /* Release old context */ | ||
51 | |||
52 | getcon(¤t_sid); /* update */ | ||
53 | |||
54 | return; | ||
55 | } | ||
56 | void | ||
57 | set_current_security_context(security_context_t sid) | ||
58 | { | ||
59 | if (current_sid) | ||
60 | freecon(current_sid); /* Release old context */ | ||
61 | |||
62 | current_sid=sid; | ||
63 | |||
64 | return; | ||
65 | } | ||
66 | |||
41 | #endif | 67 | #endif |
42 | 68 | ||
43 | /* Run SHELL, or DEFAULT_SHELL if SHELL is empty. | 69 | /* Run SHELL, or DEFAULT_SHELL if SHELL is empty. |
@@ -45,11 +71,7 @@ | |||
45 | If ADDITIONAL_ARGS is nonzero, pass it to the shell as more | 71 | If ADDITIONAL_ARGS is nonzero, pass it to the shell as more |
46 | arguments. */ | 72 | arguments. */ |
47 | 73 | ||
48 | void run_shell ( const char *shell, int loginshell, const char *command, const char **additional_args | 74 | void run_shell ( const char *shell, int loginshell, const char *command, const char **additional_args) |
49 | #ifdef CONFIG_SELINUX | ||
50 | , security_id_t sid | ||
51 | #endif | ||
52 | ) | ||
53 | { | 75 | { |
54 | const char **args; | 76 | const char **args; |
55 | int argno = 1; | 77 | int argno = 1; |
@@ -78,10 +100,11 @@ void run_shell ( const char *shell, int loginshell, const char *command, const c | |||
78 | } | 100 | } |
79 | args [argno] = 0; | 101 | args [argno] = 0; |
80 | #ifdef CONFIG_SELINUX | 102 | #ifdef CONFIG_SELINUX |
81 | if(sid) | 103 | if ( (current_sid) && (!setexeccon(current_sid)) ) { |
82 | execve_secure(shell, (char **) args, environ, sid); | 104 | freecon(current_sid); |
83 | else | 105 | execve(shell, (char **) args, environ); |
106 | } else | ||
84 | #endif | 107 | #endif |
85 | execv ( shell, (char **) args ); | 108 | execv ( shell, (char **) args ); |
86 | bb_perror_msg_and_die ( "cannot run %s", shell ); | 109 | bb_perror_msg_and_die ( "cannot run %s", shell ); |
87 | } | 110 | } |