]> 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:51:45 +0000 (14:51 +0200)
src/main.c

index 8678039f187bc8eceaaf81715fdc8fd38533a404..c277c923ae0abaf1f5dfe98c886a59c0f6aeccf3 100644 (file)
@@ -1043,10 +1043,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;