summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-01-13 18:59:51 +0000
committered <ed@FreeBSD.org>2010-01-13 18:59:51 +0000
commitfc12a579a0a06596dc1b73d257d1b9751d747ce9 (patch)
tree6a9f013d6418c72a50d9746b0cde667930a59591 /lib
parentfee8e21b50dac7cfc13624b364dc2947480b06fd (diff)
downloadFreeBSD-src-fc12a579a0a06596dc1b73d257d1b9751d747ce9.zip
FreeBSD-src-fc12a579a0a06596dc1b73d257d1b9751d747ce9.tar.gz
Remove login(3), logout(3) and logwtmp(3) from libutil.
These functions only apply to utmp(5). They cannot be kept intact when moving towards utmpx. The login(3) function would break, because its argument is an utmp structure. The logout(3) and logwtmp(3) functions cannot be used, since they provide a functionality which partially overlaps. Increment SHLIB_MAJOR to 9 to indicate the removal.
Diffstat (limited to 'lib')
-rw-r--r--lib/libutil/Makefile8
-rw-r--r--lib/libutil/libutil.h4
-rw-r--r--lib/libutil/login.367
-rw-r--r--lib/libutil/login.c71
-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
8 files changed, 4 insertions, 459 deletions
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile
index eaf6120..d82d934 100644
--- a/lib/libutil/Makefile
+++ b/lib/libutil/Makefile
@@ -6,13 +6,13 @@ 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 realhostname.c \
+ pidfile.c property.c pty.c pw_util.c realhostname.c \
stub.c trimdomain.c uucplock.c
INCS= libutil.h login_cap.h
@@ -24,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/libutil.h b/lib/libutil/libutil.h
index fca133f..4c2ee3b 100644
--- a/lib/libutil/libutil.h
+++ b/lib/libutil/libutil.h
@@ -90,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;
@@ -102,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/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);
-}
OpenPOWER on IntegriCloud