Blame SOURCES/shadow-4.6-selinux.patch

e5cfd7
diff -up shadow-4.6/lib/semanage.c.selinux shadow-4.6/lib/semanage.c
e5cfd7
--- shadow-4.6/lib/semanage.c.selinux	2018-04-29 18:42:37.000000000 +0200
e5cfd7
+++ shadow-4.6/lib/semanage.c	2018-05-28 13:38:20.551008911 +0200
e5cfd7
@@ -294,6 +294,9 @@ int set_seuser (const char *login_name,
e5cfd7
 
e5cfd7
 	ret = 0;
e5cfd7
 
e5cfd7
+        /* drop obsolete matchpathcon cache */
e5cfd7
+        matchpathcon_fini();
e5cfd7
+
e5cfd7
 done:
e5cfd7
 	semanage_seuser_key_free (key);
e5cfd7
 	semanage_handle_destroy (handle);
e5cfd7
@@ -369,6 +372,10 @@ int del_seuser (const char *login_name)
e5cfd7
 	}
e5cfd7
 
e5cfd7
 	ret = 0;
e5cfd7
+
e5cfd7
+        /* drop obsolete matchpathcon cache */
e5cfd7
+        matchpathcon_fini();
e5cfd7
+
e5cfd7
 done:
e5cfd7
 	semanage_handle_destroy (handle);
e5cfd7
 	return ret;
e5cfd7
diff -up shadow-4.6/src/useradd.c.selinux shadow-4.6/src/useradd.c
e5cfd7
--- shadow-4.6/src/useradd.c.selinux	2018-05-28 13:43:30.996748997 +0200
e5cfd7
+++ shadow-4.6/src/useradd.c	2018-05-28 13:44:04.645486199 +0200
e5cfd7
@@ -2120,6 +2120,7 @@ static void create_mail (void)
e5cfd7
  */
e5cfd7
 int main (int argc, char **argv)
e5cfd7
 {
e5cfd7
+	int rv = E_SUCCESS;
e5cfd7
 #ifdef ACCT_TOOLS_SETUID
e5cfd7
 #ifdef USE_PAM
e5cfd7
 	pam_handle_t *pamh = NULL;
e5cfd7
@@ -2342,27 +2343,11 @@ int main (int argc, char **argv)
e5cfd7
 
e5cfd7
 	usr_update ();
e5cfd7
 
e5cfd7
-	if (mflg) {
e5cfd7
-		create_home ();
e5cfd7
-		if (home_added) {
e5cfd7
-			copy_tree (def_template, prefix_user_home, false, false,
e5cfd7
-			           (uid_t)-1, user_id, (gid_t)-1, user_gid);
e5cfd7
-		} else {
e5cfd7
-			fprintf (stderr,
e5cfd7
-			         _("%s: warning: the home directory already exists.\n"
e5cfd7
-			           "Not copying any file from skel directory into it.\n"),
e5cfd7
-			         Prog);
e5cfd7
-		}
e5cfd7
-
e5cfd7
-	}
e5cfd7
-
e5cfd7
-	/* Do not create mail directory for system accounts */
e5cfd7
-	if (!rflg) {
e5cfd7
-		create_mail ();
e5cfd7
-	}
e5cfd7
-
e5cfd7
 	close_files ();
e5cfd7
 
e5cfd7
+	nscd_flush_cache ("passwd");
e5cfd7
+	nscd_flush_cache ("group");
e5cfd7
+
e5cfd7
 	/*
e5cfd7
 	 * tallylog_reset needs to be able to lookup
e5cfd7
 	 * a valid existing user name,
e5cfd7
@@ -2373,8 +2358,9 @@ int main (int argc, char **argv)
e5cfd7
 	}
e5cfd7
 
e5cfd7
 #ifdef WITH_SELINUX
e5cfd7
-	if (Zflg) {
e5cfd7
-		if (set_seuser (user_name, user_selinux) != 0) {
e5cfd7
+	if (Zflg && *user_selinux) {
e5cfd7
+		if (is_selinux_enabled () > 0) {
e5cfd7
+		    if (set_seuser (user_name, user_selinux) != 0) {
e5cfd7
 			fprintf (stderr,
e5cfd7
 			         _("%s: warning: the user name %s to %s SELinux user mapping failed.\n"),
e5cfd7
 			         Prog, user_name, user_selinux);
e5cfd7
@@ -2383,14 +2369,31 @@ int main (int argc, char **argv)
e5cfd7
 			              "adding SELinux user mapping",
e5cfd7
 			              user_name, (unsigned int) user_id, 0);
e5cfd7
 #endif				/* WITH_AUDIT */
e5cfd7
-			fail_exit (E_SE_UPDATE);
e5cfd7
+			rv = E_SE_UPDATE;
e5cfd7
+		    }
e5cfd7
 		}
e5cfd7
 	}
e5cfd7
-#endif				/* WITH_SELINUX */
e5cfd7
+#endif
e5cfd7
 
e5cfd7
-	nscd_flush_cache ("passwd");
e5cfd7
-	nscd_flush_cache ("group");
e5cfd7
+	if (mflg) {
e5cfd7
+		create_home ();
e5cfd7
+		if (home_added) {
e5cfd7
+			copy_tree (def_template, prefix_user_home, false, true,
e5cfd7
+			           (uid_t)-1, user_id, (gid_t)-1, user_gid);
e5cfd7
+		} else {
e5cfd7
+			fprintf (stderr,
e5cfd7
+			         _("%s: warning: the home directory already exists.\n"
e5cfd7
+			           "Not copying any file from skel directory into it.\n"),
e5cfd7
+			         Prog);
e5cfd7
+		}
e5cfd7
+
e5cfd7
+	}
e5cfd7
+
e5cfd7
+	/* Do not create mail directory for system accounts */
e5cfd7
+	if (!rflg) {
e5cfd7
+		create_mail ();
e5cfd7
+	}
e5cfd7
 
e5cfd7
-	return E_SUCCESS;
e5cfd7
+	return rv;
e5cfd7
 }
e5cfd7