Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bin/10930: [PATCH] Auto-login support for getty

45 views
Skip to first unread message

a...@purdue.edu

unread,
Apr 3, 1999, 3:00:00 AM4/3/99
to

>Number: 10930
>Category: bin
>Synopsis: [PATCH] Auto-login support for getty
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Sat Apr 3 12:50:01 PST 1999
>Closed-Date:
>Last-Modified:
>Originator: Andrew J. Korty
>Release: FreeBSD 3.0-RELEASE i386
>Organization:
Physics Computer Network, Purdue University
>Environment:

FreeBSD galileo.physics.purdue.edu 3.1-PCN FreeBSD 3.1-PCN #6:
Thu Mar 25 11:01:38 EST 1999
c...@tesla.physics.purdue.edu:/usr/src/sys/compile/PCN-GALILEO i386

>Description:

We run a localism called "autologin" that does nothing more than
keep a shell up on the console. It runs on all our servers, whose
consoles are connected to our console server. Autologin is run
from /etc/ttys, so when the shell exits, another one pops up. This
way, we're almost guaranteed to have a root shell. (Physical and
network access to the console server is controlled, of course.)

When porting autologin to FreeBSD, we noticed that it has to
replicate much code that already exists in getty. My colleague
remarked that we ought to just add an option to getty to do what
we want. So I did, and I'm presenting the results here because I
think it would be a worthwhile commit. (I don't have privs.)

This patch adds a string capability ("al") to getty. Setting it
to a username gives you a persistent shell without prompting for
login or password. The code is very simple; it just passes the -f
option to the login program. These are against 3.1-RELEASE; if
newer diffs are needed, I can do that.

One more upshot: if you have an operations staff, they can be root
on console without having to know the root password. When a crisis
occurs, you can call the op center and talk them through.

>How-To-Repeat:

Apply this patch in /usr/src, add "al=username" to the desired entry
in /etc/gettytab, and kill -HUP 1.

>Fix:

Index: gettytab.5
===================================================================
RCS file: /project/cvs/PCN/freebsd/src/libexec/getty/gettytab.5,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- gettytab.5 1998/12/03 15:38:11 1.1.1.1
+++ gettytab.5 1999/04/01 13:18:50 1.2
@@ -79,6 +79,7 @@
.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"
Index: gettytab.h
===================================================================
RCS file: /project/cvs/PCN/freebsd/src/libexec/getty/gettytab.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- gettytab.h 1998/12/03 15:38:11 1.1.1.1
+++ gettytab.h 1999/04/01 13:18:50 1.2
@@ -90,6 +90,7 @@
#define IF gettystrs[26].value
#define IC gettystrs[27].value
#define AC gettystrs[28].value
+#define AL gettystrs[29].value

/*
* Numeric definitions.
Index: init.c
===================================================================
RCS file: /project/cvs/PCN/freebsd/src/libexec/getty/init.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- init.c 1998/12/03 15:38:11 1.1.1.1
+++ init.c 1999/04/01 13:18:50 1.2
@@ -83,6 +83,7 @@
{ "if" }, /* sysv-like 'issue' filename */
{ "ic" }, /* modem init-chat */
{ "ac" }, /* modem answer-chat */
+ { "al" }, /* user to auto-login */
{ 0 }
};

Index: main.c
===================================================================
RCS file: /project/cvs/PCN/freebsd/src/libexec/getty/main.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- main.c 1998/12/03 15:38:11 1.1.1.1
+++ main.c 1999/04/01 13:18:51 1.2
@@ -348,13 +348,29 @@
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);
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();
@@ -389,7 +405,8 @@
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);
}

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majo...@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message

0 new messages