1.\" $NetBSD: ttyaction.5,v 1.2 1997/10/08 22:00:17 jtc Exp $ 2.\" 3.\" Copyright (c) 1996 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Gordon W. Ross. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 3. All advertising materials mentioning features or use of this software 18.\" must display the following acknowledgement: 19.\" This product includes software developed by the NetBSD 20.\" Foundation, Inc. and its contributors. 21.\" 4. Neither the name of The NetBSD Foundation nor the names of its 22.\" contributors may be used to endorse or promote products derived 23.\" from this software without specific prior written permission. 24.\" 25.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 26.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 27.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 28.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 29.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 30.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 31.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 32.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 33.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 34.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 35.\" POSSIBILITY OF SUCH DAMAGE. 36.\" 37.Dd August 24, 1996 38.Dt TTYACTION 5 39.Os 40.Sh NAME 41.Nm ttyaction 42.Nd ttyaction file format 43.Sh DESCRIPTION 44The 45.Nm ttyaction 46file specifies site-specific commands to run 47when a login session begins and ends. The 48.Nm ttyaction 49file contains a list of newline separated records, where 50each record has the following three fields: 51.Bl -tag -width username 52.It ttyname 53Name of the tty line(s) on which this line should apply. 54The name is relative to the 55.Pa /dev 56directory, similar to how such devices are named in the 57.Pa /etc/ttys 58file. 59.It action 60Name of the action for which this line should apply. 61The action names currently defined are "login" and "getty" 62which indicate which program is processing this file. 63(Note that "login" begins a login session, and "getty" is 64run after a login session ends.) 65.It command 66What command to run if this record matches. 67.El 68.Pp 69The first two fields are delimited with blanks or tabs, 70and the command field is all text to the end of the line. 71Either or both of first two fields may contain wildcard 72match patterns as implemented by the 73.Fn fnmatch 74library function. 75.Pp 76All command strings are executed by passing them to 77.Pa /bin/sh \-c 78running as "root," with an environment containing: 79.Bd -literal -offset indent 80TTY=ttyname 81ACT=action 82USER=username 83PATH=_PATH_STDPATH 84.Ed 85.Pp 86These variables may be used directly in the shell command 87part of the record for simple tasks such as changing the 88ownership of related devices. For example: 89.Bd -literal -offset indent 90console * chown ${USER}.tty /dev/mouse 91.Ed 92.Pp 93will 94.Fa chown 95the mouse appropriately when the console owner changes. 96.Sh EXAMPLE 97Here are some more example records: 98.Bd -literal -offset indent 99tty0 login /somewhere/tty_setup ${TTY} 100tty0 getty /somewhere/tty_clean ${TTY} 101* * /somewhere/ttyfrob ${TTY} ${ACT} 102.Ed 103.Pp 104.Sh SEE ALSO 105.Xr fnmatch 3 , 106.Xr ttyaction 3 107.Sh HISTORY 108The ideas for the 109.Pa /etc/ttyaction 110file were inspired by the 111.Pa /etc/fbtab 112file under SunOS. 113