diff options
Diffstat (limited to 'slowcgi.c')
-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) |