selftest: split out Samba::mk_resolv_conf() helper
authorStefan Metzmacher <metze@samba.org>
Thu, 31 Oct 2019 14:37:40 +0000 (15:37 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 27 Mar 2020 09:02:38 +0000 (09:02 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
selftest/target/Samba.pm
selftest/target/Samba4.pm

index 7895c5d271b5df86b56ef3ab8b7f0bd16b4ed2a1..0fcaf8bdbfad5fe1aaca38cd53c6812adcd4e33e 100644 (file)
@@ -436,6 +436,20 @@ sub mk_mitkdc_conf($$)
        close(KDCCONF);
 }
 
+sub mk_resolv_conf($$)
+{
+       my ($ctx) = @_;
+
+       unless (open(RESOLV_CONF, ">$ctx->{resolv_conf}")) {
+               warn("can't open $ctx->{resolv_conf}$?");
+               return undef;
+       }
+
+       print RESOLV_CONF "nameserver $ctx->{dns_ipv4}\n";
+       print RESOLV_CONF "nameserver $ctx->{dns_ipv6}\n";
+       close(RESOLV_CONF);
+}
+
 sub realm_to_ip_mappings
 {
        # this maps the DNS realms for the various testenvs to the corresponding
index 3cbe317c5c5b4e62ec23bb730503e37da32ff21e..81199077315756cff6cd7294ea326c9cd4cfb04a 100755 (executable)
@@ -298,10 +298,11 @@ sub setup_dns_hub_internal($$$)
        $env->{RESOLV_CONF} = "$prefix_abs/resolv.conf";
        $env->{TESTENV_DIR} = $prefix_abs;
 
-       open(RESOLV_CONF, ">$env->{RESOLV_CONF}");
-       print RESOLV_CONF "nameserver $env->{SERVER_IP}\n";
-       print RESOLV_CONF "nameserver $env->{SERVER_IPV6}\n";
-       close(RESOLV_CONF);
+       my $ctx = undef;
+       $ctx->{resolv_conf} = $env->{RESOLV_CONF};
+       $ctx->{dns_ipv4} = $env->{SERVER_IP};
+       $ctx->{dns_ipv6} = $env->{SERVER_IPV6};
+       Samba::mk_resolv_conf($ctx);
 
        my @preargs = ();
        my @args = ();