diff -Nru nss-wrapper-1.1.1/ChangeLog nss-wrapper-1.1.2/ChangeLog --- nss-wrapper-1.1.1/ChangeLog 2015-11-24 09:30:20.000000000 +0000 +++ nss-wrapper-1.1.2/ChangeLog 2015-12-17 08:00:25.000000000 +0000 @@ -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 -Nru nss-wrapper-1.1.1/CMakeLists.txt nss-wrapper-1.1.2/CMakeLists.txt --- nss-wrapper-1.1.1/CMakeLists.txt 2015-11-24 09:30:20.000000000 +0000 +++ nss-wrapper-1.1.2/CMakeLists.txt 2015-12-17 07:57:54.000000000 +0000 @@ -8,7 +8,7 @@ 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 @@ # 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 -Nru nss-wrapper-1.1.1/debian/changelog nss-wrapper-1.1.2/debian/changelog --- nss-wrapper-1.1.1/debian/changelog 2015-12-09 21:25:10.000000000 +0000 +++ nss-wrapper-1.1.2/debian/changelog 2016-02-22 06:22:46.000000000 +0000 @@ -1,3 +1,9 @@ +nss-wrapper (1.1.2-1) unstable; urgency=medium + + * New upstream release. + + -- Timo Aaltonen Mon, 22 Feb 2016 08:22:42 +0200 + nss-wrapper (1.1.1-1) unstable; urgency=medium * New upstream release. diff -Nru nss-wrapper-1.1.1/debian/patches/no-soname.diff nss-wrapper-1.1.2/debian/patches/no-soname.diff --- nss-wrapper-1.1.1/debian/patches/no-soname.diff 2015-12-09 21:17:23.000000000 +0000 +++ nss-wrapper-1.1.2/debian/patches/no-soname.diff 2016-02-22 06:26:42.000000000 +0000 @@ -21,20 +21,14 @@ install( --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -12,16 +12,6 @@ set(APPLICATION_VERSION_PATCH "1") - - set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}") - --# SOVERSION scheme: CURRENT.AGE.REVISION --# If there was an incompatible interface change: --# Increment CURRENT. Set AGE and REVISION to 0 --# If there was a compatible interface change: --# 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") +@@ -19,8 +19,8 @@ set(APPLICATION_VERSION "${APPLICATION_V + # 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.2") -set(LIBRARY_SOVERSION "0") -- ++#set(LIBRARY_VERSION "0.2.2") ++#set(LIBRARY_SOVERSION "0") + # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked set(CMAKE_MODULE_PATH - ${CMAKE_SOURCE_DIR}/cmake/Modules diff -Nru nss-wrapper-1.1.1/src/nss_wrapper.c nss-wrapper-1.1.2/src/nss_wrapper.c --- nss-wrapper-1.1.1/src/nss_wrapper.c 2015-11-24 09:30:20.000000000 +0000 +++ nss-wrapper-1.1.2/src/nss_wrapper.c 2015-12-17 08:14:13.000000000 +0000 @@ -2622,12 +2622,14 @@ for (cursor = el; cursor->next != NULL; cursor = cursor->next) { if (cursor->ed == ed) { - return false; + /* The entry already exists in this list. */ + return true; } } if (cursor->ed == ed) { - return false; + /* The entry already exists in this list. */ + return true; } el_new = nwrap_entlist_init(ed); @@ -2888,6 +2890,7 @@ struct nwrap_entdata *ed; struct nwrap_entlist *el; size_t i; + int rc; nwrap_vector_foreach (ed, nwrap_he->entries, i) { @@ -2913,6 +2916,18 @@ 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 -Nru nss-wrapper-1.1.1/tests/hosts.in nss-wrapper-1.1.2/tests/hosts.in --- nss-wrapper-1.1.1/tests/hosts.in 2015-11-13 12:17:02.000000000 +0000 +++ nss-wrapper-1.1.2/tests/hosts.in 2015-12-17 07:30:50.000000000 +0000 @@ -5,7 +5,7 @@ ::13 beteigeuze.galaxy.site beteigeuze mail 127.0.0.14 krikkit.galaxy.site ::14 krikkit.galaxy.site -127.1.1.1 pumpkin.bunny.net +127.1.1.1 pumpkin.bunny.net pumpkin.bunny.net 127.0.0.66 pumpkin.bunny.net 2666::22 pumpkin.bunny.net DEAD:BEEF:1:2:3::4 pumpkin.bunny.net diff -Nru nss-wrapper-1.1.1/tests/test_getaddrinfo.c nss-wrapper-1.1.2/tests/test_getaddrinfo.c --- nss-wrapper-1.1.1/tests/test_getaddrinfo.c 2015-11-19 08:39:46.000000000 +0000 +++ nss-wrapper-1.1.2/tests/test_getaddrinfo.c 2015-12-17 08:14:14.000000000 +0000 @@ -5,8 +5,10 @@ #include #include +#include #include #include +#include #include #include @@ -83,6 +85,54 @@ 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 @@ 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),