diff options
author | florian | 2014-04-16 14:43:43 +0000 |
---|---|---|
committer | Wynn Wolf Arbor | 2020-05-24 12:33:55 +0200 |
commit | aff2da75984cb4b216ac47d4603dd5618d0942f7 (patch) | |
tree | 1e4843853d43a52371dc4ce8e44b4768646213f9 | |
parent | 66a9a2015cd5871e5df35a3c793153c151c30812 (diff) | |
download | slowcgi-aff2da75984cb4b216ac47d4603dd5618d0942f7.tar.gz |
My previous attempt to chdir(2) to the directory containing the cgi script was not quite right. slowcgi would try to chdir("") with a SCRIPT_NAME of /foo.cgi; chdir("/") in that case. I'm not sure how one would configure nginx/slowcgi to get to that point though. OK benno@
-rw-r--r-- | slowcgi.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: slowcgi.c,v 1.30 2014/04/14 19:25:48 florian Exp $ */ +/* $OpenBSD: slowcgi.c,v 1.31 2014/04/16 14:43:43 florian Exp $ */ /* * Copyright (c) 2013 David Gwynne <dlg@openbsd.org> * Copyright (c) 2013 Florian Obser <florian@openbsd.org> @@ -894,10 +894,15 @@ exec_cgi(struct request *c) 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 = '/'; + if (path != c->script_name) { + *path = '\0'; + if (chdir(c->script_name) == -1) + lwarn("cannot chdir to %s", + c->script_name); + *path = '/'; + } else + if (chdir("/") == -1) + lwarn("cannot chdir to /"); } argv[0] = c->script_name; |