Introduction
Introduction Statistics Contact Development Disclaimer Help
Now scripts are run in their directory. - geomyidae - A small C-based gopherd.
git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfri…
Log
Files
Refs
Tags
README
LICENSE
---
commit 8df91710dfdf1f9091be9ed40a259933c7b62951
parent bb858e05c4c1e15bd54b5bcb37ebac0f9356af47
Author: Christoph Lohmann <[email protected]>
Date: Wed, 16 Mar 2011 06:37:10 +0100
Now scripts are run in their directory.
Diffstat:
M handlr.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
---
diff --git a/handlr.c b/handlr.c
@@ -194,7 +194,7 @@ void
handledcgi(int sock, char *file, char *port, char *base, char *args,
char *sear)
{
- char *p, *ln, addr[512];
+ char *p, *path, *ln, addr[512];
int outpipe[2];
Elems *el;
@@ -203,6 +203,15 @@ handledcgi(int sock, char *file, char *port, char *base, c…
if(pipe(outpipe) < 0)
return;
+ path = gstrdup(file);
+ p = strrchr(path, '/');
+ if (p != nil)
+ p[1] = '\0';
+ else {
+ free(path);
+ path = nil;
+ }
+
p = strrchr(file, '/');
if(p == nil)
p = file;
@@ -224,6 +233,8 @@ handledcgi(int sock, char *file, char *port, char *base, ch…
case 0:
dup2(outpipe[1], 1);
close(outpipe[0]);
+ if (path != nil)
+ chdir(path);
execl(file, p, sear, args, (char *)nil);
case -1:
break;
@@ -242,6 +253,8 @@ handledcgi(int sock, char *file, char *port, char *base, ch…
tprintf(sock, "\r\n.\r\n\r\n");
wait(NULL);
+ if (path != nil)
+ free(path);
shutdown(sock, SHUT_RDWR);
close(sock);
break;
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.