Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/getty Add two new capabilities to gettytab - idea fr...



details:   https://anonhg.NetBSD.org/src/rev/c8d7427e84f5
branches:  trunk
changeset: 480116:c8d7427e84f5
user:      ad <ad%NetBSD.org@localhost>
date:      Tue Jan 04 13:43:36 2000 +0000

description:
Add two new capabilities to gettytab - idea from FreeBSD:
  al - user to auto-login as
  if - banner file to display, like /etc/issue

diffstat:

 libexec/getty/gettytab.5 |   4 +++-
 libexec/getty/gettytab.h |   4 +++-
 libexec/getty/init.c     |   6 ++++--
 libexec/getty/main.c     |  46 ++++++++++++++++++++++++++++++++++++++++------
 4 files changed, 50 insertions(+), 10 deletions(-)

diffs (168 lines):

diff -r c6377886333f -r c8d7427e84f5 libexec/getty/gettytab.5
--- a/libexec/getty/gettytab.5  Tue Jan 04 08:33:51 2000 +0000
+++ b/libexec/getty/gettytab.5  Tue Jan 04 13:43:36 2000 +0000
@@ -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 @@
 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 @@
 .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"
diff -r c6377886333f -r c8d7427e84f5 libexec/getty/gettytab.h
--- a/libexec/getty/gettytab.h  Tue Jan 04 08:33:51 2000 +0000
+++ b/libexec/getty/gettytab.h  Tue Jan 04 13:43:36 2000 +0000
@@ -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 @@
 #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.
diff -r c6377886333f -r c8d7427e84f5 libexec/getty/init.c
--- a/libexec/getty/init.c      Tue Jan 04 08:33:51 2000 +0000
+++ b/libexec/getty/init.c      Tue Jan 04 13:43:36 2000 +0000
@@ -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 @@
        { "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 }
 };
 
diff -r c6377886333f -r c8d7427e84f5 libexec/getty/main.c
--- a/libexec/getty/main.c      Tue Jan 04 08:33:51 2000 +0000
+++ b/libexec/getty/main.c      Tue Jan 04 13:43:36 2000 +0000
@@ -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 @@
 #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 @@
 #include <time.h>
 #include <unistd.h>
 #include <util.h>
+#include <limits.h>
 
 #include "gettytab.h"
 #include "pathnames.h"
@@ -190,7 +191,7 @@
 {
        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 @@
                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 @@
                        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 @@
                        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);
                }



Home | Main Index | Thread Index | Old Index