Add the >optional< ability to sense PPP link bringups and call an authentication program

This commit is contained in:
Paul Traina 1996-11-13 01:06:40 +00:00
parent 576b74fcc8
commit ee936a69e4
4 changed files with 62 additions and 7 deletions

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" from: @(#)gettytab.5 8.4 (Berkeley) 4/19/94 .\" 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 .Dd April 19, 1994
.Dt GETTYTAB 5 .Dt GETTYTAB 5
@ -148,6 +148,7 @@ hangup line on last close
.It "pe bool false use printer (hard copy) erase algorithm" .It "pe bool false use printer (hard copy) erase algorithm"
.It "pf num 0 delay" .It "pf num 0 delay"
between first prompt and following flush (seconds) between first prompt and following flush (seconds)
.It "pp str unused PPP authentication program"
.It "ps bool false line connected to a" .It "ps bool false line connected to a"
.Tn MICOM .Tn MICOM
port selector port selector
@ -356,8 +357,15 @@ implementation.
does not check parity of input characters in does not check parity of input characters in
.Dv RAW .Dv RAW
mode. 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 .Sh SEE ALSO
.Xr login 1 , .Xr login 1 ,
.Xr ppplogin 8 ,
.Xr gethostname 2 , .Xr gethostname 2 ,
.Xr uname 2 , .Xr uname 2 ,
.Xr termcap 5 , .Xr termcap 5 ,

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* from: @(#)gettytab.h 8.2 (Berkeley) 3/30/94 * 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 WE gettystrs[22].value
#define LN gettystrs[23].value #define LN gettystrs[23].value
#define Lo gettystrs[24].value #define Lo gettystrs[24].value
#define PP gettystrs[25].value
/* /*
* Numeric definitions. * Numeric definitions.

View File

@ -33,7 +33,7 @@
#ifndef lint #ifndef lint
/*static char sccsid[] = "from: @(#)init.c 8.1 (Berkeley) 6/4/93";*/ /*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 */ #endif /* not lint */
/* /*
@ -76,6 +76,7 @@ struct gettystrs gettystrs[] = {
{ "we", &tmode.c_cc[VWERASE] }, /* word erase */ { "we", &tmode.c_cc[VWERASE] }, /* word erase */
{ "ln", &tmode.c_cc[VLNEXT] }, /* literal next */ { "ln", &tmode.c_cc[VLNEXT] }, /* literal next */
{ "Lo" }, /* locale for strftime() */ { "Lo" }, /* locale for strftime() */
{ "pp" }, /* ppp login program */
{ 0 } { 0 }
}; };

View File

@ -39,7 +39,7 @@ static char copyright[] =
#ifndef lint #ifndef lint
/*static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/20/93";*/ /*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 */ #endif /* not lint */
#include <sys/param.h> #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 #undef CTRL
#define CTRL(x) (x&037) #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; struct termios tmode, omode;
int crmod, digit, lower, upper; int crmod, digit, lower, upper;
@ -172,6 +182,7 @@ main(argc, argv)
const char *tname; const char *tname;
int repcnt = 0, failopenlogged = 0; int repcnt = 0, failopenlogged = 0;
struct rlimit limit; struct rlimit limit;
int rval;
signal(SIGINT, SIG_IGN); signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN); signal(SIGQUIT, SIG_IGN);
@ -293,7 +304,11 @@ main(argc, argv)
signal(SIGALRM, dingdong); signal(SIGALRM, dingdong);
alarm(TO); 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; register int i;
oflush(); oflush();
@ -345,7 +360,9 @@ getname()
{ {
register int c; register int c;
register char *np; register char *np;
char cs; unsigned char cs;
int ppp_state;
int ppp_connection = 0;
/* /*
* Interrupt may happen if we use CBREAK mode * Interrupt may happen if we use CBREAK mode
@ -374,6 +391,34 @@ getname()
exit(0); exit(0);
if ((c = cs&0177) == 0) if ((c = cs&0177) == 0)
return (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')) if (c == EOT || c == CTRL('d'))
exit(1); exit(1);
if (c == '\r' || c == '\n' || np >= &name[sizeof name]) { if (c == '\r' || c == '\n' || np >= &name[sizeof name]) {
@ -418,7 +463,7 @@ getname()
for (np = name; *np; np++) for (np = name; *np; np++)
if (isupper(*np)) if (isupper(*np))
*np = tolower(*np); *np = tolower(*np);
return (1); return (1 + ppp_connection);
} }
static void static void