1.\" $NetBSD: ttyaction.5,v 1.11 2021/03/22 00:09:06 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.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd August 24, 1996 31.Dt TTYACTION 5 32.Os 33.Sh NAME 34.Nm ttyaction 35.Nd ttyaction file format 36.Sh DESCRIPTION 37The 38.Nm ttyaction 39file specifies site-specific commands to run 40when a login session begins and ends. 41The 42.Nm ttyaction 43file contains a list of newline separated records, where 44each record has the following three fields: 45.Bl -tag -width username 46.It ttyname 47Name of the tty line(s) on which this line should apply. 48The name is relative to the 49.Pa /dev 50directory, similar to how such devices are named in the 51.Pa /etc/ttys 52file. 53.It action 54Name of the action for which this line should apply. 55The action names currently defined are "login", "getty", 56"telnetd" and "rlogind" 57which indicate which program is processing this file. 58(Note that "login" begins a login session, while the other 59three are run after a login session ends.) 60.It command 61What command to run if this record matches. 62.El 63.Pp 64The first two fields are delimited with blanks or tabs, 65and the command field is all text to the end of the line. 66Either or both of first two fields may contain wildcard 67match patterns as implemented by the 68.Xr fnmatch 3 69library function. 70.Pp 71All command strings are executed by passing them to 72.Pa /bin/sh \-c 73running as "root," with an environment containing: 74.Bd -literal -offset indent 75TTY=ttyname 76ACT=action 77USER=username 78PATH=_PATH_STDPATH 79.Ed 80.Pp 81These variables may be used directly in the shell command 82part of the record for simple tasks such as changing the 83ownership of related devices. 84For example: 85.Bd -literal -offset indent 86console * chown ${USER}:tty /dev/mouse 87.Ed 88.Pp 89will 90.Fa chown 91the mouse appropriately when the console owner changes. 92.Sh EXAMPLES 93Here are some more example records: 94.Bd -literal -offset indent 95tty0 login /somewhere/tty_setup ${TTY} 96tty0 getty /somewhere/tty_clean ${TTY} 97* * /somewhere/ttyfrob ${TTY} ${ACT} 98.Ed 99.Sh SEE ALSO 100.Xr fnmatch 3 , 101.Xr ttyaction 3 102.Sh HISTORY 103Support for the 104.Pa /etc/ttyaction 105file first appeared in 106.Nx 1.3 . 107The ideas for the 108.Pa /etc/ttyaction 109file were inspired by the 110.Pa /etc/fbtab 111file under SunOS. 112