xref: /illumos-gate/usr/src/man/man3utempter/utempter_add_record.3utempter (revision 0d1087e85d1cd423a6cbe5358a51a160350e956e)
1.\" Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\"
26.Dd May 5, 2020
27.Dt UTEMPTER_ADD_RECORD 3UTEMPTER
28.Os
29.Sh NAME
30.Nm utempter_add_record ,
31.Nm utempter_remove_added_record ,
32.Nm utempter_remove_record ,
33.Nm addToUtmp ,
34.Nm removeFromUtmp ,
35.Nm removeLineFromUtmp
36.Nd utempter compatibility interface
37.Sh LIBRARY
38.Lb libutempter
39.Sh SYNOPSIS
40.In utempter.h
41.Ft int
42.Fn utempter_add_record "int fd" "const char *host"
43.Ft int
44.Fn utempter_remove_added_record "void"
45.Ft int
46.Fn utempter_remove_record "int fd"
47.Ft void
48.Fn addToUtmp "const char *pty" "const char *host" "int fd"
49.Ft void
50.Fn removeFromUtmp "void"
51.Ft void
52.Fn removeLineFromUtmp "const char *pty" "int fd"
53.Sh DESCRIPTION
54These functions provide an interface for terminal emulators such as tmux,
55screen, and xterm to record user sessions to
56.Xr utmpx 4
57database.
58Note that they are best effort and may not succeed.
59If consumers need to know for certain that they have successfully updated the
60.Xr utmpx 4
61database, these functions should not be used because they cannot communicate
62that for compatibility reasons.
63.Pp
64The
65.Fn utempter_add_record
66and
67.Fn addToUtmp
68functions add a login record to the
69.Xr utmpx 4
70database for the TTY belonging to the pseudo-terminal master file descriptor
71.Fa fd ,
72using the username corresponding with the real user ID of the calling
73process and the optional hostname
74.Fa host ,
75limited to 256 characters, that is the size of
76.Va ut_host
77member of
78.Vt struct utmpx
79minus terminating NUL character.
80.Pp
81The
82.Fn utempter_remove_record
83and
84.Fn removeLineFromUtmp
85functions mark the login session as being closed for the TTY belonging
86to the pseudo-terminal master file descriptor
87.Fa fd .
88.Pp
89The
90.Fn utempter_remove_added_record
91and
92.Fn removeFromUtmp
93functions have the same properties as the previously mentioned
94functions, except that they use an internally cached value of the file
95descriptor passed to
96.Fn utempter_add_record
97and
98.Fn addToUtmp .
99.Pp
100In this implementation, the
101.Fa pty
102arguments of
103.Fn addToUtmp
104and
105.Fn removeLineFromUtmp
106are ignored, and database entries are driven entirely by the
107.Fa fd
108argument.
109.Sh RETURN VALUES
110The
111.Fn utempter_add_record ,
112.Fn utempter_remove_added_record
113and
114.Fn utempter_remove_record
115functions always return a value of 0.
116.Sh INTERFACE STABILITY
117.Fn utempter_add_record ,
118.Fn utempter_remove_added_record ,
119and
120.Fn utempter_remove_record
121are
122.Sy Committed .
123.Fn addToUtmp ,
124.Fn removeFromUtmp ,
125and
126.Fn removeLineFromUtmp
127are
128.Sy Obsolete Committed .
129.Sh MT-LEVEL
130.Sy Unsafe
131.Sh SEE ALSO
132.Xr pututxline 3c ,
133.Xr utmpx 3head ,
134.Xr utmpx 4
135