summaryrefslogtreecommitdiffstats
path: root/lib/libutil
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2010-03-04 13:35:57 +0000
committerdes <des@FreeBSD.org>2010-03-04 13:35:57 +0000
commit834fb25a9ed2240101506d137b5be7d71c75f306 (patch)
tree4002c72cd1ed11909f7640bea343988cfcf63c5b /lib/libutil
parent98b742f57cafbed05c101e60cc131f5980f044d0 (diff)
parent787cf8d03f1c58ada088933408f30fd63de85bf2 (diff)
downloadFreeBSD-src-834fb25a9ed2240101506d137b5be7d71c75f306.zip
FreeBSD-src-834fb25a9ed2240101506d137b5be7d71c75f306.tar.gz
IFH@204581
Diffstat (limited to 'lib/libutil')
-rw-r--r--lib/libutil/Makefile12
-rw-r--r--lib/libutil/gr_util.c4
-rw-r--r--lib/libutil/libutil.h32
-rw-r--r--lib/libutil/login.367
-rw-r--r--lib/libutil/login.c71
-rw-r--r--lib/libutil/login_tty.c2
-rw-r--r--lib/libutil/logout.369
-rw-r--r--lib/libutil/logout.c74
-rw-r--r--lib/libutil/logwtmp.371
-rw-r--r--lib/libutil/logwtmp.c99
-rw-r--r--lib/libutil/pw_util.c8
11 files changed, 40 insertions, 469 deletions
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile
index 6b489d3..9dc35c0 100644
--- a/lib/libutil/Makefile
+++ b/lib/libutil/Makefile
@@ -6,18 +6,16 @@ SHLIBDIR?= /lib
.include <bsd.own.mk>
LIB= util
-SHLIB_MAJOR= 8
+SHLIB_MAJOR= 9
SRCS= _secure_path.c auth.c expand_number.c flopen.c fparseln.c gr_util.c \
hexdump.c humanize_number.c kinfo_getfile.c kinfo_getvmmap.c kld.c \
- login.c login_auth.c login_cap.c \
+ login_auth.c login_cap.c \
login_class.c login_crypt.c login_ok.c login_times.c login_tty.c \
- logout.c logwtmp.c pidfile.c property.c pty.c pw_util.c quotafile.c \
- realhostname.c stub.c trimdomain.c uucplock.c
+ pidfile.c property.c pty.c pw_util.c quotafile.c realhostname.c \
+ stub.c trimdomain.c uucplock.c
INCS= libutil.h login_cap.h
-WARNS?= 6
-
CFLAGS+= -DLIBC_SCCS
.if ${MK_INET6_SUPPORT} != "no"
@@ -26,7 +24,7 @@ CFLAGS+= -DINET6
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libc/gen/
-MAN+= kld.3 login.3 login_auth.3 login_tty.3 logout.3 logwtmp.3 pty.3 \
+MAN+= kld.3 login_auth.3 login_tty.3 pty.3 \
login_cap.3 login_class.3 login_times.3 login_ok.3 \
_secure_path.3 uucplock.3 property.3 auth.3 realhostname.3 \
realhostname_sa.3 trimdomain.3 fparseln.3 humanize_number.3 \
diff --git a/lib/libutil/gr_util.c b/lib/libutil/gr_util.c
index 77e0653..633f435 100644
--- a/lib/libutil/gr_util.c
+++ b/lib/libutil/gr_util.c
@@ -117,8 +117,8 @@ gr_make(const struct group *gr)
/* Create the group line and fill it. */
if ((line = malloc(line_size)) == NULL)
return (NULL);
- line_size = snprintf(line, line_size, group_line_format, gr->gr_name,
- gr->gr_passwd, (uintmax_t)gr->gr_gid);
+ snprintf(line, line_size, group_line_format, gr->gr_name, gr->gr_passwd,
+ (uintmax_t)gr->gr_gid);
if (gr->gr_mem != NULL)
for (ndx = 0; gr->gr_mem[ndx] != NULL; ndx++) {
strcat(line, gr->gr_mem[ndx]);
diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h
index 7a4dc56..5b7ffad 100644
--- a/lib/libutil/libutil.h
+++ b/lib/libutil/libutil.h
@@ -39,6 +39,34 @@
#ifndef _LIBUTIL_H_
#define _LIBUTIL_H_
+#include <sys/cdefs.h>
+#include <sys/_types.h>
+
+#ifndef _GID_T_DECLARED
+typedef __gid_t gid_t;
+#define _GID_T_DECLARED
+#endif
+
+#ifndef _INT64_T_DECLARED
+typedef __int64_t int64_t;
+#define _INT64_T_DECLARED
+#endif
+
+#ifndef _PID_T_DECLARED
+typedef __pid_t pid_t;
+#define _PID_T_DECLARED
+#endif
+
+#ifndef _SIZE_T_DECLARED
+typedef __size_t size_t;
+#define _SIZE_T_DECLARED
+#endif
+
+#ifndef _UID_T_DECLARED
+typedef __uid_t uid_t;
+#define _UID_T_DECLARED
+#endif
+
#define PROPERTY_MAX_NAME 64
#define PROPERTY_MAX_VALUE 512
@@ -62,7 +90,6 @@ struct pidfh {
/* Avoid pulling in all the include files for no need */
struct termios;
struct winsize;
-struct utmp;
struct in_addr;
struct kinfo_file;
struct kinfo_vmentry;
@@ -74,10 +101,7 @@ int extattr_namespace_to_string(int _attrnamespace, char **_string);
int extattr_string_to_namespace(const char *_string, int *_attrnamespace);
int flopen(const char *_path, int _flags, ...);
void hexdump(const void *ptr, int length, const char *hdr, int flags);
-void login(struct utmp *_ut);
int login_tty(int _fd);
-int logout(const char *_line);
-void logwtmp(const char *_line, const char *_name, const char *_host);
void trimdomain(char *_fullhost, int _hostsize);
int openpty(int *_amaster, int *_aslave, char *_name,
struct termios *_termp, struct winsize *_winp);
diff --git a/lib/libutil/login.3 b/lib/libutil/login.3
deleted file mode 100644
index d88f719..0000000
--- a/lib/libutil/login.3
+++ /dev/null
@@ -1,67 +0,0 @@
-.\"
-.\" Copyright (c) 1996 Joerg Wunsch
-.\"
-.\" 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 DEVELOPERS ``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 DEVELOPERS 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 29, 1996
-.Os
-.Dt LOGIN 3
-.Sh NAME
-.Nm login
-.Nd "log a new login record to the utmp and wtmp files"
-.Sh LIBRARY
-.Lb libutil
-.Sh SYNOPSIS
-.In sys/types.h
-.In utmp.h
-.In libutil.h
-.Ft void
-.Fn login "struct utmp *ut"
-.Sh DESCRIPTION
-The function
-.Fn login
-records the
-.Ar ut
-entry being passed into the appropriate slot of the
-.Xr utmp 5
-file,
-and appends it to the
-.Xr wtmp 5
-file.
-The calling process must have permission to write to both files.
-.Sh RETURN VALUES
-None.
-.Sh SEE ALSO
-.Xr logout 3 ,
-.Xr ttyslot 3 ,
-.Xr utmp 5 ,
-.Xr wtmp 5
-.Sh BUGS
-The interface provided by
-.Fn login
-is rather crude.
-The caller must know about the details of a
-.Va struct utmp .
-Some better abstraction needs to be worked out.
diff --git a/lib/libutil/login.c b/lib/libutil/login.c
deleted file mode 100644
index 12fc348..0000000
--- a/lib/libutil/login.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*-
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. 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.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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$");
-
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)login.c 8.1 (Berkeley) 6/4/93";
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-
-#include <fcntl.h>
-#include <libutil.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ttyent.h>
-#include <unistd.h>
-#include <utmp.h>
-
-void
-login(struct utmp *ut)
-{
- struct ttyent *ty;
- int fd;
- int tty;
-
- setttyent();
- for (tty = 1; (ty = getttyent()) != NULL; ++tty)
- if (strcmp(ty->ty_name, ut->ut_line) == 0)
- break;
- endttyent();
- if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) {
- (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), L_SET);
- (void)write(fd, ut, sizeof(struct utmp));
- (void)close(fd);
- }
- if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
- (void)write(fd, ut, sizeof(struct utmp));
- (void)close(fd);
- }
-}
diff --git a/lib/libutil/login_tty.c b/lib/libutil/login_tty.c
index a14e244..92dc87f 100644
--- a/lib/libutil/login_tty.c
+++ b/lib/libutil/login_tty.c
@@ -50,7 +50,7 @@ login_tty(int fd)
s = setsid();
if (s == -1)
- return (-1);
+ s = getsid(0);
if (tcsetsid(fd, s) == -1)
return (-1);
(void) dup2(fd, 0);
diff --git a/lib/libutil/logout.3 b/lib/libutil/logout.3
deleted file mode 100644
index 426fe08..0000000
--- a/lib/libutil/logout.3
+++ /dev/null
@@ -1,69 +0,0 @@
-.\"
-.\" Copyright (c) 1996 Joerg Wunsch
-.\"
-.\" 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 DEVELOPERS ``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 DEVELOPERS 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 29, 1996
-.Os
-.Dt LOGOUT 3
-.Sh NAME
-.Nm logout
-.Nd remove an entry from the utmp file
-.Sh LIBRARY
-.Lb libutil
-.Sh SYNOPSIS
-.In sys/types.h
-.In libutil.h
-.Ft int
-.Fn logout "const char *line"
-.Sh DESCRIPTION
-The function
-.Fn logout
-searches the
-.Xr utmp 5
-file for the slot described by
-.Ar line
-(usually a tty name).
-If such a slot could be found, it will be updated
-with a record where the
-.Em name
-and
-.Em host
-fields are empty, and the time stamp field is updated to the current time.
-.Sh RETURN VALUES
-The
-.Fn logout
-function returns 1 if the slot described by
-.Ar line
-has been found and updated, 0 otherwise.
-.Sh SEE ALSO
-.Xr login 3 ,
-.Xr utmp 5 ,
-.Xr wtmp 5
-.Sh BUGS
-The calling interface of
-.Fn logout
-is inconsistent with that of
-.Xr login 3 .
diff --git a/lib/libutil/logout.c b/lib/libutil/logout.c
deleted file mode 100644
index fe907e5..0000000
--- a/lib/libutil/logout.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*-
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. 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.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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$");
-
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)logout.c 8.1 (Berkeley) 6/4/93";
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#include <sys/time.h>
-
-#include <fcntl.h>
-#include <libutil.h>
-#include <stdlib.h>
-#include <string.h>
-#include <timeconv.h>
-#include <unistd.h>
-#include <utmp.h>
-
-typedef struct utmp UTMP;
-
-int
-logout(const char *line)
-{
- int fd;
- UTMP ut;
- int rval;
-
- if ((fd = open(_PATH_UTMP, O_RDWR, 0)) < 0)
- return(0);
- rval = 0;
- while (read(fd, &ut, sizeof(UTMP)) == sizeof(UTMP)) {
- if (!ut.ut_name[0] || strncmp(ut.ut_line, line, UT_LINESIZE))
- continue;
- bzero(ut.ut_name, UT_NAMESIZE);
- bzero(ut.ut_host, UT_HOSTSIZE);
- ut.ut_time = _time_to_time32(time(NULL));
- (void)lseek(fd, -(off_t)sizeof(UTMP), L_INCR);
- (void)write(fd, &ut, sizeof(UTMP));
- rval = 1;
- }
- (void)close(fd);
- return(rval);
-}
diff --git a/lib/libutil/logwtmp.3 b/lib/libutil/logwtmp.3
deleted file mode 100644
index 16903fb..0000000
--- a/lib/libutil/logwtmp.3
+++ /dev/null
@@ -1,71 +0,0 @@
-.\"
-.\" Copyright (c) 1996 Joerg Wunsch
-.\"
-.\" 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 DEVELOPERS ``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 DEVELOPERS 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 29, 1996
-.Os
-.Dt LOGWTMP 3
-.Sh NAME
-.Nm logwtmp
-.Nd append a new record to the wtmp file
-.Sh LIBRARY
-.Lb libutil
-.Sh SYNOPSIS
-.In sys/types.h
-.In libutil.h
-.Ft void
-.Fn logwtmp "const char *line" "const char *name" "const char *host"
-.Sh DESCRIPTION
-The function
-.Fn logwtmp
-tries to append a new record to the
-.Xr wtmp 5
-file, using the provided arguments
-.Ar line ,
-.Ar name ,
-and
-.Ar host ,
-and the current time.
-.Pp
-If the length of the hostname string
-.Ar host
-is longer than what would fit into the hostname field of the
-.Xr wtmp 5
-file, it will first be attempted to convert it into a numerical IP
-address using
-.Xr gethostbyname 3 .
-Failing this, the hostname will be recorded as
-.Qq invalid hostname .
-.Pp
-The calling process must have permission to write to the
-.Xr wtmp 5
-file.
-.Sh RETURN VALUES
-None.
-.Sh SEE ALSO
-.Xr gethostbyname 3 ,
-.Xr login 3 ,
-.Xr wtmp 5
diff --git a/lib/libutil/logwtmp.c b/lib/libutil/logwtmp.c
deleted file mode 100644
index 6ae01a7..0000000
--- a/lib/libutil/logwtmp.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*-
- * Copyright (c) 1988, 1993
- * The Regents of the University of California. 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.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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$");
-
-#if defined(LIBC_SCCS) && !defined(lint)
-#if 0
-static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93";
-#endif
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-
-#include <libutil.h>
-#include <netdb.h>
-#include <stdio.h>
-#include <string.h>
-#include <time.h>
-#include <timeconv.h>
-#include <unistd.h>
-#include <utmp.h>
-
-
-void
-logwtmp(const char *line, const char *name, const char *host)
-{
- struct utmp ut;
- struct stat buf;
- char fullhost[MAXHOSTNAMELEN];
- int fd;
-
- strlcpy(fullhost, host, sizeof(fullhost));
- trimdomain(fullhost, UT_HOSTSIZE);
- host = fullhost;
-
- if (strlen(host) > UT_HOSTSIZE) {
- int error;
- struct addrinfo hints, *res;
-
- bzero(&hints, sizeof(struct addrinfo));
- hints.ai_family = AF_UNSPEC;
- hints.ai_flags = AI_CANONNAME;
- error = getaddrinfo(host, NULL, &hints, &res);
- if (error != 0 || res->ai_addr == NULL)
- host = "invalid hostname";
- else {
- error = getnameinfo(res->ai_addr, res->ai_addrlen,
- fullhost, strlen(fullhost), NULL, 0,
- NI_NUMERICHOST);
- if (error != 0) {
- fprintf(stderr, "%d", error);
- host = "invalid hostname";
- }
- }
- }
-
- if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0)
- return;
- if (fstat(fd, &buf) == 0) {
- (void) strncpy(ut.ut_line, line, sizeof(ut.ut_line));
- (void) strncpy(ut.ut_name, name, sizeof(ut.ut_name));
- (void) strncpy(ut.ut_host, host, sizeof(ut.ut_host));
- ut.ut_time = _time_to_time32(time(NULL));
- if (write(fd, (char *)&ut, sizeof(struct utmp)) !=
- sizeof(struct utmp))
- (void) ftruncate(fd, buf.st_size);
- }
- (void) close(fd);
-}
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c
index 69232fb..75459e3 100644
--- a/lib/libutil/pw_util.c
+++ b/lib/libutil/pw_util.c
@@ -289,7 +289,7 @@ int
pw_edit(int notsetuid)
{
struct sigaction sa, sa_int, sa_quit;
- sigset_t oldsigset, sigset;
+ sigset_t oldsigset, nsigset;
struct stat st1, st2;
const char *editor;
int pstat;
@@ -303,9 +303,9 @@ pw_edit(int notsetuid)
sa.sa_flags = 0;
sigaction(SIGINT, &sa, &sa_int);
sigaction(SIGQUIT, &sa, &sa_quit);
- sigemptyset(&sigset);
- sigaddset(&sigset, SIGCHLD);
- sigprocmask(SIG_BLOCK, &sigset, &oldsigset);
+ sigemptyset(&nsigset);
+ sigaddset(&nsigset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &nsigset, &oldsigset);
switch ((editpid = fork())) {
case -1:
return (-1);
OpenPOWER on IntegriCloud