"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "whois.c" between
whois_5.4.3.tar.xz and whois_5.5.0.tar.xz

About: whois is an improved whois client (searching in a RFC-3912 database)

whois.c  (whois_5.4.3.tar.xz):whois.c  (whois_5.5.0.tar.xz)
/* /*
* Copyright (C) 1999-2018 Marco d'Itri <md@linux.it>. * Copyright (C) 1999-2019 Marco d'Itri <md@linux.it>.
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
*/ */
/* for AI_IDN */ /* for AI_IDN */
#define _GNU_SOURCE #define _GNU_SOURCE
skipping to change at line 162 skipping to change at line 162
err_sys("getline"); err_sys("getline");
fflush(fp); fflush(fp);
/* and use it as command line arguments */ /* and use it as command line arguments */
argv = merge_args(buf, argv, &argc); argv = merge_args(buf, argv, &argc);
} }
/* prepend options from environment */ /* prepend options from environment */
argv = merge_args(getenv("WHOIS_OPTIONS"), argv, &argc); argv = merge_args(getenv("WHOIS_OPTIONS"), argv, &argc);
while ((ch = GETOPT_LONGISH(argc, argv, while ((ch = GETOPT_LONGISH(argc, argv,
"abBcdFg:Gh:Hi:KlLmMp:q:rRs:t:T:v:V:x", "abBcdFg:Gh:Hi:IKlLmMp:q:rRs:t:T:v:V:x",
longopts, &longindex)) > 0) { longopts, &longindex)) > 0) {
/* RIPE flags */ /* RIPE flags */
if (strchr(ripeflags, ch)) { if (strchr(ripeflags, ch)) {
if (strlen(fstring) + 3 > fstringlen) { if (strlen(fstring) + 3 > fstringlen) {
fstringlen += 3; fstringlen += 3;
fstring = realloc(fstring, fstringlen + 1); fstring = realloc(fstring, fstringlen + 1);
} }
sprintf(fstring + strlen(fstring), "-%c ", ch); sprintf(fstring + strlen(fstring), "-%c ", ch);
continue; continue;
} }
skipping to change at line 224 skipping to change at line 224
/* program flags */ /* program flags */
case 'h': case 'h':
server = strdup(optarg); server = strdup(optarg);
break; break;
case 'V': case 'V':
client_tag = optarg; client_tag = optarg;
break; break;
case 'H': case 'H':
hide_discl = HIDE_NOT_STARTED; /* enable disclaimers hiding */ hide_discl = HIDE_NOT_STARTED; /* enable disclaimers hiding */
break; break;
case 'I':
server = strdup("\x0E");
break;
case 'p': case 'p':
port = strdup(optarg); port = strdup(optarg);
break; break;
case 3: case 3:
usage(EXIT_SUCCESS); usage(EXIT_SUCCESS);
case 2: case 2:
verb = 1; verb = 1;
break; break;
case 1: case 1:
fprintf(stdout, _("Version %s.\n\nReport bugs to %s.\n"), fprintf(stdout, _("Version %s.\n\nReport bugs to %s.\n"),
skipping to change at line 375 skipping to change at line 378
free(server); free(server);
server = guess_server(p); server = guess_server(p);
free(p); free(p);
goto retry; goto retry;
case 0x0D: case 0x0D:
p = convert_in6arpa(query); p = convert_in6arpa(query);
free(server); free(server);
server = guess_server(p); server = guess_server(p);
free(p); free(p);
goto retry; goto retry;
case 0x0E:
if (verb)
printf(_("Using server %s.\n"), "whois.iana.org");
sockfd = openconn("whois.iana.org", NULL);
free(server);
server = query_iana(sockfd, query);
break;
default: default:
break; break;
} }
if (!server) if (!server)
return 1; return 1;
if (*server == '\0') if (*server == '\0')
return 0; return 0;
skipping to change at line 924 skipping to change at line 934
err_sys("fgets"); err_sys("fgets");
fclose(fi); fclose(fi);
if (hide > HIDE_NOT_STARTED && hide != HIDE_TO_THE_END) if (hide > HIDE_NOT_STARTED && hide != HIDE_TO_THE_END)
err_quit(_("Catastrophic error: disclaimer text has been changed.\n" err_quit(_("Catastrophic error: disclaimer text has been changed.\n"
"Please upgrade this program.\n")); "Please upgrade this program.\n"));
return referral_server; return referral_server;
} }
char *query_iana(const int sock, const char *query)
{
char *temp, *p, buf[2000];
FILE *fi;
char *referral_server = NULL;
int state = 0;
temp = malloc(strlen(query) + 2 + 1);
strcpy(temp, query);
strcat(temp, "\r\n");
fi = fdopen(sock, "r");
if (write(sock, temp, strlen(temp)) < 0)
err_sys("write");
free(temp);
while (fgets(buf, sizeof(buf), fi)) {
/* If multiple attributes are returned then use the first result.
This is not supposed to happen. */
if (state == 0 && strneq(buf, "refer:", 6)) {
for (p = buf; *p != ':'; p++); /* skip until colon */
for (p++; *p == ' '; p++); /* skip colon and spaces */
referral_server = strdup(p);
if ((p = strpbrk(referral_server, "\r\n ")))
*p = '\0';
state = 2;
}
if ((p = strpbrk(buf, "\r\n")))
*p = '\0';
recode_fputs(buf, stdout);
fputc('\n', stdout);
}
if (ferror(fi))
err_sys("fgets");
fclose(fi);
return referral_server;
}
int openconn(const char *server, const char *port) int openconn(const char *server, const char *port)
{ {
int fd = -1; int fd = -1;
int timeout = 10; int timeout = 10;
#ifdef HAVE_GETADDRINFO #ifdef HAVE_GETADDRINFO
int err; int err;
struct addrinfo hints, *res, *ai; struct addrinfo hints, *res, *ai;
#else #else
struct hostent *hostinfo; struct hostent *hostinfo;
struct servent *servinfo; struct servent *servinfo;
skipping to change at line 1440 skipping to change at line 1491
} }
/* http://www.ripe.net/ripe/docs/databaseref-manual.html */ /* http://www.ripe.net/ripe/docs/databaseref-manual.html */
void NORETURN usage(int error) void NORETURN usage(int error)
{ {
fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _( fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _(
"Usage: whois [OPTION]... OBJECT...\n\n" "Usage: whois [OPTION]... OBJECT...\n\n"
"-h HOST, --host HOST connect to server HOST\n" "-h HOST, --host HOST connect to server HOST\n"
"-p PORT, --port PORT connect to PORT\n" "-p PORT, --port PORT connect to PORT\n"
"-I query whois.iana.org and follow its referral\n"
"-H hide legal disclaimers\n" "-H hide legal disclaimers\n"
));
fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _(
" --verbose explain what is being done\n" " --verbose explain what is being done\n"
" --help display this help and exit\n" " --help display this help and exit\n"
" --version output version information and exit\n" " --version output version information and exit\n"
"\n" "\n"
));
fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _(
"These flags are supported by whois.ripe.net and some RIPE-like servers:\n" "These flags are supported by whois.ripe.net and some RIPE-like servers:\n"
"-l find the one level less specific match\n" "-l find the one level less specific match\n"
"-L find all levels less specific matches\n" "-L find all levels less specific matches\n"
"-m find all one level more specific matches\n" "-m find all one level more specific matches\n"
"-M find all levels of more specific matches\n" "-M find all levels of more specific matches\n"
));
fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _(
"-c find the smallest match containing a mnt-irt attribute\n " "-c find the smallest match containing a mnt-irt attribute\n "
"-x exact match\n" "-x exact match\n"
"-b return brief IP address ranges with abuse contact\n" "-b return brief IP address ranges with abuse contact\n"
));
fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _(
"-B turn off object filtering (show email addresses)\n" "-B turn off object filtering (show email addresses)\n"
"-G turn off grouping of associated objects\n" "-G turn off grouping of associated objects\n"
"-d return DNS reverse delegation objects too\n" "-d return DNS reverse delegation objects too\n"
));
fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _(
"-i ATTR[,ATTR]... do an inverse look-up for specified ATTRibutes\n" "-i ATTR[,ATTR]... do an inverse look-up for specified ATTRibutes\n"
"-T TYPE[,TYPE]... only look for objects of TYPE\n" "-T TYPE[,TYPE]... only look for objects of TYPE\n"
"-K only primary keys are returned\n" "-K only primary keys are returned\n"
"-r turn off recursive look-ups for contact information\n" "-r turn off recursive look-ups for contact information\n"
));
fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _(
"-R force to show local copy of the domain object even\n" "-R force to show local copy of the domain object even\n"
" if it contains referral\n" " if it contains referral\n"
"-a also search all the mirrored databases\n" "-a also search all the mirrored databases\n"
"-s SOURCE[,SOURCE]... search the database mirrored from SOURCE\n" "-s SOURCE[,SOURCE]... search the database mirrored from SOURCE\n"
"-g SOURCE:FIRST-LAST find updates from SOURCE from serial FIRST to LAST\n" "-g SOURCE:FIRST-LAST find updates from SOURCE from serial FIRST to LAST\n"
));
fprintf((EXIT_SUCCESS == error) ? stdout : stderr, _(
"-t TYPE request template for object of TYPE\n" "-t TYPE request template for object of TYPE\n"
"-v TYPE request verbose template for object of TYPE\n" "-v TYPE request verbose template for object of TYPE\n"
"-q [version|sources|types] query specified server info\n" "-q [version|sources|types] query specified server info\n"
)); ));
exit(error); exit(error);
} }
 End of changes. 13 change blocks. 
2 lines changed or deleted 68 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)