Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src mdnsd enhancements and fixes:
details: https://anonhg.NetBSD.org/src/rev/c0e2d6bc84cc
branches: trunk
changeset: 747763:c0e2d6bc84cc
user: tsarna <tsarna%NetBSD.org@localhost>
date: Thu Oct 01 16:36:20 2009 +0000
description:
mdnsd enhancements and fixes:
- Enhance the built-in drop-privs support and use it instead of
having the rc.conf do it. Avoids log error on startup.
From OpenSolaris, with enhancements.
- Add dumping of the unicast server list to the DumpStateLog
debugging output, a'la Mac OS X.
- Fix a locking botch that caused warnings in the log.
- Fix FILE leak. From OpenSolaris.
diffstat:
etc/defaults/rc.conf | 4 +-
external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c | 39 ++++++++++++-
external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c | 1 +
external/apache2/mDNSResponder/usr.sbin/Makefile.inc | 4 +-
4 files changed, 43 insertions(+), 5 deletions(-)
diffs (122 lines):
diff -r 8e9f93fae3bc -r c0e2d6bc84cc etc/defaults/rc.conf
--- a/etc/defaults/rc.conf Thu Oct 01 15:21:38 2009 +0000
+++ b/etc/defaults/rc.conf Thu Oct 01 16:36:20 2009 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: rc.conf,v 1.108 2009/09/29 23:56:27 tsarna Exp $
+# $NetBSD: rc.conf,v 1.109 2009/10/01 16:36:20 tsarna Exp $
#
# /etc/defaults/rc.conf --
# default configuration of /etc/rc.conf
@@ -160,7 +160,7 @@
# Networking startup.
#
-mdnsd=NO mdnsd_user="_mdnsd"
+mdnsd=NO
ipfilter=NO ipfilter_flags="" # uses /etc/ipf.conf
ipnat=NO # uses /etc/ipnat.conf
ipfs=NO ipfs_flags="" # save/load ipnat and ipf states
diff -r 8e9f93fae3bc -r c0e2d6bc84cc external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c
--- a/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c Thu Oct 01 15:21:38 2009 +0000
+++ b/external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c Thu Oct 01 16:36:20 2009 +0000
@@ -101,8 +101,13 @@
#include "mDNSPosix.h"
#include "mDNSUNP.h" // For daemon()
#include "uds_daemon.h"
+#include "DNSCommon.h"
#include "PlatformCommon.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;
@@ -143,8 +148,10 @@
mDNSAddr DynDNSIP;
const mDNSAddr dummy = { mDNSAddrType_IPv4, { { { 1, 1, 1, 1 } } } };;
mDNS_SetPrimaryInterfaceInfo(m, NULL, NULL, NULL);
+ mDNS_Lock(m);
if (ParseDNSServers(m, uDNS_SERVERS_FILE) < 0)
LogMsg("Unable to parse DNS server list. Unicast DNS-SD unavailable");
+ mDNS_Unlock(m);
ReadDDNSSettingsFromConfFile(m, CONFIG_FILE, &DynDNSHostname, &DynDNSZone, NULL);
mDNSPlatformSourceAddrForDest(&DynDNSIP, &dummy);
if (DynDNSHostname.c[0]) mDNS_AddDynDNSHostName(m, &DynDNSHostname, NULL, NULL);
@@ -175,8 +182,26 @@
mDNSlocal void DumpStateLog(mDNS *const m)
// Dump a little log of what we've been up to.
{
+ DNSServer *s;
+
LogMsg("---- BEGIN STATE LOG ----");
udsserver_info(m);
+
+ LogMsgNoIdent("--------- DNS Servers ----------");
+ if (!mDNSStorage.DNSServers) LogMsgNoIdent("<None>");
+ else
+ {
+ for (s = m->DNSServers; s; s = s->next)
+ {
+ LogMsgNoIdent("DNS Server %##s %#a:%d %s",
+ s->domain.c, &s->addr, mDNSVal16(s->port),
+ s->teststate == DNSServer_Untested ? "(Untested)" :
+ s->teststate == DNSServer_Passed ? "" :
+ s->teststate == DNSServer_Failed ? "(Failed)" :
+ s->teststate == DNSServer_Disabled ? "(Disabled)" : "(Unknown state)");
+ }
+ }
+
LogMsg("---- END STATE LOG ----");
}
@@ -241,11 +266,21 @@
// 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)
diff -r 8e9f93fae3bc -r c0e2d6bc84cc external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c
--- a/external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c Thu Oct 01 15:21:38 2009 +0000
+++ b/external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c Thu Oct 01 16:36:20 2009 +0000
@@ -600,6 +600,7 @@
numOfServers++;
}
}
+ fclose(fp);
return (numOfServers > 0) ? 0 : -1;
}
diff -r 8e9f93fae3bc -r c0e2d6bc84cc external/apache2/mDNSResponder/usr.sbin/Makefile.inc
--- a/external/apache2/mDNSResponder/usr.sbin/Makefile.inc Thu Oct 01 15:21:38 2009 +0000
+++ b/external/apache2/mDNSResponder/usr.sbin/Makefile.inc Thu Oct 01 16:36:20 2009 +0000
@@ -1,7 +1,9 @@
-# $NetBSD: Makefile.inc,v 1.1 2009/09/29 23:56:34 tsarna Exp $
+# $NetBSD: Makefile.inc,v 1.2 2009/10/01 16:36:20 tsarna Exp $
.include <bsd.own.mk>
.include "${.PARSEDIR}/../Makefile.inc"
+CPPFLAGS+= -DMDNSD_NOROOT -DMDNSD_USER=\"_mdnsd\"
+
BINDIR?= /usr/sbin
Home |
Main Index |
Thread Index |
Old Index