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.
This commit is contained in:
parent
5ef3483b17
commit
a4329df0cc
@ -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 @@ securelevel="" # securelevel to set to
|
||||
|
||||
# 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
|
||||
|
@ -101,8 +101,13 @@ Only use mallocL/freeL debugging routines when building mDNSResponder, not dnsex
|
||||
#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 @@ static void Reconfigure(mDNS *m)
|
||||
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 ParseCmdLinArgs(int argc, char **argv)
|
||||
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 @@ 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)
|
||||
|
@ -600,6 +600,7 @@ mDNSexport int ParseDNSServers(mDNS *m, const char *filePath)
|
||||
numOfServers++;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
return (numOfServers > 0) ? 0 : -1;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user