mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-04 18:36:02 -05:00
Move runas down into daemonize()
This commit is contained in:
parent
f39c48b989
commit
f3c0145346
13
src/main.c
13
src/main.c
@ -80,17 +80,20 @@ usage(char *program)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
daemonize(int background, char *runas, char *pidfile)
|
daemonize(int background, char *pidfile)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int fd;
|
|
||||||
pid_t childpid;
|
pid_t childpid;
|
||||||
pid_t ret;
|
pid_t ret;
|
||||||
|
int fd;
|
||||||
int iret;
|
int iret;
|
||||||
|
char *runas;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
if (geteuid() == (uid_t) 0)
|
if (geteuid() == (uid_t) 0)
|
||||||
{
|
{
|
||||||
|
runas = cfg_getstr(cfg_getsec(cfg, "general"), "uid");
|
||||||
|
|
||||||
pw = getpwnam(runas);
|
pw = getpwnam(runas);
|
||||||
|
|
||||||
if (!pw)
|
if (!pw)
|
||||||
@ -258,7 +261,7 @@ main(int argc, char **argv)
|
|||||||
char *logdomains;
|
char *logdomains;
|
||||||
char *logfile;
|
char *logfile;
|
||||||
cfg_t *lib;
|
cfg_t *lib;
|
||||||
char *runas, *tmp;
|
char *tmp;
|
||||||
int port;
|
int port;
|
||||||
char *servername;
|
char *servername;
|
||||||
char *ffid;
|
char *ffid;
|
||||||
@ -409,9 +412,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Daemonize and drop privileges */
|
/* Daemonize and drop privileges */
|
||||||
runas = cfg_getstr(cfg_getsec(cfg, "general"), "uid");
|
ret = daemonize(background, pidfile);
|
||||||
|
|
||||||
ret = daemonize(background, runas, pidfile);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_MAIN, "Could not initialize server\n");
|
DPRINTF(E_LOG, L_MAIN, "Could not initialize server\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user