mirror of
https://github.com/gophernicus/gophernicus.git
synced 2024-06-02 06:11:10 +00:00
Compare commits
20 Commits
c5eeaec4da
...
e93042f174
Author | SHA1 | Date | |
---|---|---|---|
|
e93042f174 | ||
|
d7c297ae5f | ||
|
f845dd97f6 | ||
|
1a089816fa | ||
|
a00fa5330d | ||
|
ac249aaeef | ||
|
4407583da3 | ||
|
af1aafbe0b | ||
|
103f21f50b | ||
|
7f1f3515f1 | ||
|
02fc3c3dc4 | ||
|
e318b1b294 | ||
|
3a8d4f007b | ||
|
d2007f675f | ||
|
5fd9e72ed3 | ||
|
1d79de712d | ||
|
1d6aeecfc7 | ||
|
74b3b0adfa | ||
|
9e7885f00f | ||
|
9f2767fde7 |
|
@ -22,7 +22,7 @@ Important configure arguments include:
|
||||||
|
|
||||||
- `--listener`. This is the only required argument. You must
|
- `--listener`. This is the only required argument. You must
|
||||||
choose a listener that passes network requests to
|
choose a listener that passes network requests to
|
||||||
gophernicus, as gophernicus dosen't do this by itself. The
|
gophernicus, as gophernicus doesn't do this by itself. The
|
||||||
options are:
|
options are:
|
||||||
- systemd, a common init system on many Linux distributions
|
- systemd, a common init system on many Linux distributions
|
||||||
that can do this without an external program.
|
that can do this without an external program.
|
||||||
|
@ -32,7 +32,7 @@ Important configure arguments include:
|
||||||
config files.
|
config files.
|
||||||
- mac, to be used on Mac OSX machines.
|
- mac, to be used on Mac OSX machines.
|
||||||
- haiku, to be used on Haiku machines.
|
- haiku, to be used on Haiku machines.
|
||||||
- autodetect, which looks at what you have avaliable
|
- autodetect, which looks at what you have available
|
||||||
(unrecommended, please manually specify where possible).
|
(unrecommended, please manually specify where possible).
|
||||||
- `--hostname`. This is by default attempted to be autodetected
|
- `--hostname`. This is by default attempted to be autodetected
|
||||||
by the configure script, using the command `hostname`. It is
|
by the configure script, using the command `hostname`. It is
|
||||||
|
@ -123,5 +123,5 @@ distribution? Thanks! Please see issue #50 to help. Some tips:
|
||||||
- You probably want to support as many listeners as possible.
|
- You probably want to support as many listeners as possible.
|
||||||
We allow this through the use of a comma seperated list to
|
We allow this through the use of a comma seperated list to
|
||||||
`--listener`.
|
`--listener`.
|
||||||
- The default gopher root is `/var/gopher`; many disributions
|
- The default gopher root is `/var/gopher`; many distributions
|
||||||
prefer `/srv`.
|
prefer `/srv`.
|
||||||
|
|
|
@ -142,7 +142,7 @@ install-man:
|
||||||
|
|
||||||
install-root:
|
install-root:
|
||||||
$(INSTALL) -d -m 755 $(DESTDIR)$(ROOT)
|
$(INSTALL) -d -m 755 $(DESTDIR)$(ROOT)
|
||||||
$(INSTALL) -m 644 $(MAP).sample $(DESTDIR)$(ROOT)/gophermap
|
[ ! -f $(DESTDIR)$(ROOT)/gophermap ] && $(INSTALL) -m 644 $(MAP).sample $(DESTDIR)$(ROOT)/gophermap
|
||||||
|
|
||||||
install-inetd-update: install-root
|
install-inetd-update: install-root
|
||||||
update-inetd --add "$$(sed -e "s:@BINARY_PATH@:$(SBINDIR)/$(BINARY):g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in)"
|
update-inetd --add "$$(sed -e "s:@BINARY_PATH@:$(SBINDIR)/$(BINARY):g" -e "s/@OPTIONS@/$(INETOPT)/g" init/inetlin.in)"
|
||||||
|
|
|
@ -178,7 +178,7 @@ directories and you're (kind of) up and running.
|
||||||
|
|
||||||
There is a serious issue with virtual hosting.
|
There is a serious issue with virtual hosting.
|
||||||
|
|
||||||
As stated previously, RFC1436 dosen't support virtual hosting. Clients won't
|
As stated previously, RFC1436 doesn't support virtual hosting. Clients won't
|
||||||
like it.
|
like it.
|
||||||
|
|
||||||
How the virtual hosting works, is that it loops through the vhosts looking for
|
How the virtual hosting works, is that it loops through the vhosts looking for
|
||||||
|
|
10
configure
vendored
10
configure
vendored
|
@ -16,7 +16,7 @@ usage() {
|
||||||
printf " --haikusrv=/boot/common/settings/network/services Path to services directory in Haiku\\n"
|
printf " --haikusrv=/boot/common/settings/network/services Path to services directory in Haiku\\n"
|
||||||
printf " --systemd=/lib/systemd/system Path to systemd directory when using systemd listener\\n"
|
printf " --systemd=/lib/systemd/system Path to systemd directory when using systemd listener\\n"
|
||||||
printf " --os=autodetected Your target OS, one of linux, mac, haiku, netbsd, openbsd or freebsd\\n"
|
printf " --os=autodetected Your target OS, one of linux, mac, haiku, netbsd, openbsd or freebsd\\n"
|
||||||
printf " --listener=somelistener Program to recieve and pass network requests; one or more of systemd, inetd, xinetd, comma-seperated, or autodetect, mac or haiku (parameter required, mac/haiku required on respective OSes)\\n"
|
printf " --listener=somelistener Program to receive and pass network requests; one or more of systemd, inetd, xinetd, comma-seperated, or autodetect, mac or haiku (parameter required, mac/haiku required on respective OSes)\\n"
|
||||||
printf " --hostname=autodetected Desired hostname for gophernicus to identify as\\n"
|
printf " --hostname=autodetected Desired hostname for gophernicus to identify as\\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,9 +113,9 @@ else
|
||||||
# Check it has required features (*cough* macos)
|
# Check it has required features (*cough* macos)
|
||||||
mkdir testconf
|
mkdir testconf
|
||||||
touch testfile
|
touch testfile
|
||||||
${INSTALL} -t testconf testfile 2>&1 >/dev/null || INSTALL=build-aux/install-sh
|
${INSTALL} -t testconf testfile >/dev/null 2>&1 || INSTALL=build-aux/install-sh
|
||||||
rm testconf/testfile
|
rm testconf/testfile
|
||||||
${INSTALL} -T testfile testconf/testfile 2>&1 >/dev/null || INSTALL=build-aux/install-sh
|
${INSTALL} -T testfile testconf/testfile >/dev/null 2>&1 || INSTALL=build-aux/install-sh
|
||||||
rm -r testconf testfile
|
rm -r testconf testfile
|
||||||
printf "%s" "${INSTALL}"
|
printf "%s" "${INSTALL}"
|
||||||
fi
|
fi
|
||||||
|
@ -236,7 +236,7 @@ if [ "${HOSTNAME}" = "autodetect" ]; then
|
||||||
fi
|
fi
|
||||||
printf "%s\\n" "${HOSTNAME}"
|
printf "%s\\n" "${HOSTNAME}"
|
||||||
|
|
||||||
# Use libwrap when it is avaliable
|
# Use libwrap when it is available
|
||||||
printf "checking for libwrap... "
|
printf "checking for libwrap... "
|
||||||
cat > conftest.c <<EOF
|
cat > conftest.c <<EOF
|
||||||
#include <tcpd.h>
|
#include <tcpd.h>
|
||||||
|
@ -251,7 +251,7 @@ else
|
||||||
fi
|
fi
|
||||||
printf "\\n"
|
printf "\\n"
|
||||||
|
|
||||||
# Check and use SHM if avaliable
|
# Check and use SHM if available
|
||||||
printf "checking for ipcrm (SHM management)... "
|
printf "checking for ipcrm (SHM management)... "
|
||||||
if ! IPCRM="$(command -v ipcrm)"; then
|
if ! IPCRM="$(command -v ipcrm)"; then
|
||||||
printf "not found"
|
printf "not found"
|
||||||
|
|
|
@ -196,9 +196,7 @@ Disable execution of gophermaps and scripts.
|
||||||
Disable HTTP response to HTTP GET and POST requests.
|
Disable HTTP response to HTTP GET and POST requests.
|
||||||
.It Fl d
|
.It Fl d
|
||||||
Print debug output in
|
Print debug output in
|
||||||
.Xr syslog 3
|
.Xr syslog 3 .
|
||||||
and
|
|
||||||
.Pa /server-status .
|
|
||||||
When
|
When
|
||||||
.Fl ns
|
.Fl ns
|
||||||
(disable
|
(disable
|
||||||
|
|
|
@ -107,10 +107,13 @@ void send_text_file(state *st)
|
||||||
*/
|
*/
|
||||||
void url_redirect(state *st)
|
void url_redirect(state *st)
|
||||||
{
|
{
|
||||||
char dest[BUFSIZE];
|
char unsafe[BUFSIZE];
|
||||||
|
|
||||||
/* Basic security checking */
|
/* Basic security checking */
|
||||||
sstrlcpy(dest, st->req_selector + 4);
|
sstrlcpy(unsafe, st->req_selector + 4);
|
||||||
|
|
||||||
|
char dest[BUFSIZE];
|
||||||
|
html_encode(unsafe, dest, BUFSIZE);
|
||||||
|
|
||||||
if (sstrncmp(dest, "http://") != MATCH &&
|
if (sstrncmp(dest, "http://") != MATCH &&
|
||||||
sstrncmp(dest, "https://") != MATCH &&
|
sstrncmp(dest, "https://") != MATCH &&
|
||||||
|
@ -374,7 +377,7 @@ static void run_cgi(state *st, char *script, char *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Didn't work - die */
|
/* Didn't work - die */
|
||||||
die(st, ERR_ACCESS, NULL);
|
die(st, ERR_ACCESS, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,27 @@ void footer(state *st)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void html_encode(const char *unsafe, char *dest, int bufsize)
|
||||||
|
{
|
||||||
|
char literals[] = "!#$&'()*+,/:;=?@[]-_.~";
|
||||||
|
int i = 0, j = 0;
|
||||||
|
while (unsafe[i] != '\0') {
|
||||||
|
if (j >= bufsize - 5) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (strchr(literals, unsafe[i]) ||
|
||||||
|
(unsafe[i] >= 'a' && unsafe[i] <= 'z') ||
|
||||||
|
(unsafe[i] >= 'A' && unsafe[i] <= 'Z') ||
|
||||||
|
(unsafe[i] >= '0' && unsafe[i] <= '9')) {
|
||||||
|
dest[j] = unsafe[i];
|
||||||
|
i += 1;
|
||||||
|
j += 1;
|
||||||
|
} else {
|
||||||
|
j += snprintf(&dest[j], BUFSIZE - j, "%%%02x", unsafe[i]);
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Print error message & exit
|
* Print error message & exit
|
||||||
|
@ -134,13 +155,17 @@ void die(state *st, const char *message, const char *description)
|
||||||
|
|
||||||
/* Handle HTML errors */
|
/* Handle HTML errors */
|
||||||
else if (st->req_filetype == TYPE_HTML) {
|
else if (st->req_filetype == TYPE_HTML) {
|
||||||
|
char safe_message[BUFSIZE];
|
||||||
|
html_encode(message, safe_message, BUFSIZE);
|
||||||
|
char safe_description[BUFSIZE];
|
||||||
|
html_encode(description, safe_description, BUFSIZE);
|
||||||
printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n"
|
printf("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n"
|
||||||
"<HTML>\n<HEAD>\n"
|
"<HTML>\n<HEAD>\n"
|
||||||
" <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;charset=iso-8859-1\">\n"
|
" <META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;charset=iso-8859-1\">\n"
|
||||||
" <TITLE>" ERROR_PREFIX "%1$s %2$s</TITLE>\n"
|
" <TITLE>" ERROR_PREFIX "%1$s %2$s</TITLE>\n"
|
||||||
"</HEAD>\n<BODY>\n"
|
"</HEAD>\n<BODY>\n"
|
||||||
"<STRONG>" ERROR_PREFIX "%1$s %2$s</STRONG>\n"
|
"<STRONG>" ERROR_PREFIX "%1$s %2$s</STRONG>\n"
|
||||||
"<PRE>", message, description);
|
"<PRE>", safe_message, safe_description);
|
||||||
footer(st);
|
footer(st);
|
||||||
printf("</PRE>\n</BODY>\n</HTML>\n");
|
printf("</PRE>\n</BODY>\n</HTML>\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -446,6 +446,7 @@ void info(state *st, char *str, char type);
|
||||||
void footer(state *st);
|
void footer(state *st);
|
||||||
void die(state *st, const char *message, const char *description);
|
void die(state *st, const char *message, const char *description);
|
||||||
void log_combined(state *st, int status);
|
void log_combined(state *st, int status);
|
||||||
|
void html_encode(const char *unsafe, char *dest, int bufsize);
|
||||||
|
|
||||||
/* file.c */
|
/* file.c */
|
||||||
void send_binary_file(state *st);
|
void send_binary_file(state *st);
|
||||||
|
|
|
@ -27,9 +27,7 @@ void log_init(int enable, int debug)
|
||||||
|
|
||||||
_enable = enable;
|
_enable = enable;
|
||||||
|
|
||||||
openlog(PROGNAME,
|
openlog(PROGNAME, LOG_PID, LOG_DAEMON);
|
||||||
LOG_PID | (debug ? LOG_PERROR : 0),
|
|
||||||
LOG_DAEMON);
|
|
||||||
|
|
||||||
setlogmask(_LOG_UPTO(debug ? LOG_DEBUG : LOG_INFO));
|
setlogmask(_LOG_UPTO(debug ? LOG_DEBUG : LOG_INFO));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user