|
Lines 19-24
Link Here
|
| 19 |
#include <openssl/bn.h> |
19 |
#include <openssl/bn.h> |
| 20 |
|
20 |
|
| 21 |
#include <setjmp.h> |
21 |
#include <setjmp.h> |
|
|
22 |
|
| 22 |
#include "xmalloc.h" |
23 |
#include "xmalloc.h" |
| 23 |
#include "ssh.h" |
24 |
#include "ssh.h" |
| 24 |
#include "ssh1.h" |
25 |
#include "ssh1.h" |
|
Lines 391-398
Link Here
|
| 391 |
memset(&hints, 0, sizeof(hints)); |
392 |
memset(&hints, 0, sizeof(hints)); |
| 392 |
hints.ai_family = IPv4or6; |
393 |
hints.ai_family = IPv4or6; |
| 393 |
hints.ai_socktype = SOCK_STREAM; |
394 |
hints.ai_socktype = SOCK_STREAM; |
| 394 |
if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) |
395 |
if ((gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0) { |
| 395 |
fatal("getaddrinfo %s: %s", host, gai_strerror(gaierr)); |
396 |
error("getaddrinfo %s: %s", host, gai_strerror(gaierr)); |
|
|
397 |
return(-1); |
| 398 |
} |
| 396 |
for (ai = aitop; ai; ai = ai->ai_next) { |
399 |
for (ai = aitop; ai; ai = ai->ai_next) { |
| 397 |
s = socket(ai->ai_family, SOCK_STREAM, 0); |
400 |
s = socket(ai->ai_family, SOCK_STREAM, 0); |
| 398 |
if (s < 0) { |
401 |
if (s < 0) { |
|
Lines 685-690
Link Here
|
| 685 |
__progname); |
688 |
__progname); |
| 686 |
fprintf(stderr, "Options:\n"); |
689 |
fprintf(stderr, "Options:\n"); |
| 687 |
fprintf(stderr, " -f file Read hosts or addresses from file.\n"); |
690 |
fprintf(stderr, " -f file Read hosts or addresses from file.\n"); |
|
|
691 |
fprintf(stderr, " -n netgroup Do all hosts or addresses from netgroup.\n"); |
| 688 |
fprintf(stderr, " -p port Connect to the specified port.\n"); |
692 |
fprintf(stderr, " -p port Connect to the specified port.\n"); |
| 689 |
fprintf(stderr, " -t keytype Specify the host key type.\n"); |
693 |
fprintf(stderr, " -t keytype Specify the host key type.\n"); |
| 690 |
fprintf(stderr, " -T timeout Set connection timeout.\n"); |
694 |
fprintf(stderr, " -T timeout Set connection timeout.\n"); |
|
Lines 700-705
Link Here
|
| 700 |
int debug_flag = 0, log_level = SYSLOG_LEVEL_INFO; |
704 |
int debug_flag = 0, log_level = SYSLOG_LEVEL_INFO; |
| 701 |
int opt, fopt_count = 0; |
705 |
int opt, fopt_count = 0; |
| 702 |
char *tname; |
706 |
char *tname; |
|
|
707 |
char *netgroups = NULL; |
| 703 |
|
708 |
|
| 704 |
extern int optind; |
709 |
extern int optind; |
| 705 |
extern char *optarg; |
710 |
extern char *optarg; |
|
Lines 712-718
Link Here
|
| 712 |
if (argc <= 1) |
717 |
if (argc <= 1) |
| 713 |
usage(); |
718 |
usage(); |
| 714 |
|
719 |
|
| 715 |
while ((opt = getopt(argc, argv, "v46p:T:t:f:")) != -1) { |
720 |
while ((opt = getopt(argc, argv, "v46p:T:t:f:n:")) != -1) { |
| 716 |
switch (opt) { |
721 |
switch (opt) { |
| 717 |
case 'p': |
722 |
case 'p': |
| 718 |
ssh_port = a2port(optarg); |
723 |
ssh_port = a2port(optarg); |
|
Lines 762-767
Link Here
|
| 762 |
tname = strtok(NULL, ","); |
767 |
tname = strtok(NULL, ","); |
| 763 |
} |
768 |
} |
| 764 |
break; |
769 |
break; |
|
|
770 |
case 'n': |
| 771 |
netgroups = strdup(optarg); |
| 772 |
if ( netgroups == NULL ) { |
| 773 |
fatal("out of memory"); |
| 774 |
} |
| 775 |
break; |
| 765 |
case '4': |
776 |
case '4': |
| 766 |
IPv4or6 = AF_INET; |
777 |
IPv4or6 = AF_INET; |
| 767 |
break; |
778 |
break; |
|
Lines 773-779
Link Here
|
| 773 |
usage(); |
784 |
usage(); |
| 774 |
} |
785 |
} |
| 775 |
} |
786 |
} |
| 776 |
if (optind == argc && !fopt_count) |
787 |
if (optind == argc && !fopt_count && !netgroups) |
| 777 |
usage(); |
788 |
usage(); |
| 778 |
|
789 |
|
| 779 |
log_init("ssh-keyscan", log_level, SYSLOG_FACILITY_USER, 1); |
790 |
log_init("ssh-keyscan", log_level, SYSLOG_FACILITY_USER, 1); |
|
Lines 793-798
Link Here
|
| 793 |
read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask); |
804 |
read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask); |
| 794 |
read_wait = xmalloc(read_wait_size); |
805 |
read_wait = xmalloc(read_wait_size); |
| 795 |
memset(read_wait, 0, read_wait_size); |
806 |
memset(read_wait, 0, read_wait_size); |
|
|
807 |
|
| 808 |
if (netgroups) { |
| 809 |
char *machine, *user, *domain; |
| 810 |
char *curng = strtok(netgroups, ","); |
| 811 |
while (curng) { |
| 812 |
if (setnetgrent(curng)) { |
| 813 |
error("%s: invalid netgroup \"%s\"", __progname, curng); |
| 814 |
continue; |
| 815 |
} |
| 816 |
while (getnetgrent(&machine, &user, &domain)) { |
| 817 |
if ( machine == NULL ) { |
| 818 |
continue; |
| 819 |
} |
| 820 |
do_host(machine); |
| 821 |
} |
| 822 |
endnetgrent(); |
| 823 |
curng = strtok(NULL, ","); |
| 824 |
} |
| 825 |
free(netgroups); |
| 826 |
netgroups = NULL; |
| 827 |
} |
| 796 |
|
828 |
|
| 797 |
if (fopt_count) { |
829 |
if (fopt_count) { |
| 798 |
Linebuf *lb; |
830 |
Linebuf *lb; |