[SCM] Samba Shared Repository - branch master updated
Andrew Tridgell
tridge at samba.org
Wed Dec 30 23:36:17 MST 2009
The branch, master has been updated
via de94857... s4-net: fixed finddcs to use empty SID instead of NULL sid (NDR error)
via 9d6411d... s4-testpasswords: fixed CONFIG and quoting
via 3239872... s4-net: fixed pwsettings command
via dbd7a62... py/security: Add test for dom_sid.split.
via 66f81d1... samba: Fix whitespace, remove pointless 'pass' statement.
via ea5af6e... pyldb: Add dom_sid.split in favor of less powerful dom_sid_to_rid().
via 7effe2d... net: Support 'super' commands implemented in Python.
via 9e5ef91... net: Move 'newuser' to 'net newuser'
via 73594c2... net: Fix tests and documentation of setexpiry.
via 345b25d... net: Move setexpiry to 'net setexpiry'
via b531696... net: Move 'setpassword' to 'net setpassword'.
via 552e656... net: Allow Python commands to return None instead of 0.
via 797977a... blackbox.passwords: Use convenience variable for net.
via 18d2213... Fix commands in password tests.
via 31cc963... net: Allow python subcommands to provide commands that are not recognized by net itself.
from 3a271a8... Prevent NULL dereference if group has no members
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit de9485784867a7a68207e42fe2a021de01e54904
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Dec 31 16:53:14 2009 +1100
s4-net: fixed finddcs to use empty SID instead of NULL sid (NDR error)
commit 9d6411d9dd2ef4bca247d41708bb6b0d0d14389a
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Dec 31 16:52:49 2009 +1100
s4-testpasswords: fixed CONFIG and quoting
Need to pass correct config file to tests
commit 3239872bbcd81a690663f29c8fa20811d66f9dea
Author: Andrew Tridgell <tridge at samba.org>
Date: Thu Dec 31 16:52:15 2009 +1100
s4-net: fixed pwsettings command
Don't override user settings with current settings
commit dbd7a62baa56eb2ce082fdcf24e2d8621a4f54ea
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 21:59:50 2009 +0100
py/security: Add test for dom_sid.split.
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit 66f81d18ce08cfb1ed6c347a753b436d3de8ced7
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 21:48:42 2009 +0100
samba: Fix whitespace, remove pointless 'pass' statement.
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit ea5af6e30ca91df3325581f67daab96d688d58fc
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 21:46:32 2009 +0100
pyldb: Add dom_sid.split in favor of less powerful dom_sid_to_rid().
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit 7effe2d2e30191c067ae1290224d388d96701b53
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 21:06:21 2009 +0100
net: Support 'super' commands implemented in Python.
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit 9e5ef916d41ee5f27616d18e431a9943310d3db6
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 20:40:11 2009 +0100
net: Move 'newuser' to 'net newuser'
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit 73594c248f35a6ebbe391cc46b717aff14d393be
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 20:10:34 2009 +0100
net: Fix tests and documentation of setexpiry.
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit 345b25d059db27f96b00143f7617919233a78ba4
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 20:00:12 2009 +0100
net: Move setexpiry to 'net setexpiry'
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit b531696a5b878beef9d0177eeb4939160d1a602e
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 19:53:05 2009 +0100
net: Move 'setpassword' to 'net setpassword'.
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit 552e65679df23f488ecee2c0d8555f5e0dad9166
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 18:01:24 2009 +0100
net: Allow Python commands to return None instead of 0.
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit 797977ac53466cb3096d1457e8df087eb7ad7598
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 17:58:30 2009 +0100
blackbox.passwords: Use convenience variable for net.
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit 18d221342bf87d4ef4b90d1308b957daea1faddd
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 14:55:49 2009 +0100
Fix commands in password tests.
Signed-off-by: Andrew Tridgell <tridge at samba.org>
commit 31cc963ba0adc043032ad2113b44a5d599fa07d5
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Wed Dec 30 14:55:07 2009 +0100
net: Allow python subcommands to provide commands that are not recognized by
net itself.
Signed-off-by: Andrew Tridgell <tridge at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source4/lib/ldb/tests/python/ldap.py | 18 +++---
source4/lib/ldb/tests/python/ldap_schema.py | 2 +-
source4/libcli/finddcs.c | 3 +
source4/libcli/security/tests/bindings.py | 11 ++-
source4/librpc/ndr/py_security.c | 36 +++++++++
source4/script/installmisc.sh | 2 +-
source4/scripting/python/pyglue.c | 23 ------
source4/scripting/python/samba/__init__.py | 62 +++++++---------
source4/scripting/python/samba/netcmd/__init__.py | 47 ++++++++----
.../scripting/python/samba/netcmd/enableaccount.py | 65 +++++++++++++++++
source4/scripting/python/samba/netcmd/newuser.py | 70 ++++++++++++++++++
.../scripting/python/samba/netcmd/pwsettings.py | 14 ++--
source4/scripting/python/samba/netcmd/setexpiry.py | 72 ++++++++++++++++++
.../scripting/python/samba/netcmd/setpassword.py | 77 ++++++++++++++++++++
source4/setup/enableaccount | 65 -----------------
source4/setup/newuser | 69 ------------------
source4/setup/setexpiry | 72 ------------------
source4/setup/setpassword | 74 -------------------
source4/setup/tests/blackbox_newuser.sh | 11 ++--
source4/setup/tests/blackbox_setpassword.sh | 10 ++-
source4/utils/net/net.c | 58 +++++++++------
testprogs/blackbox/test_export_keytab.sh | 2 +-
testprogs/blackbox/test_kinit.sh | 2 +-
testprogs/blackbox/test_passwords.sh | 45 ++++++------
24 files changed, 480 insertions(+), 430 deletions(-)
create mode 100755 source4/scripting/python/samba/netcmd/enableaccount.py
create mode 100755 source4/scripting/python/samba/netcmd/newuser.py
create mode 100644 source4/scripting/python/samba/netcmd/setexpiry.py
create mode 100644 source4/scripting/python/samba/netcmd/setpassword.py
delete mode 100755 source4/setup/enableaccount
delete mode 100755 source4/setup/newuser
delete mode 100755 source4/setup/setexpiry
delete mode 100755 source4/setup/setpassword
Changeset truncated at 500 lines:
diff --git a/source4/lib/ldb/tests/python/ldap.py b/source4/lib/ldb/tests/python/ldap.py
index 426d7b3..c2920c0 100755
--- a/source4/lib/ldb/tests/python/ldap.py
+++ b/source4/lib/ldb/tests/python/ldap.py
@@ -26,7 +26,7 @@ from ldb import ERR_NAMING_VIOLATION, ERR_CONSTRAINT_VIOLATION
from ldb import ERR_UNDEFINED_ATTRIBUTE_TYPE
from ldb import Message, MessageElement, Dn
from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE
-from samba import Ldb, param, dom_sid_to_rid
+from samba import Ldb, param
from samba import UF_NORMAL_ACCOUNT, UF_TEMP_DUPLICATE_ACCOUNT
from samba import UF_SERVER_TRUST_ACCOUNT, UF_WORKSTATION_TRUST_ACCOUNT
from samba import UF_INTERDOMAIN_TRUST_ACCOUNT
@@ -456,7 +456,7 @@ class BasicTests(unittest.TestCase):
self.fail()
except LdbError, (num, _):
self.assertEquals(num, ERR_NAMING_VIOLATION)
-
+
self.delete_force(self.ldb, "description=xyz,cn=users," + self.base_dn)
self.ldb.add({
@@ -642,17 +642,17 @@ objectClass: container
res1 = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn,
scope=SCOPE_BASE, attrs=["objectSID"])
self.assertTrue(len(res1) == 1)
- group_rid_1 = dom_sid_to_rid(ldb.schema_format_value("objectSID",
- res1[0]["objectSID"][0]))
+ group_rid_1 = security.dom_sid(ldb.schema_format_value("objectSID",
+ res1[0]["objectSID"][0])).split()[1]
res1 = ldb.search("cn=ldaptestgroup2,cn=users," + self.base_dn,
scope=SCOPE_BASE, attrs=["objectSID"])
self.assertTrue(len(res1) == 1)
- group_rid_2 = dom_sid_to_rid(ldb.schema_format_value("objectSID",
- res1[0]["objectSID"][0]))
+ group_rid_2 = security.dom_sid(ldb.schema_format_value("objectSID",
+ res1[0]["objectSID"][0])).split()[1]
# Try to create a user with an invalid primary group
- try:
+ try:
ldb.add({
"dn": "cn=ldaptestuser,cn=users," + self.base_dn,
"objectclass": ["user", "person"],
@@ -833,7 +833,7 @@ objectClass: container
self.assertTrue(len(res1) == 1)
self.assertFalse("primaryGroupToken" in res1[0])
- res1 = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn,
+ res1 = ldb.search("cn=ldaptestgroup,cn=users," + self.base_dn,
scope=SCOPE_BASE)
self.assertTrue(len(res1) == 1)
self.assertFalse("primaryGroupToken" in res1[0])
@@ -843,7 +843,7 @@ objectClass: container
self.assertTrue(len(res1) == 1)
primary_group_token = int(res1[0]["primaryGroupToken"][0])
- rid = dom_sid_to_rid(ldb.schema_format_value("objectSID", res1[0]["objectSID"][0]))
+ rid = security.dom_sid(ldb.schema_format_value("objectSID", res1[0]["objectSID"][0])).split()[1]
self.assertEquals(primary_group_token, rid)
m = Message()
diff --git a/source4/lib/ldb/tests/python/ldap_schema.py b/source4/lib/ldb/tests/python/ldap_schema.py
index f13a4fb..0a31db8 100755
--- a/source4/lib/ldb/tests/python/ldap_schema.py
+++ b/source4/lib/ldb/tests/python/ldap_schema.py
@@ -26,7 +26,7 @@ from ldb import ERR_NAMING_VIOLATION, ERR_CONSTRAINT_VIOLATION
from ldb import ERR_UNDEFINED_ATTRIBUTE_TYPE
from ldb import Message, MessageElement, Dn
from ldb import FLAG_MOD_ADD, FLAG_MOD_REPLACE, FLAG_MOD_DELETE
-from samba import Ldb, param, dom_sid_to_rid
+from samba import Ldb
from samba import UF_NORMAL_ACCOUNT, UF_TEMP_DUPLICATE_ACCOUNT
from samba import UF_SERVER_TRUST_ACCOUNT, UF_WORKSTATION_TRUST_ACCOUNT
from samba import UF_INTERDOMAIN_TRUST_ACCOUNT
diff --git a/source4/libcli/finddcs.c b/source4/libcli/finddcs.c
index 8330042..04b25d3 100644
--- a/source4/libcli/finddcs.c
+++ b/source4/libcli/finddcs.c
@@ -158,6 +158,9 @@ static void finddcs_name_resolved(struct composite_context *ctx)
if (composite_nomem(state->r.in.my_accountname, state->ctx)) return;
state->r.in.account_control = ACB_WSTRUST;
state->r.in.domain_sid = state->domain_sid;
+ if (state->r.in.domain_sid == NULL) {
+ state->r.in.domain_sid = talloc_zero(state, struct dom_sid);
+ }
ireq = irpc_call_send(state->msg_ctx, nbt_servers[0],
&ndr_table_irpc, NDR_NBTD_GETDCNAME,
diff --git a/source4/libcli/security/tests/bindings.py b/source4/libcli/security/tests/bindings.py
index 00fa05d..6fe3d54 100644
--- a/source4/libcli/security/tests/bindings.py
+++ b/source4/libcli/security/tests/bindings.py
@@ -2,17 +2,17 @@
# Unix SMB/CIFS implementation.
# Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2007
-#
+#
# 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
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
@@ -46,6 +46,7 @@ class SecurityTokenTests(unittest.TestCase):
class SecurityDescriptorTests(unittest.TestCase):
+
def setUp(self):
self.descriptor = security.descriptor()
@@ -100,6 +101,10 @@ class SecurityDescriptorTests(unittest.TestCase):
desc1 = security.descriptor.from_sddl(text, dom)
self.assertNotEqual(desc1.as_sddl(), desc1.as_sddl(dom))
+ def test_split(self):
+ dom = security.dom_sid("S-2-0-7")
+ self.assertEquals((security.dom_sid("S-2-0"), 7), dom.split())
+
class DomSidTests(unittest.TestCase):
def test_parse_sid(self):
diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c
index 02dc059..d04e257 100644
--- a/source4/librpc/ndr/py_security.c
+++ b/source4/librpc/ndr/py_security.c
@@ -41,6 +41,33 @@ static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods)
}
}
+static PyObject *py_dom_sid_split(PyObject *py_self, PyObject *args)
+{
+ struct dom_sid *self = py_talloc_get_ptr(py_self);
+ struct dom_sid *domain_sid;
+ TALLOC_CTX *mem_ctx;
+ uint32_t rid;
+ NTSTATUS status;
+ PyObject *py_domain_sid;
+
+ mem_ctx = talloc_new(NULL);
+ if (mem_ctx == NULL) {
+ PyErr_NoMemory();
+ return NULL;
+ }
+
+ status = dom_sid_split_rid(mem_ctx, self, &domain_sid, &rid);
+ if (!NT_STATUS_IS_OK(status)) {
+ PyErr_SetString(PyExc_RuntimeError, "dom_sid_split_rid failed");
+ talloc_free(mem_ctx);
+ return NULL;
+ }
+
+ py_domain_sid = py_talloc_steal(&dom_sid_Type, domain_sid);
+ talloc_free(mem_ctx);
+ return Py_BuildValue("(OI)", py_domain_sid, rid);
+}
+
static int py_dom_sid_cmp(PyObject *py_self, PyObject *py_other)
{
struct dom_sid *self = py_talloc_get_ptr(py_self), *other;
@@ -86,12 +113,21 @@ static int py_dom_sid_init(PyObject *self, PyObject *args, PyObject *kwargs)
return 0;
}
+static PyMethodDef py_dom_sid_extra_methods[] = {
+ { "split", (PyCFunction)py_dom_sid_split, METH_NOARGS,
+ "S.split() -> (domain_sid, rid)\n"
+ "Split a domain sid" },
+ { NULL }
+};
+
+
static void py_dom_sid_patch(PyTypeObject *type)
{
type->tp_init = py_dom_sid_init;
type->tp_str = py_dom_sid_str;
type->tp_repr = py_dom_sid_repr;
type->tp_compare = py_dom_sid_cmp;
+ PyType_AddMethods(type, py_dom_sid_extra_methods);
}
#define PY_DOM_SID_PATCH py_dom_sid_patch
diff --git a/source4/script/installmisc.sh b/source4/script/installmisc.sh
index 1617ff7..15fc645 100755
--- a/source4/script/installmisc.sh
+++ b/source4/script/installmisc.sh
@@ -49,7 +49,7 @@ cp setup/ad-schema/*.txt $SETUPDIR/ad-schema || exit 1
cp setup/display-specifiers/*.txt $SETUPDIR/display-specifiers || exit 1
echo "Installing sbin scripts from setup/*"
-for p in enableaccount newuser provision setexpiry setpassword
+for p in provision
do
cp setup/$p $SBINDIR || exit 1
chmod a+x $SBINDIR/$p
diff --git a/source4/scripting/python/pyglue.c b/source4/scripting/python/pyglue.c
index 9f01102..3d33e60 100644
--- a/source4/scripting/python/pyglue.c
+++ b/source4/scripting/python/pyglue.c
@@ -442,27 +442,6 @@ static PyObject *py_dsdb_make_schema_global(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
-static PyObject *py_dom_sid_to_rid(PyLdbObject *self, PyObject *args)
-{
- PyObject *py_sid;
- struct dom_sid *sid;
- uint32_t rid;
- NTSTATUS status;
-
- if(!PyArg_ParseTuple(args, "O", &py_sid))
- return NULL;
-
- sid = dom_sid_parse_talloc(NULL, PyString_AsString(py_sid));
-
- status = dom_sid_split_rid(NULL, sid, NULL, &rid);
- if (!NT_STATUS_IS_OK(status)) {
- PyErr_SetString(PyExc_RuntimeError, "dom_sid_split_rid failed");
- return NULL;
- }
-
- return PyInt_FromLong(rid);
-}
-
static PyMethodDef py_misc_methods[] = {
{ "generate_random_str", (PyCFunction)py_generate_random_str, METH_VARARGS,
"random_password(len) -> string\n"
@@ -506,8 +485,6 @@ static PyMethodDef py_misc_methods[] = {
NULL },
{ "dsdb_make_schema_global", (PyCFunction)py_dsdb_make_schema_global, METH_VARARGS,
NULL },
- { "dom_sid_to_rid", (PyCFunction)py_dom_sid_to_rid, METH_VARARGS,
- NULL },
{ "set_debug_level", (PyCFunction)py_set_debug_level, METH_VARARGS,
"set debug level" },
{ NULL }
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index f74304c..5d61c1b 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -2,20 +2,20 @@
# Unix SMB/CIFS implementation.
# Copyright (C) Jelmer Vernooij <jelmer at samba.org> 2007-2008
-#
+#
# Based on the original in EJS:
# Copyright (C) Andrew Tridgell <tridge at samba.org> 2005
-#
+#
# 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
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
-#
+#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
@@ -45,11 +45,11 @@ import ldb
import glue
class Ldb(ldb.Ldb):
- """Simple Samba-specific LDB subclass that takes care
+ """Simple Samba-specific LDB subclass that takes care
of setting up the modules dir, credentials pointers, etc.
-
- Please note that this is intended to be for all Samba LDB files,
- not necessarily the Sam database. For Sam-specific helper
+
+ Please note that this is intended to be for all Samba LDB files,
+ not necessarily the Sam database. For Sam-specific helper
functions see samdb.py.
"""
def __init__(self, url=None, lp=None, modules_dir=None, session_info=None,
@@ -65,7 +65,7 @@ class Ldb(ldb.Ldb):
:param options: Additional options (optional)
This is different from a regular Ldb file in that the Samba-specific
- modules-dir is used by default and that credentials and session_info
+ modules-dir is used by default and that credentials and session_info
can be passed through (required by some modules).
"""
@@ -122,10 +122,10 @@ class Ldb(ldb.Ldb):
# need one public, we will have to change this here
super(Ldb, self).set_create_perms(perms)
- def searchone(self, attribute, basedn=None, expression=None,
+ def searchone(self, attribute, basedn=None, expression=None,
scope=ldb.SCOPE_BASE):
"""Search for one attribute as a string.
-
+
:param basedn: BaseDN for the search.
:param attribute: Name of the attribute
:param expression: Optional search expression.
@@ -166,7 +166,7 @@ class Ldb(ldb.Ldb):
self.erase_users_computers(basedn)
# Delete the 'visible' records, and the invisble 'deleted' records (if this DB supports it)
- for msg in self.search(basedn, ldb.SCOPE_SUBTREE,
+ for msg in self.search(basedn, ldb.SCOPE_SUBTREE,
"(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))",
[], controls=["show_deleted:0"]):
try:
@@ -174,14 +174,14 @@ class Ldb(ldb.Ldb):
except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
# Ignore no such object errors
pass
-
- res = self.search(basedn, ldb.SCOPE_SUBTREE,
+
+ res = self.search(basedn, ldb.SCOPE_SUBTREE,
"(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))",
[], controls=["show_deleted:0"])
assert len(res) == 0
# delete the specials
- for attr in ["@SUBCLASSES", "@MODULES",
+ for attr in ["@SUBCLASSES", "@MODULES",
"@OPTIONS", "@PARTITION", "@KLUDGEACL"]:
try:
self.delete(attr)
@@ -191,7 +191,7 @@ class Ldb(ldb.Ldb):
def erase(self):
"""Erase this ldb, removing all records."""
-
+
self.erase_except_schema_controlled()
# delete the specials
@@ -207,13 +207,12 @@ class Ldb(ldb.Ldb):
def erase_recursive(self, dn):
try:
- res = self.search(base=dn, scope=ldb.SCOPE_ONELEVEL, attrs=[],
+ res = self.search(base=dn, scope=ldb.SCOPE_ONELEVEL, attrs=[],
controls=["show_deleted:0"])
except ldb.LdbError, (ldb.ERR_NO_SUCH_OBJECT, _):
# Ignore no such object errors
return
- pass
-
+
for msg in res:
erase_recursive(self, msg.dn)
@@ -223,7 +222,7 @@ class Ldb(ldb.Ldb):
# Ignore no such object errors
pass
- res = self.search("", ldb.SCOPE_BASE, "(objectClass=*)",
+ res = self.search("", ldb.SCOPE_BASE, "(objectClass=*)",
["namingContexts"])
assert len(res) == 1
if not "namingContexts" in res[0]:
@@ -285,14 +284,14 @@ class Ldb(ldb.Ldb):
def set_invocation_id(self, invocation_id):
"""Set the invocation id for this SamDB handle.
-
+
:param invocation_id: GUID of the invocation id.
"""
glue.dsdb_set_ntds_invocation_id(self, invocation_id)
def set_opaque_integer(self, name, value):
"""Set an integer as an opaque (a flag or other value) value on the database
-
+
:param name: The name for the opaque value
:param value: The integer value
"""
@@ -302,7 +301,7 @@ class Ldb(ldb.Ldb):
def substitute_var(text, values):
"""substitute strings of the form ${NAME} in str, replacing
with substitutions from subobj.
-
+
:param text: Text in which to subsitute.
:param values: Dictionary with keys and values.
"""
@@ -318,21 +317,21 @@ def substitute_var(text, values):
def check_all_substituted(text):
"""Make sure that all substitution variables in a string have been replaced.
If not, raise an exception.
-
+
:param text: The text to search for substitution variables
"""
if not "${" in text:
return
-
+
var_start = text.find("${")
var_end = text.find("}", var_start)
-
+
raise Exception("Not all variables substituted: %s" % text[var_start:var_end+1])
def read_and_sub_file(file, subst_vars):
"""Read a file and sub in variables found in it
-
+
:param file: File to be read (typically from setup directory)
param subst_vars: Optional variables to subsitute in the file.
"""
@@ -370,15 +369,6 @@ def valid_netbios_name(name):
return True
-def dom_sid_to_rid(sid_str):
- """Converts a domain SID to the relative RID.
-
- :param sid_str: The domain SID formatted as string
- """
-
- return glue.dom_sid_to_rid(sid_str)
-
-
version = glue.version
# "userAccountControl" flags
diff --git a/source4/scripting/python/samba/netcmd/__init__.py b/source4/scripting/python/samba/netcmd/__init__.py
index 1a04210..a204ab8 100644
--- a/source4/scripting/python/samba/netcmd/__init__.py
+++ b/source4/scripting/python/samba/netcmd/__init__.py
@@ -40,7 +40,7 @@ class Command(object):
name = property(_get_name)
- def usage(self, args):
+ def usage(self, *args):
parser, _ = self._create_parser()
parser.print_usage()
@@ -49,7 +49,7 @@ class Command(object):
def _get_synopsis(self):
ret = self.name
if self.takes_args:
- ret += " " + " ".join(self.takes_args)
+ ret += " " + " ".join([x.upper() for x in self.takes_args])
return ret
synopsis = property(_get_synopsis)
@@ -81,8 +81,16 @@ class Command(object):
for option in option_group.option_list:
del kwargs[option.dest]
kwargs.update(optiongroups)
- if len(args) != len(self.takes_args):
- self.usage(args)
+ min_args = 0
+ max_args = 0
+ for i, arg in enumerate(self.takes_args):
+ if arg[-1] not in ("?", "*"):
+ min_args += 1
+ max_args += 1
+ if arg[-1] == "*":
+ max_args = -1
+ if len(args) < min_args or (max_args != -1 and len(args) > max_args):
+ self.usage(*args)
return -1
try:
return self.run(*args, **kwargs)
@@ -100,21 +108,22 @@ class SuperCommand(Command):
subcommands = {}
- def run(self, subcommand, *args, **kwargs):
- if not subcommand in subcommands:
- print >>sys.stderr, "ERROR: No such subcommand '%s'" % subcommand
- return subcommands[subcommand].run(*args, **kwargs)
-
- def usage(self, subcommand=None, *args, **kwargs):
+ def _run(self, myname, subcommand=None, *args):
if subcommand is None:
- print "Available subcommands"
- for subcommand in subcommands:
+ print "Available subcommands:"
--
Samba Shared Repository
More information about the samba-cvs
mailing list