summaryrefslogtreecommitdiffstats
path: root/usr.sbin/slowcgi
diff options
context:
space:
mode:
authorflorian <florian@openbsd.org>2014-04-13 08:46:20 +0000
committerflorian <florian@openbsd.org>2014-04-13 08:46:20 +0000
commit6bcf2ad3217ce98f9c19e43024cfb2cf30c78fc7 (patch)
tree3b64c4f1e7a569c2c33f20d3a3f77f6ac7eecd78 /usr.sbin/slowcgi
parentClean up last bits of TCP_WRAPPERS and ELF_TOOLCHAIN. (diff)
downloadwireguard-openbsd-6bcf2ad3217ce98f9c19e43024cfb2cf30c78fc7.tar.xz
wireguard-openbsd-6bcf2ad3217ce98f9c19e43024cfb2cf30c78fc7.zip
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/slowcgi')
-rw-r--r--usr.sbin/slowcgi/slowcgi.c11
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)