Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Fedora 39 (Python 3.12) #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

socketpair
Copy link

No description provided.

@socketpair
Copy link
Author

where to add .patch:

--- old/src/Makefile
+++ new/src/Makefile
@@ -1,14 +1,13 @@
 all:	ctest pam_python3.so test-pam_python.pam
 
-WARNINGS=-Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wsign-compare -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Werror
-#WARNINGS=-Wunreachable-code 	# Gcc 4.1 .. 4.4 are too buggy to make this useful
+WARNINGS=-Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wsign-compare -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Werror -Wunreachable-code
 
 LIBDIR ?= /lib/security
 
 pam_python3.so: pam_python.c setup.py Makefile
 	@rm -f "$@"
 	@[ ! -e build -o build/lib.*/$@ -nt setup.py -a build/lib.*/$@ -nt Makefile ] || rm -r build
-	CFLAGS="$(WARNINGS)" python3 ./setup.py build
+	CFLAGS="$(CFLAGS) $(WARNINGS)" python3 ./setup.py build
 	@#CFLAGS="-O0 $(WARNINGS)" python3 ./setup.py build --debug
 	@#CFLAGS="-O0 $(WARNINGS)" Py_DEBUG=1 python3 ./setup.py build --debug
 	ln -sf build/lib.*/pam_python3.*.so pam_python3.so
--- old/src/pam_python.c
+++ new/src/pam_python.c
@@ -93,7 +93,32 @@
  */
 static void initialise_python(void)
 {
-#if	PY_MAJOR_VERSION*100 + PY_MINOR_VERSION >= 204
+#if	PY_MAJOR_VERSION*100 + PY_MINOR_VERSION >= 312
+  // https://docs.python.org/3/c-api/init_config.html
+  // PyPreConfig_InitIsolatedConfig(); /// ?????
+  PyConfig config;
+  PyConfig_InitIsolatedConfig(&config);
+  //PyConfig_InitPythonConfig(&config);
+  config.isolated = 1;
+  config.write_bytecode = 0;
+  config.use_environment = 0;
+  config.site_import = 1;
+  config.user_site_directory = 0;
+  config.install_signal_handlers = 0;
+  PyStatus status = Py_InitializeFromConfig(&config); // TODO: 0 (!)
+  if (PyStatus_Exception(status)) {
+     PyConfig_Clear(&config);
+     if (PyStatus_IsExit(status)) {
+        //return status.exitcode;
+     } else {
+        /* Display the error message and exit the process with
+        non-zero exit code */
+        Py_ExitStatusException(status);
+     }
+     abort();
+  }
+  PyConfig_Clear(&config);
+#elif	PY_MAJOR_VERSION*100 + PY_MINOR_VERSION >= 204
   Py_DontWriteBytecodeFlag = 1;
   Py_IgnoreEnvironmentFlag = 1;
   /* Py_IsolatedFlag = 1; 		Python3 only */

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant