2022-01-11 18:37:27 +00:00
|
|
|
From 09c752f00f9dfc610f66d68be38c9e5be8ca7f15 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Iker Pedrosa <ipedrosa@redhat.com>
|
|
|
|
Date: Fri, 8 Oct 2021 13:09:59 +0200
|
|
|
|
Subject: [PATCH] useradd: create directories after the SELinux user
|
|
|
|
|
|
|
|
Create the home and mail folders after the SELinux user has been set for
|
|
|
|
the added user. This will allow the folders to be created with the
|
|
|
|
SELinux user label.
|
|
|
|
|
|
|
|
Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
|
|
|
|
---
|
|
|
|
src/useradd.c | 46 +++++++++++++++++++++++-----------------------
|
|
|
|
1 file changed, 23 insertions(+), 23 deletions(-)
|
|
|
|
|
2021-11-04 02:59:26 +00:00
|
|
|
diff --git a/src/useradd.c b/src/useradd.c
|
2022-01-11 18:37:27 +00:00
|
|
|
index 6269c01c..b463a170 100644
|
2021-11-04 02:59:26 +00:00
|
|
|
--- a/src/useradd.c
|
|
|
|
+++ b/src/useradd.c
|
2022-01-11 18:37:27 +00:00
|
|
|
@@ -2670,27 +2670,12 @@ int main (int argc, char **argv)
|
2021-11-04 02:59:26 +00:00
|
|
|
|
|
|
|
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,
|
2022-01-11 18:37:27 +00:00
|
|
|
@@ -2716,15 +2701,30 @@ int main (int argc, char **argv)
|
2021-11-04 02:59:26 +00:00
|
|
|
}
|
2022-01-11 18:37:27 +00:00
|
|
|
#endif /* WITH_SELINUX */
|
2021-11-04 02:59:26 +00:00
|
|
|
|
|
|
|
+ if (mflg) {
|
|
|
|
+ create_home ();
|
|
|
|
+ if (home_added) {
|
2022-01-11 18:37:27 +00:00
|
|
|
+ copy_tree (def_template, prefix_user_home, false, false,
|
2021-11-04 02:59:26 +00:00
|
|
|
+ (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 ();
|
|
|
|
+ }
|
2022-01-11 18:37:27 +00:00
|
|
|
+
|
|
|
|
if (run_parts ("/etc/shadow-maint/useradd-post.d", (char*)user_name,
|
|
|
|
"useradd")) {
|
|
|
|
exit(1);
|
|
|
|
}
|
2021-11-04 02:59:26 +00:00
|
|
|
|
2022-01-11 18:37:27 +00:00
|
|
|
- nscd_flush_cache ("passwd");
|
|
|
|
- nscd_flush_cache ("group");
|
|
|
|
- sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
|
|
|
|
-
|
2021-11-04 02:59:26 +00:00
|
|
|
return E_SUCCESS;
|
|
|
|
}
|
2022-01-11 18:37:27 +00:00
|
|
|
|
|
|
|
--
|
|
|
|
2.31.1
|
|
|
|
|