[PATCH 09/26] gpo: run C code through format_indent.sh to fix some of the formatting
abartlet at samba.org
abartlet at samba.org
Thu Jun 5 04:07:14 MDT 2014
From: Garming Sam <garming at catalyst.net.nz>
Signed-off-by: Garming Sam <garming at catalyst.net.nz>
---
libgpo/pygpo.c | 342 +++++++++++++++++++++---------------------
libgpo/pygpo.h | 25 ++-
pygpo.h | 3 +-
source4/dsdb/gpo/gpo_update.c | 84 ++++++-----
4 files changed, 230 insertions(+), 224 deletions(-)
diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c
index 645c933..ed7ddc4 100644
--- a/libgpo/pygpo.c
+++ b/libgpo/pygpo.c
@@ -2,7 +2,6 @@
Unix SMB/CIFS implementation.
Copyright (C) Luke Morrison <luc785 at 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
@@ -24,7 +23,6 @@
#include "pygpo.h"
#include "ads.h"
-
/*A Python C API module to use LIBGPO*/
#ifndef Py_RETURN_NONE
@@ -43,9 +41,9 @@ staticforward PyTypeObject PyGpLink;
void initgpo(void);
//Parse raw extension string to GP_EXT structure
-static PyObject *py_ads_parse_gp_ext(PyGpExtObject *self, PyObject *args)
+static PyObject *py_ads_parse_gp_ext(PyGpExtObject * self, PyObject * args)
{
- struct GP_EXT *gp_ext = pygp_ext_AsgpextContext((PyObject *)self);
+ struct GP_EXT *gp_ext = pygp_ext_AsgpextContext((PyObject *) self);
bool verify;
const char *extension_raw;
TALLOC_CTX *tmp_ctx;
@@ -53,86 +51,89 @@ static PyObject *py_ads_parse_gp_ext(PyGpExtObject *self, PyObject *args)
tmp_ctx = talloc_new(NULL);
if (!PyArg_ParseTuple(args, "s", &extension_raw)) {
return NULL;
- }
+ }
verify = ads_parse_gp_ext(tmp_ctx, extension_raw, &gp_ext);
- if (!verify){
+ if (!verify) {
talloc_free(tmp_ctx);
Py_RETURN_NONE;
- }
- return (PyObject*)gp_ext;
+ }
+ return (PyObject *) gp_ext;
}
//Functions here
-static PyMethodDef py_gp_ext_methods[] =
-{
-{"ads_parse_gp_ext", (PyCFunction)py_ads_parse_gp_ext, METH_VARARGS, NULL},
- { NULL}
+static PyMethodDef py_gp_ext_methods[] = {
+ {"ads_parse_gp_ext", (PyCFunction) py_ads_parse_gp_ext, METH_VARARGS,
+ NULL},
+ {NULL}
};
//Mapping here
-static PyObject *py_gp_ext_get_extensions(PyGpExtObject *self)
+static PyObject *py_gp_ext_get_extensions(PyGpExtObject * self)
{
return PyString_FromString((*self->gp_ext->extensions));
}
-static PyObject *py_gp_ext_get_extensions_guid(PyGpExtObject *self)
+static PyObject *py_gp_ext_get_extensions_guid(PyGpExtObject * self)
{
return PyString_FromString((*self->gp_ext->extensions_guid));
}
-static PyObject *py_gp_ext_get_snapins(PyGpExtObject *self)
+static PyObject *py_gp_ext_get_snapins(PyGpExtObject * self)
{
return PyString_FromString((*self->gp_ext->snapins));
}
-static PyObject *py_gp_ext_get_snapins_guid(PyGpExtObject *self)
+static PyObject *py_gp_ext_get_snapins_guid(PyGpExtObject * self)
{
return PyString_FromString((*self->gp_ext->snapins_guid));
}
-static PyGetSetDef py_gp_ext_getset[] =
-{
- { discard_const_p(char, "keyval_count"), (getter)py_gp_ext_get_extensions,NULL, NULL},
- { discard_const_p(char, "current_section"), (getter)py_gp_ext_get_extensions_guid,NULL, NULL},
- { discard_const_p(char, "generated_filename"), (getter)py_gp_ext_get_snapins, NULL, NULL},
- { discard_const_p(char, "snapins_guid"), (getter)py_gp_ext_get_snapins_guid,NULL, NULL},
+
+static PyGetSetDef py_gp_ext_getset[] = {
+ {discard_const_p(char, "keyval_count"),
+ (getter) py_gp_ext_get_extensions, NULL, NULL},
+ {discard_const_p(char, "current_section"),
+ (getter) py_gp_ext_get_extensions_guid, NULL, NULL},
+ {discard_const_p(char, "generated_filename"),
+ (getter) py_gp_ext_get_snapins, NULL, NULL},
+ {discard_const_p(char, "snapins_guid"),
+ (getter) py_gp_ext_get_snapins_guid, NULL, NULL},
{NULL}
};
-static PyObject *py_gp_ext_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+
+static PyObject *py_gp_ext_new(PyTypeObject * type, PyObject * args,
+ PyObject * kwargs)
{
struct GP_EXT *gp;
TALLOC_CTX *mem_ctx;
PyGpExtObject *py_ret;
mem_ctx = talloc_new(NULL);
- if (mem_ctx == NULL)
- {
+ if (mem_ctx == NULL) {
PyErr_NoMemory();
return NULL;
}
gp = talloc(mem_ctx, struct GP_EXT);
- if (!gp)
- {
+ if (!gp) {
talloc_free(mem_ctx);
PyErr_SetString(PyExc_ValueError, "unable to allocate gp");
return NULL;
}
- py_ret = (PyGpExtObject *)type->tp_alloc(type, 0);
- if (py_ret == NULL)
- {
+ py_ret = (PyGpExtObject *) type->tp_alloc(type, 0);
+ if (py_ret == NULL) {
talloc_free(mem_ctx);
PyErr_NoMemory();
return NULL;
}
py_ret->mem_ctx = mem_ctx;
- py_ret-> gp_ext = gp;
- return (PyObject *)py_ret;
+ py_ret->gp_ext = gp;
+ return (PyObject *) py_ret;
}
-static void py_gp_ext_dealloc(PyGpExtObject *self)
+
+static void py_gp_ext_dealloc(PyGpExtObject * self)
{
- if (self->mem_ctx != NULL)
- {
+ if (self->mem_ctx != NULL) {
talloc_free(self->mem_ctx);
}
self->ob_type->tp_free(self);
@@ -140,7 +141,7 @@ static void py_gp_ext_dealloc(PyGpExtObject *self)
static PyTypeObject PyGpExt = {
.tp_name = "gpo.ext",
- .tp_dealloc = (destructor)py_gp_ext_dealloc,
+ .tp_dealloc = (destructor) py_gp_ext_dealloc,
.tp_new = py_gp_ext_new,
.tp_basicsize = sizeof(PyGpExtObject),
.tp_getset = py_gp_ext_getset,
@@ -156,8 +157,7 @@ static PyTypeObject PyGpExt = {
//static PyObject *py_gp_inifile_get_string(PyGpIniObject* self)
-
-static PyObject *py_parse_gpt_ini(PyObject *self, PyObject *args)
+static PyObject *py_parse_gpt_ini(PyObject * self, PyObject * args)
{
TALLOC_CTX *tmp_ctx = talloc_new(NULL);
char *filename;
@@ -168,11 +168,11 @@ static PyObject *py_parse_gpt_ini(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s", &filename)) {
return NULL;
- }
+ }
status = parse_gpt_ini(tmp_ctx, filename, version, display_name);
- if (!NT_STATUS_IS_OK(status)){
+ if (!NT_STATUS_IS_OK(status)) {
return NULL;
- }
+ }
//Do not need to check for display name because it might not have one
//Zero cases will be handled in python
result = Py_BuildValue("[s,i]", display_name, version);
@@ -181,218 +181,220 @@ static PyObject *py_parse_gpt_ini(PyObject *self, PyObject *args)
}
static PyMethodDef py_gp_inifile_methods[] = {
-{"parse_gpt_ini", (PyCFunction)py_parse_gpt_ini, METH_VARARGS, "Pase the local gp.ini file"},
- { NULL}
+ {"parse_gpt_ini", (PyCFunction) py_parse_gpt_ini, METH_VARARGS,
+ "Pase the local gp.ini file"},
+ {NULL}
};
//Mapping Here
-static PyObject *py_gp_inifile_keyval_count(PyGpIniObject *self)
+static PyObject *py_gp_inifile_keyval_count(PyGpIniObject * self)
{
return PyInt_FromLong(self->gp_ini->keyval_count);
}
-static PyObject *py_gp_inifile_get_current_section(PyGpIniObject *self)
+static PyObject *py_gp_inifile_get_current_section(PyGpIniObject * self)
{
return PyString_FromString(self->gp_ini->current_section);
}
-static PyObject *py_gp_inifile_generated_filename(PyGpIniObject *self)
+
+static PyObject *py_gp_inifile_generated_filename(PyGpIniObject * self)
{
return PyString_FromString(self->gp_ini->generated_filename);
}
-
-static PyGetSetDef py_gp_inifile_getset[] =
-{
- {discard_const_p(char,"keyval_count"), (getter)py_gp_inifile_keyval_count,NULL, NULL},
- {discard_const_p(char,"current_section"), (getter)py_gp_inifile_get_current_section, NULL, NULL},
- {discard_const_p(char,"generated_filename"), (getter)py_gp_inifile_generated_filename, NULL, NULL},
+static PyGetSetDef py_gp_inifile_getset[] = {
+ {discard_const_p(char, "keyval_count"),
+ (getter) py_gp_inifile_keyval_count, NULL, NULL},
+ {discard_const_p(char, "current_section"),
+ (getter) py_gp_inifile_get_current_section, NULL, NULL},
+ {discard_const_p(char, "generated_filename"),
+ (getter) py_gp_inifile_generated_filename, NULL, NULL},
{NULL}
};
-static PyObject *py_gp_inifile_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+static PyObject *py_gp_inifile_new(PyTypeObject * type, PyObject * args,
+ PyObject * kwargs)
{
struct gp_inifile_context *gp;
TALLOC_CTX *mem_ctx;
PyGpIniObject *py_ret;
mem_ctx = talloc_new(NULL);
- if (mem_ctx == NULL)
- {
+ if (mem_ctx == NULL) {
PyErr_NoMemory();
return NULL;
}
gp = talloc(mem_ctx, struct gp_inifile_context);
- if (!gp)
- {
+ if (!gp) {
talloc_free(mem_ctx);
PyErr_SetString(PyExc_ValueError, "unable to allocate gp");
return NULL;
}
- py_ret = (PyGpIniObject *)type->tp_alloc(type, 0);
- if (py_ret == NULL)
- {
+ py_ret = (PyGpIniObject *) type->tp_alloc(type, 0);
+ if (py_ret == NULL) {
talloc_free(mem_ctx);
PyErr_NoMemory();
return NULL;
}
py_ret->mem_ctx = mem_ctx;
- py_ret-> gp_ini = gp;
- return (PyObject *)py_ret;
+ py_ret->gp_ini = gp;
+ return (PyObject *) py_ret;
}
-static void py_gp_inifile_dealloc(PyGpIniObject *self)
+
+static void py_gp_inifile_dealloc(PyGpIniObject * self)
{
- if (self->mem_ctx != NULL)
- {
+ if (self->mem_ctx != NULL) {
talloc_free(self->mem_ctx);
}
self->ob_type->tp_free(self);
}
-
-static PyTypeObject PyGpIni= {
+static PyTypeObject PyGpIni = {
.tp_name = "pygpo",
.tp_methods = py_gp_inifile_methods,
.tp_getset = py_gp_inifile_getset,
.tp_doc = "GPO for gp_inifile_context.",
.tp_new = py_gp_inifile_new,
- .tp_dealloc = (destructor)py_gp_inifile_dealloc,
+ .tp_dealloc = (destructor) py_gp_inifile_dealloc,
.tp_basicsize = sizeof(PyGpIniObject),
};
+
/****************************************************************************************/
/*Parameter mapping and methods for the GROUP POLICY OBJECT Struct.*/
/*Functions here*/
-static PyObject *py_gpo_get_unix_path(PyGpObject *self, PyObject *args)
+static PyObject *py_gpo_get_unix_path(PyGpObject * self, PyObject * args)
{
TALLOC_CTX *mem_ctx;
- struct GROUP_POLICY_OBJECT *gpo = pygpo_AsgpoContext((PyObject*)self);
+ struct GROUP_POLICY_OBJECT *gpo = pygpo_AsgpoContext((PyObject *) self);
const char *cache_dir = NULL;
char **unix_path = NULL;
NTSTATUS status;
- if (!PyArg_ParseTuple(args, "s", &cache_dir)){
+ if (!PyArg_ParseTuple(args, "s", &cache_dir)) {
return NULL;
- }
+ }
mem_ctx = talloc_new(NULL);
status = gpo_get_unix_path(mem_ctx, cache_dir, gpo, unix_path);
- if (!NT_STATUS_IS_OK(status)){
+ if (!NT_STATUS_IS_OK(status)) {
return NULL;
- }
- if (!unix_path){
+ }
+ if (!unix_path) {
return NULL;
- }
+ }
return PyString_FromString(*unix_path);
}
static PyMethodDef py_gpo_local_methods[] = {
-{"gpo_get_unix_path", (PyCFunction) py_gpo_get_unix_path, METH_VARARGS, NULL},
- { NULL}
+ {"gpo_get_unix_path", (PyCFunction) py_gpo_get_unix_path, METH_VARARGS,
+ NULL},
+ {NULL}
};
/*Mapping here*/
-static PyObject *py_options(PyGpObject *self)
+static PyObject *py_options(PyGpObject * self)
{
return PyInt_FromLong(self->gpo->options);
}
-static PyObject *py_version(PyGpObject *self)
+static PyObject *py_version(PyGpObject * self)
{
return PyInt_FromLong(self->gpo->version);
}
-static PyObject *py_ds_path(PyGpObject *self)
+static PyObject *py_ds_path(PyGpObject * self)
{
return PyString_FromString(self->gpo->ds_path);
}
-static PyObject *py_file_sys_path(PyGpObject *self)
+static PyObject *py_file_sys_path(PyGpObject * self)
{
return PyString_FromString(self->gpo->file_sys_path);
}
-static PyObject *py_name(PyGpObject *self)
+static PyObject *py_name(PyGpObject * self)
{
return PyString_FromString(self->gpo->name);
}
-static PyObject *py_link(PyGpObject *self)
+static PyObject *py_link(PyGpObject * self)
{
return PyString_FromString(self->gpo->link);
}
-static PyObject *py_user_extensions(PyGpObject *self)
+static PyObject *py_user_extensions(PyGpObject * self)
{
return PyString_FromString(self->gpo->user_extensions);
}
-static PyObject *py_machine_extensions(PyGpObject *self)
+static PyObject *py_machine_extensions(PyGpObject * self)
{
return PyString_FromString(self->gpo->machine_extensions);
}
-static PyGetSetDef py_gpo_getset[] =
-{
- {discard_const_p(char,"options"), (getter)py_options, NULL , NULL},
- {discard_const_p(char,"version"), (getter)py_version, NULL, NULL},
- {discard_const_p(char,"ds_path"), (getter)py_ds_path, NULL, NULL},
- {discard_const_p(char,"file_sys_path"), (getter)py_file_sys_path, NULL, NULL},
- {discard_const_p(char,"name"), (getter)py_name, NULL, NULL},
- {discard_const_p(char,"link"), (getter)py_link, NULL, NULL},
- {discard_const_p(char,"user_extensions"), (getter)py_user_extensions, NULL, NULL},
- {discard_const_p(char,"machine_extensions"), (getter)py_machine_extensions, NULL, NULL},
+static PyGetSetDef py_gpo_getset[] = {
+ {discard_const_p(char, "options"), (getter) py_options, NULL, NULL},
+ {discard_const_p(char, "version"), (getter) py_version, NULL, NULL},
+ {discard_const_p(char, "ds_path"), (getter) py_ds_path, NULL, NULL},
+ {discard_const_p(char, "file_sys_path"), (getter) py_file_sys_path,
+ NULL, NULL},
+ {discard_const_p(char, "name"), (getter) py_name, NULL, NULL},
+ {discard_const_p(char, "link"), (getter) py_link, NULL, NULL},
+ {discard_const_p(char, "user_extensions"), (getter) py_user_extensions,
+ NULL, NULL},
+ {discard_const_p(char, "machine_extensions"),
+ (getter) py_machine_extensions, NULL, NULL},
{NULL}
};
-
-static PyObject *py_gpo_local_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+static PyObject *py_gpo_local_new(PyTypeObject * type, PyObject * args,
+ PyObject * kwargs)
{
- struct GROUP_POLICY_OBJECT* gpo;
+ struct GROUP_POLICY_OBJECT *gpo;
TALLOC_CTX *mem_ctx;
PyGpObject *py_ret;
mem_ctx = talloc_new(NULL);
- if (mem_ctx == NULL)
- {
+ if (mem_ctx == NULL) {
PyErr_NoMemory();
return NULL;
}
gpo = talloc(mem_ctx, struct GROUP_POLICY_OBJECT);
- if (!gpo)
- {
+ if (!gpo) {
talloc_free(mem_ctx);
PyErr_SetString(PyExc_ValueError, "unable to allocate gp");
return NULL;
}
- py_ret = (PyGpObject *)type->tp_alloc(type, 0);
- if (py_ret == NULL)
- {
+ py_ret = (PyGpObject *) type->tp_alloc(type, 0);
+ if (py_ret == NULL) {
talloc_free(mem_ctx);
PyErr_NoMemory();
return NULL;
}
py_ret->mem_ctx = mem_ctx;
- return (PyObject *)py_ret;
+ return (PyObject *) py_ret;
}
-static void py_gpo_local_dealloc(PyGpObject *self)
+
+static void py_gpo_local_dealloc(PyGpObject * self)
{
- if (self->mem_ctx != NULL)
- {
+ if (self->mem_ctx != NULL) {
talloc_free(self->mem_ctx);
}
self->ob_type->tp_free(self);
}
-static PyTypeObject PyGpO =
-{
+
+static PyTypeObject PyGpO = {
.tp_name = "pygpo",
.tp_methods = py_gpo_local_methods,
.tp_getset = py_gpo_getset,
.tp_doc = "GPO mapping",
.tp_new = py_gpo_local_new,
- .tp_dealloc = (destructor)py_gpo_local_dealloc,
+ .tp_dealloc = (destructor) py_gpo_local_dealloc,
.tp_basicsize = sizeof(PyGpObject),
};
+
/******************************************************************************************************************************
******************************************************************************************************************************/
//Parameter mapping and methods for the GP_LINK Struct.
@@ -448,142 +450,138 @@ static PyObject py_ads_add_gpo_link(PyGpLinkObject *self, PyObject *args)
ADS_STATUS status;
(!ADS_ERR_OK(status))
-
*/
-
-
static PyMethodDef py_gp_link_methods[] = {
//{"ads_get_gpo_link", (PyCFunction)py_ads_get_gpo_link, METH_VARARGS, NULL},
- { NULL}
+ {NULL}
};
-static PyObject *py_gp_link(PyGpLinkObject *self)
+static PyObject *py_gp_link(PyGpLinkObject * self)
{
return PyString_FromString(self->gp_link->gp_link);
}
-static PyObject *py_gp_opts(PyGpLinkObject *self)
+static PyObject *py_gp_opts(PyGpLinkObject * self)
{
return PyInt_FromLong(self->gp_link->gp_opts);
}
-static PyObject *py_num_links(PyGpLinkObject *self)
+static PyObject *py_num_links(PyGpLinkObject * self)
{
return PyInt_FromLong(self->gp_link->num_links);
}
-static PyObject *py_link_names(PyGpLinkObject *self)
+static PyObject *py_link_names(PyGpLinkObject * self)
{
return PyString_FromString((*self->gp_link->link_names));
}
-static PyObject *py_link_opts(PyGpLinkObject *self)
+static PyObject *py_link_opts(PyGpLinkObject * self)
{
return PyInt_FromLong((*self->gp_link->link_opts));
}
+static PyGetSetDef py_gp_link_getset[] = {
-
-static PyGetSetDef py_gp_link_getset[] =
-{
-
- {discard_const_p(char,"gp_link"), (getter)py_gp_link, NULL, NULL},
- {discard_const_p(char,"gp_opts"), (getter)py_gp_opts, NULL, NULL},
- {discard_const_p(char,"num_links"), (getter)py_num_links, NULL, NULL},
- {discard_const_p(char,"link_names"), (getter)py_link_names, NULL, NULL},
- {discard_const_p(char,"link_opts"), (getter)py_link_opts, NULL, NULL},
+ {discard_const_p(char, "gp_link"), (getter) py_gp_link, NULL, NULL},
+ {discard_const_p(char, "gp_opts"), (getter) py_gp_opts, NULL, NULL},
+ {discard_const_p(char, "num_links"), (getter) py_num_links, NULL, NULL},
+ {discard_const_p(char, "link_names"), (getter) py_link_names, NULL,
+ NULL},
+ {discard_const_p(char, "link_opts"), (getter) py_link_opts, NULL, NULL},
{NULL}
};
-
-static PyObject *py_gp_link_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
+static PyObject *py_gp_link_new(PyTypeObject * type, PyObject * args,
+ PyObject * kwargs)
{
struct GP_LINK *gplink;
TALLOC_CTX *mem_ctx;
PyGpLinkObject *py_ret;
mem_ctx = talloc_new(NULL);
- if (mem_ctx == NULL)
- {
+ if (mem_ctx == NULL) {
PyErr_NoMemory();
return NULL;
}
gplink = talloc(mem_ctx, struct GP_LINK);
- if (!gplink)
- {
+ if (!gplink) {
talloc_free(mem_ctx);
PyErr_SetString(PyExc_ValueError, "unable to allocate gp");
return NULL;
}
- py_ret = (PyGpLinkObject *)type->tp_alloc(type, 0);
- if (py_ret == NULL)
- {
+ py_ret = (PyGpLinkObject *) type->tp_alloc(type, 0);
+ if (py_ret == NULL) {
talloc_free(mem_ctx);
PyErr_NoMemory();
return NULL;
}
py_ret->mem_ctx = mem_ctx;
- return (PyObject *)py_ret;
+ return (PyObject *) py_ret;
}
-static void py_gpo_link_dealloc(PyGpLinkObject *self)
+
+static void py_gpo_link_dealloc(PyGpLinkObject * self)
{
- if (self->mem_ctx != NULL)
- {
+ if (self->mem_ctx != NULL) {
talloc_free(self->mem_ctx);
}
self->ob_type->tp_free(self);
}
-static PyTypeObject PyGpLink =
-{
+
+static PyTypeObject PyGpLink = {
.tp_name = "pygpo",
.tp_methods = py_gp_link_methods,
.tp_getset = py_gp_link_getset,
.tp_doc = "GPO mapping",
.tp_new = py_gp_link_new,
- .tp_dealloc = (destructor)py_gpo_link_dealloc,
+ .tp_dealloc = (destructor) py_gpo_link_dealloc,
.tp_basicsize = sizeof(PyGpLinkObject),
};
+
/*****************************************************************************************************************************/
/*Global methods aka do not need a special pyobject type*/
-static PyObject *py_gpo_get_sysvol_gpt_version(PyObject*self, PyObject *args)
+static PyObject *py_gpo_get_sysvol_gpt_version(PyObject * self, PyObject * args)
{
TALLOC_CTX *tmp_ctx = NULL;
NTSTATUS status;
char *unix_path;
char *display_name = NULL;
- uint32_t sysvol_version=0;
+ uint32_t sysvol_version = 0;
PyObject *result;
tmp_ctx = talloc_new(NULL);
- if (!PyArg_ParseTuple(args, "s" , &unix_path)) {
+ if (!PyArg_ParseTuple(args, "s", &unix_path)) {
return NULL;
- }
- status = gpo_get_sysvol_gpt_version(tmp_ctx, unix_path, &sysvol_version, &display_name);
+ }
+ status =
+ 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;
}
/*Verify that the GUID is not a client side extension*/
-static PyObject *py_cse_gpo_name_to_guid_string(PyObject *self, PyObject *args)
+static PyObject *py_cse_gpo_name_to_guid_string(PyObject * self,
+ PyObject * args)
{
char *name = NULL;
char *ret = NULL;
- if (!PyArg_ParseTuple(args, "s" , &name)) {
- return NULL;
- }
+ if (!PyArg_ParseTuple(args, "s", &name)) {
+ return NULL;
+ }
ret = cse_gpo_name_to_guid_string(name);
return PyString_FromString(ret);
}
-static PyObject *py_ads_init(PyGpObject *self, PyObject *args)
+static PyObject *py_ads_init(PyGpObject * self, PyObject * args)
{
const char *realm = NULL;
const char *workgroup = NULL;
@@ -593,26 +591,29 @@ static PyObject *py_ads_init(PyGpObject *self, PyObject *args)
printf("Before the as content statement\n");
ads = pygpoads_AsgpoadsContext(self->ads);
- if (!PyArg_ParseTuple(args, "ss" , &realm, &workgroup)) {
- return NULL;
- }
+ if (!PyArg_ParseTuple(args, "ss", &realm, &workgroup)) {
+ return NULL;
+ }
printf("After the content statement before function \n");
ads = ads_init(realm, workgroup, ldap_server);
printf("After function before returning");
- if (!ads){
+ if (!ads) {
printf("did this work");
- }
+ }
- return (PyObject *)ads;
+ return (PyObject *) ads;
}
-static PyMethodDef py_gpo_methods[] =
-{
-{"cse_gpo_name_to_guid_string", (PyCFunction)py_cse_gpo_name_to_guid_string, METH_VARARGS, NULL},
-{"gpo_get_sysvol_gpt_version", (PyCFunction)py_gpo_get_sysvol_gpt_version, METH_VARARGS, NULL},
-{"ads_init", (PyCFunction)py_ads_init, METH_VARARGS, "initializing the ads structure"},
-{NULL}
+static PyMethodDef py_gpo_methods[] = {
+ {"cse_gpo_name_to_guid_string",
+ (PyCFunction) py_cse_gpo_name_to_guid_string, METH_VARARGS, NULL},
+ {"gpo_get_sysvol_gpt_version",
+ (PyCFunction) py_gpo_get_sysvol_gpt_version, METH_VARARGS, NULL},
+ {"ads_init", (PyCFunction) py_ads_init, METH_VARARGS,
+ "initializing the ads structure"},
+ {NULL}
};
+
/* will be called by python when loading this module*/
void initgpo(void)
{
@@ -624,7 +625,7 @@ void initgpo(void)
if (m == NULL)
return;
PyModule_AddObject(m, "version",
- PyString_FromString(SAMBA_VERSION_STRING));
+ PyString_FromString(SAMBA_VERSION_STRING));
if (PyType_Ready(&PyGpO) < 0)
return;
if (PyType_Ready(&PyGpIni) < 0)
@@ -634,7 +635,6 @@ void initgpo(void)
if (PyType_Ready(&PyGpLink) < 0)
return;
-
Py_INCREF(&PyGpO);
Py_INCREF(&PyGpIni);
Py_INCREF(&PyGpExt);
diff --git a/libgpo/pygpo.h b/libgpo/pygpo.h
index 4b85597..8beada1 100644
--- a/libgpo/pygpo.h
+++ b/libgpo/pygpo.h
@@ -8,47 +8,46 @@
//#ifndef _GPEXT_H_
//#define _GPEXT_H_
-
typedef struct {
PyObject_HEAD
- TALLOC_CTX *mem_ctx;
+ TALLOC_CTX * mem_ctx;
struct GP_EXT *gp_ext;
-}PyGpExtObject;
+} PyGpExtObject;
#define pygp_ext_AsgpextContext(pyobj) ((PyGpExtObject *)pyobj)->gp_ext
typedef struct {
PyObject_HEAD
- TALLOC_CTX *mem_ctx;
+ TALLOC_CTX * mem_ctx;
struct GROUP_POLICY_OBJECT *gpo;
struct ADS_STRUCT *ads;
-}PyGpObject;
+} PyGpObject;
#define pygpo_AsgpoContext(pyobj) ((PyGpObject *)pyobj)->gpo
#define pygpoads_AsgpoadsContext(pyobj) ((PyGpObject *)pyobj)->ads
typedef struct {
PyObject_HEAD
- TALLOC_CTX *mem_ctx;
+ TALLOC_CTX * mem_ctx;
struct GP_LINK *gp_link;
struct ADS_STRUCT *ads;
-}PyGpLinkObject;
+} PyGpLinkObject;
#define pygp_link_AsgplinkContext(pyobj) ((PyGpLinkObject *)pyobj)->gp_link
#define pygplinkads_AsgplinkadsContext(pyobj) ((PyGpLinkObject *)->ads
typedef struct {
PyObject_HEAD
- TALLOC_CTX *mem_ctx;
+ TALLOC_CTX * mem_ctx;
struct gp_registry_entry *gp_reg;
-}PyRegObject;
+} PyRegObject;
#define pygp_reg_AsgpregContext(pyobj) ((PyRegObject *)pyobj)->gp_reg
typedef struct {
PyObject_HEAD
- TALLOC_CTX *mem_ctx;
+ TALLOC_CTX * mem_ctx;
struct gp_registry_value *gp_reg_value;
-}PyRegvalobject;
+} PyRegvalobject;
#define pygp_regval_AsgpregvalContext(pyobj) ((PyRegvalObject *)pyobj)->gp_reg_value
typedef struct {
PyObject_HEAD
- TALLOC_CTX *mem_ctx;
+ TALLOC_CTX * mem_ctx;
struct gp_inifile_context *gp_ini;
-}PyGpIniObject;
+} PyGpIniObject;
#define pygp_ini_AsgpiniContext(pyobj) ((PyGpIniObject *)pyobj)->gp_ini
diff --git a/pygpo.h b/pygpo.h
index 7fd588c..c517bd8 100644
--- a/pygpo.h
+++ b/pygpo.h
@@ -1,8 +1,7 @@
#include <talloc.h>
#include "gpo_ini.h"
typedef struct {
- PyObject_HEAD
- Talloc_CTX *mem_ctx;
+ PyObject_HEAD Talloc_CTX * mem_ctx;
struct gp_inifile_context *gp_ctx;
} PyGpiniObject;
diff --git a/source4/dsdb/gpo/gpo_update.c b/source4/dsdb/gpo/gpo_update.c
index c08cf52..5f93098 100644
--- a/source4/dsdb/gpo/gpo_update.c
+++ b/source4/dsdb/gpo/gpo_update.c
@@ -21,7 +21,6 @@
*/
-
#include "includes.h"
#include "dsdb/samdb/samdb.h"
#include "auth/auth.h"
@@ -41,7 +40,6 @@ struct gpoupdate_service {
struct task_server *task;
struct ldb_context *samdb;
-
/* status for periodic sysvol/GPO scan update - >sysvscan */
struct {
uint32_t interval;
@@ -57,7 +55,8 @@ Called when the sysvol scan has finished
static void gpoupdate_sysvscan_done(struct tevent_req *subreq)
{
struct gpoupdate_service *service = tevent_req_callback_data(subreq,
- struct gpoupdate_service);
+ struct
+ gpoupdate_service);
int ret;
int sys_errno;
@@ -66,66 +65,71 @@ static void gpoupdate_sysvscan_done(struct tevent_req *subreq)
ret = samba_runcmd_recv(subreq, &sys_errno);
TALLOC_FREE(subreq);
if (ret != 0) {
- service->sysvscan.status = map_nt_error_from_unix_common(sys_errno);
+ service->sysvscan.status =
+ map_nt_error_from_unix_common(sys_errno);
} else {
service->sysvscan.status = NT_STATUS_OK;
}
if (!NT_STATUS_IS_OK(service->sysvscan.status)) {
- DEBUG(0,(__location__ ": Failed GPO update - %s\n",
- nt_errstr(service->sysvscan.status)));
+ DEBUG(0, (__location__ ": Failed GPO update - %s\n",
+ nt_errstr(service->sysvscan.status)));
} else {
- DEBUG(3,("Completed GPO update check OK\n"));
+ DEBUG(3, ("Completed GPO update check OK\n"));
}
}
static NTSTATUS gpoupdate_sysvscan_schedule(struct gpoupdate_service *service);
-
static void gpoupdate_scan_apply(struct gpoupdate_service *service);
-static void gpoupdate_sysvscan_handler_te(struct tevent_context *ev, struct tevent_timer *te,
+static void gpoupdate_sysvscan_handler_te(struct tevent_context *ev,
+ struct tevent_timer *te,
struct timeval t, void *ptr)
{
- struct gpoupdate_service *service = talloc_get_type(ptr, struct gpoupdate_service);
+ struct gpoupdate_service *service =
+ talloc_get_type(ptr, struct gpoupdate_service);
gpoupdate_scan_apply(service);
gpoupdate_sysvscan_schedule(service);
}
-
-
static NTSTATUS gpoupdate_sysvscan_schedule(struct gpoupdate_service *service)
{
/* For the moment the interval is hard coded to 5 sec */
- DEBUG(0,("calling %s interval = %d\n", __FUNCTION__, service->sysvscan.interval));
- service->sysvscan.te = tevent_add_timer(service->task->event_ctx, service,
- timeval_current_ofs(service->sysvscan.interval, 0),
- gpoupdate_sysvscan_handler_te, service);
+ DEBUG(0,
+ ("calling %s interval = %d\n", __FUNCTION__,
+ service->sysvscan.interval));
+ service->sysvscan.te =
+ tevent_add_timer(service->task->event_ctx, service,
+ timeval_current_ofs(service->sysvscan.interval, 0),
+ gpoupdate_sysvscan_handler_te, service);
NT_STATUS_HAVE_NO_MEMORY(service->sysvscan.te);
return NT_STATUS_OK;
}
static void gpoupdate_scan_apply(struct gpoupdate_service *service)
{
- const char * const* gpo_update_command = lpcfg_gpo_update_command(service->task->lp_ctx);
- const char * smbconf = lpcfg_configfile(service->task->lp_ctx);
+ const char *const *gpo_update_command =
+ lpcfg_gpo_update_command(service->task->lp_ctx);
+ const char *smbconf = lpcfg_configfile(service->task->lp_ctx);
/* /home/john/samba/samba/source4/scripting/bin/gpoupdate */
TALLOC_FREE(service->sysvscan.subreq);
- DEBUG(3,("Calling GPO update script\n"));
+ DEBUG(3, ("Calling GPO update script\n"));
service->sysvscan.subreq = samba_runcmd_send(service,
- service->task->event_ctx,
- timeval_current_ofs(20, 0),
- 2, 0,
- gpo_update_command, smbconf,
- NULL);
+ service->task->event_ctx,
+ timeval_current_ofs(20, 0),
+ 2, 0,
+ gpo_update_command,
+ smbconf, NULL);
if (service->sysvscan.subreq == NULL) {
- DEBUG(0,(__location__ ": samba_runcmd_send() failed with no memory\n"));
+ DEBUG(0,
+ (__location__
+ ": samba_runcmd_send() failed with no memory\n"));
return;
}
tevent_req_set_callback(service->sysvscan.subreq,
- gpoupdate_sysvscan_done,
- service);
+ gpoupdate_sysvscan_done, service);
}
static void gpoupdate_task_init(struct task_server *task)
@@ -142,11 +146,13 @@ static void gpoupdate_task_init(struct task_server *task)
service = talloc_zero(task, struct gpoupdate_service);
if (!service) {
- task_server_terminate(task, "gpoupdate_task_init: out of memory", true);
+ task_server_terminate(task,
+ "gpoupdate_task_init: out of memory",
+ true);
return;
}
- service->task = task;
- task->private_data = service;
+ service->task = task;
+ task->private_data = service;
service->system_session_info = system_session(service->task->lp_ctx);
if (!service->system_session_info) {
@@ -156,22 +162,24 @@ static void gpoupdate_task_init(struct task_server *task)
return;
}
- /*FIXME maybe I should remove this if I don't need to do queries in C*/
- service->samdb = samdb_connect(service, service->task->event_ctx, task->lp_ctx,
- service->system_session_info, 0);
+ /*FIXME maybe I should remove this if I don't need to do queries in C */
+ service->samdb =
+ samdb_connect(service, service->task->event_ctx, task->lp_ctx,
+ service->system_session_info, 0);
if (!service->samdb) {
- task_server_terminate(task, "gpoupdate: Failed to connect to local samdb\n",
+ task_server_terminate(task,
+ "gpoupdate: Failed to connect to local samdb\n",
true);
return;
}
- service->sysvscan.interval = lpcfg_parm_int(task->lp_ctx, NULL,
- "gpoupdate", "config interval", 30); /* in seconds */
+ service->sysvscan.interval = lpcfg_parm_int(task->lp_ctx, NULL, "gpoupdate", "config interval", 30); /* in seconds */
status = gpoupdate_sysvscan_schedule(service);
if (!NT_STATUS_IS_OK(status)) {
task_server_terminate(task, talloc_asprintf(task,
- "gpoupdate: Failed to update sysvol scan schedule: %s\n",
- nt_errstr(status)), true);
+ "gpoupdate: Failed to update sysvol scan schedule: %s\n",
+ nt_errstr(status)),
+ true);
return;
}
}
--
1.9.3
More information about the samba-technical
mailing list