Blame SOURCES/shadow-4.1.5.1-selinux.patch

827aa9
diff -up shadow-4.1.5.1/lib/semanage.c.selinux shadow-4.1.5.1/lib/semanage.c
827aa9
--- shadow-4.1.5.1/lib/semanage.c.selinux	2012-01-08 17:35:44.000000000 +0100
827aa9
+++ shadow-4.1.5.1/lib/semanage.c	2014-09-10 10:11:55.417506128 +0200
827aa9
@@ -294,6 +294,9 @@ int set_seuser (const char *login_name,
827aa9
 
827aa9
 	ret = 0;
827aa9
 
827aa9
+        /* drop obsolete matchpathcon cache */
827aa9
+        matchpathcon_fini();
827aa9
+
827aa9
 done:
827aa9
 	semanage_seuser_key_free (key);
827aa9
 	semanage_handle_destroy (handle);
827aa9
@@ -369,6 +372,10 @@ int del_seuser (const char *login_name)
827aa9
 	}
827aa9
 
827aa9
 	ret = 0;
827aa9
+
827aa9
+        /* drop obsolete matchpathcon cache */
827aa9
+        matchpathcon_fini();
827aa9
+
827aa9
 done:
827aa9
 	semanage_handle_destroy (handle);
827aa9
 	return ret;
9f90df
diff -up shadow-4.1.5.1/src/useradd.c.selinux shadow-4.1.5.1/src/useradd.c
827aa9
--- shadow-4.1.5.1/src/useradd.c.selinux	2014-09-10 10:10:18.791280619 +0200
827aa9
+++ shadow-4.1.5.1/src/useradd.c	2014-09-10 10:10:18.798280781 +0200
827aa9
@@ -1850,6 +1850,7 @@ static void create_mail (void)
827aa9
  */
827aa9
 int main (int argc, char **argv)
827aa9
 {
827aa9
+	int rv = E_SUCCESS;
827aa9
 #ifdef ACCT_TOOLS_SETUID
827aa9
 #ifdef USE_PAM
827aa9
 	pam_handle_t *pamh = NULL;
827aa9
@@ -2037,10 +2038,33 @@ int main (int argc, char **argv)
827aa9
 
827aa9
 	usr_update ();
827aa9
 
827aa9
+	close_files ();
827aa9
+
827aa9
+	nscd_flush_cache ("passwd");
827aa9
+	nscd_flush_cache ("group");
827aa9
+
827aa9
+#ifdef WITH_SELINUX
827aa9
+	if (Zflg && *user_selinux) {
827aa9
+		if (is_selinux_enabled () > 0) {
827aa9
+		    if (set_seuser (user_name, user_selinux) != 0) {
827aa9
+			fprintf (stderr,
827aa9
+			         _("%s: warning: the user name %s to %s SELinux user mapping failed.\n"),
827aa9
+			         Prog, user_name, user_selinux);
827aa9
+#ifdef WITH_AUDIT
827aa9
+			audit_logger (AUDIT_ADD_USER, Prog,
827aa9
+			              "adding SELinux user mapping",
827aa9
+			              user_name, (unsigned int) user_id, 0);
827aa9
+#endif				/* WITH_AUDIT */
827aa9
+			rv = E_SE_UPDATE;
827aa9
+		    }
827aa9
+		}
827aa9
+	}
827aa9
+#endif
827aa9
+
9f90df
 	if (mflg) {
9f90df
 		create_home ();
9f90df
 		if (home_added) {
9f90df
-			copy_tree (def_template, user_home, false, false,
9f90df
+			copy_tree (def_template, user_home, false, true,
9f90df
 			           (uid_t)-1, user_id, (gid_t)-1, user_gid);
9f90df
 		} else {
9f90df
 			fprintf (stderr,
827aa9
@@ -2056,27 +2080,6 @@ int main (int argc, char **argv)
827aa9
 		create_mail ();
827aa9
 	}
827aa9
 
827aa9
-	close_files ();
827aa9
-
827aa9
-#ifdef WITH_SELINUX
827aa9
-	if (Zflg) {
827aa9
-		if (set_seuser (user_name, user_selinux) != 0) {
827aa9
-			fprintf (stderr,
827aa9
-			         _("%s: warning: the user name %s to %s SELinux user mapping failed.\n"),
827aa9
-			         Prog, user_name, user_selinux);
827aa9
-#ifdef WITH_AUDIT
827aa9
-			audit_logger (AUDIT_ADD_USER, Prog,
827aa9
-			              "adding SELinux user mapping",
827aa9
-			              user_name, (unsigned int) user_id, 0);
827aa9
-#endif				/* WITH_AUDIT */
827aa9
-			fail_exit (E_SE_UPDATE);
827aa9
-		}
827aa9
-	}
827aa9
-#endif				/* WITH_SELINUX */
827aa9
-
827aa9
-	nscd_flush_cache ("passwd");
827aa9
-	nscd_flush_cache ("group");
827aa9
-
827aa9
-	return E_SUCCESS;
827aa9
+	return rv;
827aa9
 }
827aa9