[SCM] Samba Shared Repository - branch master updated
Andreas Schneider
asn at samba.org
Fri Feb 17 14:53:01 UTC 2023
The branch, master has been updated
via 0eb459edd8a talloc: remove Python 2 #if clauses
via 2edd028fc78 s4/wmi: begone
from 206dcf7d426 lib:util: File descriptor being closed repeatedly.
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 0eb459edd8ac6fff4d590b932b708ef97e26e372
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Fri Feb 10 15:53:10 2023 +1300
talloc: remove Python 2 #if clauses
Also fix an obsolete related comment.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
Autobuild-Date(master): Fri Feb 17 14:52:26 UTC 2023 on atb-devel-224
commit 2edd028fc78be5fbac6fd8184db0d7290523903b
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date: Fri Feb 10 15:40:15 2023 +1300
s4/wmi: begone
We don't use this and will never use this.
Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/talloc/pytalloc.c | 52 +-
lib/talloc/test_pytalloc.c | 14 -
source4/lib/wmi/tools/wmic.c | 221 ---
source4/lib/wmi/tools/wmis.c | 222 ---
source4/lib/wmi/wbemdata.c | 451 -----
source4/lib/wmi/wmi.h | 48 -
source4/lib/wmi/wmi.i | 352 ----
source4/lib/wmi/wmi.py | 120 --
source4/lib/wmi/wmi_wrap.c | 4304 -----------------------------------------
source4/lib/wmi/wmicore.c | 253 ---
source4/lib/wmi/wscript_build | 26 -
11 files changed, 4 insertions(+), 6059 deletions(-)
delete mode 100644 source4/lib/wmi/tools/wmic.c
delete mode 100644 source4/lib/wmi/tools/wmis.c
delete mode 100644 source4/lib/wmi/wbemdata.c
delete mode 100644 source4/lib/wmi/wmi.h
delete mode 100644 source4/lib/wmi/wmi.i
delete mode 100644 source4/lib/wmi/wmi.py
delete mode 100644 source4/lib/wmi/wmi_wrap.c
delete mode 100644 source4/lib/wmi/wmicore.c
delete mode 100644 source4/lib/wmi/wscript_build
Changeset truncated at 500 lines:
diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c
index 41decc45f61..9d62eed455e 100644
--- a/lib/talloc/pytalloc.c
+++ b/lib/talloc/pytalloc.c
@@ -101,9 +101,9 @@ static void pytalloc_dealloc(PyObject* self)
}
/**
- * Default (but only slightly more useful than the default) implementation of cmp.
+ * Default objects do not support ordered comparisons, but talloc
+ * objects do, sorting by pointers clustered by type.
*/
-#if PY_MAJOR_VERSION >= 3
static PyObject *pytalloc_default_richcmp(PyObject *obj1, PyObject *obj2, int op)
{
void *ptr1;
@@ -131,17 +131,6 @@ static PyObject *pytalloc_default_richcmp(PyObject *obj1, PyObject *obj2, int op
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
-#else
-static int pytalloc_default_cmp(PyObject *_obj1, PyObject *_obj2)
-{
- pytalloc_Object *obj1 = (pytalloc_Object *)_obj1,
- *obj2 = (pytalloc_Object *)_obj2;
- if (obj1->ob_type != obj2->ob_type)
- return ((char *)obj1->ob_type - (char *)obj2->ob_type);
-
- return ((char *)pytalloc_get_ptr(obj1) - (char *)pytalloc_get_ptr(obj2));
-}
-#endif
static PyTypeObject TallocObject_Type = {
.tp_name = "talloc.Object",
@@ -150,11 +139,7 @@ static PyTypeObject TallocObject_Type = {
.tp_dealloc = (destructor)pytalloc_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_repr = pytalloc_default_repr,
-#if PY_MAJOR_VERSION >= 3
.tp_richcompare = pytalloc_default_richcmp,
-#else
- .tp_compare = pytalloc_default_cmp,
-#endif
};
/**
@@ -181,9 +166,9 @@ static void pytalloc_base_dealloc(PyObject* self)
}
/**
- * Default (but only slightly more useful than the default) implementation of cmp.
+ * Default objects do not support ordered comparisons, but talloc
+ * objects do, sorting by pointers clustered by type.
*/
-#if PY_MAJOR_VERSION >= 3
static PyObject *pytalloc_base_default_richcmp(PyObject *obj1, PyObject *obj2, int op)
{
void *ptr1;
@@ -211,17 +196,6 @@ static PyObject *pytalloc_base_default_richcmp(PyObject *obj1, PyObject *obj2, i
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
-#else
-static int pytalloc_base_default_cmp(PyObject *_obj1, PyObject *_obj2)
-{
- pytalloc_BaseObject *obj1 = (pytalloc_BaseObject *)_obj1,
- *obj2 = (pytalloc_BaseObject *)_obj2;
- if (obj1->ob_type != obj2->ob_type)
- return ((char *)obj1->ob_type - (char *)obj2->ob_type);
-
- return ((char *)pytalloc_get_ptr(obj1) - (char *)pytalloc_get_ptr(obj2));
-}
-#endif
static PyTypeObject TallocBaseObject_Type = {
.tp_name = "talloc.BaseObject",
@@ -230,11 +204,7 @@ static PyTypeObject TallocBaseObject_Type = {
.tp_dealloc = (destructor)pytalloc_base_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_repr = pytalloc_base_default_repr,
-#if PY_MAJOR_VERSION >= 3
.tp_richcompare = pytalloc_base_default_richcmp,
-#else
- .tp_compare = pytalloc_base_default_cmp,
-#endif
};
static PyTypeObject TallocGenericObject_Type = {
@@ -247,7 +217,6 @@ static PyTypeObject TallocGenericObject_Type = {
#define MODULE_DOC PyDoc_STR("Python wrapping of talloc-maintained objects.")
-#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
.m_name = "talloc",
@@ -255,7 +224,6 @@ static struct PyModuleDef moduledef = {
.m_size = -1,
.m_methods = talloc_methods,
};
-#endif
static PyObject *module_init(void);
static PyObject *module_init(void)
@@ -271,11 +239,7 @@ static PyObject *module_init(void)
if (PyType_Ready(&TallocGenericObject_Type) < 0)
return NULL;
-#if PY_MAJOR_VERSION >= 3
m = PyModule_Create(&moduledef);
-#else
- m = Py_InitModule3("talloc", talloc_methods, MODULE_DOC);
-#endif
if (m == NULL)
return NULL;
@@ -298,16 +262,8 @@ err:
return NULL;
}
-#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC PyInit_talloc(void);
PyMODINIT_FUNC PyInit_talloc(void)
{
return module_init();
}
-#else
-void inittalloc(void);
-void inittalloc(void)
-{
- module_init();
-}
-#endif
diff --git a/lib/talloc/test_pytalloc.c b/lib/talloc/test_pytalloc.c
index 3b0484b2274..aa05d8c342b 100644
--- a/lib/talloc/test_pytalloc.c
+++ b/lib/talloc/test_pytalloc.c
@@ -181,7 +181,6 @@ static PyTypeObject DBaseObject_Type = {
#define MODULE_DOC PyDoc_STR("Test utility module for pytalloc")
-#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
.m_name = "_test_pytalloc",
@@ -189,7 +188,6 @@ static struct PyModuleDef moduledef = {
.m_size = -1,
.m_methods = test_talloc_methods,
};
-#endif
static PyObject *module_init(void);
static PyObject *module_init(void)
@@ -207,11 +205,7 @@ static PyObject *module_init(void)
return NULL;
}
-#if PY_MAJOR_VERSION >= 3
m = PyModule_Create(&moduledef);
-#else
- m = Py_InitModule3("_test_pytalloc", test_talloc_methods, MODULE_DOC);
-#endif
if (m == NULL) {
return NULL;
@@ -229,16 +223,8 @@ static PyObject *module_init(void)
}
-#if PY_MAJOR_VERSION >= 3
PyMODINIT_FUNC PyInit__test_pytalloc(void);
PyMODINIT_FUNC PyInit__test_pytalloc(void)
{
return module_init();
}
-#else
-void init_test_pytalloc(void);
-void init_test_pytalloc(void)
-{
- module_init();
-}
-#endif
diff --git a/source4/lib/wmi/tools/wmic.c b/source4/lib/wmi/tools/wmic.c
deleted file mode 100644
index 4817decc816..00000000000
--- a/source4/lib/wmi/tools/wmic.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- WMI Sample client
- Copyright (C) 2006 Andrzej Hajda <andrzej.hajda at wp.pl>
- Copyright (C) 2008 Jelmer Vernooij <jelmer at samba.org>
-
- 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 "lib/cmdline/popt_common.h"
-#include "librpc/rpc/dcerpc.h"
-#include "librpc/gen_ndr/ndr_oxidresolver.h"
-#include "librpc/gen_ndr/ndr_oxidresolver_c.h"
-#include "librpc/gen_ndr/ndr_dcom.h"
-#include "librpc/gen_ndr/ndr_dcom_c.h"
-#include "librpc/gen_ndr/ndr_remact_c.h"
-#include "librpc/gen_ndr/ndr_epmapper_c.h"
-#include "librpc/gen_ndr/com_dcom.h"
-
-#include "lib/com/dcom/dcom.h"
-#include "lib/com/com.h"
-
-#include "lib/wmi/wmi.h"
-
-struct program_args {
- char *hostname;
- char *query;
- char *ns;
-};
-
-static void parse_args(int argc, char *argv[], struct program_args *pmyargs)
-{
- poptContext pc;
- int opt, i;
-
- int argc_new;
- char **argv_new;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_SAMBA
- POPT_COMMON_CONNECTION
- POPT_COMMON_CREDENTIALS
- POPT_COMMON_VERSION
- {"namespace", 0, POPT_ARG_STRING, &pmyargs->ns, 0,
- "WMI namespace, default to root\\cimv2", 0},
- POPT_TABLEEND
- };
-
- pc = poptGetContext("wmi", argc, (const char **) argv,
- long_options, POPT_CONTEXT_KEEP_FIRST);
-
- poptSetOtherOptionHelp(pc, "//host query\n\nExample: wmic -U [domain/]adminuser%password //host \"select * from Win32_ComputerSystem\"");
-
- while ((opt = poptGetNextOpt(pc)) != -1) {
- poptPrintUsage(pc, stdout, 0);
- poptFreeContext(pc);
- exit(1);
- }
-
- argv_new = discard_const_p(char *, poptGetArgs(pc));
-
- argc_new = argc;
- for (i = 0; i < argc; i++) {
- if (argv_new[i] == NULL) {
- argc_new = i;
- break;
- }
- }
-
- if (argc_new != 3 || argv_new[1][0] != '/'
- || argv_new[1][1] != '/') {
- poptPrintUsage(pc, stdout, 0);
- poptFreeContext(pc);
- exit(1);
- }
-
- pmyargs->hostname = argv_new[1] + 2;
- pmyargs->query = argv_new[2];
- poptFreeContext(pc);
-}
-
-#define WERR_CHECK(msg) if (!W_ERROR_IS_OK(result)) { \
- DEBUG(0, ("ERROR: %s\n", msg)); \
- goto error; \
- } else { \
- DEBUG(1, ("OK : %s\n", msg)); \
- }
-
-#define RETURN_CVAR_ARRAY_STR(fmt, arr) {\
- uint32_t i;\
- char *r;\
-\
- if (!arr) {\
- return talloc_strdup(mem_ctx, "NULL");\
- }\
- r = talloc_strdup(mem_ctx, "(");\
- for (i = 0; i < arr->count; ++i) {\
- r = talloc_asprintf_append(r, fmt "%s", arr->item[i], (i+1 == arr->count)?"":",");\
- }\
- return talloc_asprintf_append(r, ")");\
-}
-
-char *string_CIMVAR(TALLOC_CTX *mem_ctx, union CIMVAR *v, enum CIMTYPE_ENUMERATION cimtype)
-{
- switch (cimtype) {
- case CIM_SINT8: return talloc_asprintf(mem_ctx, "%d", v->v_sint8);
- case CIM_UINT8: return talloc_asprintf(mem_ctx, "%u", v->v_uint8);
- case CIM_SINT16: return talloc_asprintf(mem_ctx, "%d", v->v_sint16);
- case CIM_UINT16: return talloc_asprintf(mem_ctx, "%u", v->v_uint16);
- case CIM_SINT32: return talloc_asprintf(mem_ctx, "%d", v->v_sint32);
- case CIM_UINT32: return talloc_asprintf(mem_ctx, "%u", v->v_uint32);
- case CIM_SINT64: return talloc_asprintf(mem_ctx, "%lld", v->v_sint64);
- case CIM_UINT64: return talloc_asprintf(mem_ctx, "%llu", v->v_sint64);
- case CIM_REAL32: return talloc_asprintf(mem_ctx, "%f", (double)v->v_uint32);
- case CIM_REAL64: return talloc_asprintf(mem_ctx, "%f", (double)v->v_uint64);
- case CIM_BOOLEAN: return talloc_asprintf(mem_ctx, "%s", v->v_boolean?"True":"False");
- case CIM_STRING:
- case CIM_DATETIME:
- case CIM_REFERENCE: return talloc_asprintf(mem_ctx, "%s", v->v_string);
- case CIM_CHAR16: return talloc_asprintf(mem_ctx, "Unsupported");
- case CIM_OBJECT: return talloc_asprintf(mem_ctx, "Unsupported");
- case CIM_ARR_SINT8: RETURN_CVAR_ARRAY_STR("%d", v->a_sint8);
- case CIM_ARR_UINT8: RETURN_CVAR_ARRAY_STR("%u", v->a_uint8);
- case CIM_ARR_SINT16: RETURN_CVAR_ARRAY_STR("%d", v->a_sint16);
- case CIM_ARR_UINT16: RETURN_CVAR_ARRAY_STR("%u", v->a_uint16);
- case CIM_ARR_SINT32: RETURN_CVAR_ARRAY_STR("%d", v->a_sint32);
- case CIM_ARR_UINT32: RETURN_CVAR_ARRAY_STR("%u", v->a_uint32);
- case CIM_ARR_SINT64: RETURN_CVAR_ARRAY_STR("%lld", v->a_sint64);
- case CIM_ARR_UINT64: RETURN_CVAR_ARRAY_STR("%llu", v->a_uint64);
- case CIM_ARR_REAL32: RETURN_CVAR_ARRAY_STR("%f", v->a_real32);
- case CIM_ARR_REAL64: RETURN_CVAR_ARRAY_STR("%f", v->a_real64);
- case CIM_ARR_BOOLEAN: RETURN_CVAR_ARRAY_STR("%d", v->a_boolean);
- case CIM_ARR_STRING: RETURN_CVAR_ARRAY_STR("%s", v->a_string);
- case CIM_ARR_DATETIME: RETURN_CVAR_ARRAY_STR("%s", v->a_datetime);
- case CIM_ARR_REFERENCE: RETURN_CVAR_ARRAY_STR("%s", v->a_reference);
- default: return talloc_asprintf(mem_ctx, "Unsupported");
- }
-}
-
-#undef RETURN_CVAR_ARRAY_STR
-
-int main(int argc, char **argv)
-{
- struct program_args args = {};
- uint32_t cnt = 5, ret;
- char *class_name = NULL;
- WERROR result;
- NTSTATUS status;
- struct IWbemServices *pWS = NULL;
- struct BSTR queryLanguage, query;
- struct IEnumWbemClassObject *pEnum = NULL;
- struct com_context *ctx = NULL;
-
- parse_args(argc, argv, &args);
-
- wmi_init(&ctx, popt_get_cmdline_credentials());
-
- if (!args.ns)
- args.ns = "root\\cimv2";
- result = WBEM_ConnectServer(ctx, args.hostname, args.ns, 0, 0, 0, 0, 0, 0, &pWS);
- WERR_CHECK("Login to remote object.");
-
- queryLanguage.data = "WQL";
- query.data = args.query;
- result = IWbemServices_ExecQuery(pWS, ctx, queryLanguage, query, WBEM_FLAG_RETURN_IMMEDIATELY | WBEM_FLAG_ENSURE_LOCATABLE, NULL, &pEnum);
- WERR_CHECK("WMI query execute.");
-
- IEnumWbemClassObject_Reset(pEnum, ctx);
- WERR_CHECK("Reset result of WMI query.");
-
- do {
- uint32_t i, j;
- struct WbemClassObject *co[cnt];
-
- result = IEnumWbemClassObject_SmartNext(pEnum, ctx, 0xFFFFFFFF, cnt, co, &ret);
- /* WERR_INVALID_FUNCTION is OK, it means only that there is less returned objects than requested */
- if (!W_ERROR_EQUAL(result, WERR_INVALID_FUNCTION)) {
- WERR_CHECK("Retrieve result data.");
- } else {
- DEBUG(1, ("OK : Retrieved less objects than requested (it is normal).\n"));
- }
- if (!ret) break;
-
- for (i = 0; i < ret; ++i) {
- if (!class_name || strcmp(co[i]->obj_class->__CLASS, class_name)) {
- if (class_name) talloc_free(class_name);
- class_name = talloc_strdup(ctx, co[i]->obj_class->__CLASS);
- printf("CLASS: %s\n", class_name);
- for (j = 0; j < co[i]->obj_class->__PROPERTY_COUNT; ++j)
- printf("%s%s", j?"|":"", co[i]->obj_class->properties[j].property.name);
- printf("\n");
- }
- for (j = 0; j < co[i]->obj_class->__PROPERTY_COUNT; ++j) {
- char *s;
- s = string_CIMVAR(ctx, &co[i]->instance->data[j], co[i]->obj_class->properties[j].property.desc->cimtype & CIM_TYPEMASK);
- printf("%s%s", j?"|":"", s);
- }
- printf("\n");
- }
- } while (ret == cnt);
- talloc_free(ctx);
- return 0;
-error:
- status = werror_to_ntstatus(result);
- fprintf(stderr, "NTSTATUS: %s - %s\n", nt_errstr(status), get_friendly_nt_error_msg(status));
- talloc_free(ctx);
- return 1;
-}
diff --git a/source4/lib/wmi/tools/wmis.c b/source4/lib/wmi/tools/wmis.c
deleted file mode 100644
index 395cec2ce6d..00000000000
--- a/source4/lib/wmi/tools/wmis.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- WMI Sample client
- Copyright (C) 2006 Andrzej Hajda <andrzej.hajda at wp.pl>
- Copyright (C) 2008 Jelmer Vernooij <jelmer at samba.org>
-
- 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 "lib/cmdline/popt_common.h"
-#include "auth/credentials/credentials.h"
-#include "librpc/rpc/dcerpc.h"
-#include "librpc/gen_ndr/ndr_oxidresolver.h"
-#include "librpc/gen_ndr/ndr_oxidresolver_c.h"
-#include "librpc/gen_ndr/dcom.h"
-#include "librpc/gen_ndr/ndr_dcom.h"
-#include "librpc/gen_ndr/ndr_dcom_c.h"
-#include "librpc/gen_ndr/ndr_remact_c.h"
-#include "librpc/gen_ndr/ndr_epmapper_c.h"
-#include "librpc/gen_ndr/com_dcom.h"
-
-#include "lib/com/dcom/dcom.h"
-#include "librpc/gen_ndr/com_wmi.h"
-#include "librpc/ndr/ndr_table.h"
-
-#include "lib/wmi/wmi.h"
-
-struct program_args {
- char *hostname;
- char *query;
-};
-
-static void parse_args(int argc, char *argv[], struct program_args *pmyargs)
-{
- poptContext pc;
- int opt, i;
-
- int argc_new;
- char **argv_new;
-
- struct poptOption long_options[] = {
- POPT_AUTOHELP
- POPT_COMMON_SAMBA
- POPT_COMMON_CONNECTION
- POPT_COMMON_CREDENTIALS
- POPT_COMMON_VERSION
- POPT_TABLEEND
- };
-
- pc = poptGetContext("wmi", argc, (const char **) argv,
- long_options, POPT_CONTEXT_KEEP_FIRST);
-
- poptSetOtherOptionHelp(pc, "//host\n\nExample: wmis -U [domain/]adminuser%password //host");
-
- while ((opt = poptGetNextOpt(pc)) != -1) {
- poptPrintUsage(pc, stdout, 0);
- poptFreeContext(pc);
- exit(1);
- }
-
- argv_new = discard_const_p(char *, poptGetArgs(pc));
-
- argc_new = argc;
- for (i = 0; i < argc; i++) {
- if (argv_new[i] == NULL) {
- argc_new = i;
- break;
- }
- }
-
- if (argc_new < 2 || argv_new[1][0] != '/'
- || argv_new[1][1] != '/') {
- poptPrintUsage(pc, stdout, 0);
--
Samba Shared Repository
More information about the samba-cvs
mailing list