Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/apache2/mDNSResponder/dist/mDNSPosix reapply change...



details:   https://anonhg.NetBSD.org/src/rev/e37463c5c82f
branches:  trunk
changeset: 376028:e37463c5c82f
user:      andvar <andvar%NetBSD.org@localhost>
date:      Sat May 27 17:58:58 2023 +0000

description:
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.

diffstat:

 external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c |  18 +++++++++++-
 1 files changed, 16 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r 7fc456a61e3b -r e37463c5c82f external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c
--- a/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c       Sat May 27 14:51:47 2023 +0000
+++ b/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c       Sat May 27 17:58:58 2023 +0000
@@ -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)



Home | Main Index | Thread Index | Old Index