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