Add two new capabilities to gettytab - idea from FreeBSD:

al - user to auto-login as
  if - banner file to display, like /etc/issue
This commit is contained in:
ad 2000-01-04 13:43:36 +00:00
parent 1c5b5f62fc
commit 2a1297db0c
4 changed files with 50 additions and 10 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: gettytab.5,v 1.22 1999/03/22 18:25:44 garbled Exp $
.\" $NetBSD: gettytab.5,v 1.23 2000/01/04 13:43:36 ad Exp $
.\"
.\" Copyright (c) 1983, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -82,6 +82,7 @@ no entry in the table obtained, nor one in the special
table.
.Bl -column Namexx /usr/bin/login Default
.It Sy Name Type Default Description
.It "al str unused user to auto-login instead of prompting"
.It "ap bool false terminal uses any parity"
.It "bk str 0377 alternative end of line character (input break)"
.It "c0 num unused tty control flags to write messages"
@ -124,6 +125,7 @@ hangup line on last close
.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 "if str unused display named file before prompt, like /etc/issue"
.It "ig bool false ignore garbage characters in login name"
.It "im str" Ta Dv NULL Ta
.No "initial (banner) message"

View File

@ -1,4 +1,4 @@
/* $NetBSD: gettytab.h,v 1.9 1998/10/12 18:03:49 tsarna Exp $ */
/* $NetBSD: gettytab.h,v 1.10 2000/01/04 13:43:37 ad Exp $ */
/*
* Copyright (c) 1983, 1993, 1994
@ -87,6 +87,8 @@ struct gettyflags {
#define WE gettystrs[22].value
#define LN gettystrs[23].value
#define PP gettystrs[24].value
#define IF gettystrs[25].value
#define AL gettystrs[26].value
/*
* Numeric definitions.

View File

@ -1,4 +1,4 @@
/* $NetBSD: init.c,v 1.9 1998/10/12 18:03:49 tsarna Exp $ */
/* $NetBSD: init.c,v 1.10 2000/01/04 13:43:37 ad Exp $ */
/*
* Copyright (c) 1983, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "from: @(#)init.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID("$NetBSD: init.c,v 1.9 1998/10/12 18:03:49 tsarna Exp $");
__RCSID("$NetBSD: init.c,v 1.10 2000/01/04 13:43:37 ad Exp $");
#endif
#endif /* not lint */
@ -82,6 +82,8 @@ struct gettystrs gettystrs[] = {
{ "we", &tmode.c_cc[VWERASE] }, /* word erase */
{ "ln", &tmode.c_cc[VLNEXT] }, /* literal next */
{ "pp" }, /* ppp login program */
{ "if" }, /* sysv-like 'issue' filename */
{ "al" }, /* user to auto-login */
{ 0 }
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.29 1999/12/15 17:41:48 drochner Exp $ */
/* $NetBSD: main.c,v 1.30 2000/01/04 13:43:38 ad Exp $ */
/*-
* Copyright (c) 1980, 1993
@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
#if 0
static char sccsid[] = "from: @(#)main.c 8.1 (Berkeley) 6/20/93";
#else
__RCSID("$NetBSD: main.c,v 1.29 1999/12/15 17:41:48 drochner Exp $");
__RCSID("$NetBSD: main.c,v 1.30 2000/01/04 13:43:38 ad Exp $");
#endif
#endif /* not lint */
@ -69,6 +69,7 @@ __RCSID("$NetBSD: main.c,v 1.29 1999/12/15 17:41:48 drochner Exp $");
#include <time.h>
#include <unistd.h>
#include <util.h>
#include <limits.h>
#include "gettytab.h"
#include "pathnames.h"
@ -190,7 +191,7 @@ main(argc, argv)
{
extern char **environ;
char *tname;
int repcnt = 0, failopenlogged = 0, uugetty = 0;
int repcnt = 0, failopenlogged = 0, uugetty = 0, first_time = 1;
struct rlimit limit;
struct passwd *pw;
int rval;
@ -335,6 +336,23 @@ main(argc, argv)
if (CL && *CL)
putpad(CL);
edithost(HE);
/*
* If this is the first time through this, and an
* issue file has been given, then send it.
*/
if (first_time && IF) {
char buf[_POSIX2_LINE_MAX];
FILE *fd;
if ((fd = fopen(IF, "r")) != NULL) {
while (fgets(buf, sizeof(buf) - 1, fd) != NULL)
putf(buf);
fclose(fd);
}
}
first_time = 0;
if (IM && *IM)
putf(IM);
oflush();
@ -347,11 +365,26 @@ main(argc, argv)
signal(SIGALRM, dingdong);
alarm(TO);
}
if ((rval = getname()) == 2) {
if (AL) {
const char *p = AL;
char *q = name;
while (*p && q < &name[sizeof name - 1]) {
if (isupper(*p))
upper = 1;
else if (islower(*p))
lower = 1;
else if (isdigit(*p))
digit++;
*q++ = *p++;
}
} else if ((rval = getname()) == 2) {
execle(PP, "ppplogin", ttyn, (char *) 0, env);
syslog(LOG_ERR, "%s: %m", PP);
exit(1);
} else if (rval) {
}
if (rval || AL) {
int i;
oflush();
@ -386,7 +419,8 @@ main(argc, argv)
limit.rlim_max = RLIM_INFINITY;
limit.rlim_cur = RLIM_INFINITY;
(void)setrlimit(RLIMIT_CPU, &limit);
execle(LO, "login", "-p", "--", name, (char *)0, env);
execle(LO, "login", AL ? "-fp" : "-p", "--", name,
(char *)0, env);
syslog(LOG_ERR, "%s: %m", LO);
exit(1);
}