[mw-devel] [Git][arthur/mw][master] Make the default mwserv user configurable

Andrew Price welshbyte at sucs.org
Wed Nov 11 19:44:35 GMT 2015


Andrew Price pushed to branch master at Justin Mitchell / mw


Commits:
80db6189 by Andrew Price at 2015-11-11T03:00:25Z
Make the default mwserv user configurable

Also get rid of some unnecessary global variables.

- - - - -


2 changed files:

- src/server/mwserv.c
- src/webclient/mwpoll.c


Changes:

=====================================
src/server/mwserv.c
=====================================
--- a/src/server/mwserv.c
+++ b/src/server/mwserv.c
@@ -14,10 +14,6 @@
 #include <mwcfg.h>
 #include "servsock.h"
 
-/* unused, but necessary to link other util functions */
-int idle = 0;
-int internet = 0;
-
 #define MWUSER "mw"
 #define MWSERVCONF "mwserv.conf"
 
@@ -43,6 +39,7 @@ static void usage(char *name)
 static const struct cfg_default_opt defcfgs[] = {
 	CFG_OPT(BOOL, "foreground", 0),
 	CFG_OPT(INT, "port", 9999),
+	CFG_OPT(STR, "user", MWUSER),
 	CFG_END
 };
 
@@ -162,9 +159,10 @@ int main(int argc, char **argv)
 	}
 
 	if (geteuid() == 0) {
-		struct passwd *pwbuff = getpwnam(MWUSER);
+		const char *user = cfg_get_string("user");
+		struct passwd *pwbuff = getpwnam(user);
 		if (!pwbuff) {
-			fprintf(stderr, "Username %s does not exist.\n", MWUSER);
+			fprintf(stderr, "Username %s does not exist.\n", user);
 			return 1;
 		}
 		if (setgid(pwbuff->pw_gid)) {


=====================================
src/webclient/mwpoll.c
=====================================
--- a/src/webclient/mwpoll.c
+++ b/src/webclient/mwpoll.c
@@ -14,10 +14,6 @@
 struct user me;
 struct user *user = &me;
 
-/* unused */
-int internet = 0;
-int idle = 0;
-
 #define DEFAULT_IDLE 60
 int clientidle = DEFAULT_IDLE;
 time_t lastcomm = 0;



View it on GitLab: https://projects.sucs.org/arthur/mw/commit/80db61895ab8ec0e90c95ae3ccbe83ab1c70a08e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sucs.org/pipermail/mw-devel/attachments/20151111/f72b4b2d/attachment.html>


More information about the mw-devel mailing list