summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Smalley <sds@tycho.nsa.gov>2014-07-07 19:51:05 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-07-07 19:51:05 +0000
commit3946f9119bf4eadfcfb17bd15661515328cbbc86 (patch)
tree51a46dde77a644a71e555be19a005e30e7867619
parenta6e100d3f5457fd2307fd160c31c64272c110447 (diff)
parentf8417037e919284b2b68be6e50e1f3784511f7f1 (diff)
downloadlibselinux-lollipop-dev.tar.gz
* commit 'f8417037e919284b2b68be6e50e1f3784511f7f1': Do not try to set restorecon_last on /sys entries.
-rw-r--r--src/android.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/android.c b/src/android.c
index 74d777f..6eeefec 100644
--- a/src/android.c
+++ b/src/android.c
@@ -1174,6 +1174,9 @@ err:
goto out;
}
+#define SYS_PATH "/sys"
+#define SYS_PREFIX SYS_PATH "/"
+
static int selinux_android_restorecon_common(const char* pathname,
const char *seinfo,
uid_t uid,
@@ -1184,7 +1187,7 @@ static int selinux_android_restorecon_common(const char* pathname,
bool recurse = (flags & SELINUX_ANDROID_RESTORECON_RECURSE) ? true : false;
bool force = (flags & SELINUX_ANDROID_RESTORECON_FORCE) ? true : false;
bool datadata = (flags & SELINUX_ANDROID_RESTORECON_DATADATA) ? true : false;
- bool issys = strcmp(pathname, "/sys") == 0 ? true : false;
+ bool issys = (!strcmp(pathname, SYS_PATH) || !strncmp(pathname, SYS_PREFIX, sizeof(SYS_PREFIX)-1)) ? true : false;
bool setrestoreconlast = true;
struct stat sb;
FTS *fts;
@@ -1220,6 +1223,10 @@ static int selinux_android_restorecon_common(const char* pathname,
!strncmp(pathname, DATA_USER_PREFIX, sizeof(DATA_USER_PREFIX)-1))
setrestoreconlast = false;
+ /* Also ignore on /sys since it is regenerated on each boot regardless. */
+ if (issys)
+ setrestoreconlast = false;
+
if (setrestoreconlast) {
size = getxattr(pathname, RESTORECON_LAST, xattr_value, sizeof fc_digest);
if (!force && size == sizeof fc_digest && memcmp(fc_digest, xattr_value, sizeof fc_digest) == 0) {