summaryrefslogtreecommitdiff
path: root/session.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-06-09 01:20:06 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-06-09 01:20:06 +0000
commit983c098311526a2e09a7c2cee18f3bf1081431e5 (patch)
tree63ca288905f887632124aeaf6f9fc6aa68d8ef43 /session.c
parent742e89ec5d6d51402e8140f9eca4222405ffce36 (diff)
- markus@cvs.openbsd.org 2001/06/04 21:59:43
[channels.c channels.h session.c] switch uid when cleaning up tmp files and sockets; reported by zen-parse@gmx.net on bugtraq
Diffstat (limited to 'session.c')
-rw-r--r--session.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/session.c b/session.c
index ce9b2002b..c65c7e663 100644
--- a/session.c
+++ b/session.c
@@ -33,7 +33,7 @@
33 */ 33 */
34 34
35#include "includes.h" 35#include "includes.h"
36RCSID("$OpenBSD: session.c,v 1.79 2001/06/03 14:55:39 markus Exp $"); 36RCSID("$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);
132void do_child(Session *s, const char *command); 132void do_child(Session *s, const char *command);
133void do_motd(void); 133void do_motd(void);
134int check_quietlogin(Session *s, const char *command); 134int check_quietlogin(Session *s, const char *command);
135void xauthfile_cleanup_proc(void *ignore); 135void xauthfile_cleanup_proc(void *pw);
136 136
137void do_authenticated1(Authctxt *authctxt); 137void do_authenticated1(Authctxt *authctxt);
138void do_authenticated2(Authctxt *authctxt); 138void 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 */
211void 211void
212xauthfile_cleanup_proc(void *ignore) 212xauthfile_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