libwbclient: Fix a fd-leak at dlclose-time
authorVolker Lendecke <vl@samba.org>
Mon, 10 May 2010 10:05:01 +0000 (12:05 +0200)
committerKarolin Seeger <kseeger@samba.org>
Mon, 27 Sep 2010 19:29:03 +0000 (21:29 +0200)
__attribute__((destructor)) makes winbind_close_sock() being called at
dlclose() time.

Found while testing apache on Linux with mod_auth_pam.

Other platforms will have to find a different fix. One possibility would be to
always close the socket after each operation, but this badly sucks
performance-wise.

Fix bug #7684 (fd leak in libwbclient.so).
(cherry picked from commit f7e7fa50ec3aef60b72a34988825e314b7228c23)

nsswitch/wb_common.c

index d0dfcb8bbfb67326d82f2736b8110b3a9baf8688..b7fafc38ceea43a8548f8397914ffc51736ee0ff 100644 (file)
@@ -61,6 +61,9 @@ static void init_response(struct winbindd_response *response)
 
 /* Close established socket */
 
+#if HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR
+__attribute__((destructor))
+#endif
 void winbind_close_sock(void)
 {
        if (winbindd_fd != -1) {