Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

uDNS servers list for Posix daemon



Hello,

Currently whole unicast DNS-SD is unavailable on Linux because mdnsd never 
reads and registers list of uDNS servers.Attached patch makes Posix daemon 
parse /etc/dns-sd.resolv.conf (name probably should be configurable via 
cmdline option). It follows resolv.conf syntax so in most cases you can just 
symlink /etc/resolv.conf to /etc/dns-sd.resolv.conf and enjoy DNS-SD over 
unicast DNS.
diff -urd mDNSResponder/mDNSPosix/PosixDaemon.c mDNSResponder-mod/mDNSPosix/PosixDaemon.c
--- mDNSResponder/mDNSPosix/PosixDaemon.c	2004-09-21 23:05:12.000000000 +0200
+++ mDNSResponder-mod/mDNSPosix/PosixDaemon.c	2004-11-11 11:53:06.000000000 +0100
@@ -89,6 +89,7 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <signal.h>
+#include <arpa/inet.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <pwd.h>
@@ -102,6 +103,7 @@
 
 static void		ParseCmdLinArgs( int argc, char **argv);
 static void		DumpStateLog( mDNS *m);
+static int		ParseDNSServers( mDNS *m,const char *filePath);
 static mStatus	MainLoop( mDNS *m);
 
 
@@ -126,6 +128,9 @@
 
 	if ( mStatus_NoError == err)
 		err = udsserver_init();
+		
+	if (ParseDNSServers( &mDNSRecord, "/etc/dns-sd.resolv.conf") < 0)
+		LogMsg("Unable to parse DNS server list. Unicast DNS-SD unavailable");
 
 	// Now that we're finished with anything privileged, switch over to running as "nobody"
 	if ( mStatus_NoError == err)
@@ -235,6 +240,31 @@
 	}
 }
 
+static int ParseDNSServers( mDNS *m, const char *filePath)
+{
+    char line[256];
+    char nameserver[16];
+    char keyword[10];
+    int		numOfServers = 0;
+    FILE *      fp = fopen(filePath, "r");
+
+    if (fp == NULL) {
+        return -1;
+    }
+    while (fgets(line,sizeof(line),fp)) {
+	mDNSv4Addr DNSAddr;
+	line[255]='\0';		// just to be safe
+	if (sscanf(line,"%10s %15s",keyword,nameserver) != 2) {  // it will skip whitespaces
+	    continue;
+	}
+	if (strncmp(keyword,"nameserver",10)) continue;
+	if (inet_aton(nameserver,&DNSAddr) != 0) {
+	    mDNS_RegisterDNS(m,&DNSAddr);
+	    numOfServers++;
+	}
+    }  
+    return (numOfServers > 0) ? 0 : -1;
+}
 
 static void		DumpStateLog(mDNS *const m)
 // Dump a little log of what we've been up to.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Rendezvous-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/rendezvous-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.