diff options
author | Nick Kralevich <nnk@google.com> | 2013-09-03 16:43:01 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-09-03 16:43:01 -0700 |
commit | f487e07bce49735235b91bf5ee79b6987ff80188 (patch) | |
tree | 36c44fb5395ca484ec0f647bfb92a30ec6f24d0a | |
parent | 49382f12f2e8278a02019d78482df00bb7f7fad7 (diff) | |
parent | 531328400ed6ce513f9bb4d9d772f02affeeaa26 (diff) | |
download | system_core-f487e07bce49735235b91bf5ee79b6987ff80188.zip system_core-f487e07bce49735235b91bf5ee79b6987ff80188.tar.gz system_core-f487e07bce49735235b91bf5ee79b6987ff80188.tar.bz2 |
am 53132840: Merge "init: call restorecon on /sys"
* commit '531328400ed6ce513f9bb4d9d772f02affeeaa26':
init: call restorecon on /sys
-rw-r--r-- | init/init.c | 1 | ||||
-rw-r--r--[-rwxr-xr-x] | init/util.c | 15 | ||||
-rw-r--r-- | init/util.h | 1 |
3 files changed, 17 insertions, 0 deletions
diff --git a/init/init.c b/init/init.c index 294c2c4..b699be0 100644 --- a/init/init.c +++ b/init/init.c @@ -945,6 +945,7 @@ int main(int argc, char **argv) restorecon("/dev"); restorecon("/dev/socket"); restorecon("/dev/__properties__"); + restorecon_recursive("/sys"); is_charger = !strcmp(bootmode, "charger"); diff --git a/init/util.c b/init/util.c index 1820aa9..154bb2d 100755..100644 --- a/init/util.c +++ b/init/util.c @@ -22,6 +22,7 @@ #include <ctype.h> #include <errno.h> #include <time.h> +#include <ftw.h> #include <selinux/label.h> @@ -519,3 +520,17 @@ int restorecon(const char *pathname) freecon(secontext); return 0; } + +static int nftw_restorecon(const char* filename, const struct stat* statptr, + int fileflags, struct FTW* pftw) +{ + restorecon(filename); + return 0; +} + +int restorecon_recursive(const char* pathname) +{ + int fd_limit = 20; + int flags = FTW_DEPTH | FTW_MOUNT | FTW_PHYS; + return nftw(pathname, nftw_restorecon, fd_limit, flags); +} diff --git a/init/util.h b/init/util.h index 39d6f52..04b8129 100644 --- a/init/util.h +++ b/init/util.h @@ -41,4 +41,5 @@ void get_hardware_name(char *hardware, unsigned int *revision); void import_kernel_cmdline(int in_qemu, void (*import_kernel_nv)(char *name, int in_qemu)); int make_dir(const char *path, mode_t mode); int restorecon(const char *pathname); +int restorecon_recursive(const char *pathname); #endif |