1
0
mirror of https://git.sr.ht/~sircmpwn/gmnisrv synced 2024-12-04 14:46:42 -05:00

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);
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 :^)