[SCM] Samba Shared Repository - branch master updated
Andrew Bartlett
abartlet at samba.org
Fri Sep 9 00:55:02 MDT 2011
The branch, master has been updated
via 47130f9 s4-s3-upgrade Do not use python 2.6 style exceptions
via 25b9760 build: a more robust zlib test
via 46754e9 samba-tool: epilog option to OptionParser available in python >= 2.6
via 4d0ead8 samba-tool: Provide feedback if synopsis is not defined for a command
via e9f155f samba-tool: max() with key option is available in python >= 2.6
via b2a7fe1 samba-tool: Correctly handle sys.exit() called from subcommand
via abd7368 samba-tool: Fixed "ldapcmp" command synopsis
via 342146e samba-tool: Fixed "dbcheck" subcommand syntax
via 69a2e4b samba-tool: Moved _get_user_realm_domain fcn to common
via f4f77bb samba-tool: Fixed "testparm" syntax
via dd3ebbf samba-tool: Fixed "user" command syntax
via 59caf70 samba-tool: Fixed "rodc" syntax
via 4f26c52 samba-tool: Fixed "ntacl" subcommands syntax
via 87a6102 samba-tool: Fixed "group" subcommands syntax
via 4bf1bcf samba-tool: Fixed "dsacl" command syntax
via 54aa286 samba-tool: Fixed "drs" subcommands syntax
via 6a7679c samba-tool: Fixed "domain" subcommands syntax
via de8e47a samba-tool: Fixed "spn" command syntax
via 8a6f3fc samba-tool: Fixed "delegation" command syntax
via 1081251 samba-tool: Fixed "time" command synopsis
via 62379dd samba-tool: Removed "acl" command
via 6484e14 samba-tool: Added "ntacl" command
via 7a609d8 samba-tool: Added "dsacl" command
via 1a6a626 samba-tool: Changed fsmo implementation
via ca30b9f samba-tool: Expanded acronym descriptions
via ef01932 samba-tool: Formatted subcommand list output
via fb5e27e samba-tool: Moved command definition to sambatool command
via e309c78 samba-tool: Add long_description and epilog to Command class
via f5e1732 samba-tool: Redefined samba-tool as a SuperCommand
via 02650ac samba-tool: Removed SuperCommand usage method
via 0f580c0 samba-tool: Removed attribute name from Command class
via 4688b3c s4-test: name attribute remove from Command class, so test not required
from a9dc2c8 s3-spoolss: Fix bug #8351 forms migration.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 47130f97fd371de2541be1a7216dd1ae907bfde2
Author: Andrew Bartlett <abartlet at samba.org>
Date: Fri Sep 9 12:44:56 2011 +1000
s4-s3-upgrade Do not use python 2.6 style exceptions
Autobuild-User: Andrew Bartlett <abartlet at samba.org>
Autobuild-Date: Fri Sep 9 08:54:16 CEST 2011 on sn-devel-104
commit 25b9760a42929c27be4399cd3d7bff5bb71b67db
Author: Andrew Bartlett <abartlet at samba.org>
Date: Fri Sep 9 12:08:54 2011 +1000
build: a more robust zlib test
Just in-case, and done this way due to the #define maze that applies
to this function. No actual host has been found that needs this yet.
Andrew Bartlett
commit 46754e9665ceefe26cf28fbc70629e9660d847da
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Sep 9 13:27:13 2011 +1000
samba-tool: epilog option to OptionParser available in python >= 2.6
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 4d0ead86e1211ef81fb07621afd6028768e2fb07
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Sep 9 13:26:04 2011 +1000
samba-tool: Provide feedback if synopsis is not defined for a command
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit e9f155f52dbde0d715c4cb48093c09ba169262f7
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Sep 9 13:24:10 2011 +1000
samba-tool: max() with key option is available in python >= 2.6
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit b2a7fe166c95ef5d5f5b6af76303cc8d456ac816
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Sep 9 13:22:27 2011 +1000
samba-tool: Correctly handle sys.exit() called from subcommand
Catch SystemExit exception if any subcommand calls sys.exit()
and return with failure (-1).
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit abd7368e769f7e378594f44e569ef69e7bd626c9
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Fri Sep 2 11:23:26 2011 -0400
samba-tool: Fixed "ldapcmp" command synopsis
Fixed "ldapcmp" command syntax
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 342146e0b40eda22f1d5c0a483619ff3733f8fb3
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Aug 30 18:08:44 2011 -0400
samba-tool: Fixed "dbcheck" subcommand syntax
Fixed syntax for "dbcheck" subcommand
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 69a2e4b3605863971c26e78adcc78cab2f6c4b06
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Wed Sep 7 11:11:38 2011 -0400
samba-tool: Moved _get_user_realm_domain fcn to common
_get_user_realm_domain is used by both delegation and spn commands
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit f4f77bb95422c8dbc5df9d4156b660eb41034883
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Sep 6 13:41:41 2011 -0400
samba-tool: Fixed "testparm" syntax
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit dd3ebbffe85776073d95184348f89d44b6624ae2
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Sep 6 13:35:00 2011 -0400
samba-tool: Fixed "user" command syntax
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 59caf70824bac98513da06932d40b238d42f3bb6
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Sep 6 13:25:30 2011 -0400
samba-tool: Fixed "rodc" syntax
Remove options from syntax to be consistent w/ the rest of commands
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 4f26c526145ff32bc7d1f9411169618eaf9673fc
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Sep 6 13:15:25 2011 -0400
samba-tool: Fixed "ntacl" subcommands syntax
Removed options from syntax
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 87a6102c62f2b726b8ecda72e68643eeac479c7d
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Sep 6 13:12:36 2011 -0400
samba-tool: Fixed "group" subcommands syntax
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 4bf1bcfaebc5c37c3641444ffcc3b9310aca9249
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Sep 6 13:05:19 2011 -0400
samba-tool: Fixed "dsacl" command syntax
Removed option from syntax to be consistent w/ the rest of commands
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 54aa286b9ade93ff136cc69a6d64b3f017d6e189
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Fri Sep 2 13:56:51 2011 -0400
samba-tool: Fixed "drs" subcommands syntax
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 6a7679cdd4c07e1b8955b1f0f179a921752a529a
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Fri Sep 2 13:21:49 2011 -0400
samba-tool: Fixed "domain" subcommands syntax
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit de8e47a4e3e44edea7b0b671f547b950dc518b42
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Fri Sep 2 12:52:54 2011 -0400
samba-tool: Fixed "spn" command syntax
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 8a6f3fc3b428ad77bc116816584323bdcef55b35
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Fri Sep 2 13:10:05 2011 -0400
samba-tool: Fixed "delegation" command syntax
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 10812515161d53e582974381dddaacdb7f5a8461
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Aug 30 17:52:59 2011 -0400
samba-tool: Fixed "time" command synopsis
"server_name" is an optional parameter
added "options" parameter
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 62379dde2389082f17fea6fdaa3821419fdd38a3
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Aug 30 17:22:06 2011 -0400
samba-tool: Removed "acl" command
Removed "acl" command as it has been changed to:
"dsacl" and "ntacl"
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 6484e142dc673145fc12f06549d20121e615b7f0
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Aug 30 17:19:59 2011 -0400
samba-tool: Added "ntacl" command
Added "ntacl" command to substitute "acl nt" command
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 7a609d827eca7d72258b590999ed3ccd8e476d06
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Aug 30 17:09:53 2011 -0400
samba-tool: Added "dsacl" command
Added "dsacl" command to substitute "acl ds"
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 1a6a626a45107c7b3451ac0d33dd1b6d214dab97
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Aug 2 18:05:54 2011 -0400
samba-tool: Changed fsmo implementation
Changed fsmo code to fit the object <action> model
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit ca30b9ff3e66134f9d9d741e9c752ab4f6522f4e
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Tue Aug 2 13:50:15 2011 -0400
samba-tool: Expanded acronym descriptions
Expanded command acronym descriptions
Added footnote for "server connection needed"
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit ef01932fdbf395c5a27f1935b585c6457a427574
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Mon Aug 1 17:47:31 2011 -0400
samba-tool: Formatted subcommand list output
Formatted output of subcommand list to be a function of the
max number of chars in the longest string
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit fb5e27e4c87dddca4c1609bf8a83f2c213991782
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Mon Aug 1 14:45:18 2011 -0400
samba-tool: Moved command definition to sambatool command
Moved subcommand definition from __init__.py to cmd_sambatool class
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit e309c782baa5535a60621492d6ffa77dff37b899
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Fri Jul 29 17:04:45 2011 -0400
samba-tool: Add long_description and epilog to Command class
long_description and epilog should now be defined for each command.
Their string value will be printed whenever the user invokes the
command w/ the -h or --help
long_desciption will be printed after the usage statement.
epilog will be printed after the options are defined
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit f5e173284a959197ea3ee347fc9625aadb9591dc
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Thu Jul 28 21:44:06 2011 -0400
samba-tool: Redefined samba-tool as a SuperCommand
Removed MainCommand class as samba-tool is a SuperCommand
Redefined samba-tool as a SuperCommand
Fixed error handling in SuperCommand _run
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 02650acac397afe509b6b3bce6df975920d386b8
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Thu Jul 28 21:42:03 2011 -0400
samba-tool: Removed SuperCommand usage method
Removed usage method as it is not being used anywhere
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 0f580c0705a8d419af22300d0ece796ba1252095
Author: Giampaolo Lauria <lauria2 at yahoo.com>
Date: Thu Jul 28 14:21:40 2011 -0400
samba-tool: Removed attribute name from Command class
Removed name as it is not used anywhere
Moved all the attributes on top of the class declaration
Signed-off-by: Amitay Isaacs <amitay at gmail.com>
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
commit 4688b3ca60ebca000e489b489c6e67df848cfa98
Author: Amitay Isaacs <amitay at gmail.com>
Date: Fri Sep 9 15:21:59 2011 +1000
s4-test: name attribute remove from Command class, so test not required
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/zlib/wscript | 5 +-
source4/scripting/bin/samba-tool | 88 +++++----
source4/scripting/python/samba/netcmd/__init__.py | 91 +++-------
source4/scripting/python/samba/netcmd/common.py | 27 +++
source4/scripting/python/samba/netcmd/dbcheck.py | 2 +-
.../scripting/python/samba/netcmd/delegation.py | 52 +++---
source4/scripting/python/samba/netcmd/domain.py | 15 +-
source4/scripting/python/samba/netcmd/drs.py | 27 ++-
source4/scripting/python/samba/netcmd/dsacl.py | 10 +-
source4/scripting/python/samba/netcmd/fsmo.py | 198 +++++++++++++-------
source4/scripting/python/samba/netcmd/gpo.py | 2 +-
source4/scripting/python/samba/netcmd/group.py | 8 +-
source4/scripting/python/samba/netcmd/ldapcmp.py | 2 +-
source4/scripting/python/samba/netcmd/netacl.py | 34 ----
source4/scripting/python/samba/netcmd/ntacl.py | 18 +-
source4/scripting/python/samba/netcmd/rodc.py | 6 +-
source4/scripting/python/samba/netcmd/spn.py | 40 ++---
source4/scripting/python/samba/netcmd/testparm.py | 2 +-
source4/scripting/python/samba/netcmd/time.py | 4 +-
source4/scripting/python/samba/netcmd/user.py | 5 +-
source4/scripting/python/samba/netcmd/vampire.py | 2 +-
source4/scripting/python/samba/tests/netcmd.py | 6 -
source4/scripting/python/samba/upgrade.py | 4 +-
23 files changed, 334 insertions(+), 314 deletions(-)
delete mode 100644 source4/scripting/python/samba/netcmd/netacl.py
Changeset truncated at 500 lines:
diff --git a/lib/zlib/wscript b/lib/zlib/wscript
index a091de6..42d6f76 100644
--- a/lib/zlib/wscript
+++ b/lib/zlib/wscript
@@ -9,10 +9,13 @@ def configure(conf):
#else
#error "ZLIB_VERNUM < 0x1230"
#endif
+ z_stream *z;
+ inflateInit2(z, -15);
''',
headers='zlib.h',
+ lib='z',
local_include=False,
- msg='Checking for ZLIB_VERNUM >= 0x1230',
+ msg='Checking for ZLIB_VERNUM >= 0x1230 and working link to zlib',
define='HAVE_ZLIB')
# If we don't do this then we will receive an error that lib 'z'
diff --git a/source4/scripting/bin/samba-tool b/source4/scripting/bin/samba-tool
index 7d66230..c191865 100755
--- a/source4/scripting/bin/samba-tool
+++ b/source4/scripting/bin/samba-tool
@@ -1,7 +1,8 @@
#!/usr/bin/env python
# Unix SMB/CIFS implementation.
-# Copyright (C) Amitay Isaacs <amitay at gmail.com> 211
+# Copyright (C) Amitay Isaacs <amitay at gmail.com> 2011
+# Copyright (C) Giampaolo Lauria <lauria2 at yahoo.com> 2011
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -23,56 +24,61 @@ import sys
sys.path.insert(0, "bin/python")
from samba import netcmd
-from samba.netcmd import Command, CommandError
-
-
-class MainCommand(Command):
- """Main class for samba tool commands"""
-
- commands = {}
-
- def _run(self, myname, command=None, *args):
- if command in self.commands:
- return self.commands[command]._run(command, *args)
- print "Usage: samba-tool <command> [options]"
- print "Available commands:"
- cmds = self.commands.keys()
- cmds.sort()
- for cmd in cmds:
- print " %-16s - %s" % (cmd, self.commands[cmd].description)
- if command in [None]:
- raise CommandError("You must specify a command")
- if command in ['help', '-h', '--help']:
- print "For more help on a specific command, please type: samba-tool <command> (-h|--help)"
- return 0
- raise CommandError("No such command '%s'" % command)
-
- def usage(self, myname, command=None, *args):
- if command is None or not command in self.commands:
- print "Usage: samba-tool %s (%s) [options]" % (myname,
- " | ".join(self.commands.keys()))
- else:
- return self.commands[command].usage(*args)
-
-
-class cmd_sambatool(MainCommand):
- """Samba Tool Commands"""
- commands = netcmd.commands
+from samba.netcmd import SuperCommand
+from samba.netcmd.dbcheck import cmd_dbcheck
+from samba.netcmd.delegation import cmd_delegation
+from samba.netcmd.domain import cmd_domain
+from samba.netcmd.drs import cmd_drs
+from samba.netcmd.dsacl import cmd_dsacl
+from samba.netcmd.fsmo import cmd_fsmo
+from samba.netcmd.gpo import cmd_gpo
+from samba.netcmd.group import cmd_group
+from samba.netcmd.ldapcmp import cmd_ldapcmp
+from samba.netcmd.ntacl import cmd_ntacl
+from samba.netcmd.rodc import cmd_rodc
+from samba.netcmd.spn import cmd_spn
+from samba.netcmd.testparm import cmd_testparm
+from samba.netcmd.time import cmd_time
+from samba.netcmd.user import cmd_user
+from samba.netcmd.vampire import cmd_vampire
+
+
+class cmd_sambatool(SuperCommand):
+ """samba-tool SuperCommand"""
+
+ subcommands = {}
+ subcommands["dbcheck"] = cmd_dbcheck()
+ subcommands["delegation"] = cmd_delegation()
+ subcommands["domain"] = cmd_domain()
+ subcommands["drs"] = cmd_drs()
+ subcommands["dsacl"] = cmd_dsacl()
+ subcommands["fsmo"] = cmd_fsmo()
+ subcommands["gpo"] = cmd_gpo()
+ subcommands["group"] = cmd_group()
+ subcommands["ldapcmp"] = cmd_ldapcmp()
+ subcommands["ntacl"] = cmd_ntacl()
+ subcommands["rodc"] = cmd_rodc()
+ subcommands["spn"] = cmd_spn()
+ subcommands["testparm"] = cmd_testparm()
+ subcommands["time"] = cmd_time()
+ subcommands["user"] = cmd_user()
+ subcommands["vampire"] = cmd_vampire()
if __name__ == '__main__':
cmd = cmd_sambatool()
-
- command = None
+ subcommand = None
args = ()
if len(sys.argv) > 1:
- command = sys.argv[1]
+ subcommand = sys.argv[1]
if len(sys.argv) > 2:
args = sys.argv[2:]
try:
- retval = cmd._run("samba-tool", command, *args)
- sys.exit(retval)
+ retval = cmd._run("samba-tool", subcommand, *args)
+ except SystemExit, e:
+ retval = -1
except Exception, e:
cmd.show_command_error(e)
+ sys.exit(retval)
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py
index f76fb8a..58d5660 100644
--- a/source4/scripting/python/samba/netcmd/__init__.py
+++ b/source4/scripting/python/samba/netcmd/__init__.py
@@ -32,24 +32,29 @@ class Option(optparse.Option):
class Command(object):
"""A samba-tool command."""
-
+
def _get_description(self):
return self.__doc__.splitlines()[0].rstrip("\n")
- def _get_name(self):
- name = self.__class__.__name__
- if name.startswith("cmd_"):
- return name[4:]
- return name
+ description = property(_get_description)
- name = property(_get_name)
+ # synopsis must be defined in all subclasses in order to provide the command usage
+ synopsis = "Please provide synopsis for this command."
+ # long_description is a string describing the command in details
+ long_description = ""
+ takes_args = []
+ takes_options = []
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+ outf = sys.stdout
def usage(self, *args):
parser, _ = self._create_parser()
parser.print_usage()
- description = property(_get_description)
-
def show_command_error(self, e):
'''display a command error'''
if isinstance(e, CommandError):
@@ -84,20 +89,9 @@ class Command(object):
traceback.print_tb(etraceback)
sys.exit(1)
- outf = sys.stdout
-
- # synopsis must be defined in all subclasses in order to provide the command usage
- synopsis = ""
- takes_args = []
- takes_options = []
- takes_optiongroups = {
- "sambaopts": options.SambaOptions,
- "credopts": options.CredentialsOptions,
- "versionopts": options.VersionOptions,
- }
-
def _create_parser(self):
- parser = optparse.OptionParser(self.synopsis)
+ parser = optparse.OptionParser(usage=self.synopsis,
+ description=self.long_description)
parser.add_options(self.takes_options)
optiongroups = {}
for name, optiongroup in self.takes_optiongroups.iteritems():
@@ -157,26 +151,25 @@ class SuperCommand(Command):
def _run(self, myname, subcommand=None, *args):
if subcommand in self.subcommands:
return self.subcommands[subcommand]._run(subcommand, *args)
- print "Usage: samba-tool %s <subcommand> [options]" % myname
+
+ if (myname == "samba-tool"):
+ usage = "samba-tool <subcommand>"
+ else:
+ usage = "samba-tool %s <subcommand>" % myname
+ print "Usage: %s [options]" %usage
print "Available subcommands:"
subcmds = self.subcommands.keys()
subcmds.sort()
+ max_length = max(map(lambda c: len(c), subcmds))
for cmd in subcmds:
- print " %-20s - %s" % (cmd, self.subcommands[cmd].description)
+ print " %*s - %s" % (-max_length, cmd, self.subcommands[cmd].description)
if subcommand in [None]:
raise CommandError("You must specify a subcommand")
if subcommand in ['help', '-h', '--help']:
- print "For more help on a specific subcommand, please type: samba-tool %s <subcommand> (-h|--help)" % myname
+ print "For more help on a specific subcommand, please type: %s (-h|--help)" % usage
return 0
raise CommandError("No such subcommand '%s'" % subcommand)
- def usage(self, myname, subcommand=None, *args):
- if subcommand is None or not subcommand in self.subcommands:
- print "Usage: samba-tool %s (%s) [options]" % (myname,
- " | ".join(self.subcommands.keys()))
- else:
- return self.subcommands[subcommand].usage(*args)
-
class CommandError(Exception):
@@ -185,37 +178,3 @@ class CommandError(Exception):
self.message = message
self.inner_exception = inner_exception
self.exception_info = sys.exc_info()
-
-
-
-commands = {}
-from samba.netcmd.netacl import cmd_acl
-commands["acl"] = cmd_acl()
-from samba.netcmd.fsmo import cmd_fsmo
-commands["fsmo"] = cmd_fsmo()
-from samba.netcmd.time import cmd_time
-commands["time"] = cmd_time()
-from samba.netcmd.user import cmd_user
-commands["user"] = cmd_user()
-from samba.netcmd.vampire import cmd_vampire
-commands["vampire"] = cmd_vampire()
-from samba.netcmd.spn import cmd_spn
-commands["spn"] = cmd_spn()
-from samba.netcmd.group import cmd_group
-commands["group"] = cmd_group()
-from samba.netcmd.rodc import cmd_rodc
-commands["rodc"] = cmd_rodc()
-from samba.netcmd.drs import cmd_drs
-commands["drs"] = cmd_drs()
-from samba.netcmd.gpo import cmd_gpo
-commands["gpo"] = cmd_gpo()
-from samba.netcmd.ldapcmp import cmd_ldapcmp
-commands["ldapcmp"] = cmd_ldapcmp()
-from samba.netcmd.testparm import cmd_testparm
-commands["testparm"] = cmd_testparm()
-from samba.netcmd.dbcheck import cmd_dbcheck
-commands["dbcheck"] = cmd_dbcheck()
-from samba.netcmd.delegation import cmd_delegation
-commands["delegation"] = cmd_delegation()
-from samba.netcmd.domain import cmd_domain
-commands["domain"] = cmd_domain()
diff --git a/source4/scripting/python/samba/netcmd/common.py b/source4/scripting/python/samba/netcmd/common.py
index 71629ef..a4ebdd4 100644
--- a/source4/scripting/python/samba/netcmd/common.py
+++ b/source4/scripting/python/samba/netcmd/common.py
@@ -3,6 +3,7 @@
# common functions for samba-tool python commands
#
# Copyright Andrew Tridgell 2010
+# Copyright Giampaolo Lauria 2011 <lauria2 at yahoo.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -18,16 +19,42 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
+import re
from samba.dcerpc import nbt
from samba.net import Net
+
+def _get_user_realm_domain(user):
+ """ get the realm or the domain and the base user
+ from user like:
+ * username
+ * DOMAIN\username
+ * username at REALM
+ """
+ baseuser = user
+ realm = ""
+ domain = ""
+ m = re.match(r"(\w+)\\(\w+$)", user)
+ if m:
+ domain = m.group(1)
+ baseuser = m.group(2)
+ return (baseuser.lower(), domain.upper(), realm)
+ m = re.match(r"(\w+)@(\w+)", user)
+ if m:
+ baseuser = m.group(1)
+ realm = m.group(2)
+ return (baseuser.lower(), domain, realm.upper())
+
+
+
def netcmd_dnsname(lp):
'''return the full DNS name of our own host. Used as a default
for hostname when running status queries'''
return lp.get('netbios name').lower() + "." + lp.get('realm').lower()
+
def netcmd_finddc(lp, creds):
'''return domain-name of a writable/ldap-capable DC for the domain.'''
net = Net(creds=creds, lp=lp)
diff --git a/source4/scripting/python/samba/netcmd/dbcheck.py b/source4/scripting/python/samba/netcmd/dbcheck.py
index 2a175f3..92d27a1 100644
--- a/source4/scripting/python/samba/netcmd/dbcheck.py
+++ b/source4/scripting/python/samba/netcmd/dbcheck.py
@@ -33,7 +33,7 @@ from samba.dbchecker import dbcheck
class cmd_dbcheck(Command):
"""check local AD database for errors"""
- synopsis = "dbcheck <DN> [options]"
+ synopsis = "%prog dbcheck [<DN>] [options]"
takes_args = ["DN?"]
diff --git a/source4/scripting/python/samba/netcmd/delegation.py b/source4/scripting/python/samba/netcmd/delegation.py
index 9aa8287..cf04d9d 100644
--- a/source4/scripting/python/samba/netcmd/delegation.py
+++ b/source4/scripting/python/samba/netcmd/delegation.py
@@ -23,11 +23,11 @@
import samba.getopt as options
import ldb
-import re
from samba import provision
from samba import dsdb
from samba.samdb import SamDB
from samba.auth import system_session
+from samba.netcmd.common import _get_user_realm_domain
from samba.netcmd import (
Command,
CommandError,
@@ -35,30 +35,12 @@ from samba.netcmd import (
Option
)
-def _get_user_realm_domain(user):
- """ get the realm or the domain and the base user
- from user like:
- * username
- * DOMAIN\username
- * username at REALM
- """
- baseuser = user
- realm = ""
- domain = ""
- m = re.match(r"(\w+)\\(\w+$)", user)
- if m:
- domain = m.group(1)
- baseuser = m.group(2)
- return (baseuser.lower(), domain.upper(), realm)
- m = re.match(r"(\w+)@(\w+)", user)
- if m:
- baseuser = m.group(1)
- realm = m.group(2)
- return (baseuser.lower(), domain, realm.upper())
+
class cmd_delegation_show(Command):
"""Show the delegation setting of an account."""
- synopsis = "%prog delegation show <accountname>"
+
+ synopsis = "%prog delegation show <accountname> [options]"
takes_args = ["accountname"]
@@ -97,9 +79,12 @@ class cmd_delegation_show(Command):
for a in allowed:
print "msDS-AllowedToDelegateTo: %s" % (str(a))
+
+
class cmd_delegation_for_any_service(Command):
"""Set/unset UF_TRUSTED_FOR_DELEGATION for an account."""
- synopsis = "%prog delegation for-any-service <accountname> on|off"
+
+ synopsis = "%prog delegation for-any-service <accountname> [(on|off)] [options]"
takes_args = ["accountname", "onoff"]
@@ -129,9 +114,12 @@ class cmd_delegation_for_any_service(Command):
except Exception, err:
raise CommandError(err)
+
+
class cmd_delegation_for_any_protocol(Command):
"""Set/unset UF_TRUSTED_TO_AUTHENTICATE_FOR_DELEGATION (S4U2Proxy) for an account."""
- synopsis = "%prog delegation for-any-protocol <accountname> on|off"
+
+ synopsis = "%prog delegation for-any-protocol <accountname> [(on|off)] [options]"
takes_args = ["accountname", "onoff"]
@@ -161,9 +149,12 @@ class cmd_delegation_for_any_protocol(Command):
except Exception, err:
raise CommandError(err)
+
+
class cmd_delegation_add_service(Command):
"""Add a service principal as msDS-AllowedToDelegateTo"""
- synopsis = "%prog delegation add-service <accountname> <principal>"
+
+ synopsis = "%prog delegation add-service <accountname> <principal> [options]"
takes_args = ["accountname", "principal"]
@@ -194,9 +185,12 @@ class cmd_delegation_add_service(Command):
except Exception, err:
raise CommandError(err)
+
+
class cmd_delegation_del_service(Command):
- """Add a service principal as msDS-AllowedToDelegateTo"""
- synopsis = "%prog delegation del-service <accountname> <principal>"
+ """Delete a service principal as msDS-AllowedToDelegateTo"""
+
+ synopsis = "%prog delegation del-service <accountname> <principal> [options]"
takes_args = ["accountname", "principal"]
@@ -227,8 +221,10 @@ class cmd_delegation_del_service(Command):
except Exception, err:
raise CommandError(err)
+
+
class cmd_delegation(SuperCommand):
- """Delegation management [server connection needed]"""
+ """Delegation management"""
subcommands = {}
subcommands["show"] = cmd_delegation_show()
diff --git a/source4/scripting/python/samba/netcmd/domain.py b/source4/scripting/python/samba/netcmd/domain.py
index 423a812..884ea64 100644
--- a/source4/scripting/python/samba/netcmd/domain.py
+++ b/source4/scripting/python/samba/netcmd/domain.py
@@ -52,7 +52,8 @@ from samba.dsdb import (
class cmd_domain_export_keytab(Command):
"""Dumps kerberos keys of the domain into a keytab"""
- synopsis = "%prog domain exportkeytab <keytab>"
+
+ synopsis = "%prog domain exportkeytab <keytab> [options]"
takes_options = [
]
@@ -67,9 +68,9 @@ class cmd_domain_export_keytab(Command):
class cmd_domain_join(Command):
- """Joins domain as either member or backup domain controller [server connection needed]"""
+ """Joins domain as either member or backup domain controller *"""
- synopsis = "%prog domain join <dnsdomain> [DC | RODC | MEMBER] [options]"
+ synopsis = "%prog domain join <dnsdomain> [DC|RODC|MEMBER] [options]"
takes_options = [
Option("--server", help="DC to join", type=str),
@@ -115,14 +116,14 @@ class cmd_domain_join(Command):
domain_critical_only=domain_critical_only)
return
else:
- raise CommandError("Invalid role %s (possible values: MEMBER, BDC, RODC)" % role)
+ raise CommandError("Invalid role %s (possible values: MEMBER, DC, RODC)" % role)
class cmd_domain_level(Command):
"""Raises domain and forest function levels"""
--
Samba Shared Repository
More information about the samba-cvs
mailing list