diff --git a/ncat/docs/ncat.xml b/ncat/docs/ncat.xml index 7ecb0d659..fd8cd8301 100644 --- a/ncat/docs/ncat.xml +++ b/ncat/docs/ncat.xml @@ -767,11 +767,8 @@ Both stream and datagram domain sockets are supported. Use on its own for stream sockets, or combine it with for datagram sockets. - Datagram sockets require a source socket to connect from. By - default, a source socket with a random filename will be created as - needed, and deleted when the program ends. Use the - with a path to use a source socket with a - specific name. + Datagram sockets require the use of the + option to specify a source socket to connect from. diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c index 3c05d3809..fd331dad0 100644 --- a/ncat/ncat_connect.c +++ b/ncat/ncat_connect.c @@ -538,23 +538,11 @@ int ncat_connect(void) /* For DGRAM UNIX socket we have to use source socket */ if (o.af == AF_UNIX && o.udp) { - if (srcaddr.storage.ss_family == AF_UNIX) { - nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage, SUN_LEN((struct sockaddr_un *)&srcaddr.storage)); - } else { - char *tmp_name = NULL; - /* If no source socket was specified, we have to create temporary one. */ - if ((tmp_name = tempnam(NULL, "ncat.")) == NULL) - bye("Failed to create name for temporary DGRAM source Unix domain socket (tempnam)."); - - srcaddr.un.sun_family = AF_UNIX; - strncpy(srcaddr.un.sun_path, tmp_name, sizeof(srcaddr.un.sun_path)); - free (tmp_name); - - nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage, SUN_LEN((struct sockaddr_un *)&srcaddr.storage)); + if (srcaddr.storage.ss_family != AF_UNIX) { + bye("A source socket filename (--source) is required when using\n" + "Unix domain sockets in --udp mode."); } - - if (o.verbose) - loguser("[%s] used as source DGRAM Unix domain socket.\n", srcaddr.un.sun_path); + nsi_set_localaddr(cs.sock_nsi, &srcaddr.storage, SUN_LEN((struct sockaddr_un *)&srcaddr.storage)); } else #endif @@ -707,11 +695,6 @@ int ncat_connect(void) nsi_get_read_count(cs.sock_nsi), time); } -#if HAVE_SYS_UN_H - if (o.af == AF_UNIX && o.udp) - unlink(srcaddr.un.sun_path); -#endif - nsp_delete(mypool); return rc == NSOCK_LOOP_ERROR ? 1 : 0; diff --git a/ncat/test/ncat-test.pl b/ncat/test/ncat-test.pl index df52af74d..25f1e7481 100755 --- a/ncat/test/ncat-test.pl +++ b/ncat/test/ncat-test.pl @@ -548,20 +548,6 @@ sub { kill_children; unlink($UNIXSOCK); -($s_pid, $s_out, $s_in) = ncat("-l", "-U", "--udp", $UNIXSOCK); -test "Server UNIX socket listen on $UNIXSOCK --udp (DGRAM)", -sub { - my $resp; - - unlink($UNIXSOCK); - my ($c_pid, $c_out, $c_in) = ncat("-U", "--udp", $UNIXSOCK); - syswrite($c_in, "abc\n"); - $resp = timeout_read($s_out); - $resp eq "abc\n" or die "Server got \"$resp\", not \"abc\\n\" from client"; -}; -kill_children; -unlink($UNIXSOCK); - server_client_test "Connect success exit code", [], ["--send-only"], sub {