1.\" $NetBSD: ttyaction.5,v 1.9 2017/02/03 07:42:43 abhinav 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. The 41.Nm ttyaction 42file contains a list of newline separated records, where 43each record has the following three fields: 44.Bl -tag -width username 45.It ttyname 46Name of the tty line(s) on which this line should apply. 47The name is relative to the 48.Pa /dev 49directory, similar to how such devices are named in the 50.Pa /etc/ttys 51file. 52.It action 53Name of the action for which this line should apply. 54The action names currently defined are "login", "getty", 55"telnetd" and "rlogind" 56which indicate which program is processing this file. 57(Note that "login" begins a login session, while the other 58three are run after a login session ends.) 59.It command 60What command to run if this record matches. 61.El 62.Pp 63The first two fields are delimited with blanks or tabs, 64and the command field is all text to the end of the line. 65Either or both of first two fields may contain wildcard 66match patterns as implemented by the 67.Xr fnmatch 3 68library function. 69.Pp 70All command strings are executed by passing them to 71.Pa /bin/sh \-c 72running as "root," with an environment containing: 73.Bd -literal -offset indent 74TTY=ttyname 75ACT=action 76USER=username 77PATH=_PATH_STDPATH 78.Ed 79.Pp 80These variables may be used directly in the shell command 81part of the record for simple tasks such as changing the 82ownership of related devices. For example: 83.Bd -literal -offset indent 84console * chown ${USER}:tty /dev/mouse 85.Ed 86.Pp 87will 88.Fa chown 89the mouse appropriately when the console owner changes. 90.Sh EXAMPLES 91Here are some more example records: 92.Bd -literal -offset indent 93tty0 login /somewhere/tty_setup ${TTY} 94tty0 getty /somewhere/tty_clean ${TTY} 95* * /somewhere/ttyfrob ${TTY} ${ACT} 96.Ed 97.Sh SEE ALSO 98.Xr fnmatch 3 , 99.Xr ttyaction 3 100.Sh HISTORY 101The ideas for the 102.Pa /etc/ttyaction 103file were inspired by the 104.Pa /etc/fbtab 105file under SunOS. 106