s4-samba-tool: fixed "-k no" for disabling kerberos auth
authorAndrew Tridgell <tridge@samba.org>
Sat, 27 Nov 2010 11:03:07 +0000 (22:03 +1100)
committerAndrew Tridgell <tridge@samba.org>
Sat, 27 Nov 2010 13:16:37 +0000 (00:16 +1100)
The option "-k no" was not correctly disabling kerberos in python
programs

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/scripting/python/samba/getopt.py

index 08fe692ce0323b84914b9f8b114fc6ceaa6177f4..8104faf62edda28912ac34941287cd57e814b9de 100644 (file)
@@ -135,10 +135,12 @@ class CredentialsOptions(optparse.OptionGroup):
         self.ipaddress = arg
 
     def _set_kerberos(self, option, opt_str, arg, parser):
-        if bool(arg) or arg.lower() == "yes":
+        if arg.lower() in ["yes", 'true', '1']:
             self.creds.set_kerberos_state(MUST_USE_KERBEROS)
-        else:
+        elif arg.lower() in ["no", 'false', '0']:
             self.creds.set_kerberos_state(DONT_USE_KERBEROS)
+        else:
+            raise optparse.BadOptionErr("invalid kerberos option: %s" % arg)
 
     def _set_simple_bind_dn(self, option, opt_str, arg, parser):
         self.creds.set_bind_dn(arg)