| 1 |
From: Sam Hartman <[email protected]> |
| 2 |
Date: Mon, 11 Sep 2023 14:00:42 -0600 |
| 3 |
Subject: pam_mkhomedir_stat_before_opendir |
| 4 |
|
| 5 |
=================================================================== |
| 6 |
--- |
| 7 |
modules/pam_mkhomedir/mkhomedir_helper.c | 7 +++++++ |
| 8 |
1 file changed, 7 insertions(+) |
| 9 |
|
| 10 |
diff --git a/modules/pam_mkhomedir/mkhomedir_helper.c b/modules/pam_mkhomedir/mkhomedir_helper.c |
| 11 |
index eefb599..fa9089d 100644 |
| 12 |
--- a/modules/pam_mkhomedir/mkhomedir_helper.c |
| 13 |
+++ b/modules/pam_mkhomedir/mkhomedir_helper.c |
| 14 |
@@ -271,6 +271,7 @@ create_homedir(struct dir_spec *parent, const struct passwd *pwd, |
| 15 |
struct dirent *dent; |
| 16 |
struct dir_spec base; |
| 17 |
int retval = PAM_SESSION_ERR; |
| 18 |
+ struct stat stat_buf; |
| 19 |
|
| 20 |
/* Create the new directory */ |
| 21 |
if (mkdirat(parent->fd, dest, 0700)) |
| 22 |
@@ -295,6 +296,12 @@ create_homedir(struct dir_spec *parent, const struct passwd *pwd, |
| 23 |
goto go_out; |
| 24 |
} |
| 25 |
|
| 26 |
+ /* Various things such as an autofs mount with browsing disabled |
| 27 |
+ * can cause the directory to appear only on stat. The intent is |
| 28 |
+ * to minimize network traversal when a file explorer tries to |
| 29 |
+ * traverse large chunks of a directory tree. So stat first.*/ |
| 30 |
+ stat(source, &stat_buf); |
| 31 |
+ |
| 32 |
/* Scan the directory */ |
| 33 |
d = opendir(source); |
| 34 |
if (d == NULL) |