From a35e16a9eeda5673a313b919f149f8fa299ed8cd Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 3 Oct 2016 10:37:38 +0200
Subject: [PATCH 5/6] getty(8): Sync with FreeBSD.

---
 libexec/getty/Makefile    |   3 +-
 libexec/getty/chat.c      |  39 +++-----
 libexec/getty/extern.h    |  34 +++----
 libexec/getty/getty.8     |  11 +--
 libexec/getty/gettytab.5  | 166 ++++++++++++++++++---------------
 libexec/getty/gettytab.h  |   4 +-
 libexec/getty/init.c      |  33 ++++---
 libexec/getty/main.c      | 229 ++++++++++++++++++++++++++--------------------
 libexec/getty/pathnames.h |   3 +-
 libexec/getty/subr.c      | 197 ++++-----------------------------------
 libexec/getty/ttys.5      |  18 ++--
 11 files changed, 302 insertions(+), 435 deletions(-)

diff --git a/libexec/getty/Makefile b/libexec/getty/Makefile
index ed85691..bd38b44 100644
--- a/libexec/getty/Makefile
+++ b/libexec/getty/Makefile
@@ -1,6 +1,5 @@
 #	from: @(#)Makefile	8.1 (Berkeley) 6/4/93
-# $FreeBSD: src/libexec/getty/Makefile,v 1.9.2.1 2001/04/25 10:40:52 ru Exp $
-# $DragonFly: src/libexec/getty/Makefile,v 1.2 2003/06/17 04:27:07 dillon Exp $
+# $FreeBSD: head/libexec/getty/Makefile 275077 2014-11-25 21:18:18Z bapt $
 
 PROG=	getty
 SRCS=	main.c init.c subr.c chat.c
diff --git a/libexec/getty/chat.c b/libexec/getty/chat.c
index f16f1c0..ad552e4 100644
--- a/libexec/getty/chat.c
+++ b/libexec/getty/chat.c
@@ -22,30 +22,19 @@
  * Modem chat module - send/expect style functions for getty
  * For semi-intelligent modem handling.
  *
- * $FreeBSD: src/libexec/getty/chat.c,v 1.6 1999/08/28 00:09:34 peter Exp $
- * $DragonFly: src/libexec/getty/chat.c,v 1.6 2007/11/25 18:10:06 swildner Exp $
+ * $FreeBSD: head/libexec/getty/chat.c 228582 2011-12-16 15:44:12Z dim $
  */
 
-#include <sys/param.h>
-#include <sys/stat.h>
+#include <sys/types.h>
 #include <sys/ioctl.h>
-#include <sys/resource.h>
-#include <sys/ttydefaults.h>
 #include <sys/utsname.h>
+
 #include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <libutil.h>
-#include <locale.h>
-#include <setjmp.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
-#include <time.h>
-#include <termios.h>
 #include <unistd.h>
-#include <sys/socket.h>
 
 #include "gettytab.h"
 #include "extern.h"
@@ -67,15 +56,15 @@ static int chat_alarm = CHAT_DEFAULT_TIMEOUT; /* Default */
 static volatile int alarmed = 0;
 
 
-static void   chat_alrm (int);
-static int    chat_unalarm (void);
-static int    getdigit (unsigned char **, int, int);
-static char   **read_chat (char **);
-static char   *cleanchr (char **, unsigned char);
-static char   *cleanstr (const unsigned char *, int);
-static const char *result (int);
-static int    chat_expect (const char *);
-static int    chat_send (char const *);
+static void   chat_alrm(int);
+static int    chat_unalarm(void);
+static int    getdigit(unsigned char **, int, int);
+static char   **read_chat(char **);
+static char   *cleanchr(char **, unsigned char);
+static char   *cleanstr(const unsigned char *, int);
+static const char *result(int);
+static int    chat_expect(const char *);
+static int    chat_send(char const *);
 
 
 /*
@@ -86,7 +75,7 @@ static int    chat_send (char const *);
  */
 
 static void
-chat_alrm(int signo)
+chat_alrm(int signo __unused)
 {
 	int on = 1;
 
@@ -307,7 +296,7 @@ cleanstr(const unsigned char *s, int l)
 
 
 /*
- * return result as an pseudo-english word
+ * return result as a pseudo-english word
  */
 
 static const char *
diff --git a/libexec/getty/extern.h b/libexec/getty/extern.h
index b7f0237..5444b96 100644
--- a/libexec/getty/extern.h
+++ b/libexec/getty/extern.h
@@ -27,15 +27,11 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)extern.h	8.1 (Berkeley) 6/4/93
- * $FreeBSD: src/libexec/getty/extern.h,v 1.7 2000/01/28 07:12:02 bde Exp $
- * $DragonFly: src/libexec/getty/extern.h,v 1.3 2003/11/14 03:54:30 dillon Exp $
+ * $FreeBSD: head/libexec/getty/extern.h 262136 2014-02-17 22:27:32Z brueffer $
  */
 
 struct delayval;
 struct termios;
-struct gettyflags;
-struct gettynums;
-struct gettystrs;
 
 extern	char hostname[];
 extern	int hopcount;
@@ -44,17 +40,17 @@ extern	struct gettyflags gettyflags[];
 extern	struct gettynums gettynums[];
 extern	struct gettystrs gettystrs[];
 
-int	 adelay (int, struct delayval *);
-const char *autobaud (void);
-int	 delaybits (void);
-void	 edithost (const char *);
-void	 gendefaults (void);
-void	 gettable (const char *, char *);
-void	 makeenv (char *[]);
-const char *portselector (void);
-void	 set_ttydefaults (int);
-void	 setchars (void);
-void	 setdefaults (void);
-void	 set_flags (int);
-int	 speed (int);
-int	 getty_chat (char *, int, int);
+int	 adelay(int, struct delayval *);
+const char *autobaud(void);
+int	 delaybits(void);
+void	 edithost(const char *);
+void	 gendefaults(void);
+void	 gettable(const char *, char *);
+void	 makeenv(char *[]);
+const char *portselector(void);
+void	 set_ttydefaults(int);
+void	 setchars(void);
+void	 setdefaults(void);
+void	 set_flags(int);
+int	 speed(int);
+int	 getty_chat(char *, int, int);
diff --git a/libexec/getty/getty.8 b/libexec/getty/getty.8
index 3bec2f4..a11ef37 100644
--- a/libexec/getty/getty.8
+++ b/libexec/getty/getty.8
@@ -26,8 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     from: @(#)getty.8	8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/libexec/getty/getty.8,v 1.10.2.3 2001/08/16 10:44:15 ru Exp $
-.\" $DragonFly: src/libexec/getty/getty.8,v 1.4 2006/02/17 19:33:31 swildner Exp $
+.\" $FreeBSD: head/libexec/getty/getty.8 262136 2014-02-17 22:27:32Z brueffer $
 .\" "
 .Dd June 4, 1993
 .Dt GETTY 8
@@ -44,8 +43,7 @@
 .Sh DESCRIPTION
 The
 .Nm
-program
-is called by
+utility is called by
 .Xr init 8
 to open and initialize the tty line, read a login name, and invoke
 .Xr login 1 .
@@ -89,8 +87,7 @@ table.
 .Pp
 The
 .Nm
-program
-can be set to timeout after some interval,
+utility 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 FILES
@@ -123,5 +120,5 @@ does not exist.
 .Sh HISTORY
 A
 .Nm
-program appeared in
+utility appeared in
 .At v6 .
diff --git a/libexec/getty/gettytab.5 b/libexec/getty/gettytab.5
index f77b806..bb3b497 100644
--- a/libexec/getty/gettytab.5
+++ b/libexec/getty/gettytab.5
@@ -26,8 +26,8 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     from: @(#)gettytab.5	8.4 (Berkeley) 4/19/94
-.\" $FreeBSD: src/libexec/getty/gettytab.5,v 1.21.2.10 2003/02/06 11:45:31 sobomax Exp $
-.\"
+.\" $FreeBSD: head/libexec/getty/gettytab.5 262136 2014-02-17 22:27:32Z brueffer $
+.\" "
 .Dd April 19, 1994
 .Dt GETTYTAB 5
 .Os
@@ -54,10 +54,10 @@ Each entry in the data base
 is used to describe one class of terminals.
 .Pp
 There is a default terminal class,
-.Em default ,
+.Va default ,
 that is used to set global defaults for all other classes.
 (That is, the
-.Em default
+.Va default
 entry is read, then the entry for the class required
 is used to override particular settings.)
 .Sh CAPABILITIES
@@ -65,10 +65,10 @@ Refer to
 .Xr termcap 5
 for a description of the file layout.
 The
-.Em default
+.Va default
 column below lists defaults obtained if there is
 no entry in the table obtained, nor one in the special
-.Em default
+.Va default
 table.
 .Bl -column Name Type /usr/bin/login
 .It Sy "Name	Type	Default	Description"
@@ -86,7 +86,11 @@ table.
 .It "co	bool	false	console - add"
 .Ql \en
 after login prompt
-.It "ct	num	10	chat timeout for ac/ic scripts"
+.It "ct	num	10	chat timeout for"
+.Va \&ac
+and
+.Va \&ic
+scripts
 .It "dc	num	0	chat debug bitmask"
 .It "de	num	0	delay secs and flush input before writing first prompt"
 .It "df	str	%+	the" Xr strftime 3 "format used for \&%d in the banner message"
@@ -95,7 +99,7 @@ after login prompt
 .It "dx	bool	false	set"
 .Dv DECCTLQ
 .It "ec	bool	false	leave echo"
-.Tn OFF
+.Em OFF
 .It "ep	bool	false	terminal uses even parity"
 .It "er	str" Ta So Li ^? Sc Ta
 .No "erase character"
@@ -111,7 +115,7 @@ character
 .It "fl	str" Ta So Li ^O Sc Ta
 .No "output flush character"
 .It "hc	bool	false	do"
-.Tn NOT
+.Em NOT
 hangup line on last close
 .It "he	str" Ta Dv NULL Ta
 .No "hostname editing string"
@@ -154,9 +158,10 @@ hangup line on last close
 .It "pe	bool	false	use printer (hard copy) erase algorithm"
 .It "pf	num	0	delay"
 between first prompt and following flush (seconds)
-.It "pp	str	unused	PPP authentication program"
-.It "pl	bool	false	don't detect PPP sequence, but start PPP login"
-program referenced by pp automatically
+.It "pl	bool	false	start PPP login program unconditionally if"
+.Va \&pp
+is specified
+.It "pp	str	unused	PPP login program"
 .It "ps	bool	false	line connected to a"
 .Tn MICOM
 port selector
@@ -164,9 +169,10 @@ port selector
 .No "quit character"
 .It "rp	str" Ta So Li ^R Sc Ta
 .No "line retype character"
-.It "rt	num	unused	ring timeout when using ac"
+.It "rt	num	unused	ring timeout when using"
+.Va \&ac
 .It "rw	bool	false	do"
-.Tn NOT
+.Em 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
@@ -179,7 +185,7 @@ use raw for input, use cbreak
 .It "we	str" Ta So Li ^W Sc Ta
 .No "word erase character"
 .It "xc	bool	false	do"
-.Tn NOT
+.Em NOT
 echo control chars as
 .Ql ^X
 .It "xf	str" Ta So Li ^S Sc Ta Dv XOFF
@@ -190,7 +196,7 @@ echo control chars as
 .El
 .Pp
 The following capabilities are no longer supported by
-.Xr getty 8 Ns :
+.Xr getty 8 :
 .Bl -column Name Type /usr/bin/login
 .It "bd	num	0	backspace delay"
 .It "cb	bool	false	use crt backspace mode"
@@ -213,39 +219,40 @@ 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 ,
+.Va \&c0 ,
+.Va \&c1 ,
+.Va \&c2 ,
+.Va \&i0 ,
+.Va \&i1 ,
+.Va \&i2 ,
+.Va \&l0 ,
+.Va \&l1 ,
+.Va \&l2 ,
+.Va \&o0 ,
+.Va \&o1 ,
 or
-.Em \&o2
+.Va \&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 ,
+.Va c_cflag ,
+.Va c_iflag ,
+.Va c_lflag ,
 and
-.Em c_oflag
-fields, respectively. Each these sets must be completely specified to be
-effective.
+.Va c_oflag
+fields, respectively.
+Each these sets must be completely specified to be effective.
 The
-.Em \&f0 ,
-.Em \&f1 ,
+.Va \&f0 ,
+.Va \&f1 ,
 and
-.Em \&f2
+.Va \&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)
+the TTY sub-system.
+In these flags the bottom 16 bits of the (32 bits)
 value contain the sgttyb
-.Em sg_flags
+.Va sg_flags
 field, while the top 16 bits represent the local mode word.
 .Pp
 Should
@@ -253,8 +260,9 @@ Should
 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.
+.Va \&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.
@@ -263,17 +271,17 @@ with values 0, 1, 2, and 3 are interpreted as
 choosing that particular delay algorithm from the driver.
 .Pp
 The
-.Em \&cl
+.Va \&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 .
+.Va \&pc .
 .Pp
 The initial message, login message, and initial file;
-.Em \&im ,
-.Em \&lm
+.Va \&im ,
+.Va \&lm
 and
-.Em \&if
+.Va \&if
 may include any of the following character sequences, which expand to
 information about the environment in which
 .Xr getty 8
@@ -281,26 +289,26 @@ is running.
 .Bl -tag -offset indent -width \&%xxxxxxxxxxxxxx
 .It \&%d
 The current date and time formatted according to the
-.Em \&Lo
+.Va \&Lo
 and
-.Em \&df
+.Va \&df
 strings.
 .It \&%h
 The hostname of the machine, which is normally obtained from the
 system using
 .Xr gethostname 3 ,
 but may also be overridden by the
-.Em \&hn
+.Va \&hn
 table entry.
 In either case it may be edited with the
-.Em \&he
+.Va \&he
 string.
 A '@' in the
-.Em \&he
+.Va \&he
 string causes one character from the real hostname to
 be copied to the final hostname.
 A '#' in the
-.Em \&he
+.Va \&he
 string causes the next character of the real hostname
 to be skipped.
 Each character that
@@ -321,24 +329,24 @@ character.
 .Pp
 When getty execs the login process, given
 in the
-.Em \&lo
+.Va \&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
+.Va \&tt
 string (if it exists).
 The
-.Em \&ev
+.Va \&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 .
+.Li name=value .
 .Pp
 If a non-zero timeout is specified, with
-.Em \&to ,
+.Va \&to ,
 then getty will exit within the indicated
 number of seconds, either having
 received a login name and passed control
@@ -350,29 +358,40 @@ This may be useful to hangup dial in lines.
 Output from
 .Xr getty 8
 is even parity unless
-.Em \&op
+.Va \&op
 or
-.Em \&np
+.Va \&np
 is specified.
 The
-.Em \&op
+.Va \&op
 string
 may be specified with
-.Em \&ap
+.Va \&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
+The
+.Xr getty 8
+utility does not check parity of input characters in
 .Dv RAW
 mode.
 .Pp
-If
-.Em \&pp
-string is specified and a PPP link bring up sequence is recognized,
-getty will invoke the program referenced by the pp option.  This
-can be used to handle incoming PPP calls.
+If a
+.Va \&pp
+string is specified and a PPP link bring-up sequence is recognized,
+getty will invoke the program referenced by the
+.Va \&pp
+option.
+This can be used to handle incoming PPP calls.
+If the
+.Va \&pl
+option is true as well,
+.Xr getty 8
+will skip the user name prompt and the PPP detection phase, and will
+invoke the program specified by
+.Va \&pp
+instantly.
 .Pp
 .Nm Getty
 provides some basic intelligent modem handling by providing a chat
@@ -428,7 +447,7 @@ Hexadecimal values are, at most, 2 hex digits long, and octal
 values are a maximum of 3 octal digits.
 .Pp
 The
-.Em \&ic
+.Va \&ic
 chat sequence is used to initialize a modem or similar device.
 A typical example of an init chat script for a modem with a
 hayes compatible command set might look like this:
@@ -465,10 +484,11 @@ like:
 This causes the modem to answer the call via the "ATA" command,
 then scans input for a "CONNECT" string.
 If this is received before a
-.Em \&ct timeout, then a normal login sequence commences.
+.Va \&ct
+timeout, then a normal login sequence commences.
 .Pp
 The
-.Em \&ct
+.Va \&ct
 capability specifies a timeout for all send and expect strings.
 This timeout is set individually for each expect wait and send
 string and must be at least as long as the time it takes for
@@ -477,7 +497,7 @@ modem (usually around 10 seconds).
 .Pp
 In most situations, you will want to flush any additional
 input after the connection has been detected, and the
-.Em \&de
+.Va \&de
 capability may be used to do that, as well as delay for a
 short time after the connection has been established during
 which all of the connection data has been sent by the modem.
@@ -508,7 +528,7 @@ of the delay algorithms are not implemented.
 The terminal driver should support sane delay settings.
 .Pp
 The
-.Em \&he
+.Va \&he
 capability is stupid.
 .Pp
 The
diff --git a/libexec/getty/gettytab.h b/libexec/getty/gettytab.h
index cf4f4bb..7431b7e 100644
--- a/libexec/getty/gettytab.h
+++ b/libexec/getty/gettytab.h
@@ -27,8 +27,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)gettytab.h	8.2 (Berkeley) 3/30/94
- * $FreeBSD: src/libexec/getty/gettytab.h,v 1.10.2.3 2003/02/06 11:45:31 sobomax Exp $
- * $DragonFly: src/libexec/getty/gettytab.h,v 1.2 2003/06/17 04:27:07 dillon Exp $
+ * $FreeBSD: head/libexec/getty/gettytab.h 262136 2014-02-17 22:27:32Z brueffer $
  */
 
 /*
@@ -167,6 +166,7 @@ struct gettyflags {
 #define AB	gettyflags[19].value
 #define DX	gettyflags[20].value
 #define	NP	gettyflags[21].value
+#define	NPset	gettyflags[21].set
 #define	MB	gettyflags[22].value
 #define	HW	gettyflags[23].value
 #define	NC	gettyflags[24].value
diff --git a/libexec/getty/init.c b/libexec/getty/init.c
index fff9157..9ddedc2 100644
--- a/libexec/getty/init.c
+++ b/libexec/getty/init.c
@@ -27,8 +27,7 @@
  * SUCH DAMAGE.
  *
  * @(#)from: init.c	8.1 (Berkeley) 6/4/93
- * $FreeBSD: src/libexec/getty/init.c,v 1.11.2.3 2003/02/06 11:45:31 sobomax Exp $
- * $DragonFly: src/libexec/getty/init.c,v 1.3 2005/05/07 20:00:20 corecode Exp $
+ * $FreeBSD: head/libexec/getty/init.c 262136 2014-02-17 22:27:32Z brueffer $
  */
 
 /*
@@ -51,26 +50,26 @@ struct	gettystrs gettystrs[] = {
 	{ "cl" },			/* screen clear characters */
 	{ "im" },			/* initial message */
 	{ "lm", loginmsg },		/* login message */
-	{ "er", &tmode.c_cc[VERASE] },	/* erase character */
-	{ "kl", &tmode.c_cc[VKILL] },	/* kill character */
-	{ "et", &tmode.c_cc[VEOF] },	/* eof chatacter (eot) */
+	{ "er", &omode.c_cc[VERASE] },	/* erase character */
+	{ "kl", &omode.c_cc[VKILL] },	/* kill character */
+	{ "et", &omode.c_cc[VEOF] },	/* eof chatacter (eot) */
 	{ "pc", nullstr },		/* pad character */
 	{ "tt" },			/* terminal type */
-	{ "ev" },			/* enviroment */
+	{ "ev" },			/* environment */
 	{ "lo", loginprg },		/* 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 */
+	{ "in", &omode.c_cc[VINTR] },	/* interrupt char */
+	{ "qu", &omode.c_cc[VQUIT] },	/* quit char */
+	{ "xn", &omode.c_cc[VSTART] },	/* XON (start) char */
+	{ "xf", &omode.c_cc[VSTOP] },	/* XOFF (stop) char */
+	{ "bk", &omode.c_cc[VEOL] },	/* brk char (alt \n) */
+	{ "su", &omode.c_cc[VSUSP] },	/* suspend char */
+	{ "ds", &omode.c_cc[VDSUSP] },	/* delayed suspend */
+	{ "rp", &omode.c_cc[VREPRINT] },/* reprint char */
+	{ "fl", &omode.c_cc[VDISCARD] },/* flush output */
+	{ "we", &omode.c_cc[VWERASE] },	/* word erase */
+	{ "ln", &omode.c_cc[VLNEXT] },	/* literal next */
 	{ "Lo" },			/* locale for strftime() */
 	{ "pp" },			/* ppp login program */
 	{ "if" },			/* sysv-like 'issue' filename */
diff --git a/libexec/getty/main.c b/libexec/getty/main.c
index 4e299e6..f6c0fe7 100644
--- a/libexec/getty/main.c
+++ b/libexec/getty/main.c
@@ -26,24 +26,25 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * @(#) Copyright (c) 1980, 1993 The Regents of the University of California.  All rights reserved.
  * @(#)from: main.c	8.1 (Berkeley) 6/20/93
- * $FreeBSD: src/libexec/getty/main.c,v 1.28.2.4 2003/02/06 11:45:31 sobomax Exp $
+ * $FreeBSD: head/libexec/getty/main.c 270111 2014-08-17 19:06:26Z neel $
  */
 
 #include <sys/param.h>
-#include <sys/stat.h>
 #include <sys/ioctl.h>
+#include <sys/time.h>
 #include <sys/resource.h>
+#include <sys/stat.h>
 #include <sys/ttydefaults.h>
 #include <sys/utsname.h>
+
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <locale.h>
 #include <libutil.h>
-#include <signal.h>
 #include <setjmp.h>
+#include <signal.h>
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
@@ -52,8 +53,8 @@
 #include <unistd.h>
 
 #include "gettytab.h"
-#include "pathnames.h"
 #include "extern.h"
+#include "pathnames.h"
 
 /*
  * Set the amount of running time that getty should accumulate
@@ -74,7 +75,10 @@
 #define PPP_LCP_HI          0xc0  /* LCP protocol - high byte */
 #define PPP_LCP_LOW         0x21  /* LCP protocol - low byte */
 
-struct termios tmode, omode;
+/* original mode; flags've been reset using values from <sys/ttydefaults.h> */
+struct termios omode;
+/* current mode */
+struct termios tmode;
 
 int crmod, digit, lower, upper;
 
@@ -88,6 +92,7 @@ char	ttyn[32];
 
 char	defent[TABBUFSIZ];
 char	tabent[TABBUFSIZ];
+const	char *tname;
 
 char	*env[128];
 
@@ -116,7 +121,9 @@ char partab[] = {
 
 #define	puts	Gputs
 
+static void	defttymode(void);
 static void	dingdong(int);
+static void	dogettytab(void);
 static int	getname(void);
 static void	interrupt(int);
 static void	oflush(void);
@@ -127,14 +134,13 @@ static void	putpad(const char *);
 static void	puts(const char *);
 static void	timeoverrun(int);
 static char	*get_line(int);
-static void	setttymode(const char *, int);
-static void	setdefttymode(const char *);
+static void	setttymode(int);
 static int	opentty(const char *, int);
 
 jmp_buf timeout;
 
 static void
-dingdong(int signo)
+dingdong(int signo __unused)
 {
 	alarm(0);
 	longjmp(timeout, 1);
@@ -143,7 +149,7 @@ dingdong(int signo)
 jmp_buf	intrupt;
 
 static void
-interrupt(int signo)
+interrupt(int signo __unused)
 {
 	longjmp(intrupt, 1);
 }
@@ -152,17 +158,17 @@ interrupt(int signo)
  * Action to take when getty is running too long.
  */
 static void
-timeoverrun(int signo)
+timeoverrun(int signo __unused)
 {
+
 	syslog(LOG_ERR, "getty exiting due to excessive running time");
 	exit(1);
 }
 
 int
-main(int argc, char **argv)
+main(int argc, char *argv[])
 {
 	extern	char **environ;
-	const char *tname;
 	int first_sleep = 1, first_time = 1;
 	struct rlimit limit;
 	int rval;
@@ -170,7 +176,7 @@ main(int argc, char **argv)
 	signal(SIGINT, SIG_IGN);
 	signal(SIGQUIT, SIG_IGN);
 
-	openlog("getty", LOG_ODELAY|LOG_CONS|LOG_PID, LOG_AUTH);
+	openlog("getty", LOG_CONS|LOG_PID, LOG_AUTH);
 	gethostname(hostname, sizeof(hostname) - 1);
 	hostname[sizeof(hostname) - 1] = '\0';
 	if (hostname[0] == '\0')
@@ -207,14 +213,25 @@ main(int argc, char **argv)
 		chmod(ttyn, 0600);
 		revoke(ttyn);
 
-		gettable(tname, tabent);
+		/*
+		 * Do the first scan through gettytab.
+		 * Terminal mode parameters will be wrong until
+		 * defttymode() called, but they're irrelevant for
+		 * the initial setup of the terminal device.
+		 */
+		dogettytab();
 
-		/* Init modem sequence has been specified
+		/*
+		 * Init or answer modem sequence has been specified.
 		 */
-		if (IC) {
+		if (IC || AC) {
 			if (!opentty(ttyn, O_RDWR|O_NONBLOCK))
 				exit(1);
-			setdefttymode(tname);
+			defttymode();
+			setttymode(1);
+		}
+
+		if (IC) {
 			if (getty_chat(IC, CT, DC) > 0) {
 				syslog(LOG_ERR, "modem init problem on %s", ttyn);
 				(void)tcsetattr(STDIN_FILENO, TCSANOW, &tmode);
@@ -224,17 +241,14 @@ main(int argc, char **argv)
 
 		if (AC) {
 			int i, rfds;
-			struct timeval timeout;
-
-			if (!opentty(ttyn, O_RDWR|O_NONBLOCK))
-				exit(1);
-			setdefttymode(tname);
-			rfds = 1 << 0;	/* FD_SET */
-			timeout.tv_sec = RT;
-			timeout.tv_usec = 0;
-			i = select(32, (fd_set*)&rfds, NULL,
-				       NULL, RT ? &timeout : NULL);
-			if (i < 0) {
+			struct timeval to;
+
+        		rfds = 1 << 0;	/* FD_SET */
+        		to.tv_sec = RT;
+        		to.tv_usec = 0;
+        		i = select(32, (fd_set*)&rfds, (fd_set*)NULL,
+        			       (fd_set*)NULL, RT ? &to : NULL);
+        		if (i < 0) {
 				syslog(LOG_ERR, "select %s: %m", ttyn);
 			} else if (i == 0) {
 				syslog(LOG_NOTICE, "recycle tty %s", ttyn);
@@ -254,25 +268,7 @@ main(int argc, char **argv)
 	    }
 	}
 
-	/* Start with default tty settings */
-	if (tcgetattr(STDIN_FILENO, &tmode) < 0) {
-		syslog(LOG_ERR, "tcgetattr %s: %m", ttyn);
-		exit(1);
-	}
-	/*
-	 * Don't rely on the driver too much, and initialize crucial
-	 * things according to <sys/ttydefaults.h>.  Avoid clobbering
-	 * the c_cc[] settings however, the console drivers might wish
-	 * to leave their idea of the preferred VERASE key value
-	 * there.
-	 */
-	tmode.c_iflag = TTYDEF_IFLAG;
-	tmode.c_oflag = TTYDEF_OFLAG;
-	tmode.c_lflag = TTYDEF_LFLAG;
-	tmode.c_cflag = TTYDEF_CFLAG;
-	tmode.c_cflag |= (NC ? CLOCAL : 0);
-	omode = tmode;
-
+	defttymode();
 	for (;;) {
 
 		/*
@@ -286,13 +282,15 @@ main(int argc, char **argv)
 		}
 		first_sleep = 0;
 
-		setttymode(tname, 0);
+		setttymode(0);
 		if (AB) {
 			tname = autobaud();
+			dogettytab();
 			continue;
 		}
 		if (PS) {
 			tname = portselector();
+			dogettytab();
 			continue;
 		}
 		if (CL && *CL)
@@ -327,6 +325,8 @@ main(int argc, char **argv)
 			signal(SIGALRM, dingdong);
 			alarm(TO);
 		}
+
+		rval = 0;
 		if (AL) {
 			const char *p = AL;
 			char *q = name;
@@ -337,7 +337,7 @@ main(int argc, char **argv)
 				else if (islower(*p))
 					lower = 1;
 				else if (isdigit(*p))
-					digit++;
+					digit = 1;
 				*q++ = *p++;
 			}
 		} else if (!(PL && PP))
@@ -348,7 +348,7 @@ main(int argc, char **argv)
 			limit.rlim_max = RLIM_INFINITY;
 			limit.rlim_cur = RLIM_INFINITY;
 			(void)setrlimit(RLIMIT_CPU, &limit);
-			execle(PP, "ppplogin", ttyn, NULL, env);
+			execle(PP, "ppplogin", ttyn, (char *) 0, env);
 			syslog(LOG_ERR, "%s: %m", PP);
 			exit(1);
 		} else if (rval || AL) {
@@ -357,12 +357,20 @@ main(int argc, char **argv)
 			oflush();
 			alarm(0);
 			signal(SIGALRM, SIG_DFL);
+			if (name[0] == '\0')
+				continue;
 			if (name[0] == '-') {
 				puts("user names may not start with '-'.");
 				continue;
 			}
-			if (!(upper || lower || digit))
-				continue;
+			if (!(upper || lower || digit)) {
+				if (AL) {
+					syslog(LOG_ERR,
+					    "invalid auto-login name: %s", AL);
+					exit(1);
+				} else
+					continue;
+			}
 			set_flags(2);
 			if (crmod) {
 				tmode.c_iflag |= ICRNL;
@@ -379,7 +387,7 @@ main(int argc, char **argv)
 				exit(1);
 			}
 			signal(SIGINT, SIG_DFL);
-			for (i = 0; environ[i] != NULL; i++)
+			for (i = 0; environ[i] != (char *)0; i++)
 				env[i] = environ[i];
 			makeenv(&env[i]);
 
@@ -387,78 +395,83 @@ main(int argc, char **argv)
 			limit.rlim_cur = RLIM_INFINITY;
 			(void)setrlimit(RLIMIT_CPU, &limit);
 			execle(LO, "login", AL ? "-fp" : "-p", name,
-			    NULL, env);
+			    (char *) 0, env);
 			syslog(LOG_ERR, "%s: %m", LO);
 			exit(1);
 		}
 		alarm(0);
 		signal(SIGALRM, SIG_DFL);
 		signal(SIGINT, SIG_IGN);
-		if (NX && *NX)
+		if (NX && *NX) {
 			tname = NX;
+			dogettytab();
+		}
 	}
 }
 
 static int
-opentty(const char *ttyn, int flags)
+opentty(const char *tty, int flags)
 {
-	int i, j = 0;
+	int i;
 	int failopenlogged = 0;
 
-	while (j < 10 && (i = open(ttyn, flags)) == -1)
+	while ((i = open(tty, flags)) == -1)
 	{
-		if (((j % 10) == 0) && (errno != ENXIO || !failopenlogged)) {
-			syslog(LOG_ERR, "open %s: %m", ttyn);
+		if (!failopenlogged) {
+			syslog(LOG_ERR, "open %s: %m", tty);
 			failopenlogged = 1;
 		}
-		j++;
 		sleep(60);
 	}
-	if (i == -1) {
-		syslog(LOG_ERR, "open %s: %m", ttyn);
-		return 0;
-	}
-	else {
-		if (login_tty(i) < 0) { 
-			if (daemon(0,0) < 0) {
-				syslog(LOG_ERR,"daemon: %m");
-				close(i);
-				return 0;
-			}
-			if (login_tty(i) < 0) {
-				syslog(LOG_ERR, "login_tty %s: %m", ttyn);
-				close(i);
-				return 0;
-			}
+	if (login_tty(i) < 0) { 
+		if (daemon(0,0) < 0) {
+			syslog(LOG_ERR,"daemon: %m");
+			close(i);
+			return 0;
+		}
+		if (login_tty(i) < 0) {
+			syslog(LOG_ERR, "login_tty %s: %m", tty);
+			close(i);
+			return 0;
 		}
-		return 1;
 	}
+	return 1;
 }
 
 static void
-setdefttymode(const char *tname)
+defttymode(void)
 {
+	struct termios def;
+
+	/* Start with default tty settings. */
 	if (tcgetattr(STDIN_FILENO, &tmode) < 0) {
 		syslog(LOG_ERR, "tcgetattr %s: %m", ttyn);
 		exit(1);
 	}
-	tmode.c_iflag = TTYDEF_IFLAG;
-        tmode.c_oflag = TTYDEF_OFLAG;
-        tmode.c_lflag = TTYDEF_LFLAG;
-        tmode.c_cflag = TTYDEF_CFLAG;
-        omode = tmode;
-	setttymode(tname, 1);
+	omode = tmode; /* fill c_cc for dogettytab() */
+	dogettytab();
+	/*
+	 * Don't rely on the driver too much, and initialize crucial
+	 * things according to <sys/ttydefaults.h>.  Avoid clobbering
+	 * the c_cc[] settings however, the console drivers might wish
+	 * to leave their idea of the preferred VERASE key value
+	 * there.
+	 */
+	cfmakesane(&def);
+	tmode.c_iflag = def.c_iflag;
+	tmode.c_oflag = def.c_oflag;
+	tmode.c_lflag = def.c_lflag;
+	tmode.c_cflag = def.c_cflag;
+	if (NC)
+		tmode.c_cflag |= CLOCAL;
+	omode = tmode;
 }
 
 static void
-setttymode(const char *tname, int raw)
+setttymode(int raw)
 {
 	int off = 0;
 
-	gettable(tname, tabent);
-	if (OPset || EPset || APset)
-		APset++, OPset++, EPset++;
-	setdefaults();
 	(void)tcflush(STDIN_FILENO, TCIOFLUSH);	/* clear out the crap */
 	ioctl(STDIN_FILENO, FIONBIO, &off);	/* turn off non-blocking mode */
 	ioctl(STDIN_FILENO, FIOASYNC, &off);	/* ditto for async mode */
@@ -547,7 +560,7 @@ getname(void)
 		}
 
 		if (c == EOT || c == CTRL('d'))
-			exit(1);
+			exit(0);
 		if (c == '\r' || c == '\n' || np >= &name[sizeof name-1]) {
 			putf("\r\n");
 			break;
@@ -573,10 +586,11 @@ getname(void)
 			else if (np > name)
 				puts("                                     \r");
 			prompt();
+			digit = lower = upper = 0;
 			np = name;
 			continue;
 		} else if (isdigit(c))
-			digit++;
+			digit = 1;
 		if (IG && (c <= ' ' || c > 0176))
 			continue;
 		*np++ = c;
@@ -597,9 +611,7 @@ static void
 putpad(const char *s)
 {
 	int pad = 0;
-	speed_t ospeed;
-
-	ospeed = cfgetospeed(&tmode);
+	speed_t ospeed = cfgetospeed(&tmode);
 
 	if (isdigit(*s)) {
 		while (isdigit(*s)) {
@@ -672,6 +684,7 @@ oflush(void)
 static void
 prompt(void)
 {
+
 	putf(LM);
 	if (CO)
 		putchr('\n');
@@ -723,7 +736,7 @@ putf(const char *cp)
 
 		case 't':
 			slash = strrchr(ttyn, '/');
-			if (slash == NULL)
+			if (slash == (char *) 0)
 				puts(ttyn);
 			else
 				puts(&slash[1]);
@@ -766,3 +779,25 @@ putf(const char *cp)
 		cp++;
 	}
 }
+
+/*
+ * Read a gettytab database entry and perform necessary quirks.
+ */
+static void
+dogettytab(void)
+{
+	
+	/* Read the database entry. */
+	gettable(tname, tabent);
+
+	/*
+	 * Avoid inheriting the parity values from the default entry
+	 * if any of them is set in the current entry.
+	 * Mixing different parity settings is unreasonable.
+	 */
+	if (OPset || EPset || APset || NPset)
+		OPset = EPset = APset = NPset = 1;
+
+	/* Fill in default values for unset capabilities. */
+	setdefaults();
+}
diff --git a/libexec/getty/pathnames.h b/libexec/getty/pathnames.h
index 5e90101..aa0be91 100644
--- a/libexec/getty/pathnames.h
+++ b/libexec/getty/pathnames.h
@@ -27,8 +27,7 @@
  * SUCH DAMAGE.
  *
  *	from: @(#)pathnames.h	8.1 (Berkeley) 6/4/93
- * $FreeBSD: src/libexec/getty/pathnames.h,v 1.7 1999/08/28 00:09:36 peter Exp $
- * $DragonFly: src/libexec/getty/pathnames.h,v 1.2 2003/06/17 04:27:07 dillon Exp $
+ * $FreeBSD: head/libexec/getty/pathnames.h 262136 2014-02-17 22:27:32Z brueffer $
  */
 
 #include <paths.h>
diff --git a/libexec/getty/subr.c b/libexec/getty/subr.c
index b3e8fc8..e981102 100644
--- a/libexec/getty/subr.c
+++ b/libexec/getty/subr.c
@@ -27,33 +27,28 @@
  * SUCH DAMAGE.
  *
  * @(#)from: subr.c	8.1 (Berkeley) 6/4/93
- * $FreeBSD: src/libexec/getty/subr.c,v 1.16.2.1 2001/05/12 10:16:51 kris Exp $
+ * $FreeBSD: head/libexec/getty/subr.c 296134 2016-02-27 02:11:00Z pfg $
  */
 
 /*
  * Melbourne getty.
  */
-#define COMPAT_43
-#ifdef DEBUG
-#include <stdio.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#include <termios.h>
-#include <unistd.h>
 #include <sys/ioctl.h>
 #include <sys/param.h>
 #include <sys/time.h>
+
+#include <poll.h>
+#include <stdlib.h>
+#include <string.h>
 #include <syslog.h>
+#include <termios.h>
+#include <unistd.h>
 
 #include "gettytab.h"
 #include "pathnames.h"
 #include "extern.h"
 
 
-#ifdef COMPAT_43
-static void	compatflags (long);
-#endif
 
 /*
  * Get a table entry.
@@ -159,17 +154,6 @@ gettable(const char *name, char *buf)
 			fp->value = 1 ^ fp->invrt;
 		}
 	}
-
-#ifdef DEBUG
-	printf("name=\"%s\", buf=\"%s\"\r\n", name, buf);
-	for (sp = gettystrs; sp->field; sp++)
-		printf("cgetstr: %s=%s\r\n", sp->field, sp->value);
-	for (np = gettynums; np->field; np++)
-		printf("cgetnum: %s=%d\r\n", np->field, np->value);
-	for (fp = gettyflags; fp->field; fp++)
-		printf("cgetflags: %s='%c' set='%c'\r\n", fp->field, 
-		       fp->value + '0', fp->set + '0');
-#endif /* DEBUG */
 }
 
 void
@@ -251,28 +235,6 @@ set_flags(int n)
 {
 	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:
@@ -428,130 +390,6 @@ out:
 	tmode.c_lflag = lflag;
 }
 
-#ifdef COMPAT_43
-/*
- * Old TTY => termios, snatched from <sys/kern/tty_compat.c>
- */
-void
-compatflags(long flags)
-{
-	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 {
@@ -729,7 +567,7 @@ makeenv(char *env[])
 		if (*p)
 			*ep++ = p;
 	}
-	*ep = NULL;
+	*ep = (char *)0;
 }
 
 /*
@@ -752,7 +590,7 @@ struct	portselect {
 	{ "B4800",	"std.4800" },
 	{ "B9600",	"std.9600" },
 	{ "B19200",	"std.19200" },
-	{ 0 }
+	{ NULL, NULL }
 };
 
 const char *
@@ -761,7 +599,7 @@ portselector(void)
 	char c, baud[20];
 	const char *type = "default";
 	struct portselect *ps;
-	int len;
+	size_t len;
 
 	alarm(5*60);
 	for (len = 0; len < sizeof (baud) - 1; len++) {
@@ -792,22 +630,21 @@ portselector(void)
 const char *
 autobaud(void)
 {
-	int rfds;
-	struct timeval timeout;
+	struct pollfd set[1];
+	struct timespec timeout;
 	char c;
 	const char *type = "9600-baud";
 
 	(void)tcflush(0, TCIOFLUSH);
-	rfds = 1 << 0;
-	timeout.tv_sec = 5;
-	timeout.tv_usec = 0;
-	if (select(32, (fd_set *)&rfds, NULL, NULL, &timeout) <= 0)
+	set[0].fd = STDIN_FILENO;
+	set[0].events = POLLIN;
+	if (poll(set, 1, 5000) <= 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, NULL, NULL, NULL, &timeout);
+	timeout.tv_nsec = 20000;
+	(void)nanosleep(&timeout, NULL);
 	(void)tcflush(0, TCIOFLUSH);
 	switch (c & 0377) {
 
diff --git a/libexec/getty/ttys.5 b/libexec/getty/ttys.5
index c59935f..5ecdd5c 100644
--- a/libexec/getty/ttys.5
+++ b/libexec/getty/ttys.5
@@ -26,10 +26,9 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     from: @(#)ttys.5	8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/libexec/getty/ttys.5,v 1.11.2.3 2001/08/16 10:44:15 ru Exp $
-.\" $DragonFly: src/libexec/getty/ttys.5,v 1.3 2006/02/17 19:33:31 swildner Exp $
+.\" $FreeBSD: head/libexec/getty/ttys.5 262963 2014-03-09 22:38:11Z jilles $
 .\" "
-.Dd November 17, 1996
+.Dd October 3, 2016
 .Dt TTYS 5
 .Os
 .Sh NAME
@@ -99,13 +98,13 @@ ttys as a group.
 .Pp
 As flag values, the strings ``on'' and ``off'' specify that
 .Xr init 8
-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.
+should (should not) execute the command given in the second field.
 The flag ``ifconsole'' disables the tty entry if it is not the console.
 That is, you can construct a tty entry, set to 'on', that you intend to
 only be active if that tty is the console.
+The flag ``secure'' (if the console is enabled) allows users with a
+uid of 0 to login on
+this line.
 The flag ``dialup'' indicates that a tty entry describes a dialup
 line, and ``network'' indicates that a tty entry provides a
 network connection.
@@ -150,10 +149,7 @@ ttyh0	"/usr/libexec/getty std.9600"	hp2621-nl	on group=dialup	# 457 Evans
 # John's terminal: vt100
 ttyh1	"/usr/libexec/getty std.9600"	vt100	on group=dialup		# 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 	group=pty
-ttyp1	none	network	off	group=pty
+ttyv0	"/usr/local/bin/xterm -display :0"	xterm	on window="/usr/local/bin/X :0"
 .Ed
 .Sh SEE ALSO
 .Xr login 1 ,
-- 
2.9.2

