commit e9292b7acff19655482c6b53ff19f8c51f06bdcd
parent ecf782f0557effe122f791f839a509ec428d236e
Author: Christoph Lohmann <20h@r-36.net>
Date: Wed, 7 Feb 2018 19:59:31 +0100
Merge branch 'master' of /srv/git/geomyidae
Diffstat:
5 files changed, 39 insertions(+), 45 deletions(-)
diff --git a/README b/README
@@ -3,7 +3,7 @@ A gopherd for Linux/BSD.
Features:
* gopher menus (see index.gph for an example)
* dir listings (if no index.gph was found)
- * cgi support (.cgi files are executed)
+ * CGI support (.cgi files are executed)
* search support in CGI files
* logging (-l option) and loglevels (-v option)
diff --git a/geomyidae.8 b/geomyidae.8
@@ -328,6 +328,13 @@ All terms are tab-separated (per gopher protocol) which can cause some
surprises depending on how a script is written. See the CGI file (included
in the geomyidae source archive) for further elaboration.
.Pp
+QUIRK: The original gopher client tried to be too intelligent. It is using
+gopher+ when you request some resource. When "search" is just the value "+",
+"!", "$" or empty, geomyidae will display a gopher+ redirect instead of invoking the
+script. Be careful to design your search script so the user is unlikely to
+enter those values. The designers of gopher+ did not think of classic gopher
+to survive. It survived gopher+.
+.Pp
Additionally to the above arguments several environment variables are set.
.Pp
.Dl GATEWAY_INTERFACE = `CGI/1.1'
@@ -442,7 +449,7 @@ recursions, and/or unintended writes in the working directory.
The log file (ie. /var/log/gopherd.log) has the following structure:
.
.Pp
-.Ic [<date>|<IP:port>] <item path> <query> (<status>)
+.Ic [<date>|<IP/Host>|<port>|<status>] <item path>
.
.Pp
where,
@@ -452,40 +459,40 @@ where,
= access date and time (std 'date' format)
.Pp
ex.
-.Qq "Sun Feb 17 06:11:10 PST 2008"
-.It Ic <IP:port>
-= client IP address and port served
-.Pp
-ex.
-.Qq "24.208.18.127:16857"
-.It Ic <item path>
-= full path to item served
+.Qq "2018-01-31 14:18:34 +0000"
+.It Ic <IP/Host>
+= client IP/Host served
.Pp
ex.
-.D1 Qo "/PICS/simple2.jpg" Qc for an image file
-.D1 Qo "/PICS" Qc for a directory access
-.It Ic <query>
-= query term submitted (Type 7 requests only)
+.Qq "104.23.33.1"
+.It Ic <port>
+= client port served
.Pp
ex.
-.Dl % snarf Qq "gopher://frog.bog/7/hello.cgi?Christoph"
-.Dl would log Qo "Christoph" Qc as the query term.
-.It Ic (<status>)
+.Qq "16857"
+.It Ic <status>
= status of client request
.Pp
ex. - some common status entries:
-.It Qo (serving) Qc
+.It Qo serving Qc
=> a successful request
-.It Qo (not found) Qc
+.It Qo not found Qc
=> an unsuccessful request
-.It Qo (HTTP redirect) Qc
+.It Qo HTTP redirect Qc
=> web link redirect (Type h)
-.It Qo (dir listing) Qc
+.It Qo dir listing Qc
=> unindexed directory listing
+.Pp
+.It Ic <item path>
+= full path to item served
+.Pp
+ex.
+.D1 Qo "/PICS/simple2.jpg" Qc for an image file
+.D1 Qo "/PICS" Qc for a directory access
.El
.
.Sh FILES
-README, LICENSE, CGI, index.gph, rc.d/
+README, LICENSE, CGI, index.gph, rc.d/, LINKS, gph/
.
.Sh SEE ALSO
Links for further information on gopher:
diff --git a/ind.c b/ind.c
@@ -262,7 +262,6 @@ getadv(char *str)
char *b, *e, *o, *bo;
Elems *ret;
-
ret = xcalloc(1, sizeof(Elems));
if (strchr(str, '\t')) {
@@ -387,20 +386,6 @@ printelem(int fd, Elems *el, char *addr, char *port)
return 0;
}
-int
-initlogging(char *logf)
-{
- return open(logf, O_APPEND | O_WRONLY | O_CREAT, 0644);
-}
-
-void
-stoplogging(int fd)
-{
- close(fd);
-
- return;
-}
-
char *
smprintf(char *fmt, ...)
{
diff --git a/ind.h b/ind.h
@@ -46,8 +46,6 @@ void addindexs(Indexs *idx, Elems *el);
void addelem(Elems *e, char *s);
void freeindex(Indexs *i);
void freeelem(Elems *e);
-int initlogging(char *logf);
-void stoplogging(int fd);
char *smprintf(char *fmt, ...);
char *reverselookup(char *host);
void setcgienviron(char *file, char *path, char *port, char *base,
diff --git a/main.c b/main.c
@@ -247,8 +247,10 @@ sighandler(int sig)
case SIGABRT:
case SIGTERM:
case SIGKILL:
- if (logfile != nil)
- stoplogging(glfd);
+ if (logfile != nil && glfd != -1) {
+ close(glfd);
+ glfd = -1;
+ }
if (listfd >= 0) {
shutdown(listfd, SHUT_RDWR);
close(listfd);
@@ -448,9 +450,9 @@ main(int argc, char *argv[])
}
if (logfile != nil) {
- glfd = initlogging(logfile);
+ glfd = open(logfile, O_APPEND | O_WRONLY | O_CREAT, 0644);
if (glfd < 0) {
- perror("initlogging");
+ perror("log");
return 1;
}
} else if (!dofork) {
@@ -573,8 +575,10 @@ main(int argc, char *argv[])
shutdown(listfd, SHUT_RDWR);
close(listfd);
- if (logfile != nil)
- stoplogging(glfd);
+ if (logfile != nil && glfd != -1) {
+ close(glfd);
+ glfd = -1;
+ }
free(ohost);
return 0;