diff options
author | Andrew Bartlett <abartlet@samba.org> | 2015-02-26 12:23:55 +1300 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2015-03-06 17:39:58 +0100 |
commit | 63dbf4388a53016a110bd02a31c46e0210eda463 (patch) | |
tree | 825cb21c34e61ad68bbf4a2bb666036cc3e17d3e /python/samba/getopt.py | |
parent | 90d03a65bcb2aae262ad113da420ae63bdf5b4b1 (diff) | |
download | samba-63dbf4388a53016a110bd02a31c46e0210eda463.tar.gz |
samba-tool: Add -P to options.CredentialsOptions
This matches our other binaries, and allows samba-tool commands to run with the machine account.
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'python/samba/getopt.py')
-rw-r--r-- | python/samba/getopt.py | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/python/samba/getopt.py b/python/samba/getopt.py index c3c080084ec..0f9765864c1 100644 --- a/python/samba/getopt.py +++ b/python/samba/getopt.py @@ -126,8 +126,9 @@ class CredentialsOptions(optparse.OptionGroup): """Command line options for specifying credentials.""" def __init__(self, parser): - self.no_pass = True + self.ask_for_password = True self.ipaddress = None + self.machine_pass = False optparse.OptionGroup.__init__(self, parser, "Credentials Options") self.add_option("--simple-bind-dn", metavar="DN", action="callback", callback=self._set_simple_bind_dn, type=str, @@ -140,8 +141,9 @@ class CredentialsOptions(optparse.OptionGroup): self.add_option("-W", "--workgroup", metavar="WORKGROUP", action="callback", type=str, help="Workgroup", callback=self._parse_workgroup) - self.add_option("-N", "--no-pass", action="store_true", - help="Don't ask for a password") + self.add_option("-N", "--no-pass", action="callback", + help="Don't ask for a password", + callback=self._set_no_password) self.add_option("-k", "--kerberos", metavar="KERBEROS", action="callback", type=str, help="Use Kerberos", callback=self._set_kerberos) @@ -149,17 +151,29 @@ class CredentialsOptions(optparse.OptionGroup): action="callback", type=str, help="IP address of server", callback=self._set_ipaddress) + self.add_option("-P", "--machine-pass", + action="callback", + help="Use stored machine account password", + callback=self._set_machine_pass) self.creds = Credentials() def _parse_username(self, option, opt_str, arg, parser): self.creds.parse_string(arg) + self.machine_pass = False def _parse_workgroup(self, option, opt_str, arg, parser): self.creds.set_domain(arg) def _set_password(self, option, opt_str, arg, parser): self.creds.set_password(arg) - self.no_pass = False + self.ask_for_password = False + self.machine_pass = False + + def _set_no_password(self, option, opt_str, arg, parser): + self.ask_for_password = False + + def _set_machine_pass(self, option, opt_str, arg, parser): + self.machine_pass = True def _set_ipaddress(self, option, opt_str, arg, parser): self.ipaddress = arg @@ -177,7 +191,9 @@ class CredentialsOptions(optparse.OptionGroup): :return: Credentials object """ self.creds.guess(lp) - if self.no_pass: + if self.machine_pass: + self.creds.set_machine_account(lp) + elif self.ask_for_password: self.creds.set_cmdline_callbacks() # possibly fallback to using the machine account, if we have |