[SCM] Resolv Wrapper Repository - branch master updated

Andreas Schneider asn at samba.org
Thu Mar 19 16:15:10 UTC 2020


The branch, master has been updated
       via  3ab29a2 rwrap: improve logging messages by including getprogname()
       via  c42bd78 rwrap: fix warning where %s is always passed a NULL pointer in rwrap_create_fake_uri_rr()
       via  c8d013f ConfigureChecks.cmake: remove unused [__]res_send checks
      from  7382070 cmake: Update cmake defaults for out of source build

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


- Log -----------------------------------------------------------------
commit 3ab29a2b4bbe1217d37333a8881ca906e07a3f0d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Mar 11 17:12:22 2020 +0100

    rwrap: improve logging messages by including getprogname()
    
    This it basically the same as used in socket_wrapper.
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit c42bd7816325c460f07036101aab282049cd72df
Author: Stefan Metzmacher <metze at samba.org>
Date:   Thu Mar 19 09:54:48 2020 +0100

    rwrap: fix warning where %s is always passed a NULL pointer in rwrap_create_fake_uri_rr()
    
    This happens in Samba's gitlab pipeline on Fedora 30/31:
    
     [3203/4410] Compiling third_party/resolv_wrapper/resolv_wrapper.c
    ==> /builds/samba-team/devel/samba/samba-o3.stderr <==
    ../../third_party/resolv_wrapper/resolv_wrapper.c: In function ‘rwrap_create_fake_uri_rr’:
    ../../third_party/resolv_wrapper/resolv_wrapper.c:104:33: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
      104 | # define RWRAP_LOG(dbglvl, ...) rwrap_log((dbglvl), __func__, __VA_ARGS__)
          |                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../../third_party/resolv_wrapper/resolv_wrapper.c:340:3: note: in expansion of macro ‘RWRAP_LOG’
      340 |   RWRAP_LOG(RWRAP_LOG_ERROR,
          |   ^~~~~~~~~
    ../../third_party/resolv_wrapper/resolv_wrapper.c:341:28: note: format string is defined here
      341 |      "Malformed URI entry [%s]\n", value);
          |                            ^~
    cc1: all warnings being treated as errors
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit c8d013f3f484dc54748ca7132358ab8814d15c90
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Mar 18 15:06:36 2020 +0100

    ConfigureChecks.cmake: remove unused [__]res_send checks
    
    Signed-off-by: Stefan Metzmacher <metze at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 ConfigureChecks.cmake | 15 ++++++++++-----
 config.h.cmake        |  7 +++++++
 src/CMakeLists.txt    |  3 ++-
 src/resolv_wrapper.c  | 27 +++++++++++++++++++++++----
 4 files changed, 42 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 579d114..ae9437b 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -44,7 +44,17 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H)
 check_include_file(resolv.h HAVE_RESOLV_H)
 check_include_file(arpa/nameser.h HAVE_ARPA_NAMESER_H)
 
+# SYMBOLS
+set(CMAKE_REQUIRED_FLAGS -D_GNU_SOURCE)
+check_symbol_exists(program_invocation_short_name
+                    "errno.h"
+                    HAVE_PROGRAM_INVOCATION_SHORT_NAME)
+unset(CMAKE_REQUIRED_FLAGS)
+
 # FUNCTIONS
+check_function_exists(getprogname HAVE_GETPROGNAME)
+check_function_exists(getexecname HAVE_GETEXECNAME)
+
 find_library(RESOLV_LIRBRARY resolv)
 if (RESOLV_LIRBRARY)
     set(HAVE_LIBRESOLV TRUE)
@@ -55,11 +65,6 @@ else()
     message(STATUS "libresolv not found on ${CMAKE_SYSTEM_NAME}: Only dns faking will be available")
 endif()
 
-set(CMAKE_REQUIRED_LIBRARIES ${RESOLV_LIRBRARY})
-check_function_exists(res_send HAVE_RES_SEND)
-check_function_exists(__res_send HAVE___RES_SEND)
-unset(CMAKE_REQUIRED_LIBRARIES)
-
 set(CMAKE_REQUIRED_LIBRARIES ${RESOLV_LIRBRARY})
 check_function_exists(res_init HAVE_RES_INIT)
 check_function_exists(__res_init HAVE___RES_INIT)
diff --git a/config.h.cmake b/config.h.cmake
index 6ff75a6..0c2fa35 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -13,8 +13,15 @@
 #cmakedefine HAVE_RESOLV_H 1
 #cmakedefine HAVE_ARPA_NAMESER_H 1
 
+/**************************** SYMBOLS ****************************/
+
+#cmakedefine HAVE_PROGRAM_INVOCATION_SHORT_NAME 1
+
 /*************************** FUNCTIONS ***************************/
 
+#cmakedefine HAVE_GETPROGNAME 1
+#cmakedefine HAVE_GETEXECNAME 1
+
 #cmakedefine HAVE_RES_INIT 1
 #cmakedefine HAVE___RES_INIT 1
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 04d5395..42e9f42 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,7 +5,8 @@ target_link_libraries(resolv_wrapper ${RWRAP_REQUIRED_LIBRARIES})
 
 target_compile_options(resolv_wrapper
                        PRIVATE
-                           ${DEFAULT_C_COMPILE_FLAGS})
+                           ${DEFAULT_C_COMPILE_FLAGS}
+                          -D_GNU_SOURCE)
 target_include_directories(resolv_wrapper
                            PRIVATE ${CMAKE_BINARY_DIR})
 
diff --git a/src/resolv_wrapper.c b/src/resolv_wrapper.c
index bdf2c41..cbca248 100644
--- a/src/resolv_wrapper.c
+++ b/src/resolv_wrapper.c
@@ -83,6 +83,19 @@ enum rwrap_dbglvl_e {
 	RWRAP_LOG_TRACE
 };
 
+#ifndef HAVE_GETPROGNAME
+static const char *getprogname(void)
+{
+#if defined(HAVE_PROGRAM_INVOCATION_SHORT_NAME)
+	return program_invocation_short_name;
+#elif defined(HAVE_GETEXECNAME)
+	return getexecname();
+#else
+	return NULL;
+#endif /* HAVE_PROGRAM_INVOCATION_SHORT_NAME */
+}
+#endif /* HAVE_GETPROGNAME */
+
 static void rwrap_log(enum rwrap_dbglvl_e dbglvl, const char *func, const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
 # define RWRAP_LOG(dbglvl, ...) rwrap_log((dbglvl), __func__, __VA_ARGS__)
 
@@ -94,8 +107,8 @@ static void rwrap_log(enum rwrap_dbglvl_e dbglvl,
 	va_list va;
 	const char *d;
 	unsigned int lvl = 0;
-	int pid = getpid();
 	const char *prefix = NULL;
+	const char *progname = NULL;
 
 	d = getenv("RESOLV_WRAPPER_DEBUGLEVEL");
 	if (d != NULL) {
@@ -128,10 +141,16 @@ static void rwrap_log(enum rwrap_dbglvl_e dbglvl,
 			break;
 	}
 
+	progname = getprogname();
+	if (progname == NULL) {
+		progname = "<unknown>";
+	}
+
 	fprintf(stderr,
-		"%s(%d) - %s: %s\n",
+		"%s[%s (%u)] - %s: %s\n",
 		prefix,
-		pid,
+		progname,
+		(unsigned int)getpid(),
 		func,
 		buffer);
 }
@@ -309,7 +328,7 @@ static int rwrap_create_fake_uri_rr(const char *key,
 	NEXT_KEY(str_prio, str_weight);
 	if (uri == NULL) {
 		RWRAP_LOG(RWRAP_LOG_ERROR,
-			  "Malformed URI entry [%s]\n", value);
+			  "Malformed URI entry [<null>]\n");
 		return -1;
 	}
 


-- 
Resolv Wrapper Repository



More information about the samba-cvs mailing list