ctl->time_mode = parse_time_mode(optarg);
break;
case 'V':
- print_version(EXIT_SUCCESS);
+ {
+ static const char *features[] = {
+#ifdef HAVE_LIBLASTLOG2
+ "lastlog2",
+#endif
+ NULL
+ };
+ print_version_with_features(EXIT_SUCCESS, features);
+ }
case 'Z':
{
#ifdef HAVE_LIBSELINUX
#
# lslogin
#
-$TS_CMD_LSLOGINS --help|grep "\--lastlog2" >/dev/null
-if [ $? -eq 0 ]; then
- # tests for lastlog2 environment
- $TS_CMD_LSLOGINS -L --lastlog2="${0%/*}/lastlog2.db" root |grep "test-tty" >/dev/null
- if [ $? -ne 0 ]; then
- ts_die "Cannot find test-tty for user root in lastlog2.db"
- fi
- $TS_CMD_LSLOGINS -L --lastlog2="${0%/*}/lastlog2.db" root |grep "test-host" >/dev/null
- if [ $? -ne 0 ]; then
- ts_die "Cannot find test-host for user root in lastlog2.db"
- fi
- $TS_CMD_LSLOGINS -L --lastlog2="${0%/*}/lastlog2.db" root |grep "Jan29/16:45" >/dev/null
- if [ $? -ne 0 ]; then
- echo `$TS_CMD_LSLOGINS -L --lastlog2="${0%/*}/lastlog2.db" root` >> $TS_OUTPUT
- ts_die "Cannot find correct last login Jan29/16:45 for user root in lastlog2.db"
- fi
+$TS_CMD_LSLOGINS --version|grep "lastlog2" >/dev/null
+if [ $? -ne 0 ]; then
+ ts_skip "lastlog2 not supported"
fi
+sqlite3 $TS_SELF/lastlog2.db < $TS_SELF/create_db.sql
+
+# tests for lastlog2 environment
+$TS_CMD_LSLOGINS -L --lastlog2="${TS_SELF}/lastlog2.db" root |grep "test-tty" >/dev/null
+if [ $? -ne 0 ]; then
+ rm $TS_SELF/lastlog2.db
+ ts_die "Cannot find test-tty for user root in lastlog2.db"
+fi
+$TS_CMD_LSLOGINS -L --lastlog2="${TS_SELF}/lastlog2.db" root |grep "test-host" >/dev/null
+if [ $? -ne 0 ]; then
+ rm $TS_SELF/lastlog2.db
+ ts_die "Cannot find test-host for user root in lastlog2.db"
+fi
+$TS_CMD_LSLOGINS -L --lastlog2="${TS_SELF}/lastlog2.db" root |grep "Jan29/16:45" >/dev/null
+if [ $? -ne 0 ]; then
+ echo `$TS_CMD_LSLOGINS -L --lastlog2="${TS_SELF}/lastlog2.db" root` >> $TS_OUTPUT
+ rm $TS_SELF/lastlog2.db
+ ts_die "Cannot find correct last login Jan29/16:45 for user root in lastlog2.db"
+fi
+
+rm $TS_SELF/lastlog2.db
ts_finalize
--- /dev/null
+PRAGMA foreign_keys=OFF;
+BEGIN TRANSACTION;
+CREATE TABLE Lastlog2(Name TEXT PRIMARY KEY, Time INTEGER, TTY TEXT, RemoteHost TEXT, Service TEXT);
+INSERT INTO Lastlog2 VALUES('user1',1706543115,'test-tty','localhost','test');
+INSERT INTO Lastlog2 VALUES('user2',0,NULL,NULL,NULL);
+INSERT INTO Lastlog2 VALUES('user3',1706543115,NULL,NULL,NULL);
+INSERT INTO Lastlog2 VALUES('root',1706543115,'test-tty','test-host',NULL);
+INSERT INTO Lastlog2 VALUES('user5',1706543115,NULL,'localhost',NULL);
+COMMIT;
\ No newline at end of file