|
|
5f7b84 |
commit a33b817f13170b5c24263b92e7e09880fe797d7e
|
|
|
5f7b84 |
Author: Florian Weimer <fweimer@redhat.com>
|
|
|
5f7b84 |
Date: Tue Aug 13 12:09:32 2019 +0200
|
|
|
5f7b84 |
|
|
|
5f7b84 |
login: Assume that _HAVE_UT_* constants are true
|
|
|
5f7b84 |
|
|
|
5f7b84 |
Make the GNU version of bits/utmp.h the generic version because
|
|
|
5f7b84 |
all remaining ports use it (with a sysdeps override for
|
|
|
5f7b84 |
Linux s390/s390x).
|
|
|
5f7b84 |
|
|
|
5f7b84 |
Conflicts:
|
|
|
5f7b84 |
bits/utmp.h
|
|
|
5f7b84 |
sysdeps/gnu/bits/utmp.h
|
|
|
5f7b84 |
(Upstream copyright year change.)
|
|
|
5f7b84 |
|
|
|
5f7b84 |
diff --git a/bits/utmp.h b/bits/utmp.h
|
|
|
5f7b84 |
index 6e8695fbf072e5f1..3c02dd4f3fe4e99b 100644
|
|
|
5f7b84 |
--- a/bits/utmp.h
|
|
|
5f7b84 |
+++ b/bits/utmp.h
|
|
|
5f7b84 |
@@ -1,5 +1,5 @@
|
|
|
5f7b84 |
-/* The `struct utmp' type, describing entries in the utmp file. Generic/BSDish
|
|
|
5f7b84 |
- Copyright (C) 1993-2018 Free Software Foundation, Inc.
|
|
|
5f7b84 |
+/* The `struct utmp' type, describing entries in the utmp file.
|
|
|
5f7b84 |
+ Copyright (C) 1993-2019 Free Software Foundation, Inc.
|
|
|
5f7b84 |
This file is part of the GNU C Library.
|
|
|
5f7b84 |
|
|
|
5f7b84 |
The GNU C Library is free software; you can redistribute it and/or
|
|
|
5f7b84 |
@@ -21,29 +21,106 @@
|
|
|
5f7b84 |
#endif
|
|
|
5f7b84 |
|
|
|
5f7b84 |
#include <paths.h>
|
|
|
5f7b84 |
-#include <time.h>
|
|
|
5f7b84 |
+#include <sys/time.h>
|
|
|
5f7b84 |
+#include <sys/types.h>
|
|
|
5f7b84 |
+#include <bits/wordsize.h>
|
|
|
5f7b84 |
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-#define UT_NAMESIZE 8
|
|
|
5f7b84 |
-#define UT_LINESIZE 8
|
|
|
5f7b84 |
-#define UT_HOSTSIZE 16
|
|
|
5f7b84 |
+#define UT_LINESIZE 32
|
|
|
5f7b84 |
+#define UT_NAMESIZE 32
|
|
|
5f7b84 |
+#define UT_HOSTSIZE 256
|
|
|
5f7b84 |
|
|
|
5f7b84 |
|
|
|
5f7b84 |
+/* The structure describing an entry in the database of
|
|
|
5f7b84 |
+ previous logins. */
|
|
|
5f7b84 |
struct lastlog
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
- time_t ll_time;
|
|
|
5f7b84 |
+#if __WORDSIZE_TIME64_COMPAT32
|
|
|
5f7b84 |
+ int32_t ll_time;
|
|
|
5f7b84 |
+#else
|
|
|
5f7b84 |
+ __time_t ll_time;
|
|
|
5f7b84 |
+#endif
|
|
|
5f7b84 |
char ll_line[UT_LINESIZE];
|
|
|
5f7b84 |
char ll_host[UT_HOSTSIZE];
|
|
|
5f7b84 |
};
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-struct utmp
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+/* The structure describing the status of a terminated process. This
|
|
|
5f7b84 |
+ type is used in `struct utmp' below. */
|
|
|
5f7b84 |
+struct exit_status
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
- char ut_line[UT_LINESIZE];
|
|
|
5f7b84 |
- char ut_user[UT_NAMESIZE];
|
|
|
5f7b84 |
-#define ut_name ut_user
|
|
|
5f7b84 |
- char ut_host[UT_HOSTSIZE];
|
|
|
5f7b84 |
- long int ut_time;
|
|
|
5f7b84 |
+ short int e_termination; /* Process termination status. */
|
|
|
5f7b84 |
+ short int e_exit; /* Process exit status. */
|
|
|
5f7b84 |
};
|
|
|
5f7b84 |
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-#define _HAVE_UT_HOST 1 /* We have the ut_host field. */
|
|
|
5f7b84 |
+/* The structure describing an entry in the user accounting database. */
|
|
|
5f7b84 |
+struct utmp
|
|
|
5f7b84 |
+{
|
|
|
5f7b84 |
+ short int ut_type; /* Type of login. */
|
|
|
5f7b84 |
+ pid_t ut_pid; /* Process ID of login process. */
|
|
|
5f7b84 |
+ char ut_line[UT_LINESIZE]
|
|
|
5f7b84 |
+ __attribute_nonstring__; /* Devicename. */
|
|
|
5f7b84 |
+ char ut_id[4]; /* Inittab ID. */
|
|
|
5f7b84 |
+ char ut_user[UT_NAMESIZE]
|
|
|
5f7b84 |
+ __attribute_nonstring__; /* Username. */
|
|
|
5f7b84 |
+ char ut_host[UT_HOSTSIZE]
|
|
|
5f7b84 |
+ __attribute_nonstring__; /* Hostname for remote login. */
|
|
|
5f7b84 |
+ struct exit_status ut_exit; /* Exit status of a process marked
|
|
|
5f7b84 |
+ as DEAD_PROCESS. */
|
|
|
5f7b84 |
+/* The ut_session and ut_tv fields must be the same size when compiled
|
|
|
5f7b84 |
+ 32- and 64-bit. This allows data files and shared memory to be
|
|
|
5f7b84 |
+ shared between 32- and 64-bit applications. */
|
|
|
5f7b84 |
+#if __WORDSIZE_TIME64_COMPAT32
|
|
|
5f7b84 |
+ int32_t ut_session; /* Session ID, used for windowing. */
|
|
|
5f7b84 |
+ struct
|
|
|
5f7b84 |
+ {
|
|
|
5f7b84 |
+ int32_t tv_sec; /* Seconds. */
|
|
|
5f7b84 |
+ int32_t tv_usec; /* Microseconds. */
|
|
|
5f7b84 |
+ } ut_tv; /* Time entry was made. */
|
|
|
5f7b84 |
+#else
|
|
|
5f7b84 |
+ long int ut_session; /* Session ID, used for windowing. */
|
|
|
5f7b84 |
+ struct timeval ut_tv; /* Time entry was made. */
|
|
|
5f7b84 |
+#endif
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+ int32_t ut_addr_v6[4]; /* Internet address of remote host. */
|
|
|
5f7b84 |
+ char __glibc_reserved[20]; /* Reserved for future use. */
|
|
|
5f7b84 |
+};
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+/* Backwards compatibility hacks. */
|
|
|
5f7b84 |
+#define ut_name ut_user
|
|
|
5f7b84 |
+#ifndef _NO_UT_TIME
|
|
|
5f7b84 |
+/* We have a problem here: `ut_time' is also used otherwise. Define
|
|
|
5f7b84 |
+ _NO_UT_TIME if the compiler complains. */
|
|
|
5f7b84 |
+# define ut_time ut_tv.tv_sec
|
|
|
5f7b84 |
+#endif
|
|
|
5f7b84 |
+#define ut_xtime ut_tv.tv_sec
|
|
|
5f7b84 |
+#define ut_addr ut_addr_v6[0]
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+/* Values for the `ut_type' field of a `struct utmp'. */
|
|
|
5f7b84 |
+#define EMPTY 0 /* No valid user accounting information. */
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+#define RUN_LVL 1 /* The system's runlevel. */
|
|
|
5f7b84 |
+#define BOOT_TIME 2 /* Time of system boot. */
|
|
|
5f7b84 |
+#define NEW_TIME 3 /* Time after system clock changed. */
|
|
|
5f7b84 |
+#define OLD_TIME 4 /* Time when system clock changed. */
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+#define INIT_PROCESS 5 /* Process spawned by the init process. */
|
|
|
5f7b84 |
+#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */
|
|
|
5f7b84 |
+#define USER_PROCESS 7 /* Normal process. */
|
|
|
5f7b84 |
+#define DEAD_PROCESS 8 /* Terminated process. */
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+#define ACCOUNTING 9
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+/* Old Linux name for the EMPTY type. */
|
|
|
5f7b84 |
+#define UT_UNKNOWN EMPTY
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+
|
|
|
5f7b84 |
+/* Tell the user that we have a modern system with UT_HOST, UT_PID,
|
|
|
5f7b84 |
+ UT_TYPE, UT_ID and UT_TV fields. */
|
|
|
5f7b84 |
+#define _HAVE_UT_TYPE 1
|
|
|
5f7b84 |
+#define _HAVE_UT_PID 1
|
|
|
5f7b84 |
+#define _HAVE_UT_ID 1
|
|
|
5f7b84 |
+#define _HAVE_UT_TV 1
|
|
|
5f7b84 |
+#define _HAVE_UT_HOST 1
|
|
|
5f7b84 |
diff --git a/login/getutid_r.c b/login/getutid_r.c
|
|
|
5f7b84 |
index 8cb6b16d735e8265..11b288e99be6ee50 100644
|
|
|
5f7b84 |
--- a/login/getutid_r.c
|
|
|
5f7b84 |
+++ b/login/getutid_r.c
|
|
|
5f7b84 |
@@ -32,7 +32,6 @@ __libc_lock_define (extern, __libc_utmp_lock attribute_hidden)
|
|
|
5f7b84 |
int
|
|
|
5f7b84 |
__getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
-#if (_HAVE_UT_ID - 0) && (_HAVE_UT_TYPE - 0)
|
|
|
5f7b84 |
int retval;
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Test whether ID has any of the legal types. */
|
|
|
5f7b84 |
@@ -54,10 +53,6 @@ __getutid_r (const struct utmp *id, struct utmp *buffer, struct utmp **result)
|
|
|
5f7b84 |
__libc_lock_unlock (__libc_utmp_lock);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
return retval;
|
|
|
5f7b84 |
-#else /* !_HAVE_UT_ID && !_HAVE_UT_TYPE */
|
|
|
5f7b84 |
- __set_errno (ENOSYS);
|
|
|
5f7b84 |
- return -1;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
libc_hidden_def (__getutid_r)
|
|
|
5f7b84 |
weak_alias (__getutid_r, getutid_r)
|
|
|
5f7b84 |
diff --git a/login/getutmp.c b/login/getutmp.c
|
|
|
5f7b84 |
index 481150d5ef5a0bf0..32468ecae699fbf7 100644
|
|
|
5f7b84 |
--- a/login/getutmp.c
|
|
|
5f7b84 |
+++ b/login/getutmp.c
|
|
|
5f7b84 |
@@ -23,23 +23,11 @@
|
|
|
5f7b84 |
void
|
|
|
5f7b84 |
getutmp (const struct utmpx *utmpx, struct utmp *utmp)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
utmp->ut_type = utmpx->ut_type;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_PID - 0
|
|
|
5f7b84 |
utmp->ut_pid = utmpx->ut_pid;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
memcpy (utmp->ut_line, utmpx->ut_line, sizeof (utmp->ut_line));
|
|
|
5f7b84 |
memcpy (utmp->ut_user, utmpx->ut_user, sizeof (utmp->ut_user));
|
|
|
5f7b84 |
-#if _HAVE_UT_ID - 0
|
|
|
5f7b84 |
memcpy (utmp->ut_id, utmpx->ut_id, sizeof (utmp->ut_id));
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_HOST - 0
|
|
|
5f7b84 |
memcpy (utmp->ut_host, utmpx->ut_host, sizeof (utmp->ut_host));
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_TV - 0
|
|
|
5f7b84 |
utmp->ut_tv = utmpx->ut_tv;
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- utmp->ut_time = utmpx->ut_time;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
diff --git a/login/getutmpx.c b/login/getutmpx.c
|
|
|
5f7b84 |
index 34145fe8db71faf0..92a182698e2be438 100644
|
|
|
5f7b84 |
--- a/login/getutmpx.c
|
|
|
5f7b84 |
+++ b/login/getutmpx.c
|
|
|
5f7b84 |
@@ -24,24 +24,11 @@ void
|
|
|
5f7b84 |
getutmpx (const struct utmp *utmp, struct utmpx *utmpx)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
memset (utmpx, 0, sizeof (struct utmpx));
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
utmpx->ut_type = utmp->ut_type;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_PID - 0
|
|
|
5f7b84 |
utmpx->ut_pid = utmp->ut_pid;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
memcpy (utmpx->ut_line, utmp->ut_line, sizeof (utmp->ut_line));
|
|
|
5f7b84 |
memcpy (utmpx->ut_user, utmp->ut_user, sizeof (utmp->ut_user));
|
|
|
5f7b84 |
-#if _HAVE_UT_ID - 0
|
|
|
5f7b84 |
memcpy (utmpx->ut_id, utmp->ut_id, sizeof (utmp->ut_id));
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_HOST - 0
|
|
|
5f7b84 |
memcpy (utmpx->ut_host, utmp->ut_host, sizeof (utmp->ut_host));
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_TV - 0
|
|
|
5f7b84 |
utmpx->ut_tv = utmp->ut_tv;
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- utmpx->ut_time = utmp->ut_time;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
diff --git a/login/login.c b/login/login.c
|
|
|
5f7b84 |
index 5d48cd487f237ca0..1729fc070fcc1e4b 100644
|
|
|
5f7b84 |
--- a/login/login.c
|
|
|
5f7b84 |
+++ b/login/login.c
|
|
|
5f7b84 |
@@ -91,12 +91,8 @@ login (const struct utmp *ut)
|
|
|
5f7b84 |
struct utmp copy = *ut;
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Fill in those fields we supply. */
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
copy.ut_type = USER_PROCESS;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_PID - 0
|
|
|
5f7b84 |
copy.ut_pid = getpid ();
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Seek tty. */
|
|
|
5f7b84 |
found_tty = tty_name (STDIN_FILENO, &tty, sizeof (_tty));
|
|
|
5f7b84 |
diff --git a/login/logout.c b/login/logout.c
|
|
|
5f7b84 |
index d49bc4ecac9a8379..4d76ecf1b40d306a 100644
|
|
|
5f7b84 |
--- a/login/logout.c
|
|
|
5f7b84 |
+++ b/login/logout.c
|
|
|
5f7b84 |
@@ -36,9 +36,7 @@ logout (const char *line)
|
|
|
5f7b84 |
setutent ();
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Fill in search information. */
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
tmp.ut_type = USER_PROCESS;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
strncpy (tmp.ut_line, line, sizeof tmp.ut_line);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Read the record. */
|
|
|
5f7b84 |
@@ -46,20 +44,12 @@ logout (const char *line)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
/* Clear information about who & from where. */
|
|
|
5f7b84 |
memset (ut->ut_name, '\0', sizeof ut->ut_name);
|
|
|
5f7b84 |
-#if _HAVE_UT_HOST - 0
|
|
|
5f7b84 |
memset (ut->ut_host, '\0', sizeof ut->ut_host);
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_TV - 0
|
|
|
5f7b84 |
struct timeval tv;
|
|
|
5f7b84 |
__gettimeofday (&tv, NULL);
|
|
|
5f7b84 |
ut->ut_tv.tv_sec = tv.tv_sec;
|
|
|
5f7b84 |
ut->ut_tv.tv_usec = tv.tv_usec;
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- ut->ut_time = time (NULL);
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
ut->ut_type = DEAD_PROCESS;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
|
|
|
5f7b84 |
if (pututline (ut) != NULL)
|
|
|
5f7b84 |
result = 1;
|
|
|
5f7b84 |
diff --git a/login/logwtmp.c b/login/logwtmp.c
|
|
|
5f7b84 |
index a19da4ab5ef7a624..e0b52b23e3603b7c 100644
|
|
|
5f7b84 |
--- a/login/logwtmp.c
|
|
|
5f7b84 |
+++ b/login/logwtmp.c
|
|
|
5f7b84 |
@@ -30,26 +30,16 @@ logwtmp (const char *line, const char *name, const char *host)
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Set information in new entry. */
|
|
|
5f7b84 |
memset (&ut, 0, sizeof (ut));
|
|
|
5f7b84 |
-#if _HAVE_UT_PID - 0
|
|
|
5f7b84 |
ut.ut_pid = getpid ();
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
ut.ut_type = name[0] ? USER_PROCESS : DEAD_PROCESS;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
strncpy (ut.ut_line, line, sizeof ut.ut_line);
|
|
|
5f7b84 |
strncpy (ut.ut_name, name, sizeof ut.ut_name);
|
|
|
5f7b84 |
-#if _HAVE_UT_HOST - 0
|
|
|
5f7b84 |
strncpy (ut.ut_host, host, sizeof ut.ut_host);
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-#if _HAVE_UT_TV - 0
|
|
|
5f7b84 |
struct timeval tv;
|
|
|
5f7b84 |
__gettimeofday (&tv, NULL);
|
|
|
5f7b84 |
ut.ut_tv.tv_sec = tv.tv_sec;
|
|
|
5f7b84 |
ut.ut_tv.tv_usec = tv.tv_usec;
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- ut.ut_time = time (NULL);
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
|
|
|
5f7b84 |
updwtmp (_PATH_WTMP, &ut);
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
diff --git a/login/programs/utmpdump.c b/login/programs/utmpdump.c
|
|
|
5f7b84 |
index dccdb669f5fb9c74..1763e55af2f03d8d 100644
|
|
|
5f7b84 |
--- a/login/programs/utmpdump.c
|
|
|
5f7b84 |
+++ b/login/programs/utmpdump.c
|
|
|
5f7b84 |
@@ -37,47 +37,11 @@ print_entry (struct utmp *up)
|
|
|
5f7b84 |
temp_tv.tv_sec = up->ut_tv.tv_sec;
|
|
|
5f7b84 |
temp_tv.tv_usec = up->ut_tv.tv_usec;
|
|
|
5f7b84 |
|
|
|
5f7b84 |
- (printf) (
|
|
|
5f7b84 |
- /* The format string. */
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE
|
|
|
5f7b84 |
- "[%d] "
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_PID
|
|
|
5f7b84 |
- "[%05d] "
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_ID
|
|
|
5f7b84 |
- "[%-4.4s] "
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
- "[%-8.8s] [%-12.12s]"
|
|
|
5f7b84 |
-#if _HAVE_UT_HOST
|
|
|
5f7b84 |
- " [%-16.16s]"
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
- " [%-15.15s]"
|
|
|
5f7b84 |
-#if _HAVE_UT_TV
|
|
|
5f7b84 |
- " [%ld]"
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
- "\n"
|
|
|
5f7b84 |
- /* The arguments. */
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE
|
|
|
5f7b84 |
- , up->ut_type
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_PID
|
|
|
5f7b84 |
- , up->ut_pid
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_ID
|
|
|
5f7b84 |
- , up->ut_id
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
- , up->ut_user, up->ut_line
|
|
|
5f7b84 |
-#if _HAVE_UT_HOST
|
|
|
5f7b84 |
- , up->ut_host
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_TV
|
|
|
5f7b84 |
- , 4 + ctime (&temp_tv.tv_sec)
|
|
|
5f7b84 |
- , (long int) temp_tv.tv_usec
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- , 4 + ctime (&up->ut_time)
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
- );
|
|
|
5f7b84 |
+ printf ("[%d] [%05d] [%-4.4s] [%-8.8s] [%-12.12s] [%-16.16s] [%-15.15s]"
|
|
|
5f7b84 |
+ " [%ld]\n",
|
|
|
5f7b84 |
+ up->ut_type, up->ut_pid, up->ut_id, up->ut_user, up->ut_line,
|
|
|
5f7b84 |
+ up->ut_host, 4 + ctime (&temp_tv.tv_sec),
|
|
|
5f7b84 |
+ (long int) temp_tv.tv_usec);
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
|
|
|
5f7b84 |
int
|
|
|
5f7b84 |
diff --git a/login/tst-utmp.c b/login/tst-utmp.c
|
|
|
5f7b84 |
index 8cc7aafa89c0ea8c..49b0cbda2a719643 100644
|
|
|
5f7b84 |
--- a/login/tst-utmp.c
|
|
|
5f7b84 |
+++ b/login/tst-utmp.c
|
|
|
5f7b84 |
@@ -39,8 +39,6 @@
|
|
|
5f7b84 |
#endif
|
|
|
5f7b84 |
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-#if defined UTMPX || _HAVE_UT_TYPE
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
/* Prototype for our test function. */
|
|
|
5f7b84 |
static int do_test (int argc, char *argv[]);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
@@ -75,11 +73,7 @@ do_prepare (int argc, char *argv[])
|
|
|
5f7b84 |
|
|
|
5f7b84 |
struct utmp entry[] =
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
-#if defined UTMPX || _HAVE_UT_TV
|
|
|
5f7b84 |
#define UT(a) .ut_tv = { .tv_sec = (a)}
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
-#define UT(a) .ut_time = (a)
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
|
|
|
5f7b84 |
{ .ut_type = BOOT_TIME, .ut_pid = 1, UT(1000) },
|
|
|
5f7b84 |
{ .ut_type = RUN_LVL, .ut_pid = 1, UT(2000) },
|
|
|
5f7b84 |
@@ -167,11 +161,7 @@ simulate_login (const char *line, const char *user)
|
|
|
5f7b84 |
entry[n].ut_pid = (entry_pid += 27);
|
|
|
5f7b84 |
entry[n].ut_type = USER_PROCESS;
|
|
|
5f7b84 |
strncpy (entry[n].ut_user, user, sizeof (entry[n].ut_user));
|
|
|
5f7b84 |
-#if defined UTMPX || _HAVE_UT_TV - 0
|
|
|
5f7b84 |
entry[n].ut_tv.tv_sec = (entry_time += 1000);
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- entry[n].ut_time = (entry_time += 1000);
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
setutent ();
|
|
|
5f7b84 |
|
|
|
5f7b84 |
if (pututline (&entry[n]) == NULL)
|
|
|
5f7b84 |
@@ -201,11 +191,7 @@ simulate_logout (const char *line)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
entry[n].ut_type = DEAD_PROCESS;
|
|
|
5f7b84 |
strncpy (entry[n].ut_user, "", sizeof (entry[n].ut_user));
|
|
|
5f7b84 |
-#if defined UTMPX || _HAVE_UT_TV - 0
|
|
|
5f7b84 |
entry[n].ut_tv.tv_sec = (entry_time += 1000);
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- entry[n].ut_time = (entry_time += 1000);
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
setutent ();
|
|
|
5f7b84 |
|
|
|
5f7b84 |
if (pututline (&entry[n]) == NULL)
|
|
|
5f7b84 |
@@ -390,14 +376,3 @@ do_test (int argc, char *argv[])
|
|
|
5f7b84 |
|
|
|
5f7b84 |
return result;
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* No field 'ut_type' in struct utmp. */
|
|
|
5f7b84 |
-int
|
|
|
5f7b84 |
-main (void)
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- return 0;
|
|
|
5f7b84 |
-}
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
diff --git a/login/utmp_file.c b/login/utmp_file.c
|
|
|
5f7b84 |
index 069e6d0452e333ad..da1baa6948d0eb39 100644
|
|
|
5f7b84 |
--- a/login/utmp_file.c
|
|
|
5f7b84 |
+++ b/login/utmp_file.c
|
|
|
5f7b84 |
@@ -129,14 +129,7 @@ __libc_setutent (void)
|
|
|
5f7b84 |
file_offset = 0;
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Make sure the entry won't match. */
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
last_entry.ut_type = -1;
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- last_entry.ut_line[0] = '\177';
|
|
|
5f7b84 |
-# if _HAVE_UT_ID - 0
|
|
|
5f7b84 |
- last_entry.ut_id[0] = '\0';
|
|
|
5f7b84 |
-# endif
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
|
|
|
5f7b84 |
return 1;
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
@@ -201,7 +194,6 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer,
|
|
|
5f7b84 |
LOCKING_FAILED ();
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
if (id->ut_type == RUN_LVL || id->ut_type == BOOT_TIME
|
|
|
5f7b84 |
|| id->ut_type == OLD_TIME || id->ut_type == NEW_TIME)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
@@ -225,7 +217,6 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer,
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
else
|
|
|
5f7b84 |
-#endif /* _HAVE_UT_TYPE */
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
/* Search for the next entry with the specified ID and with type
|
|
|
5f7b84 |
INIT_PROCESS, LOGIN_PROCESS, USER_PROCESS, or DEAD_PROCESS. */
|
|
|
5f7b84 |
@@ -316,13 +307,10 @@ __libc_getutline_r (const struct utmp *line, struct utmp *buffer,
|
|
|
5f7b84 |
file_offset += sizeof (struct utmp);
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Stop if we found a user or login entry. */
|
|
|
5f7b84 |
- if (
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
- (last_entry.ut_type == USER_PROCESS
|
|
|
5f7b84 |
+ if ((last_entry.ut_type == USER_PROCESS
|
|
|
5f7b84 |
|| last_entry.ut_type == LOGIN_PROCESS)
|
|
|
5f7b84 |
- &&
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
- !strncmp (line->ut_line, last_entry.ut_line, sizeof line->ut_line))
|
|
|
5f7b84 |
+ && (strncmp (line->ut_line, last_entry.ut_line, sizeof line->ut_line)
|
|
|
5f7b84 |
+ == 0))
|
|
|
5f7b84 |
break;
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
|
|
|
5f7b84 |
@@ -368,16 +356,12 @@ __libc_pututline (const struct utmp *data)
|
|
|
5f7b84 |
|
|
|
5f7b84 |
/* Find the correct place to insert the data. */
|
|
|
5f7b84 |
if (file_offset > 0
|
|
|
5f7b84 |
- && (
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
- (last_entry.ut_type == data->ut_type
|
|
|
5f7b84 |
+ && ((last_entry.ut_type == data->ut_type
|
|
|
5f7b84 |
&& (last_entry.ut_type == RUN_LVL
|
|
|
5f7b84 |
|| last_entry.ut_type == BOOT_TIME
|
|
|
5f7b84 |
|| last_entry.ut_type == OLD_TIME
|
|
|
5f7b84 |
|| last_entry.ut_type == NEW_TIME))
|
|
|
5f7b84 |
- ||
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
- __utmp_equal (&last_entry, data)))
|
|
|
5f7b84 |
+ || __utmp_equal (&last_entry, data)))
|
|
|
5f7b84 |
found = 1;
|
|
|
5f7b84 |
else
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
diff --git a/sysdeps/generic/utmp-equal.h b/sysdeps/generic/utmp-equal.h
|
|
|
5f7b84 |
index 8b5c2e2cd2c4cf95..39993af192ab66ce 100644
|
|
|
5f7b84 |
--- a/sysdeps/generic/utmp-equal.h
|
|
|
5f7b84 |
+++ b/sysdeps/generic/utmp-equal.h
|
|
|
5f7b84 |
@@ -27,26 +27,16 @@
|
|
|
5f7b84 |
static int
|
|
|
5f7b84 |
__utmp_equal (const struct utmp *entry, const struct utmp *match)
|
|
|
5f7b84 |
{
|
|
|
5f7b84 |
- return
|
|
|
5f7b84 |
- (
|
|
|
5f7b84 |
-#if _HAVE_UT_TYPE - 0
|
|
|
5f7b84 |
- (entry->ut_type == INIT_PROCESS
|
|
|
5f7b84 |
- || entry->ut_type == LOGIN_PROCESS
|
|
|
5f7b84 |
- || entry->ut_type == USER_PROCESS
|
|
|
5f7b84 |
- || entry->ut_type == DEAD_PROCESS)
|
|
|
5f7b84 |
- &&
|
|
|
5f7b84 |
- (match->ut_type == INIT_PROCESS
|
|
|
5f7b84 |
- || match->ut_type == LOGIN_PROCESS
|
|
|
5f7b84 |
- || match->ut_type == USER_PROCESS
|
|
|
5f7b84 |
- || match->ut_type == DEAD_PROCESS)
|
|
|
5f7b84 |
- &&
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#if _HAVE_UT_ID - 0
|
|
|
5f7b84 |
- (entry->ut_id[0] && match->ut_id[0]
|
|
|
5f7b84 |
- ? strncmp (entry->ut_id, match->ut_id, sizeof match->ut_id) == 0
|
|
|
5f7b84 |
- : strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) == 0)
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line) == 0
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
- );
|
|
|
5f7b84 |
+ return (entry->ut_type == INIT_PROCESS
|
|
|
5f7b84 |
+ || entry->ut_type == LOGIN_PROCESS
|
|
|
5f7b84 |
+ || entry->ut_type == USER_PROCESS
|
|
|
5f7b84 |
+ || entry->ut_type == DEAD_PROCESS)
|
|
|
5f7b84 |
+ && (match->ut_type == INIT_PROCESS
|
|
|
5f7b84 |
+ || match->ut_type == LOGIN_PROCESS
|
|
|
5f7b84 |
+ || match->ut_type == USER_PROCESS
|
|
|
5f7b84 |
+ || match->ut_type == DEAD_PROCESS)
|
|
|
5f7b84 |
+ && (entry->ut_id[0] && match->ut_id[0]
|
|
|
5f7b84 |
+ ? strncmp (entry->ut_id, match->ut_id, sizeof match->ut_id) == 0
|
|
|
5f7b84 |
+ : (strncmp (entry->ut_line, match->ut_line, sizeof match->ut_line)
|
|
|
5f7b84 |
+ == 0));
|
|
|
5f7b84 |
}
|
|
|
5f7b84 |
diff --git a/sysdeps/gnu/bits/utmp.h b/sysdeps/gnu/bits/utmp.h
|
|
|
5f7b84 |
deleted file mode 100644
|
|
|
5f7b84 |
index 47a6082eacc56b4d..0000000000000000
|
|
|
5f7b84 |
--- a/sysdeps/gnu/bits/utmp.h
|
|
|
5f7b84 |
+++ /dev/null
|
|
|
5f7b84 |
@@ -1,126 +0,0 @@
|
|
|
5f7b84 |
-/* The `struct utmp' type, describing entries in the utmp file. GNU version.
|
|
|
5f7b84 |
- Copyright (C) 1993-2018 Free Software Foundation, Inc.
|
|
|
5f7b84 |
- This file is part of the GNU C Library.
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
5f7b84 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
5f7b84 |
- License as published by the Free Software Foundation; either
|
|
|
5f7b84 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
5f7b84 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
5f7b84 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
5f7b84 |
- Lesser General Public License for more details.
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
5f7b84 |
- License along with the GNU C Library; if not, see
|
|
|
5f7b84 |
- <http://www.gnu.org/licenses/>. */
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-#ifndef _UTMP_H
|
|
|
5f7b84 |
-# error "Never include <bits/utmp.h> directly; use <utmp.h> instead."
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-#include <paths.h>
|
|
|
5f7b84 |
-#include <sys/time.h>
|
|
|
5f7b84 |
-#include <sys/types.h>
|
|
|
5f7b84 |
-#include <bits/wordsize.h>
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-#define UT_LINESIZE 32
|
|
|
5f7b84 |
-#define UT_NAMESIZE 32
|
|
|
5f7b84 |
-#define UT_HOSTSIZE 256
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* The structure describing an entry in the database of
|
|
|
5f7b84 |
- previous logins. */
|
|
|
5f7b84 |
-struct lastlog
|
|
|
5f7b84 |
- {
|
|
|
5f7b84 |
-#if __WORDSIZE_TIME64_COMPAT32
|
|
|
5f7b84 |
- int32_t ll_time;
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- __time_t ll_time;
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
- char ll_line[UT_LINESIZE];
|
|
|
5f7b84 |
- char ll_host[UT_HOSTSIZE];
|
|
|
5f7b84 |
- };
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* The structure describing the status of a terminated process. This
|
|
|
5f7b84 |
- type is used in `struct utmp' below. */
|
|
|
5f7b84 |
-struct exit_status
|
|
|
5f7b84 |
- {
|
|
|
5f7b84 |
- short int e_termination; /* Process termination status. */
|
|
|
5f7b84 |
- short int e_exit; /* Process exit status. */
|
|
|
5f7b84 |
- };
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* The structure describing an entry in the user accounting database. */
|
|
|
5f7b84 |
-struct utmp
|
|
|
5f7b84 |
-{
|
|
|
5f7b84 |
- short int ut_type; /* Type of login. */
|
|
|
5f7b84 |
- pid_t ut_pid; /* Process ID of login process. */
|
|
|
5f7b84 |
- char ut_line[UT_LINESIZE]
|
|
|
5f7b84 |
- __attribute_nonstring__; /* Devicename. */
|
|
|
5f7b84 |
- char ut_id[4]; /* Inittab ID. */
|
|
|
5f7b84 |
- char ut_user[UT_NAMESIZE]
|
|
|
5f7b84 |
- __attribute_nonstring__; /* Username. */
|
|
|
5f7b84 |
- char ut_host[UT_HOSTSIZE]
|
|
|
5f7b84 |
- __attribute_nonstring__; /* Hostname for remote login. */
|
|
|
5f7b84 |
- struct exit_status ut_exit; /* Exit status of a process marked
|
|
|
5f7b84 |
- as DEAD_PROCESS. */
|
|
|
5f7b84 |
-/* The ut_session and ut_tv fields must be the same size when compiled
|
|
|
5f7b84 |
- 32- and 64-bit. This allows data files and shared memory to be
|
|
|
5f7b84 |
- shared between 32- and 64-bit applications. */
|
|
|
5f7b84 |
-#if __WORDSIZE_TIME64_COMPAT32
|
|
|
5f7b84 |
- int32_t ut_session; /* Session ID, used for windowing. */
|
|
|
5f7b84 |
- struct
|
|
|
5f7b84 |
- {
|
|
|
5f7b84 |
- int32_t tv_sec; /* Seconds. */
|
|
|
5f7b84 |
- int32_t tv_usec; /* Microseconds. */
|
|
|
5f7b84 |
- } ut_tv; /* Time entry was made. */
|
|
|
5f7b84 |
-#else
|
|
|
5f7b84 |
- long int ut_session; /* Session ID, used for windowing. */
|
|
|
5f7b84 |
- struct timeval ut_tv; /* Time entry was made. */
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
- int32_t ut_addr_v6[4]; /* Internet address of remote host. */
|
|
|
5f7b84 |
- char __glibc_reserved[20]; /* Reserved for future use. */
|
|
|
5f7b84 |
-};
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* Backwards compatibility hacks. */
|
|
|
5f7b84 |
-#define ut_name ut_user
|
|
|
5f7b84 |
-#ifndef _NO_UT_TIME
|
|
|
5f7b84 |
-/* We have a problem here: `ut_time' is also used otherwise. Define
|
|
|
5f7b84 |
- _NO_UT_TIME if the compiler complains. */
|
|
|
5f7b84 |
-# define ut_time ut_tv.tv_sec
|
|
|
5f7b84 |
-#endif
|
|
|
5f7b84 |
-#define ut_xtime ut_tv.tv_sec
|
|
|
5f7b84 |
-#define ut_addr ut_addr_v6[0]
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* Values for the `ut_type' field of a `struct utmp'. */
|
|
|
5f7b84 |
-#define EMPTY 0 /* No valid user accounting information. */
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-#define RUN_LVL 1 /* The system's runlevel. */
|
|
|
5f7b84 |
-#define BOOT_TIME 2 /* Time of system boot. */
|
|
|
5f7b84 |
-#define NEW_TIME 3 /* Time after system clock changed. */
|
|
|
5f7b84 |
-#define OLD_TIME 4 /* Time when system clock changed. */
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-#define INIT_PROCESS 5 /* Process spawned by the init process. */
|
|
|
5f7b84 |
-#define LOGIN_PROCESS 6 /* Session leader of a logged in user. */
|
|
|
5f7b84 |
-#define USER_PROCESS 7 /* Normal process. */
|
|
|
5f7b84 |
-#define DEAD_PROCESS 8 /* Terminated process. */
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-#define ACCOUNTING 9
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* Old Linux name for the EMPTY type. */
|
|
|
5f7b84 |
-#define UT_UNKNOWN EMPTY
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-
|
|
|
5f7b84 |
-/* Tell the user that we have a modern system with UT_HOST, UT_PID,
|
|
|
5f7b84 |
- UT_TYPE, UT_ID and UT_TV fields. */
|
|
|
5f7b84 |
-#define _HAVE_UT_TYPE 1
|
|
|
5f7b84 |
-#define _HAVE_UT_PID 1
|
|
|
5f7b84 |
-#define _HAVE_UT_ID 1
|
|
|
5f7b84 |
-#define _HAVE_UT_TV 1
|
|
|
5f7b84 |
-#define _HAVE_UT_HOST 1
|