mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
libdm: internal is_selinux_enabled wrapper
There is no point to call this external function more then once. (As suggested by selinux developer)
This commit is contained in:
parent
ee89ac7b88
commit
8346f106b4
@ -1,5 +1,6 @@
|
||||
Version 1.02.85 -
|
||||
===================================
|
||||
Wrap is_selinux_enabled() to be called just once.
|
||||
Use correctly signed 64b constant when working with raid volumes.
|
||||
Exit dmeventd with pidfile cleanup instead of raising SIGKILL on DIE request.
|
||||
Add new DM_EVENT_GET_PARAMETERS request to dmeventd protocol.
|
||||
|
@ -868,12 +868,27 @@ static int _selabel_lookup(const char *path, mode_t mode,
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SELINUX
|
||||
static int _is_selinux_enabled(void)
|
||||
{
|
||||
static int _tested = 0;
|
||||
static int _enabled;
|
||||
|
||||
if (!_tested) {
|
||||
_tested = 1;
|
||||
_enabled = is_selinux_enabled();
|
||||
}
|
||||
|
||||
return _enabled;
|
||||
}
|
||||
#endif
|
||||
|
||||
int dm_prepare_selinux_context(const char *path, mode_t mode)
|
||||
{
|
||||
#ifdef HAVE_SELINUX
|
||||
security_context_t scontext = NULL;
|
||||
|
||||
if (is_selinux_enabled() <= 0)
|
||||
if (_is_selinux_enabled() <= 0)
|
||||
return 1;
|
||||
|
||||
if (path) {
|
||||
@ -901,7 +916,7 @@ int dm_set_selinux_context(const char *path, mode_t mode)
|
||||
#ifdef HAVE_SELINUX
|
||||
security_context_t scontext = NULL;
|
||||
|
||||
if (is_selinux_enabled() <= 0)
|
||||
if (_is_selinux_enabled() <= 0)
|
||||
return 1;
|
||||
|
||||
if (!_selabel_lookup(path, mode, &scontext))
|
||||
|
Loading…
Reference in New Issue
Block a user