From: Stefan Metzmacher Date: Thu, 31 Oct 2019 14:37:40 +0000 (+0100) Subject: selftest: split out Samba::mk_resolv_conf() helper X-Git-Tag: ldb-2.2.0~1180 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8133c5787b6a5142ffbb9c3818eb7e01239005d8;p=thirdparty%2Fsamba.git selftest: split out Samba::mk_resolv_conf() helper Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/selftest/target/Samba.pm b/selftest/target/Samba.pm index 7895c5d271b..0fcaf8bdbfa 100644 --- a/selftest/target/Samba.pm +++ b/selftest/target/Samba.pm @@ -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 diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 3cbe317c5c5..81199077315 100755 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -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 = ();