|
Lines 14-19
RCSID("$OpenBSD: ssh-keyscan.c,v 1.35 20
Link Here
|
| 14 |
#include <openssl/bn.h> |
14 |
#include <openssl/bn.h> |
| 15 |
|
15 |
|
| 16 |
#include <setjmp.h> |
16 |
#include <setjmp.h> |
|
|
17 |
|
| 17 |
#include "xmalloc.h" |
18 |
#include "xmalloc.h" |
| 18 |
#include "ssh.h" |
19 |
#include "ssh.h" |
| 19 |
#include "ssh1.h" |
20 |
#include "ssh1.h" |
|
Lines 386-393
tcpconnect(char *host)
Link Here
|
| 386 |
memset(&hints, 0, sizeof(hints)); |
387 |
memset(&hints, 0, sizeof(hints)); |
| 387 |
hints.ai_family = IPv4or6; |
388 |
hints.ai_family = IPv4or6; |
| 388 |
hints.ai_socktype = SOCK_STREAM; |
389 |
hints.ai_socktype = SOCK_STREAM; |
| 389 |
if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) |
390 |
if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) { |
| 390 |
fatal("getaddrinfo %s: %s", host, gai_strerror(gaierr)); |
391 |
error("getaddrinfo %s: %s", host, gai_strerror(gaierr)); |
|
|
392 |
return (-1); |
| 393 |
} |
| 391 |
for (ai = aitop; ai; ai = ai->ai_next) { |
394 |
for (ai = aitop; ai; ai = ai->ai_next) { |
| 392 |
s = socket(ai->ai_family, SOCK_STREAM, 0); |
395 |
s = socket(ai->ai_family, SOCK_STREAM, 0); |
| 393 |
if (s < 0) { |
396 |
if (s < 0) { |
|
Lines 680-685
usage(void)
Link Here
|
| 680 |
__progname); |
683 |
__progname); |
| 681 |
fprintf(stderr, "Options:\n"); |
684 |
fprintf(stderr, "Options:\n"); |
| 682 |
fprintf(stderr, " -f file Read hosts or addresses from file.\n"); |
685 |
fprintf(stderr, " -f file Read hosts or addresses from file.\n"); |
|
|
686 |
fprintf(stderr, " -n netgroup Do all hosts or addresses from netgroup.\n"); |
| 683 |
fprintf(stderr, " -p port Connect to the specified port.\n"); |
687 |
fprintf(stderr, " -p port Connect to the specified port.\n"); |
| 684 |
fprintf(stderr, " -t keytype Specify the host key type.\n"); |
688 |
fprintf(stderr, " -t keytype Specify the host key type.\n"); |
| 685 |
fprintf(stderr, " -T timeout Set connection timeout.\n"); |
689 |
fprintf(stderr, " -T timeout Set connection timeout.\n"); |
|
Lines 695-700
main(int argc, char **argv)
Link Here
|
| 695 |
int debug_flag = 0, log_level = SYSLOG_LEVEL_INFO; |
699 |
int debug_flag = 0, log_level = SYSLOG_LEVEL_INFO; |
| 696 |
int opt, fopt_count = 0; |
700 |
int opt, fopt_count = 0; |
| 697 |
char *tname; |
701 |
char *tname; |
|
|
702 |
char *netgroups = NULL; |
| 698 |
|
703 |
|
| 699 |
extern int optind; |
704 |
extern int optind; |
| 700 |
extern char *optarg; |
705 |
extern char *optarg; |
|
Lines 707-713
main(int argc, char **argv)
Link Here
|
| 707 |
if (argc <= 1) |
712 |
if (argc <= 1) |
| 708 |
usage(); |
713 |
usage(); |
| 709 |
|
714 |
|
| 710 |
while ((opt = getopt(argc, argv, "v46p:T:t:f:")) != -1) { |
715 |
while ((opt = getopt(argc, argv, "v46p:T:t:f:n:")) != -1) { |
| 711 |
switch (opt) { |
716 |
switch (opt) { |
| 712 |
case 'p': |
717 |
case 'p': |
| 713 |
ssh_port = a2port(optarg); |
718 |
ssh_port = a2port(optarg); |
|
Lines 757-762
main(int argc, char **argv)
Link Here
|
| 757 |
tname = strtok(NULL, ","); |
762 |
tname = strtok(NULL, ","); |
| 758 |
} |
763 |
} |
| 759 |
break; |
764 |
break; |
|
|
765 |
case 'n': |
| 766 |
netgroups = xstrdup(optarg); |
| 767 |
break; |
| 760 |
case '4': |
768 |
case '4': |
| 761 |
IPv4or6 = AF_INET; |
769 |
IPv4or6 = AF_INET; |
| 762 |
break; |
770 |
break; |
|
Lines 768-774
main(int argc, char **argv)
Link Here
|
| 768 |
usage(); |
776 |
usage(); |
| 769 |
} |
777 |
} |
| 770 |
} |
778 |
} |
| 771 |
if (optind == argc && !fopt_count) |
779 |
if (optind == argc && !fopt_count && !netgroups) |
| 772 |
usage(); |
780 |
usage(); |
| 773 |
|
781 |
|
| 774 |
log_init("ssh-keyscan", log_level, SYSLOG_FACILITY_USER, 1); |
782 |
log_init("ssh-keyscan", log_level, SYSLOG_FACILITY_USER, 1); |
|
Lines 788-793
main(int argc, char **argv)
Link Here
|
| 788 |
read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask); |
796 |
read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask); |
| 789 |
read_wait = xmalloc(read_wait_size); |
797 |
read_wait = xmalloc(read_wait_size); |
| 790 |
memset(read_wait, 0, read_wait_size); |
798 |
memset(read_wait, 0, read_wait_size); |
|
|
799 |
|
| 800 |
if (netgroups) { |
| 801 |
char *machine, *user, *domain, *curng; |
| 802 |
char *token = netgroups; |
| 803 |
while ( (curng = strtok(token, ",")) ) { |
| 804 |
if (setnetgrent(curng)) { |
| 805 |
while (getnetgrent(&machine, &user, &domain)) |
| 806 |
if (machine) |
| 807 |
do_host(machine); |
| 808 |
endnetgrent(); |
| 809 |
} |
| 810 |
else |
| 811 |
error("%s: invalid netgroup \"%s\"", __progname, curng); |
| 812 |
|
| 813 |
token = NULL; |
| 814 |
} |
| 815 |
} |
| 791 |
|
816 |
|
| 792 |
if (fopt_count) { |
817 |
if (fopt_count) { |
| 793 |
Linebuf *lb; |
818 |
Linebuf *lb; |