version 1.32, 2015/12/26 20:51:35 |
version 1.33, 2018/07/09 21:26:02 |
|
|
#include <limits.h> |
#include <limits.h> |
|
|
#include "sshlogin.h" |
#include "sshlogin.h" |
|
#include "ssherr.h" |
#include "log.h" |
#include "log.h" |
#include "buffer.h" |
#include "sshbuf.h" |
#include "misc.h" |
#include "misc.h" |
#include "servconf.h" |
#include "servconf.h" |
|
|
extern Buffer loginmsg; |
extern struct sshbuf *loginmsg; |
extern ServerOptions options; |
extern ServerOptions options; |
|
|
/* |
/* |
|
|
static void |
static void |
store_lastlog_message(const char *user, uid_t uid) |
store_lastlog_message(const char *user, uid_t uid) |
{ |
{ |
char *time_string, hostname[HOST_NAME_MAX+1] = "", buf[512]; |
char *time_string, hostname[HOST_NAME_MAX+1] = ""; |
time_t last_login_time; |
time_t last_login_time; |
|
int r; |
|
|
if (!options.print_lastlog) |
if (!options.print_lastlog) |
return; |
return; |
|
|
time_string = ctime(&last_login_time); |
time_string = ctime(&last_login_time); |
time_string[strcspn(time_string, "\n")] = '\0'; |
time_string[strcspn(time_string, "\n")] = '\0'; |
if (strcmp(hostname, "") == 0) |
if (strcmp(hostname, "") == 0) |
snprintf(buf, sizeof(buf), "Last login: %s\r\n", |
r = sshbuf_putf(loginmsg, "Last login: %s\r\n", |
time_string); |
time_string); |
else |
else |
snprintf(buf, sizeof(buf), "Last login: %s from %s\r\n", |
r = sshbuf_putf(loginmsg, "Last login: %s from %s\r\n", |
time_string, hostname); |
time_string, hostname); |
buffer_append(&loginmsg, buf, strlen(buf)); |
if (r != 0) |
|
fatal("%s: buffer error: %s", __func__, ssh_err(r)); |
} |
} |
} |
} |
|
|