On Fri, Nov 03, 2017 at 10:26:31AM +0100, Tomas Mraz wrote:
The pam_mkhomedir is currently unable to create a parent directory
of
the home directory in /. This regressed with the commit
https://github.com/linux-pam/linux-pam/commit/a1f218877c56b1b0eafcbe223dd...
The attached patch fixes the issue.
OK to commit?
[...]
diff --git a/modules/pam_mkhomedir/mkhomedir_helper.c
b/modules/pam_mkhomedir/mkhomedir_helper.c
index 9fafe6a..9e204c1 100644
--- a/modules/pam_mkhomedir/mkhomedir_helper.c
+++ b/modules/pam_mkhomedir/mkhomedir_helper.c
@@ -338,16 +338,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);
Yes, this looks OK.
--
ldv