diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.sbin/Makefile | 13 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.sbin/gettable.c | 189 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.sbin/htable/Makefile | 60 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.sbin/htable/htable.c | 644 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.sbin/htable/htable.h | 74 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.sbin/htable/parse.y | 165 | ||||
-rw-r--r-- | usr/src/cmd/cmd-inet/usr.sbin/htable/scan.l | 110 | ||||
-rw-r--r-- | usr/src/man/man1m/Makefile | 2 | ||||
-rw-r--r-- | usr/src/man/man1m/gettable.1m | 41 | ||||
-rw-r--r-- | usr/src/man/man1m/htable.1m | 75 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-network-nis.mf | 5 |
11 files changed, 8 insertions, 1370 deletions
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/Makefile index de4e8236d9..deb6016891 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sbin/Makefile @@ -21,12 +21,13 @@ # # Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # SYNCPROG= syncinit syncloop syncstat DHCPPROG= dhcpconfig dhtadm pntadm -PROG= 6to4relay arp gettable if_mpadm \ +PROG= 6to4relay arp if_mpadm \ in.comsat in.fingerd in.rarpd in.rexecd in.rlogind \ in.rshd in.rwhod in.telnetd in.tftpd ipaddrsel \ ndd $(SYNCPROG) $(DHCPPROG) wanbootutil @@ -41,10 +42,10 @@ SBINLINKS= hostconfig route RPCSVCPROG= hostconfig AUDITPROG= in.rexecd in.rlogind in.rshd in.telnetd PAMPROG= in.rexecd in.rlogind in.rshd in.telnetd -SOCKETPROG= 6to4relay arp gettable hostconfig if_mpadm in.comsat \ +SOCKETPROG= 6to4relay arp hostconfig if_mpadm in.comsat \ in.fingerd in.rarpd in.rexecd in.rlogind in.rshd \ in.rwhod in.telnetd in.tftpd ipaddrsel route -NSLPROG= 6to4relay arp gettable hostconfig in.comsat in.rarpd \ +NSLPROG= 6to4relay arp hostconfig in.comsat in.rarpd \ in.rexecd in.rlogind in.rshd in.rwhod in.telnetd \ in.tftpd ipaddrsel route CMDPROG= in.telnetd @@ -61,12 +62,12 @@ K5RSHDOBJS= in.rshd.o K5TELNETOBJS= in.telnetd.o SRCS= $(PROGSRCS) $(OTHERSRC) -SUBDIRS= bootconfchk htable ifconfig ilbadm in.rdisc in.routed \ +SUBDIRS= bootconfchk ifconfig ilbadm in.rdisc in.routed \ in.talkd inetadm inetconv ipadm ipmpstat ipqosconf ipsecutils \ kssl/kssladm kssl/ksslcfg nwamadm nwamcfg ping routeadm \ snoop sppptun traceroute wificonfig -MSGSUBDIRS= bootconfchk htable ifconfig ilbadm in.routed in.talkd \ +MSGSUBDIRS= bootconfchk ifconfig ilbadm in.routed in.talkd \ inetadm inetconv ipadm ipmpstat ipqosconf ipsecutils \ kssl/ksslcfg nwamadm nwamcfg routeadm sppptun snoop wificonfig @@ -160,7 +161,7 @@ if_mpadm := LDLIBS += -linetutil -lipmp if_mpadm.po := XGETFLAGS += -a route := CPPFLAGS += -DNDEBUG ndd := LDLIBS += -ldladm -lipadm -gettable in.comsat := LDFLAGS += $(MAPFILE.NGB:%=-M%) +in.comsat := LDFLAGS += $(MAPFILE.NGB:%=-M%) .KEEP_STATE: diff --git a/usr/src/cmd/cmd-inet/usr.sbin/gettable.c b/usr/src/cmd/cmd-inet/usr.sbin/gettable.c deleted file mode 100644 index 9562d1a599..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/gettable.c +++ /dev/null @@ -1,189 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> -#include <sys/socket.h> - -#include <netinet/in.h> - -#include <stdio.h> -#include <netdb.h> - -#define OUTFILE "hosts.txt" /* default output file */ -#define VERFILE "hosts.ver" /* default version file */ -#define QUERY "ALL\r\n" /* query to hostname server */ -#define VERSION "VERSION\r\n" /* get version number */ - -#define equaln(s1, s2, n) (!strncmp(s1, s2, n)) - -#ifdef SYSV -#define bcopy(a,b,c) memcpy(b,a,c) -#endif - -struct sockaddr_in sin; -struct sockaddr_in sintmp; -char buf[BUFSIZ]; -char *outfile = OUTFILE; - -int -main(argc, argv) - int argc; - char *argv[]; -{ - int s; - register int len; - register FILE *sfi, *sfo, *hf; - char *host; - register struct hostent *hp; - struct servent *sp; - int version = 0; - int beginseen = 0; - int endseen = 0; - - argv++, argc--; - if (argc > 0 && **argv == '-') { - if (argv[0][1] != 'v') - fprintf(stderr, "unknown option %s ignored\n", *argv); - else - version++, outfile = VERFILE; - argv++, argc--; - } - if (argc < 1 || argc > 2) { - fprintf(stderr, "usage: gettable [-v] host [ file ]\n"); - exit(1); - } - sp = getservbyname("hostnames", "tcp"); - if (sp == NULL) { - fprintf(stderr, "gettable: hostnames/tcp: unknown service\n"); - exit(3); - } - host = *argv; - argv++, argc--; - sintmp.sin_addr.s_addr = inet_addr(host); - if (sintmp.sin_addr.s_addr != -1 && sintmp.sin_addr.s_addr != 0) { - sin.sin_family = AF_INET; - } else { - hp = gethostbyname(host); - if (hp == NULL) { - fprintf(stderr, "gettable: %s: host unknown\n", host); - exit(2); - } else { - sin.sin_family = hp->h_addrtype; - host = hp->h_name; - } - } - if (argc > 0) - outfile = *argv; - s = socket(sin.sin_family, SOCK_STREAM, 0); - if (s < 0) { - perror("gettable: socket"); - exit(4); - } - if (bind(s, (struct sockaddr *)&sin, sizeof (sin)) < 0) { - perror("gettable: bind"); - exit(5); - } - if (sintmp.sin_addr.s_addr != -1 && sintmp.sin_addr.s_addr != 0) - bcopy((char *)&sintmp.sin_addr, (char *)&sin.sin_addr, - sizeof(sintmp.sin_addr)); - else - bcopy(hp->h_addr, (char *)&sin.sin_addr, hp->h_length); - sin.sin_port = sp->s_port; - if (connect(s, (struct sockaddr *)&sin, sizeof (sin)) < 0) { - perror("gettable: connect"); - exit(6); - } - fprintf(stderr, "Connection to %s opened.\n", host); - sfi = fdopen(s, "r"); - sfo = fdopen(s, "w"); - if (sfi == NULL || sfo == NULL) { - perror("gettable: fdopen"); - close(s); - exit(1); - } - hf = fopen(outfile, "w"); - if (hf == NULL) { - fprintf(stderr, "gettable: "); perror(outfile); - close(s); - exit(1); - } - fprintf(sfo, version ? VERSION : QUERY); - fflush(sfo); - while (fgets(buf, sizeof(buf), sfi) != NULL) { - len = strlen(buf); - buf[len-2] = '\0'; - if (!version && equaln(buf, "BEGIN", 5)) { - if (beginseen || endseen) { - fprintf(stderr, - "gettable: BEGIN sequence error\n"); - exit(90); - } - beginseen++; - continue; - } - if (!version && equaln(buf, "END", 3)) { - if (!beginseen || endseen) { - fprintf(stderr, - "gettable: END sequence error\n"); - exit(91); - } - endseen++; - continue; - } - if (equaln(buf, "ERR", 3)) { - fprintf(stderr, - "gettable: hostname service error: %s", buf); - exit(92); - } - fprintf(hf, "%s\n", buf); - } - fclose(hf); - if (!version) { - if (!beginseen) { - fprintf(stderr, "gettable: no BEGIN seen\n"); - exit(93); - } - if (!endseen) { - fprintf(stderr, "gettable: no END seen\n"); - exit(94); - } - fprintf(stderr, "Host table received.\n"); - } else - fprintf(stderr, "Version number received.\n"); - close(s); - fprintf(stderr, "Connection to %s closed\n", host); - return (0); -} diff --git a/usr/src/cmd/cmd-inet/usr.sbin/htable/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/htable/Makefile deleted file mode 100644 index ca3917bdac..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/htable/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright (c) 1989 by Sun Microsystems, Inc. -# - -PROG= htable -OBJS= htable.o parse.o scan.o -SRCS= htable.c parse.y scan.l - -include ../../../Makefile.cmd - -CPPFLAGS += -DSYSV -DSTRNET -DBSD_COMP -LDLIBS += -lsocket -lnsl -YFLAGS += -d - -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += -_gcc=-Wno-implicit-function-declaration -CERRWARN += -_gcc=-Wno-unused-label -CERRWARN += -_gcc=-Wno-unused-variable - -.KEEP_STATE: - -all: $(PROG) - -$(PROG): $(OBJS) - $(LINK.c) $(OBJS) -o $@ $(LDLIBS) - $(POST_PROCESS) - -install: all $(ROOTUSRSBINPROG) - -clean: - $(RM) $(OBJS) y.tab.h y.tab.c parse.c scan.c - -lint: lint_PROG - -include ../../../Makefile.targ - -# explicit target for the NSE -y.tab.h: parse.y - $(YACC.y) $? diff --git a/usr/src/cmd/cmd-inet/usr.sbin/htable/htable.c b/usr/src/cmd/cmd-inet/usr.sbin/htable/htable.c deleted file mode 100644 index 6136570431..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/htable/htable.c +++ /dev/null @@ -1,644 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * htable - convert NIC host table into a UNIX format. - * DoD Internet host table format is specified in RFC 952, October 1985 - */ -#include <stdio.h> -#include <ctype.h> -#include <errno.h> -#include <netdb.h> - -#include "htable.h" /* includes <sys/types.h> */ - -#include <sys/socket.h> -#include <arpa/inet.h> - -#define DATELINES 3 /* these lines usually contain the date */ -#define MAXNETS 30 /* array size for local, connected nets */ - -FILE *hf; /* hosts file */ -FILE *gf; /* gateways file */ -FILE *nf; /* networks file */ -struct gateway *savegateway(), *gatewayto(); - -int connected_nets[MAXNETS]; -int nconnected; -int local_nets[MAXNETS]; -int nlocal; -char *myname; - -static void dogateways(void); -static void freeaddrs(struct addr *list); -static void freenames(struct name *list); -static void putaddr(FILE *f, struct in_addr v); -static void putnet(FILE *f, int v); -static void copycomments(FILE *in, FILE *out, int ccount); -static void copygateways(char *filename); -static void copylocal(FILE *f, char *filename); -static void printgateway(int net, char *name, int metric); -static void usage(void); -static int addlocal(char *arg, int *nets); -static int getnetaddr(char *name, int *addr); -static int gethostaddr(char *name, u_long *addr); -static int connectedto(int net); -static int local(int net); - -int -main(argc, argv) - int argc; - char *argv[]; -{ - int errs; - - infile = "(stdin)"; - myname = argv[0]; - argc--; - argv++; - while (argc--) { - if (*argv[0] == '-') { - switch (argv[0][1]) { - case 'c': - nconnected = addlocal(argv[1], connected_nets); - argv++; - argc--; - break; - case 'l': - nlocal = addlocal(argv[1], local_nets); - argv++; - argc--; - break; - default: - usage(); - /*NOTREACHED*/ - } - } else { - infile = argv[0]; - if (freopen(infile, "r", stdin) == NULL) { - perror(infile); - exit(1); - } - } - argv++; - } - hf = fopen("hosts", "w"); - if (hf == NULL) { - perror("hosts"); - exit(1); - } - copylocal(hf, "localhosts"); - gf = fopen("gateways", "w"); - if (gf == NULL) { - perror("gateways"); - exit(1); - } - copygateways("localgateways"); - nf = fopen("networks", "w"); - if (nf == NULL) { - perror("networks"); - exit(1); - } - copylocal(nf, "localnetworks"); - copycomments(stdin, hf, DATELINES); - errs = yyparse(); - dogateways(); - return (errs); -} - -static void -usage() -{ - fprintf(stderr, - "usage: %s [ -c connected-nets ] [-l local-nets ] [ input-file ]\n", - myname); - exit(1); -} - -/* - * Turn a comma-separated list of network names or numbers in dot notation - * (e.g. "arpanet, 128.32") into an array of net numbers. - */ -static int -addlocal(arg, nets) - char *arg; - int *nets; -{ - register char *p, c; - register int nfound = 0; - - do { - p = arg; - while (*p && *p != ',' && !isspace(*p)) - p++; - c = *p; - *p = 0; - while (*arg && isspace(*arg)) - arg++; - if (*arg == 0) - continue; - if (nfound == MAXNETS) { - fprintf(stderr, "%s: Too many networks in list\n", - myname); - return (nfound); - } - if (getnetaddr(arg, &nets[nfound])) - nfound++; - else { - fprintf(stderr, "%s: %s: unknown network\n", - myname, arg); - exit(1); - } - arg = p + 1; - } while (c); - return (nfound); -} - -struct name * -newname(str) - char *str; -{ - char *p; - struct name *nm; - - p = malloc(strlen(str) + 1); - strcpy(p, str); - nm = (struct name *)malloc(sizeof (struct name)); - nm->name_val = p; - nm->name_link = NONAME; - return (nm); -} - -char * -lower(str) - char *str; -{ - register char *cp = str; - - while (*cp) { - if (isupper(*cp)) - *cp = tolower(*cp); - cp++; - } - return (str); -} - -void -do_entry(keyword, addrlist, namelist, cputype, opsys, protos) - int keyword; - struct addr *addrlist; - struct name *namelist, *cputype, *opsys, *protos; -{ - register struct addr *al, *al2; - register struct name *nl; - struct addr *connect_addr; - char *cp; - - switch (keyword) { - - case KW_NET: - nl = namelist; - if (nl == NONAME) { - fprintf(stderr, "htable: net "); - putnet(stderr, inet_netof(addrlist->addr_val)); - fprintf(stderr, " missing names.\n"); - break; - } - fprintf(nf, "%-16s ", lower(nl->name_val)); - al2 = addrlist; - while (al = al2) { - char *cp; - - putnet(nf, inet_netof(al->addr_val)); - cp = "\t%s"; - while (nl = nl->name_link) { - fprintf(nf, cp, lower(nl->name_val)); - cp = " %s"; - } - putc('\n', nf); - al2 = al->addr_link; - free((char *)al); - } - break; - - case KW_GATEWAY: - /* locate locally connected address, if one */ - for (al = addrlist; al; al = al->addr_link) - if (connectedto(inet_netof(al->addr_val))) - break; - if (al == NULL) { - /* - * Not connected to known networks. Save for later. - */ - struct gateway *gw, *firstgw = (struct gateway *) NULL; - - for (al = addrlist; al; al = al->addr_link) { - register int net; - - net = inet_netof(al->addr_val); - gw = savegateway(namelist, net, - al->addr_val, 0); - if (firstgw == (struct gateway *) NULL) - firstgw = gw; - gw->g_firstent = firstgw; - } - freeaddrs(addrlist); - goto dontfree; - } - /* - * Connected to a known network. - * Mark this as the gateway to all other networks - * that are on the addrlist (unless we already have - * gateways to them). - */ - connect_addr = al; - for (al = addrlist; al; al = al->addr_link) { - register int net; - - /* suppress duplicates -- not optimal */ - net = inet_netof(al->addr_val); - if (connectedto(net) || gatewayto(net)) - continue; - printgateway(net, namelist->name_val, 1); - (void) savegateway(namelist, net, al->addr_val, 1); - } - /* - * Put the gateway in the hosts file. - */ - putaddr(hf, connect_addr->addr_val); - cp = "%s"; - for (nl = namelist; nl; nl = nl->name_link) { - fprintf(hf, cp, lower(nl->name_val)); - cp = " %s"; - } - fprintf(hf, "\t# gateway\n"); - freeaddrs(addrlist); - goto dontfree; - - case KW_HOST: - al2 = addrlist; - while (al = al2) { - if (!local(inet_netof(al->addr_val))) { - char *cp; - - putaddr(hf, al->addr_val); - cp = "%s"; - for (nl = namelist; nl; nl = nl->name_link) { - fprintf(hf, cp, lower(nl->name_val)); - cp = " %s"; - } - putc('\n', hf); - } - al2 = al->addr_link; - free((char *)al); - } - break; - - default: - fprintf(stderr, "Unknown keyword: %d.\n", keyword); - } - freenames(namelist); -dontfree: - freenames(protos); -} - -static void -printgateway(net, name, metric) - int net; - char *name; - int metric; -{ - struct netent *np; - - fprintf(gf, "net "); - np = getnetbyaddr(net, AF_INET); - if (np) - fprintf(gf, "%s", np->n_name); - else - putnet(gf, net); - fprintf(gf, " gateway %s metric %d passive\n", - lower(name), metric); -} - -static void -copylocal(f, filename) - FILE *f; - char *filename; -{ - register FILE *lhf; - register int cc; - char buf[BUFSIZ]; - extern int errno; - - lhf = fopen(filename, "r"); - if (lhf == NULL) { - if (errno != ENOENT) { - perror(filename); - exit(1); - } - fprintf(stderr, "Warning, no %s file.\n", filename); - return; - } - while (cc = fread(buf, 1, sizeof(buf), lhf)) - fwrite(buf, 1, cc, f); - fclose(lhf); -} - -static void -copygateways(filename) - char *filename; -{ - register FILE *lhf; - struct name *nl; - char type[80]; - char dname[80]; - char gname[80]; - char junk[80]; - char buf[500]; - struct in_addr addr; - int net, metric; - extern int errno; - - lhf = fopen(filename, "r"); - if (lhf == NULL) { - if (errno != ENOENT) { - perror(filename); - exit(1); - } - fprintf(stderr, "Warning, no %s file.\n", filename); - return; - } - /* format: {net | host} XX gateway XX metric DD [passive]\n */ - for (;;) { - junk[0] = 0; - if (fgets(buf, sizeof(buf), lhf) == (char *)NULL) - break; - fputs(buf, gf); - if (buf[0] == '#' || - sscanf(buf, "%s %s gateway %s metric %d %s", - type, dname, gname, &metric, junk) < 5) - continue; - if (strcmp(type, "net")) - continue; - if (!getnetaddr(dname, &net)) - continue; - if (!gethostaddr(gname, (u_long * )&addr.s_addr)) - continue; - nl = newname(gname); - (void) savegateway(nl, net, addr, metric); - } - fclose(lhf); -} - -static int -getnetaddr(name, addr) - char *name; - int *addr; -{ - struct netent *np = getnetbyname(name); - - if (np == 0) { - *addr = inet_network(name); - return (*addr != -1); - } else { - if (np->n_addrtype != AF_INET) - return (0); - *addr = np->n_net; - return (1); - } -} - -static int -gethostaddr(name, addr) - char *name; - u_long *addr; -{ - struct hostent *hp; - - hp = gethostbyname(name); - if (hp) { - *addr = *(u_long *)(hp->h_addr); - return (1); - } - *addr = inet_addr(name); - return (*addr != -1); -} - -static void -copycomments(in, out, ccount) - FILE *in, *out; - int ccount; -{ - char buf[BUFSIZ]; - int count; - char *fgets(); - - for (count=0; count < ccount; count++) { - if ((fgets(buf, sizeof(buf), in) == NULL) || (buf[0] != ';')) - return; - buf[0] = '#'; - fputs(buf, out); - } -} -#define UC(b) (((int)(b))&0xff) - -/* - * Print network number in internet-standard dot notation; - * v is in host byte order. - */ -static void -putnet(f, v) - FILE *f; - register int v; -{ - if (v < 128) - fprintf(f, "%d", v); - else if (v < 65536) - fprintf(f, "%d.%d", UC(v >> 8), UC(v)); - else - fprintf(f, "%d.%d.%d", UC(v >> 16), UC(v >> 8), UC(v)); -} - -static void -putaddr(f, v) - FILE *f; - struct in_addr v; -{ - fprintf(f, "%-16.16s", inet_ntoa(v)); -} - -static void -freenames(list) - struct name *list; -{ - register struct name *nl, *nl2; - - nl2 = list; - while (nl = nl2) { - nl2 = nl->name_link; - free(nl->name_val); - free((char *)nl); - } -} - -static void -freeaddrs(list) - struct addr *list; -{ - register struct addr *al, *al2; - - al2 = list; - while (al = al2) - al2 = al->addr_link, free((char *)al); -} - -struct gateway *gateways = 0; -struct gateway *lastgateway = 0; - -struct gateway * -gatewayto(net) - register int net; -{ - register struct gateway *gp; - - for (gp = gateways; gp; gp = gp->g_link) - if ((gp->g_net == net) && (gp->g_metric > 0)) - return (gp); - return ((struct gateway *) NULL); -} - -struct gateway * -savegateway(namelist, net, addr, metric) - struct name *namelist; - struct in_addr addr; - int net, metric; -{ - register struct gateway *gp; - - gp = (struct gateway *)malloc(sizeof (struct gateway)); - if (gp == 0) { - fprintf(stderr, "htable: out of memory\n"); - exit(1); - } - gp->g_link = (struct gateway *) NULL; - if (lastgateway) - lastgateway->g_link = gp; - else - gateways = gp; - lastgateway = gp; - gp->g_name = namelist; - gp->g_net = net; - gp->g_addr = addr; - gp->g_metric = metric; - if (metric == 1) - gp->g_dst = gp; - return (gp); -} - -static int -connectedto(net) - int net; -{ - register int i; - - for (i = 0; i < nconnected; i++) - if (connected_nets[i] == net) - return(1); - return(0); -} - -static int -local(net) - int net; -{ - register int i; - - for (i = 0; i < nlocal; i++) - if (local_nets[i] == net) - return(1); - return(0); -} - -#define MAXHOPS 10 - -/* - * Go through list of gateways, finding connections for gateways - * that are not yet connected. - */ -static void -dogateways(void) -{ - register struct gateway *gp, *gw, *ggp; - register int hops, changed = 1; - struct name *nl; - char *cp; - - for (hops = 0; hops < MAXHOPS && changed; hops++, changed = 0) { - for (gp = gateways; gp; gp = gp->g_link) - if ((gp->g_metric == 0) && (gw = gatewayto(gp->g_net))) { - /* - * Found a new connection. - * For each other network that this gateway is on, - * add a new gateway to that network. - */ - changed = 1; - gp->g_dst = gw->g_dst; - gp->g_metric = gw->g_metric + 1; - for (ggp = gp->g_firstent; ggp->g_name == gp->g_name; - ggp = ggp->g_link) { - if (ggp == gp) - continue; - if (gatewayto(ggp->g_net)) - continue; - ggp->g_dst = gp->g_dst; - ggp->g_metric = gp->g_metric; - printgateway(ggp->g_net, - gw->g_dst->g_name->name_val, gp->g_metric); - } - /* - * Put the gateway in the hosts file, - * using the address for the connected net. - */ - putaddr(hf, gp->g_addr); - cp = "%s"; - for (nl = gp->g_name; nl; nl = nl->name_link) { - fprintf(hf, cp, lower(nl->name_val)); - cp = " %s"; - } - fprintf(hf, "\t# gateway\n"); - } - } -} diff --git a/usr/src/cmd/cmd-inet/usr.sbin/htable/htable.h b/usr/src/cmd/cmd-inet/usr.sbin/htable/htable.h deleted file mode 100644 index 695652c609..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/htable/htable.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright 1989 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -#include <sys/types.h> -#include <netinet/in.h> -#include <stdlib.h> - -/* - * common definitions for htable - */ - -struct addr { - struct in_addr addr_val; - struct addr *addr_link; -}; - -struct name { - char *name_val; - struct name *name_link; -}; - -struct gateway { - struct gateway *g_link; - struct gateway *g_dst; /* connected gateway if metric > 0 */ - struct gateway *g_firstent; /* first entry for this gateway */ - struct name *g_name; - int g_net; - struct in_addr g_addr; /* address on g_net */ - int g_metric; /* hops to this net */ -}; - -#define NOADDR ((struct addr *)0) -#define NONAME ((struct name *)0) - -#define KW_NET 1 -#define KW_GATEWAY 2 -#define KW_HOST 3 - -struct name *newname(); - -char *infile; /* Input file name */ diff --git a/usr/src/cmd/cmd-inet/usr.sbin/htable/parse.y b/usr/src/cmd/cmd-inet/usr.sbin/htable/parse.y deleted file mode 100644 index 057bb3e0f7..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/htable/parse.y +++ /dev/null @@ -1,165 +0,0 @@ -%{ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -%} -/* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ - -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ - -%{ -#ident "%Z%%M% %I% %E% SMI" - -#include "htable.h" -%} - -%union { - int number; - struct addr *addrlist; - struct name *namelist; -} -%start Table - -%token END -%token <number> NUMBER KEYWORD -%token <namelist> NAME - -%type <namelist> Names Cputype Opsys Protos Proto -%type <addrlist> Addresses Address -%% -Table : Entry - | Table Entry - ; - -Entry : KEYWORD ':' Addresses ':' Names ':' END - = { - do_entry($1, $3, $5, NONAME, NONAME, NONAME); - } - | KEYWORD ':' Addresses ':' Names ':' Cputype ':' END - = { - do_entry($1, $3, $5, $7, NONAME, NONAME); - } - | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' END - = { - do_entry($1, $3, $5, $7, $9, NONAME); - } - | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' ':' END - = { - do_entry($1, $3, $5, $7, $9, NONAME); - } - | KEYWORD ':' Addresses ':' Names ':' Cputype ':' Opsys ':' Protos ':' END - = { - do_entry($1, $3, $5, $7, $9, $11); - } - | error END - | END /* blank line */ - ; - -Addresses: Address - = { - $$ = $1; - } - | Address ',' Addresses - = { - $1->addr_link = $3; - $$ = $1; - } - ; - -Address : NUMBER '.' NUMBER '.' NUMBER '.' NUMBER - = { - char *a; - - $$ = (struct addr *)malloc(sizeof (struct addr)); - a = (char *)&($$->addr_val); - a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7; - $$->addr_link = NOADDR; - } - ; - -Names : NAME - = { - $$ = $1; - } - | NAME ',' Names - = { - $1->name_link = $3; - $$ = $1; - } - ; - -Cputype : /* empty */ - = { - $$ = NONAME; - } - | NAME - = { - $$ = $1; - } - ; - -Opsys : /* empty */ - = { - $$ = NONAME; - } - | NAME - = { - $$ = $1; - } - ; - -Protos : Proto - = { - $$ = $1; - } - | Proto ',' Protos - = { - $1->name_link = $3; - $$ = $1; - } - ; - -Proto : NAME - = { - $$ = $1; - } - ; -%% - -#include <stdio.h> - -extern int yylineno; - -void -yyerror(msg) - char *msg; -{ - fprintf(stderr, "\"%s\", line %d: %s\n", infile, yylineno, msg); -} diff --git a/usr/src/cmd/cmd-inet/usr.sbin/htable/scan.l b/usr/src/cmd/cmd-inet/usr.sbin/htable/scan.l deleted file mode 100644 index 0676b23aec..0000000000 --- a/usr/src/cmd/cmd-inet/usr.sbin/htable/scan.l +++ /dev/null @@ -1,110 +0,0 @@ -%{ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - * - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ -%} - - -%{ -/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -%} -%{ -/* All Rights Reserved */ -%} - -%{ -/* - * Portions of this source code were derived from Berkeley 4.3 BSD - * under license from the Regents of the University of California. - */ -%} - -%{ -#ident "%Z%%M% %I% %E% SMI" - -#include "y.tab.h" -#include "htable.h" -%} - -BLANK [ \t] -DIGIT [0-9] -ALPHA [A-Za-z] -ANUM [0-9A-Za-z] -NAMECHR [0-9A-Za-z./-] - -%% -"NET" { - yylval.number = KW_NET; - return (KEYWORD); - } - -"GATEWAY" { - yylval.number = KW_GATEWAY; - return (KEYWORD); - } - -"HOST" { - yylval.number = KW_HOST; - return (KEYWORD); - } - -{ALPHA}{NAMECHR}*{ANUM} { - yylval.namelist = newname(yytext); - return (NAME); - } - -{ALPHA} { - yylval.namelist = newname(yytext); - return (NAME); - } - -{DIGIT}+{ALPHA}{NAMECHR}* { - fprintf(stderr, "Warning: nonstandard name \"%s\"\n", - yytext); - yylval.namelist = newname(yytext); - return (NAME); - } - -{DIGIT}+ { - yylval.number = atoi(yytext); - return (NUMBER); - } - -"." return ('.'); -":" return (':'); -"," return (','); -"/" return ('/'); -";".* ; -"\n"{BLANK}+ ; -{BLANK}+ ; -"\n" return (END); -. fprintf(stderr, "Illegal char: '%s'\n", yytext); - -%% - -int -yywrap() -{ - return (1); -} diff --git a/usr/src/man/man1m/Makefile b/usr/src/man/man1m/Makefile index 4d7a492855..2112b279e9 100644 --- a/usr/src/man/man1m/Makefile +++ b/usr/src/man/man1m/Makefile @@ -164,7 +164,6 @@ _MANFILES= 6to4relay.1m \ getdevpolicy.1m \ getdgrp.1m \ getent.1m \ - gettable.1m \ getty.1m \ getvol.1m \ groupadd.1m \ @@ -181,7 +180,6 @@ _MANFILES= 6to4relay.1m \ halt.1m \ hextoalabel.1m \ hostconfig.1m \ - htable.1m \ ickey.1m \ id.1m \ idmap.1m \ diff --git a/usr/src/man/man1m/gettable.1m b/usr/src/man/man1m/gettable.1m deleted file mode 100644 index 66d09f23e7..0000000000 --- a/usr/src/man/man1m/gettable.1m +++ /dev/null @@ -1,41 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH GETTABLE 1M "Sep 14, 1992" -.SH NAME -gettable \- get DoD Internet format host table from a host -.SH SYNOPSIS -.LP -.nf -\fB/usr/sbin/gettable\fR \fIhost\fR -.fi - -.SH DESCRIPTION -.sp -.LP -\fBgettable\fR is a simple program used to obtain the DoD Internet host table -from a "hostname" server. The specified \fIhost\fR is queried for the table. -The table is placed in the file \fBhosts.txt\fR. -.sp -.LP -\fBgettable\fR operates by opening a \fBTCP\fR connection to the port indicated -in the service specification for "hostname". A request is then made for all -names and the resultant information is placed in the output file. -.sp -.LP -\fBgettable\fR is best used in conjunction with the \fBhtable\fR(1M) program -which converts the DoD Internet host table format to that used by the network -library lookup routines. -.SH SEE ALSO -.sp -.LP -\fBhtable\fR(1M), \fBattributes\fR(5) Harrenstien, Ken, Mary Stahl, and -Elizabeth Feinler, \fI\fR \fBHOSTNAME\fR \fIServer\fR, \fBRFC\fR 953, Network -Information Center, \fBSRI\fR International, Menlo Park, California, October -1985. -.SH NOTES -.sp -.LP -Should allow requests for only part of the database. diff --git a/usr/src/man/man1m/htable.1m b/usr/src/man/man1m/htable.1m deleted file mode 100644 index 5060d3b01f..0000000000 --- a/usr/src/man/man1m/htable.1m +++ /dev/null @@ -1,75 +0,0 @@ -'\" te -.\" Copyright 1989 AT&T Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved. -.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. -.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. -.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] -.TH HTABLE 1M "Sep 14, 1992" -.SH NAME -htable \- convert DoD Internet format host table -.SH SYNOPSIS -.LP -.nf -\fB/usr/sbin/htable\fR \fIfilename\fR -.fi - -.SH DESCRIPTION -.sp -.LP -\fBhtable\fR converts a host table in the format specified by \fBRFC\fR 952 to -the format used by the network library routines. Three files are created as a -result of running \fBhtable\fR: \fBhosts\fR, \fBnetworks\fR, and -\fBgateways\fR. The \fBhosts\fR file is used by the \fBgethostbyname\fR(3NSL) -routines in mapping host names to addresses. The \fBnetworks\fR file is used -by the \fBgetnetbyname\fR(3SOCKET) routines in mapping network names to -numbers. The \fBgateways\fR file is used by the routing daemon to identify -"passive" Internet gateways. -.sp -.LP -If any of the files \fBlocalhosts\fR, \fBlocalnetworks\fR, or -\fBlocalgateways\fR are present in the current directory, the file's contents -is prepended to the output file without interpretation. This allows sites to -maintain local aliases and entries which are not normally present in the master -database. -.sp -.LP -\fBhtable\fR is best used in conjunction with the \fBgettable\fR(1M) program -which retrieves the DoD Internet host table from a host. -.SH FILES -.sp -.ne 2 -.na -\fB\fBlocalhosts\fR\fR -.ad -.RS 17n - -.RE - -.sp -.ne 2 -.na -\fB\fBlocalnetworks\fR\fR -.ad -.RS 17n - -.RE - -.sp -.ne 2 -.na -\fB\fBlocalgateways\fR\fR -.ad -.RS 17n - -.RE - -.SH SEE ALSO -.sp -.LP -\fBgettable\fR(1M), \fBgethostbyname\fR(3NSL), \fBgetnetbyname\fR(3SOCKET), -\fBattributes\fR(5) Harrenstien, Ken, Mary Stahl, and Elizabeth Feinler, \fIDoD -Internet Host Table Specification\fR, \fBRFC\fR 952, Network Information -Center, \fBSRI\fR International, Menlo Park, California, October 1985. -.SH NOTES -.sp -.LP -\fBhtable\fR does not properly calculate the \fBgateways\fR file. diff --git a/usr/src/pkg/manifests/system-network-nis.mf b/usr/src/pkg/manifests/system-network-nis.mf index 836685177a..dba3306a19 100644 --- a/usr/src/pkg/manifests/system-network-nis.mf +++ b/usr/src/pkg/manifests/system-network-nis.mf @@ -22,6 +22,7 @@ # # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. # Copyright 2012 Nexenta Systems, Inc. All rights reserved. +# Copyright 2014 Garrett D'Amore <garrett@damore.org> # set name=pkg.fmri value=pkg:/system/network/nis@$(PKGVERS) @@ -71,8 +72,6 @@ file path=usr/lib/netsvc/yp/ypbind mode=0555 file path=usr/lib/netsvc/yp/ypstart mode=0555 file path=usr/lib/netsvc/yp/ypstop mode=0555 file path=usr/lib/netsvc/yp/ypxfr mode=0555 -file path=usr/sbin/gettable mode=0555 -file path=usr/sbin/htable mode=0555 file path=usr/sbin/ldapaddent mode=0555 file path=usr/sbin/ldapclient mode=0555 file path=usr/sbin/newkey group=sys mode=0555 @@ -87,8 +86,6 @@ file path=usr/share/man/man1/ypcat.1 file path=usr/share/man/man1/ypmatch.1 file path=usr/share/man/man1/yppasswd.1 file path=usr/share/man/man1/ypwhich.1 -file path=usr/share/man/man1m/gettable.1m -file path=usr/share/man/man1m/htable.1m file path=usr/share/man/man1m/idsconfig.1m file path=usr/share/man/man1m/ldap_cachemgr.1m file path=usr/share/man/man1m/ldapaddent.1m |