|
Jan F |
5c20fa |
diff -up openssh-5.6p1/audit-bsm.c.audit4 openssh-5.6p1/audit-bsm.c
|
|
Jan F |
92eab1 |
--- openssh-5.6p1/audit-bsm.c.audit4 2011-01-12 14:01:50.000000000 +0100
|
|
Jan F |
92eab1 |
+++ openssh-5.6p1/audit-bsm.c 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
5c20fa |
@@ -395,4 +395,10 @@ audit_kex_body(int ctos, char *enc, char
|
|
Jan F |
5c20fa |
{
|
|
Jan F |
5c20fa |
/* not implemented */
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
+void
|
|
Jan F |
5c20fa |
+audit_session_key_free_body(int ctos)
|
|
Jan F |
5c20fa |
+{
|
|
Jan F |
5c20fa |
+ /* not implemented */
|
|
Jan F |
5c20fa |
+}
|
|
Jan F |
5c20fa |
#endif /* BSM */
|
|
Jan F |
5c20fa |
diff -up openssh-5.6p1/audit.c.audit4 openssh-5.6p1/audit.c
|
|
Jan F |
92eab1 |
--- openssh-5.6p1/audit.c.audit4 2011-01-12 14:01:50.000000000 +0100
|
|
Jan F |
92eab1 |
+++ openssh-5.6p1/audit.c 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
5c20fa |
@@ -152,6 +152,12 @@ audit_kex(int ctos, char *enc, char *mac
|
|
Jan F |
5c20fa |
PRIVSEP(audit_kex_body(ctos, enc, mac, comp));
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
+void
|
|
Jan F |
5c20fa |
+audit_session_key_free(int ctos)
|
|
Jan F |
5c20fa |
+{
|
|
Jan F |
5c20fa |
+ PRIVSEP(audit_session_key_free_body(ctos));
|
|
Jan F |
5c20fa |
+}
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
# ifndef CUSTOM_SSH_AUDIT_EVENTS
|
|
Jan F |
5c20fa |
/*
|
|
Jan F |
5c20fa |
* Null implementations of audit functions.
|
|
Jan F |
5c20fa |
@@ -254,5 +260,13 @@ audit_kex_body(int ctos, char *enc, char
|
|
Jan F |
5c20fa |
debug("audit procol negotiation euid %d direction %d cipher %s mac %s compresion %s",
|
|
Jan F |
5c20fa |
geteuid(), ctos, enc, mac, compress);
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
+/*
|
|
Jan F |
5c20fa |
+ * This will be called on succesfull session key discard
|
|
Jan F |
5c20fa |
+ */
|
|
Jan F |
5c20fa |
+audit_session_key_free_body(int ctos)
|
|
Jan F |
5c20fa |
+{
|
|
Jan F |
5c20fa |
+ debug("audit session key discard euid %d direction %d", geteuid(), ctos);
|
|
Jan F |
5c20fa |
+}
|
|
Jan F |
5c20fa |
# endif /* !defined CUSTOM_SSH_AUDIT_EVENTS */
|
|
Jan F |
5c20fa |
#endif /* SSH_AUDIT_EVENTS */
|
|
Jan F |
5c20fa |
diff -up openssh-5.6p1/audit.h.audit4 openssh-5.6p1/audit.h
|
|
Jan F |
92eab1 |
--- openssh-5.6p1/audit.h.audit4 2011-01-12 14:01:50.000000000 +0100
|
|
Jan F |
92eab1 |
+++ openssh-5.6p1/audit.h 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
5c20fa |
@@ -60,5 +60,7 @@ void audit_unsupported(int);
|
|
Jan F |
5c20fa |
void audit_kex(int, char *, char *, char *);
|
|
Jan F |
5c20fa |
void audit_unsupported_body(int);
|
|
Jan F |
5c20fa |
void audit_kex_body(int, char *, char *, char *);
|
|
Jan F |
5c20fa |
+void audit_session_key_free(int ctos);
|
|
Jan F |
5c20fa |
+void audit_session_key_free_body(int ctos);
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
#endif /* _SSH_AUDIT_H */
|
|
Jan F |
5c20fa |
diff -up openssh-5.6p1/audit-linux.c.audit4 openssh-5.6p1/audit-linux.c
|
|
Jan F |
92eab1 |
--- openssh-5.6p1/audit-linux.c.audit4 2011-01-12 14:01:50.000000000 +0100
|
|
Jan F |
92eab1 |
+++ openssh-5.6p1/audit-linux.c 2011-01-12 14:04:15.000000000 +0100
|
|
Jan F |
5c20fa |
@@ -174,13 +174,14 @@ audit_unsupported_body(int what)
|
|
Jan F |
5c20fa |
#endif
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
+const static char *direction[] = { "from-server", "from-client", "both" };
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
void
|
|
Jan F |
5c20fa |
audit_kex_body(int ctos, char *enc, char *mac, char *compress)
|
|
Jan F |
5c20fa |
{
|
|
Jan F |
5c20fa |
#ifdef AUDIT_CRYPTO_SESSION
|
|
Jan F |
5c20fa |
char buf[AUDIT_LOG_SIZE];
|
|
Jan F |
5c20fa |
int audit_fd, audit_ok;
|
|
Jan F |
5c20fa |
- const static char *direction[] = { "from-server", "from-client", "both" };
|
|
Jan F |
5c20fa |
Cipher *cipher = cipher_by_name(enc);
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
snprintf(buf, sizeof(buf), "start direction=%s cipher=%s, ksize=%d rport=%d laddr=%s lport=%d",
|
|
Jan F |
92eab1 |
@@ -203,4 +204,26 @@ audit_kex_body(int ctos, char *enc, char
|
|
Jan F |
5c20fa |
#endif
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
+void
|
|
Jan F |
5c20fa |
+audit_session_key_free_body(int ctos)
|
|
Jan F |
5c20fa |
+{
|
|
Jan F |
5c20fa |
+ char buf[AUDIT_LOG_SIZE];
|
|
Jan F |
5c20fa |
+ int audit_fd, audit_ok;
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
+ snprintf(buf, sizeof(buf), "destroy kind=session direction=%s", direction[ctos]);
|
|
Jan F |
5c20fa |
+ audit_fd = audit_open();
|
|
Jan F |
92eab1 |
+ if (audit_fd < 0) {
|
|
Jan F |
92eab1 |
+ if (errno != EINVAL && errno != EPROTONOSUPPORT &&
|
|
Jan F |
92eab1 |
+ errno != EAFNOSUPPORT)
|
|
Jan F |
92eab1 |
+ error("cannot open audit");
|
|
Jan F |
5c20fa |
+ return;
|
|
Jan F |
92eab1 |
+ }
|
|
Jan F |
5c20fa |
+ audit_ok = audit_log_acct_message(audit_fd, AUDIT_CRYPTO_KEY_USER, NULL,
|
|
Jan F |
5c20fa |
+ buf, NULL, -1, NULL, get_remote_ipaddr(), NULL, 1);
|
|
Jan F |
5c20fa |
+ audit_close(audit_fd);
|
|
Jan F |
5c20fa |
+ /* do not abort if the error is EPERM and sshd is run as non root user */
|
|
Jan F |
5c20fa |
+ if ((audit_ok < 0) && ((audit_ok != -1) || (getuid() == 0)))
|
|
Jan F |
5c20fa |
+ error("cannot write into audit");
|
|
Jan F |
5c20fa |
+}
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
#endif /* USE_LINUX_AUDIT */
|
|
Jan F |
5c20fa |
diff -up openssh-5.6p1/auditstub.c.audit4 openssh-5.6p1/auditstub.c
|
|
Jan F |
92eab1 |
--- openssh-5.6p1/auditstub.c.audit4 2011-01-12 14:01:50.000000000 +0100
|
|
Jan F |
92eab1 |
+++ openssh-5.6p1/auditstub.c 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
5c20fa |
@@ -37,3 +37,7 @@ audit_kex(int ctos, char *enc, char *mac
|
|
Jan F |
5c20fa |
{
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
+void
|
|
Jan F |
5c20fa |
+audit_session_key_free(int ctos)
|
|
Jan F |
5c20fa |
+{
|
|
Jan F |
5c20fa |
+}
|
|
Jan F |
5c20fa |
diff -up openssh-5.6p1/monitor.c.audit4 openssh-5.6p1/monitor.c
|
|
Jan F |
92eab1 |
--- openssh-5.6p1/monitor.c.audit4 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
92eab1 |
+++ openssh-5.6p1/monitor.c 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
5c20fa |
@@ -180,6 +180,7 @@ int mm_answer_audit_event(int, Buffer *)
|
|
Jan F |
5c20fa |
int mm_answer_audit_command(int, Buffer *);
|
|
Jan F |
5c20fa |
int mm_answer_audit_unsupported_body(int, Buffer *);
|
|
Jan F |
5c20fa |
int mm_answer_audit_kex_body(int, Buffer *);
|
|
Jan F |
5c20fa |
+int mm_answer_audit_session_key_free_body(int, Buffer *);
|
|
Jan F |
5c20fa |
#endif
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
static Authctxt *authctxt;
|
|
Jan F |
5c20fa |
@@ -230,6 +231,7 @@ struct mon_table mon_dispatch_proto20[]
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event},
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F |
5c20fa |
+ {MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F |
5c20fa |
#endif
|
|
Jan F |
5c20fa |
#ifdef BSD_AUTH
|
|
Jan F |
5c20fa |
{MONITOR_REQ_BSDAUTHQUERY, MON_ISAUTH, mm_answer_bsdauthquery},
|
|
Jan F |
5c20fa |
@@ -268,6 +270,7 @@ struct mon_table mon_dispatch_postauth20
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT, mm_answer_audit_command},
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F |
5c20fa |
+ {MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F |
5c20fa |
#endif
|
|
Jan F |
5c20fa |
{0, 0, NULL}
|
|
Jan F |
5c20fa |
};
|
|
Jan F |
5c20fa |
@@ -301,6 +304,7 @@ struct mon_table mon_dispatch_proto15[]
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event},
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F |
5c20fa |
+ {MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F |
5c20fa |
#endif
|
|
Jan F |
5c20fa |
{0, 0, NULL}
|
|
Jan F |
5c20fa |
};
|
|
Jan F |
5c20fa |
@@ -314,6 +318,7 @@ struct mon_table mon_dispatch_postauth15
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_COMMAND, MON_PERMIT|MON_ONCE, mm_answer_audit_command},
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F |
5c20fa |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F |
5c20fa |
+ {MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F |
5c20fa |
#endif
|
|
Jan F |
5c20fa |
{0, 0, NULL}
|
|
Jan F |
5c20fa |
};
|
|
Jan F |
5c20fa |
@@ -2252,4 +2257,18 @@ mm_answer_audit_kex_body(int sock, Buffe
|
|
Jan F |
5c20fa |
return 0;
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
+int
|
|
Jan F |
5c20fa |
+mm_answer_audit_session_key_free_body(int sock, Buffer *m)
|
|
Jan F |
5c20fa |
+{
|
|
Jan F |
5c20fa |
+ int ctos;
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
+ ctos = buffer_get_int(m);
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
+ audit_session_key_free_body(ctos);
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
+ buffer_clear(m);
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
+ mm_request_send(sock, MONITOR_ANS_AUDIT_SESSION_KEY_FREE, m);
|
|
Jan F |
5c20fa |
+ return 0;
|
|
Jan F |
5c20fa |
+}
|
|
Jan F |
5c20fa |
#endif /* SSH_AUDIT_EVENTS */
|
|
Jan F |
5c20fa |
diff -up openssh-5.6p1/monitor.h.audit4 openssh-5.6p1/monitor.h
|
|
Jan F |
92eab1 |
--- openssh-5.6p1/monitor.h.audit4 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
92eab1 |
+++ openssh-5.6p1/monitor.h 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
5c20fa |
@@ -68,6 +68,7 @@ enum monitor_reqtype {
|
|
Jan F |
5c20fa |
MONITOR_REQ_JPAKE_CHECK_CONFIRM, MONITOR_ANS_JPAKE_CHECK_CONFIRM,
|
|
Jan F |
5c20fa |
MONITOR_REQ_AUDIT_UNSUPPORTED, MONITOR_ANS_AUDIT_UNSUPPORTED,
|
|
Jan F |
5c20fa |
MONITOR_REQ_AUDIT_KEX, MONITOR_ANS_AUDIT_KEX,
|
|
Jan F |
5c20fa |
+ MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MONITOR_ANS_AUDIT_SESSION_KEY_FREE,
|
|
Jan F |
5c20fa |
};
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
struct mm_master;
|
|
Jan F |
5c20fa |
diff -up openssh-5.6p1/monitor_wrap.c.audit4 openssh-5.6p1/monitor_wrap.c
|
|
Jan F |
92eab1 |
--- openssh-5.6p1/monitor_wrap.c.audit4 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
92eab1 |
+++ openssh-5.6p1/monitor_wrap.c 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
5c20fa |
@@ -1445,4 +1445,17 @@ mm_audit_kex_body(int ctos, char *cipher
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
buffer_free(&m);
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
+void
|
|
Jan F |
5c20fa |
+mm_audit_session_key_free_body(int ctos)
|
|
Jan F |
5c20fa |
+{
|
|
Jan F |
5c20fa |
+ Buffer m;
|
|
Jan F |
5c20fa |
+
|
|
Jan F |
5c20fa |
+ buffer_init(&m);
|
|
Jan F |
5c20fa |
+ buffer_put_int(&m, ctos);
|
|
Jan F |
5c20fa |
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_SESSION_KEY_FREE, &m);
|
|
Jan F |
5c20fa |
+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUDIT_SESSION_KEY_FREE,
|
|
Jan F |
5c20fa |
+ &m);
|
|
Jan F |
5c20fa |
+ buffer_free(&m);
|
|
Jan F |
5c20fa |
+}
|
|
Jan F |
5c20fa |
#endif /* SSH_AUDIT_EVENTS */
|
|
Jan F |
5c20fa |
diff -up openssh-5.6p1/monitor_wrap.h.audit4 openssh-5.6p1/monitor_wrap.h
|
|
Jan F |
92eab1 |
--- openssh-5.6p1/monitor_wrap.h.audit4 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
92eab1 |
+++ openssh-5.6p1/monitor_wrap.h 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
5c20fa |
@@ -76,6 +76,7 @@ void mm_audit_event(ssh_audit_event_t);
|
|
Jan F |
5c20fa |
void mm_audit_run_command(const char *);
|
|
Jan F |
5c20fa |
void mm_audit_unsupported_body(int);
|
|
Jan F |
5c20fa |
void mm_audit_kex_body(int, char *, char *, char *);
|
|
Jan F |
5c20fa |
+void mm_audit_session_key_free_body(int);
|
|
Jan F |
5c20fa |
#endif
|
|
Jan F |
5c20fa |
|
|
Jan F |
5c20fa |
struct Session;
|
|
Jan F |
5c20fa |
diff -up openssh-5.6p1/packet.c.audit4 openssh-5.6p1/packet.c
|
|
Jan F |
5c20fa |
--- openssh-5.6p1/packet.c.audit4 2010-07-16 05:58:37.000000000 +0200
|
|
Jan F |
92eab1 |
+++ openssh-5.6p1/packet.c 2011-01-12 14:01:51.000000000 +0100
|
|
Jan F |
5c20fa |
@@ -495,6 +495,7 @@ packet_close(void)
|
|
Jan F |
5c20fa |
buffer_free(&active_state->compression_buffer);
|
|
Jan F |
5c20fa |
buffer_compress_uninit();
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
+ audit_session_key_free(2);
|
|
Jan F |
5c20fa |
cipher_cleanup(&active_state->send_context);
|
|
Jan F |
5c20fa |
cipher_cleanup(&active_state->receive_context);
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
@@ -749,6 +750,7 @@ set_newkeys(int mode)
|
|
Jan F |
5c20fa |
}
|
|
Jan F |
5c20fa |
if (active_state->newkeys[mode] != NULL) {
|
|
Jan F |
5c20fa |
debug("set_newkeys: rekeying");
|
|
Jan F |
5c20fa |
+ audit_session_key_free(mode);
|
|
Jan F |
5c20fa |
cipher_cleanup(cc);
|
|
Jan F |
5c20fa |
enc = &active_state->newkeys[mode]->enc;
|
|
Jan F |
5c20fa |
mac = &active_state->newkeys[mode]->mac;
|