summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2014-06-08 17:50:07 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2014-06-08 17:50:07 +0000
commitdc45432cd4f03f948237c53e557e8a56c844f7ca (patch)
tree65553542f819e6c80a2e85faee72b236e6ddc304
parent4c7f4e5ef3415b0183caaebe7b91bf164418864b (diff)
downloadFreeBSD-src-dc45432cd4f03f948237c53e557e8a56c844f7ca.zip
FreeBSD-src-dc45432cd4f03f948237c53e557e8a56c844f7ca.tar.gz
MFC r260913,266895:
Add a new flag to /etc/ttys: onifconsole. This is equivalent to "on" if the device is an active kernel console and "off" otherwise. This is designed to allow serial-booting x86 systems to provide a login prompt on the serial line by default without providing one on all systems by default. Set this flag on x86 systems for ttyu0. Comments and suggestions by: grehan, dteske, jilles
-rw-r--r--UPDATING7
-rw-r--r--etc/etc.amd64/ttys2
-rw-r--r--etc/etc.i386/ttys2
-rw-r--r--include/ttyent.h1
-rw-r--r--lib/libc/gen/getttyent.c35
-rw-r--r--libexec/getty/ttys.57
6 files changed, 50 insertions, 4 deletions
diff --git a/UPDATING b/UPDATING
index 87d493d..7bf818b 100644
--- a/UPDATING
+++ b/UPDATING
@@ -16,6 +16,13 @@ from older versions of FreeBSD, try WITHOUT_CLANG to bootstrap to the tip of
stable/10, and then rebuild without this option. The bootstrap process from
older version of current is a bit fragile.
+20140608:
+ On i386 and amd64 systems, the onifconsole flag is now set by default
+ in /etc/ttys for ttyu0. This causes ttyu0 to be automatically enabled
+ as a login TTY if it is set in the bootloader as an active kernel
+ console. No changes in behavior should result otherwise. To revert to
+ the previous behavior, set ttyu0 to "off" in /etc/ttys.
+
20140512:
Clang and llvm have been upgraded to 3.4.1 release.
diff --git a/etc/etc.amd64/ttys b/etc/etc.amd64/ttys
index 42fa7c0..ead05af 100644
--- a/etc/etc.amd64/ttys
+++ b/etc/etc.amd64/ttys
@@ -41,7 +41,7 @@ ttyv7 "/usr/libexec/getty Pc" xterm on secure
ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure
# Serial terminals
# The 'dialup' keyword identifies dialin lines to login, fingerd etc.
-ttyu0 "/usr/libexec/getty std.9600" dialup off secure
+ttyu0 "/usr/libexec/getty std.9600" vt100 onifconsole secure
ttyu1 "/usr/libexec/getty std.9600" dialup off secure
ttyu2 "/usr/libexec/getty std.9600" dialup off secure
ttyu3 "/usr/libexec/getty std.9600" dialup off secure
diff --git a/etc/etc.i386/ttys b/etc/etc.i386/ttys
index 42fa7c0..ead05af 100644
--- a/etc/etc.i386/ttys
+++ b/etc/etc.i386/ttys
@@ -41,7 +41,7 @@ ttyv7 "/usr/libexec/getty Pc" xterm on secure
ttyv8 "/usr/local/bin/xdm -nodaemon" xterm off secure
# Serial terminals
# The 'dialup' keyword identifies dialin lines to login, fingerd etc.
-ttyu0 "/usr/libexec/getty std.9600" dialup off secure
+ttyu0 "/usr/libexec/getty std.9600" vt100 onifconsole secure
ttyu1 "/usr/libexec/getty std.9600" dialup off secure
ttyu2 "/usr/libexec/getty std.9600" dialup off secure
ttyu3 "/usr/libexec/getty std.9600" dialup off secure
diff --git a/include/ttyent.h b/include/ttyent.h
index 815d168..f2220ad 100644
--- a/include/ttyent.h
+++ b/include/ttyent.h
@@ -37,6 +37,7 @@
#define _TTYS_OFF "off"
#define _TTYS_ON "on"
+#define _TTYS_ONIFCONSOLE "onifconsole"
#define _TTYS_SECURE "secure"
#define _TTYS_INSECURE "insecure"
#define _TTYS_WINDOW "window"
diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c
index b82c30a..d104305 100644
--- a/lib/libc/gen/getttyent.c
+++ b/lib/libc/gen/getttyent.c
@@ -39,6 +39,9 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
static char zapchar;
static FILE *tf;
static size_t lbsize;
@@ -64,6 +67,36 @@ getttynam(const char *tty)
return (t);
}
+static int
+auto_tty_status(const char *ty_name)
+{
+ size_t len;
+ char *buf, *cons, *nextcons;
+
+ /* Check if this is an enabled kernel console line */
+ buf = NULL;
+ if (sysctlbyname("kern.console", NULL, &len, NULL, 0) == -1)
+ return (0); /* Errors mean don't enable */
+ buf = malloc(len);
+ if (sysctlbyname("kern.console", buf, &len, NULL, 0) == -1)
+ goto done;
+
+ if ((cons = strchr(buf, '/')) == NULL)
+ goto done;
+ *cons = '\0';
+ nextcons = buf;
+ while ((cons = strsep(&nextcons, ",")) != NULL && strlen(cons) != 0) {
+ if (strcmp(cons, ty_name) == 0) {
+ free(buf);
+ return (TTY_ON);
+ }
+ }
+
+done:
+ free(buf);
+ return (0);
+}
+
struct ttyent *
getttyent(void)
{
@@ -126,6 +159,8 @@ getttyent(void)
tty.ty_status &= ~TTY_ON;
else if (scmp(_TTYS_ON))
tty.ty_status |= TTY_ON;
+ else if (scmp(_TTYS_ONIFCONSOLE))
+ tty.ty_status |= auto_tty_status(tty.ty_name);
else if (scmp(_TTYS_SECURE))
tty.ty_status |= TTY_SECURE;
else if (scmp(_TTYS_INSECURE))
diff --git a/libexec/getty/ttys.5 b/libexec/getty/ttys.5
index 2ff0fc8..e555c4f 100644
--- a/libexec/getty/ttys.5
+++ b/libexec/getty/ttys.5
@@ -98,8 +98,11 @@ ttys as a group.
.Pp
As flag values, the strings ``on'' and ``off'' specify that
.Xr init 8
-should (should not) execute the command given in the second field,
-while ``secure'' (if ``on'' is also specified) allows users with a
+should (should not) execute the command given in the second field.
+``onifconsole'' will cause this line to be enabled if and only if it is
+an active kernel console device (it is equivalent to ``on'' in this
+case).
+The flag ``secure'' (if the console is enabled) allows users with a
uid of 0 to login on
this line.
The flag ``dialin'' indicates that a tty entry describes a dialin
OpenPOWER on IntegriCloud