summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xselftest/target/Samba3.pm11
-rwxr-xr-xsource4/scripting/bin/samba_dnsupdate18
2 files changed, 21 insertions, 8 deletions
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index ef22b02865..df8b55c613 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -1067,10 +1067,13 @@ domusers:X:$gid_domusers:
}
print "DONE\n";
- open(HOSTS, ">>$ENV{SELFTEST_PREFIX}/dns_host_file") or die("Unable to open $ENV{SELFTEST_PREFIX}/dns_host_file");
- print HOSTS "A $server. $server_ip
-";
- close(HOSTS);
+ open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");
+ print DNS_UPDATE_LIST "A $server. $server_ip";
+ close(DNS_UPDATE_LIST);
+
+ if (system("$ENV{SRCDIR_ABS}/source4/scripting/bin/samba_dnsupdate --all-interfaces --use-file=$dns_host_file -s $conffile --update-list=$prefix/dns_update_list --no-substiutions --no-credentials") != 0) {
+ die "Unable to update hostname into $dns_host_file";
+ }
$ret{SERVER_IP} = $server_ip;
$ret{NMBD_TEST_LOG} = "$prefix/nmbd_test.log";
diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate
index ab87356484..2f2c7b562a 100755
--- a/source4/scripting/bin/samba_dnsupdate
+++ b/source4/scripting/bin/samba_dnsupdate
@@ -65,6 +65,7 @@ parser.add_option("--use-file", type="string", help="Use a file, rather than rea
parser.add_option("--update-list", type="string", help="Add DNS names from the given file")
parser.add_option("--fail-immediately", action='store_true', help="Exit on first failure")
parser.add_option("--no-credentials", dest='nocreds', action='store_true', help="don't try and get credentials")
+parser.add_option("--no-substiutions", dest='nosubs', action='store_true', help="don't try and expands variables in file specified by --update-list")
creds = None
ccachename = None
@@ -278,7 +279,13 @@ def call_nsupdate(d):
print "Calling nsupdate for %s" % d
if opts.use_file is not None:
- rfile = open(opts.use_file, 'r+')
+ try:
+ rfile = open(opts.use_file, 'r+')
+ except IOError:
+ # Perhaps create it
+ rfile = open(opts.use_file, 'w+')
+ # Open it for reading again, in case someone else got to it first
+ rfile = open(opts.use_file, 'r+')
fcntl.lockf(rfile, fcntl.LOCK_EX)
(file_dir, file_name) = os.path.split(opts.use_file)
(tmp_fd, tmpfile) = tempfile.mkstemp(dir=file_dir, prefix=file_name, suffix="XXXXXX")
@@ -432,10 +439,13 @@ os.environ['KRB5_CONFIG'] = krb5conf
file = open(dns_update_list, "r")
-samdb = SamDB(url=lp.samdb_url(), session_info=system_session(), lp=lp)
+if opts.nosubs:
+ sub_vars = {}
+else:
+ samdb = SamDB(url=lp.samdb_url(), session_info=system_session(), lp=lp)
-# get the substitution dictionary
-sub_vars = get_subst_vars(samdb)
+ # get the substitution dictionary
+ sub_vars = get_subst_vars(samdb)
# build up a list of update commands to pass to nsupdate
update_list = []