aboutsummaryrefslogtreecommitdiff
path: root/libexec
diff options
context:
space:
mode:
authorPaul Traina <pst@FreeBSD.org>1996-11-13 01:06:40 +0000
committerPaul Traina <pst@FreeBSD.org>1996-11-13 01:06:40 +0000
commitee936a69e46e5ebe7c17c72dca3fb232eb167b19 (patch)
tree1eea76ea1873c5758e07425cc7eaeef246b89452 /libexec
parent576b74fcc873d219c8eb69f906759a3251b94f0b (diff)
downloadsrc-ee936a69e46e5ebe7c17c72dca3fb232eb167b19.tar.gz
src-ee936a69e46e5ebe7c17c72dca3fb232eb167b19.zip
Notes
Diffstat (limited to 'libexec')
-rw-r--r--libexec/getty/gettytab.510
-rw-r--r--libexec/getty/gettytab.h3
-rw-r--r--libexec/getty/init.c3
-rw-r--r--libexec/getty/main.c53
4 files changed, 62 insertions, 7 deletions
diff --git a/libexec/getty/gettytab.5 b/libexec/getty/gettytab.5
index d1327dd9b618..22ef5c82dae6 100644
--- a/libexec/getty/gettytab.5
+++ b/libexec/getty/gettytab.5
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)gettytab.5 8.4 (Berkeley) 4/19/94
-.\" $Id: gettytab.5,v 1.6 1996/05/05 19:01:08 joerg Exp $
+.\" $Id: gettytab.5,v 1.7 1996/08/23 20:33:49 mpp Exp $
.\" "
.Dd April 19, 1994
.Dt GETTYTAB 5
@@ -148,6 +148,7 @@ 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 "ps bool false line connected to a"
.Tn MICOM
port selector
@@ -356,8 +357,15 @@ implementation.
does not check parity of input characters in
.Dv RAW
mode.
+.Pp
+If
+.Em \&pp
+string is specified and a PPP link bringup sequence is recognized,
+getty will invoke the program referenced by the pp option. This
+can be used to handle incoming PPP calls.
.Sh SEE ALSO
.Xr login 1 ,
+.Xr ppplogin 8 ,
.Xr gethostname 2 ,
.Xr uname 2 ,
.Xr termcap 5 ,
diff --git a/libexec/getty/gettytab.h b/libexec/getty/gettytab.h
index 6eecc12f138d..8a673156b907 100644
--- a/libexec/getty/gettytab.h
+++ b/libexec/getty/gettytab.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)gettytab.h 8.2 (Berkeley) 3/30/94
- * $Id: gettytab.h,v 1.1.1.2 1996/04/13 15:33:09 joerg Exp $
+ * $Id: gettytab.h,v 1.3 1996/05/05 19:01:09 joerg Exp $
*/
/*
@@ -86,6 +86,7 @@ struct gettyflags {
#define WE gettystrs[22].value
#define LN gettystrs[23].value
#define Lo gettystrs[24].value
+#define PP gettystrs[25].value
/*
* Numeric definitions.
diff --git a/libexec/getty/init.c b/libexec/getty/init.c
index f28979502e6c..394cb3e474f7 100644
--- a/libexec/getty/init.c
+++ b/libexec/getty/init.c
@@ -33,7 +33,7 @@
#ifndef lint
/*static char sccsid[] = "from: @(#)init.c 8.1 (Berkeley) 6/4/93";*/
-static char rcsid[] = "$Id: init.c,v 1.1.1.2 1996/04/13 15:33:10 joerg Exp $";
+static char rcsid[] = "$Id: init.c,v 1.3 1996/05/05 19:01:09 joerg Exp $";
#endif /* not lint */
/*
@@ -76,6 +76,7 @@ struct gettystrs gettystrs[] = {
{ "we", &tmode.c_cc[VWERASE] }, /* word erase */
{ "ln", &tmode.c_cc[VLNEXT] }, /* literal next */
{ "Lo" }, /* locale for strftime() */
+ { "pp" }, /* ppp login program */
{ 0 }
};
diff --git a/libexec/getty/main.c b/libexec/getty/main.c
index 3edf3384a666..5f6c2de609b0 100644
--- a/libexec/getty/main.c
+++ b/libexec/getty/main.c
@@ -39,7 +39,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/20/93";*/
-static char rcsid[] = "$Id: main.c,v 1.9 1996/05/05 19:01:10 joerg Exp $";
+static char rcsid[] = "$Id: main.c,v 1.10 1996/05/07 16:42:26 ache Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -78,6 +78,16 @@ static char rcsid[] = "$Id: main.c,v 1.9 1996/05/05 19:01:10 joerg Exp $";
#undef CTRL
#define CTRL(x) (x&037)
+/* defines for auto detection of incoming PPP calls (->PAP/CHAP) */
+
+#define PPP_FRAME 0x7e /* PPP Framing character */
+#define PPP_STATION 0xff /* "All Station" character */
+#define PPP_ESCAPE 0x7d /* Escape Character */
+#define PPP_CONTROL 0x03 /* PPP Control Field */
+#define PPP_CONTROL_ESCAPED 0x23 /* PPP Control Field, escaped */
+#define PPP_LCP_HI 0xc0 /* LCP protocol - high byte */
+#define PPP_LCP_LOW 0x21 /* LCP protocol - low byte */
+
struct termios tmode, omode;
int crmod, digit, lower, upper;
@@ -172,6 +182,7 @@ main(argc, argv)
const char *tname;
int repcnt = 0, failopenlogged = 0;
struct rlimit limit;
+ int rval;
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
@@ -293,7 +304,11 @@ main(argc, argv)
signal(SIGALRM, dingdong);
alarm(TO);
}
- if (getname()) {
+ if ((rval = getname()) == 2) {
+ execle(PP, "ppplogin", ttyn, (char *) 0, env);
+ syslog(LOG_ERR, "%s: %m", PP);
+ exit(1);
+ } else if (rval) {
register int i;
oflush();
@@ -345,7 +360,9 @@ getname()
{
register int c;
register char *np;
- char cs;
+ unsigned char cs;
+ int ppp_state;
+ int ppp_connection = 0;
/*
* Interrupt may happen if we use CBREAK mode
@@ -374,6 +391,34 @@ getname()
exit(0);
if ((c = cs&0177) == 0)
return (0);
+
+ /* PPP detection state machine..
+ Look for sequences:
+ PPP_FRAME, PPP_STATION, PPP_ESCAPE, PPP_CONTROL_ESCAPED or
+ PPP_FRAME, PPP_STATION, PPP_CONTROL (deviant from RFC)
+ See RFC1662.
+ Derived from code from Michael Hancock, <michaelh@cet.co.jp>
+ and Erik 'PPP' Olson, <eriko@wrq.com>
+ */
+
+ if (PP && (cs == PPP_FRAME)) {
+ ppp_state = 1;
+ } else if (ppp_state == 1 && cs == PPP_STATION) {
+ ppp_state = 2;
+ } else if (ppp_state == 2 && cs == PPP_ESCAPE) {
+ ppp_state = 3;
+ } else if ((ppp_state == 2 && cs == PPP_CONTROL)
+ || (ppp_state == 3 && cs == PPP_CONTROL_ESCAPED)) {
+ ppp_state = 4;
+ } else if (ppp_state == 4 && cs == PPP_LCP_HI) {
+ ppp_state = 5;
+ } else if (ppp_state == 5 && cs == PPP_LCP_LOW) {
+ ppp_connection = 1;
+ break;
+ } else {
+ ppp_state = 0;
+ }
+
if (c == EOT || c == CTRL('d'))
exit(1);
if (c == '\r' || c == '\n' || np >= &name[sizeof name]) {
@@ -418,7 +463,7 @@ getname()
for (np = name; *np; np++)
if (isupper(*np))
*np = tolower(*np);
- return (1);
+ return (1 + ppp_connection);
}
static void