summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--audit-bsm.c2
-rw-r--r--audit-linux.c4
-rw-r--r--audit.c2
-rw-r--r--audit.h4
-rw-r--r--auth.c4
-rw-r--r--auth2.c6
-rw-r--r--monitor.c2
-rw-r--r--monitor_wrap.c2
-rw-r--r--monitor_wrap.h2
-rw-r--r--regress/misc/kexfuzz/kexfuzz.c2
-rw-r--r--regress/unittests/kex/test_kex.c2
-rw-r--r--session.c32
-rw-r--r--ssh-keyscan.c2
-rw-r--r--ssh-keysign.c2
-rw-r--r--sshd.c8
15 files changed, 18 insertions, 58 deletions
diff --git a/audit-bsm.c b/audit-bsm.c
index 1409f69ae..0ba16c72c 100644
--- a/audit-bsm.c
+++ b/audit-bsm.c
@@ -391,7 +391,7 @@ audit_session_close(struct logininfo *li)
391} 391}
392 392
393void 393void
394audit_event(ssh_audit_event_t event) 394audit_event(struct ssh *ssh, ssh_audit_event_t event)
395{ 395{
396 char textbuf[BSM_TEXTBUFSZ]; 396 char textbuf[BSM_TEXTBUFSZ];
397 static int logged_in = 0; 397 static int logged_in = 0;
diff --git a/audit-linux.c b/audit-linux.c
index 136ed76bb..3fcbe5c53 100644
--- a/audit-linux.c
+++ b/audit-linux.c
@@ -97,10 +97,8 @@ audit_session_close(struct logininfo *li)
97} 97}
98 98
99void 99void
100audit_event(ssh_audit_event_t event) 100audit_event(struct ssh *ssh, ssh_audit_event_t event)
101{ 101{
102 struct ssh *ssh = active_state; /* XXX */
103
104 switch(event) { 102 switch(event) {
105 case SSH_AUTH_SUCCESS: 103 case SSH_AUTH_SUCCESS:
106 case SSH_CONNECTION_CLOSE: 104 case SSH_CONNECTION_CLOSE:
diff --git a/audit.c b/audit.c
index 33a04376d..dd2f03558 100644
--- a/audit.c
+++ b/audit.c
@@ -131,7 +131,7 @@ audit_connection_from(const char *host, int port)
131 * events and what they mean). 131 * events and what they mean).
132 */ 132 */
133void 133void
134audit_event(ssh_audit_event_t event) 134audit_event(struct ssh *ssh, ssh_audit_event_t event)
135{ 135{
136 debug("audit event euid %d user %s event %d (%s)", geteuid(), 136 debug("audit event euid %d user %s event %d (%s)", geteuid(),
137 audit_username(), event, audit_event_lookup(event)); 137 audit_username(), event, audit_event_lookup(event));
diff --git a/audit.h b/audit.h
index 0b593666d..38cb5ad31 100644
--- a/audit.h
+++ b/audit.h
@@ -27,6 +27,8 @@
27 27
28#include "loginrec.h" 28#include "loginrec.h"
29 29
30struct ssh;
31
30enum ssh_audit_event_type { 32enum ssh_audit_event_type {
31 SSH_LOGIN_EXCEED_MAXTRIES, 33 SSH_LOGIN_EXCEED_MAXTRIES,
32 SSH_LOGIN_ROOT_DENIED, 34 SSH_LOGIN_ROOT_DENIED,
@@ -46,7 +48,7 @@ enum ssh_audit_event_type {
46typedef enum ssh_audit_event_type ssh_audit_event_t; 48typedef enum ssh_audit_event_type ssh_audit_event_t;
47 49
48void audit_connection_from(const char *, int); 50void audit_connection_from(const char *, int);
49void audit_event(ssh_audit_event_t); 51void audit_event(struct ssh *, ssh_audit_event_t);
50void audit_session_open(struct logininfo *); 52void audit_session_open(struct logininfo *);
51void audit_session_close(struct logininfo *); 53void audit_session_close(struct logininfo *);
52void audit_run_command(const char *); 54void audit_run_command(const char *);
diff --git a/auth.c b/auth.c
index a4c1dece5..62c58e72f 100644
--- a/auth.c
+++ b/auth.c
@@ -367,7 +367,7 @@ auth_log(struct ssh *ssh, int authenticated, int partial,
367#endif 367#endif
368#ifdef SSH_AUDIT_EVENTS 368#ifdef SSH_AUDIT_EVENTS
369 if (authenticated == 0 && !authctxt->postponed) 369 if (authenticated == 0 && !authctxt->postponed)
370 audit_event(audit_classify_auth(method)); 370 audit_event(ssh, audit_classify_auth(method));
371#endif 371#endif
372} 372}
373 373
@@ -605,7 +605,7 @@ getpwnamallow(struct ssh *ssh, const char *user)
605 auth_get_canonical_hostname(ssh, options.use_dns), "ssh"); 605 auth_get_canonical_hostname(ssh, options.use_dns), "ssh");
606#endif 606#endif
607#ifdef SSH_AUDIT_EVENTS 607#ifdef SSH_AUDIT_EVENTS
608 audit_event(SSH_INVALID_USER); 608 audit_event(ssh, SSH_INVALID_USER);
609#endif /* SSH_AUDIT_EVENTS */ 609#endif /* SSH_AUDIT_EVENTS */
610 return (NULL); 610 return (NULL);
611 } 611 }
diff --git a/auth2.c b/auth2.c
index a80b3f872..e43350c36 100644
--- a/auth2.c
+++ b/auth2.c
@@ -294,7 +294,7 @@ input_userauth_request(int type, u_int32_t seq, struct ssh *ssh)
294 /* Invalid user, fake password information */ 294 /* Invalid user, fake password information */
295 authctxt->pw = fakepw(); 295 authctxt->pw = fakepw();
296#ifdef SSH_AUDIT_EVENTS 296#ifdef SSH_AUDIT_EVENTS
297 PRIVSEP(audit_event(SSH_INVALID_USER)); 297 PRIVSEP(audit_event(ssh, SSH_INVALID_USER));
298#endif 298#endif
299 } 299 }
300#ifdef USE_PAM 300#ifdef USE_PAM
@@ -369,7 +369,7 @@ userauth_finish(struct ssh *ssh, int authenticated, const char *method,
369 !auth_root_allowed(ssh, method)) { 369 !auth_root_allowed(ssh, method)) {
370 authenticated = 0; 370 authenticated = 0;
371#ifdef SSH_AUDIT_EVENTS 371#ifdef SSH_AUDIT_EVENTS
372 PRIVSEP(audit_event(SSH_LOGIN_ROOT_DENIED)); 372 PRIVSEP(audit_event(ssh, SSH_LOGIN_ROOT_DENIED));
373#endif 373#endif
374 } 374 }
375 375
@@ -430,7 +430,7 @@ userauth_finish(struct ssh *ssh, int authenticated, const char *method,
430 authctxt->failures++; 430 authctxt->failures++;
431 if (authctxt->failures >= options.max_authtries) { 431 if (authctxt->failures >= options.max_authtries) {
432#ifdef SSH_AUDIT_EVENTS 432#ifdef SSH_AUDIT_EVENTS
433 PRIVSEP(audit_event(SSH_LOGIN_EXCEED_MAXTRIES)); 433 PRIVSEP(audit_event(ssh, SSH_LOGIN_EXCEED_MAXTRIES));
434#endif 434#endif
435 auth_maxtries_exceeded(ssh); 435 auth_maxtries_exceeded(ssh);
436 } 436 }
diff --git a/monitor.c b/monitor.c
index 5fa30b2a8..a9546dad2 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1628,7 +1628,7 @@ mm_answer_audit_event(struct ssh *ssh, int socket, struct sshbuf *m)
1628 case SSH_LOGIN_ROOT_DENIED: 1628 case SSH_LOGIN_ROOT_DENIED:
1629 case SSH_CONNECTION_CLOSE: 1629 case SSH_CONNECTION_CLOSE:
1630 case SSH_INVALID_USER: 1630 case SSH_INVALID_USER:
1631 audit_event(event); 1631 audit_event(ssh, event);
1632 break; 1632 break;
1633 default: 1633 default:
1634 fatal("Audit event type %d not permitted", event); 1634 fatal("Audit event type %d not permitted", event);
diff --git a/monitor_wrap.c b/monitor_wrap.c
index f52b9c88c..9e3c7cd17 100644
--- a/monitor_wrap.c
+++ b/monitor_wrap.c
@@ -867,7 +867,7 @@ mm_bsdauth_respond(void *ctx, u_int numresponses, char **responses)
867 867
868#ifdef SSH_AUDIT_EVENTS 868#ifdef SSH_AUDIT_EVENTS
869void 869void
870mm_audit_event(ssh_audit_event_t event) 870mm_audit_event(struct ssh *ssh, ssh_audit_event_t event)
871{ 871{
872 struct sshbuf *m; 872 struct sshbuf *m;
873 int r; 873 int r;
diff --git a/monitor_wrap.h b/monitor_wrap.h
index c7e0c91dd..fdebb3aa4 100644
--- a/monitor_wrap.h
+++ b/monitor_wrap.h
@@ -76,7 +76,7 @@ void mm_sshpam_free_ctx(void *);
76 76
77#ifdef SSH_AUDIT_EVENTS 77#ifdef SSH_AUDIT_EVENTS
78#include "audit.h" 78#include "audit.h"
79void mm_audit_event(ssh_audit_event_t); 79void mm_audit_event(struct ssh *, ssh_audit_event_t);
80void mm_audit_run_command(const char *); 80void mm_audit_run_command(const char *);
81#endif 81#endif
82 82
diff --git a/regress/misc/kexfuzz/kexfuzz.c b/regress/misc/kexfuzz/kexfuzz.c
index 3e2c48160..61cae042f 100644
--- a/regress/misc/kexfuzz/kexfuzz.c
+++ b/regress/misc/kexfuzz/kexfuzz.c
@@ -29,8 +29,6 @@
29#include "authfile.h" 29#include "authfile.h"
30#include "log.h" 30#include "log.h"
31 31
32struct ssh *active_state = NULL; /* XXX - needed for linking */
33
34void kex_tests(void); 32void kex_tests(void);
35static int do_debug = 0; 33static int do_debug = 0;
36 34
diff --git a/regress/unittests/kex/test_kex.c b/regress/unittests/kex/test_kex.c
index 90f1ebf45..112bc5499 100644
--- a/regress/unittests/kex/test_kex.c
+++ b/regress/unittests/kex/test_kex.c
@@ -24,8 +24,6 @@
24#include "packet.h" 24#include "packet.h"
25#include "myproposal.h" 25#include "myproposal.h"
26 26
27struct ssh *active_state = NULL; /* XXX - needed for linking */
28
29void kex_tests(void); 27void kex_tests(void);
30static int do_debug = 0; 28static int do_debug = 0;
31 29
diff --git a/session.c b/session.c
index b5a382473..4862e5d63 100644
--- a/session.c
+++ b/session.c
@@ -123,9 +123,6 @@ int do_exec_no_pty(struct ssh *, Session *, const char *);
123int do_exec(struct ssh *, Session *, const char *); 123int do_exec(struct ssh *, Session *, const char *);
124void do_login(struct ssh *, Session *, const char *); 124void do_login(struct ssh *, Session *, const char *);
125void do_child(struct ssh *, Session *, const char *); 125void do_child(struct ssh *, Session *, const char *);
126#ifdef LOGIN_NEEDS_UTMPX
127static void do_pre_login(Session *s);
128#endif
129void do_motd(void); 126void do_motd(void);
130int check_quietlogin(Session *, const char *); 127int check_quietlogin(Session *, const char *);
131 128
@@ -656,35 +653,6 @@ do_exec_pty(struct ssh *ssh, Session *s, const char *command)
656 return 0; 653 return 0;
657} 654}
658 655
659#ifdef LOGIN_NEEDS_UTMPX
660static void
661do_pre_login(Session *s)
662{
663 struct ssh *ssh = active_state; /* XXX */
664 socklen_t fromlen;
665 struct sockaddr_storage from;
666 pid_t pid = getpid();
667
668 /*
669 * Get IP address of client. If the connection is not a socket, let
670 * the address be 0.0.0.0.
671 */
672 memset(&from, 0, sizeof(from));
673 fromlen = sizeof(from);
674 if (packet_connection_is_on_socket()) {
675 if (getpeername(packet_get_connection_in(),
676 (struct sockaddr *)&from, &fromlen) < 0) {
677 debug("getpeername: %.100s", strerror(errno));
678 cleanup_exit(255);
679 }
680 }
681
682 record_utmp_only(pid, s->tty, s->pw->pw_name,
683 session_get_remote_name_or_ip(ssh, utmp_len, options.use_dns),
684 (struct sockaddr *)&from, fromlen);
685}
686#endif
687
688/* 656/*
689 * This is called to fork and execute a command. If another command is 657 * This is called to fork and execute a command. If another command is
690 * to be forced, execute that instead. 658 * to be forced, execute that instead.
diff --git a/ssh-keyscan.c b/ssh-keyscan.c
index 38b1c548b..88449f672 100644
--- a/ssh-keyscan.c
+++ b/ssh-keyscan.c
@@ -83,8 +83,6 @@ fd_set *read_wait;
83size_t read_wait_nfdset; 83size_t read_wait_nfdset;
84int ncon; 84int ncon;
85 85
86struct ssh *active_state = NULL; /* XXX needed for linking */
87
88/* 86/*
89 * Keep a connection structure for each file descriptor. The state 87 * Keep a connection structure for each file descriptor. The state
90 * associated with file descriptor n is held in fdcon[n]. 88 * associated with file descriptor n is held in fdcon[n].
diff --git a/ssh-keysign.c b/ssh-keysign.c
index 7ea5ad0e9..601f6ca72 100644
--- a/ssh-keysign.c
+++ b/ssh-keysign.c
@@ -59,8 +59,6 @@
59#include "sshkey.h" 59#include "sshkey.h"
60#include "ssherr.h" 60#include "ssherr.h"
61 61
62struct ssh *active_state = NULL; /* XXX needed for linking */
63
64extern char *__progname; 62extern char *__progname;
65 63
66static int 64static int
diff --git a/sshd.c b/sshd.c
index 58d17e546..f6927672e 100644
--- a/sshd.c
+++ b/sshd.c
@@ -2080,7 +2080,7 @@ main(int ac, char **av)
2080 } 2080 }
2081 2081
2082#ifdef SSH_AUDIT_EVENTS 2082#ifdef SSH_AUDIT_EVENTS
2083 audit_event(SSH_AUTH_SUCCESS); 2083 audit_event(ssh, SSH_AUTH_SUCCESS);
2084#endif 2084#endif
2085 2085
2086#ifdef GSSAPI 2086#ifdef GSSAPI
@@ -2128,7 +2128,7 @@ main(int ac, char **av)
2128#endif /* USE_PAM */ 2128#endif /* USE_PAM */
2129 2129
2130#ifdef SSH_AUDIT_EVENTS 2130#ifdef SSH_AUDIT_EVENTS
2131 PRIVSEP(audit_event(SSH_CONNECTION_CLOSE)); 2131 PRIVSEP(audit_event(ssh, SSH_CONNECTION_CLOSE));
2132#endif 2132#endif
2133 2133
2134 ssh_packet_close(ssh); 2134 ssh_packet_close(ssh);
@@ -2256,8 +2256,8 @@ cleanup_exit(int i)
2256 } 2256 }
2257#ifdef SSH_AUDIT_EVENTS 2257#ifdef SSH_AUDIT_EVENTS
2258 /* done after do_cleanup so it can cancel the PAM auth 'thread' */ 2258 /* done after do_cleanup so it can cancel the PAM auth 'thread' */
2259 if (!use_privsep || mm_is_monitor()) 2259 if (the_active_state != NULL && (!use_privsep || mm_is_monitor()))
2260 audit_event(SSH_CONNECTION_ABANDON); 2260 audit_event(the_active_state, SSH_CONNECTION_ABANDON);
2261#endif 2261#endif
2262 _exit(i); 2262 _exit(i);
2263} 2263}