Rev 12012: Fix param module. in
file:///home/jelmer/bzr.samba/python/
Jelmer Vernooij
jelmer at samba.org
Tue May 8 21:58:00 GMT 2007
At file:///home/jelmer/bzr.samba/python/
------------------------------------------------------------
revno: 12012
revision-id: jelmer at samba.org-20070508215744-bw3ibeqsypztyvv3
parent: jelmer at samba.org-20070508202221-cv48zrv775va98jy
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: python
timestamp: Tue 2007-05-08 23:57:44 +0200
message:
Fix param module.
added:
source/scripting/python/talloc.c talloc.c-20070508214200-ruf43htj5k9dlrwj-1
modified:
.bzrignore svn-v2:17811 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-.bzrignore
source/scripting/python/config.mk config.mk-20070425124132-wptmykwi2tvyqm26-1
source/scripting/python/parammodule.c param.c-20070425124147-y6pej29g7xqsb3n6-1
source/selftest/Samba4.pm svn-v2:22575 at 0c0555d6-39d7-0310-84fc-f1cc0bd64818-branches%2fSAMBA_4_0-source%2fselftest%2fSamba4.pm
=== added file 'source/scripting/python/talloc.c'
--- a/source/scripting/python/talloc.c 1970-01-01 00:00:00 +0000
+++ b/source/scripting/python/talloc.c 2007-05-08 21:57:44 +0000
@@ -0,0 +1,30 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Helper functions for using talloc and Python together
+
+ Copyright (C) Jelmer Vernooij 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 2 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, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "includes.h"
+#include "scripting/ejs/smbcalls.h"
+#include "Python.h"
+#include "param/param.h"
+
+TALLOC_CTX *PyMemCtx() {
+ return talloc_autofree_context();
+}
=== modified file '.bzrignore'
--- a/.bzrignore 2007-05-05 00:02:47 +0000
+++ b/.bzrignore 2007-05-08 21:57:44 +0000
@@ -191,3 +191,4 @@
source/lib/ldb/examples/ldifreader
source/lib/tdb/bin/tdbbackup
source/lib/tdb/bin/tdbdump
+source/scripting/python/talloc.h
=== modified file 'source/scripting/python/config.mk'
--- a/source/scripting/python/config.mk 2007-04-27 21:34:20 +0000
+++ b/source/scripting/python/config.mk 2007-05-08 21:57:44 +0000
@@ -1,4 +1,9 @@
+[SUBSYSTEM::talloc_python]
+PRIVATE_DEPENDENCIES = LIBTALLOC LIBPYTHON
+OBJ_FILES = talloc.o
+PUBLIC_PROTO_HEADER = talloc.h
+
[PYTHON::python_param]
-PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG
+PRIVATE_DEPENDENCIES = LIBSAMBA-CONFIG talloc_python
OBJ_FILES = \
parammodule.o
=== modified file 'source/scripting/python/parammodule.c'
--- a/source/scripting/python/parammodule.c 2007-04-27 21:34:20 +0000
+++ b/source/scripting/python/parammodule.c 2007-05-08 21:57:44 +0000
@@ -21,42 +21,55 @@
*/
#include "includes.h"
-#include "scripting/ejs/smbcalls.h"
+#include "scripting/python/talloc.h"
#include "Python.h"
#include "param/param.h"
-PyTypeObject noddy_NoddyType;
+staticforward PyTypeObject param_ParamFileType;
typedef struct {
- PyObject_HEAD
-} noddy_NoddyObject;
-
-static PyObject *loadparm_object(void)
-{
- PyObject *self = PyObject_New();
-
- /* FIXME */
-
- return self;
-}
+ PyObject_HEAD
+} param_ParamFileObject;
static PyObject *param_load(PyObject *self, PyObject *args)
{
+ int ret;
char *filename;
- PyObject *param;
+ param_ParamFileObject *param;
if (!PyArg_ParseTuple(args, "s:new", &filename))
return NULL;
- param = PyObject_New();
+ param = PyObject_New(param_ParamFileObject, ¶m_ParamFileType);
+
+ ret = param_read(PyMemCtx(), filename);
+
+ if (ret == -1) {
+ PyErr_SetString(PyExc_TypeError, "reading file failed");
+ return NULL;
+ }
/* FIXME: Add members:
* globals
* shares
*/
- return param;
-}
+ return (PyObject *)param;
+}
+
+static void
+param_dealloc(PyObject* self)
+{
+ PyObject_Del(self);
+}
+
+static PyTypeObject param_ParamFileType = {
+ PyObject_HEAD_INIT(NULL) 0,
+ .tp_name = "ParamFile",
+ .tp_basicsize = sizeof(param_ParamFileObject),
+ .tp_dealloc = param_dealloc,
+};
+
static PyMethodDef methods[] = {
{ "ParamFile", (PyCFunction)param_load, METH_VARARGS, NULL},
@@ -65,6 +78,12 @@
PyDoc_STRVAR(param_doc, "Simple wrappers around the smb.conf parsers");
+PyObject *loadparm_object(void)
+{
+
+ return NULL; /* FIXME */
+}
+
PyMODINIT_FUNC initparam(void)
{
PyObject *mod = Py_InitModule3("param", methods, param_doc);
@@ -72,5 +91,5 @@
return;
/* FIXME: Check error code */
- PyModule_AddObject(mod, "default_config", loadparm_object());
+ /*PyModule_AddObject(mod, "default_config", loadparm_object());*/
}
=== modified file 'source/selftest/Samba4.pm'
--- a/source/selftest/Samba4.pm 2007-05-01 03:30:04 +0000
+++ b/source/selftest/Samba4.pm 2007-05-08 21:57:44 +0000
@@ -417,7 +417,7 @@
system("$self->{bindir}/ad2oLschema $configuration -H $privatedir/sam.ldb -I $self->{setupdir}/schema-map-openldap-2.3 -O $ldapdir/ad.schema >&2") == 0 or die("schema conversion for OpenLDAP failed");
#Now create an LDAP baseDN
- system("$self->{bindir}/smbscript $self->{setupdir}/provision $provision_options --ldap-base >&2") == 0 or die("creating an OpenLDAP basedn failed");
+ system("$ENV{PYTHON} $self->{setupdir}/provision $provision_options --ldap-base >&2") == 0 or die("creating an OpenLDAP basedn failed");
my $oldpath = $ENV{PATH};
$ENV{PATH} = "/usr/local/sbin:/usr/sbin:/sbin:$ENV{PATH}";
@@ -615,7 +615,7 @@
push (@provision_options, "--password=$password");
push (@provision_options, "--root=$root");
- (system("$self->{bindir}/smbscript $self->{setupdir}/provision " . join(' ', @provision_options) . ">&2") == 0) or die("Unable to provision");
+ (system("$ENV{PYTHON} $self->{setupdir}/provision " . join(' ', @provision_options) . ">&2") == 0) or die("Unable to provision");
my $ldap_uri= "$ldapdir/ldapi";
$ldap_uri =~ s|/|%2F|g;
@@ -733,8 +733,8 @@
$provision_aci = "--aci=aci:: KHRhcmdldGF0dHIgPSAiKiIpICh2ZXJzaW9uIDMuMDthY2wgImZ1bGwgYWNjZXNzIHRvIGFsbCBieSBhbGwiO2FsbG93IChhbGwpKHVzZXJkbiA9ICJsZGFwOi8vL2FueW9uZSIpOykK";
}
- system("$self->{bindir}/smbscript $self->{setupdir}/provision $envvars->{PROVISION_OPTIONS} \"$provision_aci\" --ldap-backend=$envvars->{LDAP_URI}") and
- die("LDAP PROVISIONING failed: $self->{bindir}/smbscript $self->{setupdir}/provision $envvars->{PROVISION_OPTIONS} \"$provision_aci\" --ldap-backend=$envvars->{LDAP_URI}");
+ system("$ENV{PYTHON} $self->{setupdir}/provision $envvars->{PROVISION_OPTIONS} \"$provision_aci\" --ldap-backend=$envvars->{LDAP_URI}") and
+ die("LDAP PROVISIONING failed: $ENV{PYTHON} $self->{setupdir}/provision $envvars->{PROVISION_OPTIONS} \"$provision_aci\" --ldap-backend=$envvars->{LDAP_URI}");
}
sub teardown_env($$)
More information about the samba-cvs
mailing list