]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
main: set default user/group only when specified for non-root users, fixes #5213
authorJaroslav Kysela <perex@perex.cz>
Thu, 20 Sep 2018 12:46:42 +0000 (14:46 +0200)
committerJaroslav Kysela <perex@perex.cz>
Thu, 20 Sep 2018 12:46:47 +0000 (14:46 +0200)
src/main.c

index 47a00fa0dad8c772d6db270d9050cdde288a49ed..24e53acebca4581b7df61c9049a21cb186a0da4c 100644 (file)
@@ -1046,10 +1046,10 @@ main(int argc, char **argv)
   signal(SIGILL, handle_sigill);   // see handler..
 
   /* Set priviledges */
-  if(opt_fork || opt_group || opt_user) {
+  if((opt_fork && getuid() == 0) || opt_group || opt_user) {
     const char *homedir;
     struct group  *grp = getgrnam(opt_group ?: "video");
-    struct passwd *pw  = opt_user ? getpwnam(opt_user) : NULL;
+    struct passwd *pw  = getpwnam(opt_user ?: "daemon");
 
     if(grp != NULL) {
       gid = grp->gr_gid;