remove vestiges of old packet API from loginrec.c

This commit is contained in:
Damien Miller 2019-01-20 09:58:45 +11:00
parent c327813ea1
commit 08f66d9f17
6 changed files with 18 additions and 11 deletions

6
auth.c
View File

@ -356,11 +356,11 @@ auth_log(struct ssh *ssh, int authenticated, int partial,
(strcmp(method, "password") == 0 || (strcmp(method, "password") == 0 ||
strncmp(method, "keyboard-interactive", 20) == 0 || strncmp(method, "keyboard-interactive", 20) == 0 ||
strcmp(method, "challenge-response") == 0)) strcmp(method, "challenge-response") == 0))
record_failed_login(authctxt->user, record_failed_login(ssh, authctxt->user,
auth_get_canonical_hostname(ssh, options.use_dns), "ssh"); auth_get_canonical_hostname(ssh, options.use_dns), "ssh");
# ifdef WITH_AIXAUTHENTICATE # ifdef WITH_AIXAUTHENTICATE
if (authenticated) if (authenticated)
sys_auth_record_login(authctxt->user, sys_auth_record_login(ssh, authctxt->user,
auth_get_canonical_hostname(ssh, options.use_dns), "ssh", auth_get_canonical_hostname(ssh, options.use_dns), "ssh",
loginmsg); loginmsg);
# endif # endif
@ -601,7 +601,7 @@ getpwnamallow(struct ssh *ssh, const char *user)
logit("Invalid user %.100s from %.100s port %d", logit("Invalid user %.100s from %.100s port %d",
user, ssh_remote_ipaddr(ssh), ssh_remote_port(ssh)); user, ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
#ifdef CUSTOM_FAILED_LOGIN #ifdef CUSTOM_FAILED_LOGIN
record_failed_login(user, record_failed_login(ssh, user,
auth_get_canonical_hostname(ssh, options.use_dns), "ssh"); auth_get_canonical_hostname(ssh, options.use_dns), "ssh");
#endif #endif
#ifdef SSH_AUDIT_EVENTS #ifdef SSH_AUDIT_EVENTS

View File

@ -401,7 +401,10 @@ userauth_finish(struct ssh *ssh, int authenticated, const char *method,
fatal("%s: buffer error: %s", fatal("%s: buffer error: %s",
__func__, ssh_err(r)); __func__, ssh_err(r));
userauth_send_banner(ssh, sshbuf_ptr(loginmsg)); userauth_send_banner(ssh, sshbuf_ptr(loginmsg));
packet_write_wait(); if ((r = ssh_packet_write_wait(ssh)) != 0) {
sshpkt_fatal(ssh, r,
"%s: send PAM banner", __func__);
}
} }
fatal("Access denied for user %s by PAM account " fatal("Access denied for user %s by PAM account "
"configuration", authctxt->user); "configuration", authctxt->user);

View File

@ -1653,7 +1653,7 @@ utmpx_get_entry(struct logininfo *li)
*/ */
void void
record_failed_login(const char *username, const char *hostname, record_failed_login(struct ssh *ssh, const char *username, const char *hostname,
const char *ttyn) const char *ttyn)
{ {
int fd; int fd;
@ -1696,8 +1696,8 @@ record_failed_login(const char *username, const char *hostname,
/* strncpy because we don't necessarily want nul termination */ /* strncpy because we don't necessarily want nul termination */
strncpy(ut.ut_host, hostname, sizeof(ut.ut_host)); strncpy(ut.ut_host, hostname, sizeof(ut.ut_host));
if (packet_connection_is_on_socket() && if (ssh_packet_connection_is_on_socket(ssh) &&
getpeername(packet_get_connection_in(), getpeername(ssh_packet_get_connection_in(ssh),
(struct sockaddr *)&from, &fromlen) == 0) { (struct sockaddr *)&from, &fromlen) == 0) {
ipv64_normalise_mapped(&from, &fromlen); ipv64_normalise_mapped(&from, &fromlen);
if (from.ss_family == AF_INET) { if (from.ss_family == AF_INET) {

View File

@ -31,6 +31,8 @@
#include "includes.h" #include "includes.h"
struct ssh;
/** /**
** you should use the login_* calls to work around platform dependencies ** you should use the login_* calls to work around platform dependencies
**/ **/
@ -126,6 +128,7 @@ char *line_fullname(char *dst, const char *src, u_int dstsize);
char *line_stripname(char *dst, const char *src, int dstsize); char *line_stripname(char *dst, const char *src, int dstsize);
char *line_abbrevname(char *dst, const char *src, int dstsize); char *line_abbrevname(char *dst, const char *src, int dstsize);
void record_failed_login(const char *, const char *, const char *); void record_failed_login(struct ssh *, const char *, const char *,
const char *);
#endif /* _HAVE_LOGINREC_H_ */ #endif /* _HAVE_LOGINREC_H_ */

View File

@ -280,8 +280,8 @@ sys_auth_allowed_user(struct passwd *pw, struct sshbuf *loginmsg)
} }
int int
sys_auth_record_login(const char *user, const char *host, const char *ttynm, sys_auth_record_login(struct ssh *ssh, const char *user, const char *host,
struct sshbuf *loginmsg) const char *ttynm, struct sshbuf *loginmsg)
{ {
char *msg = NULL; char *msg = NULL;
int success = 0; int success = 0;

View File

@ -30,6 +30,7 @@
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
struct ssh;
struct sshbuf; struct sshbuf;
/* These should be in the system headers but are not. */ /* These should be in the system headers but are not. */
@ -89,7 +90,7 @@ void aix_usrinfo(struct passwd *);
# define CUSTOM_SYS_AUTH_ALLOWED_USER 1 # define CUSTOM_SYS_AUTH_ALLOWED_USER 1
int sys_auth_allowed_user(struct passwd *, struct sshbuf *); int sys_auth_allowed_user(struct passwd *, struct sshbuf *);
# define CUSTOM_SYS_AUTH_RECORD_LOGIN 1 # define CUSTOM_SYS_AUTH_RECORD_LOGIN 1
int sys_auth_record_login(const char *, const char *, int sys_auth_record_login(struct ssh *, const char *, const char *,
const char *, struct sshbuf *); const char *, struct sshbuf *);
# define CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG # define CUSTOM_SYS_AUTH_GET_LASTLOGIN_MSG
char *sys_auth_get_lastlogin_msg(const char *, uid_t); char *sys_auth_get_lastlogin_msg(const char *, uid_t);