mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-09 16:01:19 +01:00
Add -4 and -6 options.
Current getaddrinfo() implemetation has a problem of too much resolving waiting time on INET6 enabled systems. -4 and -6 options can limit name resolving address family and is a possible workaround for the problem. Approved by: jkh
This commit is contained in:
parent
f5abb8467c
commit
1132b408c5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=57232
@ -165,6 +165,7 @@ extern struct cmd cmdtab[];
|
||||
extern FILE *cout;
|
||||
extern int data;
|
||||
extern char *home;
|
||||
extern int family;
|
||||
extern int proxy;
|
||||
extern char reply_string[];
|
||||
extern int NCMDS;
|
||||
|
@ -204,7 +204,7 @@ url_get(origline, proxyenv)
|
||||
port = httpport;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_family = family;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
error = getaddrinfo(host, port, &hints, &res);
|
||||
res0 = res;
|
||||
|
@ -121,7 +121,7 @@ hookup(host0, port)
|
||||
host = hostnamebuf;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_family = family;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_protocol = 0;
|
||||
error = getaddrinfo(host, port, &hints, &res0);
|
||||
|
@ -70,6 +70,8 @@ __RCSID_SOURCE("$NetBSD: main.c,v 1.26 1997/10/14 16:31:22 christos Exp $");
|
||||
#include "ftp_var.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
int family = AF_UNSPEC;
|
||||
|
||||
int main __P((int, char **));
|
||||
|
||||
int
|
||||
@ -151,8 +153,16 @@ main(argc, argv)
|
||||
if (isatty(fileno(stdout)) && !dumbterm)
|
||||
progress = 1; /* progress bar on if tty is usable */
|
||||
|
||||
while ((ch = getopt(argc, argv, "adeginpP:s:tUvV")) != -1) {
|
||||
while ((ch = getopt(argc, argv, "46adeginpP:s:tUvV")) != -1) {
|
||||
switch (ch) {
|
||||
case '4':
|
||||
family = AF_INET;
|
||||
break;
|
||||
#ifdef INET6
|
||||
case '6':
|
||||
family = AF_INET6;
|
||||
break;
|
||||
#endif
|
||||
case 'a':
|
||||
anonftp = 1;
|
||||
break;
|
||||
@ -228,7 +238,7 @@ main(argc, argv)
|
||||
int error;
|
||||
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_family = family;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
error = getaddrinfo(src_addr, NULL, &hints, &res);
|
||||
if (error) {
|
||||
@ -697,7 +707,7 @@ void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: %s [-adeginptUvV] [-P port] [-s src_addr] [host [port]]\n"
|
||||
"usage: %s [-46adeginptUvV] [-P port] [-s src_addr] [host [port]]\n"
|
||||
" %s host:path[/]\n"
|
||||
" %s ftp://host[:port]/path[/]\n"
|
||||
" %s http://host[:port]/file\n",
|
||||
|
@ -95,6 +95,7 @@ char dst_realm_buf[REALM_SZ], *dest_realm = NULL;
|
||||
#endif
|
||||
|
||||
int eight, litout, rem;
|
||||
int family = PF_UNSPEC;
|
||||
|
||||
int noescape;
|
||||
u_char escapechar = '~';
|
||||
@ -176,12 +177,20 @@ main(argc, argv)
|
||||
}
|
||||
|
||||
#ifdef KERBEROS
|
||||
#define OPTIONS "8DEKLde:i:k:l:x"
|
||||
#define OPTIONS "468DEKLde:i:k:l:x"
|
||||
#else
|
||||
#define OPTIONS "8DEKLde:i:l:"
|
||||
#define OPTIONS "468DEKLde:i:l:"
|
||||
#endif
|
||||
while ((ch = getopt(argc - argoff, argv + argoff, OPTIONS)) != -1)
|
||||
switch(ch) {
|
||||
case '4':
|
||||
family = PF_INET;
|
||||
break;
|
||||
|
||||
case '6':
|
||||
family = PF_INET6;
|
||||
break;
|
||||
|
||||
case '8':
|
||||
eight = 1;
|
||||
break;
|
||||
@ -334,10 +343,10 @@ main(argc, argv)
|
||||
errx(1, "the -x flag requires Kerberos authentication");
|
||||
#endif /* CRYPT */
|
||||
rem = rcmd_af(&host, sp->s_port, localname, user, term, 0,
|
||||
PF_UNSPEC);
|
||||
family);
|
||||
}
|
||||
#else
|
||||
rem = rcmd_af(&host, sp->s_port, localname, user, term, 0, PF_UNSPEC);
|
||||
rem = rcmd_af(&host, sp->s_port, localname, user, term, 0, family);
|
||||
#endif /* KERBEROS */
|
||||
|
||||
if (rem < 0)
|
||||
@ -876,7 +885,7 @@ void
|
||||
usage()
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
"usage: rlogin [-%s]%s[-e char] [-i localname] [-l username] host\n",
|
||||
"usage: rlogin [-46%s]%s[-e char] [-i localname] [-l username] host\n",
|
||||
#ifdef KERBEROS
|
||||
#ifdef CRYPT
|
||||
"8DEKLdx", " [-k realm] ");
|
||||
|
@ -85,6 +85,8 @@ extern char *krb_realmofhost();
|
||||
*/
|
||||
int rfd2;
|
||||
|
||||
int family = PF_UNSPEC;
|
||||
|
||||
char *copyargs __P((char **));
|
||||
void sendsig __P((int));
|
||||
void talk __P((int, long, pid_t, int, int));
|
||||
@ -129,15 +131,23 @@ main(argc, argv)
|
||||
|
||||
#ifdef KERBEROS
|
||||
#ifdef CRYPT
|
||||
#define OPTIONS "8KLde:k:l:nt:wx"
|
||||
#define OPTIONS "468KLde:k:l:nt:wx"
|
||||
#else
|
||||
#define OPTIONS "8KLde:k:l:nt:w"
|
||||
#define OPTIONS "468KLde:k:l:nt:w"
|
||||
#endif
|
||||
#else
|
||||
#define OPTIONS "8KLde:l:nt:w"
|
||||
#define OPTIONS "468KLde:l:nt:w"
|
||||
#endif
|
||||
while ((ch = getopt(argc - argoff, argv + argoff, OPTIONS)) != -1)
|
||||
switch(ch) {
|
||||
case '4':
|
||||
family = PF_INET;
|
||||
break;
|
||||
|
||||
case '6':
|
||||
family = PF_INET6;
|
||||
break;
|
||||
|
||||
case 'K':
|
||||
#ifdef KERBEROS
|
||||
use_kerberos = 0;
|
||||
@ -270,11 +280,11 @@ try_connect:
|
||||
if (doencrypt)
|
||||
errx(1, "the -x flag requires Kerberos authentication");
|
||||
rem = rcmd_af(&host, sp->s_port, pw->pw_name, user, args,
|
||||
&rfd2, PF_UNSPEC);
|
||||
&rfd2, family);
|
||||
}
|
||||
#else
|
||||
rem = rcmd_af(&host, sp->s_port, pw->pw_name, user, args, &rfd2,
|
||||
PF_UNSPEC);
|
||||
family);
|
||||
#endif
|
||||
|
||||
if (rem < 0)
|
||||
@ -479,7 +489,7 @@ usage()
|
||||
{
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"usage: rsh [-nd%s]%s[-l login] [-t timeout] host [command]\n",
|
||||
"usage: rsh [-46] [-nd%s]%s[-l login] [-t timeout] host [command]\n",
|
||||
#ifdef KERBEROS
|
||||
#ifdef CRYPT
|
||||
"x", " [-k realm] ");
|
||||
|
Loading…
Reference in New Issue
Block a user