[SCM] NSS Wrapper Repository - branch master updated
Michael Adam
obnox at samba.org
Thu Dec 17 08:07:14 UTC 2015
The branch, master has been updated
via 03018f8 Bump version to 1.1.2
via a93a07d tests: Add reload test for the hosts file
via 6406714 nwrap: Fix segfaults while reloading hosts file
from 581a412 tests: Add the same alias again
https://git.samba.org/?p=nss_wrapper.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 03018f8b035cd2b627298cf47290f2563f821e76
Author: Andreas Schneider <asn at samba.org>
Date: Thu Dec 17 09:00:30 2015 +0100
Bump version to 1.1.2
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit a93a07d5e122b50dcec2e8fe7dbee022e5d5d301
Author: Andreas Schneider <asn at samba.org>
Date: Thu Dec 17 08:56:05 2015 +0100
tests: Add reload test for the hosts file
With this valgrind should show issues if the hash table is not
recreated.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
commit 64067145b4e013d4223bf17011984988bddbe43e
Author: Andreas Schneider <asn at samba.org>
Date: Thu Dec 17 08:46:33 2015 +0100
nwrap: Fix segfaults while reloading hosts file
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Michael Adam <obnox at samba.org>
-----------------------------------------------------------------------
Summary of changes:
CMakeLists.txt | 4 ++--
ChangeLog | 5 +++++
src/nss_wrapper.c | 13 ++++++++++++
tests/test_getaddrinfo.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 71 insertions(+), 2 deletions(-)
Changeset truncated at 500 lines:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a1ed061..8b352cb 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 "1")
-set(APPLICATION_VERSION_PATCH "1")
+set(APPLICATION_VERSION_PATCH "2")
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
@@ -19,7 +19,7 @@ set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
# Increment AGE. Set REVISION to 0
# If the source code was changed, but there were no interface changes:
# Increment REVISION.
-set(LIBRARY_VERSION "0.2.1")
+set(LIBRARY_VERSION "0.2.2")
set(LIBRARY_SOVERSION "0")
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
diff --git a/ChangeLog b/ChangeLog
index 139d4fa..8d55fc3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,11 @@
ChangeLog
==========
+version 1.1.2 (released 2015-12-17)
+ * Fixed segfault while reloading hosts file
+ * Fixed issue where are not fault tolerant if an alias has already
+ been added
+
version 1.1.1 (released 2015-11-23)
* Fixed nss_wrapper build on Solaris
diff --git a/src/nss_wrapper.c b/src/nss_wrapper.c
index f48b9cc..c4f1b33 100644
--- a/src/nss_wrapper.c
+++ b/src/nss_wrapper.c
@@ -2890,6 +2890,7 @@ static void nwrap_he_unload(struct nwrap_cache *nwrap)
struct nwrap_entdata *ed;
struct nwrap_entlist *el;
size_t i;
+ int rc;
nwrap_vector_foreach (ed, nwrap_he->entries, i)
{
@@ -2915,6 +2916,18 @@ static void nwrap_he_unload(struct nwrap_cache *nwrap)
nwrap_he->num = 0;
nwrap_he->idx = 0;
+
+ /*
+ * If we unload the file, the pointers in the hash table point to
+ * invalid memory. So we need to destroy the hash table and recreate
+ * it.
+ */
+ hdestroy();
+ rc = hcreate(max_hostents);
+ if (rc == 0) {
+ NWRAP_LOG(NWRAP_LOG_ERROR, "Failed to initialize hash table");
+ exit(-1);
+ }
}
diff --git a/tests/test_getaddrinfo.c b/tests/test_getaddrinfo.c
index b200275..438ea12 100644
--- a/tests/test_getaddrinfo.c
+++ b/tests/test_getaddrinfo.c
@@ -5,8 +5,10 @@
#include <setjmp.h>
#include <cmocka.h>
+#include <errno.h>
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
@@ -83,6 +85,54 @@ static void test_nwrap_getaddrinfo(void **state)
freeaddrinfo(res);
}
+/*
+ * The purpose of this test is to verify that reloading of the hosts
+ * file (triggered by a timestamp change) correctly frees and re-creates
+ * the internal data structures, so we do not end up using invalid memory.
+ */
+static void test_nwrap_getaddrinfo_reload(void **state)
+{
+ struct addrinfo hints;
+ struct addrinfo *res = NULL;
+ const char *env;
+ char touch_cmd[1024];
+ int rc;
+
+ (void) state; /* unused */
+
+ /* IPv4 */
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
+ hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */
+ hints.ai_flags = AI_PASSIVE; /* For wildcard IP address */
+ hints.ai_protocol = 0; /* Any protocol */
+ hints.ai_canonname = NULL;
+ hints.ai_addr = NULL;
+ hints.ai_next = NULL;
+
+ rc = getaddrinfo("127.0.0.11", NULL, &hints, &res);
+ assert_int_equal(rc, 0);
+ assert_non_null(res);
+
+ freeaddrinfo(res);
+ res = NULL;
+
+ env = getenv("NSS_WRAPPER_HOSTS");
+ assert_non_null(env);
+
+ snprintf(touch_cmd, sizeof(touch_cmd), "touch %s", env);
+
+ rc = system(touch_cmd);
+ assert_return_code(rc, errno);
+
+ rc = getaddrinfo("127.0.0.11", NULL, &hints, &res);
+ assert_int_equal(rc, 0);
+ assert_non_null(res);
+
+
+ freeaddrinfo(res);
+}
+
static void test_nwrap_getaddrinfo_samba(void **state)
{
struct addrinfo hints;
@@ -661,6 +711,7 @@ int main(void) {
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_nwrap_getaddrinfo),
+ cmocka_unit_test(test_nwrap_getaddrinfo_reload),
cmocka_unit_test(test_nwrap_getaddrinfo_any),
cmocka_unit_test(test_nwrap_getaddrinfo_local),
cmocka_unit_test(test_nwrap_getaddrinfo_name),
--
NSS Wrapper Repository
More information about the samba-cvs
mailing list