Blob Blame History Raw
diff -up Linux-PAM-1.1.8/modules/pam_mkhomedir/mkhomedir_helper.c.mkhomedir-inroot Linux-PAM-1.1.8/modules/pam_mkhomedir/mkhomedir_helper.c
--- Linux-PAM-1.1.8/modules/pam_mkhomedir/mkhomedir_helper.c.mkhomedir-inroot	2013-06-18 16:11:21.000000000 +0200
+++ Linux-PAM-1.1.8/modules/pam_mkhomedir/mkhomedir_helper.c	2017-11-03 10:20:59.823998481 +0100
@@ -352,16 +352,18 @@ make_parent_dirs(char *dir, int make)
   char *cp = strrchr(dir, '/');
   struct stat st;
 
-  if (!cp || cp == dir)
+  if (!cp)
     return rc;
 
-  *cp = '\0';
-  if (stat(dir, &st) && errno == ENOENT)
-    rc = make_parent_dirs(dir, 1);
-  *cp = '/';
+  if (cp != dir) {
+    *cp = '\0';
+    if (stat(dir, &st) && errno == ENOENT)
+      rc = make_parent_dirs(dir, 1);
+    *cp = '/';
 
-  if (rc != PAM_SUCCESS)
-    return rc;
+    if (rc != PAM_SUCCESS)
+      return rc;
+  }
 
   if (make && mkdir(dir, 0755) && errno != EEXIST) {
     pam_syslog(NULL, LOG_ERR, "unable to create directory %s: %m", dir);