@@ -300,12 +300,6 @@ w32_socket(int domain, int type, int protocol)
300
300
if (min_index == -1 )
301
301
return -1 ;
302
302
303
- #ifdef HAVE_AFUNIX_H
304
- pio = socketio_socket (domain , type , protocol );
305
- if (pio == NULL )
306
- return -1 ;
307
- pio -> type = SOCK_FD ;
308
- #else
309
303
if (domain == AF_UNIX && type == SOCK_STREAM ) {
310
304
pio = fileio_afunix_socket ();
311
305
if (pio == NULL )
@@ -317,7 +311,65 @@ w32_socket(int domain, int type, int protocol)
317
311
return -1 ;
318
312
pio -> type = SOCK_FD ;
319
313
}
314
+
315
+ fd_table_set (pio , min_index );
316
+ debug4 ("socket:%d, socktype:%d, io:%p, fd:%d " , pio -> sock , type , pio , min_index );
317
+ return min_index ;
318
+ }
319
+
320
+ int
321
+ w32_afunix_socket (struct sockaddr_un * addr )
322
+ {
323
+ #ifdef HAVE_AFUNIX_H
324
+ /*
325
+ If HAVE_AFUNIX_H is defined, we can be dealing with the ssh-agent named pipe or
326
+ a AF_UNIX socket if ssh forwarding is enabled. If the addr->sun_path is the
327
+ the well known named pipe, we open the socket with w32_fileio.
328
+ */
329
+ if (strcmp (addr -> sun_path , "\\\\.\\pipe\\openssh-ssh-agent" ) == 0 )
330
+ return w32_fileio_socket (SOCK_STREAM , 0 );
331
+ else
332
+ return w32_unix_socket (SOCK_STREAM , 0 );
333
+ #else
334
+ return w32_socket (AF_UNIX , SOCK_STREAM , 0 );
320
335
#endif
336
+ }
337
+
338
+ int
339
+ w32_unix_socket (int type , int protocol )
340
+ {
341
+ int domain = AF_UNIX ;
342
+ int min_index = fd_table_get_min_index ();
343
+ struct w32_io * pio = NULL ;
344
+
345
+ errno = 0 ;
346
+ if (min_index == -1 )
347
+ return -1 ;
348
+
349
+ pio = socketio_socket (domain , type , protocol );
350
+ if (pio == NULL )
351
+ return -1 ;
352
+ pio -> type = SOCK_FD ;
353
+
354
+ fd_table_set (pio , min_index );
355
+ debug4 ("socket:%d, socktype:%d, io:%p, fd:%d " , pio -> sock , type , pio , min_index );
356
+ return min_index ;
357
+ }
358
+
359
+ int
360
+ w32_fileio_socket (int type , int protocol )
361
+ {
362
+ int min_index = fd_table_get_min_index ();
363
+ struct w32_io * pio = NULL ;
364
+
365
+ errno = 0 ;
366
+ if (min_index == -1 )
367
+ return -1 ;
368
+
369
+ pio = fileio_afunix_socket ();
370
+ if (pio == NULL )
371
+ return -1 ;
372
+ pio -> type = NONSOCK_FD ;
321
373
322
374
fd_table_set (pio , min_index );
323
375
debug4 ("socket:%d, socktype:%d, io:%p, fd:%d " , pio -> sock , type , pio , min_index );
0 commit comments