Commit Diff


commit - 5f3a1ac784fa42b175d8a4313442772a7d032a3ed30bdf8294fa8948bf47b3bd
commit + 11d14bebc977b671830614cf83306648bce10eca587a90d4e1ec2889d135caee
blob - 5df79bc62a87b4dd3a995f18ed37365600027ab68b7b62926dba24b9e2707d2e
blob + 23e900367238f93025d033b9c42ba2627814226fdfda9332a3794bb2af2caddf
--- gotwebd/gotwebd.c	
+++ gotwebd/gotwebd.c	
@@ -676,13 +676,18 @@ main(int argc, char **argv)
 	pw = getpwnam(gotwebd_username);
 	if (pw == NULL)
 		fatalx("unknown user %s", gotwebd_username);
+	if (pw->pw_uid == 0 || pw->pw_gid == 0) {
+		fatalx("refusing to start up with user \"root\" set "
+		    "in gotwebd.conf; running gotwebd with UID/GID 0 "
+		    "is dangerous");
+	}
 	if (getgrouplist(gotwebd_username, pw->pw_gid, gotwebd_groups,
 	    &gotwebd_ngroups) == -1)
 		fatalx("too many groups for user %s", gotwebd_username);
 
 	/* check for root privileges */
 	if (geteuid())
-		fatalx("need root privileges");
+		fatalx("need root privileges to start up");
 
 	log_init(env->gotwebd_debug, LOG_DAEMON);
 	log_setverbose(env->gotwebd_verbose);