diff options
author | florian | 2014-04-13 08:46:20 +0000 |
---|---|---|
committer | Wynn Wolf Arbor | 2020-05-24 12:33:55 +0200 |
commit | feeb9503d238a5bd3f5689dd65388114cb306fe8 (patch) | |
tree | 31ea94ec0d50fa7684cafb5b04cf1599ee6320cd | |
parent | 4e7c58a85289fd84aef1aebf1c8afb58b4322dd6 (diff) | |
download | slowcgi-feeb9503d238a5bd3f5689dd65388114cb306fe8.tar.gz |
httpd(8) did a chdir(2) to the directory containing the cgi script. As there might be scripts depending on this do the same in slowcgi(8).
pointed out and OK ratchov@
-rw-r--r-- | slowcgi.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: slowcgi.c,v 1.28 2014/03/17 13:39:29 florian Exp $ */ +/* $OpenBSD: slowcgi.c,v 1.29 2014/04/13 08:46:20 florian Exp $ */ /* * Copyright (c) 2013 David Gwynne <dlg@openbsd.org> * Copyright (c) 2013 Florian Obser <florian@openbsd.org> @@ -841,6 +841,7 @@ exec_cgi(struct request *c) pid_t pid; char *argv[2]; char **env; + char *path; i = 0; @@ -891,6 +892,14 @@ exec_cgi(struct request *c) close(s_out[1]); close(s_err[1]); + path = strrchr(c->script_name, '/'); + if (path != NULL) { + *path = '\0'; + if (chdir(c->script_name) == -1) + lwarn("cannot chdir to %s", c->script_name); + *path = '/'; + } + argv[0] = c->script_name; argv[1] = NULL; if ((env = calloc(c->env_count + 1, sizeof(char*))) == NULL) |