diff options
author | Jan Synacek <jsynacek@redhat.com> | 2013-09-06 13:40:08 +0200 |
---|---|---|
committer | Jan Synacek <jsynacek@redhat.com> | 2013-09-09 08:58:51 +0200 |
commit | 5abd893c3dcd5836d9c006b47a55fd5f9ce032f1 (patch) | |
tree | 9632ce46c2b314bed79c1938bc64801775dc0ba9 /src/logicalfile | |
parent | e3db726720562b67a07f70dec858ef9a6f946d97 (diff) | |
download | openlmi-providers-5abd893c3dcd5836d9c006b47a55fd5f9ce032f1.tar.gz openlmi-providers-5abd893c3dcd5836d9c006b47a55fd5f9ce032f1.tar.xz openlmi-providers-5abd893c3dcd5836d9c006b47a55fd5f9ce032f1.zip |
logicalfile: protect libselinux calls with a mutex
Diffstat (limited to 'src/logicalfile')
-rw-r--r-- | src/logicalfile/LMI_UnixFileProvider.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/logicalfile/LMI_UnixFileProvider.c b/src/logicalfile/LMI_UnixFileProvider.c index 82a6479..5da5bb0 100644 --- a/src/logicalfile/LMI_UnixFileProvider.c +++ b/src/logicalfile/LMI_UnixFileProvider.c @@ -27,6 +27,9 @@ static const CMPIBroker* _cb = NULL; #ifdef LOGICALFILE_SELINUX #include <selinux/selinux.h> #include <selinux/label.h> +#include <pthread.h> + +static pthread_mutex_t selinux_mutex; static struct selabel_handle *_selabel_hnd = NULL; static struct selabel_handle *get_selabel_handle() @@ -35,6 +38,7 @@ static struct selabel_handle *get_selabel_handle() const unsigned int CHECK_PERIOD = 20; /* seconds */ const char *err = "gettimeofday() failed, selinux handle might not get re-initialized"; + pthread_mutex_lock(&selinux_mutex); if (_selabel_hnd == NULL) { _selabel_hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0); if (gettimeofday(×tamp, NULL) < 0) { @@ -54,6 +58,7 @@ static struct selabel_handle *get_selabel_handle() } } } + pthread_mutex_unlock(&selinux_mutex); return _selabel_hnd; } @@ -62,6 +67,9 @@ static struct selabel_handle *get_selabel_handle() static void LMI_UnixFileInitialize() { lmi_init_logging(LMI_UnixFile_ClassName, _cb); +#ifdef LOGICALFILE_SELINUX + pthread_mutex_init(&selinux_mutex, NULL); +#endif } static CMPIStatus LMI_UnixFileCleanup( @@ -73,6 +81,7 @@ static CMPIStatus LMI_UnixFileCleanup( if (_selabel_hnd != NULL) { selabel_close(_selabel_hnd); } + pthread_mutex_destroy(&selinux_mutex); #endif CMReturn(CMPI_RC_OK); } |