summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-04-04 04:36:50 +0000
committerpeter <peter@FreeBSD.org>1999-04-04 04:36:50 +0000
commitdf68fc891ee0312e07a22bce08ce1dbceab3cc8c (patch)
treeda3be46c62a4c622a7e6485d49a37765a7cc2337 /libexec
parent51fa2770453bbfdd2e24f97d58127572525f6cf9 (diff)
downloadFreeBSD-src-df68fc891ee0312e07a22bce08ce1dbceab3cc8c.zip
FreeBSD-src-df68fc891ee0312e07a22bce08ce1dbceab3cc8c.tar.gz
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>
Diffstat (limited to 'libexec')
-rw-r--r--libexec/getty/gettytab.53
-rw-r--r--libexec/getty/gettytab.h3
-rw-r--r--libexec/getty/init.c3
-rw-r--r--libexec/getty/main.c25
4 files changed, 27 insertions, 7 deletions
diff --git a/libexec/getty/gettytab.5 b/libexec/getty/gettytab.5
index ca95f6b..1a09d43 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.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"
diff --git a/libexec/getty/gettytab.h b/libexec/getty/gettytab.h
index 1321ad1..1323f67 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$
+ * $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.
diff --git a/libexec/getty/init.c b/libexec/getty/init.c
index 31c62a2..3f279fa 100644
--- a/libexec/getty/init.c
+++ b/libexec/getty/init.c
@@ -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 }
};
diff --git a/libexec/getty/main.c b/libexec/getty/main.c
index 55fa1b6..0047f59 100644
--- a/libexec/getty/main.c
+++ b/libexec/getty/main.c
@@ -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);
}
OpenPOWER on IntegriCloud