1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
Description: upstream: session: use opendir
Check `~/.ssh' folder existence with opendir(3)
(see #802212); meant to be submitted to the
upstream maintainer.
Origin: debian
Forwarded: dormant-upstream
Author: Jerome Benoit <calculus@rezozer.net>
Last-Update: 2022-01-09
--- a/pam_ssh.c
+++ b/pam_ssh.c
@@ -915,6 +915,7 @@
char hname[MAXHOSTNAMELEN]; /* local hostname */
int no_link; /* link per-agent file? */
char *dotdir; /* .ssh dir name */
+ DIR *dotstr; /* .ssh dir stream */
char *per_agent; /* to store env */
char *per_session; /* per-session filename */
const struct passwd *pwent; /* user's passwd entry */
@@ -974,12 +975,15 @@
openpam_restore_cred(pamh);
return PAM_SERVICE_ERR;
}
- if ((access(dotdir,F_OK)) == -1) {
+ if ((dotstr=opendir(dotdir)) == NULL) {
pam_ssh_log(LOG_DEBUG, "inexistent configuration directory");
free(dotdir);
openpam_restore_cred(pamh);
return PAM_SUCCESS;
}
+ else {
+ closedir(dotstr);
+ }
/* the per-agent file contains just the hostname */
@@ -1159,6 +1163,7 @@
struct stat sb; /* to check st_nlink */
const char *user; /* username */
char *dotdir; /* .ssh dir name */
+ DIR *dotstr; /* .ssh dir stream */
pam_ssh_log(LOG_DEBUG, "close session");
@@ -1185,11 +1190,14 @@
openpam_restore_cred(pamh);
return PAM_SERVICE_ERR;
}
- if ((access(dotdir,F_OK)) == -1) {
+ if ((dotstr=opendir(dotdir)) == NULL) {
pam_ssh_log(LOG_DEBUG, "inexistent configuration directory");
free(dotdir);
openpam_restore_cred(pamh);
return PAM_SUCCESS;
+ }
+ else {
+ closedir(dotstr);
}
free(dotdir);
|