init: call restorecon on /sys
Not all files on /sys are not getting labeled properly. Fix them.
Change-Id: I9dcff76354e7f50d41f1b6e702836cfbbc149278
diff --git a/init/util.c b/init/util.c
old mode 100755
new mode 100644
index 1820aa9..154bb2d
--- 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 @@
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);
+}