The branch, master has been updated
       via  7e31704 selftest: Remove unused --analyse argument.
       via  1716cdb dsdb: Use short path for ldb_handlers.h, in case ldb is 
installed in the system.
       via  8dd0c8c ldb: Use waf as default build system.
       via  c031329 ldb: Depend directly on replace, fixes the build on systems 
with tdb and tevent installed in the system.
       via  1c3c9a4 s4-param: Fix more memory leaks, invalid memory context.
       via  5b10c82 s3-selftest: Fix test prefixes in subunit output.
       via  3fea9df s4-param: Check type when converting python object to 
lp_ctx, fix some memory leaks.
       via  63031a2 pygensec: Implement start_mech_by_name().
       via  6abe823 subunithelper: Cope with errors outside of testsuites.
       via  5a75fb1 ndrdump: Move blackbox test to standard python namespace.
       via  18f10ee s4/selftest: Simplify running of python tests.
       via  31d5ac0 selftest: Let tests add prefix to tests by themselve.
      from  54f0da3 s3: Use asprintf where appropriate

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


- Log -----------------------------------------------------------------
commit 7e31704762b63ac580f3b778520d9f5f7d212cbe
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 17:47:28 2010 -0700

    selftest: Remove unused --analyse argument.

commit 1716cdbef36b7905c08d89de1ca3de4b61e3fe0f
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 17:17:42 2010 -0700

    dsdb: Use short path for ldb_handlers.h, in case ldb is installed in the
    system.

commit 8dd0c8c5460c6f16367a4a73f0ce4b27d5acab4f
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 17:17:25 2010 -0700

    ldb: Use waf as default build system.

commit c031329af1f4300237ba200a4d6ff5eb041d8e3d
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 17:15:38 2010 -0700

    ldb: Depend directly on replace, fixes the build on systems with
    tdb and tevent installed in the system.

commit 1c3c9a483be6d63b8efb67bfd2c04ef9302ccce6
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 16:44:17 2010 -0700

    s4-param: Fix more memory leaks, invalid memory context.

commit 5b10c82a5837073836fcf04152a6f032c98c93d1
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 15:36:06 2010 -0700

    s3-selftest: Fix test prefixes in subunit output.

commit 3fea9df85a7d489b81e21a7a63f9e115de712d4c
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 15:35:36 2010 -0700

    s4-param: Check type when converting python object to lp_ctx, fix some
    memory leaks.

commit 63031a2a78cff19f1f17137adfbc85a4df05ae36
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 13:57:07 2010 -0700

    pygensec: Implement start_mech_by_name().

commit 6abe823ce6c6fd1804d45b7c63c770d22b3e7265
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 13:05:55 2010 -0700

    subunithelper: Cope with errors outside of testsuites.

commit 5a75fb194a290cb09fc03312262bd57196e86cb9
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 12:52:29 2010 -0700

    ndrdump: Move blackbox test to standard python namespace.

commit 18f10eec0ea55108e97da019f07a18b8854c2883
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 11:39:53 2010 -0700

    s4/selftest: Simplify running of python tests.

commit 31d5ac05402ed9ac8158d143283c7f8b2d7bb7b4
Author: Jelmer Vernooij <[email protected]>
Date:   Wed Sep 22 11:30:34 2010 -0700

    selftest: Let tests add prefix to tests by themselve.

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

Summary of changes:
 selftest/Subunit.pm                                |   33 --------
 selftest/selftest.pl                               |   41 +++-------
 selftest/subunithelper.py                          |    3 +-
 source3/selftest/tests.sh                          |    7 +-
 source4/auth/credentials/pycredentials.c           |   49 ++++++++++--
 source4/auth/gensec/gensec.c                       |    5 +-
 source4/auth/gensec/gensec_gssapi.c                |    2 +-
 source4/auth/gensec/pygensec.c                     |   51 +++++++++++-
 source4/auth/pyauth.c                              |   38 ++++++++-
 source4/dsdb/samdb/ldb_modules/simple_ldap_map.c   |    2 +-
 .../lib/ldb/{autogen.sh => autogen-autotools.sh}   |    0
 source4/lib/ldb/autogen.sh                         |   19 +----
 source4/lib/ldb/wscript                            |    3 +
 source4/lib/registry/pyregistry.c                  |   37 ++++++++-
 source4/librpc/tests/test_ndrdump.sh               |   20 -----
 source4/param/provision.c                          |    9 ++-
 source4/param/pyparam_util.c                       |   24 ++++++-
 source4/scripting/python/pyglue.c                  |    7 +-
 source4/scripting/python/samba/provision.py        |    3 +-
 source4/scripting/python/samba/tests/__init__.py   |   13 +++
 .../python/samba/tests/blackbox}/__init__.py       |    0
 .../python/samba/tests/blackbox/ndrdump.py         |   28 +++++++
 source4/scripting/python/samba/tests/gensec.py     |   16 +++-
 source4/selftest/tests.sh                          |   84 ++++++++++----------
 24 files changed, 311 insertions(+), 183 deletions(-)
 copy source4/lib/ldb/{autogen.sh => autogen-autotools.sh} (100%)
 mode change 100755 => 120000 source4/lib/ldb/autogen.sh
 delete mode 100755 source4/librpc/tests/test_ndrdump.sh
 copy {source3/build => 
source4/scripting/python/samba/tests/blackbox}/__init__.py (100%)
 create mode 100755 source4/scripting/python/samba/tests/blackbox/ndrdump.py


Changeset truncated at 500 lines:

diff --git a/selftest/Subunit.pm b/selftest/Subunit.pm
index a94eecd..1cc0e72 100644
--- a/selftest/Subunit.pm
+++ b/selftest/Subunit.pm
@@ -19,42 +19,9 @@ use POSIX;
 
 require Exporter;
 @ISA = qw(Exporter);
-...@export_ok = qw(filter_add_prefix);
 
 use strict;
 
-sub filter_add_prefix($$)
-{
-       my ($prefix, $fh) = @_;
-
-       while(<$fh>) {
-               if (/^test: (.+)\n/) {
-                       Subunit::start_test($prefix.$1);
-               } elsif 
(/^(success|successful|failure|fail|skip|knownfail|error|xfail): (.*?)( \[)?([ 
\t]*)( multipart)?\n/) {
-                       my $result = $1;
-                       my $testname = $prefix.$2;
-                       my $reason = undef;
-                       if ($3) {
-                               $reason = "";
-                               # reason may be specified in next lines
-                               my $terminated = 0;
-                               while(<$fh>) {
-                                       if ($_ eq "]\n") { $terminated = 1; 
last; } else { $reason .= $_; }
-                               }
-
-                               unless ($terminated) {
-                                       print $reason;
-                                       $reason = "reason ($result) 
interrupted";
-                                       $result = "error";
-                               }
-                       }
-                       Subunit::end_test($testname, $result, $reason);
-               } else {
-                       print $_;
-               }
-       }
-}
-
 sub start_test($)
 {
        my ($testname) = @_;
diff --git a/selftest/selftest.pl b/selftest/selftest.pl
index a21ecba..f973ae5 100755
--- a/selftest/selftest.pl
+++ b/selftest/selftest.pl
@@ -153,7 +153,6 @@ my $opt_verbose = 0;
 my $opt_image = undef;
 my $opt_testenv = 0;
 my $ldap = undef;
-my $opt_analyse_cmd = undef;
 my $opt_resetup_env = undef;
 my $opt_bindir = undef;
 my $opt_load_list = undef;
@@ -238,28 +237,22 @@ sub run_testsuite($$$$$)
        Subunit::start_testsuite($name);
        Subunit::progress_push();
        Subunit::report_time(time());
+       system($cmd);
+       Subunit::report_time(time());
+       Subunit::progress_pop();
 
-       open(RESULTS, "$cmd 2>&1|");
-
-       Subunit::filter_add_prefix("$name\.", *RESULTS);
-
-       my $ret = 0;
-
-       unless (close(RESULTS)) {
-               if ($!) {
-                       Subunit::progress_pop();
-                       Subunit::end_testsuite($name, "error", "Unable to run 
$cmd: $!");
-                       return 0;
-               } else {
-                       $ret = $?;
-               }
-       } 
-
-       if ($ret & 127) {
+       if ($? == -1) {
                Subunit::progress_pop();
-               Subunit::end_testsuite($name, "error", sprintf("Testsuite died 
with signal %d, %s coredump", ($ret & 127), ($ret & 128) ? "with": "without"));
+               Subunit::end_testsuite($name, "error", "Unable to run $cmd: 
$!");
+               return 0;
+       } elsif ($? & 127) {
+               Subunit::end_testsuite($name, "error",
+                       sprintf("%s died with signal %d, %s coredump\n", $cmd, 
($? & 127),  ($? & 128) ? 'with' : 'without'));
                return 0;
        }
+
+       my $exitcode = $? >> 8;
+
        my $envlog = getlog_env($envname);
        if ($envlog ne "") {
                print "envlog: $envlog\n";
@@ -268,10 +261,6 @@ sub run_testsuite($$$$$)
        print "command: $cmd\n";
        printf "expanded command: %s\n", expand_environment_strings($cmd);
 
-       my $exitcode = $ret >> 8;
-
-       Subunit::report_time(time());
-       Subunit::progress_pop();
        if ($exitcode == 0) {
                Subunit::end_testsuite($name, "success");
        } else {
@@ -349,7 +338,6 @@ my $result = GetOptions (
                'verbose' => \$opt_verbose,
                'testenv' => \$opt_testenv,
                'ldap:s' => \$ldap,
-               'analyse-cmd=s' => \$opt_analyse_cmd,
                'resetup-environment' => \$opt_resetup_env,
                'bindir:s' => \$opt_bindir,
                'image=s' => \$opt_image,
@@ -933,7 +921,6 @@ $envvarstr
        foreach (@todo) {
                $i++;
                my $cmd = $$_[2];
-               $cmd =~ s/([\(\)])/\\$1/g;
                my $name = $$_[0];
                my $envname = $$_[1];
 
@@ -962,10 +949,6 @@ $envvarstr
 
                run_testsuite($envname, $name, $cmd, $i, $suitestotal);
 
-               if (defined($opt_analyse_cmd)) {
-                       system("$opt_analyse_cmd \"$name\"");
-               }
-
                teardown_env($envname) if ($opt_resetup_env);
        }
 }
diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py
index 4a649c3..2a5d9ec 100644
--- a/selftest/subunithelper.py
+++ b/selftest/subunithelper.py
@@ -298,7 +298,6 @@ class FilterOps(testtools.testresult.TestResult):
 
     def start_testsuite(self, name):
         self._ops.start_testsuite(name)
-
         self.error_added = 0
         self.fail_added = 0
         self.xfail_added = 0
@@ -335,6 +334,8 @@ class FilterOps(testtools.testresult.TestResult):
         self.expected_failures = expected_failures
         self.strip_ok_output = strip_ok_output
         self.xfail_added = 0
+        self.fail_added = 0
         self.total_xfail = 0
         self.total_error = 0
         self.total_fail = 0
+        self.error_added = 0
diff --git a/source3/selftest/tests.sh b/source3/selftest/tests.sh
index 7a9e68a..39c1a26 100755
--- a/source3/selftest/tests.sh
+++ b/source3/selftest/tests.sh
@@ -30,12 +30,13 @@ plantest() {
        cmdline="$*"
        echo "-- TEST --"
        if [ "$env" = "none" ]; then
-               echo "samba3.$name"
+               fulltest="samba3.$name"
        else
-               echo "samba3.$name ($env)"
+               fulltest="samba3.$name ($env)"
        fi
+       echo $fulltest
        echo $env
-       echo $cmdline
+       echo $cmdline "2>&1" "| ../selftest/filter-subunit --prefix 
\"$fullname.\""
 }
 
 normalize_testname() {
diff --git a/source4/auth/credentials/pycredentials.c 
b/source4/auth/credentials/pycredentials.c
index 7c860b0..879d906 100644
--- a/source4/auth/credentials/pycredentials.c
+++ b/source4/auth/credentials/pycredentials.c
@@ -207,6 +207,7 @@ static PyObject *py_creds_guess(py_talloc_Object *self, 
PyObject *args)
 {
        PyObject *py_lp_ctx = Py_None;
        struct loadparm_context *lp_ctx;
+       TALLOC_CTX *mem_ctx;
        struct cli_credentials *creds;
 
        creds = PyCredentials_AsCliCredentials(self);
@@ -214,12 +215,22 @@ static PyObject *py_creds_guess(py_talloc_Object *self, 
PyObject *args)
        if (!PyArg_ParseTuple(args, "|O", &py_lp_ctx))
                return NULL;
 
-       lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx); /* FIXME: leaky */
-       if (lp_ctx == NULL)
+       mem_ctx = talloc_new(NULL);
+       if (mem_ctx == NULL) {
+               PyErr_NoMemory();
                return NULL;
+       }
+
+       lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
+       if (lp_ctx == NULL) {
+               talloc_free(mem_ctx);
+               return NULL;
+       }
 
        cli_credentials_guess(creds, lp_ctx);
 
+       talloc_free(mem_ctx);
+
        Py_RETURN_NONE;
 }
 
@@ -229,17 +240,28 @@ static PyObject 
*py_creds_set_machine_account(py_talloc_Object *self, PyObject *
        struct loadparm_context *lp_ctx;
        NTSTATUS status;
        struct cli_credentials *creds;
+       TALLOC_CTX *mem_ctx;
 
        creds = PyCredentials_AsCliCredentials(self);
 
        if (!PyArg_ParseTuple(args, "|O", &py_lp_ctx))
                return NULL;
 
-       lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx); /* FIXME: leaky */
-       if (lp_ctx == NULL)
+       mem_ctx = talloc_new(NULL);
+       if (mem_ctx == NULL) {
+               PyErr_NoMemory();
                return NULL;
+       }
+
+       lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
+       if (lp_ctx == NULL) {
+               talloc_free(mem_ctx);
+               return NULL;
+       }
 
        status = cli_credentials_set_machine_account(creds, lp_ctx);
+       talloc_free(mem_ctx);
+
        PyErr_NTSTATUS_IS_ERR_RAISE(status);
 
        Py_RETURN_NONE;
@@ -274,28 +296,39 @@ static PyObject 
*py_creds_get_named_ccache(py_talloc_Object *self, PyObject *arg
        int ret;
        const char *error_string;
        struct cli_credentials *creds;
+       TALLOC_CTX *mem_ctx;
 
        creds = PyCredentials_AsCliCredentials(self);
 
        if (!PyArg_ParseTuple(args, "|Os", &py_lp_ctx, &ccache_name))
                return NULL;
 
-       lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx); /* FIXME: leaky */
-       if (lp_ctx == NULL)
+       mem_ctx = talloc_new(NULL);
+       if (mem_ctx == NULL) {
+               PyErr_NoMemory();
+               return NULL;
+       }
+
+       lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
+       if (lp_ctx == NULL) {
+               talloc_free(mem_ctx);
                return NULL;
+       }
 
-       event_ctx = tevent_context_init(NULL);
+       event_ctx = tevent_context_init(mem_ctx);
 
        ret = cli_credentials_get_named_ccache(creds, event_ctx, lp_ctx,
                                               ccache_name, &ccc, 
&error_string);
+       talloc_free(lp_ctx);
        if (ret == 0) {
                talloc_steal(ccc, event_ctx);
+               talloc_free(mem_ctx);
                return PyCredentialCacheContainer_from_ccache_container(ccc);
        }
 
        PyErr_SetString(PyExc_RuntimeError, error_string?error_string:"NULL");
 
-       talloc_free(event_ctx);
+       talloc_free(mem_ctx);
        return NULL;
 }
 
diff --git a/source4/auth/gensec/gensec.c b/source4/auth/gensec/gensec.c
index 3520585..7220d0e 100644
--- a/source4/auth/gensec/gensec.c
+++ b/source4/auth/gensec/gensec.c
@@ -718,10 +718,9 @@ _PUBLIC_ const char *gensec_get_name_by_oid(struct 
gensec_security *gensec_secur
        }
        return oid_string;
 }
-       
 
-/** 
- * Start a GENSEC sub-mechanism with a specifed mechansim structure, used in 
SPNEGO
+/**
+ * Start a GENSEC sub-mechanism with a specified mechansim structure, used in 
SPNEGO
  *
  */
 
diff --git a/source4/auth/gensec/gensec_gssapi.c 
b/source4/auth/gensec/gensec_gssapi.c
index f28ab95..d2f19e9 100644
--- a/source4/auth/gensec/gensec_gssapi.c
+++ b/source4/auth/gensec/gensec_gssapi.c
@@ -360,7 +360,7 @@ static NTSTATUS gensec_gssapi_client_start(struct 
gensec_security *gensec_securi
                                            hostname, 
lpcfg_realm(gensec_security->settings->lp_ctx));
 
                name_type = GSS_C_NT_USER_NAME;
-       }               
+       }
        name_token.value  = discard_const_p(uint8_t, principal);
        name_token.length = strlen(principal);
 
diff --git a/source4/auth/gensec/pygensec.c b/source4/auth/gensec/pygensec.c
index fc76fad..f8825b8 100644
--- a/source4/auth/gensec/pygensec.c
+++ b/source4/auth/gensec/pygensec.c
@@ -67,7 +67,7 @@ static struct gensec_settings 
*settings_from_object(TALLOC_CTX *mem_ctx, PyObjec
                PyErr_SetString(PyExc_ValueError, "settings.lp_ctx not found");
                return NULL;
        }
-       
+
        s->target_hostname = PyString_AsString(py_hostname);
        s->lp_ctx = lpcfg_from_py_object(s, py_lp_ctx);
        return s;
@@ -81,6 +81,7 @@ static PyObject *py_gensec_start_client(PyTypeObject *type, 
PyObject *args, PyOb
        const char *kwnames[] = { "settings", NULL };
        PyObject *py_settings;
        struct tevent_context *ev;
+       struct gensec_security *gensec;
 
        if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O", 
discard_const_p(char *, kwnames), &py_settings))
                return NULL;
@@ -101,7 +102,7 @@ static PyObject *py_gensec_start_client(PyTypeObject *type, 
PyObject *args, PyOb
                PyObject_DEL(self);
                return NULL;
        }
-       
+
        ev = tevent_context_init(self->talloc_ctx);
        if (ev == NULL) {
                PyErr_NoMemory();
@@ -116,13 +117,15 @@ static PyObject *py_gensec_start_client(PyTypeObject 
*type, PyObject *args, PyOb
                return NULL;
        }
 
-       status = gensec_client_start(self->talloc_ctx, 
-               (struct gensec_security **)&self->ptr, ev, settings);
+       status = gensec_client_start(self->talloc_ctx, &gensec, ev, settings);
        if (!NT_STATUS_IS_OK(status)) {
                PyErr_SetNTSTATUS(status);
                PyObject_DEL(self);
                return NULL;
        }
+
+       self->ptr = gensec;
+
        return (PyObject *)self;
 }
 
@@ -132,7 +135,7 @@ static PyObject *py_gensec_session_info(PyObject *self)
        struct gensec_security *security = (struct gensec_security 
*)py_talloc_get_ptr(self);
        struct auth_session_info *info;
        if (security->ops == NULL) {
-               PyErr_SetString(PyExc_ValueError, "gensec not fully initialised 
- ask Andrew");
+               PyErr_SetString(PyExc_RuntimeError, "no mechanism selected");
                return NULL;
        }
        status = gensec_session_info(security, &info);
@@ -145,6 +148,41 @@ static PyObject *py_gensec_session_info(PyObject *self)
        Py_RETURN_NONE;
 }
 
+static PyObject *py_gensec_start_mech_by_name(PyObject *self, PyObject *args)
+{
+    char *name;
+    struct gensec_security *security = (struct gensec_security 
*)py_talloc_get_ptr(self);
+    NTSTATUS status;
+
+    if (!PyArg_ParseTuple(args, "s", &name))
+        return NULL;
+
+    status = gensec_start_mech_by_name(security, name);
+    if (!NT_STATUS_IS_OK(status)) {
+        PyErr_SetNTSTATUS(status);
+        return NULL;
+    }
+
+    Py_RETURN_NONE;
+}
+
+static PyObject *py_gensec_start_mech_by_authtype(PyObject *self, PyObject 
*args)
+{
+       int authtype, level;
+    struct gensec_security *security = (struct gensec_security 
*)py_talloc_get_ptr(self);
+       NTSTATUS status;
+       if (!PyArg_ParseTuple(args, "ii", &authtype, &level))
+               return NULL;
+
+       status = gensec_start_mech_by_authtype(security, authtype, level);
+       if (!NT_STATUS_IS_OK(status)) {
+               PyErr_SetNTSTATUS(status);
+               return NULL;
+       }
+
+       Py_RETURN_NONE;
+}
+
 static PyMethodDef py_gensec_security_methods[] = {
        { "start_client", (PyCFunction)py_gensec_start_client, 
METH_VARARGS|METH_KEYWORDS|METH_CLASS, 
                "S.start_client(settings) -> gensec" },
@@ -152,6 +190,9 @@ static PyMethodDef py_gensec_security_methods[] = {
                "S.start_server(auth_ctx, settings) -> gensec" },*/
        { "session_info", (PyCFunction)py_gensec_session_info, METH_NOARGS,
                "S.session_info() -> info" },
+    { "start_mech_by_name", (PyCFunction)py_gensec_start_mech_by_name, 
METH_VARARGS, 
+        "S.start_mech_by_name(name)" },
+       { "start_mech_by_authtype", 
(PyCFunction)py_gensec_start_mech_by_authtype, METH_VARARGS, 
"S.start_mech_by_authtype(authtype, level)" },
        { "get_name_by_authtype", (PyCFunction)py_get_name_by_authtype, 
METH_VARARGS,
                "S.get_name_by_authtype(authtype) -> name\nLookup an auth 
type." },
        { NULL }
diff --git a/source4/auth/pyauth.c b/source4/auth/pyauth.c
index dff6963..c2a5e40 100644
--- a/source4/auth/pyauth.c
+++ b/source4/auth/pyauth.c
@@ -43,15 +43,26 @@ static PyObject *py_system_session(PyObject *module, 
PyObject *args)
        PyObject *py_lp_ctx = Py_None;
        struct loadparm_context *lp_ctx = NULL;
        struct auth_session_info *session;
+       TALLOC_CTX *mem_ctx;
        if (!PyArg_ParseTuple(args, "|O", &py_lp_ctx))
                return NULL;
 
-       lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx); /* FIXME: Leaks memory 
*/
-       if (lp_ctx == NULL)
+       mem_ctx = talloc_new(NULL);
+       if (mem_ctx == NULL) {
+               PyErr_NoMemory();
                return NULL;
+       }
+
+       lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
+       if (lp_ctx == NULL) {
+               talloc_free(mem_ctx);
+               return NULL;
+       }
 
        session = system_session(lp_ctx);
 
+       talloc_free(mem_ctx);
+
        return PyAuthSession_FromSession(session);
 }
 
@@ -63,15 +74,32 @@ static PyObject *py_admin_session(PyObject *module, 
PyObject *args)
        struct loadparm_context *lp_ctx = NULL;
        struct auth_session_info *session;
        struct dom_sid *domain_sid = NULL;
+       TALLOC_CTX *mem_ctx;
+
        if (!PyArg_ParseTuple(args, "OO", &py_lp_ctx, &py_sid))
                return NULL;
 
-       lp_ctx = lpcfg_from_py_object(NULL, py_lp_ctx); /* FIXME: leaky */
-       if (lp_ctx == NULL)
+       mem_ctx = talloc_new(NULL);
+       if (mem_ctx == NULL) {
+               PyErr_NoMemory();
                return NULL;
+       }
 
-       domain_sid = dom_sid_parse_talloc(NULL, PyString_AsString(py_sid));
+       lp_ctx = lpcfg_from_py_object(mem_ctx, py_lp_ctx);
+       if (lp_ctx == NULL) {
+               talloc_free(mem_ctx);
+               return NULL;
+       }
+
+       domain_sid = dom_sid_parse_talloc(mem_ctx, PyString_AsString(py_sid));
+       if (domain_sid == NULL) {
+               PyErr_Format(PyExc_RuntimeError, "Unable to parse sid %s", 
+                                        PyString_AsString(py_sid));
+               talloc_free(mem_ctx);
+               return NULL;
+       }
        session = admin_session(NULL, lp_ctx, domain_sid);
+       talloc_free(mem_ctx);
 
        return PyAuthSession_FromSession(session);
 }


-- 
Samba Shared Repository

Reply via email to