File: upstream-fix-session_closing.patch

package info (click to toggle)
libpam-ssh 2.3%2Bds-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,432 kB
  • sloc: ansic: 19,197; makefile: 95; sh: 44
file content (41 lines) | stat: -rw-r--r-- 1,222 bytes parent folder | download | duplicates (2)
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
Description: upstream: ssh session: clean closing
 Close sessions in a civilized manner when no dotdir
 is present (Close: #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
@@ -1158,6 +1158,7 @@
 	const struct passwd *pwent;	/* user's passwd entry */
 	struct stat sb;			/* to check st_nlink */
 	const char *user;               /* username */
+	char *dotdir;		        /* .ssh dir name */
 
 	pam_ssh_log(LOG_DEBUG, "close session");
 
@@ -1177,6 +1178,21 @@
 		return retval;
 	}
 
+	/* handle the per-user configuration directory and check its existence */
+
+	if (asprintf(&dotdir, "%s/%s", pwent->pw_dir, SSH_DIR) == -1) {
+		pam_ssh_log(LOG_CRIT, "out of memory");
+		openpam_restore_cred(pamh);
+		return PAM_SERVICE_ERR;
+	}
+	if ((access(dotdir,F_OK)) == -1) {
+		pam_ssh_log(LOG_DEBUG, "inexistent configuration directory");
+		free(dotdir);
+		openpam_restore_cred(pamh);
+		return PAM_SUCCESS;
+	}
+	free(dotdir);
+
 	if (pam_get_data(pamh, "ssh_agent_env_session",
 	    (const void **)(void *)&env_file) == PAM_SUCCESS && env_file)
 		unlink(env_file);