Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package wtmpdb for openSUSE:Factory checked in at 2023-04-26 17:26:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/wtmpdb (Old) and /work/SRC/openSUSE:Factory/.wtmpdb.new.1533 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "wtmpdb" Wed Apr 26 17:26:25 2023 rev:3 rq:1082984 version:0.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/wtmpdb/wtmpdb.changes 2023-04-24 22:31:44.523699241 +0200 +++ /work/SRC/openSUSE:Factory/.wtmpdb.new.1533/wtmpdb.changes 2023-04-26 17:26:28.370012288 +0200 @@ -1,0 +2,8 @@ +Wed Apr 26 09:11:23 UTC 2023 - Thorsten Kukuk <ku...@suse.com> + +- Update to version 0.5.0 + - Use uint64_t instead of usec_t to avoid conflicts + - wtmpdb boot: more accurate calculation of boot time + + +------------------------------------------------------------------- Old: ---- wtmpdb-0.4.0.tar.xz New: ---- wtmpdb-0.5.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ wtmpdb.spec ++++++ --- /var/tmp/diff_new_pack.LjO0iQ/_old 2023-04-26 17:26:29.658019803 +0200 +++ /var/tmp/diff_new_pack.LjO0iQ/_new 2023-04-26 17:26:29.666019849 +0200 @@ -18,7 +18,7 @@ %define lname libwtmpdb0 Name: wtmpdb -Version: 0.4.0 +Version: 0.5.0 Release: 0 Summary: Reports last logged in users and system reboots License: BSD-2-Clause ++++++ wtmpdb-0.4.0.tar.xz -> wtmpdb-0.5.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wtmpdb-0.4.0/NEWS new/wtmpdb-0.5.0/NEWS --- old/wtmpdb-0.4.0/NEWS 2023-04-18 08:20:46.000000000 +0200 +++ new/wtmpdb-0.5.0/NEWS 2023-04-26 11:10:14.000000000 +0200 @@ -1,3 +1,7 @@ +Version 0.5.0 +* Use uint64_t instead of usec_t to avoid conflicts with other projects +* wtmpdb boot: ore accurate calculation of boot time + Version 0.4.0 * libwtmpdb: Use project version for library version * libwtmpdb: Always use _PATH_WTMPDB as fallback diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wtmpdb-0.4.0/include/wtmpdb.h new/wtmpdb-0.5.0/include/wtmpdb.h --- old/wtmpdb-0.4.0/include/wtmpdb.h 2023-04-18 08:20:46.000000000 +0200 +++ new/wtmpdb-0.5.0/include/wtmpdb.h 2023-04-26 11:10:14.000000000 +0200 @@ -37,26 +37,25 @@ #define RUNLEVEL 2 /* The system's runlevel. Unused with systemd. */ #define USER_PROCESS 3 /* Normal process. */ -typedef uint64_t usec_t; -#define USEC_INFINITY ((usec_t) UINT64_MAX) -#define NSEC_PER_USEC ((usec_t) 1000ULL) -#define USEC_PER_SEC ((usec_t) 1000000ULL) +#define USEC_INFINITY ((uint64_t) UINT64_MAX) +#define NSEC_PER_USEC ((uint64_t) 1000ULL) +#define USEC_PER_SEC ((uint64_t) 1000000ULL) extern int64_t logwtmpdb (const char *db_path, const char *tty, const char *name, const char *host, const char *service, char **error); extern int64_t wtmpdb_login (const char *db_path, int type, - const char *user, usec_t login, + const char *user, uint64_t usec_login, const char *tty, const char *rhost, const char *service, char **error); -extern int wtmpdb_logout (const char *db_path, int64_t id, usec_t logout, - char **error); +extern int wtmpdb_logout (const char *db_path, int64_t id, + uint64_t usec_logout, char **error); extern int wtmpdb_read_all (const char *db_path, - int (*cb_func) (void *unused, int argc, + int (*cb_func) (void *unused, int argc, char **argv, char **azColName), char **error); /* helper function */ extern int64_t wtmpdb_get_id (const char *db_path, const char *tty, char **error); -extern usec_t wtmpdb_timespec2usec (const struct timespec ts); +extern uint64_t wtmpdb_timespec2usec (const struct timespec ts); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wtmpdb-0.4.0/lib/logwtmpdb.c new/wtmpdb-0.5.0/lib/logwtmpdb.c --- old/wtmpdb-0.4.0/lib/logwtmpdb.c 2023-04-18 08:20:46.000000000 +0200 +++ new/wtmpdb-0.5.0/lib/logwtmpdb.c 2023-04-26 11:10:14.000000000 +0200 @@ -33,18 +33,18 @@ #include "wtmpdb.h" -usec_t +uint64_t wtmpdb_timespec2usec (const struct timespec ts) { if (ts.tv_sec < 0 || ts.tv_nsec < 0) return USEC_INFINITY; - if ((usec_t) ts.tv_sec > + if ((uint64_t) ts.tv_sec > (UINT64_MAX - (ts.tv_nsec / NSEC_PER_USEC)) / USEC_PER_SEC) return UINT64_MAX; - return (usec_t) ts.tv_sec * USEC_PER_SEC + - (usec_t) ts.tv_nsec / NSEC_PER_USEC; + return (uint64_t) ts.tv_sec * USEC_PER_SEC + + (uint64_t) ts.tv_nsec / NSEC_PER_USEC; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wtmpdb-0.4.0/lib/sqlite.c new/wtmpdb-0.5.0/lib/sqlite.c --- old/wtmpdb-0.4.0/lib/sqlite.c 2023-04-18 08:20:46.000000000 +0200 +++ new/wtmpdb-0.5.0/lib/sqlite.c 2023-04-26 11:10:14.000000000 +0200 @@ -76,7 +76,7 @@ /* Add a new entry. Returns ID (>=0) on success, -1 on failure. */ static int64_t add_entry (sqlite3 *db, int type, const char *user, - usec_t login, const char *tty, const char *rhost, + uint64_t usec_login, const char *tty, const char *rhost, const char *service, char **error) { char *err_msg = NULL; @@ -126,7 +126,7 @@ return -1; } - if (sqlite3_bind_int64 (res, 3, login) != SQLITE_OK) + if (sqlite3_bind_int64 (res, 3, usec_login) != SQLITE_OK) { if (error) if (asprintf (error, "Failed to create replace statement for login time: %s", @@ -190,12 +190,12 @@ /* Add new wtmp entry to db. - login is usec. + login timestamp is in usec. Returns 0 on success, -1 on failure. */ int64_t wtmpdb_login (const char *db_path, int type, const char *user, - usec_t login, const char *tty, const char *rhost, + uint64_t usec_login, const char *tty, const char *rhost, const char *service, char **error) { sqlite3 *db; @@ -204,17 +204,18 @@ if ((db = open_database_rw (db_path?db_path:_PATH_WTMPDB, error)) == NULL) return -1; - retval = add_entry (db, type, user, login, tty, rhost, service, error); + retval = add_entry (db, type, user, usec_login, tty, rhost, service, error); sqlite3_close (db); return retval; } -/* Updates logout field +/* Updates logout field. + logout timestamp is in usec. Returns 0 on success, -1 on failure. */ static int -update_logout (sqlite3 *db, int64_t id, usec_t logout, char **error) +update_logout (sqlite3 *db, int64_t id, uint64_t usec_logout, char **error) { sqlite3_stmt *res; char *sql = "UPDATE wtmp SET Logout = ? WHERE ID = ?"; @@ -229,7 +230,7 @@ return -1; } - if (sqlite3_bind_int64 (res, 1, logout) != SQLITE_OK) + if (sqlite3_bind_int64 (res, 1, usec_logout) != SQLITE_OK) { if (error) if (asprintf (error, "Failed to create update query (logout): %s", @@ -284,12 +285,13 @@ /* Add logout timestamp to existingentry. - logout is usec. + logout timestamp is in usec. ID is the return value of wtmpdb_login/logwtmpdb. Returns 0 on success, -1 on failure. */ int -wtmpdb_logout (const char *db_path, int64_t id, usec_t logout, char **error) +wtmpdb_logout (const char *db_path, int64_t id, uint64_t usec_logout, + char **error) { sqlite3 *db; int retval; @@ -297,7 +299,7 @@ if ((db = open_database_rw (db_path?db_path:_PATH_WTMPDB, error)) == NULL) return -1; - retval = update_logout (db, id, logout, error); + retval = update_logout (db, id, usec_logout, error); sqlite3_close (db); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wtmpdb-0.4.0/meson.build new/wtmpdb-0.5.0/meson.build --- old/wtmpdb-0.4.0/meson.build 2023-04-18 08:20:46.000000000 +0200 +++ new/wtmpdb-0.5.0/meson.build 2023-04-26 11:10:14.000000000 +0200 @@ -11,7 +11,7 @@ 'b_pie=true', 'warning_level=3',], license : ['BSD-2-Clause',], - version : '0.4.0', + version : '0.5.0', ) conf = configuration_data() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/wtmpdb-0.4.0/src/wtmpdb.c new/wtmpdb-0.5.0/src/wtmpdb.c --- old/wtmpdb-0.4.0/src/wtmpdb.c 2023-04-18 08:20:46.000000000 +0200 +++ new/wtmpdb-0.5.0/src/wtmpdb.c 2023-04-26 11:10:14.000000000 +0200 @@ -49,7 +49,7 @@ #define TIMEFMT_SHORT 2 #define TIMEFMT_HHMM 3 -static usec_t wtmp_start = UINT64_MAX; +static uint64_t wtmp_start = UINT64_MAX; static int after_reboot = 0; /* options for last */ @@ -141,7 +141,7 @@ const char *host = argv[6]?argv[6]:""; const char *service = argv[7]?argv[7]:""; - usec_t login_t = strtoul(argv[3], &endptr, 10); + uint64_t login_t = strtoul(argv[3], &endptr, 10); if ((errno == ERANGE && login_t == UINT64_MAX) || (endptr == argv[1]) || (*endptr != '\0')) fprintf (stderr, "Invalid numeric time entry for 'login': '%s'\n", @@ -455,6 +455,18 @@ } #endif +static struct timespec +diff_timespec(const struct timespec *time1, const struct timespec *time0) +{ + struct timespec diff = {.tv_sec = time1->tv_sec - time0->tv_sec, + .tv_nsec = time1->tv_nsec - time0->tv_nsec}; + if (diff.tv_nsec < 0) { + diff.tv_nsec += 1000000000; // nsec/sec + diff.tv_sec--; + } + return diff; +} + static int main_boot (int argc, char **argv) { @@ -487,10 +499,11 @@ struct utsname uts; uname(&uts); - struct timespec ts; - clock_gettime (CLOCK_REALTIME, &ts); - int64_t time = wtmpdb_timespec2usec (ts); - + struct timespec ts_now; + struct timespec ts_boot; + clock_gettime (CLOCK_REALTIME, &ts_now); + clock_gettime (CLOCK_BOOTTIME, &ts_boot); + int64_t time = wtmpdb_timespec2usec (diff_timespec(&ts_now, &ts_boot)); #if HAVE_AUDIT log_audit (AUDIT_SYSTEM_BOOT);