From: Garming Sam Date: Wed, 20 Feb 2019 00:43:42 +0000 (+1300) Subject: gpo: Ensure that gplink works when empty X-Git-Tag: talloc-2.2.0~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5514b98f1d6611b99923ad98e8d55985c6620b70;p=thirdparty%2Fsamba.git gpo: Ensure that gplink works when empty It appears that RSAT can leave a space in the gPLink field, which we need to handle. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13564 Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index 95fe5d6d439..ae06594e719 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -93,6 +93,10 @@ def gplink_options_string(value): def parse_gplink(gplink): '''parse a gPLink into an array of dn and options''' ret = [] + + if gplink.strip() == '': + return ret + a = gplink.split(']') for g in a: if not g: @@ -656,7 +660,7 @@ class cmd_getlink(GPOCommand): except Exception: raise CommandError("Container '%s' does not exist" % container_dn) - if msg['gPLink']: + if 'gPLink' in msg and msg['gPLink']: self.outf.write("GPO(s) linked to DN %s\n" % container_dn) gplist = parse_gplink(str(msg['gPLink'][0])) for g in gplist: