geomyidae

A small C-based gopherd. (gopher://bitreich.org/1/scm/geomyidae)
git clone git://r-36.net/geomyidae
Log | Files | Refs | README | LICENSE

commit bb858e05c4c1e15bd54b5bcb37ebac0f9356af47
parent 708d5eec1eaa6e7b3189515adcc353ff4058d592
Author: Christoph Lohmann <20h@r-36.net>
Date:   Wed, 16 Mar 2011 06:26:06 +0100

Trying to fix the base path.

Diffstat:
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, char *args, 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;