diff options
-rw-r--r-- | usr/src/cmd/mandoc/lib.in | 1 | ||||
-rw-r--r-- | usr/src/cmd/mandoc/msec.in | 1 | ||||
-rw-r--r-- | usr/src/lib/Makefile | 2 | ||||
-rw-r--r-- | usr/src/lib/libutempter/Makefile | 37 | ||||
-rw-r--r-- | usr/src/lib/libutempter/Makefile.com | 30 | ||||
-rw-r--r-- | usr/src/lib/libutempter/THIRDPARTYLICENSE | 23 | ||||
-rw-r--r-- | usr/src/lib/libutempter/THIRDPARTYLICENSE.descrip | 1 | ||||
-rw-r--r-- | usr/src/lib/libutempter/amd64/Makefile | 15 | ||||
-rw-r--r-- | usr/src/lib/libutempter/common/mapfile-vers | 38 | ||||
-rw-r--r-- | usr/src/lib/libutempter/common/utempter.c | 132 | ||||
-rw-r--r-- | usr/src/lib/libutempter/common/utempter.h | 47 | ||||
-rw-r--r-- | usr/src/lib/libutempter/i386/Makefile | 14 | ||||
-rw-r--r-- | usr/src/lib/libutempter/sparc/Makefile | 14 | ||||
-rw-r--r-- | usr/src/lib/libutempter/sparcv9/Makefile | 15 | ||||
-rw-r--r-- | usr/src/man/Makefile | 1 | ||||
-rw-r--r-- | usr/src/man/man3utempter/Makefile | 35 | ||||
-rw-r--r-- | usr/src/man/man3utempter/utempter_add_record.3utempter | 134 | ||||
-rw-r--r-- | usr/src/pkg/manifests/system-library-libutempter.mf | 44 |
18 files changed, 584 insertions, 0 deletions
diff --git a/usr/src/cmd/mandoc/lib.in b/usr/src/cmd/mandoc/lib.in index 0d65eeb086..9e42725de5 100644 --- a/usr/src/cmd/mandoc/lib.in +++ b/usr/src/cmd/mandoc/lib.in @@ -77,6 +77,7 @@ LINE("libtecla", "Interactive Command Line Input Library (libtecla, \\-ltecla)") LINE("libtnfctl", "TNF Probe Control Library (libtnfctl, \\-ltnfctl)") LINE("libtsol", "Trusted Extensions Library (libtsol, \\-ltsol)") LINE("libumem", "Object-Caching Memory Allocation Library (libumem, \\-lumem") +LINE("libutempter", "UTEMPTER Library (libutempter, \\-lutempter)") LINE("libuuid", "UUID Library (libuuid, \\-luuid)") LINE("libvolmgt", "Volume Management Library (libvolmgt, \\-lvolmgt)") LINE("libxcurses", "X/Open Curses Library (libxcurses, \\-lxcurses)") diff --git a/usr/src/cmd/mandoc/msec.in b/usr/src/cmd/mandoc/msec.in index 10861ddd07..09069603b7 100644 --- a/usr/src/cmd/mandoc/msec.in +++ b/usr/src/cmd/mandoc/msec.in @@ -88,6 +88,7 @@ LINE("3SYSEVENT", "System Event Library Functions") LINE("3TECLA", "Interactive Command-line Input Library Functions") LINE("3TNF", "TNF Library Functions") LINE("3TSOL", "Trusted Extensions Library Functions") +LINE("3UTEMPTER", "UTEMPTER Library Functions") LINE("3UUID", "Universally Unique Identifier Library Functions") LINE("3VOLMGT", "Volume Management Library Functions") LINE("3XCURSES", "X/Open Curses Library Functions") diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile index 4023cf6290..e2bbd9a8c0 100644 --- a/usr/src/lib/Makefile +++ b/usr/src/lib/Makefile @@ -232,6 +232,7 @@ SUBDIRS += \ libtsnet \ libtsol \ libumem \ + libutempter \ libuuid \ libuutil \ libvolmgt \ @@ -479,6 +480,7 @@ HDRSUBDIRS= \ libtsnet \ libtsol \ libumem \ + libutempter \ libuutil \ libvolmgt \ libvrrpadm \ diff --git a/usr/src/lib/libutempter/Makefile b/usr/src/lib/libutempter/Makefile new file mode 100644 index 0000000000..50a91bef6b --- /dev/null +++ b/usr/src/lib/libutempter/Makefile @@ -0,0 +1,37 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +include $(SRC)/lib/Makefile.lib + +SUBDIRS= $(MACH) $(BUILD64) $(MACH64) + +all:= TARGET= all +clean:= TARGET= clean +clobber:= TARGET= clobber +install:= TARGET= install + +HDRDIR= common +HDRS= utempter.h + +.KEEP_STATE: + +all clean clobber install: $(SUBDIRS) + +check: $(CHECKHDRS) + +install_h: $(ROOTHDRS) + +$(SUBDIRS): FRC + @cd $@; pwd; $(MAKE) $(TARGET) + +FRC: + +include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/libutempter/Makefile.com b/usr/src/lib/libutempter/Makefile.com new file mode 100644 index 0000000000..6e0332e4e0 --- /dev/null +++ b/usr/src/lib/libutempter/Makefile.com @@ -0,0 +1,30 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +LIBRARY= libutempter.a +VERS= .1 + +OBJECTS= utempter.o + +include $(SRC)/lib/Makefile.lib + +SRCDIR= ../common + +LDLIBS += -lc +LIBS= $(DYNLIB) + +CSTD= $(CSTD_GNU99) + +.KEEP_STATE: + +all: $(LIBS) + +include $(SRC)/lib/Makefile.targ diff --git a/usr/src/lib/libutempter/THIRDPARTYLICENSE b/usr/src/lib/libutempter/THIRDPARTYLICENSE new file mode 100644 index 0000000000..aa2de14939 --- /dev/null +++ b/usr/src/lib/libutempter/THIRDPARTYLICENSE @@ -0,0 +1,23 @@ +Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. diff --git a/usr/src/lib/libutempter/THIRDPARTYLICENSE.descrip b/usr/src/lib/libutempter/THIRDPARTYLICENSE.descrip new file mode 100644 index 0000000000..a5add467b7 --- /dev/null +++ b/usr/src/lib/libutempter/THIRDPARTYLICENSE.descrip @@ -0,0 +1 @@ +UTEMPTER LIBRARY diff --git a/usr/src/lib/libutempter/amd64/Makefile b/usr/src/lib/libutempter/amd64/Makefile new file mode 100644 index 0000000000..c876c91740 --- /dev/null +++ b/usr/src/lib/libutempter/amd64/Makefile @@ -0,0 +1,15 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +include ../Makefile.com +include ../../Makefile.lib.64 + +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/lib/libutempter/common/mapfile-vers b/usr/src/lib/libutempter/common/mapfile-vers new file mode 100644 index 0000000000..c2c0249afd --- /dev/null +++ b/usr/src/lib/libutempter/common/mapfile-vers @@ -0,0 +1,38 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# MAPFILE HEADER START +# +# WARNING: STOP NOW. DO NOT MODIFY THIS FILE. +# Object versioning must comply with the rules detailed in +# +# usr/src/lib/README.mapfiles +# +# You should not be making modifications here until you've read the most current +# copy of that file. If you need help, contact a gatekeeper for guidance. +# +# MAPFILE HEADER END +# + +$mapfile_version 2 + +SYMBOL_VERSION ILLUMOS_0.1 { + global: + addToUtmp; + removeFromUtmp; + removeLineFromUtmp; + utempter_add_record; + utempter_remove_added_record; + utempter_remove_record; + local: + *; +}; diff --git a/usr/src/lib/libutempter/common/utempter.c b/usr/src/lib/libutempter/common/utempter.c new file mode 100644 index 0000000000..63e6b24ba1 --- /dev/null +++ b/usr/src/lib/libutempter/common/utempter.c @@ -0,0 +1,132 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include <sys/types.h> + +#include <pwd.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <utmpx.h> + +static int last_fd = -1; + +static void +utempter_update_utmpx(int type, int fd, const char *host) +{ + struct utmpx ut; + struct passwd *pw; + uid_t uid; + + (void) memset(&ut, 0, sizeof (ut)); + ut.ut_type = type; + ut.ut_pid = getpid(); + ut.ut_session = getsid(0); + (void) gettimeofday(&ut.ut_tv, NULL); + if (snprintf(ut.ut_id, sizeof (ut.ut_id), "f%d", fd) >= + sizeof (ut.ut_id)) + return; + uid = getuid(); + if ((pw = getpwuid(uid)) == NULL) + return; + (void) strlcpy(ut.ut_user, pw->pw_name, sizeof (ut.ut_user)); + + if (type == DEAD_PROCESS) { + struct utmpx *ut1; + struct utmpx ut2; + + (void) memset(&ut2, 0, sizeof (ut2)); + ut2.ut_type = USER_PROCESS; + if (snprintf(ut2.ut_id, sizeof (ut2.ut_id), "f%d", fd) >= + sizeof (ut2.ut_id)) + return; + if ((ut1 = getutxid(&ut2)) == NULL) + return; + (void) strlcpy(ut.ut_line, ut1->ut_line, sizeof (ut.ut_line)); + } else { + char *line = ptsname(fd); + if (line == NULL) + return; + (void) strlcpy(ut.ut_line, line + strlen("/dev/"), + sizeof (ut.ut_line)); + } + + if (host != NULL) { + (void) strlcpy(ut.ut_host, host, sizeof (ut.ut_host)); + ut.ut_syslen = strlen(ut.ut_host) + 1; + } + + setutxent(); + (void) pututxline(&ut); + endutxent(); +} + +int +utempter_add_record(int fd, const char *host) +{ + utempter_update_utmpx(USER_PROCESS, fd, host); + last_fd = fd; + return (0); +} + +int +utempter_remove_record(int fd) +{ + utempter_update_utmpx(DEAD_PROCESS, fd, NULL); + if (last_fd == fd) + last_fd = -1; + return (0); +} + +int +utempter_remove_added_record(void) +{ + if (last_fd < 0) + return (0); + utempter_update_utmpx(DEAD_PROCESS, last_fd, NULL); + last_fd = -1; + return (0); +} + +void +addToUtmp(const char *pty __unused, const char *host, int fd) +{ + (void) utempter_add_record(fd, host); +} + +void +removeFromUtmp(void) +{ + (void) utempter_remove_added_record(); +} + +void +removeLineFromUtmp(const char *pty __unused, int fd) +{ + (void) utempter_remove_record(fd); +} diff --git a/usr/src/lib/libutempter/common/utempter.h b/usr/src/lib/libutempter/common/utempter.h new file mode 100644 index 0000000000..fab58d9422 --- /dev/null +++ b/usr/src/lib/libutempter/common/utempter.h @@ -0,0 +1,47 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _UTEMPTER_H +#define _UTEMPTER_H + +#ifdef __cplusplus +extern "C" { +#endif + +int utempter_add_record(int, const char *); +int utempter_remove_added_record(void); +int utempter_remove_record(int); +void addToUtmp(const char *, const char *, int); +void removeFromUtmp(void); +void removeLineFromUtmp(const char *, int); + +#ifdef __cplusplus +} +#endif + +#endif /* !_UTEMPTER_H */ diff --git a/usr/src/lib/libutempter/i386/Makefile b/usr/src/lib/libutempter/i386/Makefile new file mode 100644 index 0000000000..f4a0a208fd --- /dev/null +++ b/usr/src/lib/libutempter/i386/Makefile @@ -0,0 +1,14 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +include ../Makefile.com + +install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/libutempter/sparc/Makefile b/usr/src/lib/libutempter/sparc/Makefile new file mode 100644 index 0000000000..f4a0a208fd --- /dev/null +++ b/usr/src/lib/libutempter/sparc/Makefile @@ -0,0 +1,14 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +include ../Makefile.com + +install: all $(ROOTLIBS) $(ROOTLINKS) diff --git a/usr/src/lib/libutempter/sparcv9/Makefile b/usr/src/lib/libutempter/sparcv9/Makefile new file mode 100644 index 0000000000..c876c91740 --- /dev/null +++ b/usr/src/lib/libutempter/sparcv9/Makefile @@ -0,0 +1,15 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +include ../Makefile.com +include ../../Makefile.lib.64 + +install: all $(ROOTLIBS64) $(ROOTLINKS64) diff --git a/usr/src/man/Makefile b/usr/src/man/Makefile index 7bfd356b32..f3e553ecf6 100644 --- a/usr/src/man/Makefile +++ b/usr/src/man/Makefile @@ -83,6 +83,7 @@ SUBDIRS= man1 \ man3tecla \ man3tnf \ man3tsol \ + man3utempter \ man3uuid \ man3volmgt \ man3xcurses \ diff --git a/usr/src/man/man3utempter/Makefile b/usr/src/man/man3utempter/Makefile new file mode 100644 index 0000000000..a61f7696e6 --- /dev/null +++ b/usr/src/man/man3utempter/Makefile @@ -0,0 +1,35 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet +# at http://www.illumos.org/license/CDDL. +# + +include $(SRC)/Makefile.master + +MANSECT= 3utempter + +MANFILES= utempter_add_record.3utempter + +MANLINKS= addToUtmp.3utempter \ + removeFromUtmp.3utempter \ + removeLineFromUtmp.3utempter \ + utempter_remove_added_record.3utempter \ + utempter_remove_record.3utempter + + +addToUtmp.3utempter := LINKSRC = utempter_add_record.3utempter +removeFromUtmp.3utempter := LINKSRC = utempter_add_record.3utempter +removeLineFromUtmp.3utempter := LINKSRC = utempter_add_record.3utempter +utempter_remove_added_record.3utempter := LINKSRC = utempter_add_record.3utempter +utempter_remove_record.3utempter := LINKSRC = utempter_add_record.3utempter + +.KEEP_STATE: + +include $(SRC)/man/Makefile.man + +install: $(ROOTMANFILES) $(ROOTMANLINKS) diff --git a/usr/src/man/man3utempter/utempter_add_record.3utempter b/usr/src/man/man3utempter/utempter_add_record.3utempter new file mode 100644 index 0000000000..da6cbb7211 --- /dev/null +++ b/usr/src/man/man3utempter/utempter_add_record.3utempter @@ -0,0 +1,134 @@ +.\" Copyright (c) 2009 Ed Schouten <ed@FreeBSD.org> +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" +.Dd May 5, 2020 +.Dt UTEMPTER_ADD_RECORD 3UTEMPTER +.Os +.Sh NAME +.Nm utempter_add_record , +.Nm utempter_remove_added_record , +.Nm utempter_remove_record , +.Nm addToUtmp , +.Nm removeFromUtmp , +.Nm removeLineFromUtmp +.Nd utempter compatibility interface +.Sh LIBRARY +.Lb libutempter +.Sh SYNOPSIS +.In utempter.h +.Ft int +.Fn utempter_add_record "int fd" "const char *host" +.Ft int +.Fn utempter_remove_added_record "void" +.Ft int +.Fn utempter_remove_record "int fd" +.Ft void +.Fn addToUtmp "const char *pty" "const char *host" "int fd" +.Ft void +.Fn removeFromUtmp "void" +.Ft void +.Fn removeLineFromUtmp "const char *pty" "int fd" +.Sh DESCRIPTION +These functions provide an interface for terminal emulators such as tmux, +screen, and xterm to record user sessions to +.Xr utmpx 4 +database. +Note that they are best effort and may not succeed. +If consumers need to know for certain that they have successfully updated the +.Xr utmpx 4 +database, these functions should not be used because they cannot communicate +that for compatibility reasons. +.Pp +The +.Fn utempter_add_record +and +.Fn addToUtmp +functions add a login record to the +.Xr utmpx 4 +database for the TTY belonging to the pseudo-terminal master file descriptor +.Fa fd , +using the username corresponding with the real user ID of the calling +process and the optional hostname +.Fa host , +limited to 256 characters, that is the size of +.Va ut_host +member of +.Vt struct utmpx +minus terminating NUL character. +.Pp +The +.Fn utempter_remove_record +and +.Fn removeLineFromUtmp +functions mark the login session as being closed for the TTY belonging +to the pseudo-terminal master file descriptor +.Fa fd . +.Pp +The +.Fn utempter_remove_added_record +and +.Fn removeFromUtmp +functions have the same properties as the previously mentioned +functions, except that they use an internally cached value of the file +descriptor passed to +.Fn utempter_add_record +and +.Fn addToUtmp . +.Pp +In this implementation, the +.Fa pty +arguments of +.Fn addToUtmp +and +.Fn removeLineFromUtmp +are ignored, and database entries are driven entirely by the +.Fa fd +argument. +.Sh RETURN VALUES +The +.Fn utempter_add_record , +.Fn utempter_remove_added_record +and +.Fn utempter_remove_record +functions always return a value of 0. +.Sh INTERFACE STABILITY +.Fn utempter_add_record , +.Fn utempter_remove_added_record , +and +.Fn utempter_remove_record +are +.Sy Committed . +.Fn addToUtmp , +.Fn removeFromUtmp , +and +.Fn removeLineFromUtmp +are +.Sy Obsolete Committed . +.Sh MT-LEVEL +.Sy Unsafe +.Sh SEE ALSO +.Xr pututxline 3c , +.Xr utmpx 3head , +.Xr utmpx 4 diff --git a/usr/src/pkg/manifests/system-library-libutempter.mf b/usr/src/pkg/manifests/system-library-libutempter.mf new file mode 100644 index 0000000000..e883545383 --- /dev/null +++ b/usr/src/pkg/manifests/system-library-libutempter.mf @@ -0,0 +1,44 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +set name=pkg.fmri value=pkg:/system/library/libutempter@$(PKGVERS) +set name=pkg.description \ + value="Interface to record user sessions in utmpx database" +set name=pkg.summary \ + value="Interface to record user sessions in utmpx database" +set name=info.classification \ + value=org.opensolaris.category.2008:System/Library +set name=variant.arch value=$(ARCH) +dir path=usr group=sys +dir path=usr/include +dir path=usr/lib +dir path=usr/lib/$(ARCH64) +dir path=usr/share +dir path=usr/share/man +dir path=usr/share/man/man3utempter +file path=usr/include/utempter.h +file path=usr/lib/$(ARCH64)/libutempter.so.1 +file path=usr/lib/libutempter.so.1 +file path=usr/share/man/man3utempter/utempter_add_record.3utempter +license usr/src/lib/libutempter/THIRDPARTYLICENSE \ + license=usr/src/lib/libutempter/THIRDPARTYLICENSE +link path=usr/lib/$(ARCH64)/libutempter.so target=libutempter.so.1 +link path=usr/lib/libutempter.so target=libutempter.so.1 +link path=usr/share/man/man3utempter/addToUtmp.3utempter \ + target=utempter_add_record.3utempter +link path=usr/share/man/man3utempter/removeFromUtmp.3utempter \ + target=utempter_add_record.3utempter +link path=usr/share/man/man3utempter/removeLineFromUtmp.3utempter \ + target=utempter_add_record.3utempter +link path=usr/share/man/man3utempter/utempter_remove_added_record.3utempter \ + target=utempter_add_record.3utempter +link path=usr/share/man/man3utempter/utempter_remove_record.3utempter \ + target=utempter_add_record.3utempter |