From: Ryan Bloom Date: Thu, 27 Jun 2002 06:07:58 +0000 (+0000) Subject: Fix a long-standing bug in 2.0, CGI scripts were being called X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=352c8eed0eb4df5a835c298a0e852da1a1f5cf0a;p=apache Fix a long-standing bug in 2.0, CGI scripts were being called with relative paths instead of absolute paths. Apache 1.3 used absolute paths for everything except for SuExec, this brings back that standard. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@95899 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index bfae68757b..25358a51ff 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,10 @@ Changes with Apache 2.0.40 + *) Fix a long-standing bug in 2.0, CGI scripts were being called + with relative paths instead of absolute paths. Apache 1.3 used + absolute paths for everything except for SuExec, this brings back + that standard. [Ryan Bloom] + *) Fix infinite loop due to two HTTP_IN filters being present for internally redirected requests. PR 10146. [Justin Erenkrantz] diff --git a/modules/generators/mod_cgi.c b/modules/generators/mod_cgi.c index b38a605d19..6fc59dd2dd 100644 --- a/modules/generators/mod_cgi.c +++ b/modules/generators/mod_cgi.c @@ -513,13 +513,7 @@ static apr_status_t default_build_command(const char **cmd, const char ***argv, const char *args = NULL; if (e_info->process_cgi) { - /* Allow suexec's "/" check to succeed */ - const char *argv0 = strrchr(r->filename, '/'); - if (argv0 != NULL) - argv0++; - else - argv0 = r->filename; - *cmd = argv0; + *cmd = r->filename; args = r->args; /* Do not process r->args if they contain an '=' assignment */ diff --git a/os/unix/unixd.c b/os/unix/unixd.c index c21868e388..515c430443 100644 --- a/os/unix/unixd.c +++ b/os/unix/unixd.c @@ -326,11 +326,22 @@ static apr_status_t ap_unix_create_privileged_process( const char **newargs; char *newprogname; char *execuser, *execgroup; + const char *argv0; if (!unixd_config.suexec_enabled) { return apr_proc_create(newproc, progname, args, env, attr, p); } + argv0 = strrchr(progname, '/'); + /* Allow suexec's "/" check to succeed */ + if (argv0 != NULL) { + argv0++; + } + else { + argv0 = progname; + } + + if (ugid->userdir) { execuser = apr_psprintf(p, "~%ld", (long) ugid->uid); } @@ -355,7 +366,7 @@ static apr_status_t ap_unix_create_privileged_process( newargs[0] = SUEXEC_BIN; newargs[1] = execuser; newargs[2] = execgroup; - newargs[3] = apr_pstrdup(p, progname); + newargs[3] = apr_pstrdup(p, argv0); /* ** using a shell to execute suexec makes no sense thus