diff options
author | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-05-03 06:25:50 +0000 |
---|---|---|
committer | landley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2005-05-03 06:25:50 +0000 |
commit | 406bbe0151d55bb191d8f65e9dfb4b281c3396e8 (patch) | |
tree | fe97ec71775deb1f3078c6db0cb8db554bc6b76f /libbb/run_shell.c | |
parent | 6e34669c94a04dd5462996b1fdf85f7cbba02351 (diff) | |
download | busybox-w32-406bbe0151d55bb191d8f65e9dfb4b281c3396e8.tar.gz busybox-w32-406bbe0151d55bb191d8f65e9dfb4b281c3396e8.tar.bz2 busybox-w32-406bbe0151d55bb191d8f65e9dfb4b281c3396e8.zip |
A patch from Takeharu KATO to update/fix SE-Linux support.
git-svn-id: svn://busybox.net/trunk/busybox@10238 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb/run_shell.c')
-rw-r--r-- | libbb/run_shell.c | 43 |
1 files changed, 33 insertions, 10 deletions
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 | } |