diff options
author | Tomas Mraz <tmraz@fedoraproject.org> | 2017-11-10 08:56:09 +0100 |
---|---|---|
committer | Tomas Mraz <tmraz@fedoraproject.org> | 2017-11-10 08:56:09 +0100 |
commit | ee204e9914be30c0b4462aefa1f4d45aa1068c0a (patch) | |
tree | 10e744791ca0615822aa3295a2a56a7ec34394cc | |
parent | 94f529d4f239362dea6e43a0bd3f6323b429a712 (diff) | |
download | pam-ee204e9914be30c0b4462aefa1f4d45aa1068c0a.tar.gz pam-ee204e9914be30c0b4462aefa1f4d45aa1068c0a.tar.bz2 pam-ee204e9914be30c0b4462aefa1f4d45aa1068c0a.zip |
pam_mkhomedir: Allow creating parent of homedir under /
* modules/pam_mkhomedir/mkhomedir_helper.c (make_parent_dirs): Do not
skip creating the directory if we are under /.
-rw-r--r-- | modules/pam_mkhomedir/mkhomedir_helper.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/modules/pam_mkhomedir/mkhomedir_helper.c b/modules/pam_mkhomedir/mkhomedir_helper.c index 9fafe6ab..9e204c16 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); |