shadow-utils/shadow-4.9-move-create-home.patch
Iker Pedrosa 19b91d37bd - Rebase to version 4.9
- usermod: allow all group types with -G option
- useradd: avoid generating an empty subid range
- Clean spec file

Resolves: #1989556
Resolves: #1975329

Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
2021-08-12 09:38:52 +02:00

65 lines
1.6 KiB
Diff

diff --git a/src/useradd.c b/src/useradd.c
index baeffb35..02e1402c 100644
--- a/src/useradd.c
+++ b/src/useradd.c
@@ -2644,27 +2644,12 @@ 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 %s already exists.\n"
- "%s: Not copying any file from skel directory into it.\n"),
- Prog, user_home, Prog);
- }
-
- }
-
- /* Do not create mail directory for system accounts */
- if (!rflg) {
- create_mail ();
- }
-
close_files ();
+ nscd_flush_cache ("passwd");
+ nscd_flush_cache ("group");
+ sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
+
/*
* tallylog_reset needs to be able to lookup
* a valid existing user name,
@@ -2695,9 +2680,24 @@ int main (int argc, char **argv)
exit(1);
}
- nscd_flush_cache ("passwd");
- nscd_flush_cache ("group");
- sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_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 %s already exists.\n"
+ "%s: Not copying any file from skel directory into it.\n"),
+ Prog, user_home, Prog);
+ }
+
+ }
+
+ /* Do not create mail directory for system accounts */
+ if (!rflg) {
+ create_mail ();
+ }
return E_SUCCESS;
}