Skip to content
Snippets Groups Projects
Commit 80db6189 authored by Andrew Price's avatar Andrew Price
Browse files

Make the default mwserv user configurable

Also get rid of some unnecessary global variables.
parent 96c971cb
No related branches found
No related tags found
No related merge requests found
......@@ -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)) {
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment