+ int enforce = selinux_status_getenforce();
+
+ if (getenv("SELINUX_INIT")) {
+ /* SELinux already initialized */
+ if (getenv("SELINUX_RESTORECON")) {
+ unsetenv("SELINUX_INIT");
+ unsetenv("SELINUX_RESTORECON");
+ return 0;
+ }
+ /* Second call: restore filesystem labels */
+ ret = selinux_restorecon("/", SELINUX_RESTORECON_RECURSE);
+ putenv("SELINUX_RESTORECON=1");
+ } else {
+ /* First call: load policy */
+ ret = selinux_init_load_policy(&enforce);
+ putenv("SELINUX_INIT=1");
+ }