diff options
author | Florian Obser <florian@cvs.openbsd.org> | 2014-04-13 08:46:21 +0000 |
---|---|---|
committer | Florian Obser <florian@cvs.openbsd.org> | 2014-04-13 08:46:21 +0000 |
commit | e1cbcc8a218bdbb19851bee87693773ffe070f97 (patch) | |
tree | 1a76e52f965224929fe3f265e486f813caecf5f5 /usr.sbin | |
parent | dd2780c25990b70c65888d43f6709e345db84f58 (diff) |
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@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/slowcgi/slowcgi.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/usr.sbin/slowcgi/slowcgi.c b/usr.sbin/slowcgi/slowcgi.c index 7c914f65788..8d947d32e8c 100644 --- a/usr.sbin/slowcgi/slowcgi.c +++ b/usr.sbin/slowcgi/slowcgi.c @@ -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) |