1
0
forked from aniani/gmnisrv

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

View File

@ -145,6 +145,10 @@ serve_cgi(struct gmnisrv_client *client, const char *path,
dup2(pfd[1], STDOUT_FILENO); dup2(pfd[1], STDOUT_FILENO);
close(pfd[1]); 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 // 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 // going to die soon anyway so let's just be hip and call it an
// arena allocator :^) // arena allocator :^)