xref: /netbsd-src/lib/libutil/ttyaction.3 (revision f96996de73923c47404ad0d08162b451791959de)
1.\" $NetBSD: ttyaction.3,v 1.16 2021/03/21 23:29:36 mrg 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 May 4, 2010
31.Dt TTYACTION 3
32.Os
33.Sh NAME
34.Nm ttyaction
35.Nd ttyaction utility function
36.Sh LIBRARY
37.Lb libutil
38.Sh SYNOPSIS
39.In util.h
40.Ft int
41.Fn ttyaction "char *ttyname" "char *action" "char *username"
42.Sh DESCRIPTION
43The
44.Fn ttyaction
45function is used by
46.Xr login 1 ,
47.Xr getty 8 ,
48.Xr telnetd 8
49and
50.Xr rlogind 8
51to execute site-specific commands
52when a login session begins and ends.
53.Pp
54The
55.Fn ttyaction
56function scans the
57.Pa /etc/ttyaction
58file for any records that match the current
59.Fa ttyname
60and
61.Fa action
62parameters, and for each matching record,
63runs the shell command shown in that record.
64The record format is described in
65.Xr ttyaction 5 .
66The parameter
67.Fa username
68is the name of the new owner of the
69.Fa ttyname
70device.
71Note that the
72.Fa ttyname
73parameter may be passed as a fully qualified pathname, and the
74.Fn ttyaction
75function will skip the leading "/dev/" part of the string.
76(This is a convenience for login and getty.)
77.Sh RETURN VALUES
78.Fn ttyaction
79returns the status of the last command it executed,
80or zero if no matching commands were found.
81.Sh FILES
82.Bl -tag -width /etc/ttyaction -compact
83.It Pa /dev/\(**
84.It Pa /etc/ttyaction
85.El
86.Sh SEE ALSO
87.Xr ttyaction 5
88.Sh HISTORY
89The
90.Fn ttyaction
91function appeared in
92.Nx 1.3 .
93.Sh AUTHORS
94.An Gordon W. Ross
95.Aq gwr@NetBSD.org ,
96.An Chris G. Demetriou
97.Aq cgd@NetBSD.org ,
98.An Ty Sarna
99.Aq tsarna@NetBSD.org .
100.Sh BUGS
101There should be some
102.Em other
103mechanism to allow selection of different access control policies
104on a per-line basis.
105It has been suggested that the same
106.Fn ttyaction
107mechanism should also be used for determining access control, but
108it was decided (after much discussion) that
109.Fn ttyaction
110should only describe actions to be performed
111.Em after
112the system has decided to change the ownership of some tty.
113Access control policies will be handled by a separate mechanism.
114