diff options
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -33,7 +33,7 @@ | |||
33 | */ | 33 | */ |
34 | 34 | ||
35 | #include "includes.h" | 35 | #include "includes.h" |
36 | RCSID("$OpenBSD: session.c,v 1.79 2001/06/03 14:55:39 markus Exp $"); | 36 | RCSID("$OpenBSD: session.c,v 1.80 2001/06/04 21:59:43 markus Exp $"); |
37 | 37 | ||
38 | #include "ssh.h" | 38 | #include "ssh.h" |
39 | #include "ssh1.h" | 39 | #include "ssh1.h" |
@@ -132,7 +132,7 @@ void do_pre_login(Session *s); | |||
132 | void do_child(Session *s, const char *command); | 132 | void do_child(Session *s, const char *command); |
133 | void do_motd(void); | 133 | void do_motd(void); |
134 | int check_quietlogin(Session *s, const char *command); | 134 | int check_quietlogin(Session *s, const char *command); |
135 | void xauthfile_cleanup_proc(void *ignore); | 135 | void xauthfile_cleanup_proc(void *pw); |
136 | 136 | ||
137 | void do_authenticated1(Authctxt *authctxt); | 137 | void do_authenticated1(Authctxt *authctxt); |
138 | void do_authenticated2(Authctxt *authctxt); | 138 | void do_authenticated2(Authctxt *authctxt); |
@@ -200,21 +200,23 @@ do_authenticated(Authctxt *authctxt) | |||
200 | 200 | ||
201 | /* remote user's local Xauthority file and agent socket */ | 201 | /* remote user's local Xauthority file and agent socket */ |
202 | if (xauthfile) | 202 | if (xauthfile) |
203 | xauthfile_cleanup_proc(NULL); | 203 | xauthfile_cleanup_proc(authctxt->pw); |
204 | if (auth_get_socket_name()) | 204 | if (auth_get_socket_name()) |
205 | auth_sock_cleanup_proc(NULL); | 205 | auth_sock_cleanup_proc(authctxt->pw); |
206 | } | 206 | } |
207 | 207 | ||
208 | /* | 208 | /* |
209 | * Remove local Xauthority file. | 209 | * Remove local Xauthority file. |
210 | */ | 210 | */ |
211 | void | 211 | void |
212 | xauthfile_cleanup_proc(void *ignore) | 212 | xauthfile_cleanup_proc(void *_pw) |
213 | { | 213 | { |
214 | debug("xauthfile_cleanup_proc called"); | 214 | struct passwd *pw = _pw; |
215 | char *p; | ||
215 | 216 | ||
217 | debug("xauthfile_cleanup_proc called"); | ||
216 | if (xauthfile != NULL) { | 218 | if (xauthfile != NULL) { |
217 | char *p; | 219 | temporarily_use_uid(pw); |
218 | unlink(xauthfile); | 220 | unlink(xauthfile); |
219 | p = strrchr(xauthfile, '/'); | 221 | p = strrchr(xauthfile, '/'); |
220 | if (p != NULL) { | 222 | if (p != NULL) { |
@@ -223,6 +225,7 @@ xauthfile_cleanup_proc(void *ignore) | |||
223 | } | 225 | } |
224 | xfree(xauthfile); | 226 | xfree(xauthfile); |
225 | xauthfile = NULL; | 227 | xauthfile = NULL; |
228 | restore_uid(); | ||
226 | } | 229 | } |
227 | } | 230 | } |
228 | 231 | ||
@@ -399,7 +402,7 @@ do_authenticated1(Authctxt *authctxt) | |||
399 | if (fd >= 0) | 402 | if (fd >= 0) |
400 | close(fd); | 403 | close(fd); |
401 | restore_uid(); | 404 | restore_uid(); |
402 | fatal_add_cleanup(xauthfile_cleanup_proc, NULL); | 405 | fatal_add_cleanup(xauthfile_cleanup_proc, s->pw); |
403 | success = 1; | 406 | success = 1; |
404 | break; | 407 | break; |
405 | 408 | ||
@@ -1811,7 +1814,7 @@ session_x11_req(Session *s) | |||
1811 | if (fd >= 0) | 1814 | if (fd >= 0) |
1812 | close(fd); | 1815 | close(fd); |
1813 | restore_uid(); | 1816 | restore_uid(); |
1814 | fatal_add_cleanup(xauthfile_cleanup_proc, s); | 1817 | fatal_add_cleanup(xauthfile_cleanup_proc, s->pw); |
1815 | return 1; | 1818 | return 1; |
1816 | } | 1819 | } |
1817 | 1820 | ||