summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2011-07-28 15:15:26 -0400
committerStephen Gallagher <sgallagh@redhat.com>2011-07-29 10:18:34 -0400
commitc57b2068ff45f1d184d034e62c48a6bdd9d6eed7 (patch)
treec8ecb0cf3a0b91e3a0a2a7ac8f973aee9f4ef01f
parentb00113f8d5fcaf405364dfb5bc28a8076b6c10bd (diff)
downloadsssd_unused-c57b2068ff45f1d184d034e62c48a6bdd9d6eed7.tar.gz
sssd_unused-c57b2068ff45f1d184d034e62c48a6bdd9d6eed7.tar.xz
sssd_unused-c57b2068ff45f1d184d034e62c48a6bdd9d6eed7.zip
sss_client: avoid leaking file descriptors
If a pam or nss module is dlcolse()d and unloaded we were leaking the file descriptor used to communicate to sssd in the process. Make sure the fucntion used to close the socket file descriptor is called on dlclose() Silence autoconf 2.28 warnings (Patch by Jakub Hrozek)
-rw-r--r--configure.ac12
-rw-r--r--src/sss_client/common.c3
2 files changed, 15 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 84b83eb1..c0b7f8f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -170,6 +170,18 @@ AC_CHECK_HEADERS([sys/inotify.h])
AC_CHECK_HEADERS([sasl/sasl.h],,AC_MSG_ERROR([Could not find SASL headers]))
+AC_CACHE_CHECK([whether compiler supports __attribute__((destructor))],
+ sss_client_cv_attribute_destructor,
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_SOURCE([__attribute__((destructor)) static void cleanup(void) { }])],
+ sss_client_cv_attribute_destructor=yes)
+ ])
+
+if test x"$sss_client_cv_attribute_destructor" = xyes ; then
+ AC_DEFINE(HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR, 1,
+ [whether compiler supports __attribute__((destructor))])
+fi
+
PKG_CHECK_MODULES([CHECK], [check >= 0.9.5], [have_check=1], [have_check=])
if test x$have_check = x; then
AC_MSG_WARN([Without the 'CHECK' libraries, you will be unable to run all tests in the 'make check' suite])
diff --git a/src/sss_client/common.c b/src/sss_client/common.c
index c17629a9..5f6af418 100644
--- a/src/sss_client/common.c
+++ b/src/sss_client/common.c
@@ -55,6 +55,9 @@
int sss_cli_sd = -1; /* the sss client socket descriptor */
struct stat sss_cli_sb; /* the sss client stat buffer */
+#if HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR
+__attribute__((destructor))
+#endif
static void sss_cli_close_socket(void)
{
if (sss_cli_sd != -1) {