run_shell.c: style fix
This commit is contained in:
parent
d25a2645f5
commit
797b4d210d
@ -41,27 +41,21 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SELINUX
|
#ifdef CONFIG_SELINUX
|
||||||
static security_context_t current_sid=NULL;
|
static security_context_t current_sid;
|
||||||
|
|
||||||
void
|
void
|
||||||
renew_current_security_context(void)
|
renew_current_security_context(void)
|
||||||
{
|
{
|
||||||
if (current_sid)
|
if (current_sid)
|
||||||
freecon(current_sid); /* Release old context */
|
freecon(current_sid); /* Release old context */
|
||||||
|
getcon(¤t_sid); /* update */
|
||||||
getcon(¤t_sid); /* update */
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
void
|
void
|
||||||
set_current_security_context(security_context_t sid)
|
set_current_security_context(security_context_t sid)
|
||||||
{
|
{
|
||||||
if (current_sid)
|
if (current_sid)
|
||||||
freecon(current_sid); /* Release old context */
|
freecon(current_sid); /* Release old context */
|
||||||
|
current_sid = sid;
|
||||||
current_sid=sid;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -71,37 +65,37 @@ set_current_security_context(security_context_t sid)
|
|||||||
If ADDITIONAL_ARGS is nonzero, pass it to the shell as more
|
If ADDITIONAL_ARGS is nonzero, pass it to the shell as more
|
||||||
arguments. */
|
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)
|
||||||
{
|
{
|
||||||
const char **args;
|
const char **args;
|
||||||
int argno = 1;
|
int argno = 1;
|
||||||
int additional_args_cnt = 0;
|
int additional_args_cnt = 0;
|
||||||
|
|
||||||
for ( args = additional_args; args && *args; args++ )
|
for (args = additional_args; args && *args; args++)
|
||||||
additional_args_cnt++;
|
additional_args_cnt++;
|
||||||
|
|
||||||
args = (const char **) xmalloc (sizeof (char *) * ( 4 + additional_args_cnt ));
|
args = xmalloc(sizeof(char*) * (4 + additional_args_cnt));
|
||||||
|
|
||||||
args [0] = bb_get_last_path_component ( xstrdup ( shell ));
|
args[0] = bb_get_last_path_component(xstrdup(shell));
|
||||||
|
|
||||||
if ( loginshell )
|
if (loginshell)
|
||||||
args [0] = xasprintf ("-%s", args [0]);
|
args[0] = xasprintf("-%s", args[0]);
|
||||||
|
|
||||||
if ( command ) {
|
if (command) {
|
||||||
args [argno++] = "-c";
|
args[argno++] = "-c";
|
||||||
args [argno++] = command;
|
args[argno++] = command;
|
||||||
}
|
}
|
||||||
if ( additional_args ) {
|
if (additional_args) {
|
||||||
for ( ; *additional_args; ++additional_args )
|
for (; *additional_args; ++additional_args)
|
||||||
args [argno++] = *additional_args;
|
args[argno++] = *additional_args;
|
||||||
}
|
}
|
||||||
args [argno] = 0;
|
args[argno] = NULL;
|
||||||
#ifdef CONFIG_SELINUX
|
#ifdef CONFIG_SELINUX
|
||||||
if ( (current_sid) && (!setexeccon(current_sid)) ) {
|
if (current_sid && !setexeccon(current_sid)) {
|
||||||
freecon(current_sid);
|
freecon(current_sid);
|
||||||
execve(shell, (char **) args, environ);
|
execve(shell, (char **) args, environ);
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
execv ( shell, (char **) args );
|
execv(shell, (char **) args);
|
||||||
bb_perror_msg_and_die ( "cannot run %s", shell );
|
bb_perror_msg_and_die("cannot run %s", shell);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user