[SCM] UID Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Fri Jul 14 13:41:03 UTC 2017


The branch, master has been updated
       via  7386dc6 Bump version to 1.2.3
       via  4cbcf1f uwrap: Do an early return if log level doesn't match
       via  c59500e uwrap: Always enable logging
       via  a337fc9 uwrap: Add log message before exit
       via  3a43ef7 uwrap: Add mamximum for groups we can handle while forking
       via  c71fb12 uwrap: Do not leak groups_str
      from  27e9f76 Bump version to 1.2.2

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


- Log -----------------------------------------------------------------
commit 7386dc6dfa2e4b78e1616acbdff88efc8e089dd7
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jul 14 10:39:53 2017 +0200

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

commit 4cbcf1fd1746bbc2e933401628a2cb71c0f1c45d
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jul 14 10:34:48 2017 +0200

    uwrap: Do an early return if log level doesn't match
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit c59500ee54aa95ebbc43c43ada06eeab41267cd7
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jul 14 10:33:46 2017 +0200

    uwrap: Always enable logging
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit a337fc93269d50a265df1f568a99db490865702f
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jul 14 10:31:05 2017 +0200

    uwrap: Add log message before exit
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit 3a43ef7330fc84e61c8545709e36440affd26950
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jul 14 09:05:26 2017 +0200

    uwrap: Add mamximum for groups we can handle while forking
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

commit c71fb1219b9d08f7faf27a15977163bb7c86c7a0
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Jul 14 09:07:19 2017 +0200

    uwrap: Do not leak groups_str
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>

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

Summary of changes:
 CMakeLists.txt    |  2 +-
 ChangeLog         |  7 +++++-
 src/uid_wrapper.c | 71 +++++++++++++++++++++++++++++++++----------------------
 3 files changed, 50 insertions(+), 30 deletions(-)


Changeset truncated at 500 lines:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4dc42f2..97f0e30 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ set(APPLICATION_NAME ${PROJECT_NAME})
 
 set(APPLICATION_VERSION_MAJOR "1")
 set(APPLICATION_VERSION_MINOR "2")
-set(APPLICATION_VERSION_PATCH "2")
+set(APPLICATION_VERSION_PATCH "3")
 
 set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
 
diff --git a/ChangeLog b/ChangeLog
index cc02554..33a879e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
 ChangeLog
 ==========
 
-version 1.2.2 (released 2107-07-13)
+version 1.2.3 (released 2017-07-14)
+  * Logging is always turned on now
+  * Fixed a memory leak
+  * Limited number of groups during fork+exec
+
+version 1.2.2 (released 2017-07-13)
   * Added support for fork'ed and then exec'ed processes
   * Added support for Alpha
 
diff --git a/src/uid_wrapper.c b/src/uid_wrapper.c
index 6e39eb6..0e9be96 100644
--- a/src/uid_wrapper.c
+++ b/src/uid_wrapper.c
@@ -133,9 +133,6 @@ enum uwrap_dbglvl_e {
 	UWRAP_LOG_TRACE
 };
 
-#ifdef NDEBUG
-# define UWRAP_LOG(...)
-#else /* NDEBUG */
 static void uwrap_log(enum uwrap_dbglvl_e dbglvl, const char *function, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
 # define UWRAP_LOG(dbglvl, ...) uwrap_log((dbglvl), __func__, __VA_ARGS__)
 
@@ -145,42 +142,43 @@ static void uwrap_log(enum uwrap_dbglvl_e dbglvl, const char *function, const ch
 	va_list va;
 	const char *d;
 	unsigned int lvl = 0;
+	const char *prefix = "UWRAP";
 
 	d = getenv("UID_WRAPPER_DEBUGLEVEL");
 	if (d != NULL) {
 		lvl = atoi(d);
 	}
 
+	if (lvl < dbglvl) {
+		return;
+	}
+
 	va_start(va, format);
 	vsnprintf(buffer, sizeof(buffer), format, va);
 	va_end(va);
 
-	if (lvl >= dbglvl) {
-		const char *prefix = "UWRAP";
-		switch (dbglvl) {
-			case UWRAP_LOG_ERROR:
-				prefix = "UWRAP_ERROR";
-				break;
-			case UWRAP_LOG_WARN:
-				prefix = "UWRAP_WARN";
-				break;
-			case UWRAP_LOG_DEBUG:
-				prefix = "UWRAP_DEBUG";
-				break;
-			case UWRAP_LOG_TRACE:
-				prefix = "UWRAP_TRACE";
-				break;
-		}
-
-		fprintf(stderr,
-			"%s(%d) - %s: %s\n",
-			prefix,
-			(int)getpid(),
-			function,
-			buffer);
+	switch (dbglvl) {
+		case UWRAP_LOG_ERROR:
+			prefix = "UWRAP_ERROR";
+			break;
+		case UWRAP_LOG_WARN:
+			prefix = "UWRAP_WARN";
+			break;
+		case UWRAP_LOG_DEBUG:
+			prefix = "UWRAP_DEBUG";
+			break;
+		case UWRAP_LOG_TRACE:
+			prefix = "UWRAP_TRACE";
+			break;
 	}
+
+	fprintf(stderr,
+		"%s(%d) - %s: %s\n",
+		prefix,
+		(int)getpid(),
+		function,
+		buffer);
 }
-#endif /* NDEBUG */
 
 /*****************
  * LIBC
@@ -816,6 +814,7 @@ int pthread_create(pthread_t *thread,
  *********************************************************/
 
 #define GROUP_STRING_SIZE 16384
+#define GROUP_MAX_COUNT (GROUP_STRING_SIZE / (10 + 1))
 
 /**
  * This function exports all the IDs of the current user so if
@@ -849,6 +848,15 @@ static void uwrap_export_ids(struct uwrap_thread *id)
 	snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->sgid);
 	setenv("UID_WRAPPER_INITIAL_SGID", unsigned_str, 1);
 
+	if (id->ngroups > GROUP_MAX_COUNT) {
+		UWRAP_LOG(UWRAP_LOG_ERROR,
+			  "ERROR: Number of groups (%u) exceeds maximum value "
+			  "uid_wrapper will handle (%u).",
+			  id->ngroups,
+			  GROUP_MAX_COUNT);
+		exit(-1);
+	}
+
 	/* GROUPS */
 	snprintf(unsigned_str, sizeof(unsigned_str), "%u", id->ngroups);
 	setenv("UID_WRAPPER_INITIAL_GROUPS_COUNT", unsigned_str, 1);
@@ -1003,7 +1011,7 @@ static void uwrap_init_env(struct uwrap_thread *id)
 		unsetenv("UID_WRAPPER_INITIAL_GROUPS_COUNT");
 	}
 
-	if (ngroups > 0) {
+	if (ngroups > 0 && ngroups < GROUP_MAX_COUNT) {
 		int i = 0;
 
 		id->ngroups = 0;
@@ -1034,9 +1042,16 @@ static void uwrap_init_env(struct uwrap_thread *id)
 
 				p = strtok_r(NULL, ",", &saveptr);
 			}
+			SAFE_FREE(groups_str);
 		}
 
 		if (i != ngroups) {
+			UWRAP_LOG(UWRAP_LOG_ERROR,
+				  "ERROR: The number of groups (%u) passed, "
+				  "does not the number of groups (%u) we "
+				  "parsed",
+				  ngroups,
+				  i);
 			exit(-1);
 		}
 


-- 
UID Wrapper Repository



More information about the samba-cvs mailing list