nwrap: Don't fail if we want to add an existing entry
[obnox/samba/samba-obnox.git] / lib / nss_wrapper / nss_wrapper.c
index a6ca81637ffe3dda29b361a6855a5da37f5afe3c..f48b9cc7e8d65d1f992a014d8dad80fc2ed833a8 100644 (file)
@@ -2622,12 +2622,14 @@ static bool nwrap_ed_inventarize_add_to_existing(struct nwrap_entdata *const ed,
        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);
@@ -5551,6 +5553,7 @@ void nwrap_destructor(void)
                nwrap_pw_global.num = 0;
        }
 
+#if defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM)
        if (nwrap_sp_global.cache != NULL) {
                struct nwrap_cache *c = nwrap_sp_global.cache;
 
@@ -5562,6 +5565,7 @@ void nwrap_destructor(void)
 
                nwrap_sp_global.num = 0;
        }
+#endif /* defined(HAVE_SHADOW_H) && defined(HAVE_GETSPNAM) */
 
        if (nwrap_he_global.cache != NULL) {
                struct nwrap_cache *c = nwrap_he_global.cache;
@@ -5575,6 +5579,11 @@ void nwrap_destructor(void)
                nwrap_he_global.num = 0;
        }
 
+       free(user_addrlist.items);
+#ifdef HAVE_GETHOSTBYNAME2
+       free(user_addrlist2.items);
+#endif
+
        hdestroy();
        NWRAP_UNLOCK_ALL;
 }