Created
April 8, 2021 21:07
-
-
Save dmulder/7857947bfa5cc8905d31627310ff9e9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Unix SMB/CIFS implementation. | |
Samba utility functions | |
Copyright (C) David Mulder <[email protected]> 2021 | |
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 "python/modules.h" | |
#include "libcli/util/pyerrors.h" | |
#include "reg_api.h" | |
#include "reg_api_util.h" | |
#include <pytalloc.h> | |
#include "lib/events/events.h" | |
#include "param/pyparam.h" | |
static PyObject *py_reg_open_path(PyObject *self, PyObject *args) | |
{ | |
WERROR werr; | |
char *orig_path; | |
uint32_t desired_access; | |
struct security_token *token = NULL; | |
struct registry_key *hive = NULL; | |
TALLOC_CTX *tmp_ctx = talloc_stackframe(); | |
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sI", | |
&orig_path, &desired_access)) { | |
return NULL; | |
} | |
werr = ntstatus_to_werror(registry_create_admin_token(tmp_ctx, &token)); | |
if (!W_ERROR_IS_OK(werr)) { | |
return NULL; | |
} | |
werr = reg_open_path(tmp_ctx, orig_path, desired_access, token, &hive); | |
if (!W_ERROR_IS_OK(werr)) { | |
return NULL; | |
} | |
} | |
static PyObject *py_reg_create_path(PyObject *self, PyObject *args) | |
{ | |
} | |
static PyObject *py_reg_delete_path(PyObject *self, PyObject *args) | |
{ | |
} | |
static PyMethodDef py_registry_methods[] = { | |
{ "OpenPath", py_reg_open_path, METH_VARARGS, | |
"OpenPath(str, int, security_token) -> registry_key" }, | |
{ "CreatePath", py_reg_create_path, METH_VARARGS, | |
"CreatePath(str, int, security_token, winreg_CreateAction) -> registry_key" }, | |
{ "DeletePath", py_reg_delete_path, METH_VARARGS, | |
"DeletePath(security_token, str)" }, | |
{0} | |
}; | |
static struct PyModuleDef moduledef = { | |
PyModuleDef_HEAD_INIT, | |
.m_name = "registry", | |
.m_doc = "Registry", | |
.m_size = -1, | |
.m_methods = py_registry_methods, | |
}; | |
MODULE_INIT_FUNC(registry) | |
{ | |
PyObject *m; | |
m = PyModule_Create(&moduledef); | |
if (m == NULL) | |
return NULL; | |
if (PyModule_AddObject(m, "version", | |
PyUnicode_FromString(SAMBA_VERSION_STRING)) ) { | |
goto err; | |
} | |
return m; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment