The branch, master has been updated via 47278bfaa6d waf: Simplify condition for undefined symbol detection via 9314bd0b25c samba_dnsupdate: small tweaks to make code more pythonic from 92c726dc7a8 make some auth functions return an NTSTATUS like other similar functions for better diagnostics.
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 47278bfaa6dec543be49c0d66a2418928356a4a3 Author: Michael Hanselmann <pub...@hansmi.ch> Date: Sat Mar 23 00:14:52 2019 +0100 waf: Simplify condition for undefined symbol detection There's no need to check for OpenBSD twice. Signed-off-by: Michael Hanselmann <pub...@hansmi.ch> Reviewed-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> Autobuild-User(master): Noel Power <npo...@samba.org> Autobuild-Date(master): Tue Apr 2 17:28:40 UTC 2019 on sn-devel-144 commit 9314bd0b25c397deec6e431c7f64be9e5c00d02b Author: Joe Guo <j...@catalyst.net.nz> Date: Wed Mar 27 15:21:14 2019 +1300 samba_dnsupdate: small tweaks to make code more pythonic Signed-off-by: Joe Guo <j...@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abart...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> ----------------------------------------------------------------------- Summary of changes: buildtools/wafsamba/samba_autoconf.py | 9 +++-- source4/scripting/bin/samba_dnsupdate | 68 ++++++++++------------------------- 2 files changed, 23 insertions(+), 54 deletions(-) Changeset truncated at 500 lines: diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index ee1fc231eb9..98ffdfea458 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -919,12 +919,11 @@ def SETUP_CONFIGURE_CACHE(conf, enable): @conf def SAMBA_CHECK_UNDEFINED_SYMBOL_FLAGS(conf): - # we don't want any libraries or modules to rely on runtime - # resolution of symbols if not sys.platform.startswith("openbsd"): + # we don't want any libraries or modules to rely on runtime + # resolution of symbols conf.env.undefined_ldflags = conf.ADD_LDFLAGS('-Wl,-no-undefined', testflags=True) - if not sys.platform.startswith("openbsd") and conf.env.undefined_ignore_ldflags == []: - if conf.CHECK_LDFLAGS(['-undefined', 'dynamic_lookup']): + if (conf.env.undefined_ignore_ldflags == [] and + conf.CHECK_LDFLAGS(['-undefined', 'dynamic_lookup'])): conf.env.undefined_ignore_ldflags = ['-undefined', 'dynamic_lookup'] - diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate index 3fb540b202c..2ecb2ce9f1d 100755 --- a/source4/scripting/bin/samba_dnsupdate +++ b/source4/scripting/bin/samba_dnsupdate @@ -91,35 +91,21 @@ lp = sambaopts.get_loadparm() domain = lp.get("realm") host = lp.get("netbios name") -if opts.all_interfaces: - all_interfaces = True -else: - all_interfaces = False +all_interfaces = opts.all_interfaces -if opts.current_ip: - IPs = opts.current_ip -else: - IPs = samba.interface_ips(lp, all_interfaces) +IPs = opts.current_ip or samba.interface_ips(lp, bool(all_interfaces)) or [] nsupdate_cmd = lp.get('nsupdate command') dns_zone_scavenging = lp.get("dns zone scavenging") -if len(IPs) == 0: +if not IPs: print("No IP interfaces - skipping DNS updates") sys.exit(0) -if opts.rpc_server_ip: - rpc_server_ip = opts.rpc_server_ip -else: - rpc_server_ip = IPs[0] +rpc_server_ip = opts.rpc_server_ip or IPs[0] -IP6s = [] -IP4s = [] -for i in IPs: - if i.find(':') != -1: - IP6s.append(i) - else: - IP4s.append(i) +IP6s = [ip for ip in IPs if ':' in ip] +IP4s = [ip for ip in IPs if ':' not in ip] smb_conf = sambaopts.get_loadparm_path() @@ -132,23 +118,18 @@ def get_possible_rw_dns_server(creds, domain): (4.6 and prior) do not maintain this value, so add NS servers as well""" - hostnames = [] ans_soa = check_one_dns_name(domain, 'SOA') - # Actually there is only one - for i in range(len(ans_soa)): - hostnames.append(str(ans_soa[i].mname).rstrip('.')) + hosts_soa = [str(a.mname).rstrip('.') for a in ans_soa] # This is not strictly legit, but old Samba domains may have an # unmaintained SOA record, so go for any NS that we can get a # ticket to. ans_ns = check_one_dns_name(domain, 'NS') - # Actually there is only one - for i in range(len(ans_ns)): - hostnames.append(str(ans_ns[i].target).rstrip('.')) + hosts_ns = [str(a.target).rstrip('.') for a in ans_ns] - return hostnames + return hosts_soa + hosts_ns def get_krb5_rw_dns_server(creds, domain): """Get a list of read-write DNS servers that we can obtain a ticket @@ -160,8 +141,7 @@ def get_krb5_rw_dns_server(creds, domain): rw_dns_servers = get_possible_rw_dns_server(creds, domain) # Actually there is only one - for i in range(len(rw_dns_servers)): - target_hostname = str(rw_dns_servers[i]) + for i, target_hostname in enumerate(rw_dns_servers): settings = {} settings["lp_ctx"] = lp settings["target_hostname"] = target_hostname @@ -181,9 +161,8 @@ def get_krb5_rw_dns_server(creds, domain): return target_hostname except RuntimeError: # Only raise an exception if they all failed - if i != len(rw_dns_servers) - 1: - pass - raise + if i == len(rw_dns_servers) - 1: + raise def get_credentials(lp): """# get credentials if we haven't got them already.""" @@ -278,9 +257,7 @@ def hostname_match(h1, h2): return h1.lower().rstrip('.') == h2.lower().rstrip('.') def get_resolver(d=None): - resolv_conf = os.getenv('RESOLV_CONF') - if not resolv_conf: - resolv_conf = '/etc/resolv.conf' + resolv_conf = os.getenv('RESOLV_CONF', default='/etc/resolv.conf') resolver = dns.resolver.Resolver(filename=resolv_conf, configure=True) if d is not None and d.nameservers != []: @@ -290,11 +267,10 @@ def get_resolver(d=None): def check_one_dns_name(name, name_type, d=None): resolver = get_resolver(d) - if d is not None and len(d.nameservers) == 0: + if d and not d.nameservers: d.nameservers = resolver.nameservers - - ans = resolver.query(name, name_type) - return ans + # dns.resolver.Answer + return resolver.query(name, name_type) def check_dns_name(d): """check that a DNS entry exists.""" @@ -727,15 +703,9 @@ def call_rodc_update(d, op="add"): # get the list of DNS entries we should have -if opts.update_list: - dns_update_list = opts.update_list -else: - dns_update_list = lp.private_path('dns_update_list') +dns_update_list = opts.update_list or lp.private_path('dns_update_list') -if opts.update_cache: - dns_update_cache = opts.update_cache -else: - dns_update_cache = lp.private_path('dns_update_cache') +dns_update_cache = opts.update_cache or lp.private_path('dns_update_cache') krb5conf = None # only change the krb5.conf if we are not in selftest @@ -895,7 +865,7 @@ else: use_samba_tool = opts.use_samba_tool use_nsupdate = opts.use_nsupdate # get our krb5 creds -if len(delete_list) != 0 or len(update_list) != 0 and not opts.nocreds: +if delete_list or update_list and not opts.nocreds: try: creds = get_credentials(lp) except RuntimeError as e: -- Samba Shared Repository