Introduction
Introduction Statistics Contact Development Disclaimer Help
Trying to fix the base path. - geomyidae - A small C-based gopherd.
git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfri…
Log
Files
Refs
Tags
README
LICENSE
---
commit bb858e05c4c1e15bd54b5bcb37ebac0f9356af47
parent 708d5eec1eaa6e7b3189515adcc353ff4058d592
Author: Christoph Lohmann <[email protected]>
Date: Wed, 16 Mar 2011 06:26:06 +0100
Trying to fix the base path.
Diffstat:
M handlr.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/handlr.c b/handlr.c
@@ -149,13 +149,22 @@ void
handlecgi(int sock, char *file, char *port, char *base, char *args,
char *sear)
{
- char *p;
+ char *p, *path;
USED(base);
USED(port);
+ path = gstrdup(file);
+ p = strrchr(path, '/');
+ if (p != nil)
+ p[1] = '\0';
+ else {
+ free(path);
+ path = nil;
+ }
+
p = strrchr(file, '/');
- if(p == nil)
+ if (p == nil)
p = file;
if(sear == nil)
@@ -166,11 +175,15 @@ handlecgi(int sock, char *file, char *port, char *base, c…
dup2(sock, 2);
switch(fork()) {
case 0:
+ if (path != nil)
+ chdir(path);
execl(file, p, sear, args, (char *)nil);
case -1:
break;
default:
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.