summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAlexander Bokovoy <ab@samba.org>2012-05-18 15:24:38 +0300
committerAlexander Bokovoy <ab@samba.org>2012-05-23 17:51:50 +0300
commit2fc96e695599312c26576b5d0a0f6a86852131c4 (patch)
tree9c0c7effff5d8c10a83f7f5cebcd838d37f8ac32 /source4
parentec989e7c402e9868d45d7764175f2b44d85bb244 (diff)
downloadsamba-2fc96e695599312c26576b5d0a0f6a86852131c4.tar.gz
samba-2fc96e695599312c26576b5d0a0f6a86852131c4.tar.bz2
samba-2fc96e695599312c26576b5d0a0f6a86852131c4.zip
s4: samba-tool is usable without export-keytab command, make sure it does not break
When export_keytab is not compiled in (pure client-side Samba 4 build as with system MIT krb5), export-keytab command of samba-tool will not be available. Make sure it is not provided but its absence does not break the Python tool.
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/python/samba/netcmd/domain.py41
1 files changed, 22 insertions, 19 deletions
diff --git a/source4/scripting/python/samba/netcmd/domain.py b/source4/scripting/python/samba/netcmd/domain.py
index 2ce0535591..a53c06acd9 100644
--- a/source4/scripting/python/samba/netcmd/domain.py
+++ b/source4/scripting/python/samba/netcmd/domain.py
@@ -29,7 +29,6 @@ import os
import tempfile
import logging
from samba.net import Net, LIBNET_JOIN_AUTOMATIC
-import samba.dckeytab
import samba.ntacls
from samba.join import join_RODC, join_DC, join_subdomain
from samba.auth import system_session
@@ -69,28 +68,31 @@ def get_testparm_var(testparm, smbconf, varname):
output = os.popen(cmd, 'r').readline()
return output.strip()
+try:
+ import samba.dckeytab
+ class cmd_domain_export_keytab(Command):
+ """Dumps kerberos keys of the domain into a keytab"""
-class cmd_domain_export_keytab(Command):
- """Dumps kerberos keys of the domain into a keytab"""
+ synopsis = "%prog <keytab> [options]"
- synopsis = "%prog <keytab> [options]"
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
- takes_optiongroups = {
- "sambaopts": options.SambaOptions,
- "credopts": options.CredentialsOptions,
- "versionopts": options.VersionOptions,
- }
+ takes_options = [
+ Option("--principal", help="extract only this principal", type=str),
+ ]
- takes_options = [
- Option("--principal", help="extract only this principal", type=str),
- ]
+ takes_args = ["keytab"]
- takes_args = ["keytab"]
-
- def run(self, keytab, credopts=None, sambaopts=None, versionopts=None, principal=None):
- lp = sambaopts.get_loadparm()
- net = Net(None, lp)
- net.export_keytab(keytab=keytab, principal=principal)
+ def run(self, keytab, credopts=None, sambaopts=None, versionopts=None, principal=None):
+ lp = sambaopts.get_loadparm()
+ net = Net(None, lp)
+ net.export_keytab(keytab=keytab, principal=principal)
+except:
+ cmd_domain_export_keytab = None
class cmd_domain_info(Command):
@@ -928,7 +930,8 @@ class cmd_domain(SuperCommand):
subcommands = {}
subcommands["demote"] = cmd_domain_demote()
- subcommands["exportkeytab"] = cmd_domain_export_keytab()
+ if type(cmd_domain_export_keytab).__name__ != 'NoneType':
+ subcommands["exportkeytab"] = cmd_domain_export_keytab()
subcommands["info"] = cmd_domain_info()
subcommands["join"] = cmd_domain_join()
subcommands["level"] = cmd_domain_level()