Set the SELinux security label on new directories.

Automatically set the SELinux security label on directories created
by init.rc.  This avoids the need to separately call restorecon on
each such directory from the init.rc file.  Also restorecon /dev
and /dev/socket after initial policy load so that they are labeled
correctly before any other dev nodes or sockets are created.

Change-Id: If6af6c4887cdead949737cebdd673957e9273ead
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
diff --git a/init/init.c b/init/init.c
index 1ee88a7..31f5c12 100755
--- a/init/init.c
+++ b/init/init.c
@@ -900,6 +900,12 @@
 #ifdef HAVE_SELINUX
     INFO("loading selinux policy\n");
     selinux_load_policy();
+    /* These directories were necessarily created before policy load
+     * and therefore need their security context restored to the proper value.
+     * This must happen before /dev is populated by ueventd.
+     */
+    restorecon("/dev");
+    restorecon("/dev/socket");
 #endif
 
     is_charger = !strcmp(bootmode, "charger");