s4-net: Use new Net() object in net export keytab.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 8 Apr 2010 20:59:16 +0000 (22:59 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 8 Apr 2010 21:22:55 +0000 (23:22 +0200)
source4/lib/ldb-samba/pyldb.c
source4/libnet/py_net.c
source4/scripting/python/samba/netcmd/export.py

index 084afb7603902c8329fd933849abd1509f6f8049..2b7b23739e48ddb9ffc827787de51f10ec51e164 100644 (file)
@@ -54,14 +54,14 @@ static PyObject *py_ldb_set_loadparm(PyObject *self, PyObject *args)
        if (!PyArg_ParseTuple(args, "O", &py_lp_ctx))
                return NULL;
 
-       lp_ctx = lp_from_py_object(py_lp_ctx);
+       ldb = PyLdb_AsLdbContext(self);
+
+       lp_ctx = lp_from_py_object(ldb, py_lp_ctx);
        if (lp_ctx == NULL) {
                PyErr_SetString(PyExc_TypeError, "Expected loadparm object");
                return NULL;
        }
 
-       ldb = PyLdb_AsLdbContext(self);
-
        ldb_set_opaque(ldb, "loadparm", lp_ctx);
 
        Py_RETURN_NONE;
index 71e7cd87d684b35cea2c0e27999da7b666875f58..569f3955bb68e182c1fbb795614d5443d5edd200 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Unix SMB/CIFS implementation.
    Samba utility functions
-   Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+   Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008-2010
    Copyright (C) Kamen Mazdrashki <kamen.mazdrashki@postpath.com> 2009
 
    This program is free software; you can redistribute it and/or modify
@@ -215,6 +215,10 @@ PyTypeObject py_net_Type = {
 void initnet(void)
 {
        PyObject *m;
+
+       if (PyType_Ready(&py_net_Type) < 0)
+               return;
+
        m = Py_InitModule3("net", NULL, NULL);
        if (m == NULL)
                return;
index 8e5fd2b6e236011be671fd108d0e5ea5b49e6924..90b83689dd25c7b2630932d430adc646772bce9a 100644 (file)
@@ -20,7 +20,7 @@
 
 import samba.getopt as options
 
-from samba import net
+from samba.net import Net
 
 from samba.netcmd import (
     Command,
@@ -45,7 +45,7 @@ class cmd_export_keytab(Command):
     def run(self, keytab, credopts=None, sambaopts=None, versionopts=None):
         lp = sambaopts.get_loadparm()
         creds = credopts.get_credentials(lp)
-        # FIXME: Obtain net context
+        net = Net(creds, lp)
         net.export_keytab(keytab=keytab, creds=creds)