applied rransom's quark patch for FreeBSD compliance, thanks

This commit is contained in:
garbeam@gmail.com 2011-06-26 10:51:42 +01:00
parent d6cbb5b9d9
commit 3a9701d828
2 changed files with 21 additions and 17 deletions

View file

@ -4,8 +4,8 @@ static const char servername[] = "127.0.0.1";
static const char serverport[] = "80"; static const char serverport[] = "80";
static const char docroot[] = "."; static const char docroot[] = ".";
static const char docindex[] = "index.html"; static const char docindex[] = "index.html";
static const char user[] = "nobody"; static const char *user = "nobody";
static const char group[] = "nogroup"; static const char *group = "nogroup";
static const char cgi_dir[] = "/var/www/werc-dev/bin"; static const char cgi_dir[] = "/var/www/werc-dev/bin";
static const char cgi_script[] = "./werc.rc"; static const char cgi_script[] = "./werc.rc";
static const int cgi_mode = 0; static const int cgi_mode = 0;

View file

@ -522,8 +522,10 @@ main(int argc, char *argv[]) {
die("usage: quark [-v]\n"); die("usage: quark [-v]\n");
/* sanity checks */ /* sanity checks */
if(user)
if(!(upwd = getpwnam(user))) if(!(upwd = getpwnam(user)))
die("error: invalid user %s\n", user); die("error: invalid user %s\n", user);
if(group)
if(!(gpwd = getgrnam(group))) if(!(gpwd = getgrnam(group)))
die("error: invalid group %s\n", group); die("error: invalid group %s\n", group);
@ -573,8 +575,10 @@ main(int argc, char *argv[]) {
if(chroot(".") == -1) if(chroot(".") == -1)
die("error: chroot .: %s\n", strerror(errno)); die("error: chroot .: %s\n", strerror(errno));
if(gpwd)
if(setgid(gpwd->gr_gid) == -1) if(setgid(gpwd->gr_gid) == -1)
die("error: cannot set group id\n"); die("error: cannot set group id\n");
if(upwd)
if(setuid(upwd->pw_uid) == -1) if(setuid(upwd->pw_uid) == -1)
die("error: cannot set user id\n"); die("error: cannot set user id\n");