4cea964109
- New upstream version 4.5 - Refreshed patches: * shadow-login_defs.patch * chkname-regex.patch * getdef-new-defs.patch * useradd-mkdirs.patch - Upstreamed patches: * shadow-4.1.5.1-manfix.patch * shadow-4.1.5.1-errmsg.patch * shadow-4.1.5.1-backup-mode.patch * shadow-4.1.5.1-audit-owner.patch * shadow-4.2.1-defs-chroot.patch * shadow-4.2.1-merge-group.patch * Fix-user-busy-errors-at-userdel.patch * useradd-clear-tallylog.patch - shadow.keyring: update keyring with current maintainer's keyid only - Serge Hallyn 'F1D08DB778185BF784002DFFE9FEEA06A85E3F9D' - disable_new_audit_function.patch: Disable newer libaudit functionality for older distributions OBS-URL: https://build.opensuse.org/request/show/497707 OBS-URL: https://build.opensuse.org/package/show/Base:System/shadow?expand=0&rev=32
72 lines
2.0 KiB
Diff
72 lines
2.0 KiB
Diff
Index: src/useradd.c
|
|
===================================================================
|
|
--- src/useradd.c.orig
|
|
+++ src/useradd.c
|
|
@@ -1943,6 +1943,13 @@ static void usr_update (void)
|
|
static void create_home (void)
|
|
{
|
|
if (access (user_home, F_OK) != 0) {
|
|
+ char path[strlen (user_home) + 2];
|
|
+ char *bhome, *cp;
|
|
+
|
|
+ path[0] = '\0';
|
|
+ bhome = strdup (user_home);
|
|
+ ++bhome;
|
|
+
|
|
#ifdef WITH_SELINUX
|
|
if (set_selinux_file_context (user_home) != 0) {
|
|
fprintf (stderr,
|
|
@@ -1951,19 +1958,42 @@ static void create_home (void)
|
|
fail_exit (E_HOMEDIR);
|
|
}
|
|
#endif
|
|
- /* XXX - create missing parent directories. --marekm */
|
|
- if (mkdir (user_home, 0) != 0) {
|
|
- fprintf (stderr,
|
|
- _("%s: cannot create directory %s\n"),
|
|
- Prog, user_home);
|
|
+
|
|
+ /* Check for every part of the path, if the directory
|
|
+ exists. If not, create it with permissions 755 and
|
|
+ owner root:root.
|
|
+ */
|
|
+ cp = strtok (bhome, "/");
|
|
+ while (cp) {
|
|
+ strcat (path, "/");
|
|
+ strcat (path, cp);
|
|
+ if (access (path, F_OK) != 0) {
|
|
+ if (mkdir (path, 0) != 0) {
|
|
+ fprintf (stderr,
|
|
+ _("%s: cannot create directory %s\n"),
|
|
+ Prog, path);
|
|
#ifdef WITH_AUDIT
|
|
- audit_logger (AUDIT_ADD_USER, Prog,
|
|
- "adding home directory",
|
|
- user_name, (unsigned int) user_id,
|
|
- SHADOW_AUDIT_FAILURE);
|
|
+ audit_logger (AUDIT_ADD_USER, Prog,
|
|
+ "adding home directory",
|
|
+ user_name, (unsigned int) user_id,
|
|
+ SHADOW_AUDIT_FAILURE);
|
|
#endif
|
|
- fail_exit (E_HOMEDIR);
|
|
+ fail_exit (E_HOMEDIR);
|
|
+ }
|
|
+ if (chown (path, 0, 0) < 0) {
|
|
+ fprintf (stderr,
|
|
+ _("%s: warning: chown on `%s' failed: %m\n"),
|
|
+ Prog, path);
|
|
+ }
|
|
+ if (chmod (path, 0777) < 0) {
|
|
+ fprintf (stderr,
|
|
+ _("%s: warning: chmod on `%s' failed: %m\n"),
|
|
+ Prog, path);
|
|
+ }
|
|
+ }
|
|
+ cp = strtok (NULL, "/");
|
|
}
|
|
+
|
|
chown (user_home, user_id, user_gid);
|
|
chmod (user_home,
|
|
0777 & ~getdef_num ("UMASK", GETDEF_DEFAULT_UMASK));
|