From 491f466d43593e7c0691cd232c935ef913050d58 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sun, 3 May 2015 09:59:44 -0400 Subject: [PATCH] Set user and group before init. Fixes crashes do to permission errors on startup. --- src/main.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main.c b/src/main.c index 95784a2..bb4c096 100644 --- a/src/main.c +++ b/src/main.c @@ -878,16 +878,6 @@ main(int argc, char **argv) } } - uuid_init(); - config_boot(opt_config, gid, uid); - tcp_server_preinit(opt_ipv6); - http_server_init(opt_bindaddr); // bind to ports only - htsp_init(opt_bindaddr); // bind to ports only - satip_server_init(opt_satip_rtsp); // bind to ports only - - if (opt_fork) - pidfile = tvh_fopen(opt_pidpath, "w+"); - if (gid != -1 && (getgid() != gid) && setgid(gid)) { tvhlog(LOG_ALERT, "START", "setgid(%d) failed, do you have permission?", gid); @@ -899,6 +889,16 @@ main(int argc, char **argv) return 1; } + uuid_init(); + config_boot(opt_config, gid, uid); + tcp_server_preinit(opt_ipv6); + http_server_init(opt_bindaddr); // bind to ports only + htsp_init(opt_bindaddr); // bind to ports only + satip_server_init(opt_satip_rtsp); // bind to ports only + + if (opt_fork) + pidfile = tvh_fopen(opt_pidpath, "w+"); + /* Daemonise */ if(opt_fork) { if(daemon(0, 0)) { -- 2.1.4