quark

quark web server
git clone git://git.suckless.org/quark
Log | Files | Refs | LICENSE

commit 3a9701d8282a3eb1639b6ba01a442eee39006d77
parent d6cbb5b9d98330ccb09b8cdb32eede28b54ddc4d
Author: garbeam@gmail.com <unknown>
Date:   Sun, 26 Jun 2011 10:51:42 +0100

applied rransom's quark patch for FreeBSD compliance, thanks
Diffstat:
Mconfig.def.h | 18+++++++++---------
Mquark.c | 20++++++++++++--------
2 files changed, 21 insertions(+), 17 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -1,14 +1,14 @@ /* quark configuration */ -static const char servername[] = "127.0.0.1"; -static const char serverport[] = "80"; -static const char docroot[] = "."; -static const char docindex[] = "index.html"; -static const char user[] = "nobody"; -static const char group[] = "nogroup"; -static const char cgi_dir[] = "/var/www/werc-dev/bin"; -static const char cgi_script[] = "./werc.rc"; -static const int cgi_mode = 0; +static const char servername[] = "127.0.0.1"; +static const char serverport[] = "80"; +static const char docroot[] = "."; +static const char docindex[] = "index.html"; +static const char *user = "nobody"; +static const char *group = "nogroup"; +static const char cgi_dir[] = "/var/www/werc-dev/bin"; +static const char cgi_script[] = "./werc.rc"; +static const int cgi_mode = 0; static const MimeType servermimes[] = { { "html", "text/html; charset=UTF-8" }, diff --git a/quark.c b/quark.c @@ -522,10 +522,12 @@ main(int argc, char *argv[]) { die("usage: quark [-v]\n"); /* sanity checks */ - if(!(upwd = getpwnam(user))) - die("error: invalid user %s\n", user); - if(!(gpwd = getgrnam(group))) - die("error: invalid group %s\n", group); + if(user) + if(!(upwd = getpwnam(user))) + die("error: invalid user %s\n", user); + if(group) + if(!(gpwd = getgrnam(group))) + die("error: invalid group %s\n", group); signal(SIGCHLD, sighandler); signal(SIGHUP, sighandler); @@ -573,10 +575,12 @@ main(int argc, char *argv[]) { if(chroot(".") == -1) die("error: chroot .: %s\n", strerror(errno)); - if(setgid(gpwd->gr_gid) == -1) - die("error: cannot set group id\n"); - if(setuid(upwd->pw_uid) == -1) - die("error: cannot set user id\n"); + if(gpwd) + if(setgid(gpwd->gr_gid) == -1) + die("error: cannot set group id\n"); + if(upwd) + if(setuid(upwd->pw_uid) == -1) + die("error: cannot set user id\n"); if(getuid() == 0) die("error: won't run with root permissions, choose another user\n");