forked from aniani/gmnisrv
1
0
Fork 0

Set CWD to cgi-bin when executing scripts

This commit is contained in:
Drew DeVault 2020-11-08 12:16:59 -05:00
parent 57f4fcdc41
commit ea2914efff
1 changed files with 4 additions and 0 deletions

View File

@ -145,6 +145,10 @@ serve_cgi(struct gmnisrv_client *client, const char *path,
dup2(pfd[1], STDOUT_FILENO);
close(pfd[1]);
char cwd[PATH_MAX + 1];
strcpy(cwd, path);
chdir(dirname(cwd));
// I don't feel like freeing this stuff and this process is
// going to die soon anyway so let's just be hip and call it an
// arena allocator :^)