matchpathcon: Close selabel handle in thread destructor.

This is necessary because the handle is thread-local.

Signed-off-by: Eamon Walsh <ewalsh@tycho.nsa.gov>
This commit is contained in:
Eamon Walsh 2010-12-02 19:30:06 -05:00
parent a00fd94a46
commit 569ce54985

View File

@ -45,7 +45,7 @@ static int add_array_elt(char *con)
return con_array_used++;
}
static void free_array_elts(void __attribute__((unused)) *unused)
static void free_array_elts(void)
{
con_array_size = con_array_used = 0;
free(con_array);
@ -266,7 +266,7 @@ void matchpathcon_filespec_destroy(void)
file_spec_t *fl, *tmp;
int h;
free_array_elts(NULL);
free_array_elts();
if (!fl_head)
return;
@ -285,9 +285,14 @@ void matchpathcon_filespec_destroy(void)
fl_head = NULL;
}
static void matchpathcon_thread_destructor(void __attribute__((unused)) *ptr)
{
matchpathcon_fini();
}
static void matchpathcon_init_once(void)
{
__selinux_key_create(&destructor_key, free_array_elts);
__selinux_key_create(&destructor_key, matchpathcon_thread_destructor);
}
int matchpathcon_init_prefix(const char *path, const char *subset)
@ -316,6 +321,8 @@ int matchpathcon_init(const char *path)
void matchpathcon_fini(void)
{
free_array_elts();
if (hnd) {
selabel_close(hnd);
hnd = NULL;