Skip to content

Commit

Permalink
libselinux: Close old selabel handle when setting a new one
Browse files Browse the repository at this point in the history
In selinux_restorecon_set_sehandle(), close the old selabel handle
(if it exists) before setting the new one.

Signed-off-by: James Carter <[email protected]>
Acked-by: Petr Lautrbach <[email protected]>
  • Loading branch information
jwcart2 committed Jan 28, 2025
1 parent fb8c507 commit 45fdf23
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions libselinux/src/selinux_restorecon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,10 @@ void selinux_restorecon_set_sehandle(struct selabel_handle *hndl)
unsigned char *fc_digest;
size_t num_specfiles, fc_digest_len;

if (fc_sehandle) {
selabel_close(fc_sehandle);
}

fc_sehandle = hndl;
if (!fc_sehandle)
return;
Expand Down

0 comments on commit 45fdf23

Please sign in to comment.