[SCM] pam wrapper repository - branch master updated

Andreas Schneider asn at samba.org
Tue Jul 23 07:44:30 UTC 2024


The branch, master has been updated
       via  0d3b5be Bump version to 1.1.6
       via  ce61f64 pwrap: Use mkdtemp() for config dir if we have pam_start_confdir()
       via  c40e906 cmake: Move to new FindPython module
       via  5098caa gitlab-ci: Adapt to latest changes
       via  43330b5 Add clang-format
       via  2e96ed9 Add editorconfig
      from  9f0cccf pwrap: Fix PAM_WRAPPER_DISABLE_DEEPBIND environment variable

https://git.samba.org/?p=pam_wrapper.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 0d3b5be59a5f6ade0f29ef1a325d32a48ae8726e
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jul 23 09:41:30 2024 +0200

    Bump version to 1.1.6
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit ce61f64d899249adac520e9048cb8690f2af97e5
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jul 23 07:49:50 2024 +0200

    pwrap: Use mkdtemp() for config dir if we have pam_start_confdir()
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit c40e906bb68de9258b78fe07502e17d4a9e8b8ba
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jul 23 09:03:07 2024 +0200

    cmake: Move to new FindPython module
    
    The old one is deprecated.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 5098caa591bcf53ecf6e12f93aaef63bc3cf1638
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jul 23 07:52:50 2024 +0200

    gitlab-ci: Adapt to latest changes
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 43330b55acf98c80033d7b7715cf51e5f8706af3
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jul 23 07:45:13 2024 +0200

    Add clang-format
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 2e96ed91cc4e4ec863bd0193278fe28ad8c3cefe
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Jul 23 07:42:55 2024 +0200

    Add editorconfig
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 .clang-format                     | 33 +++++++++++++++++++
 .editorconfig                     | 23 ++++++++++++++
 .gitlab-ci.yml                    | 20 ------------
 CHANGELOG                         |  5 +++
 CMakeLists.txt                    |  4 +--
 src/pam_wrapper.c                 | 67 +++++++++++----------------------------
 src/python/python3/CMakeLists.txt | 47 +++++++--------------------
 tests/CMakeLists.txt              |  5 +--
 8 files changed, 96 insertions(+), 108 deletions(-)
 create mode 100644 .clang-format
 create mode 100644 .editorconfig


Changeset truncated at 500 lines:

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..c4c12b9
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,33 @@
+# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
+AlignAfterOpenBracket: Align
+AlignEscapedNewlines: Left
+AllowAllArgumentsOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortFunctionsOnASingleLine: Empty
+AllowShortIfStatementsOnASingleLine: false
+AlwaysBreakAfterReturnType: None
+BasedOnStyle: LLVM
+BinPackArguments: false
+BinPackParameters: false
+BraceWrapping:
+    AfterEnum: false
+    AfterFunction: true
+    AfterStruct: false
+    AfterUnion: false
+    AfterExternBlock: true
+    BeforeElse: false
+    BeforeWhile: false
+    AfterControlStatement: MultiLine
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Custom
+ColumnLimit: 80
+ContinuationIndentWidth: 8
+IndentCaseLabels: false
+IndentGotoLabels: false
+IndentWidth: 8
+PenaltyBreakAssignment: 200
+PenaltyBreakBeforeFirstCallParameter: 100
+PenaltyReturnTypeOnItsOwnLine: 1000
+SortIncludes: false
+UseTab: true
+WhitespaceSensitiveMacros: ['DEBUG']
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..bbe1bd5
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,23 @@
+root = true
+
+[*]
+charset = utf-8
+max_line_length = 80
+end_of_line = lf
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.{c,h}]
+indent_style = tab
+indent_size = 8
+tab_width = 8
+
+[*.cmake]
+indent_style = space
+indent_size = 4
+tab_width = 4
+
+[CMake*]
+indent_style = space
+indent_size = 4
+tab_width = 4
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c205528..6b13e8a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -21,8 +21,6 @@ centos7/x86_64:
       -DPICKY_DEVELOPER=ON
       -DUNIT_TESTING=ON .. &&
       make -j$(nproc) && ctest --output-on-failure
-  tags:
-    - shared
   except:
     - tags
   artifacts:
@@ -41,8 +39,6 @@ fedora/x86_64:
       -DPICKY_DEVELOPER=ON
       -DUNIT_TESTING=ON .. &&
       make -j$(nproc) && ctest --output-on-failure && make install
-  tags:
-    - shared
   except:
     - tags
   artifacts:
@@ -60,8 +56,6 @@ fedora/address-sanitizer:
       -DPICKY_DEVELOPER=ON
       -DUNIT_TESTING=ON .. &&
       make -j$(nproc) && ctest --output-on-failure
-  tags:
-    - shared
   except:
     - tags
   artifacts:
@@ -79,8 +73,6 @@ fedora/undefined-sanitizer:
       -DPICKY_DEVELOPER=ON
       -DUNIT_TESTING=ON ..
       && make -j$(nproc) && ctest --output-on-failure
-  tags:
-    - shared
   except:
     - tags
   artifacts:
@@ -113,8 +105,6 @@ fedora/csbuild:
       --git-commit-range $CI_COMMIT_RANGE
       --color
       --print-current --print-fixed
-  tags:
-    - shared
   except:
     - tags
   artifacts:
@@ -157,8 +147,6 @@ tumbleweed/x86_64/gcc:
       -DPICKY_DEVELOPER=ON
       -DUNIT_TESTING=ON .. &&
       make -j$(nproc) && ctest --output-on-failure
-  tags:
-    - shared
   except:
     - tags
   artifacts:
@@ -177,8 +165,6 @@ tumbleweed/x86_64/gcc7:
       -DPICKY_DEVELOPER=ON
       -DUNIT_TESTING=ON .. &&
       make -j$(nproc) && ctest --output-on-failure
-  tags:
-    - shared
   except:
     - tags
   artifacts:
@@ -199,8 +185,6 @@ tumbleweed/x86_64/clang:
       -DPICKY_DEVELOPER=OFF
       -DUNIT_TESTING=ON .. &&
       make -j$(nproc) && ctest --output-on-failure
-  tags:
-    - shared
   except:
     - tags
   artifacts:
@@ -223,8 +207,6 @@ tumbleweed/static-analysis:
       -DPICKY_DEVELOPER=OFF
       -DUNIT_TESTING=ON .. &&
       scan-build --status-bugs -o scan make -j$(nproc)
-  tags:
-    - shared
   except:
     - tags
   artifacts:
@@ -242,8 +224,6 @@ ubuntu/x86_64:
       -DPICKY_DEVELOPER=ON
       -DUNIT_TESTING=ON .. &&
       make -j$(nproc) && ctest --output-on-failure
-  tags:
-    - shared
   except:
     - tags
   artifacts:
diff --git a/CHANGELOG b/CHANGELOG
index 5e2da7c..1b1e48e 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,11 @@
 ChangeLog
 ==========
 
+version 1.1.6 (released 2023-07-23)
+  * Improve config dir creation if we have pam_start_confdir()
+  * Fixed PAM_WRAPPER_DISABLE_DEEPBIND
+  * Directly fail if we can't create the config dir
+
 version 1.1.5 (released 2023-08-08)
   * Fixed building with Python 3.12
   * Removed Python 2 support
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7b01937..e2f548b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,7 +11,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 include(DefineCMakeDefaults)
 include(DefineCompilerFlags)
 
-project(pam_wrapper VERSION 1.1.5 LANGUAGES C)
+project(pam_wrapper VERSION 1.1.6 LANGUAGES C)
 
 # global needed variables
 set(APPLICATION_NAME ${PROJECT_NAME})
@@ -25,7 +25,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 #     Increment PATCH.
 set(LIBRARY_VERSION_MAJOR 0)
 set(LIBRARY_VERSION_MINOR 0)
-set(LIBRARY_VERSION_PATCH 8)
+set(LIBRARY_VERSION_PATCH 9)
 set(LIBRARY_VERSION "${LIBRARY_VERSION_MAJOR}.${LIBRARY_VERSION_MINOR}.${LIBRARY_VERSION_PATCH}")
 set(LIBRARY_SOVERSION ${LIBRARY_VERSION_MAJOR})
 
diff --git a/src/pam_wrapper.c b/src/pam_wrapper.c
index c47b564..606fb66 100644
--- a/src/pam_wrapper.c
+++ b/src/pam_wrapper.c
@@ -749,6 +749,7 @@ static int copy_confdir(const char *src)
 
 static int p_rmdirs(const char *path);
 
+#ifndef HAVE_PAM_START_CONFDIR
 static void pwrap_clean_stale_dirs(const char *dir)
 {
 	size_t len = strlen(dir);
@@ -816,20 +817,18 @@ static void pwrap_clean_stale_dirs(const char *dir)
 
 	return;
 }
+#endif /* HAVE_PAM_START_CONFDIR */
 
 #ifdef HAVE_PAM_START_CONFDIR
 static void pwrap_init(void)
 {
-	char tmp_config_dir[] = "/tmp/pam.X";
-	size_t len = strlen(tmp_config_dir);
+	const char *tmpdir = getenv("TMPDIR");
+	char *tmp_config_dir = NULL;
 	const char *env;
-	struct stat sb;
 	int rc;
-	unsigned i;
 	ssize_t ret;
 	FILE *pidfile;
 	char pidfile_path[1024] = { 0 };
-	char letter;
 
 	if (!pam_wrapper_enabled()) {
 		return;
@@ -839,63 +838,33 @@ static void pwrap_init(void)
 		return;
 	}
 
-	/*
-	 * The name is selected to match/replace /etc/pam.d
-	 * We start from a random alphanum trying letters until
-	 * an available directory is found.
-	 */
-	letter = 48 + (getpid() % 70);
-	for (i = 0; i < 127; i++) {
-		if (isalpha(letter) || isdigit(letter)) {
-			tmp_config_dir[len - 1] = letter;
-
-			rc = lstat(tmp_config_dir, &sb);
-			if (rc == 0) {
-				PWRAP_LOG(PWRAP_LOG_TRACE,
-					  "Check if pam_wrapper dir %s is a "
-					  "stale directory",
-					  tmp_config_dir);
-				pwrap_clean_stale_dirs(tmp_config_dir);
-			} else if (rc < 0) {
-				if (errno != ENOENT) {
-					continue;
-				}
-				break; /* found */
-			}
-		}
+	PWRAP_LOG(PWRAP_LOG_DEBUG, "Initialize pam_wrapper");
 
-		letter++;
-		letter %= 127;
+	if (tmpdir == NULL || strlen(tmpdir) == 0 ||
+	    strlen(tmpdir) >= PATH_MAX - 12)
+	{
+		tmpdir = "/tmp";
 	}
 
-	if (i == 127) {
-		PWRAP_LOG(PWRAP_LOG_ERROR,
-			  "Failed to find a possible path to create "
-			  "pam_wrapper config dir: %s",
-			  tmp_config_dir);
+	rc = asprintf(&pwrap.config_dir, "%s/pam.XXXXXX", tmpdir);
+	if (rc <= 0) {
+		PWRAP_LOG(PWRAP_LOG_ERROR, "Failed to create path");
 		exit(1);
 	}
 
-	PWRAP_LOG(PWRAP_LOG_DEBUG, "Initialize pam_wrapper");
-
-	pwrap.config_dir = strdup(tmp_config_dir);
-	if (pwrap.config_dir == NULL) {
+	tmp_config_dir = mkdtemp(pwrap.config_dir);
+	if (tmp_config_dir == NULL) {
 		PWRAP_LOG(PWRAP_LOG_ERROR,
-			  "No memory");
+			  "Failed to create temporary directory based "
+			  "on template: %s",
+			  pwrap.config_dir);
 		exit(1);
 	}
+
 	PWRAP_LOG(PWRAP_LOG_TRACE,
 		  "pam_wrapper config dir: %s",
 		  tmp_config_dir);
 
-	rc = mkdir(pwrap.config_dir, 0755);
-	if (rc != 0) {
-		PWRAP_LOG(PWRAP_LOG_ERROR,
-			  "Failed to create pam_wrapper config dir: %s - %s",
-			  tmp_config_dir, strerror(errno));
-		exit(1);
-	}
-
 	/* Create file with the PID of the the process */
 	ret = snprintf(pidfile_path, sizeof(pidfile_path),
 		       "%s/pid", pwrap.config_dir);
diff --git a/src/python/python3/CMakeLists.txt b/src/python/python3/CMakeLists.txt
index 7890d53..4e8b967 100644
--- a/src/python/python3/CMakeLists.txt
+++ b/src/python/python3/CMakeLists.txt
@@ -1,45 +1,22 @@
 project(python3-pamtest C)
 
-if (NOT PYTHON3_LIBRARY)
-    unset(PYTHON_EXECUTABLE CACHE)
-    unset(PYTHON_INCLUDE_DIR CACHE)
-    unset(PYTHON_LIBRARY CACHE)
-    unset(PYTHON_SITELIB CACHE)
-    unset(PYTHONLIBS_FOUND CACHE)
-    unset(PYTHONLIBS_VERSION_STRING CACHE)
+find_package(Python 3.6 COMPONENTS Development)
 
-    find_package(PythonLibs 3)
-    find_package(PythonInterp 3)
-    find_package(PythonSiteLibs 3)
-
-    if (PYTHONLIBS_FOUND)
-        set(PYTHON3_LIBRARY ${PYTHON_LIBRARY})
-        set(PYTHON3_INCLUDE_DIR ${PYTHON_INCLUDE_DIR})
-        set(PYTHON3_SITELIB ${PYTHON_SITELIB})
-        set(PYTHON3_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE FILEPATH "PYTHON3_EXECUTABLE")
-    endif()
-
-    unset(PYTHON_EXECUTABLE CACHE)
-    unset(PYTHON_INCLUDE_DIR CACHE)
-    unset(PYTHON_LIBRARY CACHE)
-    unset(PYTHON_SITELIB CACHE)
-    unset(PYTHONLIBS_FOUND CACHE)
-    unset(PYTHONLIBS_VERSION_STRING CACHE)
-endif()
-
-if (PYTHON3_INCLUDE_DIR AND PYTHON3_LIBRARY AND PYTHON3_SITELIB)
-    include_directories(${CMAKE_BINARY_DIR})
-    include_directories(${pam_wrapper-headers_DIR})
-    include_directories(${PYTHON3_INCLUDE_DIR})
-
-    python_add_module(python3-pamtest ${pypamtest_SOURCE_DIR}/pypamtest.c)
-    target_link_libraries(python3-pamtest pamtest::pamtest ${PYTHON3_LIBRARY})
+if (Python_Development_FOUND)
+    add_library(python3-pamtest
+                MODULE ${pypamtest_SOURCE_DIR}/pypamtest.c)
     target_compile_options(python3-pamtest
                            PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
-    set_target_properties(python3-pamtest PROPERTIES OUTPUT_NAME "pypamtest")
+    target_include_directories(python3-pamtest
+                               PRIVATE
+                                   ${pam_wrapper_BINARY_DIR}
+                                   ${pam_wrapper-headers_DIR})
+    target_link_libraries(python3-pamtest PRIVATE pamtest::pamtest Python::Python)
+    set_property(TARGET python3-pamtest PROPERTY PREFIX "")
+    set_property(TARGET python3-pamtest PROPERTY OUTPUT_NAME "pypamtest")
 
     install(TARGETS
                 python3-pamtest
             DESTINATION
-                ${CMAKE_INSTALL_PREFIX}/${PYTHON3_SITELIB})
+                ${CMAKE_INSTALL_PREFIX}/${Python_SITELIB})
 endif()
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 26f2da2..b3503eb 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -94,11 +94,12 @@ if (CMAKE_BUILD_TYPE)
 endif()
 
 if (RUN_PYTHON_TESTS)
-    if (PYTHON3_EXECUTABLE)
+    find_package(Python 3.6 COMPONENTS Interpreter)
+    if (Python_Interpreter_FOUND)
         add_test(NAME
                     py3pamtest_test
                  COMMAND
-                    ${PYTHON3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pypamtest_test.py)
+                    ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/pypamtest_test.py)
 
         add_cmocka_test_environment(py3pamtest_test)
     endif()


-- 
pam wrapper repository



More information about the samba-cvs mailing list