gpo: Add python libgpo bindings
authorLuke Morrison <luc785@hotmail.com>
Fri, 31 Jan 2014 00:27:05 +0000 (13:27 +1300)
committerGarming Sam <garming@samba.org>
Mon, 20 Nov 2017 20:41:14 +0000 (21:41 +0100)
Split from "Initial commit for GPO work done by Luke Morrison" by David Mulder

Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Signed-off-by: Luke Morrison <luke@hubtrek.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libgpo/gpo_filesync.c [moved from source3/libgpo/gpo_filesync.c with 100% similarity]
libgpo/gpo_proto.h [moved from source3/libgpo/gpo_proto.h with 100% similarity]
libgpo/gpo_reg.c [moved from source3/libgpo/gpo_reg.c with 99% similarity]
libgpo/pygpo.c [new file with mode: 0644]
libgpo/wscript_build
source3/wscript_build

similarity index 99%
rename from source3/libgpo/gpo_reg.c
rename to libgpo/gpo_reg.c
index 7f5fbc4fff113d89a7dfe9f5e9b72236ac0f38d3..18d0498c7e9b66988d31a9136c43a3cf8b37fc99 100644 (file)
@@ -1037,4 +1037,3 @@ WERROR reg_apply_registry_entry(TALLOC_CTX *mem_ctx,
 
        return werr;
 }
 
        return werr;
 }
-
diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c
new file mode 100644 (file)
index 0000000..c42811f
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+   Unix SMB/CIFS implementation.
+   Copyright (C) Luke Morrison <luc785@hotmail.com> 2013
+
+   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/>.
+*/
+
+#include <Python.h>
+#include "includes.h"
+#include "version.h"
+#include "param/pyparam.h"
+#include "gpo.h"
+#include "ads.h"
+
+/* A Python C API module to use LIBGPO */
+
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
+#endif
+
+/* Parameter mapping and functions for the GP_EXT struct */
+void initgpo(void);
+
+/* Global methods aka do not need a special pyobject type */
+static PyObject *py_gpo_get_sysvol_gpt_version(PyObject * self, PyObject * args)
+{
+       TALLOC_CTX *tmp_ctx = NULL;
+       char *unix_path;
+       char *display_name = NULL;
+       uint32_t sysvol_version = 0;
+       PyObject *result;
+
+       tmp_ctx = talloc_new(NULL);
+
+       if (!PyArg_ParseTuple(args, "s", &unix_path)) {
+               return NULL;
+       }
+       gpo_get_sysvol_gpt_version(tmp_ctx, unix_path, &sysvol_version, &display_name);
+       talloc_free(tmp_ctx);
+       result = Py_BuildValue("[s,i]", display_name, sysvol_version);
+       return result;
+}
+
+static PyMethodDef py_gpo_methods[] = {
+       {"gpo_get_sysvol_gpt_version", (PyCFunction) py_gpo_get_sysvol_gpt_version, METH_VARARGS, NULL},
+       {NULL}
+};
+
+/* Will be called by python when loading this module */
+void initgpo(void)
+{
+       PyObject *m;
+
+       debug_setup_talloc_log();
+       /* Instantiate the types */
+       m = Py_InitModule3("gpo", py_gpo_methods, "libgpo python bindings");
+       if (m == NULL)
+               return;
+       PyModule_AddObject(m, "version", PyString_FromString(SAMBA_VERSION_STRING));
+}
index 034af0a163f5c80057204b3eeb39ed100e9dd6dc..598cfcb327c3f99512547753084524d7670eda98 100644 (file)
@@ -1,7 +1,13 @@
 #!/usr/bin/env python
 
 #!/usr/bin/env python
 
-bld.SAMBA_SUBSYSTEM('LIBGPO',
-       source='gpo_util.c gpo_sec.c ../libgpo/gpext/gpext.c gpo_fetch.c gpo_ini.c ../source4/libgpo/ads_convenience.c ../source3/libgpo/gpo_filesync.c ../source4/libgpo/gpo_filesync.c',
-       deps='ldb samba-net samba-util',
-       enabled=False
-       )
+LIBGPO_SRC = '''gpo_ldap.c gpo_ini.c gpo_util.c gpo_fetch.c gpo_filesync.c
+                gpo_sec.c gpo_reg.c gpext/gpext.c'''
+
+bld.SAMBA3_LIBRARY('gpo',
+                   source='${LIBGPO_SRC}',
+                   deps='talloc ads TOKEN_UTIL auth',
+                   vars=locals(),
+                   private_library=True)
+bld.SAMBA3_PYTHON('python_samba_libgpo', 'pygpo.c',
+                 deps='pyparam_util gpo talloc ads TOKEN_UTIL auth',
+                 realname='samba/gpo.so')
index f4c3eb58b022833738b9c6de13230f08065ce34e..8718e9b95587bcd37985d718ac217067ac6763aa 100644 (file)
@@ -82,9 +82,9 @@ bld.SAMBA3_LIBRARY('gpo',
                           ../libgpo/gpo_ini.c
                           ../libgpo/gpo_util.c
                           ../libgpo/gpo_fetch.c
                           ../libgpo/gpo_ini.c
                           ../libgpo/gpo_util.c
                           ../libgpo/gpo_fetch.c
-                          libgpo/gpo_filesync.c
+                          ../libgpo/gpo_filesync.c
                           ../libgpo/gpo_sec.c
                           ../libgpo/gpo_sec.c
-                          libgpo/gpo_reg.c
+                          ../libgpo/gpo_reg.c
                           ''',
                    deps='''
                         talloc
                           ''',
                    deps='''
                         talloc