summaryrefslogtreecommitdiffstats
path: root/libexec/ulog-helper
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2011-06-21 17:59:51 +0000
committered <ed@FreeBSD.org>2011-06-21 17:59:51 +0000
commitf12aed9bf619f5f301b38d5dc262b5c7a1cee743 (patch)
treedced231505ce30bf1d0e6f690c4cfb84f4c3bf78 /libexec/ulog-helper
parent17293d73f86fdd3a8fac6facf760f336b9780f6a (diff)
downloadFreeBSD-src-f12aed9bf619f5f301b38d5dc262b5c7a1cee743.zip
FreeBSD-src-f12aed9bf619f5f301b38d5dc262b5c7a1cee743.tar.gz
Minor cleanups to ulog-helper:
- Remove unneeded linking against libmd. libulog depends on this library, but the ulog-helper tool itself does not. - Change the comment at the top to mention utmpx instead of utmp, wtmp and lastlog. - Simply use user_from_uid() to translate to a username string. - Put variable declarations together.
Diffstat (limited to 'libexec/ulog-helper')
-rw-r--r--libexec/ulog-helper/Makefile4
-rw-r--r--libexec/ulog-helper/ulog-helper.c24
2 files changed, 12 insertions, 16 deletions
diff --git a/libexec/ulog-helper/Makefile b/libexec/ulog-helper/Makefile
index 3c1770c..c1697c8 100644
--- a/libexec/ulog-helper/Makefile
+++ b/libexec/ulog-helper/Makefile
@@ -5,7 +5,7 @@ BINOWN= root
BINMODE=4555
NO_MAN=
-DPADD= ${LIBULOG} ${LIBMD}
-LDADD= -lulog -lmd
+DPADD= ${LIBULOG}
+LDADD= -lulog
.include <bsd.prog.mk>
diff --git a/libexec/ulog-helper/ulog-helper.c b/libexec/ulog-helper/ulog-helper.c
index eaef778..31b40e9 100644
--- a/libexec/ulog-helper/ulog-helper.c
+++ b/libexec/ulog-helper/ulog-helper.c
@@ -36,11 +36,11 @@ __FBSDID("$FreeBSD$");
/*
* This setuid helper utility writes user login records to disk.
- * Unprivileged processes are not capable of writing records to utmp,
- * wtmp and lastlog, but we do want to allow this for pseudo-terminals.
- * Because a file descriptor to a pseudo-terminal master device can only
- * be obtained by processes using the pseudo-terminal, we expect such a
- * descriptor on stdin.
+ * Unprivileged processes are not capable of writing records to utmpx,
+ * but we do want to allow this for pseudo-terminals. Because a file
+ * descriptor to a pseudo-terminal master device can only be obtained by
+ * processes using the pseudo-terminal, we expect such a descriptor on
+ * stdin.
*
* It uses the real user ID of the calling process to determine the
* username. It does allow users to log arbitrary hostnames.
@@ -49,26 +49,22 @@ __FBSDID("$FreeBSD$");
int
main(int argc, char *argv[])
{
- const char *line;
+ const char *line, *user, *host;
/* Device line name. */
if ((line = ptsname(STDIN_FILENO)) == NULL)
return (EX_USAGE);
if ((argc == 2 || argc == 3) && strcmp(argv[1], "login") == 0) {
- struct passwd *pwd;
- const char *host = NULL;
-
/* Username. */
- pwd = getpwuid(getuid());
- if (pwd == NULL)
+ user = user_from_uid(getuid(), 1);
+ if (user == NULL)
return (EX_OSERR);
/* Hostname. */
- if (argc == 3)
- host = argv[2];
+ host = argc == 3 ? argv[2] : NULL;
- ulog_login(line, pwd->pw_name, host);
+ ulog_login(line, user, host);
return (EX_OK);
} else if (argc == 2 && strcmp(argv[1], "logout") == 0) {
ulog_logout(line);
OpenPOWER on IntegriCloud