summaryrefslogtreecommitdiff
path: root/channels.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 /channels.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 'channels.c')
-rw-r--r--channels.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/channels.c b/channels.c
index 110613896..32c23be1f 100644
--- a/channels.c
+++ b/channels.c
@@ -40,7 +40,7 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: channels.c,v 1.122 2001/06/03 14:55:38 markus Exp $"); 43RCSID("$OpenBSD: channels.c,v 1.123 2001/06/04 21:59:42 markus Exp $");
44 44
45#include "ssh.h" 45#include "ssh.h"
46#include "ssh1.h" 46#include "ssh1.h"
@@ -2777,12 +2777,16 @@ auth_get_socket_name()
2777/* removes the agent forwarding socket */ 2777/* removes the agent forwarding socket */
2778 2778
2779void 2779void
2780auth_sock_cleanup_proc(void *ignored) 2780auth_sock_cleanup_proc(void *_pw)
2781{ 2781{
2782 struct passwd *pw = _pw;
2783
2782 if (auth_sock_name) { 2784 if (auth_sock_name) {
2785 temporarily_use_uid(pw);
2783 unlink(auth_sock_name); 2786 unlink(auth_sock_name);
2784 rmdir(auth_sock_dir); 2787 rmdir(auth_sock_dir);
2785 auth_sock_name = NULL; 2788 auth_sock_name = NULL;
2789 restore_uid();
2786 } 2790 }
2787} 2791}
2788 2792
@@ -2826,7 +2830,7 @@ auth_input_request_forwarding(struct passwd * pw)
2826 auth_sock_dir, (int) getpid()); 2830 auth_sock_dir, (int) getpid());
2827 2831
2828 /* delete agent socket on fatal() */ 2832 /* delete agent socket on fatal() */
2829 fatal_add_cleanup(auth_sock_cleanup_proc, NULL); 2833 fatal_add_cleanup(auth_sock_cleanup_proc, pw);
2830 2834
2831 /* Create the socket. */ 2835 /* Create the socket. */
2832 sock = socket(AF_UNIX, SOCK_STREAM, 0); 2836 sock = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -2856,7 +2860,7 @@ auth_input_request_forwarding(struct passwd * pw)
2856 0, xstrdup("auth socket"), 1); 2860 0, xstrdup("auth socket"), 1);
2857 if (nc == NULL) { 2861 if (nc == NULL) {
2858 error("auth_input_request_forwarding: channel_new failed"); 2862 error("auth_input_request_forwarding: channel_new failed");
2859 auth_sock_cleanup_proc(NULL); 2863 auth_sock_cleanup_proc(pw);
2860 close(sock); 2864 close(sock);
2861 return 0; 2865 return 0;
2862 } 2866 }