diff -uprk.orig SimplePAMApps-0.60.orig/common/lib/shell_args.c SimplePAMApps-0.60/common/lib/shell_args.c --- SimplePAMApps-0.60.orig/common/lib/shell_args.c 2003-01-12 22:44:38 +0300 +++ SimplePAMApps-0.60/common/lib/shell_args.c 2003-01-12 22:44:51 +0300 @@ -91,6 +91,8 @@ char * const *build_shell_args(const cha if (tmpb != NULL && tmpb[0] == '/' /* something (full path) */ && ( login || arg_no == 1 ) /* login, or single arg shells */ ) { + const char *bname; + char *bshell; use_default = 0; /* we will use this shell */ D(("commited to using user's shell")); @@ -107,9 +109,9 @@ char * const *build_shell_args(const cha /* get a string long enough for all the arguments */ - D(("an array of size %d chars", 2+strlen(tmpb) + D(("an array of size %d chars", 1+strlen(tmpb) + ( command ? 4:0 ))); - line = (char *) malloc(2+strlen(tmpb) + line = (char *) malloc(1+strlen(tmpb) + ( command ? 4:0 )); if (line == NULL) { free(args); @@ -118,8 +120,7 @@ char * const *build_shell_args(const cha /* fill array - tmpb points to start of first non-space char */ - line[0] = '-'; - strcpy(line+1, tmpb); + strcpy(line, tmpb); /* append " -c" to line? */ if (command) { @@ -129,16 +130,24 @@ char * const *build_shell_args(const cha D(("complete command: %s [+] %s", line, command)); tmp = strtok(line, " \t"); - D(("command path=%s", line+1)); - args[0] = line+1; + D(("command path=%s", line)); + args[0] = line; - if (login) { /* standard procedure for login shell */ - D(("argv[0]=%s", line)); - args[i=1] = line; - } else { /* not a login shell -- for use with su */ - D(("argv[0]=%s", line+1)); - args[i=1] = line+1; + bname = basename(line); + bshell = (char *) malloc( 1 + strlen(bname) + (login?1:0) ); + if ( !bshell ) { + free(args); + return NULL; } + if ( login ) { /* standard procedure for login shell */ + bshell[0] = '-'; + strcpy( bshell + 1, bname ); + } else { /* not a login shell -- for use with su */ + strcpy( bshell, bname ); + } + + D(("argv[0]=%s", bshell)); + args[i=1] = bshell; while ((tmp = strtok(NULL, " \t"))) { D(("adding argument %d: %s",i,tmp)); @@ -167,8 +176,8 @@ char * const *build_shell_args(const cha if (args == NULL) { return NULL; } - args[1] = DEFAULT_SHELL; /* mapped to argv[0] (NOT login shell) */ - args[0] = args[1]; /* path to program */ + args[0] = DEFAULT_SHELL; /* path to program (NOT login shell) */ + args[1] = basename(args[0]); /* mapped to argv[0] */ if (command) { args[2] = "-c"; /* should perform command and exit */ args[3] = command; /* the desired command */