Add an 'al' (autologin username) capability to getty/gettytab. This is a

damn useful thing for using with serial consoles in clusters etc or secure
console locations.  Using a custom gettytab entry for console with
an entry like 'al=root' means that there is *always* a root login ready on
the console.  This should replace hacks like those which go with conserver
etc.  (This is a loaded gun, watch out for those feet!)

Submitted by:  "Andrew J. Korty" <ajk@purdue.edu>
This commit is contained in:
Peter Wemm 1999-04-04 04:36:50 +00:00
parent 7b2a16a33a
commit 610b0299af
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=45291
4 changed files with 27 additions and 7 deletions

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)gettytab.5 8.4 (Berkeley) 4/19/94
.\" $Id: gettytab.5,v 1.17 1998/05/04 02:37:24 steve Exp $
.\" $Id: gettytab.5,v 1.18 1998/06/10 12:34:25 phk Exp $
.\" "
.Dd April 19, 1994
.Dt GETTYTAB 5
@ -79,6 +79,7 @@ table.
.Bl -column Namexx /usr/bin/login Default
.It Sy Name Type Default Description
.It "ac str unused expect-send chat script for modem answer"
.It "al str unused user to auto-login instead of prompting"
.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"

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)gettytab.h 8.2 (Berkeley) 3/30/94
* $Id$
* $Id: gettytab.h,v 1.8 1997/02/22 14:21:38 peter Exp $
*/
/*
@ -90,6 +90,7 @@ struct gettyflags {
#define IF gettystrs[26].value
#define IC gettystrs[27].value
#define AC gettystrs[28].value
#define AL gettystrs[29].value
/*
* Numeric definitions.

View File

@ -36,7 +36,7 @@
static char sccsid[] = "@(#)from: init.c 8.1 (Berkeley) 6/4/93";
#endif
static const char rcsid[] =
"$Id$";
"$Id: init.c,v 1.9 1997/11/21 07:43:49 charnier Exp $";
#endif /* not lint */
/*
@ -83,6 +83,7 @@ struct gettystrs gettystrs[] = {
{ "if" }, /* sysv-like 'issue' filename */
{ "ic" }, /* modem init-chat */
{ "ac" }, /* modem answer-chat */
{ "al" }, /* user to auto-login */
{ 0 }
};

View File

@ -42,7 +42,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)from: main.c 8.1 (Berkeley) 6/20/93";
#endif
static const char rcsid[] =
"$Id: main.c,v 1.23 1998/10/08 23:14:02 jkh Exp $";
"$Id: main.c,v 1.24 1999/03/09 22:04:44 brian Exp $";
#endif /* not lint */
#include <sys/param.h>
@ -348,7 +348,23 @@ main(argc, argv)
signal(SIGALRM, dingdong);
alarm(TO);
}
if ((rval = getname()) == 2) {
if (AL) {
const char *p = AL;
char *q = name;
int n = sizeof 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
rval = getname();
if (rval == 2) {
oflush();
alarm(0);
limit.rlim_max = RLIM_INFINITY;
@ -357,7 +373,7 @@ main(argc, argv)
execle(PP, "ppplogin", ttyn, (char *) 0, env);
syslog(LOG_ERR, "%s: %m", PP);
exit(1);
} else if (rval) {
} else if (rval || AL) {
register int i;
oflush();
@ -392,7 +408,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);
}