summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/ssh-agent.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2014-07-15 15:54:16 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2014-07-15 15:54:16 +0000
commit4df827c87d1c22d7bcf04fafb8776788ec3d8cd3 (patch)
treeaf30b0dad78b066b92a3edfa64f54d2b1fff5c9e /usr.bin/ssh/ssh-agent.c
parent00d4c61e8e8d1537cb67af4fdfe0e319d81277a8 (diff)
Add support for Unix domain socket forwarding. A remote TCP port
may be forwarded to a local Unix domain socket and vice versa or both ends may be a Unix domain socket. This is a reimplementation of the streamlocal patches by William Ahern from: http://www.25thandclement.com/~william/projects/streamlocal.html OK djm@ markus@
Diffstat (limited to 'usr.bin/ssh/ssh-agent.c')
-rw-r--r--usr.bin/ssh/ssh-agent.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c
index 4c0b6184a6c..56cee5b5715 100644
--- a/usr.bin/ssh/ssh-agent.c
+++ b/usr.bin/ssh/ssh-agent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-agent.c,v 1.187 2014/07/03 03:11:03 djm Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.188 2014/07/15 15:54:14 millert Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1022,7 +1022,6 @@ main(int ac, char **av)
u_int nalloc;
char *shell, *format, *pidstr, *agentsocket = NULL;
fd_set *readsetp = NULL, *writesetp = NULL;
- struct sockaddr_un sunaddr;
struct rlimit rlim;
extern int optind;
extern char *optarg;
@@ -1134,24 +1133,12 @@ main(int ac, char **av)
* Create socket early so it will exist before command gets run from
* the parent.
*/
- sock = socket(AF_UNIX, SOCK_STREAM, 0);
+ sock = unix_listener(socket_name, SSH_LISTEN_BACKLOG, 0);
if (sock < 0) {
- perror("socket");
- *socket_name = '\0'; /* Don't unlink any existing file */
- cleanup_exit(1);
- }
- memset(&sunaddr, 0, sizeof(sunaddr));
- sunaddr.sun_family = AF_UNIX;
- strlcpy(sunaddr.sun_path, socket_name, sizeof(sunaddr.sun_path));
- if (bind(sock, (struct sockaddr *)&sunaddr, sizeof(sunaddr)) < 0) {
- perror("bind");
+ /* XXX - unix_listener() calls error() not perror() */
*socket_name = '\0'; /* Don't unlink any existing file */
cleanup_exit(1);
}
- if (listen(sock, SSH_LISTEN_BACKLOG) < 0) {
- perror("listen");
- cleanup_exit(1);
- }
/*
* Fork, and have the parent execute the command, if any, or present