Module Name:    src
Committed By:   martin
Date:           Sun May 28 10:21:15 UTC 2023

Modified Files:
        src/external/apache2/mDNSResponder/dist/mDNSPosix [netbsd-9]:
            PosixDaemon.c

Log Message:
Pull up following revision(s) (requested by andvar in ticket #1634):

        external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c: revision 
1.15

reapply changes for the built-in drop-privs support by tsarna.

this commit doesn't reapply "dumping of the unicast server list
to the DumpStateLog debugging output" enhancement.
It doesn't build anymore, no idea how to rewrite.

Should fix PR 57442. Needs pull-ups for netbsd-9, netbsd-10.


To generate a diff of this commit:
cvs rdiff -u -r1.12.4.1 -r1.12.4.2 \
    src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c
diff -u src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c:1.12.4.1 src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c:1.12.4.2
--- src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c:1.12.4.1	Sun Jul 26 10:44:28 2020
+++ src/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c	Sun May 28 10:21:15 2023
@@ -50,6 +50,10 @@ extern int daemon(int, int);
 #include "PlatformCommon.h"
 #include "DNSCommon.h"
 
+#ifndef MDNSD_USER
+#define MDNSD_USER "nobody"
+#endif
+
 #define CONFIG_FILE "/etc/mdnsd.conf"
 static domainname DynDNSZone;                // Default wide-area zone for service registration
 static domainname DynDNSHostname;
@@ -190,11 +194,21 @@ int main(int argc, char **argv)
     // Now that we're finished with anything privileged, switch over to running as "nobody"
     if (mStatus_NoError == err)
     {
-        const struct passwd *pw = getpwnam("nobody");
+        const struct passwd *pw = getpwnam(MDNSD_USER);
         if (pw != NULL)
+	{
+            setgid(pw->pw_gid);
             setuid(pw->pw_uid);
+	}
         else
-            LogMsg("WARNING: mdnsd continuing as root because user \"nobody\" does not exist");
+#ifdef MDNSD_NOROOT
+        {
+            LogMsg("WARNING: mdnsd exiting because user \""MDNSD_USER"\" does not exist");
+            err = mStatus_Invalid;
+        }
+#else
+            LogMsg("WARNING: mdnsd continuing as root because user \""MDNSD_USER"\" does not exist");
+#endif
     }
 
     if (mStatus_NoError == err)

Reply via email to