openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/login-utils/su-common.c
static void run_shell(struct su_context* su, char const* shell,
                      char const* command, char** additional_args,
                      size_t n_additional_args)
{
    size_t n_args =
        1 + su->fast_startup + 2 * !!command + n_additional_args + 1;
    const char** args = xcalloc(n_args, sizeof *args);
    size_t argno = 1;

    DBG(MISC, ul_debug("starting shell [shell=%s, command=\"%s\"%s%s]", shell,
                       command, su->simulate_login ? " login" : "",
                       su->fast_startup ? " fast-start" : ""));

    if (su->simulate_login)
    {
        char* arg0;
        char* shell_basename;

        shell_basename = basename(shell);
        arg0 = xmalloc(strlen(shell_basename) + 2);
        arg0[0] = '-';
        strcpy(arg0 + 1, shell_basename);
        args[0] = arg0;
    }
    else
        args[0] = basename(shell);

    if (su->fast_startup)
        args[argno++] = "-f";
    if (command)
    {
        args[argno++] = "-c";
        args[argno++] = command;
    }

    memcpy(args + argno, additional_args, n_additional_args * sizeof *args);
    args[argno + n_additional_args] = NULL;
    execv(shell, (char**)args);
    errexec(shell);
}
/* Run SHELL, if COMMAND is nonzero, pass it to the shell with the -c option.
 * Pass ADDITIONAL_ARGS to the shell as more arguments; there are
 * N_ADDITIONAL_ARGS extra arguments.
 */
Run SHELL, if COMMAND is nonzero, pass it to the shell with the -c option.
Pass ADDITIONAL_ARGS to the shell as more arguments; there are
N_ADDITIONAL_ARGS extra arguments.
Run SHELL if COMMAND is nonzero pass it to the shell with the - c option . Pass ADDITIONAL_ARGS to the shell as more arguments ; there are N_ADDITIONAL_ARGS extra arguments .
static void run_shell(struct su_context* su, char const* shell,
                      char const* command, char** additional_args,
                      size_t n_additional_args)
{
    size_t n_args =
        1 + su->fast_startup + 2 * !!command + n_additional_args + 1;
    const char** args = xcalloc(n_args, sizeof *args);
    size_t argno = 1;
    DBG(MISC, ul_debug("starting shell [shell=%s, command=\"%s\"%s%s]", shell,
                       command, su->simulate_login ? " login" : "",
                       su->fast_startup ? " fast-start" : ""));
    if (su->simulate_login)
    {
        char* arg0;
        char* shell_basename;
        shell_basename = basename(shell);
        arg0 = xmalloc(strlen(shell_basename) + 2);
        arg0[0] = '-';
        strcpy(arg0 + 1, shell_basename);
        args[0] = arg0;
    }
    else
        args[0] = basename(shell);
    if (su->fast_startup)
        args[argno++] = "-f";
    if (command)
    {
        args[argno++] = "-c";
        args[argno++] = command;
    }
    memcpy(args + argno, additional_args, n_additional_args * sizeof *args);
    args[argno + n_additional_args] = NULL;
    execv(shell, (char**)args);
    errexec(shell);
}
static void run_shell ( struct su_context * su , char const * shell , char const * command , char * * additional_args , size_t n_additional_args ) { size_t n_args = 1 + su -> fast_startup + 2 * ! ! command + n_additional_args + 1 ; const char * * args = xcalloc ( n_args , sizeof * args ) ; size_t argno = 1 ; DBG ( MISC , ul_debug ( " \" \" " , shell , command , su -> simulate_login ? " " : " " , su -> fast_startup ? " " : " " ) ) ; if ( su -> simulate_login ) { char * arg0 ; char * shell_basename ; shell_basename = basename ( shell ) ; arg0 = xmalloc ( strlen ( shell_basename ) + 2 ) ; arg0 [ 0 ] = ' ' ; strcpy ( arg0 + 1 , shell_basename ) ; args [ 0 ] = arg0 ; } else args [ 0 ] = basename ( shell ) ; if ( su -> fast_startup ) args [ argno ++ ] = " " ; if ( command ) { args [ argno ++ ] = " " ; args [ argno ++ ] = command ; } memcpy ( args + argno , additional_args , n_additional_args * sizeof * args ) ; args [ argno + n_additional_args ] = NULL ; execv ( shell , ( char * * ) args ) ; errexec ( shell ) ; }
Run SHELL, if COMMAND is nonzero, pass it to the shell with the -c option.
Run SHELL if COMMAND is nonzero pass it to the shell with the - c option .