*** suexec.c.orig Mon Jul 13 07:32:59 1998 --- suexec.c Thu Jul 23 10:28:51 1998 *************** *** 68,75 **** * *********************************************************************** * * ! */ #include "ap_config.h" #include --- 68,78 ---- * *********************************************************************** * + * Added ability for programs and parameters in suexec. *Keeps the + * security model!* - Theo Van Dinter * ! * ! * */ #include "ap_config.h" #include *************** *** 245,250 **** --- 248,256 ---- char *actual_gname; /* actual group name */ char *prog; /* name of this program */ char *cmd; /* command to be executed */ + char **param; /* ARGV for execv below */ + int param_count = 1; /* ARGC count for execv */ + char **param_tmp; /* temporary dual param pntr */ char cwd[AP_MAXPATH]; /* current working directory */ char dwd[AP_MAXPATH]; /* docroot working directory */ struct passwd *pw; /* password entry holder */ *************** *** 263,269 **** } target_uname = argv[1]; target_gname = argv[2]; ! cmd = argv[3]; /* * Check existence/validity of the UID of the user --- 269,307 ---- } target_uname = argv[1]; target_gname = argv[2]; ! ! ! /* ! * This section of code was added to support commandline parameters. ! * ! */ ! param = (char **) malloc(sizeof(char *) * 12); ! if ( param == NULL ) { /* malloc failed. */ ! log_err("malloc() call failed.\n"); ! exit(100); /* Error number? */ ! } ! ! cmd = param[0] = strtok( argv[3], " " ); ! ! do { ! if ( param_count % 10 == 0 ) /* Out of space */ ! { ! param_tmp = (char **) realloc(param, sizeof(char *) * ! (param_count+12)); ! if ( param_tmp == NULL ) /* Realloc failed */ ! { ! log_err("realloc() call failed.\n"); ! exit(100); /* What error to fail with? */ ! } ! ! if ( param_tmp != param ) { /* If we got a new addr. space, free the old one. */ ! free(param); ! param = param_tmp; ! } ! ! } ! } while ( (param[param_count++] = strtok( NULL, " " )) != NULL ); ! /* * Check existence/validity of the UID of the user *************** *** 506,512 **** /* * Execute the command, replacing our image with its own. */ ! execv(cmd, &argv[3]); /* * (I can't help myself...sorry.) --- 544,550 ---- /* * Execute the command, replacing our image with its own. */ ! execv(cmd, param); /* * (I can't help myself...sorry.)