chdir to the bin-path dir before exec()ing the to-be-spawned fastcgi backend

- fixes #331


git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-merge-1.4.x@926 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.11
Jan Kneschke 18 years ago
parent 5da3530140
commit 4a86d31562

@ -904,6 +904,7 @@ static int fcgi_spawn_connection(server *srv,
switch ((child = fork())) {
case 0: {
size_t i = 0;
char *c;
char_array env;
char_array arg;
@ -966,6 +967,18 @@ static int fcgi_spawn_connection(server *srv,
env.ptr[env.used] = NULL;
/* chdir into the base of the bin-path,
* search for the last / */
if (NULL != (c = strrchr(host->bin_path->ptr, '/'))) {
*c = '\0';
/* change to the physical directory */
if (-1 == chdir(host->bin_path->ptr)) {
log_error_write(srv, __FILE__, __LINE__, "ssb", "chdir failed:", strerror(errno), host->bin_path);
}
*c = '/';
}
parse_binpath(&arg, host->bin_path);
/* exec the cgi */

Loading…
Cancel
Save