[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Thu Aug 25 23:05:03 MDT 2011


The branch, master has been updated
       via  099b9db py-samba3-test: Copy sample database in tempdir before running test
       via  7a8565f samba3dump: Update the code using modified samba3 module with passdb api
       via  76ff9bf s3_upgrade: Set lock directory to correct directory
       via  eebb37c py-samba3-test: Set lock directory to the datadir
       via  7017e6b testdata: Set netbios name in the samba3 configuation
       via  d8465f2 s3_upgrade: Update commandline options and use updated samba3 python module
       via  d2536b3 py-samba3: Use passdb/param wrapper for samba3 module
       via  17c74e5 s3-passdb: Make domain_sid argument optional for search_aliases method
       via  0cfeb65 s3-passdb: Return assigned number of hours and not MAX_HOURS_LEN
       via  a38a3b1 s3-passdb: Convert lm_pw and nt_pw to python string using length
       via  b206816 script: Fix the name of the script in autogenerated header file
       via  b5da5f7 s4-param: Use s3 dump method if s3 context is defined
       via  d847f62 s3-param: Add a dump() method to output parameters
       via  7f67d7b s3_upgrade: Let python generate backtrace for unknown exceptions
       via  886203f s3_upgrade: Add document strings for python methods
      from  a3538b9 werror: remove duplicate definition of WERR_INVALID_OWNER

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 099b9db4045d6d12ec9f55647def5d1af0baa3c6
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Aug 26 13:19:18 2011 +1000

    py-samba3-test: Copy sample database in tempdir before running test
    
    Samba3 python module using passdb api modifies the database files, to
    upgrade them to latest version. So copy the sample database before
    running tests on it.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User: Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date: Fri Aug 26 07:04:15 CEST 2011 on sn-devel-104

commit 7a8565fc59d917b83561dd32d14c6c0c98334d3c
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Aug 26 13:00:48 2011 +1000

    samba3dump: Update the code using modified samba3 module with passdb api
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit 76ff9bffd873e923c3fa156c60ccd34e7de3cdc2
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Aug 26 10:01:29 2011 +1000

    s3_upgrade: Set lock directory to correct directory
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit eebb37c9b23fab3c4dc0790352a557abaf0c9898
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Aug 26 10:00:47 2011 +1000

    py-samba3-test: Set lock directory to the datadir
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit 7017e6b8824e9b1b4035299e42a1f93581406b92
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Aug 25 17:25:28 2011 +1000

    testdata: Set netbios name in the samba3 configuation
    
    To correctly find the domain sid, passdb api uses netbios name to
    look up secrets database. If no nebios name is configured, passdb uses
    current hostname and adds entry for hostname in secrets and uses that
    instead of the intended one.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit d8465f2a918deb9fb94f4dc5ad85bc07c073bd05
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Aug 25 17:20:05 2011 +1000

    s3_upgrade: Update commandline options and use updated samba3 python module
    
    upgrade_from_s3 script now requires samba3 configuration file and target
    directory for samba4 database. In addition, it either uses --libdir option
    or --testparm option to correctly guess the paths for samba3 databases
    (private dir and state directory).
    
    Usage: upgrade_from_s3 [options] <configuration_file> <targetdir>
    
    Input arguments are:
      <configuration_file> - path to existing smb.conf
      <targetdir>          - directory in which samba4 database will be created
    
    In addition, specify either samba3 database directory (with --libdir) or
    samba3 testparm utility (with --testparm).
    
    Before using passdb interface, initialize s3 loadparm context using
    correct path settings for private dir and state directory.
    
    Export account policy from s3 to s4.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit d2536b31200106ad0bbea60abd3e654c23540e6d
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Aug 25 17:10:23 2011 +1000

    py-samba3: Use passdb/param wrapper for samba3 module
    
    Instead of parsing samba3 database files (password, group mapping,
    account policy, secrets), use passdb python wrapper.
    
    Similarly for parsing configuration, use samba3 param python wrapper.
    
    Other databases (idmap, registry, wins) are still parsed in python.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit 17c74e5dfd02df7e935171422477dea3f1bce057
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Aug 25 16:53:26 2011 +1000

    s3-passdb: Make domain_sid argument optional for search_aliases method
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit 0cfeb65a0b559e2a7e5f6e672d68d9d076b6fd7b
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Aug 25 16:50:34 2011 +1000

    s3-passdb: Return assigned number of hours and not MAX_HOURS_LEN
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit a38a3b16e1b39985d8d9e084a1ca31e7e14d0198
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Thu Aug 25 16:48:40 2011 +1000

    s3-passdb: Convert lm_pw and nt_pw to python string using length
    
    lm_pw and nt_pw are fixed length strings and convert them to python
    strings as fixed length strings.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit b2068162f71d762fb862daa8f84cbfce64217161
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Wed Aug 24 16:31:12 2011 +1000

    script: Fix the name of the script in autogenerated header file
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit b5da5f7379d5efeb3828841ccb6d07ed821817cd
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Aug 22 16:32:03 2011 +1000

    s4-param: Use s3 dump method if s3 context is defined
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit d847f62161cbb4a2b5fe7f1c1105ff2e478e4858
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Aug 22 16:26:13 2011 +1000

    s3-param: Add a dump() method to output parameters
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit 7f67d7b5caa0915820b9ae3f9b83b7b02c63b307
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Aug 22 09:43:20 2011 +1000

    s3_upgrade: Let python generate backtrace for unknown exceptions
    
    Catch known exceptions only.
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

commit 886203f3bc2ed445c6b3a03dbe145ecaa1b44050
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Mon Aug 22 09:42:13 2011 +1000

    s3_upgrade: Add document strings for python methods
    
    Signed-off-by: Andrew Bartlett <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 script/mkparamdefs.pl                             |    2 +-
 source3/param/loadparm_ctx.c                      |    1 +
 source3/passdb/py_passdb.c                        |   26 +-
 source4/param/loadparm.c                          |    4 +
 source4/script/mks3param.pl                       |    1 +
 source4/scripting/bin/samba3dump                  |   93 +++--
 source4/scripting/python/samba/samba3/__init__.py |  454 +-------------------
 source4/scripting/python/samba/tests/samba3.py    |  237 +++++-------
 source4/scripting/python/samba/upgrade.py         |  271 +++++--------
 source4/setup/tests/blackbox_s3upgrade.sh         |    4 +-
 source4/setup/upgrade_from_s3                     |   84 +++-
 testdata/samba3/smb.conf                          |    1 +
 12 files changed, 369 insertions(+), 809 deletions(-)


Changeset truncated at 500 lines:

diff --git a/script/mkparamdefs.pl b/script/mkparamdefs.pl
index d978420..eacdebd 100644
--- a/script/mkparamdefs.pl
+++ b/script/mkparamdefs.pl
@@ -85,7 +85,7 @@ sub print_header($$$)
 	my ($file, $header_name,$generate_scope) = @_;
 	$file->("#ifndef $header_name\n");
 	$file->("#define $header_name\n\n");
-$file->("/* This file was automatically generated by mkparmdefs.pl. DO NOT EDIT */\n\n");
+$file->("/* This file was automatically generated by mkparamdefs.pl. DO NOT EDIT */\n\n");
 	$file->("/**\n");
 	if ($generate_scope eq "GLOBAL") {
 	    $file->(" * This structure describes global (ie., server-wide) parameters.\n");
diff --git a/source3/param/loadparm_ctx.c b/source3/param/loadparm_ctx.c
index abd7dbe..5cf8ce6 100644
--- a/source3/param/loadparm_ctx.c
+++ b/source3/param/loadparm_ctx.c
@@ -47,6 +47,7 @@ static const struct loadparm_s3_context s3_fns =
 	.get_numservices = lp_numservices,
 	.load = lp_load_for_s4_ctx,
 	.set_cmdline = lp_set_cmdline,
+	.dump = lp_dump,
 
 	.server_role = lp_server_role,
 
diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c
index e23f475..f1f138d 100644
--- a/source3/passdb/py_passdb.c
+++ b/source3/passdb/py_passdb.c
@@ -613,7 +613,7 @@ static PyObject *py_samu_get_lanman_passwd(PyObject *obj, void *closure)
 		Py_RETURN_NONE;
 	}
 
-	py_lm_pw = PyString_FromString(lm_pw);
+	py_lm_pw = PyString_FromStringAndSize(lm_pw, LM_HASH_LEN);
 	return py_lm_pw;
 }
 
@@ -639,7 +639,7 @@ static PyObject *py_samu_get_nt_passwd(PyObject *obj, void *closure)
 		Py_RETURN_NONE;
 	}
 
-	py_nt_pw = PyString_FromString(nt_pw);
+	py_nt_pw = PyString_FromStringAndSize(nt_pw, NT_HASH_LEN);
 	return py_nt_pw;
 }
 
@@ -774,19 +774,20 @@ static PyObject *py_samu_get_hours(PyObject *obj, void *closure)
 	struct samu *sam_acct = (struct samu *)pytalloc_get_ptr(obj);
 	PyObject *py_hours;
 	const char *hours;
-	int i;
+	int hours_len, i;
 
 	hours = (const char *)pdb_get_hours(sam_acct);
 	if(! hours) {
 		Py_RETURN_NONE;
 	}
 
-	if ((py_hours = PyList_New(MAX_HOURS_LEN)) == NULL) {
+	hours_len = pdb_get_hours_len(sam_acct);
+	if ((py_hours = PyList_New(hours_len)) == NULL) {
 		PyErr_NoMemory();
 		return NULL;
 	}
 
-	for (i=0; i<MAX_HOURS_LEN; i++) {
+	for (i=0; i<hours_len; i++) {
 		PyList_SetItem(py_hours, i, PyInt_FromLong(hours[i]));
 	}
 	return py_hours;
@@ -2496,9 +2497,12 @@ static PyObject *py_pdb_search_aliases(pytalloc_Object *self, PyObject *args)
 	struct samr_displayentry *entry;
 	PyObject *py_aliaslist, *py_dict;
 	PyObject *py_domain_sid;
-	struct dom_sid *dom_sid;
+	struct dom_sid *domain_sid = NULL;
+
+	py_domain_sid = Py_None;
+	Py_INCREF(Py_None);
 
-	if (!PyArg_ParseTuple(args, "O!:search_users", dom_sid_Type, &py_domain_sid)) {
+	if (!PyArg_ParseTuple(args, "|O!:search_aliases", dom_sid_Type, &py_domain_sid)) {
 		return NULL;
 	}
 
@@ -2509,7 +2513,9 @@ static PyObject *py_pdb_search_aliases(pytalloc_Object *self, PyObject *args)
 		return NULL;
 	}
 
-	dom_sid = pytalloc_get_ptr(py_domain_sid);
+	if (py_domain_sid != Py_None) {
+		domain_sid = pytalloc_get_ptr(py_domain_sid);
+	}
 
 	search = talloc_zero(tframe, struct pdb_search);
 	if (search == NULL) {
@@ -2518,7 +2524,7 @@ static PyObject *py_pdb_search_aliases(pytalloc_Object *self, PyObject *args)
 		return NULL;
 	}
 
-	if (!methods->search_aliases(methods, search, dom_sid)) {
+	if (!methods->search_aliases(methods, search, domain_sid)) {
 		PyErr_Format(py_pdb_error, "Unable to search aliases");
 		talloc_free(tframe);
 		return NULL;
@@ -3437,7 +3443,7 @@ static PyMethodDef py_pdb_methods[] = {
 		Search unix only groups. \n \
 		Each list entry is dictionary with keys - idx, rid, acct_flags, account_name, fullname, description." },
 	{ "search_aliases", (PyCFunction)py_pdb_search_aliases, METH_VARARGS,
-		"search_aliases(domain_sid) -> List\n\n \
+		"search_aliases([domain_sid]) -> List\n\n \
 		Search aliases. domain_sid is dcerpc.security.dom_sid object.\n \
 		Each list entry is dictionary with keys - idx, rid, acct_flags, account_name, fullname, description." },
 	{ "uid_to_sid", (PyCFunction)py_pdb_uid_to_sid, METH_VARARGS,
diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 74c0550..e4f1c85 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -3589,6 +3589,10 @@ void lpcfg_dump(struct loadparm_context *lp_ctx, FILE *f, bool show_defaults,
 {
 	int iService;
 
+	if (lp_ctx->s3_fns) {
+		return lp_ctx->s3_fns->dump(f, show_defaults, maxtoprint);
+	}
+
 	defaults_saved = !show_defaults;
 
 	dump_globals(lp_ctx, f, show_defaults);
diff --git a/source4/script/mks3param.pl b/source4/script/mks3param.pl
index 37277c2..2679b5a 100644
--- a/source4/script/mks3param.pl
+++ b/source4/script/mks3param.pl
@@ -94,6 +94,7 @@ sub print_header($$)
 	$file->("\tint (*get_numservices)(void);\n");
 	$file->("\tbool (*load)(const char *filename);\n");
 	$file->("\tbool (*set_cmdline)(const char *pszParmName, const char *pszParmValue);\n");
+	$file->("\tvoid (*dump)(FILE *f, bool show_defaults, int maxtoprint);\n");
 }
 
 sub print_footer($$) 
diff --git a/source4/scripting/bin/samba3dump b/source4/scripting/bin/samba3dump
index 0edbf6e..a1a893a 100755
--- a/source4/scripting/bin/samba3dump
+++ b/source4/scripting/bin/samba3dump
@@ -13,6 +13,8 @@ sys.path.insert(0, "bin/python")
 
 import samba
 import samba.samba3
+from samba.samba3 import param as s3param
+from samba.dcerpc import lsa
 
 parser = optparse.OptionParser("samba3dump <libdir> [<smb.conf>]")
 parser.add_option("--format", type="choice", metavar="FORMAT",
@@ -29,36 +31,36 @@ def print_header(txt):
 
 def print_samba3_policy(pol):
     print_header("Account Policies")
-    print "Min password length: %d" % pol.min_password_length
-    print "Password history length: %d" % pol.password_history
-    if pol.user_must_logon_to_change_password:
-        print "User must logon to change password: %d" % pol.user_must_logon_to_change_password
-    if pol.maximum_password_age:
-        print "Maximum password age: %d" % pol.maximum_password_age
-    if pol.minimum_password_age:
-        print "Minimum password age: %d" % pol.minimum_password_age
-    if pol.lockout_duration:
-        print "Lockout duration: %d" % pol.lockout_duration
-    if pol.reset_count_minutes:
-        print "Reset Count Minutes: %d" % pol.reset_count_minutes
-    if pol.bad_lockout_minutes:
-        print "Bad Lockout Minutes: %d" % pol.bad_lockout_minutes
-    if pol.disconnect_time:
-        print "Disconnect Time: %d" % pol.disconnect_time
-    if pol.refuse_machine_password_change:
-        print "Refuse Machine Password Change: %d" % pol.refuse_machine_password_change
+    print "Min password length: %d" % pol['min password length']
+    print "Password history length: %d" % pol['password history']
+    if pol['user must logon to change password']:
+        print "User must logon to change password: %d" % pol['user must logon to change password']
+    if pol['maximum password age']:
+        print "Maximum password age: %d" % pol['maximum password age']
+    if pol['minimum password age']:
+        print "Minimum password age: %d" % pol['minimum password age']
+    if pol['lockout duration']:
+        print "Lockout duration: %d" % pol['lockout duration']
+    if pol['reset count minutes']:
+        print "Reset Count Minutes: %d" % pol['reset count minutes']
+    if pol['bad lockout attempt']:
+        print "Bad Lockout Minutes: %d" % pol['bad lockout attempt']
+    if pol['disconnect time']:
+        print "Disconnect Time: %d" % pol['disconnect time']
+    if pol['refuse machine password change']:
+        print "Refuse Machine Password Change: %d" % pol['refuse machine password change']
 
 def print_samba3_sam(samdb):
     print_header("SAM Database")
-    for user in samdb:
-        print "%s" % user
+    for user in samdb.search_users(0):
+        print "%s (%d): %s" % (user['account_name'], user['rid'], user['fullname'])
 
-def print_samba3_shares(shares):
+def print_samba3_shares(lp):
     print_header("Configured shares")
-    for s in shares:
-        print "--- %s ---" % s.name
-        for p in s:
-            print "\t%s = %s" % (p.key, p.value)
+    for s in lp.services():
+        print "--- %s ---" % s
+        for p in ['path']:
+            print "\t%s = %s" % (p, lp.get(p, s))
         print ""
 
 def print_samba3_secrets(secrets):
@@ -113,12 +115,14 @@ def print_samba3_winsdb(winsdb):
 def print_samba3_groupmappings(groupdb):
     print_header("Group Mappings")
     
-    for sid in groupdb.groupsids():
-        print "\t--- Group: %s ---" % sid
+    for g in groupdb.enum_group_mapping(samba.samba3.passdb.get_global_sam_sid(),
+                                        lsa.SID_NAME_DOM_GRP):
+        print "\t--- Group: %s ---" % g.sid
 
 def print_samba3_aliases(groupdb):
-    for sid in groupdb.aliases():
-        print "\t--- Alias: %s ---" % sid
+    for g in groupdb.enum_group_mapping(samba.samba3.passdb.get_global_sam_sid(),
+                                        lsa.SID_NAME_ALIAS):
+        print "\t--- Alias: %s ---" % g.sid
 
 def print_samba3_idmapdb(idmapdb):
     print_header("Winbindd SID<->GID/UID mappings")
@@ -133,33 +137,42 @@ def print_samba3_idmapdb(idmapdb):
         print "%s -> GID %d" % (idmapdb.get_group_sid(gid), gid)
 
 def print_samba3(samba3):
-    print_samba3_policy(samba3.get_policy_db())
+    passdb = samba3.get_sam_db()
+    print_samba3_policy(passdb.get_account_policy())
     print_samba3_winsdb(samba3.get_wins_db())
     print_samba3_regdb(samba3.get_registry())
     print_samba3_secrets(samba3.get_secrets_db())
     print_samba3_idmapdb(samba3.get_idmap_db())
-    print_samba3_sam(samba3.get_sam_db())
-    groupdb = samba3.get_groupmapping_db()
-    print_samba3_groupmappings(groupdb)
-    print_samba3_aliases(groupdb)
-    print_samba3_shares(samba3.get_shares())
+    print_samba3_sam(passdb)
+    print_samba3_groupmappings(passdb)
+    print_samba3_aliases(passdb)
+    print_samba3_shares(samba3.lp)
 
 def print_samba3_summary(samba3):
     print "WINS db entries: %d" % len(samba3.get_wins_db())
     print "Registry key count: %d" % len(samba3.get_registry())
-    groupdb = samba3.get_groupmapping_db()
-    print "Groupmap count: %d" % len(list(groupdb.groupsids()))
-    print "Alias count: %d" % len(list(groupdb.aliases()))
+    passdb = samba3.get_sam_db()
+    print "Groupmap count: %d" % len(passdb.enum_group_mapping())
+    print "Alias count: %d" % len(passdb.search_aliases())
     idmapdb = samba3.get_idmap_db()
     print "Idmap count: %d" % (len(list(idmapdb.uids())) + len(list(idmapdb.gids())))
 
+if len(args) < 1:
+    parser.print_help()
+    sys.exit(1)
+
 libdir = args[0]
-if len(args) > 1:
+if len(args) < 1:
     smbconf = args[1]
 else:
     smbconf = os.path.join(libdir, "smb.conf")
 
-samba3 = samba.samba3.Samba3(libdir, smbconf)
+s3_lp = s3param.get_context()
+s3_lp.set("private dir", libdir)
+s3_lp.set("state directory", libdir)
+s3_lp.set("lock directory", libdir)
+s3_lp.load(smbconf)
+samba3 = samba.samba3.Samba3(smbconf, s3_lp)
 
 if opts.format == "summary":
     print_samba3_summary(samba3)
diff --git a/source4/scripting/python/samba/samba3/__init__.py b/source4/scripting/python/samba/samba3/__init__.py
index 385d933..dd2f927 100644
--- a/source4/scripting/python/samba/samba3/__init__.py
+++ b/source4/scripting/python/samba/samba3/__init__.py
@@ -26,6 +26,9 @@ import os
 import struct
 import tdb
 
+import passdb
+import param as s3param
+
 
 def fetch_uint32(tdb, key):
     try:
@@ -125,74 +128,6 @@ class Registry(TdbDatabase):
         return ret
 
 
-class PolicyDatabase(TdbDatabase):
-    """Samba 3 Account Policy database reader."""
-    def __init__(self, file):
-        """Open a policy database
-
-        :param file: Path to the file to open.
-        """
-        super(PolicyDatabase, self).__init__(file)
-        self.min_password_length = fetch_uint32(self.tdb, "min password length\x00")
-        self.password_history = fetch_uint32(self.tdb, "password history\x00")
-        self.user_must_logon_to_change_password = fetch_uint32(self.tdb, "user must logon to change pasword\x00")
-        self.maximum_password_age = fetch_uint32(self.tdb, "maximum password age\x00")
-        self.minimum_password_age = fetch_uint32(self.tdb, "minimum password age\x00")
-        self.lockout_duration = fetch_uint32(self.tdb, "lockout duration\x00")
-        self.reset_count_minutes = fetch_uint32(self.tdb, "reset count minutes\x00")
-        self.bad_lockout_minutes = fetch_uint32(self.tdb, "bad lockout minutes\x00")
-        self.disconnect_time = fetch_int32(self.tdb, "disconnect time\x00")
-        self.refuse_machine_password_change = fetch_uint32(self.tdb, "refuse machine password change\x00")
-
-        # FIXME: Read privileges as well
-
-
-GROUPDB_DATABASE_VERSION_V1 = 1 # native byte format.
-GROUPDB_DATABASE_VERSION_V2 = 2 # le format.
-
-GROUP_PREFIX = "UNIXGROUP/"
-
-# Alias memberships are stored reverse, as memberships. The performance
-# critical operation is to determine the aliases a SID is member of, not
-# listing alias members. So we store a list of alias SIDs a SID is member of
-# hanging of the member as key.
-MEMBEROF_PREFIX = "MEMBEROF/"
-
-class GroupMappingDatabase(TdbDatabase):
-    """Samba 3 group mapping database reader."""
-    def _check_version(self):
-        assert fetch_int32(self.tdb, "INFO/version\x00") in (GROUPDB_DATABASE_VERSION_V1, GROUPDB_DATABASE_VERSION_V2)
-
-    def groupsids(self):
-        """Retrieve the SIDs for the groups in this database.
-
-        :return: List with sids as strings.
-        """
-        for k in self.tdb.iterkeys():
-            if k.startswith(GROUP_PREFIX):
-                yield k[len(GROUP_PREFIX):].rstrip("\0")
-
-    def get_group(self, sid):
-        """Retrieve the group mapping information for a particular group.
-
-        :param sid: SID of the group
-        :return: None if the group can not be found, otherwise
-            a tuple with gid, sid_name_use, the NT name and comment.
-        """
-        data = self.tdb.get("%s%s\0" % (GROUP_PREFIX, sid))
-        if data is None:
-            return data
-        (gid, sid_name_use) = struct.unpack("<lL", data[0:8])
-        (nt_name, comment, _) = data[8:].split("\0")
-        return (gid, sid_name_use, nt_name, comment)
-
-    def aliases(self):
-        """Retrieve the aliases in this database."""
-        for k in self.tdb.iterkeys():
-            if k.startswith(MEMBEROF_PREFIX):
-                yield k[len(MEMBEROF_PREFIX):].rstrip("\0")
-
-
 # High water mark keys
 IDMAP_HWM_GROUP = "GROUP HWM\0"
 IDMAP_HWM_USER = "USER HWM\0"
@@ -229,6 +164,11 @@ class IdmapDatabase(TdbDatabase):
                 yield int(k[len(IDMAP_GROUP_PREFIX):].rstrip("\0"))
 
     def get_sid(self, xid, id_type):
+        """Retrive SID associated with a particular id and type.
+
+        :param xid: UID or GID to retrive SID for.
+        :param id_type: Type of id specified - 'UID' or 'GID'
+        """
         data = self.tdb.get("%s %s\0" % (id_type, str(xid)))
         if data is None:
             return data
@@ -354,266 +294,6 @@ class Shares(object):
         return self.lp.__iter__()
 
 
-ACB_DISABLED = 0x00000001
-ACB_HOMDIRREQ = 0x00000002
-ACB_PWNOTREQ = 0x00000004
-ACB_TEMPDUP = 0x00000008
-ACB_NORMAL = 0x00000010
-ACB_MNS = 0x00000020
-ACB_DOMTRUST = 0x00000040
-ACB_WSTRUST = 0x00000080
-ACB_SVRTRUST = 0x00000100
-ACB_PWNOEXP = 0x00000200
-ACB_AUTOLOCK = 0x00000400
-ACB_ENC_TXT_PWD_ALLOWED = 0x00000800
-ACB_SMARTCARD_REQUIRED = 0x00001000
-ACB_TRUSTED_FOR_DELEGATION = 0x00002000
-ACB_NOT_DELEGATED = 0x00004000
-ACB_USE_DES_KEY_ONLY = 0x00008000
-ACB_DONT_REQUIRE_PREAUTH = 0x00010000
-ACB_PW_EXPIRED = 0x00020000
-ACB_NO_AUTH_DATA_REQD = 0x00080000
-
-acb_info_mapping = {
-        'N': ACB_PWNOTREQ,  # 'N'o password.
-        'D': ACB_DISABLED,  # 'D'isabled.
-        'H': ACB_HOMDIRREQ, # 'H'omedir required.
-        'T': ACB_TEMPDUP,   # 'T'emp account.
-        'U': ACB_NORMAL,    # 'U'ser account (normal).
-        'M': ACB_MNS,       # 'M'NS logon user account. What is this ?
-        'W': ACB_WSTRUST,   # 'W'orkstation account.
-        'S': ACB_SVRTRUST,  # 'S'erver account.
-        'L': ACB_AUTOLOCK,  # 'L'ocked account.
-        'X': ACB_PWNOEXP,   # No 'X'piry on password
-        'I': ACB_DOMTRUST,  # 'I'nterdomain trust account.
-        ' ': 0
-        }
-
-def decode_acb(text):
-    """Decode a ACB field.
-
-    :param text: ACB text
-    :return: integer with flags set.
-    """
-    assert not "[" in text and not "]" in text
-    ret = 0
-    for x in text:
-        ret |= acb_info_mapping[x]
-    return ret
-
-
-class SAMUser(object):
-    """Samba 3 SAM User.
-
-    :note: Unknown or unset fields are set to None.
-    """
-    def __init__(self, name, uid=None, lm_password=None, nt_password=None, acct_ctrl=None,
-                 last_change_time=None, nt_username=None, fullname=None, logon_time=None, logoff_time=None,
-                 acct_desc=None, group_rid=None, bad_password_count=None, logon_count=None,
-                 domain=None, dir_drive=None, munged_dial=None, homedir=None, logon_script=None,
-                 profile_path=None, workstations=None, kickoff_time=None, bad_password_time=None,
-                 pass_last_set_time=None, pass_can_change_time=None, pass_must_change_time=None,
-                 user_rid=None, unknown_6=None, nt_password_history=None,
-                 unknown_str=None, hours=None, logon_divs=None):
-        self.username = name
-        self.uid = uid
-        self.lm_password = lm_password
-        self.nt_password = nt_password
-        self.acct_ctrl = acct_ctrl
-        self.pass_last_set_time = last_change_time
-        self.nt_username = nt_username
-        self.fullname = fullname
-        self.logon_time = logon_time
-        self.logoff_time = logoff_time
-        self.acct_desc = acct_desc
-        self.group_rid = group_rid
-        self.bad_password_count = bad_password_count
-        self.logon_count = logon_count
-        self.domain = domain
-        self.dir_drive = dir_drive
-        self.munged_dial = munged_dial
-        self.homedir = homedir
-        self.logon_script = logon_script
-        self.profile_path = profile_path
-        self.workstations = workstations
-        self.kickoff_time = kickoff_time
-        self.bad_password_time = bad_password_time
-        self.pass_can_change_time = pass_can_change_time
-        self.pass_must_change_time = pass_must_change_time
-        self.user_rid = user_rid
-        self.unknown_6 = unknown_6
-        self.nt_password_history = nt_password_history
-        self.unknown_str = unknown_str
-        self.hours = hours
-        self.logon_divs = logon_divs
-
-    def __eq__(self, other):
-        if not isinstance(other, SAMUser):
-            return False
-        return self.__dict__ == other.__dict__
-
-
-class SmbpasswdFile(object):
-    """Samba 3 smbpasswd file reader."""
-    def __init__(self, file):
-        self.users = {}
-        f = open(file, 'r')
-        for l in f.readlines():


-- 
Samba Shared Repository


More information about the samba-cvs mailing list