selinux_android_restorecon: log if selinux is disabled

Right now selinux_android_restorecon will silently succeed if selinux is
disabled which is confusing.

This change adds a log statement that should help with debugging issues
related to disabled selinux (see attached bug).

Bug: 284277137
Test: presubmit
Change-Id: I4ebc6400ac7188660658ef3cccfb7cbdc76c0f22
This commit is contained in:
Nikita Ioffe 2023-06-15 16:28:25 +01:00
parent e1c842285b
commit f8cf22eba8

View file

@ -633,8 +633,10 @@ static int selinux_android_restorecon_common(const char* pathname_orig,
ftsflags |= FTS_XDEV; ftsflags |= FTS_XDEV;
} }
if (is_selinux_enabled() <= 0) if (is_selinux_enabled() <= 0) {
selinux_log(SELINUX_WARNING, "SELinux: SELinux is disabled, skipping restorecon");
return 0; return 0;
}
__selinux_once(fc_once, file_context_init); __selinux_once(fc_once, file_context_init);