[Dnssec-trigger] [PATCH] Pass all domains from 'search' through to MacOS.
Phil Pennock
dnssec-trigger+phil at spodhuis.org
Thu Mar 28 19:09:48 UTC 2013
From: Phil Pennock <phil+git at apcera.com>
Previously, 'search' was like 'domain but allowing extra domains to
appear, and be ignored. This fixes that.
Note: scutil setting is defined but not actually used (before and after
this patch). I've no idea why scutil changes don't take and
networksetup is needed, but I can confirm that this is the case for me
too; nonetheless, I changed both approaches, to keep things in sync.
---
osx/dnssec-trigger-setdns.sh.in | 36 ++++++++++++++++++++++++++++--------
riggerd/reshook.c | 12 +++++-------
2 files changed, 33 insertions(+), 15 deletions(-)
mode change 100644 => 100755 osx/dnssec-trigger-setdns.sh.in
diff --git a/osx/dnssec-trigger-setdns.sh.in b/osx/dnssec-trigger-setdns.sh.in
old mode 100644
new mode 100755
index 0552b5b..5ca4121
--- a/osx/dnssec-trigger-setdns.sh.in
+++ b/osx/dnssec-trigger-setdns.sh.in
@@ -32,11 +32,27 @@ function doinstall () {
cmd="$1"
shift
if test "$cmd" = "set"; then
- domain="$1"
+ domains="$1"
+ firstdomain="$1"
shift
# remaining arguments are the servers to set
servers="$*"
- logger "dnssec-trigger-setdns to $domain and $servers"
+ logger "dnssec-trigger-setdns to $domains and $servers"
+elif test "$cmd" = "mset"; then
+ domains="$1"
+ firstdomain="$1"
+ shift
+ while test "$1" != "--"; do
+ domains="$domains $1"
+ shift
+ done
+ if test "$1" != "--"; then
+ echo >&2 "Usage: $0 domain [domain ..] -- server [server ..]"
+ exit 1
+ fi
+ shift # --
+ servers="$*"
+ logger "dnssec-trigger-setdns to $domains and $servers"
elif test "$cmd" = "install"; then
doinstall "$*"
exit 0
@@ -44,10 +60,13 @@ else
if test "$cmd" = "uninit"; then
logger "dnssec-trigger-setdns uninit dns override"
else
- echo "bad command: set domain [ip ..] | uninit"
+ echo >&2 "bad command: set | mset | unint"
+ echo >&2 " set domain [ip ..]"
+ echo >&2 " mset domain [domain ..] -- ip [ip ..]"
exit 1
fi
- domain=""
+ firstdomain=""
+ domains=""
servers=""
fi
@@ -62,7 +81,8 @@ for i in $ids State:/Network/Global/DNS; do
open
d.init
d.add ServerAddresses * $servers
-d.add DomainName $domain
+d.add SearchDomains * $domains
+d.add DomainName $firstdomain
set $i
quit
END
@@ -71,15 +91,15 @@ done
# set the DNS settings via networksetup
nws="networksetup"
-if test -z "$domain"; then
- domain="empty"
+if test -z "$domains"; then
+ domains="empty"
fi
if test -z "$servers"; then
servers="empty"
fi
$nws -listallnetworkservices 2>/dev/null | grep -v '*' | while read x ; do
#echo $x
- $nws -setsearchdomains "$x" $domain
+ $nws -setsearchdomains "$x" $domains
# no quotes around servers: the IPs have to be separate arguments.
$nws -setdnsservers "$x" $servers
done
diff --git a/riggerd/reshook.c b/riggerd/reshook.c
index 7dcf84a..9644293 100644
--- a/riggerd/reshook.c
+++ b/riggerd/reshook.c
@@ -60,17 +60,15 @@ set_dns_osx(struct cfg* cfg, char* iplist)
{
char cmd[10240];
char dm[1024];
- char* domain = "nothing.invalid";
+ char* domains = "nothing.invalid";
if(cfg->rescf_domain && cfg->rescf_domain[0])
- domain = cfg->rescf_domain;
+ domains = cfg->rescf_domain;
else if(cfg->rescf_search && cfg->rescf_search[0]) {
snprintf(dm, sizeof(dm), "%s", cfg->rescf_search);
- if(strchr(dm, ' '))
- strchr(dm, ' ')[0] = 0; /* use first word as domain */
- domain = dm;
+ domains = dm;
}
- snprintf(cmd, sizeof(cmd), "%s/dnssec-trigger-setdns.sh set %s %s",
- LIBEXEC_DIR, domain, iplist);
+ snprintf(cmd, sizeof(cmd), "%s/dnssec-trigger-setdns.sh mset %s -- %s",
+ LIBEXEC_DIR, domains, iplist);
verbose(VERB_QUERY, "%s", cmd);
system(cmd);
}
--
1.8.2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <http://lists.nlnetlabs.nl/pipermail/dnssec-trigger/attachments/20130328/5fecc128/attachment.bin>
More information about the dnssec-trigger
mailing list