summaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
Diffstat (limited to 'libexec')
-rw-r--r--libexec/bootpgw/Makefile12
-rw-r--r--libexec/bootpgw/bootpgw.c675
-rw-r--r--libexec/getty/Makefile10
-rw-r--r--libexec/getty/extern.h57
-rw-r--r--libexec/getty/getty.8128
-rw-r--r--libexec/getty/gettytab.5385
-rw-r--r--libexec/getty/gettytab.h171
-rw-r--r--libexec/getty/init.c133
-rw-r--r--libexec/getty/main.c560
-rw-r--r--libexec/getty/pathnames.h40
-rw-r--r--libexec/getty/subr.c726
-rw-r--r--libexec/getty/ttys.5153
-rw-r--r--libexec/rpc.rquotad/Makefile10
-rw-r--r--libexec/rpc.rquotad/rpc.rquotad.858
-rw-r--r--libexec/rpc.rquotad/rquotad.c331
-rw-r--r--libexec/rpc.sprayd/Makefile11
-rw-r--r--libexec/rpc.sprayd/rpc.sprayd.854
-rw-r--r--libexec/rpc.sprayd/sprayd.c169
18 files changed, 0 insertions, 3683 deletions
diff --git a/libexec/bootpgw/Makefile b/libexec/bootpgw/Makefile
deleted file mode 100644
index a155e0e4f7c3..000000000000
--- a/libexec/bootpgw/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# Makefile
-# $Id$
-
-PROG= bootpgw
-NOMAN= true
-SRCS= bootpgw.c getif.c hwaddr.c report.c rtmsg.c
-
-SRCDIR= ${.CURDIR}/../bootpd
-CFLAGS+=-I${SRCDIR}
-.PATH: ${SRCDIR}
-
-.include <bsd.prog.mk>
diff --git a/libexec/bootpgw/bootpgw.c b/libexec/bootpgw/bootpgw.c
deleted file mode 100644
index 4e7538bb4def..000000000000
--- a/libexec/bootpgw/bootpgw.c
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * bootpgw.c - BOOTP GateWay
- * This program forwards BOOTP Request packets to a BOOTP server.
- */
-
-/************************************************************************
- Copyright 1988, 1991 by Carnegie Mellon University
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted, provided
-that the above copyright notice appear in all copies and that both that
-copyright notice and this permission notice appear in supporting
-documentation, and that the name of Carnegie Mellon University not be used
-in advertising or publicity pertaining to distribution of the software
-without specific, written prior permission.
-
-CARNEGIE MELLON UNIVERSITY DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
-SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
-IN NO EVENT SHALL CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
-DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
-PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
-ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-************************************************************************/
-
-#ifndef lint
-static char rcsid[] = "$Id: bootpgw.c,v 1.1.1.1 1994/09/10 14:44:54 csgr Exp $";
-#endif
-
-/*
- * BOOTPGW is typically used to forward BOOTP client requests from
- * one subnet to a BOOTP server on a different subnet.
- */
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h> /* inet_ntoa */
-
-#ifndef NO_UNISTD
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <signal.h>
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <ctype.h>
-#include <netdb.h>
-#include <syslog.h>
-#include <assert.h>
-
-#ifdef NO_SETSID
-# include <fcntl.h> /* for O_RDONLY, etc */
-#endif
-
-#ifndef USE_BFUNCS
-# include <memory.h>
-/* Yes, memcpy is OK here (no overlapped copies). */
-# define bcopy(a,b,c) memcpy(b,a,c)
-# define bzero(p,l) memset(p,0,l)
-# define bcmp(a,b,c) memcmp(a,b,c)
-#endif
-
-#include "bootp.h"
-#include "getif.h"
-#include "hwaddr.h"
-#include "report.h"
-#include "patchlevel.h"
-
-/* Local definitions: */
-#define MAX_MSG_SIZE (3*512) /* Maximum packet size */
-#define TRUE 1
-#define FALSE 0
-#define get_network_errmsg get_errmsg
-
-
-
-/*
- * Externals, forward declarations, and global variables
- */
-
-#ifdef __STDC__
-#define P(args) args
-#else
-#define P(args) ()
-#endif
-
-static void usage P((void));
-static void handle_reply P((void));
-static void handle_request P((void));
-
-#undef P
-
-/*
- * IP port numbers for client and server obtained from /etc/services
- */
-
-u_short bootps_port, bootpc_port;
-
-
-/*
- * Internet socket and interface config structures
- */
-
-struct sockaddr_in bind_addr; /* Listening */
-struct sockaddr_in recv_addr; /* Packet source */
-struct sockaddr_in send_addr; /* destination */
-
-
-/*
- * option defaults
- */
-int debug = 0; /* Debugging flag (level) */
-struct timeval actualtimeout =
-{ /* fifteen minutes */
- 15 * 60L, /* tv_sec */
- 0 /* tv_usec */
-};
-u_int maxhops = 4; /* Number of hops allowed for requests. */
-u_int minwait = 3; /* Number of seconds client must wait before
- its bootrequest packets are forwarded. */
-
-/*
- * General
- */
-
-int s; /* Socket file descriptor */
-char *pktbuf; /* Receive packet buffer */
-int pktlen;
-char *progname;
-char *servername;
-int32 server_ipa; /* Real server IP address, network order. */
-
-char myhostname[64];
-struct in_addr my_ip_addr;
-
-
-
-
-/*
- * Initialization such as command-line processing is done and then the
- * main server loop is started.
- */
-
-void
-main(argc, argv)
- int argc;
- char **argv;
-{
- struct timeval *timeout;
- struct bootp *bp;
- struct servent *servp;
- struct hostent *hep;
- char *stmp;
- int n, ba_len, ra_len;
- int nfound, readfds;
- int standalone;
-
- progname = strrchr(argv[0], '/');
- if (progname) progname++;
- else progname = argv[0];
-
- /*
- * Initialize logging.
- */
- report_init(0); /* uses progname */
-
- /*
- * Log startup
- */
- report(LOG_INFO, "version %s.%d", VERSION, PATCHLEVEL);
-
- /* Debugging for compilers with struct padding. */
- assert(sizeof(struct bootp) == BP_MINPKTSZ);
-
- /* Get space for receiving packets and composing replies. */
- pktbuf = malloc(MAX_MSG_SIZE);
- if (!pktbuf) {
- report(LOG_ERR, "malloc failed");
- exit(1);
- }
- bp = (struct bootp *) pktbuf;
-
- /*
- * Check to see if a socket was passed to us from inetd.
- *
- * Use getsockname() to determine if descriptor 0 is indeed a socket
- * (and thus we are probably a child of inetd) or if it is instead
- * something else and we are running standalone.
- */
- s = 0;
- ba_len = sizeof(bind_addr);
- bzero((char *) &bind_addr, ba_len);
- errno = 0;
- standalone = TRUE;
- if (getsockname(s, (struct sockaddr *) &bind_addr, &ba_len) == 0) {
- /*
- * Descriptor 0 is a socket. Assume we are a child of inetd.
- */
- if (bind_addr.sin_family == AF_INET) {
- standalone = FALSE;
- bootps_port = ntohs(bind_addr.sin_port);
- } else {
- /* Some other type of socket? */
- report(LOG_INFO, "getsockname: not an INET socket");
- }
- }
- /*
- * Set defaults that might be changed by option switches.
- */
- stmp = NULL;
- timeout = &actualtimeout;
- gethostname(myhostname, sizeof(myhostname));
- hep = gethostbyname(myhostname);
- if (!hep) {
- printf("Can not get my IP address\n");
- exit(1);
- }
- bcopy(hep->h_addr, (char *)&my_ip_addr, sizeof(my_ip_addr));
-
- /*
- * Read switches.
- */
- for (argc--, argv++; argc > 0; argc--, argv++) {
- if (argv[0][0] != '-')
- break;
- switch (argv[0][1]) {
-
- case 'd': /* debug level */
- if (argv[0][2]) {
- stmp = &(argv[0][2]);
- } else if (argv[1] && argv[1][0] == '-') {
- /*
- * Backwards-compatible behavior:
- * no parameter, so just increment the debug flag.
- */
- debug++;
- break;
- } else {
- argc--;
- argv++;
- stmp = argv[0];
- }
- if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) {
- fprintf(stderr,
- "%s: invalid debug level\n", progname);
- break;
- }
- debug = n;
- break;
-
- case 'h': /* hop count limit */
- if (argv[0][2]) {
- stmp = &(argv[0][2]);
- } else {
- argc--;
- argv++;
- stmp = argv[0];
- }
- if (!stmp || (sscanf(stmp, "%d", &n) != 1) ||
- (n < 0) || (n > 16))
- {
- fprintf(stderr,
- "bootpgw: invalid hop count limit\n");
- break;
- }
- maxhops = (u_int)n;
- break;
-
- case 'i': /* inetd mode */
- standalone = FALSE;
- break;
-
- case 's': /* standalone mode */
- standalone = TRUE;
- break;
-
- case 't': /* timeout */
- if (argv[0][2]) {
- stmp = &(argv[0][2]);
- } else {
- argc--;
- argv++;
- stmp = argv[0];
- }
- if (!stmp || (sscanf(stmp, "%d", &n) != 1) || (n < 0)) {
- fprintf(stderr,
- "%s: invalid timeout specification\n", progname);
- break;
- }
- actualtimeout.tv_sec = (int32) (60 * n);
- /*
- * If the actual timeout is zero, pass a NULL pointer
- * to select so it blocks indefinitely, otherwise,
- * point to the actual timeout value.
- */
- timeout = (n > 0) ? &actualtimeout : NULL;
- break;
-
- case 'w': /* wait time */
- if (argv[0][2]) {
- stmp = &(argv[0][2]);
- } else {
- argc--;
- argv++;
- stmp = argv[0];
- }
- if (!stmp || (sscanf(stmp, "%d", &n) != 1) ||
- (n < 0) || (n > 60))
- {
- fprintf(stderr,
- "bootpgw: invalid wait time\n");
- break;
- }
- minwait = (u_int)n;
- break;
-
- default:
- fprintf(stderr, "%s: unknown switch: -%c\n",
- progname, argv[0][1]);
- usage();
- break;
-
- } /* switch */
- } /* for args */
-
- /* Make sure server name argument is suplied. */
- servername = argv[0];
- if (!servername) {
- fprintf(stderr, "bootpgw: missing server name\n");
- usage();
- }
- /*
- * Get address of real bootp server.
- */
- if (isdigit(servername[0]))
- server_ipa = inet_addr(servername);
- else {
- hep = gethostbyname(servername);
- if (!hep) {
- fprintf(stderr, "bootpgw: can't get addr for %s\n", servername);
- exit(1);
- }
- bcopy(hep->h_addr, (char *)&server_ipa, sizeof(server_ipa));
- }
-
- if (standalone) {
- /*
- * Go into background and disassociate from controlling terminal.
- * XXX - This is not the POSIX way (Should use setsid). -gwr
- */
- if (debug < 3) {
- if (fork())
- exit(0);
-#ifdef NO_SETSID
- setpgrp(0,0);
-#ifdef TIOCNOTTY
- n = open("/dev/tty", O_RDWR);
- if (n >= 0) {
- ioctl(n, TIOCNOTTY, (char *) 0);
- (void) close(n);
- }
-#endif /* TIOCNOTTY */
-#else /* SETSID */
- if (setsid() < 0)
- perror("setsid");
-#endif /* SETSID */
- } /* if debug < 3 */
- /*
- * Nuke any timeout value
- */
- timeout = NULL;
-
- /*
- * Here, bootpd would do:
- * chdir
- * tzone_init
- * rdtab_init
- * readtab
- */
-
- /*
- * Create a socket.
- */
- if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- report(LOG_ERR, "socket: %s", get_network_errmsg());
- exit(1);
- }
- /*
- * Get server's listening port number
- */
- servp = getservbyname("bootps", "udp");
- if (servp) {
- bootps_port = ntohs((u_short) servp->s_port);
- } else {
- bootps_port = (u_short) IPPORT_BOOTPS;
- report(LOG_ERR,
- "udp/bootps: unknown service -- assuming port %d",
- bootps_port);
- }
-
- /*
- * Bind socket to BOOTPS port.
- */
- bind_addr.sin_family = AF_INET;
- bind_addr.sin_port = htons(bootps_port);
- bind_addr.sin_addr.s_addr = INADDR_ANY;
- if (bind(s, (struct sockaddr *) &bind_addr,
- sizeof(bind_addr)) < 0)
- {
- report(LOG_ERR, "bind: %s", get_network_errmsg());
- exit(1);
- }
- } /* if standalone */
- /*
- * Get destination port number so we can reply to client
- */
- servp = getservbyname("bootpc", "udp");
- if (servp) {
- bootpc_port = ntohs(servp->s_port);
- } else {
- report(LOG_ERR,
- "udp/bootpc: unknown service -- assuming port %d",
- IPPORT_BOOTPC);
- bootpc_port = (u_short) IPPORT_BOOTPC;
- }
-
- /* no signal catchers */
-
- /*
- * Process incoming requests.
- */
- for (;;) {
- readfds = 1 << s;
- nfound = select(s + 1, (fd_set *)&readfds, NULL, NULL, timeout);
- if (nfound < 0) {
- if (errno != EINTR) {
- report(LOG_ERR, "select: %s", get_errmsg());
- }
- continue;
- }
- if (!(readfds & (1 << s))) {
- report(LOG_INFO, "exiting after %ld minutes of inactivity",
- actualtimeout.tv_sec / 60);
- exit(0);
- }
- ra_len = sizeof(recv_addr);
- n = recvfrom(s, pktbuf, MAX_MSG_SIZE, 0,
- (struct sockaddr *) &recv_addr, &ra_len);
- if (n <= 0) {
- continue;
- }
- if (debug > 3) {
- report(LOG_INFO, "recvd pkt from IP addr %s",
- inet_ntoa(recv_addr.sin_addr));
- }
- if (n < sizeof(struct bootp)) {
- if (debug) {
- report(LOG_INFO, "received short packet");
- }
- continue;
- }
- pktlen = n;
-
- switch (bp->bp_op) {
- case BOOTREQUEST:
- handle_request();
- break;
- case BOOTREPLY:
- handle_reply();
- break;
- }
- }
-}
-
-
-
-
-/*
- * Print "usage" message and exit
- */
-
-static void
-usage()
-{
- fprintf(stderr,
- "usage: bootpgw [-d level] [-i] [-s] [-t timeout] server\n");
- fprintf(stderr, "\t -d n\tset debug level\n");
- fprintf(stderr, "\t -h n\tset max hop count\n");
- fprintf(stderr, "\t -i\tforce inetd mode (run as child of inetd)\n");
- fprintf(stderr, "\t -s\tforce standalone mode (run without inetd)\n");
- fprintf(stderr, "\t -t n\tset inetd exit timeout to n minutes\n");
- fprintf(stderr, "\t -w n\tset min wait time (secs)\n");
- exit(1);
-}
-
-
-
-/*
- * Process BOOTREQUEST packet.
- *
- * Note, this just forwards the request to a real server.
- */
-static void
-handle_request()
-{
- struct bootp *bp = (struct bootp *) pktbuf;
- struct ifreq *ifr;
- u_short secs, hops;
-
- /* XXX - SLIP init: Set bp_ciaddr = recv_addr here? */
-
- if (debug) {
- report(LOG_INFO, "request from %s",
- inet_ntoa(recv_addr.sin_addr));
- }
- /* Has the client been waiting long enough? */
- secs = ntohs(bp->bp_secs);
- if (secs < minwait)
- return;
-
- /* Has this packet hopped too many times? */
- hops = ntohs(bp->bp_hops);
- if (++hops > maxhops) {
- report(LOG_NOTICE, "reqest from %s reached hop limit",
- inet_ntoa(recv_addr.sin_addr));
- return;
- }
- bp->bp_hops = htons(hops);
-
- /*
- * Here one might discard a request from the same subnet as the
- * real server, but we can assume that the real server will send
- * a reply to the client before it waits for minwait seconds.
- */
-
- /* If gateway address is not set, put in local interface addr. */
- if (bp->bp_giaddr.s_addr == 0) {
-#if 0 /* BUG */
- struct sockaddr_in *sip;
- /*
- * XXX - This picks the wrong interface when the receive addr
- * is the broadcast address. There is no portable way to
- * find out which interface a broadcast was received on. -gwr
- * (Thanks to <walker@zk3.dec.com> for finding this bug!)
- */
- ifr = getif(s, &recv_addr.sin_addr);
- if (!ifr) {
- report(LOG_NOTICE, "no interface for request from %s",
- inet_ntoa(recv_addr.sin_addr));
- return;
- }
- sip = (struct sockaddr_in *) &(ifr->ifr_addr);
- bp->bp_giaddr = sip->sin_addr;
-#else /* BUG */
- /*
- * XXX - Just set "giaddr" to our "official" IP address.
- * RFC 1532 says giaddr MUST be set to the address of the
- * interface on which the request was received. Setting
- * it to our "default" IP address is not strictly correct,
- * but is good enough to allow the real BOOTP server to
- * get the reply back here. Then, before we forward the
- * reply to the client, the giaddr field is corrected.
- * (In case the client uses giaddr, which it should not.)
- * See handle_reply()
- */
- bp->bp_giaddr = my_ip_addr;
-#endif /* BUG */
-
- /*
- * XXX - DHCP says to insert a subnet mask option into the
- * options area of the request (if vendor magic == std).
- */
- }
- /* Set up socket address for send. */
- send_addr.sin_family = AF_INET;
- send_addr.sin_port = htons(bootps_port);
- send_addr.sin_addr.s_addr = server_ipa;
-
- /* Send reply with same size packet as request used. */
- if (sendto(s, pktbuf, pktlen, 0,
- (struct sockaddr *) &send_addr,
- sizeof(send_addr)) < 0)
- {
- report(LOG_ERR, "sendto: %s", get_network_errmsg());
- }
-}
-
-
-
-/*
- * Process BOOTREPLY packet.
- */
-static void
-handle_reply()
-{
- struct bootp *bp = (struct bootp *) pktbuf;
- struct ifreq *ifr;
- struct sockaddr_in *sip;
- u_char canon_haddr[MAXHADDRLEN];
- unsigned char *ha;
- int len;
-
- if (debug) {
- report(LOG_INFO, " reply for %s",
- inet_ntoa(bp->bp_yiaddr));
- }
- /* Make sure client is directly accessible. */
- ifr = getif(s, &(bp->bp_yiaddr));
- if (!ifr) {
- report(LOG_NOTICE, "no interface for reply to %s",
- inet_ntoa(bp->bp_yiaddr));
- return;
- }
-#if 1 /* Experimental (see BUG above) */
-/* #ifdef CATER_TO_OLD_CLIENTS ? */
- /*
- * The giaddr field has been set to our "default" IP address
- * which might not be on the same interface as the client.
- * In case the client looks at giaddr, (which it should not)
- * giaddr is now set to the address of the correct interface.
- */
- sip = (struct sockaddr_in *) &(ifr->ifr_addr);
- bp->bp_giaddr = sip->sin_addr;
-#endif
-
- /* Set up socket address for send to client. */
- send_addr.sin_family = AF_INET;
- send_addr.sin_addr = bp->bp_yiaddr;
- send_addr.sin_port = htons(bootpc_port);
-
- /* Create an ARP cache entry for the client. */
- ha = bp->bp_chaddr;
- len = bp->bp_hlen;
- if (len > MAXHADDRLEN)
- len = MAXHADDRLEN;
- if (bp->bp_htype == HTYPE_IEEE802) {
- haddr_conv802(ha, canon_haddr, len);
- ha = canon_haddr;
- }
- if (debug > 1)
- report(LOG_INFO, "setarp %s - %s",
- inet_ntoa(bp->bp_yiaddr), haddrtoa(ha, len));
- setarp(s, &bp->bp_yiaddr, ha, len);
-
- /* Send reply with same size packet as request used. */
- if (sendto(s, pktbuf, pktlen, 0,
- (struct sockaddr *) &send_addr,
- sizeof(send_addr)) < 0)
- {
- report(LOG_ERR, "sendto: %s", get_network_errmsg());
- }
-}
-
-/*
- * Local Variables:
- * tab-width: 4
- * c-indent-level: 4
- * c-argdecl-indent: 4
- * c-continued-statement-offset: 4
- * c-continued-brace-offset: -4
- * c-label-offset: -4
- * c-brace-offset: 0
- * End:
- */
diff --git a/libexec/getty/Makefile b/libexec/getty/Makefile
deleted file mode 100644
index a201e6252a6f..000000000000
--- a/libexec/getty/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# from: @(#)Makefile 8.1 (Berkeley) 6/4/93
-# $Id: Makefile,v 1.7 1994/12/22 10:27:06 cgd Exp $
-
-PROG= getty
-SRCS= main.c init.c subr.c
-DPADD+= ${LIBUTIL}
-LDADD+= -lutil
-MAN= getty.8 gettytab.5 ttys.5
-
-.include <bsd.prog.mk>
diff --git a/libexec/getty/extern.h b/libexec/getty/extern.h
deleted file mode 100644
index 366316641b80..000000000000
--- a/libexec/getty/extern.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: @(#)extern.h 8.1 (Berkeley) 6/4/93
- * $Id: extern.h,v 1.2 1994/08/17 20:10:29 pk Exp $
- */
-
-struct delayval;
-
-int adelay __P((int, struct delayval *));
-char *autobaud __P((void));
-int delaybits __P((void));
-void edithost __P((char *));
-void gendefaults __P((void));
-int getent __P((char *, char *));
-int getflag __P((char *));
-long getnum __P((char *));
-char *getstr __P((char *, char **));
-void gettable __P((char *, char *));
-void makeenv __P((char *[]));
-char *portselector __P((void));
-void set_ttydefaults __P((int));
-void setchars __P((void));
-void setdefaults __P((void));
-void setflags __P((int));
-int speed __P((int));
-
-int login_tty __P((int)); /* From libutil. */
diff --git a/libexec/getty/getty.8 b/libexec/getty/getty.8
deleted file mode 100644
index 1b00ae5a05ed..000000000000
--- a/libexec/getty/getty.8
+++ /dev/null
@@ -1,128 +0,0 @@
-.\" Copyright (c) 1980, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" from: @(#)getty.8 8.1 (Berkeley) 6/4/93
-.\" $Id: getty.8,v 1.3 1994/08/17 20:10:30 pk Exp $
-.\"
-.Dd June 4, 1993
-.Dt GETTY 8
-.Os BSD 4
-.Sh NAME
-.Nm getty
-.Nd set terminal mode
-.Sh SYNOPSIS
-.Nm getty
-.Oo
-.Ar type
-.Op Ar tty
-.Oc
-.Sh DESCRIPTION
-The
-.Nm getty
-program
-is called by
-.Xr init 8
-to open and initialize the tty line, read a login name, and invoke
-.Xr login 1 .
-.Pp
-The argument
-.Ar tty
-is the special device file in
-.Pa /dev
-to open for the terminal (for example, ``ttyh0'').
-If there is no argument or the argument is
-.Ql Fl ,
-the tty line is assumed to be open as file descriptor 0.
-.Pp
-The
-.Ar type
-argument can be used to make
-.Nm getty
-treat the terminal line specially.
-This argument is used as an index into the
-.Nm gettytab 5
-database, to determine the characteristics of the line.
-If there is no argument, or there is no such table, the
-.Em default
-table is used.
-If there is no
-.Pa /etc/gettytab
-a set of system defaults is used.
-If indicated by the table located,
-.Nm getty
-will clear the terminal screen,
-print a banner heading,
-and prompt for a login name.
-Usually either the banner or the login prompt will include
-the system hostname.
-.Pp
-Most of the default actions of
-.Nm getty
-can be circumvented, or modified, by a suitable
-.Nm gettytab
-table.
-.Pp
-The
-.Nm getty
-program
-can be set to timeout after some interval,
-which will cause dial up lines to hang up
-if the login name is not entered reasonably quickly.
-.Sh DIAGNOSTICS
-.Bl -diag
-.It "ttyxx: No such device or address."
-.It "ttyxx: No such file or address."
-A terminal which is turned
-on in the
-.Xr ttys
-file cannot be opened, likely because the requisite
-lines are either not configured into the system, the associated device
-was not attached during boot-time system configuration,
-or the special file in
-.Pa /dev
-does not exist.
-.El
-.Sh FILES
-.Bl -tag -width /etc/gettytab -compact
-.It Pa /etc/gettytab
-.El
-.Sh SEE ALSO
-.Xr gettytab 5 ,
-.Xr init 8 ,
-.Xr login 1 ,
-.Xr ioctl 2 ,
-.Xr tty 4 ,
-.Xr ttys 5
-.Sh HISTORY
-A
-.Nm getty
-program appeared in
-.At v6 .
diff --git a/libexec/getty/gettytab.5 b/libexec/getty/gettytab.5
deleted file mode 100644
index 2c2589911dcc..000000000000
--- a/libexec/getty/gettytab.5
+++ /dev/null
@@ -1,385 +0,0 @@
-.\" Copyright (c) 1983, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" from: @(#)gettytab.5 8.4 (Berkeley) 4/19/94
-.\" $Id: gettytab.5,v 1.12 1994/09/24 00:56:05 mycroft Exp $
-.\"
-.Dd April 19, 1994
-.Dt GETTYTAB 5
-.Os BSD 4.2
-.Sh NAME
-.Nm gettytab
-.Nd terminal configuration data base
-.Sh SYNOPSIS
-.Nm gettytab
-.Sh DESCRIPTION
-The
-.Nm gettytab
-file
-is a simplified version of the
-.Xr termcap 5
-data base
-used to describe terminal lines.
-The initial terminal login process
-.Xr getty 8
-accesses the
-.Nm gettytab
-file each time it starts, allowing simpler
-reconfiguration of terminal characteristics.
-Each entry in the data base
-is used to describe one class of terminals.
-.Pp
-There is a default terminal class,
-.Em default ,
-that is used to set global defaults for all other classes.
-(That is, the
-.Em default
-entry is read, then the entry for the class required
-is used to override particular settings.)
-.Sh CAPABILITIES
-Refer to
-.Xr termcap 5
-for a description of the file layout.
-The
-.Em default
-column below lists defaults obtained if there is
-no entry in the table obtained, nor one in the special
-.Em default
-table.
-.Bl -column Namexx /usr/bin/login Default
-.It Sy Name Type Default Description
-.It "ap bool false terminal uses any parity"
-.It "bk str 0377 alternate end of line character (input break)"
-.It "c0 num unused tty control flags to write messages"
-.It "c1 num unused tty control flags to read login name"
-.It "c2 num unused tty control flags to leave terminal as"
-.It "ce bool false use crt erase algorithm"
-.It "ck bool false use crt kill algorithm"
-.It "cl str" Ta Dv NULL Ta
-.No "screen clear sequence"
-.It "co bool false console - add"
-.Ql \en
-after login prompt
-.It "ds str" Ta So Li ^Y Sc Ta
-.No "delayed suspend character"
-.It "dx bool false set"
-.Dv DECCTLQ
-.It "ec bool false leave echo"
-.Tn OFF
-.It "ep bool false terminal uses even parity"
-.It "er str" Ta So Li ^? Sc Ta
-.No "erase character"
-.It "et str" Ta So Li ^D Sc Ta
-.No "end of text"
-.Pq Dv EOF
-character
-.It "ev str" Ta Dv NULL Ta
-.No "initial environment"
-.It "f0 num unused tty mode flags to write messages"
-.It "f1 num unused tty mode flags to read login name"
-.It "f2 num unused tty mode flags to leave terminal as"
-.It "fl str" Ta So Li ^O Sc Ta
-.No "output flush character"
-.It "hc bool false do"
-.Tn NOT
-hangup line on last close
-.It "he str" Ta Dv NULL Ta
-.No "hostname editing string"
-.It "hn str hostname hostname"
-.It "ht bool false terminal has real tabs"
-.It "i0 num unused tty input flags to write messages"
-.It "i1 num unused tty input flags to read login name"
-.It "i2 num unused tty input flags to leave terminal as"
-.It "ig bool false ignore garbage characters in login name"
-.It "im str" Ta Dv NULL Ta
-.No "initial (banner) message"
-.It "in str" Ta So Li ^C Sc Ta
-.No "interrupt character"
-.It "is num unused input speed"
-.It "kl str" Ta So Li ^U Sc Ta
-.No "kill character"
-.It "l0 num unused tty local flags to write messages"
-.It "l1 num unused tty local flags to read login name"
-.It "l2 num unused tty local flags to leave terminal as"
-.It "lc bool false terminal has lower case"
-.It "lm str login: login prompt"
-.It "ln str" Ta So Li ^V Sc Ta
-.No "``literal next'' character"
-.It "lo str" Ta Pa /usr/bin/login Ta
-.No "program to exec when name obtained"
-.It "mb bool false do flow control based on carrier"
-.It "nl bool false terminal has (or might have) a newline character"
-.It "np bool false terminal uses no parity (i.e. 8-bit characters)"
-.It "nx str default next table (for auto speed selection)"
-.It "o0 num unused tty output flags to write messages"
-.It "o1 num unused tty output flags to read login name"
-.It "o2 num unused tty output flags to leave terminal as"
-.It "op bool false terminal uses odd parity"
-.It "os num unused output speed"
-.It "pc str" Ta So Li \e0 Sc Ta
-.No "pad character"
-.It "pe bool false use printer (hard copy) erase algorithm"
-.It "pf num 0 delay"
-between first prompt and following flush (seconds)
-.It "ps bool false line connected to a"
-.Tn MICOM
-port selector
-.It "qu str" Ta So Li \&^\e Sc Ta
-.No "quit character"
-.It "rp str" Ta So Li ^R Sc Ta
-.No "line retype character"
-.It "rw bool false do"
-.Tn NOT
-use raw for input, use cbreak
-.It "sp num unused line speed (input and output)"
-.It "su str" Ta So Li ^Z Sc Ta
-.No "suspend character"
-.It "tc str none table continuation"
-.It "to num 0 timeout (seconds)"
-.It "tt str" Ta Dv NULL Ta
-.No "terminal type (for environment)"
-.It "ub bool false do unbuffered output (of prompts etc)"
-.It "we str" Ta So Li ^W Sc Ta
-.No "word erase character"
-.It "xc bool false do
-.Tn NOT
-echo control chars as
-.Ql ^X
-.It "xf str" Ta So Li ^S Sc Ta Dv XOFF
-(stop output) character
-.It "xn str" Ta So Li ^Q Sc Ta Dv XON
-(start output) character
-.El
-.Pp
-The following capabilities are no longer supported by getty(8):
-.Bl -column Namexx /usr/bin/login Default
-.It "bd num 0 backspace delay"
-.It "cb bool false use crt backspace mode"
-.It "cd num 0 carriage-return delay"
-.It "fd num 0 form-feed (vertical motion) delay"
-.It "nd num 0 newline (line-feed) delay"
-.It "uc bool false terminal is known upper case only"
-.El
-.Pp
-If no line speed is specified, speed will not be altered
-from that which prevails when getty is entered.
-Specifying an input or output speed will override
-line speed for stated direction only.
-.Pp
-Terminal modes to be used for the output of the message,
-for input of the login name,
-and to leave the terminal set as upon completion,
-are derived from the boolean flags specified.
-If the derivation should prove inadequate,
-any (or all) of these three may be overridden
-with one of the
-.Em \&c0 ,
-.Em \&c1 ,
-.Em \&c2 ,
-.Em \&i0 ,
-.Em \&i1 ,
-.Em \&i2 ,
-.Em \&l0 ,
-.Em \&l1 ,
-.Em \&l2 ,
-.Em \&o0 ,
-.Em \&o1 ,
-or
-.Em \&o2
-numeric specifications, which can be used to specify
-(usually in octal, with a leading '0')
-the exact values of the flags.
-These flags correspond to the termios
-.Em c_cflag ,
-.Em c_iflag ,
-.Em c_lflag ,
-and
-.Em c_oflag
-fields, respectively. Each these sets must be completely specified to be
-effective.
-The
-.Em \&f0 ,
-.Em \&f1 ,
-and
-.Em \&f2
-are excepted for backwards compatibility with a previous incarnation of
-the TTY sub-system. In these flags the bottom 16 bits of the (32 bits)
-value contain the sgttyb
-.Em sg_flags
-field, while the top 16 bits represent the local mode word.
-.Pp
-Should
-.Xr getty 8
-receive a null character
-(presumed to indicate a line break)
-it will restart using the table indicated by the
-.Em nx
-entry. If there is none, it will re-use its original table.
-.Pp
-Delays are specified in milliseconds, the nearest possible
-delay available in the tty driver will be used.
-Should greater certainty be desired, delays
-with values 0, 1, 2, and 3 are interpreted as
-choosing that particular delay algorithm from the driver.
-.Pp
-The
-.Em \&cl
-screen clear string may be preceded by a (decimal) number
-of milliseconds of delay required (a la termcap).
-This delay is simulated by repeated use of the pad character
-.Em \&pc .
-.Pp
-The initial message, and login message,
-.Em \&im
-and
-.Em \&lm
-may include any of the following character sequences, which expand to
-information about the environment in which
-.Xr getty 8
-is running.
-.Pp
-.Bl -tag -width \&%xxx -compact
-.It \&%d
-The current date.
-.It \&%h
-The hostname of the machine, which is normally obtained from the
-system using
-.Xr gethostname 2 ,
-but may also be overridden by the
-.Em \&hn
-table entry.
-In either case it may be edited with the
-.Em \&he
-string.
-A '@' in the
-.Em \&he
-string causes one character from the real hostname to
-be copied to the final hostname.
-A '#' in the
-.Em \&he
-string causes the next character of the real hostname
-to be skipped.
-Each character that
-is neither '@' nor '#' is copied into the final hostname.
-Surplus '@' and '#' characters are ignored.
-.It \&%t
-The tty name.
-.It "\&%m, \&%r, \&%s, \&%v"
-The type of machine, release of the operating system, name of the
-operating system, and version of the kernel, respectively, as
-returned by
-.Xr uname 2 .
-.It \&%%
-A
-.Dq %
-character.
-.El
-.Pp
-When getty execs the login process, given
-in the
-.Em \&lo
-string (usually
-.Dq Pa /usr/bin/login ) ,
-it will have set
-the environment to include the terminal type, as indicated
-by the
-.Em \&tt
-string (if it exists).
-The
-.Em \&ev
-string, can be used to enter additional data into
-the environment.
-It is a list of comma separated strings, each of which
-will presumably be of the form
-.Em name=value .
-.Pp
-If a non-zero timeout is specified, with
-.Em \&to ,
-then getty will exit within the indicated
-number of seconds, either having
-received a login name and passed control
-to
-.Xr login 1 ,
-or having received an alarm signal, and exited.
-This may be useful to hangup dial in lines.
-.Pp
-Output from
-.Xr getty 8
-is even parity unless
-.Em \&op
-or
-.Em \&np
-is specified.
-The
-.Em \&op
-string
-may be specified with
-.Em \&ap
-to allow any parity on input, but generate odd parity output.
-Note: this only applies while getty is being run,
-terminal driver limitations prevent a more complete
-implementation.
-.Xr Getty 8
-does not check parity of input characters in
-.Dv RAW
-mode.
-.Sh SEE ALSO
-.Xr login 1 ,
-.Xr gethostname 2 ,
-.Xr uname 2 ,
-.Xr termcap 5 ,
-.Xr getty 8 .
-.Sh BUGS
-The special characters (erase, kill, etc.) are reset to system defaults
-by
-.Xr login 1 .
-In
-.Em all
-cases, '#' or '^H' typed in a login name will be treated as
-an erase character, and '@' will be treated as a kill character.
-.Pp
-The delay stuff is a real crock.
-Apart form its general lack of flexibility, some
-of the delay algorithms are not implemented.
-The terminal driver should support sane delay settings.
-.Pp
-The
-.Em \&he
-capability is stupid.
-.Pp
-The
-.Xr termcap
-format is horrid, something more rational should
-have been chosen.
-.Sh HISTORY
-The
-.Nm gettytab
-file format appeared in 4.2BSD.
diff --git a/libexec/getty/gettytab.h b/libexec/getty/gettytab.h
deleted file mode 100644
index a712e43909bd..000000000000
--- a/libexec/getty/gettytab.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (c) 1983, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: @(#)gettytab.h 8.2 (Berkeley) 3/30/94
- * $Id: gettytab.h,v 1.7 1994/08/17 20:10:34 pk Exp $
- */
-
-/*
- * Getty description definitions.
- */
-struct gettystrs {
- char *field; /* name to lookup in gettytab */
- char *defalt; /* value we find by looking in defaults */
- char *value; /* value that we find there */
-};
-
-struct gettynums {
- char *field; /* name to lookup */
- long defalt; /* number we find in defaults */
- long value; /* number we find there */
- int set; /* we actually got this one */
-};
-
-struct gettyflags {
- char *field; /* name to lookup */
- char invrt; /* name existing in gettytab --> false */
- char defalt; /* true/false in defaults */
- char value; /* true/false flag */
- char set; /* we found it */
-};
-
-/*
- * String values.
- */
-#define NX gettystrs[0].value
-#define CL gettystrs[1].value
-#define IM gettystrs[2].value
-#define LM gettystrs[3].value
-#define ER gettystrs[4].value
-#define KL gettystrs[5].value
-#define ET gettystrs[6].value
-#define PC gettystrs[7].value
-#define TT gettystrs[8].value
-#define EV gettystrs[9].value
-#define LO gettystrs[10].value
-#define HN gettystrs[11].value
-#define HE gettystrs[12].value
-#define IN gettystrs[13].value
-#define QU gettystrs[14].value
-#define XN gettystrs[15].value
-#define XF gettystrs[16].value
-#define BK gettystrs[17].value
-#define SU gettystrs[18].value
-#define DS gettystrs[19].value
-#define RP gettystrs[20].value
-#define FL gettystrs[21].value
-#define WE gettystrs[22].value
-#define LN gettystrs[23].value
-
-/*
- * Numeric definitions.
- */
-#define IS gettynums[0].value
-#define OS gettynums[1].value
-#define SP gettynums[2].value
-#define ND gettynums[3].value
-#define CD gettynums[4].value
-#define TD gettynums[5].value
-#define FD gettynums[6].value
-#define BD gettynums[7].value
-#define TO gettynums[8].value
-#define F0 gettynums[9].value
-#define F0set gettynums[9].set
-#define F1 gettynums[10].value
-#define F1set gettynums[10].set
-#define F2 gettynums[11].value
-#define F2set gettynums[11].set
-#define PF gettynums[12].value
-#define C0 gettynums[13].value
-#define C0set gettynums[13].set
-#define C1 gettynums[14].value
-#define C1set gettynums[14].set
-#define C2 gettynums[15].value
-#define C2set gettynums[15].set
-#define I0 gettynums[16].value
-#define I0set gettynums[16].set
-#define I1 gettynums[17].value
-#define I1set gettynums[17].set
-#define I2 gettynums[18].value
-#define I2set gettynums[18].set
-#define L0 gettynums[19].value
-#define L0set gettynums[19].set
-#define L1 gettynums[20].value
-#define L1set gettynums[20].set
-#define L2 gettynums[21].value
-#define L2set gettynums[21].set
-#define O0 gettynums[22].value
-#define O0set gettynums[22].set
-#define O1 gettynums[23].value
-#define O1set gettynums[23].set
-#define O2 gettynums[24].value
-#define O2set gettynums[24].set
-
-/*
- * Boolean values.
- */
-#define HT gettyflags[0].value
-#define NL gettyflags[1].value
-#define EP gettyflags[2].value
-#define EPset gettyflags[2].set
-#define OP gettyflags[3].value
-#define OPset gettyflags[3].set
-#define AP gettyflags[4].value
-#define APset gettyflags[4].set
-#define EC gettyflags[5].value
-#define CO gettyflags[6].value
-#define CB gettyflags[7].value
-#define CK gettyflags[8].value
-#define CE gettyflags[9].value
-#define PE gettyflags[10].value
-#define RW gettyflags[11].value
-#define XC gettyflags[12].value
-#define LC gettyflags[13].value
-#define UC gettyflags[14].value
-#define IG gettyflags[15].value
-#define PS gettyflags[16].value
-#define HC gettyflags[17].value
-#define UB gettyflags[18].value
-#define AB gettyflags[19].value
-#define DX gettyflags[20].value
-#define NP gettyflags[21].value
-#define MB gettyflags[22].value
-
-int getent __P((char *, char *));
-long getnum __P((char *));
-int getflag __P((char *));
-char *getstr __P((char *, char **));
-
-extern struct gettyflags gettyflags[];
-extern struct gettynums gettynums[];
-extern struct gettystrs gettystrs[];
-extern int hopcount;
diff --git a/libexec/getty/init.c b/libexec/getty/init.c
deleted file mode 100644
index f3e78c00e1f6..000000000000
--- a/libexec/getty/init.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)init.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$Id: init.c,v 1.6 1994/08/17 20:10:35 pk Exp $";
-#endif /* not lint */
-
-/*
- * Getty table initializations.
- *
- * Melbourne getty.
- */
-#include <termios.h>
-#include "gettytab.h"
-#include "pathnames.h"
-
-extern struct termios tmode;
-extern char hostname[];
-
-struct gettystrs gettystrs[] = {
- { "nx" }, /* next table */
- { "cl" }, /* screen clear characters */
- { "im" }, /* initial message */
- { "lm", "login: " }, /* login message */
- { "er", &tmode.c_cc[VERASE] }, /* erase character */
- { "kl", &tmode.c_cc[VKILL] }, /* kill character */
- { "et", &tmode.c_cc[VEOF] }, /* eof chatacter (eot) */
- { "pc", "" }, /* pad character */
- { "tt" }, /* terminal type */
- { "ev" }, /* enviroment */
- { "lo", _PATH_LOGIN }, /* login program */
- { "hn", hostname }, /* host name */
- { "he" }, /* host name edit */
- { "in", &tmode.c_cc[VINTR] }, /* interrupt char */
- { "qu", &tmode.c_cc[VQUIT] }, /* quit char */
- { "xn", &tmode.c_cc[VSTART] }, /* XON (start) char */
- { "xf", &tmode.c_cc[VSTOP] }, /* XOFF (stop) char */
- { "bk", &tmode.c_cc[VEOL] }, /* brk char (alt \n) */
- { "su", &tmode.c_cc[VSUSP] }, /* suspend char */
- { "ds", &tmode.c_cc[VDSUSP] }, /* delayed suspend */
- { "rp", &tmode.c_cc[VREPRINT] },/* reprint char */
- { "fl", &tmode.c_cc[VDISCARD] },/* flush output */
- { "we", &tmode.c_cc[VWERASE] }, /* word erase */
- { "ln", &tmode.c_cc[VLNEXT] }, /* literal next */
- { 0 }
-};
-
-struct gettynums gettynums[] = {
- { "is" }, /* input speed */
- { "os" }, /* output speed */
- { "sp" }, /* both speeds */
- { "nd" }, /* newline delay */
- { "cd" }, /* carriage-return delay */
- { "td" }, /* tab delay */
- { "fd" }, /* form-feed delay */
- { "bd" }, /* backspace delay */
- { "to" }, /* timeout */
- { "f0" }, /* output flags */
- { "f1" }, /* input flags */
- { "f2" }, /* user mode flags */
- { "pf" }, /* delay before flush at 1st prompt */
- { "c0" }, /* output c_flags */
- { "c1" }, /* input c_flags */
- { "c2" }, /* user mode c_flags */
- { "i0" }, /* output i_flags */
- { "i1" }, /* input i_flags */
- { "i2" }, /* user mode i_flags */
- { "l0" }, /* output l_flags */
- { "l1" }, /* input l_flags */
- { "l2" }, /* user mode l_flags */
- { "o0" }, /* output o_flags */
- { "o1" }, /* input o_flags */
- { "o2" }, /* user mode o_flags */
- { 0 }
-};
-
-struct gettyflags gettyflags[] = {
- { "ht", 0 }, /* has tabs */
- { "nl", 1 }, /* has newline char */
- { "ep", 0 }, /* even parity */
- { "op", 0 }, /* odd parity */
- { "ap", 0 }, /* any parity */
- { "ec", 1 }, /* no echo */
- { "co", 0 }, /* console special */
- { "cb", 0 }, /* crt backspace */
- { "ck", 0 }, /* crt kill */
- { "ce", 0 }, /* crt erase */
- { "pe", 0 }, /* printer erase */
- { "rw", 1 }, /* don't use raw */
- { "xc", 1 }, /* don't ^X ctl chars */
- { "lc", 0 }, /* terminal las lower case */
- { "uc", 0 }, /* terminal has no lower case */
- { "ig", 0 }, /* ignore garbage */
- { "ps", 0 }, /* do port selector speed select */
- { "hc", 1 }, /* don't set hangup on close */
- { "ub", 0 }, /* unbuffered output */
- { "ab", 0 }, /* auto-baud detect with '\r' */
- { "dx", 0 }, /* set decctlq */
- { "np", 0 }, /* no parity at all (8bit chars) */
- { "mb", 0 }, /* do MDMBUF flow control */
- { 0 }
-};
diff --git a/libexec/getty/main.c b/libexec/getty/main.c
deleted file mode 100644
index 0539b1749f4e..000000000000
--- a/libexec/getty/main.c
+++ /dev/null
@@ -1,560 +0,0 @@
-/*-
- * Copyright (c) 1980, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1980, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/20/93";*/
-static char rcsid[] = "$Id: main.c,v 1.15 1995/08/13 04:08:27 cgd Exp $";
-#endif /* not lint */
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-#include <sys/resource.h>
-#include <sys/utsname.h>
-#include <errno.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <time.h>
-#include <ctype.h>
-#include <fcntl.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <stdlib.h>
-#include <string.h>
-#include <syslog.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "gettytab.h"
-#include "pathnames.h"
-#include "extern.h"
-
-/*
- * Set the amount of running time that getty should accumulate
- * before deciding that something is wrong and exit.
- */
-#define GETTY_TIMEOUT 60 /* seconds */
-
-struct termios tmode, omode;
-
-int crmod, digit, lower, upper;
-
-char hostname[MAXHOSTNAMELEN];
-struct utsname kerninfo;
-char name[16];
-char dev[] = _PATH_DEV;
-char ttyn[32];
-char *portselector();
-char *ttyname();
-
-#define OBUFSIZ 128
-#define TABBUFSIZ 512
-
-char defent[TABBUFSIZ];
-char tabent[TABBUFSIZ];
-
-char *env[128];
-
-char partab[] = {
- 0001,0201,0201,0001,0201,0001,0001,0201,
- 0202,0004,0003,0205,0005,0206,0201,0001,
- 0201,0001,0001,0201,0001,0201,0201,0001,
- 0001,0201,0201,0001,0201,0001,0001,0201,
- 0200,0000,0000,0200,0000,0200,0200,0000,
- 0000,0200,0200,0000,0200,0000,0000,0200,
- 0000,0200,0200,0000,0200,0000,0000,0200,
- 0200,0000,0000,0200,0000,0200,0200,0000,
- 0200,0000,0000,0200,0000,0200,0200,0000,
- 0000,0200,0200,0000,0200,0000,0000,0200,
- 0000,0200,0200,0000,0200,0000,0000,0200,
- 0200,0000,0000,0200,0000,0200,0200,0000,
- 0000,0200,0200,0000,0200,0000,0000,0200,
- 0200,0000,0000,0200,0000,0200,0200,0000,
- 0200,0000,0000,0200,0000,0200,0200,0000,
- 0000,0200,0200,0000,0200,0000,0000,0201
-};
-
-#define ERASE tmode.c_cc[VERASE]
-#define KILL tmode.c_cc[VKILL]
-#define EOT tmode.c_cc[VEOF]
-
-jmp_buf timeout;
-
-static void
-dingdong()
-{
-
- alarm(0);
- signal(SIGALRM, SIG_DFL);
- longjmp(timeout, 1);
-}
-
-jmp_buf intrupt;
-
-static void
-interrupt()
-{
-
- signal(SIGINT, interrupt);
- longjmp(intrupt, 1);
-}
-
-/*
- * Action to take when getty is running too long.
- */
-void
-timeoverrun(signo)
- int signo;
-{
-
- syslog(LOG_ERR, "getty exiting due to excessive running time\n");
- exit(1);
-}
-
-static int getname __P((void));
-static void oflush __P((void));
-static void prompt __P((void));
-static void putchr __P((int));
-static void putf __P((char *));
-static void putpad __P((char *));
-static void puts __P((char *));
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- extern char **environ;
- char *tname;
- long allflags;
- int repcnt = 0, failopenlogged = 0;
- struct rlimit limit;
-
- signal(SIGINT, SIG_IGN);
-/*
- signal(SIGQUIT, SIG_DFL);
-*/
- openlog("getty", LOG_ODELAY|LOG_CONS|LOG_PID, LOG_AUTH);
- gethostname(hostname, sizeof(hostname));
- if (hostname[0] == '\0')
- strcpy(hostname, "Amnesiac");
- uname(&kerninfo);
-
- /*
- * Limit running time to deal with broken or dead lines.
- */
- (void)signal(SIGXCPU, timeoverrun);
- limit.rlim_max = RLIM_INFINITY;
- limit.rlim_cur = GETTY_TIMEOUT;
- (void)setrlimit(RLIMIT_CPU, &limit);
-
- /*
- * The following is a work around for vhangup interactions
- * which cause great problems getting window systems started.
- * If the tty line is "-", we do the old style getty presuming
- * that the file descriptors are already set up for us.
- * J. Gettys - MIT Project Athena.
- */
- if (argc <= 2 || strcmp(argv[2], "-") == 0)
- strcpy(ttyn, ttyname(0));
- else {
- int i;
-
- strcpy(ttyn, dev);
- strncat(ttyn, argv[2], sizeof(ttyn)-sizeof(dev));
- if (strcmp(argv[0], "+") != 0) {
- chown(ttyn, 0, 0);
- chmod(ttyn, 0600);
- revoke(ttyn);
- /*
- * Delay the open so DTR stays down long enough to be detected.
- */
- sleep(2);
- while ((i = open(ttyn, O_RDWR)) == -1) {
- if ((repcnt % 10 == 0) &&
- (errno != ENXIO || !failopenlogged)) {
- syslog(LOG_ERR, "%s: %m", ttyn);
- closelog();
- failopenlogged = 1;
- }
- repcnt++;
- sleep(60);
- }
- login_tty(i);
- }
- }
-
- /* Start with default tty settings */
- if (tcgetattr(0, &tmode) < 0) {
- syslog(LOG_ERR, "%s: %m", ttyn);
- exit(1);
- }
- omode = tmode;
-
- gettable("default", defent);
- gendefaults();
- tname = "default";
- if (argc > 1)
- tname = argv[1];
- for (;;) {
- int off;
-
- gettable(tname, tabent);
- if (OPset || EPset || APset)
- APset++, OPset++, EPset++;
- setdefaults();
- off = 0;
- (void)tcflush(0, TCIOFLUSH); /* clear out the crap */
- ioctl(0, FIONBIO, &off); /* turn off non-blocking mode */
- ioctl(0, FIOASYNC, &off); /* ditto for async mode */
-
- if (IS)
- cfsetispeed(&tmode, IS);
- else if (SP)
- cfsetispeed(&tmode, SP);
- if (OS)
- cfsetospeed(&tmode, OS);
- else if (SP)
- cfsetospeed(&tmode, SP);
- setflags(0);
- setchars();
- if (tcsetattr(0, TCSANOW, &tmode) < 0) {
- syslog(LOG_ERR, "%s: %m", ttyn);
- exit(1);
- }
- if (AB) {
- extern char *autobaud();
-
- tname = autobaud();
- continue;
- }
- if (PS) {
- tname = portselector();
- continue;
- }
- if (CL && *CL)
- putpad(CL);
- edithost(HE);
- if (IM && *IM)
- putf(IM);
- if (setjmp(timeout)) {
- tmode.c_ispeed = tmode.c_ospeed = 0;
- (void)tcsetattr(0, TCSANOW, &tmode);
- exit(1);
- }
- if (TO) {
- signal(SIGALRM, dingdong);
- alarm(TO);
- }
- if (getname()) {
- register int i;
-
- oflush();
- alarm(0);
- signal(SIGALRM, SIG_DFL);
- if (name[0] == '-') {
- puts("user names may not start with '-'.");
- continue;
- }
- if (!(upper || lower || digit))
- continue;
- setflags(2);
- if (crmod) {
- tmode.c_iflag |= ICRNL;
- tmode.c_oflag |= ONLCR;
- }
-#if XXX
- if (upper || UC)
- tmode.sg_flags |= LCASE;
- if (lower || LC)
- tmode.sg_flags &= ~LCASE;
-#endif
- if (tcsetattr(0, TCSANOW, &tmode) < 0) {
- syslog(LOG_ERR, "%s: %m", ttyn);
- exit(1);
- }
- signal(SIGINT, SIG_DFL);
- for (i = 0; environ[i] != (char *)0; i++)
- env[i] = environ[i];
- makeenv(&env[i]);
-
- limit.rlim_max = RLIM_INFINITY;
- limit.rlim_cur = RLIM_INFINITY;
- (void)setrlimit(RLIMIT_CPU, &limit);
- execle(LO, "login", "-p", name, (char *) 0, env);
- syslog(LOG_ERR, "%s: %m", LO);
- exit(1);
- }
- alarm(0);
- signal(SIGALRM, SIG_DFL);
- signal(SIGINT, SIG_IGN);
- if (NX && *NX)
- tname = NX;
- }
-}
-
-static int
-getname()
-{
- register int c;
- register char *np;
- char cs;
-
- /*
- * Interrupt may happen if we use CBREAK mode
- */
- if (setjmp(intrupt)) {
- signal(SIGINT, SIG_IGN);
- return (0);
- }
- signal(SIGINT, interrupt);
- setflags(1);
- prompt();
- if (PF > 0) {
- oflush();
- sleep(PF);
- PF = 0;
- }
- if (tcsetattr(0, TCSANOW, &tmode) < 0) {
- syslog(LOG_ERR, "%s: %m", ttyn);
- exit(1);
- }
- crmod = digit = lower = upper = 0;
- np = name;
- for (;;) {
- oflush();
- if (read(STDIN_FILENO, &cs, 1) <= 0)
- exit(0);
- if ((c = cs&0177) == 0)
- return (0);
- if (c == EOT)
- exit(1);
- if (c == '\r' || c == '\n' || np >= &name[sizeof name]) {
- putf("\r\n");
- break;
- }
- if (islower(c))
- lower = 1;
- else if (isupper(c))
- upper = 1;
- else if (c == ERASE || c == '#' || c == '\b') {
- if (np > name) {
- np--;
- if (cfgetospeed(&tmode) >= 1200)
- puts("\b \b");
- else
- putchr(cs);
- }
- continue;
- } else if (c == KILL || c == '@') {
- putchr(cs);
- putchr('\r');
- if (cfgetospeed(&tmode) < 1200)
- putchr('\n');
- /* this is the way they do it down under ... */
- else if (np > name)
- puts(" \r");
- prompt();
- np = name;
- continue;
- } else if (isdigit(c))
- digit++;
- if (IG && (c <= ' ' || c > 0176))
- continue;
- *np++ = c;
- putchr(cs);
- }
- signal(SIGINT, SIG_IGN);
- *np = 0;
- if (c == '\r')
- crmod = 1;
- if (upper && !lower && !LC || UC)
- for (np = name; *np; np++)
- if (isupper(*np))
- *np = tolower(*np);
- return (1);
-}
-
-static void
-putpad(s)
- register char *s;
-{
- register pad = 0;
- speed_t ospeed = cfgetospeed(&tmode);
-
- if (isdigit(*s)) {
- while (isdigit(*s)) {
- pad *= 10;
- pad += *s++ - '0';
- }
- pad *= 10;
- if (*s == '.' && isdigit(s[1])) {
- pad += s[1] - '0';
- s += 2;
- }
- }
-
- puts(s);
- /*
- * If no delay needed, or output speed is
- * not comprehensible, then don't try to delay.
- */
- if (pad == 0 || ospeed <= 0)
- return;
-
- /*
- * Round up by a half a character frame, and then do the delay.
- * Too bad there are no user program accessible programmed delays.
- * Transmitting pad characters slows many terminals down and also
- * loads the system.
- */
- pad = (pad * ospeed + 50000) / 100000;
- while (pad--)
- putchr(*PC);
-}
-
-static void
-puts(s)
- register char *s;
-{
- while (*s)
- putchr(*s++);
-}
-
-char outbuf[OBUFSIZ];
-int obufcnt = 0;
-
-static void
-putchr(cc)
- int cc;
-{
- char c;
-
- c = cc;
- if (!NP) {
- c |= partab[c&0177] & 0200;
- if (OP)
- c ^= 0200;
- }
- if (!UB) {
- outbuf[obufcnt++] = c;
- if (obufcnt >= OBUFSIZ)
- oflush();
- } else
- write(STDOUT_FILENO, &c, 1);
-}
-
-static void
-oflush()
-{
- if (obufcnt)
- write(STDOUT_FILENO, outbuf, obufcnt);
- obufcnt = 0;
-}
-
-static void
-prompt()
-{
-
- putf(LM);
- if (CO)
- putchr('\n');
-}
-
-static void
-putf(cp)
- register char *cp;
-{
- extern char editedhost[];
- time_t t;
- char *slash, db[100];
-
- while (*cp) {
- if (*cp != '%') {
- putchr(*cp++);
- continue;
- }
- switch (*++cp) {
-
- case 't':
- slash = strrchr(ttyn, '/');
- if (slash == (char *) 0)
- puts(ttyn);
- else
- puts(&slash[1]);
- break;
-
- case 'h':
- puts(editedhost);
- break;
-
- case 'd': {
- static char fmt[] = "%l:% %p on %A, %d %B %Y";
-
- fmt[4] = 'M'; /* I *hate* SCCS... */
- (void)time(&t);
- (void)strftime(db, sizeof(db), fmt, localtime(&t));
- puts(db);
- break;
-
- case 's':
- puts(kerninfo.sysname);
- break;
-
- case 'm':
- puts(kerninfo.machine);
- break;
-
- case 'r':
- puts(kerninfo.release);
- break;
-
- case 'v':
- puts(kerninfo.version);
- break;
- }
-
- case '%':
- putchr('%');
- break;
- }
- cp++;
- }
-}
diff --git a/libexec/getty/pathnames.h b/libexec/getty/pathnames.h
deleted file mode 100644
index 5cfe73dfa6fd..000000000000
--- a/libexec/getty/pathnames.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * from: @(#)pathnames.h 8.1 (Berkeley) 6/4/93
- * $Id: pathnames.h,v 1.3 1994/08/17 20:10:39 pk Exp $
- */
-
-#include <paths.h>
-
-#define _PATH_GETTYTAB "/etc/gettytab"
-#define _PATH_LOGIN "/usr/bin/login"
diff --git a/libexec/getty/subr.c b/libexec/getty/subr.c
deleted file mode 100644
index 8c55e37dc4f7..000000000000
--- a/libexec/getty/subr.c
+++ /dev/null
@@ -1,726 +0,0 @@
-/*
- * Copyright (c) 1983, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#ifndef lint
-/*static char sccsid[] = "from: @(#)subr.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$Id: subr.c,v 1.18 1995/10/05 08:51:31 mycroft Exp $";
-#endif /* not lint */
-
-/*
- * Melbourne getty.
- */
-#define COMPAT_43
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <termios.h>
-#include <sys/ioctl.h>
-
-#include "gettytab.h"
-#include "pathnames.h"
-#include "extern.h"
-
-extern struct termios tmode, omode;
-
-static void compatflags __P((long));
-
-/*
- * Get a table entry.
- */
-void
-gettable(name, buf)
- char *name, *buf;
-{
- register struct gettystrs *sp;
- register struct gettynums *np;
- register struct gettyflags *fp;
- long n;
- char *dba[2];
- dba[0] = _PATH_GETTYTAB;
- dba[1] = 0;
-
- if (cgetent(&buf, dba, name) != 0)
- return;
-
- for (sp = gettystrs; sp->field; sp++)
- cgetstr(buf, sp->field, &sp->value);
- for (np = gettynums; np->field; np++) {
- if (cgetnum(buf, np->field, &n) == -1)
- np->set = 0;
- else {
- np->set = 1;
- np->value = n;
- }
- }
- for (fp = gettyflags; fp->field; fp++) {
- if (cgetcap(buf, fp->field, ':') == NULL)
- fp->set = 0;
- else {
- fp->set = 1;
- fp->value = 1 ^ fp->invrt;
- }
- }
-#ifdef DEBUG
- printf("name=\"%s\", buf=\"%s\"\n", name, buf);
- for (sp = gettystrs; sp->field; sp++)
- printf("cgetstr: %s=%s\n", sp->field, sp->value);
- for (np = gettynums; np->field; np++)
- printf("cgetnum: %s=%d\n", np->field, np->value);
- for (fp = gettyflags; fp->field; fp++)
- printf("cgetflags: %s='%c' set='%c'\n", fp->field,
- fp->value + '0', fp->set + '0');
- exit(1);
-#endif /* DEBUG */
-}
-
-void
-gendefaults()
-{
- register struct gettystrs *sp;
- register struct gettynums *np;
- register struct gettyflags *fp;
-
- for (sp = gettystrs; sp->field; sp++)
- if (sp->value)
- sp->defalt = sp->value;
- for (np = gettynums; np->field; np++)
- if (np->set)
- np->defalt = np->value;
- for (fp = gettyflags; fp->field; fp++)
- if (fp->set)
- fp->defalt = fp->value;
- else
- fp->defalt = fp->invrt;
-}
-
-void
-setdefaults()
-{
- register struct gettystrs *sp;
- register struct gettynums *np;
- register struct gettyflags *fp;
-
- for (sp = gettystrs; sp->field; sp++)
- if (!sp->value)
- sp->value = sp->defalt;
- for (np = gettynums; np->field; np++)
- if (!np->set)
- np->value = np->defalt;
- for (fp = gettyflags; fp->field; fp++)
- if (!fp->set)
- fp->value = fp->defalt;
-}
-
-static char **
-charnames[] = {
- &ER, &KL, &IN, &QU, &XN, &XF, &ET, &BK,
- &SU, &DS, &RP, &FL, &WE, &LN, 0
-};
-
-static char *
-charvars[] = {
- &tmode.c_cc[VERASE], &tmode.c_cc[VKILL], &tmode.c_cc[VINTR],
- &tmode.c_cc[VQUIT], &tmode.c_cc[VSTART], &tmode.c_cc[VSTOP],
- &tmode.c_cc[VEOF], &tmode.c_cc[VEOL], &tmode.c_cc[VSUSP],
- &tmode.c_cc[VDSUSP], &tmode.c_cc[VREPRINT], &tmode.c_cc[VDISCARD],
- &tmode.c_cc[VWERASE], &tmode.c_cc[VLNEXT], 0
-};
-
-void
-setchars()
-{
- register int i;
- register char *p;
-
- for (i = 0; charnames[i]; i++) {
- p = *charnames[i];
- if (p && *p)
- *charvars[i] = *p;
- else
- *charvars[i] = _POSIX_VDISABLE;
- }
-}
-
-/* Macros to clear/set/test flags. */
-#define SET(t, f) (t) |= (f)
-#define CLR(t, f) (t) &= ~(f)
-#define ISSET(t, f) ((t) & (f))
-
-void
-setflags(n)
- int n;
-{
- register tcflag_t iflag, oflag, cflag, lflag;
-
-#ifdef COMPAT_43
- switch (n) {
- case 0:
- if (F0set) {
- compatflags(F0);
- return;
- }
- break;
- case 1:
- if (F1set) {
- compatflags(F1);
- return;
- }
- break;
- default:
- if (F2set) {
- compatflags(F2);
- return;
- }
- break;
- }
-#endif
-
- switch (n) {
- case 0:
- if (C0set && I0set && L0set && O0set) {
- tmode.c_cflag = C0;
- tmode.c_iflag = I0;
- tmode.c_lflag = L0;
- tmode.c_oflag = O0;
- return;
- }
- break;
- case 1:
- if (C1set && I1set && L1set && O1set) {
- tmode.c_cflag = C1;
- tmode.c_iflag = I1;
- tmode.c_lflag = L1;
- tmode.c_oflag = O1;
- return;
- }
- break;
- default:
- if (C2set && I2set && L2set && O2set) {
- tmode.c_cflag = C2;
- tmode.c_iflag = I2;
- tmode.c_lflag = L2;
- tmode.c_oflag = O2;
- return;
- }
- break;
- }
-
- iflag = omode.c_iflag;
- oflag = omode.c_oflag;
- cflag = omode.c_cflag;
- lflag = omode.c_lflag;
-
- if (NP) {
- CLR(cflag, CSIZE|PARENB);
- SET(cflag, CS8);
- CLR(iflag, ISTRIP|INPCK|IGNPAR);
- } else if (AP || EP || OP) {
- CLR(cflag, CSIZE);
- SET(cflag, CS7|PARENB);
- SET(iflag, ISTRIP);
- if (OP && !EP) {
- SET(iflag, INPCK|IGNPAR);
- SET(cflag, PARODD);
- if (AP)
- CLR(iflag, INPCK);
- } else if (EP && !OP) {
- SET(iflag, INPCK|IGNPAR);
- CLR(cflag, PARODD);
- if (AP)
- CLR(iflag, INPCK);
- } else if (AP || EP && OP) {
- CLR(iflag, INPCK|IGNPAR);
- CLR(cflag, PARODD);
- }
- } /* else, leave as is */
-
-#if 0
- if (UC)
- f |= LCASE;
-#endif
-
- if (HC)
- SET(cflag, HUPCL);
- else
- CLR(cflag, HUPCL);
-
- if (MB)
- SET(cflag, MDMBUF);
- else
- CLR(cflag, MDMBUF);
-
- if (NL) {
- SET(iflag, ICRNL);
- SET(oflag, ONLCR|OPOST);
- } else {
- CLR(iflag, ICRNL);
- CLR(oflag, ONLCR);
- }
-
- if (!HT)
- SET(oflag, OXTABS|OPOST);
- else
- CLR(oflag, OXTABS);
-
-#ifdef XXX_DELAY
- SET(f, delaybits());
-#endif
-
- if (n == 1) { /* read mode flags */
- if (RW) {
- iflag = 0;
- CLR(oflag, OPOST);
- CLR(cflag, CSIZE|PARENB);
- SET(cflag, CS8);
- lflag = 0;
- } else {
- CLR(lflag, ICANON);
- }
- goto out;
- }
-
- if (n == 0)
- goto out;
-
-#if 0
- if (CB)
- SET(f, CRTBS);
-#endif
-
- if (CE)
- SET(lflag, ECHOE);
- else
- CLR(lflag, ECHOE);
-
- if (CK)
- SET(lflag, ECHOKE);
- else
- CLR(lflag, ECHOKE);
-
- if (PE)
- SET(lflag, ECHOPRT);
- else
- CLR(lflag, ECHOPRT);
-
- if (EC)
- SET(lflag, ECHO);
- else
- CLR(lflag, ECHO);
-
- if (XC)
- SET(lflag, ECHOCTL);
- else
- CLR(lflag, ECHOCTL);
-
- if (DX)
- SET(lflag, IXANY);
- else
- CLR(lflag, IXANY);
-
-out:
- tmode.c_iflag = iflag;
- tmode.c_oflag = oflag;
- tmode.c_cflag = cflag;
- tmode.c_lflag = lflag;
-}
-
-#ifdef COMPAT_43
-/*
- * Old TTY => termios, snatched from <sys/kern/tty_compat.c>
- */
-void
-compatflags(flags)
-register long flags;
-{
- register tcflag_t iflag, oflag, cflag, lflag;
-
- iflag = BRKINT|ICRNL|IMAXBEL|IXON|IXANY;
- oflag = OPOST|ONLCR|OXTABS;
- cflag = CREAD;
- lflag = ICANON|ISIG|IEXTEN;
-
- if (ISSET(flags, TANDEM))
- SET(iflag, IXOFF);
- else
- CLR(iflag, IXOFF);
- if (ISSET(flags, ECHO))
- SET(lflag, ECHO);
- else
- CLR(lflag, ECHO);
- if (ISSET(flags, CRMOD)) {
- SET(iflag, ICRNL);
- SET(oflag, ONLCR);
- } else {
- CLR(iflag, ICRNL);
- CLR(oflag, ONLCR);
- }
- if (ISSET(flags, XTABS))
- SET(oflag, OXTABS);
- else
- CLR(oflag, OXTABS);
-
-
- if (ISSET(flags, RAW)) {
- iflag &= IXOFF;
- CLR(lflag, ISIG|ICANON|IEXTEN);
- CLR(cflag, PARENB);
- } else {
- SET(iflag, BRKINT|IXON|IMAXBEL);
- SET(lflag, ISIG|IEXTEN);
- if (ISSET(flags, CBREAK))
- CLR(lflag, ICANON);
- else
- SET(lflag, ICANON);
- switch (ISSET(flags, ANYP)) {
- case 0:
- CLR(cflag, PARENB);
- break;
- case ANYP:
- SET(cflag, PARENB);
- CLR(iflag, INPCK);
- break;
- case EVENP:
- SET(cflag, PARENB);
- SET(iflag, INPCK);
- CLR(cflag, PARODD);
- break;
- case ODDP:
- SET(cflag, PARENB);
- SET(iflag, INPCK);
- SET(cflag, PARODD);
- break;
- }
- }
-
- /* Nothing we can do with CRTBS. */
- if (ISSET(flags, PRTERA))
- SET(lflag, ECHOPRT);
- else
- CLR(lflag, ECHOPRT);
- if (ISSET(flags, CRTERA))
- SET(lflag, ECHOE);
- else
- CLR(lflag, ECHOE);
- /* Nothing we can do with TILDE. */
- if (ISSET(flags, MDMBUF))
- SET(cflag, MDMBUF);
- else
- CLR(cflag, MDMBUF);
- if (ISSET(flags, NOHANG))
- CLR(cflag, HUPCL);
- else
- SET(cflag, HUPCL);
- if (ISSET(flags, CRTKIL))
- SET(lflag, ECHOKE);
- else
- CLR(lflag, ECHOKE);
- if (ISSET(flags, CTLECH))
- SET(lflag, ECHOCTL);
- else
- CLR(lflag, ECHOCTL);
- if (!ISSET(flags, DECCTQ))
- SET(iflag, IXANY);
- else
- CLR(iflag, IXANY);
- CLR(lflag, TOSTOP|FLUSHO|PENDIN|NOFLSH);
- SET(lflag, ISSET(flags, TOSTOP|FLUSHO|PENDIN|NOFLSH));
-
- if (ISSET(flags, RAW|LITOUT|PASS8)) {
- CLR(cflag, CSIZE);
- SET(cflag, CS8);
- if (!ISSET(flags, RAW|PASS8))
- SET(iflag, ISTRIP);
- else
- CLR(iflag, ISTRIP);
- if (!ISSET(flags, RAW|LITOUT))
- SET(oflag, OPOST);
- else
- CLR(oflag, OPOST);
- } else {
- CLR(cflag, CSIZE);
- SET(cflag, CS7);
- SET(iflag, ISTRIP);
- SET(oflag, OPOST);
- }
-
- tmode.c_iflag = iflag;
- tmode.c_oflag = oflag;
- tmode.c_cflag = cflag;
- tmode.c_lflag = lflag;
-}
-#endif
-
-#ifdef XXX_DELAY
-struct delayval {
- unsigned delay; /* delay in ms */
- int bits;
-};
-
-/*
- * below are random guesses, I can't be bothered checking
- */
-
-struct delayval crdelay[] = {
- { 1, CR1 },
- { 2, CR2 },
- { 3, CR3 },
- { 83, CR1 },
- { 166, CR2 },
- { 0, CR3 },
-};
-
-struct delayval nldelay[] = {
- { 1, NL1 }, /* special, calculated */
- { 2, NL2 },
- { 3, NL3 },
- { 100, NL2 },
- { 0, NL3 },
-};
-
-struct delayval bsdelay[] = {
- { 1, BS1 },
- { 0, 0 },
-};
-
-struct delayval ffdelay[] = {
- { 1, FF1 },
- { 1750, FF1 },
- { 0, FF1 },
-};
-
-struct delayval tbdelay[] = {
- { 1, TAB1 },
- { 2, TAB2 },
- { 3, XTABS }, /* this is expand tabs */
- { 100, TAB1 },
- { 0, TAB2 },
-};
-
-int
-delaybits()
-{
- register int f;
-
- f = adelay(CD, crdelay);
- f |= adelay(ND, nldelay);
- f |= adelay(FD, ffdelay);
- f |= adelay(TD, tbdelay);
- f |= adelay(BD, bsdelay);
- return (f);
-}
-
-int
-adelay(ms, dp)
- register ms;
- register struct delayval *dp;
-{
- if (ms == 0)
- return (0);
- while (dp->delay && ms > dp->delay)
- dp++;
- return (dp->bits);
-}
-#endif
-
-char editedhost[32];
-
-void
-edithost(pat)
- register char *pat;
-{
- register char *host = HN;
- register char *res = editedhost;
-
- if (!pat)
- pat = "";
- while (*pat) {
- switch (*pat) {
-
- case '#':
- if (*host)
- host++;
- break;
-
- case '@':
- if (*host)
- *res++ = *host++;
- break;
-
- default:
- *res++ = *pat;
- break;
-
- }
- if (res == &editedhost[sizeof editedhost - 1]) {
- *res = '\0';
- return;
- }
- pat++;
- }
- if (*host)
- strncpy(res, host, sizeof editedhost - (res - editedhost) - 1);
- else
- *res = '\0';
- editedhost[sizeof editedhost - 1] = '\0';
-}
-
-void
-makeenv(env)
- char *env[];
-{
- static char termbuf[128] = "TERM=";
- register char *p, *q;
- register char **ep;
-
- ep = env;
- if (TT && *TT) {
- strcat(termbuf, TT);
- *ep++ = termbuf;
- }
- if (p = EV) {
- q = p;
- while (q = strchr(q, ',')) {
- *q++ = '\0';
- *ep++ = p;
- p = q;
- }
- if (*p)
- *ep++ = p;
- }
- *ep = (char *)0;
-}
-
-/*
- * This speed select mechanism is written for the Develcon DATASWITCH.
- * The Develcon sends a string of the form "B{speed}\n" at a predefined
- * baud rate. This string indicates the user's actual speed.
- * The routine below returns the terminal type mapped from derived speed.
- */
-struct portselect {
- char *ps_baud;
- char *ps_type;
-} portspeeds[] = {
- { "B110", "std.110" },
- { "B134", "std.134" },
- { "B150", "std.150" },
- { "B300", "std.300" },
- { "B600", "std.600" },
- { "B1200", "std.1200" },
- { "B2400", "std.2400" },
- { "B4800", "std.4800" },
- { "B9600", "std.9600" },
- { "B19200", "std.19200" },
- { 0 }
-};
-
-char *
-portselector()
-{
- char c, baud[20], *type = "default";
- register struct portselect *ps;
- int len;
-
- alarm(5*60);
- for (len = 0; len < sizeof (baud) - 1; len++) {
- if (read(STDIN_FILENO, &c, 1) <= 0)
- break;
- c &= 0177;
- if (c == '\n' || c == '\r')
- break;
- if (c == 'B')
- len = 0; /* in case of leading garbage */
- baud[len] = c;
- }
- baud[len] = '\0';
- for (ps = portspeeds; ps->ps_baud; ps++)
- if (strcmp(ps->ps_baud, baud) == 0) {
- type = ps->ps_type;
- break;
- }
- sleep(2); /* wait for connection to complete */
- return (type);
-}
-
-/*
- * This auto-baud speed select mechanism is written for the Micom 600
- * portselector. Selection is done by looking at how the character '\r'
- * is garbled at the different speeds.
- */
-#include <sys/time.h>
-
-char *
-autobaud()
-{
- int rfds;
- struct timeval timeout;
- char c, *type = "9600-baud";
-
- (void)tcflush(0, TCIOFLUSH);
- rfds = 1 << 0;
- timeout.tv_sec = 5;
- timeout.tv_usec = 0;
- if (select(32, (fd_set *)&rfds, (fd_set *)NULL,
- (fd_set *)NULL, &timeout) <= 0)
- return (type);
- if (read(STDIN_FILENO, &c, sizeof(char)) != sizeof(char))
- return (type);
- timeout.tv_sec = 0;
- timeout.tv_usec = 20;
- (void) select(32, (fd_set *)NULL, (fd_set *)NULL,
- (fd_set *)NULL, &timeout);
- (void)tcflush(0, TCIOFLUSH);
- switch (c & 0377) {
-
- case 0200: /* 300-baud */
- type = "300-baud";
- break;
-
- case 0346: /* 1200-baud */
- type = "1200-baud";
- break;
-
- case 015: /* 2400-baud */
- case 0215:
- type = "2400-baud";
- break;
-
- default: /* 4800-baud */
- type = "4800-baud";
- break;
-
- case 0377: /* 9600-baud */
- type = "9600-baud";
- break;
- }
- return (type);
-}
diff --git a/libexec/getty/ttys.5 b/libexec/getty/ttys.5
deleted file mode 100644
index 59287821c827..000000000000
--- a/libexec/getty/ttys.5
+++ /dev/null
@@ -1,153 +0,0 @@
-.\" Copyright (c) 1985, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" from: @(#)ttys.5 8.1 (Berkeley) 6/4/93
-.\" $Id: ttys.5,v 1.6 1994/08/17 20:10:41 pk Exp $
-.\"
-.Dd June 4, 1993
-.Dt TTYS 5
-.Os
-.Sh NAME
-.Nm ttys
-.Nd terminal initialization information
-.Sh DESCRIPTION
-The file
-.Nm ttys
-contains information that is used by various routines to initialize
-and control the use of terminal special files.
-This information is read with the
-.Xr getttyent 3
-library routines.
-There is one line in the
-.Nm ttys
-file per special device file.
-Fields are separated by tabs and/or spaces.
-Fields comprised of more than one word should be enclosed in double
-quotes (``"'').
-Blank lines and comments may appear anywhere in the file; comments
-are delimited by hash marks (``#'') and new lines.
-Any unspecified fields will default to null.
-.Pp
-The first field is the
-name of the terminal special file as it is found in
-.Pa /dev .
-.Pp
-The second field of the file is the command to execute for the line,
-usually
-.Xr getty 8 ,
-which initializes and opens the line, setting the speed, waiting for
-a user name and executing the
-.Xr login 1
-program.
-It can be, however, any desired command, for example
-the start up for a window system terminal emulator or some other
-daemon process, and can contain multiple words if quoted.
-.Pp
-The third field is the type of terminal usually connected to that
-tty line, normally the one found in the
-.Xr termcap 5
-data base file.
-The environment variable
-.Dv TERM
-is initialized with the value by
-either
-.Xr getty 8
-or
-.Xr login 1 .
-.Pp
-The remaining fields set flags in the
-.Fa ty_status
-entry (see
-.Xr getttyent 3 )
-or specify a window system process that
-.Xr init 8
-will maintain for the terminal line.
-.Pp
-As flag values, the strings ``on'' and ``off'' specify that
-.Xr init
-should (should not) execute the command given in the second field,
-while ``secure'' (if ``on'' is also specified) allows users with a
-uid of 0 to login on
-this line.
-The flags ``local'', ``rtscts'', ``mdmbuf'', and ``softcar''
-modify the default behaviour of the terminal line, and their actions
-are driver dependent.
-The ``local'' flag causes the driver to
-treat the line as if it locally connected.
-The ``rtscts'' flag
-instructs the driver to use RTS/CTS hardware flow control, if
-possible.
-The ``mdmbuf'' flag instructs the driver to use
-DTR/DCD flow control, if possible.
-The ``softcar'' flag causes the driver to ignore
-hardware carrier on the line.
-These flag fields should not be quoted.
-.Pp
-The string ``window='' may be followed by a quoted command
-string which
-.Xr init
-will execute
-.Em before
-starting the command specified by the second field.
-.Sh EXAMPLES
-.Bd -literal
-# root login on console at 1200 baud
-console "/usr/libexec/getty std.1200" vt100 on secure
-# dialup at 1200 baud, no root logins
-ttyd0 "/usr/libexec/getty d1200" dialup on # 555-1234
-# Mike's terminal: hp2621
-ttyh0 "/usr/libexec/getty std.9600" hp2621-nl on # 457 Evans
-# John's terminal: vt100
-ttyh1 "/usr/libexec/getty std.9600" vt100 on # 459 Evans
-# terminal emulate/window system
-ttyv0 "/usr/new/xterm -L :0" vs100 on window="/usr/new/Xvs100 0"
-# Network pseudo ttys -- don't enable getty
-ttyp0 none network
-ttyp1 none network off
-.Ed
-.Sh FILES
-.Bl -tag -width /etc/ttys -compact
-.It Pa /etc/ttys
-.El
-.Sh SEE ALSO
-.Xr login 1 ,
-.Xr getttyent 3 ,
-.Xr ttyslot 3 ,
-.Xr gettytab 5 ,
-.Xr termcap 5 ,
-.Xr getty 8 ,
-.Xr init 8 ,
-.Xr ttyflags 8
-.Sh HISTORY
-A
-.Nm
-file appeared in
-.At v6 .
diff --git a/libexec/rpc.rquotad/Makefile b/libexec/rpc.rquotad/Makefile
deleted file mode 100644
index 7618d98f4a48..000000000000
--- a/libexec/rpc.rquotad/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# $Id: Makefile,v 1.3 1995/04/12 00:47:27 jtc Exp $
-
-PROG = rpc.rquotad
-SRCS = rquotad.c
-MAN8 = rpc.rquotad.8
-
-DPADD= ${LIBRPCSVC}
-LDADD= -lrpcsvc
-
-.include <bsd.prog.mk>
diff --git a/libexec/rpc.rquotad/rpc.rquotad.8 b/libexec/rpc.rquotad/rpc.rquotad.8
deleted file mode 100644
index b378cc33f47d..000000000000
--- a/libexec/rpc.rquotad/rpc.rquotad.8
+++ /dev/null
@@ -1,58 +0,0 @@
-.\"
-.\" Copyright (c) 1994 Theo de Raadt
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by Theo de Raadt.
-.\" 4. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $Id: rpc.rquotad.8,v 1.2 1995/04/12 00:47:32 jtc Exp $
-.\"
-.Dd June 22, 1994
-.Dt RPC.RQUOTAD 8
-.Os BSD 4.3
-.Sh NAME
-.Nm rpc.rquotad
-.Nd remote quota server
-.Sh SYNOPSIS
-.Nm /usr/libexec/rpc.rquotad
-.Sh DESCRIPTION
-.Nm rpc.rquotad
-is a
-.Xr rpc 3
-server which returns quotas for a user of a local filesystem
-which is NFS-mounted onto a remote machine.
-.Xr quota 1
-uses the results to display user quotas for remote filesystems.
-.Nm rpc.rquotad
-is normally invoked by
-.Xr inetd 8 .
-.Pp
-.Nm rpc.rquotad
-uses an RPC protocol defined in
-.Pa /usr/include/rpcsvc/rquota.x .
-.Sh BUGS
-BSD 4.4 and NetBSD support group quotas but the rquota protocol does not.
-.Sh SEE ALSO
-.Xr quota 1
diff --git a/libexec/rpc.rquotad/rquotad.c b/libexec/rpc.rquotad/rquotad.c
deleted file mode 100644
index 33fa420b17f4..000000000000
--- a/libexec/rpc.rquotad/rquotad.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * by Manuel Bouyer (bouyer@ensta.fr)
- *
- * There is no copyright, you can use it as you want.
- */
-
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/mount.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <signal.h>
-
-#include <stdio.h>
-#include <fstab.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <pwd.h>
-#include <grp.h>
-#include <errno.h>
-
-#include <syslog.h>
-#include <varargs.h>
-
-#include <ufs/ufs/quota.h>
-#include <rpc/rpc.h>
-#include <rpc/pmap_clnt.h>
-#include <rpcsvc/rquota.h>
-#include <arpa/inet.h>
-
-void rquota_service __P((struct svc_req *request, SVCXPRT *transp));
-void sendquota __P((struct svc_req *request, SVCXPRT *transp));
-void printerr_reply __P((SVCXPRT *transp));
-void initfs __P((void));
-int getfsquota __P((long id, char *path, struct dqblk *dqblk));
-int hasquota __P((struct fstab *fs, char **qfnamep));
-
-/*
- * structure containing informations about ufs filesystems
- * initialised by initfs()
- */
-struct fs_stat {
- struct fs_stat *fs_next; /* next element */
- char *fs_file; /* mount point of the filesystem */
- char *qfpathname; /* pathname of the quota file */
- dev_t st_dev; /* device of the filesystem */
-} fs_stat;
-struct fs_stat *fs_begin = NULL;
-
-int from_inetd = 1;
-
-void
-cleanup()
-{
- (void) pmap_unset(RQUOTAPROG, RQUOTAVERS);
- exit(0);
-}
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- SVCXPRT *transp;
- int sock = 0;
- int proto = 0;
- struct sockaddr_in from;
- int fromlen;
-
- fromlen = sizeof(from);
- if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
- from_inetd = 0;
- sock = RPC_ANYSOCK;
- proto = IPPROTO_UDP;
- }
-
- if (!from_inetd) {
- daemon(0, 0);
-
- (void) pmap_unset(RQUOTAPROG, RQUOTAVERS);
-
- (void) signal(SIGINT, cleanup);
- (void) signal(SIGTERM, cleanup);
- (void) signal(SIGHUP, cleanup);
- }
-
- openlog("rpc.rquotad", LOG_CONS|LOG_PID, LOG_DAEMON);
-
- /* create and register the service */
- transp = svcudp_create(sock);
- if (transp == NULL) {
- syslog(LOG_ERR, "couldn't create udp service.");
- exit(1);
- }
- if (!svc_register(transp, RQUOTAPROG, RQUOTAVERS, rquota_service, proto)) {
- syslog(LOG_ERR, "unable to register (RQUOTAPROG, RQUOTAVERS, %s).", proto?"udp":"(inetd)");
- exit(1);
- }
-
- initfs(); /* init the fs_stat list */
- svc_run();
- syslog(LOG_ERR, "svc_run returned");
- exit(1);
-}
-
-void
-rquota_service(request, transp)
- struct svc_req *request;
- SVCXPRT *transp;
-{
- switch (request->rq_proc) {
- case NULLPROC:
- (void)svc_sendreply(transp, xdr_void, (char *)NULL);
- break;
-
- case RQUOTAPROC_GETQUOTA:
- case RQUOTAPROC_GETACTIVEQUOTA:
- sendquota(request, transp);
- break;
-
- default:
- svcerr_noproc(transp);
- break;
- }
- if (from_inetd)
- exit(0);
-}
-
-/* read quota for the specified id, and send it */
-void
-sendquota(request, transp)
- struct svc_req *request;
- SVCXPRT *transp;
-{
- struct getquota_args getq_args;
- struct getquota_rslt getq_rslt;
- struct dqblk dqblk;
- struct timeval timev;
-
- bzero((char *)&getq_args, sizeof(getq_args));
- if (!svc_getargs(transp, xdr_getquota_args, (caddr_t)&getq_args)) {
- svcerr_decode(transp);
- return;
- }
- if (request->rq_cred.oa_flavor != AUTH_UNIX) {
- /* bad auth */
- getq_rslt.status = Q_EPERM;
- } else if (!getfsquota(getq_args.gqa_uid, getq_args.gqa_pathp, &dqblk)) {
- /* failed, return noquota */
- getq_rslt.status = Q_NOQUOTA;
- } else {
- gettimeofday(&timev, NULL);
- getq_rslt.status = Q_OK;
- getq_rslt.getquota_rslt_u.gqr_rquota.rq_active = TRUE;
- getq_rslt.getquota_rslt_u.gqr_rquota.rq_bsize = DEV_BSIZE;
- getq_rslt.getquota_rslt_u.gqr_rquota.rq_bhardlimit =
- dqblk.dqb_bhardlimit;
- getq_rslt.getquota_rslt_u.gqr_rquota.rq_bsoftlimit =
- dqblk.dqb_bsoftlimit;
- getq_rslt.getquota_rslt_u.gqr_rquota.rq_curblocks =
- dqblk.dqb_curblocks;
- getq_rslt.getquota_rslt_u.gqr_rquota.rq_fhardlimit =
- dqblk.dqb_ihardlimit;
- getq_rslt.getquota_rslt_u.gqr_rquota.rq_fsoftlimit =
- dqblk.dqb_isoftlimit;
- getq_rslt.getquota_rslt_u.gqr_rquota.rq_curfiles =
- dqblk.dqb_curinodes;
- getq_rslt.getquota_rslt_u.gqr_rquota.rq_btimeleft =
- dqblk.dqb_btime - timev.tv_sec;
- getq_rslt.getquota_rslt_u.gqr_rquota.rq_ftimeleft =
- dqblk.dqb_itime - timev.tv_sec;
- }
- if (!svc_sendreply(transp, xdr_getquota_rslt, (char *)&getq_rslt)) {
- svcerr_systemerr(transp);
- }
- if (!svc_freeargs(transp, xdr_getquota_args, (caddr_t)&getq_args)) {
- syslog(LOG_ERR, "unable to free arguments");
- exit(1);
- }
-}
-
-void
-printerr_reply(transp) /* when a reply to a request failed */
- SVCXPRT *transp;
-{
- char *name;
- struct sockaddr_in *caller;
- int save_errno;
-
- save_errno = errno;
-
- caller = svc_getcaller(transp);
- name = (char *)inet_ntoa(caller->sin_addr);
- errno = save_errno;
- if (errno == 0)
- syslog(LOG_ERR, "couldn't send reply to %s", name);
- else
- syslog(LOG_ERR, "couldn't send reply to %s: %m", name);
-}
-
-/* initialise the fs_tab list from entries in /etc/fstab */
-void
-initfs()
-{
- struct fs_stat *fs_current = NULL;
- struct fs_stat *fs_next = NULL;
- char *qfpathname;
- struct fstab *fs;
- struct stat st;
-
- setfsent();
- while ((fs = getfsent())) {
- if (strcmp(fs->fs_vfstype, "ufs"))
- continue;
- if (!hasquota(fs, &qfpathname))
- continue;
-
- fs_current = (struct fs_stat *) malloc(sizeof(struct fs_stat));
- fs_current->fs_next = fs_next; /* next element */
-
- fs_current->fs_file = malloc(sizeof(char) * (strlen(fs->fs_file) + 1));
- strcpy(fs_current->fs_file, fs->fs_file);
-
- fs_current->qfpathname = malloc(sizeof(char) * (strlen(qfpathname) + 1));
- strcpy(fs_current->qfpathname, qfpathname);
-
- stat(qfpathname, &st);
- fs_current->st_dev = st.st_dev;
-
- fs_next = fs_current;
- }
- endfsent();
- fs_begin = fs_current;
-}
-
-/*
- * gets the quotas for id, filesystem path.
- * Return 0 if fail, 1 otherwise
- */
-int
-getfsquota(id, path, dqblk)
- long id;
- char *path;
- struct dqblk *dqblk;
-{
- struct stat st_path;
- struct fs_stat *fs;
- int qcmd, fd, ret = 0;
-
- if (stat(path, &st_path) < 0)
- return (0);
-
- qcmd = QCMD(Q_GETQUOTA, USRQUOTA);
-
- for (fs = fs_begin; fs != NULL; fs = fs->fs_next) {
- /* where the devise is the same as path */
- if (fs->st_dev != st_path.st_dev)
- continue;
-
- /* find the specified filesystem. get and return quota */
- if (quotactl(fs->fs_file, qcmd, id, dqblk) == 0)
- return (1);
-
- if ((fd = open(fs->qfpathname, O_RDONLY)) < 0) {
- syslog(LOG_ERR, "open error: %s: %m", fs->qfpathname);
- return (0);
- }
- if (lseek(fd, (off_t)(id * sizeof(struct dqblk)), L_SET) == (off_t)-1) {
- close(fd);
- return (1);
- }
- switch (read(fd, dqblk, sizeof(struct dqblk))) {
- case 0:
- /*
- * Convert implicit 0 quota (EOF)
- * into an explicit one (zero'ed dqblk)
- */
- bzero((caddr_t) dqblk, sizeof(struct dqblk));
- ret = 1;
- break;
- case sizeof(struct dqblk): /* OK */
- ret = 1;
- break;
- default: /* ERROR */
- syslog(LOG_ERR, "read error: %s: %m", fs->qfpathname);
- close(fd);
- return (0);
- }
- close(fd);
- }
- return (ret);
-}
-
-/*
- * Check to see if a particular quota is to be enabled.
- * Comes from quota.c, NetBSD 0.9
- */
-int
-hasquota(fs, qfnamep)
- struct fstab *fs;
- char **qfnamep;
-{
- static char initname, usrname[100];
- static char buf[BUFSIZ];
- char *opt, *cp;
- char *qfextension[] = INITQFNAMES;
-
- if (!initname) {
- sprintf(usrname, "%s%s", qfextension[USRQUOTA], QUOTAFILENAME);
- initname = 1;
- }
- strcpy(buf, fs->fs_mntops);
- for (opt = strtok(buf, ","); opt; opt = strtok(NULL, ",")) {
- if ((cp = index(opt, '=')))
- *cp++ = '\0';
- if (strcmp(opt, usrname) == 0)
- break;
- }
- if (!opt)
- return (0);
- if (cp) {
- *qfnamep = cp;
- return (1);
- }
- sprintf(buf, "%s/%s.%s", fs->fs_file, QUOTAFILENAME, qfextension[USRQUOTA]);
- *qfnamep = buf;
- return (1);
-}
diff --git a/libexec/rpc.sprayd/Makefile b/libexec/rpc.sprayd/Makefile
deleted file mode 100644
index e497599a8451..000000000000
--- a/libexec/rpc.sprayd/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-# $Id: Makefile,v 1.3 1995/04/12 00:48:01 jtc Exp $
-
-PROG = rpc.sprayd
-SRCS = sprayd.c
-MAN8 = rpc.sprayd.8
-
-DPADD= ${LIBRPCSVC}
-LDADD= -lrpcsvc
-
-.include <bsd.prog.mk>
-
diff --git a/libexec/rpc.sprayd/rpc.sprayd.8 b/libexec/rpc.sprayd/rpc.sprayd.8
deleted file mode 100644
index cff47264ca97..000000000000
--- a/libexec/rpc.sprayd/rpc.sprayd.8
+++ /dev/null
@@ -1,54 +0,0 @@
-.\"
-.\" Copyright (c) 1994 Christos Zoulas
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by Christos Zoulas.
-.\" 4. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $Id: rpc.sprayd.8,v 1.2 1995/04/12 00:48:03 jtc Exp $
-.\"
-.Dd June 22, 1994
-.Dt RPC.SPRAYD 8
-.Os BSD 4.3
-.Sh NAME
-.Nm rpc.sprayd
-.Nd spray server
-.Sh SYNOPSIS
-.Nm /usr/libexec/rpc.sprayd
-.Sh DESCRIPTION
-.Nm rpc.sprayd
-is a server which records packets sent by the
-.Xr spray 1
-command and sends a traffic report to the originator of the packets.
-The
-.Nm rpc.sprayd
-daemon is normally invoked by
-.Xr inetd 8 .
-.Pp
-.Nm rpc.sprayd
-uses an RPC protocol defined in
-.Pa /usr/include/rpcsvc/spray.x .
-.Sh SEE ALSO
-.Xr spray 8
diff --git a/libexec/rpc.sprayd/sprayd.c b/libexec/rpc.sprayd/sprayd.c
deleted file mode 100644
index 28ae295fad05..000000000000
--- a/libexec/rpc.sprayd/sprayd.c
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (c) 1994 Christos Zoulas
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Christos Zoulas.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $Id: sprayd.c,v 1.7 1995/03/26 23:36:44 mycroft Exp $
- */
-
-#ifndef lint
-static char rcsid[] = "$Id: sprayd.c,v 1.7 1995/03/26 23:36:44 mycroft Exp $";
-#endif /* not lint */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <unistd.h>
-#include <rpc/rpc.h>
-#include <rpc/pmap_clnt.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <syslog.h>
-#include <rpcsvc/spray.h>
-
-static void spray_service __P((struct svc_req *, SVCXPRT *));
-
-static int from_inetd = 1;
-
-#define timersub(tvp, uvp, vvp) \
- do { \
- (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
- (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
- if ((vvp)->tv_usec < 0) { \
- (vvp)->tv_sec--; \
- (vvp)->tv_usec += 1000000; \
- } \
- } while (0)
-
-#define TIMEOUT 120
-
-void
-cleanup()
-{
- (void) pmap_unset(SPRAYPROG, SPRAYVERS);
- exit(0);
-}
-
-void
-die()
-{
- exit(0);
-}
-
-int
-main(argc, argv)
- int argc;
- char *argv[];
-{
- SVCXPRT *transp;
- int sock = 0;
- int proto = 0;
- struct sockaddr_in from;
- int fromlen;
-
- /*
- * See if inetd started us
- */
- fromlen = sizeof(from);
- if (getsockname(0, (struct sockaddr *)&from, &fromlen) < 0) {
- from_inetd = 0;
- sock = RPC_ANYSOCK;
- proto = IPPROTO_UDP;
- }
-
- if (!from_inetd) {
- daemon(0, 0);
-
- (void) pmap_unset(SPRAYPROG, SPRAYVERS);
-
- (void) signal(SIGINT, cleanup);
- (void) signal(SIGTERM, cleanup);
- (void) signal(SIGHUP, cleanup);
- } else {
- (void) signal(SIGALRM, die);
- alarm(TIMEOUT);
- }
-
- openlog("rpc.sprayd", LOG_CONS|LOG_PID, LOG_DAEMON);
-
- transp = svcudp_create(sock);
- if (transp == NULL) {
- syslog(LOG_ERR, "cannot create udp service.");
- return 1;
- }
- if (!svc_register(transp, SPRAYPROG, SPRAYVERS, spray_service, proto)) {
- syslog(LOG_ERR,
- "unable to register (SPRAYPROG, SPRAYVERS, %s).",
- proto ? "udp" : "(inetd)");
- return 1;
- }
-
- svc_run();
- syslog(LOG_ERR, "svc_run returned");
- return 1;
-}
-
-
-static void
-spray_service(rqstp, transp)
- struct svc_req *rqstp;
- SVCXPRT *transp;
-{
- static spraycumul scum;
- static struct timeval clear, get;
-
- switch (rqstp->rq_proc) {
- case SPRAYPROC_CLEAR:
- scum.counter = 0;
- (void) gettimeofday(&clear, 0);
- /*FALLTHROUGH*/
-
- case NULLPROC:
- (void)svc_sendreply(transp, xdr_void, (char *)NULL);
- return;
-
- case SPRAYPROC_SPRAY:
- scum.counter++;
- return;
-
- case SPRAYPROC_GET:
- (void) gettimeofday(&get, 0);
- timersub(&get, &clear, &get);
- scum.clock.sec = get.tv_sec;
- scum.clock.usec = get.tv_usec;
- break;
-
- default:
- svcerr_noproc(transp);
- return;
- }
-
- if (!svc_sendreply(transp, xdr_spraycumul, (caddr_t)&scum)) {
- svcerr_systemerr(transp);
- syslog(LOG_ERR, "bad svc_sendreply");
- }
-}