1.\" $NetBSD: ttyaction.5,v 1.7 2001/09/11 01:01:58 wiz 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", "getty", 62"telnetd" and "rlogind" 63which indicate which program is processing this file. 64(Note that "login" begins a login session, while the other 65three are run after a login session ends.) 66.It command 67What command to run if this record matches. 68.El 69.Pp 70The first two fields are delimited with blanks or tabs, 71and the command field is all text to the end of the line. 72Either or both of first two fields may contain wildcard 73match patterns as implemented by the 74.Fn fnmatch 75library function. 76.Pp 77All command strings are executed by passing them to 78.Pa /bin/sh \-c 79running as "root," with an environment containing: 80.Bd -literal -offset indent 81TTY=ttyname 82ACT=action 83USER=username 84PATH=_PATH_STDPATH 85.Ed 86.Pp 87These variables may be used directly in the shell command 88part of the record for simple tasks such as changing the 89ownership of related devices. For example: 90.Bd -literal -offset indent 91console * chown ${USER}:tty /dev/mouse 92.Ed 93.Pp 94will 95.Fa chown 96the mouse appropriately when the console owner changes. 97.Sh EXAMPLES 98Here are some more example records: 99.Bd -literal -offset indent 100tty0 login /somewhere/tty_setup ${TTY} 101tty0 getty /somewhere/tty_clean ${TTY} 102* * /somewhere/ttyfrob ${TTY} ${ACT} 103.Ed 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