summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/getutxent.312
-rw-r--r--lib/libc/gen/pututxline.c12
-rw-r--r--lib/libc/gen/utxdb.c11
3 files changed, 12 insertions, 23 deletions
diff --git a/lib/libc/gen/getutxent.3 b/lib/libc/gen/getutxent.3
index 7436142..37080bb 100644
--- a/lib/libc/gen/getutxent.3
+++ b/lib/libc/gen/getutxent.3
@@ -311,13 +311,9 @@ will only be written to
Entries of type
.Dv USER_PROCESS
will also be written to
-.Pa /var/run/utx.active .
-It will only be written to
-.Pa /var/log/utx.lastlogin
-if
-.Fa ut_tv
-for that user has a greater value than the existing entry or when no
-entry for the user has been found.
+.Pa /var/run/utx.active
+and
+.Pa /var/log/utx.lastlogin .
.Pp
Entries of type
.Dv DEAD_PROCESS
@@ -345,6 +341,8 @@ to be discarded.
All entries whose type has not been mentioned previously, are discarded
by this implementation of
.Fn pututxline .
+This implementation also ignores the value of
+.Fa ut_tv .
.Sh RETURN VALUES
The
.Fn getutxent ,
diff --git a/lib/libc/gen/pututxline.c b/lib/libc/gen/pututxline.c
index 1239531..ce4dc28 100644
--- a/lib/libc/gen/pututxline.c
+++ b/lib/libc/gen/pututxline.c
@@ -132,13 +132,6 @@ utx_active_remove(struct futx *fu)
if (memcmp(fu->fu_id, fe.fu_id, sizeof fe.fu_id) != 0)
continue;
- /*
- * Prevent login sessions from having a negative
- * timespan.
- */
- if (be64toh(fu->fu_tv) < be64toh(fe.fu_tv))
- fu->fu_tv = fe.fu_tv;
-
/* Terminate session. */
fseeko(fp, -(off_t)sizeof fe, SEEK_CUR);
fwrite(fu, sizeof *fu, 1, fp);
@@ -175,17 +168,12 @@ utx_lastlogin_add(const struct futx *fu)
while (fread(&fe, sizeof fe, 1, fp) == 1) {
if (strncmp(fu->fu_user, fe.fu_user, sizeof fe.fu_user) != 0)
continue;
-
- /* Prevent lowering the time value. */
- if (be64toh(fu->fu_tv) <= be64toh(fe.fu_tv))
- goto done;
/* Found a previous lastlogin entry for this user. */
fseeko(fp, -(off_t)sizeof fe, SEEK_CUR);
break;
}
fwrite(fu, sizeof *fu, 1, fp);
-done:
fclose(fp);
}
diff --git a/lib/libc/gen/utxdb.c b/lib/libc/gen/utxdb.c
index 49118ff..6a85c05 100644
--- a/lib/libc/gen/utxdb.c
+++ b/lib/libc/gen/utxdb.c
@@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$");
#include "namespace.h"
#include <sys/endian.h>
#include <sys/param.h>
+#include <sys/time.h>
#include <stdlib.h>
#include <string.h>
#include <utmpx.h>
@@ -50,9 +51,11 @@ __FBSDID("$FreeBSD$");
#define UTOF_TYPE(ut, fu) do { \
(fu)->fu_type = (ut)->ut_type; \
} while (0)
-#define UTOF_TV(ut, fu) do { \
- (fu)->fu_tv = htobe64((uint64_t)(ut)->ut_tv.tv_sec * 1000000 + \
- (uint64_t)(ut)->ut_tv.tv_usec); \
+#define UTOF_TV(fu) do { \
+ struct timeval tv; \
+ gettimeofday(&tv, NULL); \
+ (fu)->fu_tv = htobe64((uint64_t)tv.tv_sec * 1000000 + \
+ (uint64_t)tv.tv_usec); \
} while (0)
void
@@ -96,7 +99,7 @@ utx_to_futx(const struct utmpx *ut, struct futx *fu)
}
UTOF_TYPE(ut, fu);
- UTOF_TV(ut, fu);
+ UTOF_TV(fu);
}
#define FTOU_STRING(fu, ut, field) do { \
OpenPOWER on IntegriCloud