diff options
author | Nick Kralevich <nnk@google.com> | 2014-07-07 20:05:16 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-07-07 20:05:16 +0000 |
commit | 4ef159a3c711650fce74ab13e3a883fab0598124 (patch) | |
tree | 1f5c4ac9cc8bbec15520074fd5aa064180a26afb /init | |
parent | 7df14ef339fcdd9103f2ef4e0eb66bf9c4ad3f5b (diff) | |
parent | 7367ecbc4839e3a608ab9b7742c659b58065209f (diff) | |
download | system_core-4ef159a3c711650fce74ab13e3a883fab0598124.zip system_core-4ef159a3c711650fce74ab13e3a883fab0598124.tar.gz system_core-4ef159a3c711650fce74ab13e3a883fab0598124.tar.bz2 |
am 7367ecbc: am 06023134: am 8022ce1e: Merge "ueventd fixup_sys_perms: fixup SELinux labels unconditionally"
* commit '7367ecbc4839e3a608ab9b7742c659b58065209f':
ueventd fixup_sys_perms: fixup SELinux labels unconditionally
Diffstat (limited to 'init')
-rw-r--r-- | init/devices.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/init/devices.c b/init/devices.c index 304888e..1012fee 100644 --- a/init/devices.c +++ b/init/devices.c @@ -134,11 +134,10 @@ void fixup_sys_perms(const char *upath) char buf[512]; struct listnode *node; struct perms_ *dp; - char *secontext; - /* upaths omit the "/sys" that paths in this list - * contain, so we add 4 when comparing... - */ + /* upaths omit the "/sys" that paths in this list + * contain, so we add 4 when comparing... + */ list_for_each(node, &sys_perms) { dp = &(node_to_item(node, struct perm_node, plist))->dp; if (dp->prefix) { @@ -153,20 +152,23 @@ void fixup_sys_perms(const char *upath) } if ((strlen(upath) + strlen(dp->attr) + 6) > sizeof(buf)) - return; + break; sprintf(buf,"/sys%s/%s", upath, dp->attr); INFO("fixup %s %d %d 0%o\n", buf, dp->uid, dp->gid, dp->perm); chown(buf, dp->uid, dp->gid); chmod(buf, dp->perm); - if (sehandle) { - secontext = NULL; - selabel_lookup(sehandle, &secontext, buf, 0); - if (secontext) { - setfilecon(buf, secontext); - freecon(secontext); - } - } + } + + // Now fixup SELinux file labels + int len = snprintf(buf, sizeof(buf), "/sys%s", upath); + if ((len < 0) || ((size_t) len >= sizeof(buf))) { + // Overflow + return; + } + if (access(buf, F_OK) == 0) { + INFO("restorecon_recursive: %s\n", buf); + restorecon_recursive(buf); } } |