A feature to allow one to telnet to a unix domain socket.
Obtained from: Lyndon Nerenberg <lyndon@orthanc.ab.ca>
This commit is contained in:
parent
60517fd1f7
commit
a4cc82665c
@ -39,6 +39,7 @@ static char sccsid[] = "@(#)commands.c 8.2 (Berkeley) 12/15/93";
|
|||||||
|
|
||||||
#if defined(unix)
|
#if defined(unix)
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/un.h>
|
||||||
#if defined(CRAY) || defined(sysV88)
|
#if defined(CRAY) || defined(sysV88)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
@ -2109,6 +2110,9 @@ sockaddr_ntop(sa)
|
|||||||
case AF_INET:
|
case AF_INET:
|
||||||
addr = &((struct sockaddr_in *)sa)->sin_addr;
|
addr = &((struct sockaddr_in *)sa)->sin_addr;
|
||||||
break;
|
break;
|
||||||
|
case AF_UNIX:
|
||||||
|
addr = &((struct sockaddr_un *)sa)->sun_path;
|
||||||
|
break;
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
addr = &((struct sockaddr_in6 *)sa)->sin6_addr;
|
addr = &((struct sockaddr_in6 *)sa)->sin6_addr;
|
||||||
@ -2267,7 +2271,30 @@ tn(argc, argv)
|
|||||||
}
|
}
|
||||||
src_res0 = src_res;
|
src_res0 = src_res;
|
||||||
}
|
}
|
||||||
if (hostp[0] == '@' || hostp[0] == '!') {
|
if (hostp[0] == '/') {
|
||||||
|
struct sockaddr_un su;
|
||||||
|
|
||||||
|
if (strlen(hostp) >= sizeof(su.sun_path)) {
|
||||||
|
fprintf(stderr, "hostname too long for unix domain socket: %s",
|
||||||
|
hostp);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
memset(&su, 0, sizeof su);
|
||||||
|
su.sun_family = AF_UNIX;
|
||||||
|
strncpy(su.sun_path, hostp, sizeof su.sun_path);
|
||||||
|
printf("Trying %s...\n", &su.sun_path);
|
||||||
|
net = socket(PF_UNIX, SOCK_STREAM, 0);
|
||||||
|
if ( net < 0) {
|
||||||
|
perror("socket");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
if (connect(net, (struct sockaddr *)&su, sizeof su) == -1) {
|
||||||
|
perror(su.sun_path);
|
||||||
|
(void) NetClose(net);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
goto af_unix;
|
||||||
|
} else if (hostp[0] == '@' || hostp[0] == '!') {
|
||||||
if (
|
if (
|
||||||
#ifdef INET6
|
#ifdef INET6
|
||||||
family == AF_INET6 ||
|
family == AF_INET6 ||
|
||||||
@ -2450,6 +2477,7 @@ tn(argc, argv)
|
|||||||
if (src_res0 != NULL)
|
if (src_res0 != NULL)
|
||||||
freeaddrinfo(src_res0);
|
freeaddrinfo(src_res0);
|
||||||
cmdrc(hostp, hostname);
|
cmdrc(hostp, hostname);
|
||||||
|
af_unix:
|
||||||
if (autologin && user == NULL) {
|
if (autologin && user == NULL) {
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
|
@ -157,11 +157,14 @@ main(argc, argv)
|
|||||||
#define IPSECOPT
|
#define IPSECOPT
|
||||||
#endif
|
#endif
|
||||||
while ((ch = getopt(argc, argv,
|
while ((ch = getopt(argc, argv,
|
||||||
"468EKLNS:X:acde:fFk:l:n:rs:t:x" IPSECOPT)) != -1)
|
"468EKLNS:X:acde:fFk:l:n:rs:t:ux" IPSECOPT)) != -1)
|
||||||
#undef IPSECOPT
|
#undef IPSECOPT
|
||||||
{
|
{
|
||||||
|
|
||||||
switch(ch) {
|
switch(ch) {
|
||||||
|
case 'u':
|
||||||
|
family = AF_UNIX;
|
||||||
|
break;
|
||||||
case '4':
|
case '4':
|
||||||
family = AF_INET;
|
family = AF_INET;
|
||||||
break;
|
break;
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
protocol
|
protocol
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl 468EFKLNacdfrx
|
.Op Fl u468EFKLNacdfrx
|
||||||
.Op Fl S Ar tos
|
.Op Fl S Ar tos
|
||||||
.Op Fl X Ar authtype
|
.Op Fl X Ar authtype
|
||||||
.Op Fl e Ar escapechar
|
.Op Fl e Ar escapechar
|
||||||
@ -75,6 +75,11 @@ command with those arguments.
|
|||||||
.Pp
|
.Pp
|
||||||
Options:
|
Options:
|
||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
|
.It Fl u
|
||||||
|
Forces
|
||||||
|
.Nm
|
||||||
|
to use
|
||||||
|
AF_UNIX addresses only (e.g. unix domain sockets, accessed with a file path)
|
||||||
.It Fl 4
|
.It Fl 4
|
||||||
Forces
|
Forces
|
||||||
.Nm
|
.Nm
|
||||||
@ -205,7 +210,11 @@ option is not available outside of the United States and
|
|||||||
Canada.
|
Canada.
|
||||||
.It Ar host
|
.It Ar host
|
||||||
Indicates the official name, an alias, or the Internet address
|
Indicates the official name, an alias, or the Internet address
|
||||||
of a remote host.
|
of a remote host. If
|
||||||
|
.Ar host
|
||||||
|
starts with a /,
|
||||||
|
.Nm
|
||||||
|
establishes a connection to the corresponding named socket.
|
||||||
.It Ar port
|
.It Ar port
|
||||||
Indicates a port number (address of an application). If a number is
|
Indicates a port number (address of an application). If a number is
|
||||||
not specified, the default
|
not specified, the default
|
||||||
|
Loading…
Reference in New Issue
Block a user