File openssh-7.7p1-remove_xauth_cookies_on_exit.patch of Package openssh (Revision 030dec49fd0ca28b30b3fde287d4a0ba)
Currently displaying revision 030dec49fd0ca28b30b3fde287d4a0ba , Show latest
56
1
# HG changeset patch
2
# Parent a60c0d88667efe0a64c030168950b69476af1622
3
# --used to be called '-xauth'
4
try to remove xauth cookies on logout
5
6
bnc#98815
7
8
diff --git a/openssh-7.7p1/session.c b/openssh-7.7p1/session.c
9
--- openssh-7.7p1/session.c
10
+++ openssh-7.7p1/session.c
11
12
u_int i;
13
14
verbose("Close session: user %s from %.200s port %d id %d",
15
s->pw->pw_name,
16
ssh_remote_ipaddr(ssh),
17
ssh_remote_port(ssh),
18
s->self);
19
20
+ if ((s->display != NULL) && (s->auth_proto != NULL) &&
21
+ (s->auth_data != NULL) && (options.xauth_location != NULL)) {
22
+ pid_t pid;
23
+ FILE *f;
24
+ char cmd[1024];
25
+ struct passwd * pw = s->pw;
26
+
27
+ if (!(pid = fork())) {
28
+ permanently_set_uid(pw);
29
+
30
+ /* Remove authority data from .Xauthority if appropriate. */
31
+ debug("Running %.500s remove %.100s\n",
32
+ options.xauth_location, s->auth_display);
33
+
34
+ snprintf(cmd, sizeof cmd, "unset XAUTHORITY && HOME=\"%.200s\" %s -q -",
35
+ s->pw->pw_dir, options.xauth_location);
36
+ f = popen(cmd, "w");
37
+ if (f) {
38
+ fprintf(f, "remove %s\n", s->auth_display);
39
+ pclose(f);
40
+ } else
41
+ error("Could not run %s\n", cmd);
42
+ exit(0);
43
+ } else if (pid > 0) {
44
+ waitpid(pid, NULL, 0);
45
+ }
46
+ }
47
+
48
if (s->ttyfd != -1)
49
session_pty_cleanup(s);
50
free(s->term);
51
free(s->display);
52
free(s->x11_chanids);
53
free(s->auth_display);
54
free(s->auth_data);
55
free(s->auth_proto);
56