#ifdef HAVE_LIBLASTLOG2
static int get_lastlog2(struct lslogins_control *ctl, const char *user, void *dst, int what)
{
- struct ll2_context *context = ll2_new_context(ctl->lastlog2_path); /* LL2_DEFAULT_DATABASE is default path */
+ struct ll2_context *context = ll2_new_context(ctl->lastlog2_path);
switch (what) {
case LASTLOG_TIME: {
}
*t = res_time;
break;
- }
+ }
case LASTLOG_LINE: {
char *res_tty = NULL;
free (res_tty);
}
break;
- }
+ }
case LASTLOG_HOST: {
char *res_host = NULL;
}
if (res_host) {
mem2strcpy(dst, res_host, strlen(res_host), strlen(res_host) + 1);
- free (res_host);
+ free(res_host);
}
break;
- }
+ }
default:
abort();
}
struct lastlog ll;
#ifdef HAVE_LIBLASTLOG2
- if (get_lastlog2(ctl, user, dst, LASTLOG_TIME) >= 0)
+ if (get_lastlog2(ctl, user, dst, what) >= 0)
return;
#endif
if (ctl->lastlogin_fd < 0 ||
sizeof(user_wtmp->ut_line),
sizeof(user_wtmp->ut_line) + 1);;
} else
- get_lastlog(ctl, user->uid, user->login, user->last_tty, LASTLOG_LINE);
+ get_lastlog(ctl, user->uid, user->login, user->last_tty, LASTLOG_LINE);
break;
case COL_LAST_HOSTNAME:
user->last_hostname = xcalloc(1, sizeof(user_wtmp->ut_host) + 1);
sizeof(user_wtmp->ut_host),
sizeof(user_wtmp->ut_host) + 1);;
} else
- get_lastlog(ctl, user->uid, user->login, user->last_hostname, LASTLOG_HOST);
+ get_lastlog(ctl, user->uid, user->login, user->last_hostname, LASTLOG_HOST);
break;
case COL_FAILED_LOGIN:
if (user_btmp) {
TS_CMD_SWAPLABEL=${TS_CMD_SWAPLABEL:-"${ts_commandsdir}swaplabel"}
TS_CMD_SWAPOFF=${TS_CMD_SWAPOFF:-"${ts_commandsdir}swapoff"}
TS_CMD_SWAPON=${TS_CMD_SWAPON:-"${ts_commandsdir}swapon"}
+TS_CMD_LSLOGINS=${TS_CMD_LSLOGINS:-"${ts_commandsdir}lslogins"}
TS_CMD_UL=${TS_CMD_UL-"${ts_commandsdir}ul"}
TS_CMD_UMOUNT=${TS_CMD_UMOUNT:-"${ts_commandsdir}umount"}
TS_CMD_UNSHARE=${TS_CMD_UNSHARE:-"${ts_commandsdir}unshare"}
--- /dev/null
+#!/bin/bash
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="read logins"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_check_test_command "$TS_CMD_LSLOGINS"
+
+#
+# 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
+ ts_die "Cannot find correct last login Jan29/16:45 for user root in lastlog2.db"
+ fi
+fi
+
+ts_finalize
+