diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-05-03 22:59:24 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-05-03 22:59:24 +0000 |
commit | 3524d697374a37d39e971d96c33080c307304820 (patch) | |
tree | 0aa3c1cae184d546bbdc1776e51fe59f2d0b65f2 /ssh-agent.c | |
parent | 834417afa544d3521f9dbb17335d777c3a8a0b31 (diff) |
- (bal) Avoid socket file security issues in ssh-agent for Cygwin.
Patch by Egor Duda <deo@logos-m.ru>
Diffstat (limited to 'ssh-agent.c')
-rw-r--r-- | ssh-agent.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ssh-agent.c b/ssh-agent.c index e8362ded0..07dafaa57 100644 --- a/ssh-agent.c +++ b/ssh-agent.c | |||
@@ -714,6 +714,9 @@ main(int ac, char **av) | |||
714 | #ifdef HAVE_SETRLIMIT | 714 | #ifdef HAVE_SETRLIMIT |
715 | struct rlimit rlim; | 715 | struct rlimit rlim; |
716 | #endif | 716 | #endif |
717 | #ifdef HAVE_CYGWIN | ||
718 | int prev_mask; | ||
719 | #endif | ||
717 | pid_t pid; | 720 | pid_t pid; |
718 | char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid]; | 721 | char *shell, *format, *pidstr, pidstrbuf[1 + 3 * sizeof pid]; |
719 | extern int optind; | 722 | extern int optind; |
@@ -805,10 +808,19 @@ main(int ac, char **av) | |||
805 | memset(&sunaddr, 0, sizeof(sunaddr)); | 808 | memset(&sunaddr, 0, sizeof(sunaddr)); |
806 | sunaddr.sun_family = AF_UNIX; | 809 | sunaddr.sun_family = AF_UNIX; |
807 | strlcpy(sunaddr.sun_path, socket_name, sizeof(sunaddr.sun_path)); | 810 | strlcpy(sunaddr.sun_path, socket_name, sizeof(sunaddr.sun_path)); |
811 | #ifdef HAVE_CYGWIN | ||
812 | prev_mask = umask(0177); | ||
813 | #endif | ||
808 | if (bind(sock, (struct sockaddr *) & sunaddr, sizeof(sunaddr)) < 0) { | 814 | if (bind(sock, (struct sockaddr *) & sunaddr, sizeof(sunaddr)) < 0) { |
809 | perror("bind"); | 815 | perror("bind"); |
816 | #ifdef HAVE_CYGWIN | ||
817 | umask(prev_mask); | ||
818 | #endif | ||
810 | cleanup_exit(1); | 819 | cleanup_exit(1); |
811 | } | 820 | } |
821 | #ifdef HAVE_CYGWIN | ||
822 | umask(prev_mask); | ||
823 | #endif | ||
812 | if (listen(sock, 5) < 0) { | 824 | if (listen(sock, 5) < 0) { |
813 | perror("listen"); | 825 | perror("listen"); |
814 | cleanup_exit(1); | 826 | cleanup_exit(1); |