From owner-svn-src-all@FreeBSD.ORG Sun Jun 8 21:21:56 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 73026EA0; Sun, 8 Jun 2014 21:21:56 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5DF5C2A47; Sun, 8 Jun 2014 21:21:56 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s58LLuAa048991; Sun, 8 Jun 2014 21:21:56 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s58LLtIX048976; Sun, 8 Jun 2014 21:21:55 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201406082121.s58LLtIX048976@svn.freebsd.org> From: Nathan Whitehorn Date: Sun, 8 Jun 2014 21:21:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r267243 - in stable/9: . etc/etc.amd64 etc/etc.i386 include lib/libc/gen libexec/getty X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 08 Jun 2014 21:21:56 -0000 Author: nwhitehorn Date: Sun Jun 8 21:21:54 2014 New Revision: 267243 URL: http://svnweb.freebsd.org/changeset/base/267243 Log: 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 Approved by: re (gjb) Relnotes: yes Modified: stable/9/UPDATING stable/9/etc/etc.amd64/ttys stable/9/etc/etc.i386/ttys stable/9/include/ttyent.h stable/9/lib/libc/gen/getttyent.c stable/9/libexec/getty/ttys.5 Directory Properties: stable/9/ (props changed) stable/9/etc/ (props changed) stable/9/include/ (props changed) stable/9/lib/ (props changed) stable/9/lib/libc/ (props changed) stable/9/libexec/getty/ (props changed) Modified: stable/9/UPDATING ============================================================================== --- stable/9/UPDATING Sun Jun 8 20:39:39 2014 (r267242) +++ stable/9/UPDATING Sun Jun 8 21:21:54 2014 (r267243) @@ -11,6 +11,13 @@ handbook: Items affecting the ports and packages system can be found in /usr/ports/UPDATING. Please read that file before running portupgrade. +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. Modified: stable/9/etc/etc.amd64/ttys ============================================================================== --- stable/9/etc/etc.amd64/ttys Sun Jun 8 20:39:39 2014 (r267242) +++ stable/9/etc/etc.amd64/ttys Sun Jun 8 21:21:54 2014 (r267243) @@ -41,7 +41,7 @@ ttyv7 "/usr/libexec/getty Pc" xterm on 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 Modified: stable/9/etc/etc.i386/ttys ============================================================================== --- stable/9/etc/etc.i386/ttys Sun Jun 8 20:39:39 2014 (r267242) +++ stable/9/etc/etc.i386/ttys Sun Jun 8 21:21:54 2014 (r267243) @@ -41,7 +41,7 @@ ttyv7 "/usr/libexec/getty Pc" xterm on 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 Modified: stable/9/include/ttyent.h ============================================================================== --- stable/9/include/ttyent.h Sun Jun 8 20:39:39 2014 (r267242) +++ stable/9/include/ttyent.h Sun Jun 8 21:21:54 2014 (r267243) @@ -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" Modified: stable/9/lib/libc/gen/getttyent.c ============================================================================== --- stable/9/lib/libc/gen/getttyent.c Sun Jun 8 20:39:39 2014 (r267242) +++ stable/9/lib/libc/gen/getttyent.c Sun Jun 8 21:21:54 2014 (r267243) @@ -39,6 +39,9 @@ __FBSDID("$FreeBSD$"); #include #include +#include +#include + 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)) Modified: stable/9/libexec/getty/ttys.5 ============================================================================== --- stable/9/libexec/getty/ttys.5 Sun Jun 8 20:39:39 2014 (r267242) +++ stable/9/libexec/getty/ttys.5 Sun Jun 8 21:21:54 2014 (r267243) @@ -102,8 +102,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