summaryrefslogtreecommitdiffstats
path: root/lib/libulog
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libulog')
-rw-r--r--lib/libulog/Makefile38
-rw-r--r--lib/libulog/Symbol.map17
-rw-r--r--lib/libulog/ulog.h41
-rw-r--r--lib/libulog/ulog_login.399
-rw-r--r--lib/libulog/ulog_login.c84
-rw-r--r--lib/libulog/ulog_login_pseudo.c92
-rw-r--r--lib/libulog/utempter.c84
-rw-r--r--lib/libulog/utempter.h44
-rw-r--r--lib/libulog/utempter_add_record.3105
9 files changed, 604 insertions, 0 deletions
diff --git a/lib/libulog/Makefile b/lib/libulog/Makefile
new file mode 100644
index 0000000..074d9db
--- /dev/null
+++ b/lib/libulog/Makefile
@@ -0,0 +1,38 @@
+# $FreeBSD$
+
+SHLIBDIR?=/lib
+
+.include <bsd.own.mk>
+
+LIB= ulog
+SHLIB_MAJOR= 0
+INCS= ulog.h utempter.h
+SRCS= ulog.h ulog_login.c ulog_login_pseudo.c utempter.c
+
+MAN= ulog_login.3 utempter_add_record.3
+MLINKS+=ulog_login.3 ulog_login_pseudo.3 \
+ ulog_login.3 ulog_logout.3 \
+ ulog_login.3 ulog_logout_pseudo.3 \
+ utempter_add_record.3 utempter_remove_added_record.3 \
+ utempter_add_record.3 utempter_remove_record.3 \
+ utempter_add_record.3 addToUtmp.3 \
+ utempter_remove_added_record.3 removeFromUtmp.3 \
+ utempter_remove_record.3 removeLineFromUtmp.3
+
+DPADD= ${LIBMD}
+LDADD= -lmd
+
+VERSION_DEF= ${.CURDIR}/../libc/Versions.def
+SYMBOL_MAPS= ${.CURDIR}/Symbol.map
+
+.if ${MK_INSTALLLIB} != "no"
+SYMLINKS+=libulog.a ${LIBDIR}/libutempter.a
+.endif
+.if !defined(NO_PIC)
+SYMLINKS+=libulog.so ${LIBDIR}/libutempter.so
+.endif
+.if ${MK_PROFILE} != "no"
+SYMLINKS+=libulog_p.a ${LIBDIR}/libutempter_p.a
+.endif
+
+.include <bsd.lib.mk>
diff --git a/lib/libulog/Symbol.map b/lib/libulog/Symbol.map
new file mode 100644
index 0000000..e0375ae
--- /dev/null
+++ b/lib/libulog/Symbol.map
@@ -0,0 +1,17 @@
+/*
+ * $FreeBSD$
+ */
+
+FBSD_1.2 {
+ ulog_login;
+ ulog_login_pseudo;
+ ulog_logout;
+ ulog_logout_pseudo;
+
+ addToUtmp;
+ removeFromUtmp;
+ removeLineFromUtmp;
+ utempter_add_record;
+ utempter_remove_added_record;
+ utempter_remove_record;
+};
diff --git a/lib/libulog/ulog.h b/lib/libulog/ulog.h
new file mode 100644
index 0000000..c5f6fa0
--- /dev/null
+++ b/lib/libulog/ulog.h
@@ -0,0 +1,41 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _ULOG_H_
+#define _ULOG_H_
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+void ulog_login(const char *, const char *, const char *);
+void ulog_login_pseudo(int, const char *);
+void ulog_logout(const char *);
+void ulog_logout_pseudo(int);
+__END_DECLS
+
+#endif /* !_ULOG_H_ */
diff --git a/lib/libulog/ulog_login.3 b/lib/libulog/ulog_login.3
new file mode 100644
index 0000000..451a4f7
--- /dev/null
+++ b/lib/libulog/ulog_login.3
@@ -0,0 +1,99 @@
+.\" 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd December 5, 2009
+.Dt ULOG_LOGIN 3
+.Os
+.Sh NAME
+.Nm ulog_login ,
+.Nm ulog_login_pseudo ,
+.Nm ulog_logout ,
+.Nm ulog_logout_pseudo
+.Nd manage user login records
+.Sh LIBRARY
+.Lb libulog
+.Sh SYNOPSIS
+.In ulog.h
+.Ft void
+.Fn ulog_login "const char *line" "const char *user" "const char *host"
+.Ft void
+.Fn ulog_login_pseudo "int fd" "const char *host"
+.Ft void
+.Fn ulog_logout "const char *line"
+.Ft void
+.Fn ulog_logout_pseudo "int fd"
+.Sh DESCRIPTION
+The
+.Fn ulog_login
+and
+.Fn ulog_login_pseudo
+functions register a login session on a TTY.
+The
+.Fn ulog_login
+function adds an entry for TTY
+.Fa line
+and username
+.Fa user .
+The
+.Fn ulog_login_pseudo
+function uses file descriptor to a pseudo-terminal master device
+.Fa fd
+to determine the TTY name, while using the username belonging to the
+real user ID of the calling process.
+The optional
+.Fa host
+argument denotes a remote hostname, in case the login session is
+provided by a network service.
+.Pp
+The
+.Fn ulog_logout
+and
+.Fn ulog_logout_pseudo
+functions mark the previously registered login session as being
+terminated.
+.Pp
+Because the
+.Fa line
+and
+.Fa user
+arguments of
+.Fn ulog_login
+and
+.Fn ulog_logout
+cannot be trusted, these functions require administrative privileges.
+The
+.Fn ulog_login_pseudo
+and
+.Fn ulog_logout_pseudo
+functions spawn a privileged process to perform the actual logging.
+.Sh SEE ALSO
+.Xr posix_openpt 2 ,
+.Xr getuid 3 ,
+.Xr ptsname 3 ,
+.Xr pututxline 3
+.Sh HISTORY
+These functions appeared in
+.Fx 9.0 .
diff --git a/lib/libulog/ulog_login.c b/lib/libulog/ulog_login.c
new file mode 100644
index 0000000..3058b9f
--- /dev/null
+++ b/lib/libulog/ulog_login.c
@@ -0,0 +1,84 @@
+/*-
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <paths.h>
+#include <sha.h>
+#include <string.h>
+#include <unistd.h>
+#include <utmpx.h>
+#include "ulog.h"
+
+static void
+ulog_fill(struct utmpx *utx, const char *line)
+{
+ SHA_CTX c;
+ char id[SHA_DIGEST_LENGTH];
+
+ /* Remove /dev/ component. */
+ if (strncmp(line, _PATH_DEV, sizeof _PATH_DEV - 1) == 0)
+ line += sizeof _PATH_DEV - 1;
+
+ memset(utx, 0, sizeof *utx);
+
+ utx->ut_pid = getpid();
+ gettimeofday(&utx->ut_tv, NULL);
+ strncpy(utx->ut_line, line, sizeof utx->ut_line);
+
+ SHA1_Init(&c);
+ SHA1_Update(&c, "libulog", 7);
+ SHA1_Update(&c, utx->ut_line, sizeof utx->ut_line);
+ SHA_Final(id, &c);
+
+ memcpy(utx->ut_id, id, MIN(sizeof utx->ut_id, sizeof id));
+}
+
+void
+ulog_login(const char *line, const char *user, const char *host)
+{
+ struct utmpx utx;
+
+ ulog_fill(&utx, line);
+ utx.ut_type = USER_PROCESS;
+ strncpy(utx.ut_user, user, sizeof utx.ut_user);
+ if (host != NULL)
+ strncpy(utx.ut_host, host, sizeof utx.ut_host);
+ pututxline(&utx);
+}
+
+void
+ulog_logout(const char *line)
+{
+ struct utmpx utx;
+
+ ulog_fill(&utx, line);
+ utx.ut_type = DEAD_PROCESS;
+ pututxline(&utx);
+}
diff --git a/lib/libulog/ulog_login_pseudo.c b/lib/libulog/ulog_login_pseudo.c
new file mode 100644
index 0000000..c7f3066
--- /dev/null
+++ b/lib/libulog/ulog_login_pseudo.c
@@ -0,0 +1,92 @@
+/*-
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/wait.h>
+
+#include <errno.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <sysexits.h>
+#include <unistd.h>
+#include "ulog.h"
+
+#define _PATH_ULOG_HELPER "/usr/libexec/ulog-helper"
+
+/*
+ * Registering login sessions.
+ */
+
+static void
+ulog_exec_helper(int fd, char const * const argv[])
+{
+ sigset_t oblock, nblock;
+ pid_t pid, wpid;
+ int status;
+
+ /* Block SIGCHLD. */
+ sigemptyset(&nblock);
+ sigaddset(&nblock, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &nblock, &oblock);
+
+ switch (pid = fork()) {
+ case -1:
+ break;
+ case 0:
+ /* Execute helper program. */
+ if (dup2(fd, STDIN_FILENO) == -1)
+ exit(EX_UNAVAILABLE);
+ sigprocmask(SIG_SETMASK, &oblock, NULL);
+ execv(_PATH_ULOG_HELPER, __DECONST(char * const *, argv));
+ exit(EX_UNAVAILABLE);
+ default:
+ /* Wait for helper to finish. */
+ do {
+ wpid = waitpid(pid, &status, 0);
+ } while (wpid == -1 && errno == EINTR);
+ break;
+ }
+
+ sigprocmask(SIG_SETMASK, &oblock, NULL);
+}
+
+void
+ulog_login_pseudo(int fd, const char *host)
+{
+ char const * const args[4] = { "ulog-helper", "login", host, NULL };
+
+ ulog_exec_helper(fd, args);
+}
+
+void
+ulog_logout_pseudo(int fd)
+{
+ char const * const args[3] = { "ulog-helper", "logout", NULL };
+
+ ulog_exec_helper(fd, args);
+}
diff --git a/lib/libulog/utempter.c b/lib/libulog/utempter.c
new file mode 100644
index 0000000..94495b0
--- /dev/null
+++ b/lib/libulog/utempter.c
@@ -0,0 +1,84 @@
+/*-
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "ulog.h"
+#include "utempter.h"
+
+static int last_fd = -1;
+
+int
+utempter_add_record(int fd, const char *host)
+{
+
+ ulog_login_pseudo(fd, host);
+ last_fd = fd;
+ return (0);
+}
+
+int
+utempter_remove_added_record(void)
+{
+
+ if (last_fd < 0)
+ return (0);
+ ulog_logout_pseudo(last_fd);
+ last_fd = -1;
+ return (0);
+}
+
+int
+utempter_remove_record(int fd)
+{
+
+ ulog_logout_pseudo(fd);
+ if (last_fd == fd)
+ last_fd = -1;
+ return (0);
+}
+
+void
+addToUtmp(const char *pty __unused, const char *host, int fd)
+{
+
+ utempter_add_record(fd, host);
+}
+
+void
+removeFromUtmp(void)
+{
+
+ utempter_remove_added_record();
+}
+
+void
+removeLineFromUtmp(const char *pty __unused, int fd)
+{
+
+ utempter_remove_record(fd);
+}
diff --git a/lib/libulog/utempter.h b/lib/libulog/utempter.h
new file mode 100644
index 0000000..0e0274c
--- /dev/null
+++ b/lib/libulog/utempter.h
@@ -0,0 +1,44 @@
+/*-
+ * 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _UTEMPTER_H_
+#define _UTEMPTER_H_
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+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);
+__END_DECLS
+
+#endif /* !_UTEMPTER_H_ */
diff --git a/lib/libulog/utempter_add_record.3 b/lib/libulog/utempter_add_record.3
new file mode 100644
index 0000000..cd8e8f1
--- /dev/null
+++ b/lib/libulog/utempter_add_record.3
@@ -0,0 +1,105 @@
+.\" 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd December 6, 2009
+.Dt UTEMPTER_ADD_RECORD 3
+.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 libulog
+.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
+The
+.Fn utempter_add_record
+and
+.Fn addToUtmp
+functions add a login record to the 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 .
+These functions are equivalent to
+.Xr ulog_login_pseudo 3 .
+.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 .
+These functions are equivalent to
+.Xr ulog_logout_pseudo 3 .
+.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 the login functions.
+.Pp
+The
+.Fa pty
+arguments of
+.Fn addToUtmp
+and
+.Fn removeLineFromUtmp
+are unused.
+.Sh RETURN VALUES
+In this implementation, the
+.Fn utempter_add_record ,
+.Fn utempter_remove_added_record
+and
+.Fn utempter_remove_record
+always return a value of 0.
+.Sh SEE ALSO
+.Xr pututxline 3 ,
+.Xr ulog_login_pseudo 3
+.Sh HISTORY
+These functions appeared in
+.Fx 9.0 .
OpenPOWER on IntegriCloud