From aecfc01d1bad84e66649703f7fc2926ef70b34ba Mon Sep 17 00:00:00 2001 From: rui zang - Sun Microsystems - Beijing China Date: Thu, 25 Sep 2008 14:01:48 +0800 Subject: PSARC 2006/591 Virtual Console PSARC 2008/515 Virtual Console Update 4309501 Need additional local 'terminal' --HG-- rename : usr/src/uts/intel/sys/kd.h => usr/src/uts/common/sys/kd.h --- usr/src/Makefile.lint | 1 + usr/src/Targetdirs | 1 + usr/src/cmd/Adm/ttysrch | 10 +- usr/src/cmd/Makefile | 1 + usr/src/cmd/login/login.c | 37 +- usr/src/cmd/login/login.dfl | 10 +- usr/src/cmd/login/logindevperm.sh | 34 +- usr/src/cmd/netadm/iu.ap.sh | 8 +- usr/src/cmd/sulogin/sulogin.c | 11 + usr/src/cmd/svc/milestone/Makefile | 9 +- usr/src/cmd/svc/milestone/console-login | 22 +- usr/src/cmd/svc/milestone/make-console-login-xml | 96 +- usr/src/cmd/svc/milestone/vtdaemon | 45 + usr/src/cmd/svc/milestone/vtdaemon.xml | 110 ++ usr/src/cmd/svc/profile/generic_limited_net.xml | 12 +- usr/src/cmd/svc/profile/generic_open.xml | 12 +- usr/src/cmd/svc/shell/smf_include.sh | 14 +- usr/src/cmd/ttymon/tmexpress.c | 9 +- usr/src/cmd/vt/Makefile | 57 + usr/src/cmd/vt/vtdaemon.c | 1400 ++++++++++++++++++ usr/src/cmd/vt/vtinfo.c | 59 + usr/src/cmd/vt/vtxlock.sh | 85 ++ usr/src/lib/libc/port/gen/ttyname.c | 4 + usr/src/lib/libdevinfo/devinfo_devperm.c | 67 +- usr/src/lib/libsecdb/auth_attr.txt | 2 + usr/src/lib/libsecdb/help/auths/Makefile | 2 + usr/src/lib/libsecdb/help/auths/SmfValueVt.html | 37 + usr/src/lib/libsecdb/help/auths/SmfVtStates.html | 37 + usr/src/lib/libsecdb/prof_attr.txt | 2 +- usr/src/pkgdefs/SUNW0on/prototype_com | 2 + usr/src/pkgdefs/SUNWcsd/prototype_com | 3 +- usr/src/pkgdefs/SUNWcsr/postinstall | 27 +- usr/src/pkgdefs/SUNWcsr/preinstall | 13 +- usr/src/pkgdefs/SUNWcsr/prototype_com | 2 + usr/src/pkgdefs/SUNWcsu/prototype_com | 5 + usr/src/pkgdefs/SUNWhea/prototype_com | 3 + usr/src/pkgdefs/SUNWhea/prototype_i386 | 2 - usr/src/pkgdefs/common_files/i.logindevperm | 13 +- usr/src/tools/scripts/bfu.sh | 29 + usr/src/uts/common/Makefile.files | 6 +- usr/src/uts/common/fs/dev/sdev_subr.c | 34 +- usr/src/uts/common/fs/dev/sdev_vtops.c | 442 ++++++ usr/src/uts/common/fs/namefs/namevfs.c | 11 +- usr/src/uts/common/io/cons.c | 3 +- usr/src/uts/common/io/consconfig_dacf.c | 20 + usr/src/uts/common/io/kbtrans/kbtrans_streams.c | 257 +++- usr/src/uts/common/io/kbtrans/kbtrans_streams.h | 12 +- usr/src/uts/common/io/tem.c | 967 +++++++----- usr/src/uts/common/io/tem_safe.c | 1709 +++++++++++++--------- usr/src/uts/common/io/vcons.c | 1308 +++++++++++++++++ usr/src/uts/common/io/vcons_conf.c | 116 ++ usr/src/uts/common/io/warlock/tem.wlcmd | 61 + usr/src/uts/common/io/warlock/wc.wlcmd | 88 ++ usr/src/uts/common/io/warlock/wc_devfs.wlcmd | 45 + usr/src/uts/common/io/wscons.c | 694 ++++++--- usr/src/uts/common/os/console.c | 30 +- usr/src/uts/common/sys/Makefile | 3 + usr/src/uts/common/sys/console.h | 12 +- usr/src/uts/common/sys/fs/sdev_impl.h | 7 +- usr/src/uts/common/sys/kd.h | 54 + usr/src/uts/common/sys/tem.h | 42 +- usr/src/uts/common/sys/tem_impl.h | 258 ++-- usr/src/uts/common/sys/vt.h | 112 ++ usr/src/uts/common/sys/vt_impl.h | 137 ++ usr/src/uts/common/sys/vtdaemon.h | 51 + usr/src/uts/intel/Makefile.intel.shared | 2 +- usr/src/uts/intel/ia32/ml/modstubs.s | 1 + usr/src/uts/intel/sys/Makefile | 2 - usr/src/uts/intel/sys/kd.h | 57 - usr/src/uts/intel/tem/Makefile | 31 +- usr/src/uts/intel/warlock/Makefile | 5 +- usr/src/uts/intel/wc/Makefile | 40 +- usr/src/uts/sparc/Makefile.sparc.shared | 2 +- usr/src/uts/sparc/ml/modstubs.s | 1 + usr/src/uts/sparc/tem/Makefile | 30 +- usr/src/uts/sparc/warlock/Makefile | 5 +- usr/src/uts/sparc/wc/Makefile | 41 +- 77 files changed, 7278 insertions(+), 1711 deletions(-) create mode 100644 usr/src/cmd/svc/milestone/vtdaemon create mode 100644 usr/src/cmd/svc/milestone/vtdaemon.xml create mode 100644 usr/src/cmd/vt/Makefile create mode 100644 usr/src/cmd/vt/vtdaemon.c create mode 100644 usr/src/cmd/vt/vtinfo.c create mode 100644 usr/src/cmd/vt/vtxlock.sh create mode 100644 usr/src/lib/libsecdb/help/auths/SmfValueVt.html create mode 100644 usr/src/lib/libsecdb/help/auths/SmfVtStates.html create mode 100644 usr/src/uts/common/fs/dev/sdev_vtops.c create mode 100644 usr/src/uts/common/io/vcons.c create mode 100644 usr/src/uts/common/io/vcons_conf.c create mode 100644 usr/src/uts/common/io/warlock/tem.wlcmd create mode 100644 usr/src/uts/common/io/warlock/wc.wlcmd create mode 100644 usr/src/uts/common/io/warlock/wc_devfs.wlcmd create mode 100644 usr/src/uts/common/sys/kd.h create mode 100644 usr/src/uts/common/sys/vt.h create mode 100644 usr/src/uts/common/sys/vt_impl.h create mode 100644 usr/src/uts/common/sys/vtdaemon.h delete mode 100644 usr/src/uts/intel/sys/kd.h (limited to 'usr/src') diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint index 018eec7115..0b0b657e11 100644 --- a/usr/src/Makefile.lint +++ b/usr/src/Makefile.lint @@ -281,6 +281,7 @@ COMMON_SUBDIRS = \ cmd/utmpd \ cmd/valtools \ cmd/vna \ + cmd/vt \ cmd/wall \ cmd/wbem \ cmd/wc \ diff --git a/usr/src/Targetdirs b/usr/src/Targetdirs index 31245d9ef6..15c4693142 100644 --- a/usr/src/Targetdirs +++ b/usr/src/Targetdirs @@ -71,6 +71,7 @@ ROOT.SYS= \ /dev/pts \ /dev/sad \ /dev/swap \ + /dev/vt \ /dev/zcons \ /devices \ /devices/pseudo \ diff --git a/usr/src/cmd/Adm/ttysrch b/usr/src/cmd/Adm/ttysrch index ef3bd2e4ed..b4e2195503 100644 --- a/usr/src/cmd/Adm/ttysrch +++ b/usr/src/cmd/Adm/ttysrch @@ -1,13 +1,12 @@ # -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # CDDL HEADER START # # The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. @@ -22,8 +21,6 @@ # # CDDL HEADER END # -#ident "%Z%%M% %I% %E% SMI" -# # This file is used by ttyname(3C) to minimize search time # during attempts to determine the name of a terminal device. # @@ -56,5 +53,6 @@ # in the /dev/slan directory. # /dev/pts +/dev/vt /dev/term /dev/zcons diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile index c9b15faf8d..dbabc8ac14 100644 --- a/usr/src/cmd/Makefile +++ b/usr/src/cmd/Makefile @@ -417,6 +417,7 @@ COMMON_SUBDIRS= \ volcheck \ volrmmount \ vscan \ + vt \ w \ wall \ wbem \ diff --git a/usr/src/cmd/login/login.c b/usr/src/cmd/login/login.c index 16a9a633e0..98e42468e2 100644 --- a/usr/src/cmd/login/login.c +++ b/usr/src/cmd/login/login.c @@ -18,6 +18,7 @@ * * CDDL HEADER END */ + /* * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. @@ -1177,22 +1178,42 @@ logins_disabled(char *user_name) return (FALSE); } +#define DEFAULT_CONSOLE "/dev/console" + /* * check_for_console - Checks if we're getting a root login on the - * console, or a login from the global zone. Exits if not. + * console, or a login from the global zone. Exits if not. * + * If CONSOLE is set to /dev/console in /etc/default/login, then root logins + * on /dev/vt/# are permitted as well. /dev/vt/# does not exist in non-global + * zones, but checking them does no harm. */ static void check_for_console(void) { - if (pwd != NULL && pwd->pw_uid == 0 && zflag == B_FALSE) { - if ((Console != NULL) && (strcmp(ttyn, Console) != 0)) { - (void) printf("Not on system console\n"); + const char *consoles[] = { "/dev/console", "/dev/vt/", NULL }; + int i; + + if (pwd == NULL || pwd->pw_uid != 0 || zflag != B_FALSE || + Console == NULL) + return; - audit_error = ADT_FAIL_VALUE_CONSOLE; - login_exit(10); + if (strcmp(Console, DEFAULT_CONSOLE) == 0) { + for (i = 0; consoles[i] != NULL; i ++) { + if (strncmp(ttyn, consoles[i], + strlen(consoles[i])) == 0) + return; } + } else { + if (strcmp(ttyn, Console) == 0) + return; } + + (void) printf("Not on system console\n"); + + audit_error = ADT_FAIL_VALUE_CONSOLE; + login_exit(10); + } /* @@ -2017,10 +2038,10 @@ update_utmpx_entry(int sublogin) char *user; static char *errmsg = "No utmpx entry. " "You must exec \"login\" from the lowest level \"shell\"."; - int tmplen; + int tmplen; struct utmpx *u = (struct utmpx *)0; struct utmpx utmpx; - char *ttyntail; + char *ttyntail; /* * If we're not a sublogin then diff --git a/usr/src/cmd/login/login.dfl b/usr/src/cmd/login/login.dfl index 03cd4d14f2..4b11830230 100644 --- a/usr/src/cmd/login/login.dfl +++ b/usr/src/cmd/login/login.dfl @@ -1,14 +1,12 @@ -#ident "%Z%%M% %I% %E% SMI" # -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # CDDL HEADER START # # The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. +# Common Development and Distribution License (the "License"). +# You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. @@ -34,6 +32,8 @@ #ULIMIT=0 # If CONSOLE is set, root can only login on that device. +# If the specified device is /dev/console, then root can also log into +# any of the currently enabled /dev/vt/# virtual terminal devices. # Comment this line out to allow remote login by root. # CONSOLE=/dev/console diff --git a/usr/src/cmd/login/logindevperm.sh b/usr/src/cmd/login/logindevperm.sh index c6e0a09933..7c5025212b 100644 --- a/usr/src/cmd/login/logindevperm.sh +++ b/usr/src/cmd/login/logindevperm.sh @@ -20,10 +20,9 @@ # CDDL HEADER END # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" # # This is the script that generates the logindevperm file. It is # architecture-aware, and dumps different stuff for x86 and sparc. @@ -35,11 +34,9 @@ cat < #include #include +#include /* * Intervals to sleep after failed login @@ -458,6 +459,16 @@ main_loop(char *devname, boolean_t cttyflag) } if ((fd = open(devname, O_RDWR)) < 0) exit(EXIT_FAILURE); + + /* + * In system maintenance mode, all virtual console instances + * of the svc:/system/console-login service are not available + * any more, and only the system console is available. So here + * we always switch to the system console in case at the moment + * the active console isn't it. + */ + (void) ioctl(fd, VT_ACTIVATE, 1); + if (fd != 0) (void) dup2(fd, STDIN_FILENO); if (fd != 1) diff --git a/usr/src/cmd/svc/milestone/Makefile b/usr/src/cmd/svc/milestone/Makefile index b084a04e44..fdcff57933 100644 --- a/usr/src/cmd/svc/milestone/Makefile +++ b/usr/src/cmd/svc/milestone/Makefile @@ -19,10 +19,9 @@ # CDDL HEADER END # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -#ident "%Z%%M% %I% %E% SMI" include ../../Makefile.cmd @@ -70,7 +69,8 @@ SYSTEMSVCS= \ console-login.xml \ identity.xml \ manifest-import.xml \ - rmtmpfiles.xml + rmtmpfiles.xml \ + vtdaemon.xml SYSTEMMANIFESTS = $(SYSTEMSVCS:%=$(ROOTSVCSYSTEM)/%) @@ -107,7 +107,8 @@ SVCMETHOD=\ net-physical \ net-routing-setup \ net-svc \ - rmtmpfiles + rmtmpfiles \ + vtdaemon $(ROOTSVCMETHOD) := FILEMODE = 0555 diff --git a/usr/src/cmd/svc/milestone/console-login b/usr/src/cmd/svc/milestone/console-login index 6e4a733d87..c7003b103b 100644 --- a/usr/src/cmd/svc/milestone/console-login +++ b/usr/src/cmd/svc/milestone/console-login @@ -21,10 +21,11 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" +# This method script manages all vt logins including system +# console login. # # For modifying parameters passed to ttymon, do not edit # this script. Instead use svccfg(1m) to modify the SMF @@ -35,6 +36,15 @@ # svc:/system/console-login> setprop ttymon/terminal_type = "xterm" # svc:/system/console-login> exit +. /lib/svc/share/smf_include.sh + +if [ "$1" != "default" ]; then + if smf_dont_configure_vt; then + /usr/sbin/svcadm disable $SMF_FMRI + exit $SMF_EXIT_OK + fi +fi + getproparg() { val=`svcprop -p $2 $SMF_FMRI` [ -n "$val" ] && [ "$val" != "\"\"" ] && echo $1 $val @@ -44,7 +54,13 @@ args="-g" val=`svcprop -p ttymon/device $SMF_FMRI` # if this isn't set, recover a little -[ -z "$val" ] && val=/dev/console +[ -z "$val" ] && val="/dev/console" + +if [ "$val" = "/dev/vt/1" ]; then + echo "ERROR: ttymon/device cannot be configured to /dev/vt/1." + exit $SMF_EXIT_ERR_CONFIG +fi + args="$args -d $val" args="$args `getproparg -l ttymon/label`" diff --git a/usr/src/cmd/svc/milestone/make-console-login-xml b/usr/src/cmd/svc/milestone/make-console-login-xml index 07f238ba4d..75948cde6f 100644 --- a/usr/src/cmd/svc/milestone/make-console-login-xml +++ b/usr/src/cmd/svc/milestone/make-console-login-xml @@ -21,10 +21,9 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" cat >console-login.xml < @@ -32,8 +31,6 @@ cat >console-login.xml <console-login.xml < - - - - console-login.xml < + exec='/lib/svc/method/console-login %i' + timeout_seconds='0'> + + + + + timeout_seconds='3'> + + + + + @@ -109,8 +111,20 @@ cat >console-login.xml < - + + + + + + + @@ -123,6 +137,64 @@ cat >console-login.xml < + + + + +EOF + +# Note that this script file is normally parsed during build by sh(1). +# When the parser encounters an EOF token (like the one above), it +# will fork off and pipe all the text after the EOF above to the shell +# for execution. +# +# one system console (/dev/console) plus five virtual consoles +# (/dev/vt/#, # is from 2 to 6). + +for num in 2 3 4 5 6; do + cat >>console-login.xml < + + + + + + + + + + + + + + + + + + + + + + + +EOF +done + +cat >>console-login.xml <