Description: Stop rnews from segfaulting while starting
Author: Julien ÉLIE <julien@trigofacile.com>
Origin: upstream
Bug-Debian: http://bugs.debian.org/809774

--- a/frontends/rnews.c
+++ b/frontends/rnews.c
@@ -861,7 +861,14 @@ int main(int ac, char *av[])
        other setups where rnews might be setuid news or be run by other
        processes in the news group. */
     if (getuid() == 0 || geteuid() == 0) {
-        ensure_news_user(true);
+        uid_t uid;
+
+        /* Do not use ensure_news_user() because it will fail to deal
+         * with the case of rnews being setuid news. */
+        get_news_uid_gid(&uid, false, true);
+        if (setuid(uid) < 0) {
+            sysdie("failed to setuid");
+        }
     }
 
     if (!innconf_read(NULL))
--- a/lib/newsuser.c
+++ b/lib/newsuser.c
@@ -69,14 +69,16 @@ ensure_news_user(bool may_setuid)
     if (geteuid() == 0) {
         if (! may_setuid) {
             /* NB:  mustn't be run as root, unless "may_setuid" is true. */
-            die("must be run as %s, not as root", innconf->runasuser);
+            die("must be run as %s, not as root",
+                innconf != NULL ? innconf->runasuser : RUNASUSER);
         }
         if (setuid(uid) < 0) {
             sysdie("failed to setuid");
         }
     }
     if (geteuid() != uid || getuid() != uid) {
-        die("must be run as %s", innconf->runasuser);
+        die("must be run as %s",
+            innconf != NULL ? innconf->runasuser : RUNASUSER);
     }
 }
 
@@ -95,7 +97,8 @@ ensure_news_grp(bool may_setgid)
         }
     }
     if (getegid() != gid || getgid() != gid) {
-        die ("must be run as %s group", innconf->runasgroup);
+        die ("must be run as %s group",
+             innconf != NULL ? innconf->runasgroup : RUNASGROUP);
     }
 }
 
