Skip to content

Commit 57dabcc

Browse files
committed
Add support for AF_UNIX
1 parent 33a141f commit 57dabcc

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

contrib/win32/win32compat/socketio.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ socketio_acceptEx(struct w32_io* pio)
118118
}
119119

120120
/* create accepting socket */
121-
context->accept_socket = socket(addr.ss_family, SOCK_STREAM, IPPROTO_TCP);
121+
context->accept_socket = socket(addr.ss_family, SOCK_STREAM, IPPROTO_IP);
122122
if (context->accept_socket == INVALID_SOCKET) {
123123
errno = errno_from_WSALastError();
124124
debug3("acceptEx - socket() ERROR:%d, io:%p", WSAGetLastError(), pio);
@@ -778,6 +778,12 @@ socketio_connectex(struct w32_io* pio, const struct sockaddr* name, int namelen)
778778
tmp_addr4.sin_port = 0;
779779
tmp_addr = (SOCKADDR*)&tmp_addr4;
780780
tmp_addr_len = sizeof(tmp_addr4);
781+
} else if (name->sa_family == AF_UNIX) {
782+
ZeroMemory(&tmp_addr4, sizeof(tmp_addr4));
783+
tmp_addr4.sin_family = AF_UNIX;
784+
tmp_addr4.sin_port = 0;
785+
tmp_addr = (SOCKADDR*)&tmp_addr4;
786+
tmp_addr_len = sizeof(tmp_addr4);
781787
} else {
782788
errno = ENOTSUP;
783789
debug3("connectex - ERROR: unsuppored address family:%d, io:%p", name->sa_family, pio);

contrib/win32/win32compat/w32fd.c

+5-11
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,11 @@ w32_socket(int domain, int type, int protocol)
299299
if (min_index == -1)
300300
return -1;
301301

302-
if (domain == AF_UNIX && type == SOCK_STREAM) {
303-
pio = fileio_afunix_socket();
304-
if (pio == NULL)
305-
return -1;
306-
pio->type = NONSOCK_FD;
307-
} else {
308-
pio = socketio_socket(domain, type, protocol);
309-
if (pio == NULL)
310-
return -1;
311-
pio->type = SOCK_FD;
312-
}
302+
pio = socketio_socket(domain, type, protocol);
303+
if (pio == NULL)
304+
return -1;
305+
pio->type = SOCK_FD;
306+
313307

314308
fd_table_set(pio, min_index);
315309
debug4("socket:%d, socktype:%d, io:%p, fd:%d ", pio->sock, type, pio, min_index);

session.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,15 @@ auth_input_request_forwarding(struct ssh *ssh, struct passwd * pw)
198198
/* Temporarily drop privileged uid for mkdir/bind. */
199199
temporarily_use_uid(pw);
200200

201+
#ifdef WINDOWS
202+
/* Allocate a buffer for the socket name, and format the name. */
203+
auth_sock_dir = xstrdup("C:\\tmp\\ssh-XXXXXXXXXX");
204+
205+
#else
201206
/* Allocate a buffer for the socket name, and format the name. */
202207
auth_sock_dir = xstrdup("/tmp/ssh-XXXXXXXXXX");
208+
#endif
209+
203210

204211
/* Create private directory for socket */
205212
if (mkdtemp(auth_sock_dir) == NULL) {
@@ -211,8 +218,13 @@ auth_input_request_forwarding(struct ssh *ssh, struct passwd * pw)
211218
goto authsock_err;
212219
}
213220

221+
#ifdef WINDOWS
222+
xasprintf(&auth_sock_name, "%s\\agent.%ld",
223+
auth_sock_dir, (long)getpid());
224+
#else
214225
xasprintf(&auth_sock_name, "%s/agent.%ld",
215-
auth_sock_dir, (long) getpid());
226+
auth_sock_dir, (long)getpid());
227+
#endif
216228

217229
/* Start a Unix listener on auth_sock_name. */
218230
sock = unix_listener(auth_sock_name, SSH_LISTEN_BACKLOG, 0);

0 commit comments

Comments
 (0)