Introduction
Introduction Statistics Contact Development Disclaimer Help
strip / at the end of the base path - geomyidae - A small C-based gopherd.
git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfri…
Log
Files
Refs
Tags
README
LICENSE
---
commit 2760fe803a9ea8574dd7fa57b17708f283b5dbe0
parent baf4df6c6481209962d0fa861dcbb6b9d69467a6
Author: Hiltjo Posthuma <[email protected]>
Date: Thu, 13 Sep 2018 20:42:13 +0200
strip / at the end of the base path
this fixes relative path handling when using:
geomyidae -b /var/gopher/ (added slash).
Signed-off-by: Christoph Lohmann <[email protected]>
Diffstat:
M main.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/main.c b/main.c
@@ -44,7 +44,7 @@ int revlookup = 1;
char *logfile = NULL;
char *argv0;
-char *stdbase = "/var/gopher";
+char stdbase[] = "/var/gopher";
char *stdport = "70";
char *indexf[] = {"/index.gph", "/index.cgi", "/index.dcgi", "/index.bin"};
char *nocgierr = "3Sorry, execution of the token '%s' was requested, but this "
@@ -374,7 +374,7 @@ main(int argc, char *argv[])
socklen_t cltlen;
int sock, dofork, inetf, usechroot, nocgi;
char *port, *base, clienth[NI_MAXHOST], clientp[NI_MAXSERV];
- char *user, *group, *bindip, *ohost, *sport;
+ char *user, *group, *bindip, *ohost, *sport, *p;
struct passwd *us;
struct group *gr;
@@ -538,6 +538,10 @@ main(int argc, char *argv[])
return 1;
}
+ /* strip / at the end, except if it is "/" */
+ for (p = base + strlen(base); p > base + 1 && p[-1] == '/'; --p)
+ p[-1] = '\0';
+
if (dropprivileges(gr, us) < 0) {
perror("dropprivileges");
close(listfd);
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.