Commit Diff


commit - 1220d7ea84811c79f71a7f24917d77cb2f10b02a
commit + 9bc2ee804d400559347917989bde415da69cbc20
blob - 78650d9d0acbde3b541498a0d42df9757b6f238d
blob + e6c663ff42ff32e1e3f11d9873f7735b9f1eb98e
--- gotwebd/gotwebd.c
+++ gotwebd/gotwebd.c
@@ -273,6 +273,7 @@ main(int argc, char **argv)
 	int			 no_action = 0;
 	int			 server_proc = 0;
 	const char		*conffile = GOTWEBD_CONF;
+	const char		*username = GOTWEBD_DEFAULT_USER;
 	const char		*argv0;
 
 	if ((argv0 = argv[0]) == NULL)
@@ -332,9 +333,11 @@ main(int argc, char **argv)
 	if (geteuid())
 		fatalx("need root privileges");
 
-	pw = getpwnam(GOTWEBD_USER);
+	if (env->user)
+		username = env->user;
+	pw = getpwnam(username);
 	if (pw == NULL)
-		fatalx("unknown user %s", GOTWEBD_USER);
+		fatalx("unknown user %s", username);
 	env->pw = pw;
 
 	log_init(env->gotwebd_debug, LOG_DAEMON);
blob - 89f71710e8a0c0843273917b078dba8ab9a9b945
blob + eeebc610744523f4541a4d40fe150fcf56088e7c
--- gotwebd/gotwebd.conf.5
+++ gotwebd/gotwebd.conf.5
@@ -55,9 +55,9 @@ Set the path to the
 .Xr chroot 2
 environment of
 .Xr httpd 8 .
-If not specified then
-.Pa /var/www
-will be used.
+If not specified, it defaults to
+.Pa /var/www ,
+the home directory of the www user.
 .It Ic listen on Ar address Ic port Ar number
 Configure an address and port for incoming FastCGI connections.
 Valid
@@ -77,6 +77,12 @@ May be specified multiple times to build up a list of 
 Run the specified number of server processes.
 .Xr gotwebd 8
 runs 3 server processes by default.
+.It Ic user Ar user
+Set the
+.Ar user
+which will run
+.Xr gotwebd 8 .
+If not specified, the user www will be used.
 .El
 .Pp
 If no
blob - 55aa40d54946310b204bf2c3690e25f707cf817a
blob + 54d00805fd26e7a6b11e21510aad032bf7d9e1bc
--- gotwebd/gotwebd.h
+++ gotwebd/gotwebd.h
@@ -31,7 +31,9 @@
 /* GOTWEBD DEFAULTS */
 #define GOTWEBD_CONF		 "/etc/gotwebd.conf"
 
-#define GOTWEBD_USER		 "www"
+#ifndef GOTWEBD_DEFAULT_USER
+#define GOTWEBD_DEFAULT_USER	 "www"
+#endif
 
 #define GOTWEBD_MAXDESCRSZ	 1024
 #define GOTWEBD_MAXCLONEURLSZ	 1024
@@ -340,6 +342,7 @@ struct gotwebd {
 	struct socketlist	sockets;
 	struct addresslist	addresses;
 
+	char		*user;
 	const char	*gotwebd_conffile;
 
 	int		 gotwebd_debug;
blob - 7b408b0688937e1e12a09c5cf4581c84dce21a1d
blob + 645aee63addc029fccb841ae1421a6184d3e0877
--- gotwebd/parse.y
+++ gotwebd/parse.y
@@ -115,7 +115,7 @@ typedef struct {
 %token	MAX_REPOS_DISPLAY REPOS_PATH MAX_COMMITS_DISPLAY ON ERROR
 %token	SHOW_SITE_OWNER SHOW_REPO_CLONEURL PORT PREFORK RESPECT_EXPORTOK
 %token	SERVER CHROOT CUSTOM_CSS SOCKET
-%token	SUMMARY_COMMITS_DISPLAY SUMMARY_TAGS_DISPLAY
+%token	SUMMARY_COMMITS_DISPLAY SUMMARY_TAGS_DISPLAY USER
 
 %token	<v.string>	STRING
 %token	<v.number>	NUMBER
@@ -235,6 +235,12 @@ main		: PREFORK NUMBER {
 			}
 			free($4);
 		}
+		| USER STRING {
+			if (gotwebd->user != NULL)
+				yyerror("user already specified");
+			free(gotwebd->user);
+			gotwebd->user = $2;
+		}
 		;
 
 server		: SERVER STRING {
@@ -460,6 +466,7 @@ lookup(char *s)
 		{ "socket",			SOCKET },
 		{ "summary_commits_display",	SUMMARY_COMMITS_DISPLAY },
 		{ "summary_tags_display",	SUMMARY_TAGS_DISPLAY },
+		{ "user",			USER },
 	};
 	const struct keywords *p;