diff options
Diffstat (limited to 'pam_exec.c')
-rw-r--r-- | pam_exec.c | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -67,15 +67,18 @@ static int append_arg(pam_handle_t* pamh, int item, char* name, char* (*pargv[]) static int do_exec(pam_handle_t *pamh, const char *function, int argc, const char* argv[]) { int debug=0, ret=PAM_SUCCESS, i; + char *args=NULL; #define ARGS_MAX 9 char **pass_argv; - pid_t child; + pid_t child; pass_argv=calloc(ARGS_MAX, sizeof(char*)); for (i = 0; i < argc; i++) { if (!strncmp (argv[i], "exec=", 5)) pass_argv[0] = argv[i] + 5; + if (!strncmp (argv[i], "args=", 5)) + args = argv[i] + 5; else if (!strcmp (argv[i], "debug")) debug=1; else @@ -86,6 +89,8 @@ static int do_exec(pam_handle_t *pamh, const char *function, int argc, const cha return PAM_SYSTEM_ERR; } else { pass_argv[1] = function; + if(args) + pass_argv[2] = args; } if((ret=append_arg(pamh, PAM_USER, "user", &pass_argv)) != PAM_SUCCESS) { @@ -139,7 +144,11 @@ static int do_exec(pam_handle_t *pamh, const char *function, int argc, const cha } } out: - for(i=2; i < ARGS_MAX; i++) { /* don't free argv[0] and function */ + if(!args) + i=2; /* don't free argv[0] and function */ + else + i=3; /* don't free argv[0], function and args */ + for(; i < ARGS_MAX; i++) { if(pass_argv[i] != NULL) free(pass_argv[i]); else |