Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package lastlog2 for openSUSE:Factory checked in at 2023-04-05 21:28:44 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/lastlog2 (Old) and /work/SRC/openSUSE:Factory/.lastlog2.new.19717 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "lastlog2" Wed Apr 5 21:28:44 2023 rev:4 rq:1077558 version:1.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/lastlog2/lastlog2.changes 2023-04-04 21:18:13.816352588 +0200 +++ /work/SRC/openSUSE:Factory/.lastlog2.new.19717/lastlog2.changes 2023-04-05 21:36:08.274733818 +0200 @@ -1,0 +2,14 @@ +Wed Apr 5 14:23:21 UTC 2023 - Thorsten Kukuk <ku...@suse.com> + +- Version 1.0.1 + - liblastlog2: fix memory leak + +------------------------------------------------------------------- +Wed Apr 5 13:12:56 UTC 2023 - Thorsten Kukuk <ku...@suse.com> + +- Version 1.0.0 + - Add PAM service name to database + - pam_lastlog2: Try XDG_VTNR if PAM_TTY is not a tty + - lastlog2: Fix header alignment + +------------------------------------------------------------------- Old: ---- lastlog2-0.7.0.tar.xz New: ---- lastlog2-1.0.1.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ lastlog2.spec ++++++ --- /var/tmp/diff_new_pack.A322zi/_old 2023-04-05 21:36:08.758736580 +0200 +++ /var/tmp/diff_new_pack.A322zi/_new 2023-04-05 21:36:08.770736649 +0200 @@ -16,9 +16,9 @@ # -%define lname liblastlog2-0 +%define lname liblastlog2-1 Name: lastlog2 -Version: 0.7.0 +Version: 1.0.1 Release: 0 Summary: Reports most recent login of users License: BSD-2-Clause ++++++ lastlog2-0.7.0.tar.xz -> lastlog2-1.0.1.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/NEWS new/lastlog2-1.0.1/NEWS --- old/lastlog2-0.7.0/NEWS 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/NEWS 2023-04-05 16:23:04.000000000 +0200 @@ -1,3 +1,11 @@ +Version 1.0.1 +* liblastlog2: fix memory leak + +Version 1.0.0 +* Add PAM service name to database +* pam_lastlog2: Try XDG_VTNR if PAM_TTY is not a tty +* lastlog2: Fix header alignment + Version 0.7.0 * pam_lastlog2: add silent_if= option * pam_lastlog2: try PAM_XDISPLAY if PAM_RHOST is not set diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/include/lastlog2.h new/lastlog2-1.0.1/include/lastlog2.h --- old/lastlog2-0.7.0/include/lastlog2.h 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/include/lastlog2.h 2023-04-05 16:23:04.000000000 +0200 @@ -34,14 +34,16 @@ /* Write a new entry. Returns 0 on success, -1 on failure. */ extern int ll2_write_entry (const char *lastlog2_path, const char *user, int64_t ll_time, const char *tty, - const char *rhost, char **error); + const char *rhost, const char *pam_service, + char **error); extern int ll2_read_all (const char *lastlog2_path, int (*callback)(const char *user, int64_t ll_time, - const char *tty, const char *rhost), - char **error); + const char *tty, const char *rhost, + const char *pam_service), + char **error); extern int ll2_read_entry (const char *lastlog2_path, const char *user, - int64_t *ll_time, char **tty, - char **rhost, char **error); + int64_t *ll_time, char **tty, char **rhost, + char **pam_service, char **error); extern int ll2_update_login_time (const char *lastlog2_path, const char *user, int64_t ll_time, char **error); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/lib/lastlog2.c new/lastlog2-1.0.1/lib/lastlog2.c --- old/lastlog2-0.7.0/lib/lastlog2.c 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/lib/lastlog2.c 2023-04-05 16:23:04.000000000 +0200 @@ -79,11 +79,12 @@ Returns 0 on success, -1 on failure. */ static int read_entry (sqlite3 *db, const char *user, - int64_t *ll_time, char **tty, char **rhost, char **error) + int64_t *ll_time, char **tty, char **rhost, + char **pam_service, char **error) { int retval = 0; sqlite3_stmt *res; - char *sql = "SELECT * FROM Lastlog WHERE Name = ?"; + char *sql = "SELECT * FROM Lastlog2 WHERE Name = ?"; if (sqlite3_prepare_v2 (db, sql, -1, &res, 0) != SQLITE_OK) { @@ -138,6 +139,12 @@ if (uc != NULL && strlen ((const char *)uc) > 0) *rhost = strdup ((const char *)uc); } + if (pam_service) + { + uc = sqlite3_column_text (res, 4); + if (uc != NULL && strlen ((const char *)uc) > 0) + *pam_service = strdup ((const char *)uc); + } } else { @@ -156,7 +163,8 @@ /* reads 1 entry from database and returns that. Returns 0 on success, -1 on failure. */ int ll2_read_entry (const char *lastlog2_path, const char *user, - int64_t *ll_time, char **tty, char **rhost, char **error) + int64_t *ll_time, char **tty, char **rhost, + char **pam_service, char **error) { sqlite3 *db; int retval; @@ -164,7 +172,7 @@ if ((db = open_database_ro (lastlog2_path, error)) == NULL) return -1; - retval = read_entry (db, user, ll_time, tty, rhost, error); + retval = read_entry (db, user, ll_time, tty, rhost, pam_service, error); sqlite3_close (db); @@ -175,12 +183,12 @@ static int write_entry (sqlite3 *db, const char *user, int64_t ll_time, const char *tty, const char *rhost, - char **error) + const char *pam_service, char **error) { char *err_msg = NULL; sqlite3_stmt *res; - char *sql_table = "CREATE TABLE IF NOT EXISTS Lastlog(Name TEXT PRIMARY KEY, Time INTEGER, TTY TEXT, RemoteHost TEXT) STRICT;"; - char *sql_replace = "REPLACE INTO Lastlog VALUES(?,?,?,?);"; + char *sql_table = "CREATE TABLE IF NOT EXISTS Lastlog2(Name TEXT PRIMARY KEY, Time INTEGER, TTY TEXT, RemoteHost TEXT, Service TEXT) STRICT;"; + char *sql_replace = "REPLACE INTO Lastlog2 VALUES(?,?,?,?,?);"; if (sqlite3_exec (db, sql_table, 0, 0, &err_msg) != SQLITE_OK) { @@ -246,6 +254,17 @@ return -1; } + if (sqlite3_bind_text (res, 5, pam_service, -1, SQLITE_STATIC) != SQLITE_OK) + { + if (error) + if (asprintf (error, "Failed to create replace statement for PAM service: %s", + sqlite3_errmsg (db)) < 0) + *error = strdup("Out of memory"); + + sqlite3_finalize(res); + return -1; + } + int step = sqlite3_step (res); if (step != SQLITE_DONE) @@ -268,7 +287,7 @@ int ll2_write_entry (const char *lastlog2_path, const char *user, int64_t ll_time, const char *tty, const char *rhost, - char **error) + const char *pam_service, char **error) { sqlite3 *db; int retval; @@ -276,14 +295,15 @@ if ((db = open_database_rw (lastlog2_path, error)) == NULL) return -1; - retval = write_entry (db, user, ll_time, tty, rhost, error); + retval = write_entry (db, user, ll_time, tty, rhost, pam_service, error); sqlite3_close (db); return retval; } -/* Write a new entry. Returns 0 on success, -1 on failure. */ +/* Write a new entry with updated login time. + Returns 0 on success, -1 on failure. */ int ll2_update_login_time (const char *lastlog2_path, const char *user, int64_t ll_time, char **error) @@ -292,17 +312,18 @@ int retval; char *tty; char *rhost; + char *pam_service; if ((db = open_database_rw (lastlog2_path, error)) == NULL) return -1; - if (read_entry (db, user, 0, &tty, &rhost, error) != 0) + if (read_entry (db, user, 0, &tty, &rhost, &pam_service, error) != 0) { sqlite3_close (db); return -1; } - retval = write_entry (db, user, ll_time, tty, rhost, error); + retval = write_entry (db, user, ll_time, tty, rhost, pam_service, error); sqlite3_close (db); @@ -310,13 +331,16 @@ free (tty); if (rhost) free (rhost); + if (pam_service) + free (pam_service); return retval; } typedef int (*callback_f)(const char *user, int64_t ll_time, - const char *tty, const char *rhost); + const char *tty, const char *rhost, + const char *pam_service); static int callback (void *cb_func, int argc, char **argv, char **azColName) @@ -324,7 +348,7 @@ char *endptr; callback_f print_entry = cb_func; - if (argc != 4) + if (argc != 5) { fprintf (stderr, "Mangled entry:"); for (int i = 0; i < argc; i++) @@ -339,7 +363,7 @@ || (endptr == argv[1]) || (*endptr != '\0')) fprintf (stderr, "Invalid numeric time entry for '%s': '%s'\n", argv[0], argv[1]); - print_entry (argv[0], ll_time, argv[2], argv[3]); + print_entry (argv[0], ll_time, argv[2], argv[3], argv[4]); return 0; } @@ -349,7 +373,8 @@ int ll2_read_all (const char *lastlog2_path, int (*cb_func)(const char *user, int64_t ll_time, - const char *tty, const char *rhost), + const char *tty, const char *rhost, + const char *pam_service), char **error) { sqlite3 *db; @@ -358,7 +383,7 @@ if ((db = open_database_ro (lastlog2_path, error)) == NULL) return -1; - char *sql = "SELECT * FROM Lastlog"; + char *sql = "SELECT * FROM Lastlog2"; if (sqlite3_exec (db, sql, callback, cb_func, &err_msg) != SQLITE_OK) { @@ -381,7 +406,7 @@ remove_entry (sqlite3 *db, const char *user, char **error) { sqlite3_stmt *res; - char *sql = "DELETE FROM Lastlog WHERE Name = ?"; + char *sql = "DELETE FROM Lastlog2 WHERE Name = ?"; if (sqlite3_prepare_v2 (db, sql, -1, &res, 0) != SQLITE_OK) { @@ -449,18 +474,19 @@ time_t ll_time; char *tty; char *rhost; + char *pam_service; int retval; if ((db = open_database_rw (lastlog2_path, error)) == NULL) return -1; - if (read_entry (db, user, &ll_time, &tty, &rhost, error) != 0) + if (read_entry (db, user, &ll_time, &tty, &rhost, &pam_service, error) != 0) { sqlite3_close (db); return -1; } - if (write_entry (db, newname, ll_time, tty, rhost, error) != 0) + if (write_entry (db, newname, ll_time, tty, rhost, pam_service, error) != 0) { sqlite3_close (db); if (tty) @@ -478,6 +504,8 @@ free (tty); if (rhost) free (rhost); + if (pam_service) + free (pam_service); return retval; } @@ -555,7 +583,7 @@ rhost[UT_HOSTSIZE] = '\0'; if (write_entry (db, pw->pw_name, ll_time, tty, - rhost, error) != 0) + rhost, NULL, error) != 0) { endpwent (); sqlite3_close (db); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/lib/liblastlog2.map new/lastlog2-1.0.1/lib/liblastlog2.map --- old/lastlog2-0.7.0/lib/liblastlog2.map 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/lib/liblastlog2.map 2023-04-05 16:23:04.000000000 +0200 @@ -1,4 +1,4 @@ -LIBLASTLOG2_0.5 { +LIBLASTLOG2_1.0 { global: ll2_read_all; ll2_read_entry; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/meson.build new/lastlog2-1.0.1/meson.build --- old/lastlog2-0.7.0/meson.build 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/meson.build 2023-04-05 16:23:04.000000000 +0200 @@ -11,7 +11,7 @@ 'b_pie=true', 'warning_level=2',], license : ['BSD-2-Clause',], - version : '0.7.0', + version : '1.0.1', ) cc = meson.get_compiler('c') @@ -108,7 +108,7 @@ link_depends : liblastlog2_map, dependencies : [libsqlite3], install : true, - soversion : '0' + soversion : '1' ) install_headers('include/lastlog2.h') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/src/lastlog2.c new/lastlog2-1.0.1/src/lastlog2.c --- old/lastlog2-0.7.0/src/lastlog2.c 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/src/lastlog2.c 2023-04-05 16:23:04.000000000 +0200 @@ -45,7 +45,8 @@ static int print_entry (const char *user, time_t ll_time, - const char *tty, const char *rhost) + const char *tty, const char *rhost, + const char *pam_service __attribute__((__unused__))) { static int once = 0; char *datep; @@ -78,10 +79,10 @@ if (!once) { - printf ("Username Port From%*sLatest\n", maxIPv6Addrlen-3, " "); + printf ("Username Port From%*s Latest\n", maxIPv6Addrlen-4, " "); once = 1; } - printf ("%-16s %-8.8s %*s%s\n", user, tty ? tty : "", + printf ("%-16s %-8.8s %*s %s\n", user, tty ? tty : "", -maxIPv6Addrlen, rhost ? rhost : "", datep); return 0; @@ -323,6 +324,7 @@ time_t ll_time = 0; char *tty = NULL; char *rhost = NULL; + char *service = NULL; if (check_user (user) != 0) { @@ -331,9 +333,10 @@ } /* We ignore errors, if the user is not in the database he did never login */ - ll2_read_entry (lastlog2_path, user, &ll_time, &tty, &rhost, NULL); + ll2_read_entry (lastlog2_path, user, &ll_time, &tty, &rhost, + &service, NULL); - print_entry(user, ll_time, tty, rhost); + print_entry(user, ll_time, tty, rhost, service); exit (EXIT_SUCCESS); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/src/pam_lastlog2.c new/lastlog2-1.0.1/src/pam_lastlog2.c --- old/lastlog2-0.7.0/src/pam_lastlog2.c 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/src/pam_lastlog2.c 2023-04-05 16:23:04.000000000 +0200 @@ -104,14 +104,6 @@ if (flags & PAM_SILENT) ctrl |= LASTLOG2_QUIET; - const void *void_str = NULL; - const char *service; - if ((pam_get_item (pamh, PAM_SERVICE, &void_str) != PAM_SUCCESS) || - void_str == NULL) - service = ""; - else - service = void_str; - /* step through arguments */ for (; argc-- > 0; ++argv) { @@ -123,6 +115,14 @@ lastlog2_path = str; else if ((str = skip_prefix (*argv, "silent_if=")) != NULL) { + const void *void_str = NULL; + const char *service; + if ((pam_get_item (pamh, PAM_SERVICE, &void_str) != PAM_SUCCESS) || + void_str == NULL) + service = ""; + else + service = void_str; + if (check_in_list (service, str)) { if (ctrl & LASTLOG2_DEBUG) @@ -143,6 +143,10 @@ const void *void_str; const char *tty; const char *rhost; + const char *pam_service; + const char *xdg_vtnr; + int xdg_vtnr_nr; + char tty_buf[8]; time_t ll_time; char *error = NULL; int retval; @@ -162,6 +166,18 @@ if (ctrl & LASTLOG2_DEBUG) pam_syslog (pamh, LOG_DEBUG, "tty=%s", tty); + /* if PAM_TTY is not set or an X11 $DISPLAY, try XDG_VTNR */ + if ((tty[0] == '\0' || strchr(tty, ':') != NULL) && (xdg_vtnr = pam_getenv (pamh, "XDG_VTNR")) != NULL) + { + xdg_vtnr_nr = atoi (xdg_vtnr); + if (xdg_vtnr_nr > 0 && snprintf (tty_buf, sizeof(tty_buf), "tty%d", xdg_vtnr_nr) < (int) sizeof(tty_buf)) + { + tty = tty_buf; + if (ctrl & LASTLOG2_DEBUG) + pam_syslog (pamh, LOG_DEBUG, "tty(XDG_VTNR)=%s", tty); + } + } + void_str = NULL; retval = pam_get_item (pamh, PAM_RHOST, &void_str); if (retval != PAM_SUCCESS || void_str == NULL) @@ -184,10 +200,18 @@ pam_syslog (pamh, LOG_DEBUG, "rhost(PAM_RHOST)=%s", rhost); } + void_str = NULL; + if ((pam_get_item (pamh, PAM_SERVICE, &void_str) != PAM_SUCCESS) || + void_str == NULL) + pam_service = ""; + else + pam_service = void_str; + if (time (&ll_time) < 0) return PAM_SYSTEM_ERR; - if (ll2_write_entry (lastlog2_path, user, ll_time, tty, rhost, &error) != 0) + if (ll2_write_entry (lastlog2_path, user, ll_time, tty, rhost, + pam_service, &error) != 0) { if (error) { @@ -208,6 +232,7 @@ time_t ll_time = 0; char *tty = NULL; char *rhost = NULL; + char *service = NULL; char *date = NULL; char the_time[256]; char *error = NULL; @@ -216,7 +241,8 @@ if (ctrl & LASTLOG2_QUIET) return PAM_SUCCESS; - if (ll2_read_entry (lastlog2_path, user, &ll_time, &tty, &rhost, &error) != 0) + if (ll2_read_entry (lastlog2_path, user, &ll_time, &tty, &rhost, + &service, &error) != 0) { if (error) { @@ -248,6 +274,7 @@ tty ? " on " : "", tty ? tty : ""); + _pam_drop(service); _pam_drop(rhost); _pam_drop(tty); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/tests/tst-pam_lastlog2-output.c new/lastlog2-1.0.1/tests/tst-pam_lastlog2-output.c --- old/lastlog2-0.7.0/tests/tst-pam_lastlog2-output.c 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/tests/tst-pam_lastlog2-output.c 2023-04-05 16:23:04.000000000 +0200 @@ -54,7 +54,7 @@ char *output = NULL; if (ll2_write_entry (db_path, user, login_time, "pts/0", - "192.168.122.1", &error) != 0) + "192.168.122.1", NULL, &error) != 0) { if (error) { @@ -66,7 +66,8 @@ return 1; } - if (ll2_read_entry (db_path, user, &ll_time, &tty, &rhost, &error) != 0) + if (ll2_read_entry (db_path, user, &ll_time, &tty, &rhost, + NULL, &error) != 0) { if (error) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/tests/tst-remove-entry.c new/lastlog2-1.0.1/tests/tst-remove-entry.c --- old/lastlog2-0.7.0/tests/tst-remove-entry.c 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/tests/tst-remove-entry.c 2023-04-05 16:23:04.000000000 +0200 @@ -45,10 +45,11 @@ time_t ll_time = 0; char *tty = NULL; char *rhost = NULL; + char *service = NULL; char *error = NULL; if (ll2_write_entry (db_path, user, time (NULL), "test-tty", - "localhost", &error) != 0) + "localhost", "sshd", &error) != 0) { if (error) { @@ -73,11 +74,11 @@ } /* this needs to fail, as the old entry shouldn't exist anymore. */ - if (ll2_read_entry (db_path, user, &ll_time, &tty, &rhost, &error) == 0) + if (ll2_read_entry (db_path, user, &ll_time, &tty, &rhost, &service, &error) == 0) { fprintf (stderr, "Reading old user from database did not fail!\n"); - fprintf (stderr, "ll_time=%lld, tty='%s', rhost='%s'\n", - (long long int)ll_time, tty, rhost); + fprintf (stderr, "ll_time=%lld, tty='%s', rhost='%s', service='%s'\n", + (long long int)ll_time, tty, rhost, service); return 1; } @@ -87,6 +88,8 @@ free (tty); if (rhost) free (rhost); + if (service) + free (service); return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/tests/tst-rename-user.c new/lastlog2-1.0.1/tests/tst-rename-user.c --- old/lastlog2-0.7.0/tests/tst-rename-user.c 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/tests/tst-rename-user.c 2023-04-05 16:23:04.000000000 +0200 @@ -46,10 +46,11 @@ time_t ll_time = 0; char *tty = NULL; char *rhost = NULL; + char *service = NULL; char *error = NULL; if (ll2_write_entry (db_path, user, time (NULL), "test-tty", - "localhost", &error) != 0) + "localhost", "test-service", &error) != 0) { if (error) { @@ -74,11 +75,12 @@ } /* this needs to fail, as the old entry shouldn't exist anymore. */ - if (ll2_read_entry (db_path, user, &ll_time, &tty, &rhost, &error) == 0) + if (ll2_read_entry (db_path, user, &ll_time, &tty, &rhost, + &service, &error) == 0) { fprintf (stderr, "Reading old user from database did not fail!\n"); - fprintf (stderr, "ll_time=%lld, tty='%s', rhost='%s'\n", - (long long int)ll_time, tty, rhost); + fprintf (stderr, "ll_time=%lld, tty='%s', rhost='%s', service='%s'\n", + (long long int)ll_time, tty, rhost, service); return 1; } @@ -88,7 +90,8 @@ error = NULL; } - if (ll2_read_entry (db_path, newname, &ll_time, &tty, &rhost, &error) != 0) + if (ll2_read_entry (db_path, newname, &ll_time, &tty, &rhost, &service, + &error) != 0) { if (error) { @@ -100,7 +103,8 @@ return 1; } - if (strcmp (tty, "test-tty") != 0 || strcmp (rhost, "localhost") != 0) + if (strcmp (tty, "test-tty") != 0 || strcmp (rhost, "localhost") != 0 || + strcmp (service, "test-service") != 0) { fprintf (stderr, "New entry data does not match old entry data!\n"); } @@ -109,6 +113,8 @@ free (tty); if (rhost) free (rhost); + if (service) + free (service); return 0; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/tests/tst-write-read-user.c new/lastlog2-1.0.1/tests/tst-write-read-user.c --- old/lastlog2-0.7.0/tests/tst-write-read-user.c 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/tests/tst-write-read-user.c 2023-04-05 16:23:04.000000000 +0200 @@ -39,14 +39,15 @@ static int test_args (const char *db_path, const char *user, int64_t ll_time, - const char *tty, const char *rhost) + const char *tty, const char *rhost, const char *service) { char *error = NULL; int64_t res_time; char *res_tty = NULL; char *res_rhost = NULL; + char *res_service = NULL; - if (ll2_write_entry (db_path, user, ll_time, tty, rhost, &error) != 0) + if (ll2_write_entry (db_path, user, ll_time, tty, rhost, service, &error) != 0) { if (error) { @@ -58,7 +59,7 @@ return 1; } - if (ll2_read_entry (db_path, user, &res_time, &res_tty, &res_rhost, &error) != 0) + if (ll2_read_entry (db_path, user, &res_time, &res_tty, &res_rhost, &res_service, &error) != 0) { if (error) { @@ -93,11 +94,21 @@ return 1; } + if ((service == NULL && res_service != NULL) || + (service != NULL && res_service == NULL) || + (service != NULL && res_service != NULL && strcmp (service, res_service) != 0)) + { + fprintf (stderr, "Wrong service: got %s, expect %s\n", service, res_service); + return 1; + } + + if (res_tty) free (res_tty); - if (res_rhost) free (res_rhost); + if (res_service) + free (res_service); return 0; } @@ -107,15 +118,15 @@ { const char *db_path = "tst-write-read-user.db"; - if (test_args (db_path, "user1", time (NULL), "test-tty", "localhost") != 0) + if (test_args (db_path, "user1", time (NULL), "test-tty", "localhost", "test") != 0) return 1; - if (test_args (db_path, "user2", 0, NULL, NULL) != 0) + if (test_args (db_path, "user2", 0, NULL, NULL, NULL) != 0) return 1; - if (test_args (db_path, "user3", time (NULL), NULL, NULL) != 0) + if (test_args (db_path, "user3", time (NULL), NULL, NULL, NULL) != 0) return 1; - if (test_args (db_path, "user4", time (NULL), "test-tty", NULL) != 0) + if (test_args (db_path, "user4", time (NULL), "test-tty", NULL, NULL) != 0) return 1; - if (test_args (db_path, "user5", time (NULL), NULL, "localhost") != 0) + if (test_args (db_path, "user5", time (NULL), NULL, "localhost", NULL) != 0) return 1; return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/tests/tst-y2038-ll2_read_all.c new/lastlog2-1.0.1/tests/tst-y2038-ll2_read_all.c --- old/lastlog2-0.7.0/tests/tst-y2038-ll2_read_all.c 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/tests/tst-y2038-ll2_read_all.c 2023-04-05 16:23:04.000000000 +0200 @@ -44,10 +44,11 @@ const char *user = "y2038"; const char *tty = "pts/test"; const char *rhost = NULL; +const char *service = "sshd"; static int check_y2038 (const char *res_user, time_t ll_time, const char *res_tty, - const char *res_rhost) + const char *res_rhost, const char *res_service) { if (strcmp (user, res_user) != 0) @@ -78,6 +79,12 @@ exit (1); } + if (strcmp (service, res_service) != 0) + { + fprintf (stderr, "write/read entry service mismatch: written: %s, got: %s\n", + service, res_service); + exit (1); + } return 0; } @@ -92,7 +99,8 @@ printf ("Big time value is: %lld\n", (long long int)BIG_TIME_VALUE); - if (ll2_write_entry (db_path, user, BIG_TIME_VALUE, tty, rhost, &error) != 0) + if (ll2_write_entry (db_path, user, BIG_TIME_VALUE, tty, rhost, service, + &error) != 0) { if (error) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lastlog2-0.7.0/tests/tst-y2038-sqlite3-time.c new/lastlog2-1.0.1/tests/tst-y2038-sqlite3-time.c --- old/lastlog2-0.7.0/tests/tst-y2038-sqlite3-time.c 2023-04-03 11:58:46.000000000 +0200 +++ new/lastlog2-1.0.1/tests/tst-y2038-sqlite3-time.c 2023-04-05 16:23:04.000000000 +0200 @@ -49,7 +49,8 @@ printf ("Big time value is: %lld\n", (long long int)BIG_TIME_VALUE); - if (ll2_write_entry (db_path, user, BIG_TIME_VALUE, NULL, NULL, &error) != 0) + if (ll2_write_entry (db_path, user, BIG_TIME_VALUE, NULL, NULL, + NULL, &error) != 0) { if (error) { @@ -61,7 +62,8 @@ return 1; } - if (ll2_read_entry (db_path, user, &ll_time, NULL, NULL, &error) != 0) + if (ll2_read_entry (db_path, user, &ll_time, NULL, NULL, NULL, + &error) != 0) { if (error) {