From 0afaf0f4615f163229190f321da12649b918c933 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 9 Nov 2023 11:32:58 +0100 Subject: [PATCH 1/5] lib:replace: Add python.h BUG: https://bugzilla.samba.org/show_bug.cgi?id=15513 Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett (cherry picked from commit f337fd995024283f6e1b3f8ec1cc2b3aeb55a2a6) --- lib/replace/system/python.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/replace/system/python.h diff --git a/lib/replace/system/python.h b/lib/replace/system/python.h new file mode 100644 index 00000000000..b242baecb1c --- /dev/null +++ b/lib/replace/system/python.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2023 Andreas Schneider + * + * 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 . + */ + +#ifndef _SAMBA_PYTHON_H +#define _SAMBA_PYTHON_H + +/* + * With Python 3.6 Cpython started to require C99. With Python 3.12 they + * started to mix code and variable declarations so disable the warnings. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeclaration-after-statement" +#include +#pragma GCC diagnostic pop + +#endif /* _SAMBA_PYTHON_H */ -- 2.42.1 From dcd60ef1e5ef2040ddffd8e72b011f4c129dc477 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 9 Nov 2023 11:35:56 +0100 Subject: [PATCH 2/5] Use python.h from libreplace BUG: https://bugzilla.samba.org/show_bug.cgi?id=15513 Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett (cherry picked from commit 9621a3d7a6949aa833425884cd22379387738cfa) --- auth/credentials/pycredentials.c | 2 +- lib/compression/pycompression.c | 2 +- lib/crypto/py_crypto.c | 2 +- lib/ldb-samba/pyldb.c | 2 +- lib/ldb/pyldb.c | 2 +- lib/ldb/pyldb_util.c | 2 +- lib/smbconf/pysmbconf.c | 2 +- lib/smbconf/pysmbconf.h | 2 +- lib/talloc/pytalloc.c | 2 +- lib/talloc/pytalloc_util.c | 2 +- lib/talloc/test_pytalloc.c | 2 +- lib/tdb/pytdb.c | 2 +- lib/tevent/pytevent.c | 2 +- libcli/nbt/pynbt.c | 2 +- libcli/security/pysecurity.c | 2 +- libcli/smb/py_reparse_symlink.c | 2 +- libgpo/pygpo.c | 2 +- pidl/lib/Parse/Pidl/Samba4/Python.pm | 2 +- python/modules.c | 2 +- python/py3compat.h | 2 +- python/pyglue.c | 2 +- source3/lib/smbconf/pys3smbconf.c | 2 +- source3/libsmb/pylibsmb.c | 2 +- source3/param/pyparam.c | 2 +- source3/param/pyparam_util.c | 2 +- source3/passdb/py_passdb.c | 2 +- source3/rpc_client/py_mdscli.c | 2 +- source3/smbd/pysmbd.c | 2 +- source3/utils/py_net.c | 2 +- source4/auth/gensec/pygensec.c | 2 +- source4/auth/pyauth.c | 2 +- source4/dns_server/pydns.c | 2 +- source4/dsdb/pydsdb.c | 2 +- source4/lib/messaging/pymessaging.c | 2 +- source4/lib/policy/pypolicy.c | 2 +- source4/lib/registry/pyregistry.c | 2 +- source4/libnet/py_net.c | 2 +- source4/libnet/py_net_dckeytab.c | 2 +- source4/librpc/ndr/py_auth.c | 2 +- source4/librpc/ndr/py_lsa.c | 2 +- source4/librpc/ndr/py_misc.c | 2 +- source4/librpc/ndr/py_security.c | 26 ++++++++++----------- source4/librpc/ndr/py_xattr.c | 2 +- source4/librpc/rpc/pyrpc.c | 2 +- source4/librpc/rpc/pyrpc_util.c | 2 +- source4/ntvfs/posix/python/pyposix_eadb.c | 2 +- source4/ntvfs/posix/python/pyxattr_native.c | 2 +- source4/ntvfs/posix/python/pyxattr_tdb.c | 2 +- source4/param/provision.c | 2 +- source4/param/pyparam.c | 2 +- source4/param/pyparam_util.c | 2 +- source4/scripting/bin/gen_ntstatus.py | 2 +- source4/scripting/bin/gen_werror.py | 2 +- 53 files changed, 65 insertions(+), 65 deletions(-) diff --git a/auth/credentials/pycredentials.c b/auth/credentials/pycredentials.c index bd877941a9a..3687050bde9 100644 --- a/auth/credentials/pycredentials.c +++ b/auth/credentials/pycredentials.c @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/lib/compression/pycompression.c b/lib/compression/pycompression.c index 3be3620b1cf..5c3fd82a00a 100644 --- a/lib/compression/pycompression.c +++ b/lib/compression/pycompression.c @@ -26,7 +26,7 @@ #include "includes.h" #include -#include +#include "lib/replace/system/python.h" #include "lzxpress.h" #include "lzxpress_huffman.h" diff --git a/lib/crypto/py_crypto.c b/lib/crypto/py_crypto.c index 5b3c307057a..4d89e12376f 100644 --- a/lib/crypto/py_crypto.c +++ b/lib/crypto/py_crypto.c @@ -18,7 +18,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "python/py3compat.h" diff --git a/lib/ldb-samba/pyldb.c b/lib/ldb-samba/pyldb.c index 01ed065947a..2241abc01df 100644 --- a/lib/ldb-samba/pyldb.c +++ b/lib/ldb-samba/pyldb.c @@ -19,7 +19,7 @@ License along with this library; if not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include diff --git a/lib/ldb/pyldb.c b/lib/ldb/pyldb.c index 8981e5ea45c..a0383ab8166 100644 --- a/lib/ldb/pyldb.c +++ b/lib/ldb/pyldb.c @@ -28,7 +28,7 @@ License along with this library; if not, see . */ -#include +#include "lib/replace/system/python.h" #include "ldb_private.h" #include "ldb_handlers.h" #include "pyldb.h" diff --git a/lib/ldb/pyldb_util.c b/lib/ldb/pyldb_util.c index 665e34426bc..1256b16ddad 100644 --- a/lib/ldb/pyldb_util.c +++ b/lib/ldb/pyldb_util.c @@ -23,7 +23,7 @@ License along with this library; if not, see . */ -#include +#include "lib/replace/system/python.h" #include "ldb.h" #include "pyldb.h" diff --git a/lib/smbconf/pysmbconf.c b/lib/smbconf/pysmbconf.c index 20041d3a580..2538127b1ba 100644 --- a/lib/smbconf/pysmbconf.c +++ b/lib/smbconf/pysmbconf.c @@ -18,7 +18,7 @@ * along with this program; if not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "python/py3compat.h" diff --git a/lib/smbconf/pysmbconf.h b/lib/smbconf/pysmbconf.h index e8c6c9998e3..1e57bfb19dd 100644 --- a/lib/smbconf/pysmbconf.h +++ b/lib/smbconf/pysmbconf.h @@ -21,7 +21,7 @@ #ifndef _PYSMBCONF_H_ #define _PYSMBCONF_H_ -#include +#include "lib/replace/system/python.h" #include "lib/smbconf/smbconf.h" typedef struct { diff --git a/lib/talloc/pytalloc.c b/lib/talloc/pytalloc.c index 9d62eed455e..f6f068108d6 100644 --- a/lib/talloc/pytalloc.c +++ b/lib/talloc/pytalloc.c @@ -21,7 +21,7 @@ License along with this library; if not, see . */ -#include +#include "lib/replace/system/python.h" #include #include #include "pytalloc_private.h" diff --git a/lib/talloc/pytalloc_util.c b/lib/talloc/pytalloc_util.c index 064957ffd6f..766938a82c8 100644 --- a/lib/talloc/pytalloc_util.c +++ b/lib/talloc/pytalloc_util.c @@ -21,7 +21,7 @@ License along with this library; if not, see . */ -#include +#include "lib/replace/system/python.h" #include "replace.h" #include #include "pytalloc.h" diff --git a/lib/talloc/test_pytalloc.c b/lib/talloc/test_pytalloc.c index aa05d8c342b..fb385852a39 100644 --- a/lib/talloc/test_pytalloc.c +++ b/lib/talloc/test_pytalloc.c @@ -26,7 +26,7 @@ License along with this library; if not, see . */ -#include +#include "lib/replace/system/python.h" #include #include diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c index ed22803328c..4d75d7a9041 100644 --- a/lib/tdb/pytdb.c +++ b/lib/tdb/pytdb.c @@ -24,7 +24,7 @@ License along with this library; if not, see . */ -#include +#include "lib/replace/system/python.h" #include "replace.h" #include "system/filesys.h" diff --git a/lib/tevent/pytevent.c b/lib/tevent/pytevent.c index aa2331c1d6c..bbe29f6c693 100644 --- a/lib/tevent/pytevent.c +++ b/lib/tevent/pytevent.c @@ -22,7 +22,7 @@ License along with this library; if not, see . */ -#include +#include "lib/replace/system/python.h" #include "replace.h" #include diff --git a/libcli/nbt/pynbt.c b/libcli/nbt/pynbt.c index 0908a6bce3c..e0a72fa8451 100644 --- a/libcli/nbt/pynbt.c +++ b/libcli/nbt/pynbt.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "python/py3compat.h" #include "libcli/util/pyerrors.h" diff --git a/libcli/security/pysecurity.c b/libcli/security/pysecurity.c index 80730485242..c7eaa91a71b 100644 --- a/libcli/security/pysecurity.c +++ b/libcli/security/pysecurity.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/libcli/smb/py_reparse_symlink.c b/libcli/smb/py_reparse_symlink.c index 57dc6032f99..470aab8d679 100644 --- a/libcli/smb/py_reparse_symlink.c +++ b/libcli/smb/py_reparse_symlink.c @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "replace.h" #include "python/modules.h" #include "python/py3compat.h" diff --git a/libgpo/pygpo.c b/libgpo/pygpo.c index bf63a60522f..adbd5b4688d 100644 --- a/libgpo/pygpo.c +++ b/libgpo/pygpo.c @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "version.h" #include "param/pyparam.h" diff --git a/pidl/lib/Parse/Pidl/Samba4/Python.pm b/pidl/lib/Parse/Pidl/Samba4/Python.pm index 6eb59a0557e..7867eabad92 100644 --- a/pidl/lib/Parse/Pidl/Samba4/Python.pm +++ b/pidl/lib/Parse/Pidl/Samba4/Python.pm @@ -2293,7 +2293,7 @@ sub Parse($$$$$) $self->pidl_hdr(" /* Python wrapper functions auto-generated by pidl */ #define PY_SSIZE_T_CLEAN 1 /* We use Py_ssize_t for PyArg_ParseTupleAndKeywords */ -#include +#include \"lib/replace/system/python.h\" #include \"python/py3compat.h\" #include \"includes.h\" #include \"python/modules.h\" diff --git a/python/modules.c b/python/modules.c index ca563ff07d2..577eb552750 100644 --- a/python/modules.c +++ b/python/modules.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/python/py3compat.h b/python/py3compat.h index 01108214783..bfee82f92b3 100644 --- a/python/py3compat.h +++ b/python/py3compat.h @@ -19,7 +19,7 @@ #ifndef _SAMBA_PY3COMPAT_H_ #define _SAMBA_PY3COMPAT_H_ -#include +#include "lib/replace/system/python.h" /* Quick docs: * Syntax for module initialization is as in Python 3, except the entrypoint diff --git a/python/pyglue.c b/python/pyglue.c index 901a9a37be5..b35b2d21104 100644 --- a/python/pyglue.c +++ b/python/pyglue.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/source3/lib/smbconf/pys3smbconf.c b/source3/lib/smbconf/pys3smbconf.c index 07e75f6b579..09d4881a9b0 100644 --- a/source3/lib/smbconf/pys3smbconf.c +++ b/source3/lib/smbconf/pys3smbconf.c @@ -18,7 +18,7 @@ * along with this program; if not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "python/py3compat.h" diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index 6199f7b32dc..f06f6640640 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -45,7 +45,7 @@ c = libsmb.Conn("127.0.0.1", ------------------------- */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "python/py3compat.h" #include "python/modules.h" diff --git a/source3/param/pyparam.c b/source3/param/pyparam.c index 749cfe308f4..531bc2a687f 100644 --- a/source3/param/pyparam.c +++ b/source3/param/pyparam.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "python/py3compat.h" #include "param/param.h" diff --git a/source3/param/pyparam_util.c b/source3/param/pyparam_util.c index 67ab4945d6a..bfd8d05a292 100644 --- a/source3/param/pyparam_util.c +++ b/source3/param/pyparam_util.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "param/param.h" #include "param/pyparam.h" diff --git a/source3/passdb/py_passdb.c b/source3/passdb/py_passdb.c index 7982654b6bc..48497a34552 100644 --- a/source3/passdb/py_passdb.c +++ b/source3/passdb/py_passdb.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include #include "includes.h" #include "python/py3compat.h" diff --git a/source3/rpc_client/py_mdscli.c b/source3/rpc_client/py_mdscli.c index 2594200ecfe..ccb0342b86b 100644 --- a/source3/rpc_client/py_mdscli.c +++ b/source3/rpc_client/py_mdscli.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include #include "includes.h" #include "python/py3compat.h" diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c index f9f5384cfb3..e1f889dad30 100644 --- a/source3/smbd/pysmbd.c +++ b/source3/smbd/pysmbd.c @@ -23,7 +23,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "python/py3compat.h" #include "python/modules.h" diff --git a/source3/utils/py_net.c b/source3/utils/py_net.c index 6f20fdb0890..181b8f2d1ca 100644 --- a/source3/utils/py_net.c +++ b/source3/utils/py_net.c @@ -18,7 +18,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include #include "python/modules.h" diff --git a/source4/auth/gensec/pygensec.c b/source4/auth/gensec/pygensec.c index dd63fa58348..97ced8f11c4 100644 --- a/source4/auth/gensec/pygensec.c +++ b/source4/auth/gensec/pygensec.c @@ -16,7 +16,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/source4/auth/pyauth.c b/source4/auth/pyauth.c index b41108b7072..498b52e2bec 100644 --- a/source4/auth/pyauth.c +++ b/source4/auth/pyauth.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/source4/dns_server/pydns.c b/source4/dns_server/pydns.c index 7b83d7c49a1..6e99ebd6479 100644 --- a/source4/dns_server/pydns.c +++ b/source4/dns_server/pydns.c @@ -19,7 +19,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/source4/dsdb/pydsdb.c b/source4/dsdb/pydsdb.c index 6bf304f4f91..aac311a84ff 100644 --- a/source4/dsdb/pydsdb.c +++ b/source4/dsdb/pydsdb.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include diff --git a/source4/lib/messaging/pymessaging.c b/source4/lib/messaging/pymessaging.c index 31755ea591a..b88727c6bd2 100644 --- a/source4/lib/messaging/pymessaging.c +++ b/source4/lib/messaging/pymessaging.c @@ -19,7 +19,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/source4/lib/policy/pypolicy.c b/source4/lib/policy/pypolicy.c index f40d811a50f..f85ea8532bc 100644 --- a/source4/lib/policy/pypolicy.c +++ b/source4/lib/policy/pypolicy.c @@ -17,7 +17,7 @@ * along with this program; if not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "python/py3compat.h" #include "policy.h" diff --git a/source4/lib/registry/pyregistry.c b/source4/lib/registry/pyregistry.c index f4201c3ca9e..de40d2a6669 100644 --- a/source4/lib/registry/pyregistry.c +++ b/source4/lib/registry/pyregistry.c @@ -18,7 +18,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/source4/libnet/py_net.c b/source4/libnet/py_net.c index 42eee509c6b..071ad0481ec 100644 --- a/source4/libnet/py_net.c +++ b/source4/libnet/py_net.c @@ -19,7 +19,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/source4/libnet/py_net_dckeytab.c b/source4/libnet/py_net_dckeytab.c index ad65c7d46a6..0c3df8958ab 100644 --- a/source4/libnet/py_net_dckeytab.c +++ b/source4/libnet/py_net_dckeytab.c @@ -20,7 +20,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "python/py3compat.h" #include "python/modules.h" diff --git a/source4/librpc/ndr/py_auth.c b/source4/librpc/ndr/py_auth.c index d34a852c06d..8d233b3112c 100644 --- a/source4/librpc/ndr/py_auth.c +++ b/source4/librpc/ndr/py_auth.c @@ -18,7 +18,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "includes.h" #include "libcli/util/pyerrors.h" #include "pyauth.h" diff --git a/source4/librpc/ndr/py_lsa.c b/source4/librpc/ndr/py_lsa.c index a59dcbf970c..c5e221fbaa0 100644 --- a/source4/librpc/ndr/py_lsa.c +++ b/source4/librpc/ndr/py_lsa.c @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "librpc/gen_ndr/lsa.h" static PyObject *py_lsa_String_str(PyObject *py_self) diff --git a/source4/librpc/ndr/py_misc.c b/source4/librpc/ndr/py_misc.c index 99100875689..16e2960a1c3 100644 --- a/source4/librpc/ndr/py_misc.c +++ b/source4/librpc/ndr/py_misc.c @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "librpc/gen_ndr/misc.h" diff --git a/source4/librpc/ndr/py_security.c b/source4/librpc/ndr/py_security.c index 217b7dc19d1..772f8ac1837 100644 --- a/source4/librpc/ndr/py_security.c +++ b/source4/librpc/ndr/py_security.c @@ -1,23 +1,23 @@ -/* +/* Unix SMB/CIFS implementation. Samba utility functions Copyright (C) Jelmer Vernooij 2008-2010 - + 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 . */ -#include +#include "lib/replace/system/python.h" #include "py3compat.h" #include "libcli/security/sddl.h" #include "libcli/security/security.h" @@ -31,11 +31,11 @@ static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods) dict = type->tp_dict; for (i = 0; methods[i].ml_name; i++) { PyObject *descr; - if (methods[i].ml_flags & METH_CLASS) + if (methods[i].ml_flags & METH_CLASS) descr = PyCFunction_New(&methods[i], (PyObject *)type); - else + else descr = PyDescr_NewMethod(type, &methods[i]); - PyDict_SetItemString(dict, methods[i].ml_name, + PyDict_SetItemString(dict, methods[i].ml_name, descr); Py_CLEAR(descr); } @@ -414,7 +414,7 @@ static PyObject *py_token_is_anonymous(PyObject *self, PyObject *Py_UNUSED(ignored)) { struct security_token *token = pytalloc_get_ptr(self); - + return PyBool_FromLong(security_token_is_anonymous(token)); } @@ -422,7 +422,7 @@ static PyObject *py_token_is_system(PyObject *self, PyObject *Py_UNUSED(ignored)) { struct security_token *token = pytalloc_get_ptr(self); - + return PyBool_FromLong(security_token_is_system(token)); } @@ -430,7 +430,7 @@ static PyObject *py_token_has_builtin_administrators(PyObject *self, PyObject *Py_UNUSED(ignored)) { struct security_token *token = pytalloc_get_ptr(self); - + return PyBool_FromLong(security_token_has_builtin_administrators(token)); } @@ -438,7 +438,7 @@ static PyObject *py_token_has_nt_authenticated_users(PyObject *self, PyObject *Py_UNUSED(ignored)) { struct security_token *token = pytalloc_get_ptr(self); - + return PyBool_FromLong(security_token_has_nt_authenticated_users(token)); } @@ -468,7 +468,7 @@ static PyObject *py_token_set_privilege(PyObject *self, PyObject *args) static PyObject *py_token_new(PyTypeObject *self, PyObject *args, PyObject *kwargs) { return pytalloc_steal(self, security_token_initialise(NULL)); -} +} static PyMethodDef py_token_extra_methods[] = { { "is_sid", (PyCFunction)py_token_is_sid, METH_VARARGS, diff --git a/source4/librpc/ndr/py_xattr.c b/source4/librpc/ndr/py_xattr.c index 221b9771e0d..523c1ab4a19 100644 --- a/source4/librpc/ndr/py_xattr.c +++ b/source4/librpc/ndr/py_xattr.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" static void PyType_AddMethods(PyTypeObject *type, PyMethodDef *methods) { diff --git a/source4/librpc/rpc/pyrpc.c b/source4/librpc/rpc/pyrpc.c index 61b3c6357b0..3f1a8679d3e 100644 --- a/source4/librpc/rpc/pyrpc.c +++ b/source4/librpc/rpc/pyrpc.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/source4/librpc/rpc/pyrpc_util.c b/source4/librpc/rpc/pyrpc_util.c index 0d6a16518f1..6a9c8c77437 100644 --- a/source4/librpc/rpc/pyrpc_util.c +++ b/source4/librpc/rpc/pyrpc_util.c @@ -20,7 +20,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "python/modules.h" diff --git a/source4/ntvfs/posix/python/pyposix_eadb.c b/source4/ntvfs/posix/python/pyposix_eadb.c index abf397f990c..aca92e71b7e 100644 --- a/source4/ntvfs/posix/python/pyposix_eadb.c +++ b/source4/ntvfs/posix/python/pyposix_eadb.c @@ -18,7 +18,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "system/filesys.h" diff --git a/source4/ntvfs/posix/python/pyxattr_native.c b/source4/ntvfs/posix/python/pyxattr_native.c index 7511e5c02bf..6b237b00084 100644 --- a/source4/ntvfs/posix/python/pyxattr_native.c +++ b/source4/ntvfs/posix/python/pyxattr_native.c @@ -18,7 +18,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "librpc/ndr/libndr.h" diff --git a/source4/ntvfs/posix/python/pyxattr_tdb.c b/source4/ntvfs/posix/python/pyxattr_tdb.c index 425fd868ca0..5f07809834c 100644 --- a/source4/ntvfs/posix/python/pyxattr_tdb.c +++ b/source4/ntvfs/posix/python/pyxattr_tdb.c @@ -18,7 +18,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "system/filesys.h" diff --git a/source4/param/provision.c b/source4/param/provision.c index d6d120647e6..f5caf66b3c6 100644 --- a/source4/param/provision.c +++ b/source4/param/provision.c @@ -18,7 +18,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include #include diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index c91b7382ef4..2bd7b91bd50 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "python/py3compat.h" #include "includes.h" #include "param/param.h" diff --git a/source4/param/pyparam_util.c b/source4/param/pyparam_util.c index 9b9dcd22c90..bb7ffda1cc2 100644 --- a/source4/param/pyparam_util.c +++ b/source4/param/pyparam_util.c @@ -17,7 +17,7 @@ along with this program. If not, see . */ -#include +#include "lib/replace/system/python.h" #include "py3compat.h" #include "includes.h" #include "param/param.h" diff --git a/source4/scripting/bin/gen_ntstatus.py b/source4/scripting/bin/gen_ntstatus.py index bf0f01640b0..e4b0ad8e428 100755 --- a/source4/scripting/bin/gen_ntstatus.py +++ b/source4/scripting/bin/gen_ntstatus.py @@ -69,7 +69,7 @@ def generatePythonFile(out_file, errors): out_file.write(" * New descriptions for existing errors generated from\n") out_file.write(" * [MS-ERREF] http://msdn.microsoft.com/en-us/library/cc704588.aspx\n") out_file.write(" */\n") - out_file.write("#include \n") + out_file.write("#include \"lib/replace/system/python.h\"\n") out_file.write("#include \"python/py3compat.h\"\n") out_file.write("#include \"includes.h\"\n\n") # This is needed to avoid a missing prototype error from the C diff --git a/source4/scripting/bin/gen_werror.py b/source4/scripting/bin/gen_werror.py index 445d7994d8b..c0087d3c3f2 100755 --- a/source4/scripting/bin/gen_werror.py +++ b/source4/scripting/bin/gen_werror.py @@ -67,7 +67,7 @@ def generatePythonFile(out_file, errors): out_file.write(" * Errors generated from\n") out_file.write(" * [MS-ERREF] https://msdn.microsoft.com/en-us/library/cc231199.aspx\n") out_file.write(" */\n") - out_file.write("#include \n") + out_file.write("#include \"lib/replace/system/python.h\"\n") out_file.write("#include \"python/py3compat.h\"\n") out_file.write("#include \"includes.h\"\n\n") # This is needed to avoid a missing prototype error from the C -- 2.42.1 From b3a546251e138ccada4d0300c09786bda84c2507 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 9 Nov 2023 17:16:17 +0100 Subject: [PATCH 3/5] third_party: Build pypamtest with -Wno-error=declaration-after-statement BUG: https://bugzilla.samba.org/show_bug.cgi?id=15513 Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett (cherry picked from commit c290052fd28bbfa5b885119f322cb0718073e507) --- buildtools/wafsamba/samba_autoconf.py | 3 +++ third_party/pam_wrapper/wscript | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/buildtools/wafsamba/samba_autoconf.py b/buildtools/wafsamba/samba_autoconf.py index 8541d003e2a..34fd5fab2c0 100644 --- a/buildtools/wafsamba/samba_autoconf.py +++ b/buildtools/wafsamba/samba_autoconf.py @@ -817,6 +817,9 @@ int main(void) { if CHECK_CFLAGS(conf, ["-Wno-error=array-bounds"]): conf.define('HAVE_WNO_ERROR_ARRAY_BOUNDS', 1) + if CHECK_CFLAGS(conf, ["-Wno-error=declaration-after-statement"]): + conf.define('HAVE_WNO_ERROR_DECLARATION_AFTER_STATEMENT', 1) + if not Options.options.disable_warnings_as_errors: conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Werror -Wno-error=deprecated-declarations', testflags=True) conf.ADD_NAMED_CFLAGS('PICKY_CFLAGS', '-Wno-error=tautological-compare', testflags=True) diff --git a/third_party/pam_wrapper/wscript b/third_party/pam_wrapper/wscript index 28d003d9fab..3ce89bbbc27 100644 --- a/third_party/pam_wrapper/wscript +++ b/third_party/pam_wrapper/wscript @@ -105,8 +105,13 @@ def build(bld): install=False, realname='pam_set_items.so') + pypamtest_cflags = '' + if bld.CONFIG_SET('HAVE_WNO_ERROR_DECLARATION_AFTER_STATEMENT'): + pypamtest_cflags = '-Wno-error=declaration-after-statement' + # Can be used to write pam tests in python bld.SAMBA_PYTHON('pypamtest', source='python/pypamtest.c', + cflags_end=pypamtest_cflags, deps='libpamtest', install=False) -- 2.42.1 From af73d200e4d481cf70d4f2cc94763b09f0083413 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 9 Nov 2023 21:43:54 +0100 Subject: [PATCH 4/5] python:tests: Fix assertEquals which doesn't exist in Python 3.12 BUG: https://bugzilla.samba.org/show_bug.cgi?id=15513 Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett (cherry picked from commit 362b0d69b16c5bbcd0ff7dd7ba12e1ac037a6b3d) --- python/samba/tests/gpo.py | 204 +++++++++++++++++++------------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/python/samba/tests/gpo.py b/python/samba/tests/gpo.py index f5e25e71041..e4b75cc62a4 100644 --- a/python/samba/tests/gpo.py +++ b/python/samba/tests/gpo.py @@ -5314,7 +5314,7 @@ class GPOTests(tests.TestCase): with TemporaryDirectory(sections[keyname]) as dname: ext.process_group_policy([], gpos, dname) scripts = os.listdir(dname) - self.assertEquals(len(scripts), 1, + self.assertEqual(len(scripts), 1, 'The %s script was not created' % keyname.decode()) out, _ = Popen([os.path.join(dname, scripts[0])], stdout=PIPE).communicate() self.assertIn(b'hello world', out, @@ -5322,14 +5322,14 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) del_gpos = get_deleted_gpos_list(gp_db, []) ext.process_group_policy(del_gpos, []) - self.assertEquals(len(os.listdir(dname)), 0, - 'Unapply failed to cleanup scripts') + self.assertEqual(len(os.listdir(dname)), 0, + 'Unapply failed to cleanup scripts') # Unstage the Registry.pol file unstage_file(reg_pol) @@ -5369,21 +5369,21 @@ class GPOTests(tests.TestCase): with TemporaryDirectory() as dname: ext.process_group_policy([], gpos, dname) sudoers = os.listdir(dname) - self.assertEquals(len(sudoers), 1, 'The sudoer file was not created') + self.assertEqual(len(sudoers), 1, 'The sudoer file was not created') self.assertIn(e.data, open(os.path.join(dname, sudoers[0]), 'r').read(), 'The sudoers entry was not applied') # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) del_gpos = get_deleted_gpos_list(gp_db, []) ext.process_group_policy(del_gpos, []) - self.assertEquals(len(os.listdir(dname)), 0, - 'Unapply failed to cleanup scripts') + self.assertEqual(len(os.listdir(dname)), 0, + 'Unapply failed to cleanup scripts') # Unstage the Registry.pol file unstage_file(reg_pol) @@ -5464,7 +5464,7 @@ class GPOTests(tests.TestCase): with TemporaryDirectory() as dname: ext.process_group_policy([], gpos, dname) sudoers = os.listdir(dname) - self.assertEquals(len(sudoers), 3, 'The sudoer file was not created') + self.assertEqual(len(sudoers), 3, 'The sudoer file was not created') output = open(os.path.join(dname, sudoers[0]), 'r').read() + \ open(os.path.join(dname, sudoers[1]), 'r').read() + \ open(os.path.join(dname, sudoers[2]), 'r').read() @@ -5477,14 +5477,14 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) del_gpos = get_deleted_gpos_list(gp_db, []) ext.process_group_policy(del_gpos, []) - self.assertEquals(len(os.listdir(dname)), 0, - 'Unapply failed to cleanup scripts') + self.assertEqual(len(os.listdir(dname)), 0, + 'Unapply failed to cleanup scripts') # Unstage the Registry.pol file unstage_file(manifest) @@ -5510,8 +5510,8 @@ class GPOTests(tests.TestCase): self.fail('Failed to parse utf-16') self.assertIn('Kerberos Policy', inf_conf.keys(), 'Kerberos Policy was not read from the file') - self.assertEquals(inf_conf.get('Kerberos Policy', 'MaxTicketAge'), - '99', 'MaxTicketAge was not read from the file') + self.assertEqual(inf_conf.get('Kerberos Policy', 'MaxTicketAge'), + '99', 'MaxTicketAge was not read from the file') with NamedTemporaryFile() as f: with codecs.open(f.name, 'w', 'utf-8') as w: @@ -5519,8 +5519,8 @@ class GPOTests(tests.TestCase): inf_conf = ext.read(f.name) self.assertIn('Kerberos Policy', inf_conf.keys(), 'Kerberos Policy was not read from the file') - self.assertEquals(inf_conf.get('Kerberos Policy', 'MaxTicketAge'), - '99', 'MaxTicketAge was not read from the file') + self.assertEqual(inf_conf.get('Kerberos Policy', 'MaxTicketAge'), + '99', 'MaxTicketAge was not read from the file') def test_rsop(self): cache_dir = self.lp.get('cache directory') @@ -5584,8 +5584,8 @@ class GPOTests(tests.TestCase): ext = ext(self.lp, machine_creds, machine_creds.get_username(), store) ret = ext.rsop(g) - self.assertEquals(len(ret.keys()), 1, - 'A single policy should have been displayed') + self.assertEqual(len(ret.keys()), 1, + 'A single policy should have been displayed') # Check the Security Extension if type(ext) == gp_krb_ext: @@ -5593,8 +5593,8 @@ class GPOTests(tests.TestCase): 'Kerberos Policy not found') self.assertIn('MaxTicketAge', ret['Kerberos Policy'], 'MaxTicketAge setting not found') - self.assertEquals(ret['Kerberos Policy']['MaxTicketAge'], '99', - 'MaxTicketAge was not set to 99') + self.assertEqual(ret['Kerberos Policy']['MaxTicketAge'], '99', + 'MaxTicketAge was not set to 99') # Check the Scripts Extension elif type(ext) == gp_scripts_ext: self.assertIn('Daily Scripts', ret.keys(), @@ -5614,18 +5614,18 @@ class GPOTests(tests.TestCase): 'apply group policies was not applied') self.assertIn(e3.valuename, ret['smb.conf'], 'apply group policies was not applied') - self.assertEquals(ret['smb.conf'][e3.valuename], e3.data, - 'apply group policies was not set') + self.assertEqual(ret['smb.conf'][e3.valuename], e3.data, + 'apply group policies was not set') # Check the Messages Extension elif type(ext) == gp_msgs_ext: self.assertIn('/etc/issue', ret, 'Login Prompt Message not applied') - self.assertEquals(ret['/etc/issue'], e4.data, - 'Login Prompt Message not set') + self.assertEqual(ret['/etc/issue'], e4.data, + 'Login Prompt Message not set') # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') unstage_file(gpofile % g.name) unstage_file(reg_pol % g.name) @@ -5762,17 +5762,17 @@ class GPOTests(tests.TestCase): lp = LoadParm(f.name) template_homedir = lp.get('template homedir') - self.assertEquals(template_homedir, '/home/samba/%D/%U', + self.assertEqual(template_homedir, '/home/samba/%D/%U', 'template homedir was not applied') apply_group_policies = lp.get('apply group policies') self.assertTrue(apply_group_policies, 'apply group policies was not applied') ldap_timeout = lp.get('ldap timeout') - self.assertEquals(ldap_timeout, 9999, 'ldap timeout was not applied') + self.assertEqual(ldap_timeout, 9999, 'ldap timeout was not applied') # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -5782,13 +5782,13 @@ class GPOTests(tests.TestCase): lp = LoadParm(f.name) template_homedir = lp.get('template homedir') - self.assertEquals(template_homedir, self.lp.get('template homedir'), + self.assertEqual(template_homedir, self.lp.get('template homedir'), 'template homedir was not unapplied') apply_group_policies = lp.get('apply group policies') - self.assertEquals(apply_group_policies, self.lp.get('apply group policies'), + self.assertEqual(apply_group_policies, self.lp.get('apply group policies'), 'apply group policies was not unapplied') ldap_timeout = lp.get('ldap timeout') - self.assertEquals(ldap_timeout, self.lp.get('ldap timeout'), + self.assertEqual(ldap_timeout, self.lp.get('ldap timeout'), 'ldap timeout was not unapplied') # Unstage the Registry.pol file @@ -5837,16 +5837,16 @@ class GPOTests(tests.TestCase): self.assertTrue(os.path.exists(motd_file), 'Message of the day file not created') data = open(motd_file, 'r').read() - self.assertEquals(data, e1.data, 'Message of the day not applied') + self.assertEqual(data, e1.data, 'Message of the day not applied') issue_file = os.path.join(dname, 'issue') self.assertTrue(os.path.exists(issue_file), 'Login Prompt Message file not created') data = open(issue_file, 'r').read() - self.assertEquals(data, e2.data, 'Login Prompt Message not applied') + self.assertEqual(data, e2.data, 'Login Prompt Message not applied') # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Unapply policy, and ensure the test files are removed gp_db = store.get_gplog(machine_creds.get_username()) @@ -5931,7 +5931,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Unstage the manifest.xml file unstage_file(manifest) @@ -5999,9 +5999,9 @@ class GPOTests(tests.TestCase): ext.process_group_policy([], gpos) self.assertTrue(os.path.exists(target.text), 'The target file does not exist') - self.assertEquals(os.stat(target.text).st_mode & 0o777, 0o755, + self.assertEqual(os.stat(target.text).st_mode & 0o777, 0o755, 'The target file permissions are incorrect') - self.assertEquals(open(target.text).read(), source_data, + self.assertEqual(open(target.text).read(), source_data, 'The target file contents are incorrect') # Remove policy @@ -6021,7 +6021,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Unstage the manifest and source files unstage_file(manifest) @@ -6077,14 +6077,14 @@ class GPOTests(tests.TestCase): with TemporaryDirectory() as dname: ext.process_group_policy([], gpos, dname) conf = os.listdir(dname) - self.assertEquals(len(conf), 1, 'The conf file was not created') + self.assertEqual(len(conf), 1, 'The conf file was not created') gp_cfg = os.path.join(dname, conf[0]) self.assertIn(data, open(gp_cfg, 'r').read(), 'The sshd_config entry was not applied') # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -6142,7 +6142,7 @@ class GPOTests(tests.TestCase): with TemporaryDirectory() as dname: ext.process_group_policy([], gpos, dname) files = os.listdir(dname) - self.assertEquals(len(files), 1, + self.assertEqual(len(files), 1, 'The target script was not created') entry = '@reboot %s %s %s' % (run_as.text, test_script, parameters.text) @@ -6155,8 +6155,8 @@ class GPOTests(tests.TestCase): del_gpos = get_deleted_gpos_list(gp_db, []) ext.process_group_policy(del_gpos, []) files = os.listdir(dname) - self.assertEquals(len(files), 0, - 'The target script was not removed') + self.assertEqual(len(files), 0, + 'The target script was not removed') # Test rsop g = [g for g in gpos if g.name == guid][0] @@ -6166,7 +6166,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Unstage the manifest.xml and script files unstage_file(manifest) @@ -6188,18 +6188,18 @@ class GPOTests(tests.TestCase): ext.process_group_policy([], gpos, dname) files = os.listdir(dname) - self.assertEquals(len(files), 1, - 'The test file was not created') - self.assertEquals(files[0], os.path.basename(test_file), - 'The test file was not created') + self.assertEqual(len(files), 1, + 'The test file was not created') + self.assertEqual(files[0], os.path.basename(test_file), + 'The test file was not created') # Unlink the test file and ensure that processing # policy again does not recreate it. os.unlink(test_file) ext.process_group_policy([], gpos, dname) files = os.listdir(dname) - self.assertEquals(len(files), 0, - 'The test file should not have been created') + self.assertEqual(len(files), 0, + 'The test file should not have been created') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -6216,7 +6216,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Unstage the manifest.xml and script files unstage_file(manifest) @@ -6245,8 +6245,8 @@ class GPOTests(tests.TestCase): except Exception as e: self.fail(str(e)) files = os.listdir(dname) - self.assertEquals(len(files), 1, - 'The target script was not created') + self.assertEqual(len(files), 1, + 'The target script was not created') entry = '@reboot %s %s' % (run_as.text, test_script) self.assertIn(entry, open(os.path.join(dname, files[0]), 'r').read(), @@ -6257,8 +6257,8 @@ class GPOTests(tests.TestCase): del_gpos = get_deleted_gpos_list(gp_db, []) ext.process_group_policy(del_gpos, []) files = os.listdir(dname) - self.assertEquals(len(files), 0, - 'The target script was not removed') + self.assertEqual(len(files), 0, + 'The target script was not removed') # Test rsop g = [g for g in gpos if g.name == guid][0] @@ -6268,7 +6268,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Unstage the manifest.xml and script files unstage_file(manifest) @@ -6309,12 +6309,12 @@ class GPOTests(tests.TestCase): # Process all gpos, with temp output directory with NamedTemporaryFile() as f: ext.process_group_policy([], gpos, f.name) - self.assertEquals(open(f.name, 'r').read(), text.text, - 'The motd was not applied') + self.assertEqual(open(f.name, 'r').read(), text.text, + 'The motd was not applied') # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -6361,12 +6361,12 @@ class GPOTests(tests.TestCase): # Process all gpos, with temp output directory with NamedTemporaryFile() as f: ext.process_group_policy([], gpos, f.name) - self.assertEquals(open(f.name, 'r').read(), text.text, - 'The issue was not applied') + self.assertEqual(open(f.name, 'r').read(), text.text, + 'The issue was not applied') # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -6489,7 +6489,7 @@ class GPOTests(tests.TestCase): ext.process_group_policy([], gpos, dname) conf = os.listdir(dname) # There will be 2 files, the policy file and the deny file - self.assertEquals(len(conf), 2, 'The conf file was not created') + self.assertEqual(len(conf), 2, 'The conf file was not created') # Ignore the DENY_ALL conf file gp_cfg = os.path.join(dname, [c for c in conf if '_gp_DENY_ALL.conf' not in c][0]) @@ -6504,7 +6504,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -6550,7 +6550,7 @@ class GPOTests(tests.TestCase): 'Local db dir not created') def db_check(name, data, count=1): db = glob(os.path.join(local_db, '*-%s' % name)) - self.assertEquals(len(db), count, '%s not created' % name) + self.assertEqual(len(db), count, '%s not created' % name) file_contents = ConfigParser() file_contents.read(db) for key in data.keys(): @@ -6564,14 +6564,14 @@ class GPOTests(tests.TestCase): def del_db_check(name): db = glob(os.path.join(local_db, '*-%s' % name)) - self.assertEquals(len(db), 0, '%s not deleted' % name) + self.assertEqual(len(db), 0, '%s not deleted' % name) locks = os.path.join(local_db, 'locks') self.assertTrue(os.path.isdir(local_db), 'Locks dir not created') def lock_check(name, items, count=1): lock = glob(os.path.join(locks, '*%s' % name)) - self.assertEquals(len(lock), count, - '%s lock not created' % name) + self.assertEqual(len(lock), count, + '%s lock not created' % name) file_contents = [] for i in range(count): file_contents.extend(open(lock[i], 'r').read().split('\n')) @@ -6581,7 +6581,7 @@ class GPOTests(tests.TestCase): def del_lock_check(name): lock = glob(os.path.join(locks, '*%s' % name)) - self.assertEquals(len(lock), 0, '%s lock not deleted' % name) + self.assertEqual(len(lock), 0, '%s lock not deleted' % name) # Check the user profile user_profile = os.path.join(dname, 'etc/dconf/profile/user') @@ -6652,23 +6652,23 @@ class GPOTests(tests.TestCase): actions = os.path.join(dname, 'etc/share/polkit-1/actions') udisk2 = glob(os.path.join(actions, 'org.freedesktop.[u|U][d|D]isks2.policy')) - self.assertEquals(len(udisk2), 1, 'udisk2 policy not created') + self.assertEqual(len(udisk2), 1, 'udisk2 policy not created') udisk2_tree = etree.fromstring(open(udisk2[0], 'r').read()) actions = udisk2_tree.findall('action') md = 'org.freedesktop.udisks2.modify-device' action = [a for a in actions if a.attrib['id'] == md] - self.assertEquals(len(action), 1, 'modify-device not found') + self.assertEqual(len(action), 1, 'modify-device not found') defaults = action[0].find('defaults') self.assertTrue(defaults is not None, 'modify-device defaults not found') allow_any = defaults.find('allow_any').text - self.assertEquals(allow_any, 'no', + self.assertEqual(allow_any, 'no', 'modify-device allow_any not set to no') allow_inactive = defaults.find('allow_inactive').text - self.assertEquals(allow_inactive, 'no', + self.assertEqual(allow_inactive, 'no', 'modify-device allow_inactive not set to no') allow_active = defaults.find('allow_active').text - self.assertEquals(allow_active, 'yes', + self.assertEqual(allow_active, 'yes', 'modify-device allow_active not set to yes') # Disable printing @@ -6708,7 +6708,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -6729,7 +6729,7 @@ class GPOTests(tests.TestCase): actions = os.path.join(dname, 'etc/share/polkit-1/actions') udisk2 = glob(os.path.join(actions, 'org.freedesktop.[u|U][d|D]isks2.policy')) - self.assertEquals(len(udisk2), 0, 'udisk2 policy not deleted') + self.assertEqual(len(udisk2), 0, 'udisk2 policy not deleted') del_db_check('printing') del_lock_check('printing') del_db_check('filesaving') @@ -6817,7 +6817,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -6891,7 +6891,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(os.environ.get('DC_USERNAME')) @@ -6951,7 +6951,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Unapply the policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -6995,15 +6995,15 @@ class GPOTests(tests.TestCase): ext.process_group_policy([], gpos, dname) managed = os.path.join(dname, 'managed') managed_files = os.listdir(managed) - self.assertEquals(len(managed_files), 1, - 'Chromium policies are missing') + self.assertEqual(len(managed_files), 1, + 'Chromium policies are missing') managed_file = os.path.join(managed, managed_files[0]) with open(managed_file, 'r') as r: managed_data = json.load(r) recommended = os.path.join(dname, 'recommended') recommended_files = os.listdir(recommended) - self.assertEquals(len(recommended_files), 1, - 'Chromium policies are missing') + self.assertEqual(len(recommended_files), 1, + 'Chromium policies are missing') recommended_file = os.path.join(recommended, recommended_files[0]) with open(recommended_file, 'r') as r: recommended_data = json.load(r) @@ -7037,16 +7037,16 @@ class GPOTests(tests.TestCase): ext.process_group_policy([], gpos, dname) managed_files = os.listdir(managed) - self.assertEquals(len(managed_files), 1, - 'Number of Chromium policies is incorrect') + self.assertEqual(len(managed_files), 1, + 'Number of Chromium policies is incorrect') omanaged_file = managed_file managed_file = os.path.join(managed, managed_files[0]) self.assertNotEqual(omanaged_file, managed_file, 'The managed Chromium file did not change') recommended_files = os.listdir(recommended) - self.assertEquals(len(recommended_files), 1, - 'Number of Chromium policies is incorrect') + self.assertEqual(len(recommended_files), 1, + 'Number of Chromium policies is incorrect') orecommended_file = recommended_file recommended_file = os.path.join(recommended, recommended_files[0]) self.assertNotEqual(orecommended_file, recommended_file, @@ -7057,7 +7057,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Unapply the policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -7127,14 +7127,14 @@ class GPOTests(tests.TestCase): out, err = p.communicate() rule = b'rule family=ipv4 source address=172.25.1.7 ' + \ b'service name=ftp reject' - self.assertEquals(rule, out.strip(), 'Failed to set rich rule') + self.assertEqual(rule, out.strip(), 'Failed to set rich rule') # Verify RSOP does not fail ext.rsop([g for g in gpos if g.name == guid][0]) # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Unapply the policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -7238,7 +7238,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) @@ -7305,7 +7305,7 @@ class GPOTests(tests.TestCase): with TemporaryDirectory() as dname: ext.process_group_policy([], gpos, dname) sudoers = os.listdir(dname) - self.assertEquals(len(sudoers), 1, 'The sudoer file was not created') + self.assertEqual(len(sudoers), 1, 'The sudoer file was not created') sudoers_file = os.path.join(dname, sudoers[0]) self.assertIn(e2.data, open(sudoers_file, 'r').read(), 'The sudoers entry was not applied') @@ -7314,22 +7314,22 @@ class GPOTests(tests.TestCase): os.unlink(sudoers_file) ext.process_group_policy([], gpos, dname) sudoers = os.listdir(dname) - self.assertEquals(len(sudoers), 1, - 'The sudoer file was not recreated') + self.assertEqual(len(sudoers), 1, + 'The sudoer file was not recreated') sudoers_file = os.path.join(dname, sudoers[0]) self.assertIn(e2.data, open(sudoers_file, 'r').read(), 'The sudoers entry was not reapplied') # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) del_gpos = get_deleted_gpos_list(gp_db, []) ext.process_group_policy(del_gpos, []) - self.assertEquals(len(os.listdir(dname)), 0, - 'Unapply failed to cleanup scripts') + self.assertEqual(len(os.listdir(dname)), 0, + 'Unapply failed to cleanup scripts') # Unstage the Registry.pol file unstage_file(reg_pol) @@ -7370,21 +7370,21 @@ class GPOTests(tests.TestCase): with TemporaryDirectory() as dname: ext.process_group_policy([], gpos, dname) cron_entries = os.listdir(dname) - self.assertEquals(len(cron_entries), 1, 'Cron entry not created') + self.assertEqual(len(cron_entries), 1, 'Cron entry not created') fname = os.path.join(dname, cron_entries[0]) data = open(fname, 'rb').read() self.assertIn(get_bytes(e.data), data, 'Cron entry is missing') # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(machine_creds.get_username()) del_gpos = get_deleted_gpos_list(gp_db, []) ext.process_group_policy(del_gpos, []) - self.assertEquals(len(os.listdir(dname)), 0, - 'Unapply failed to cleanup script') + self.assertEqual(len(os.listdir(dname)), 0, + 'Unapply failed to cleanup script') # Unstage the Registry.pol file unstage_file(reg_pol) @@ -7432,7 +7432,7 @@ class GPOTests(tests.TestCase): # Check that a call to gpupdate --rsop also succeeds ret = rsop(self.lp) - self.assertEquals(ret, 0, 'gpupdate --rsop failed!') + self.assertEqual(ret, 0, 'gpupdate --rsop failed!') # Remove policy gp_db = store.get_gplog(os.environ.get('DC_USERNAME')) -- 2.42.1 From 9a86c6a0ff08d1d547d08a69edc43077f577a827 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 9 Nov 2023 22:27:03 +0100 Subject: [PATCH 5/5] python:tests: SHA1 is no longer supported by cryptography module See https://github.com/pyca/cryptography/issues/8213#issuecomment-1419060001 BUG: https://bugzilla.samba.org/show_bug.cgi?id=15513 Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett (cherry picked from commit 938afb8b28973b0065cc3509b70ebe3f6986de47) --- python/samba/tests/krb5/pkinit_tests.py | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/python/samba/tests/krb5/pkinit_tests.py b/python/samba/tests/krb5/pkinit_tests.py index 15166499adc..3d47c799f86 100755 --- a/python/samba/tests/krb5/pkinit_tests.py +++ b/python/samba/tests/krb5/pkinit_tests.py @@ -79,28 +79,6 @@ class PkInitTests(KDCBaseTest): account_type=account_type, opts={'upn': f'{{account}}.{realm}@{realm}'}) - def test_pkinit(self): - """Test public-key PK-INIT.""" - client_creds = self._get_creds() - target_creds = self.get_service_creds() - - self._pkinit_req(client_creds, target_creds) - - def test_pkinit_dh(self): - """Test Diffie-Hellman PK-INIT.""" - client_creds = self._get_creds() - target_creds = self.get_service_creds() - - self._pkinit_req(client_creds, target_creds, - using_pkinit=PkInit.DIFFIE_HELLMAN) - - def test_pkinit_win2k(self): - """Test public-key Windows 2000 PK-INIT.""" - client_creds = self._get_creds() - target_creds = self.get_service_creds() - - self._pkinit_req(client_creds, target_creds, win2k_variant=True) - def test_pkinit_no_des3(self): """Test public-key PK-INIT without specifying the DES3 encryption type. It should fail.""" @@ -740,7 +718,7 @@ class PkInitTests(KDCBaseTest): ca_private_key, certificate_signature=None): if certificate_signature is None: - certificate_signature = hashes.SHA1 + certificate_signature = hashes.SHA256 user_name = creds.get_username() -- 2.42.1