applied rransom's quark patch for FreeBSD compliance, thanks
This commit is contained in:
parent
d6cbb5b9d9
commit
3a9701d828
2 changed files with 21 additions and 17 deletions
18
config.def.h
18
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" },
|
||||
|
|
20
quark.c
20
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");
|
||||
|
|
Loading…
Reference in a new issue