|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/audit-bsm.c.audit4 openssh-6.0p1/audit-bsm.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/audit-bsm.c.audit4 2012-08-06 20:35:56.306789054 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/audit-bsm.c 2012-08-06 20:35:56.314789022 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -485,4 +485,10 @@ audit_kex_body(int ctos, char *enc, char
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
/* not implemented */
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+audit_session_key_free_body(int ctos, pid_t pid, uid_t uid)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ /* not implemented */
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
#endif /* BSM */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/audit.c.audit4 openssh-6.0p1/audit.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/audit.c.audit4 2012-08-06 20:35:56.307789050 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/audit.c 2012-08-06 20:35:56.315789018 +0200
|
|
Petr Lautrbach |
d9e618 |
@@ -143,6 +143,12 @@ audit_kex(int ctos, char *enc, char *mac
|
|
Petr Lautrbach |
d9e618 |
PRIVSEP(audit_kex_body(ctos, enc, mac, comp, getpid(), getuid()));
|
|
Petr Lautrbach |
d9e618 |
}
|
|
Petr Lautrbach |
d9e618 |
|
|
Petr Lautrbach |
d9e618 |
+void
|
|
Petr Lautrbach |
d9e618 |
+audit_session_key_free(int ctos)
|
|
Petr Lautrbach |
d9e618 |
+{
|
|
Petr Lautrbach |
d9e618 |
+ PRIVSEP(audit_session_key_free_body(ctos, getpid(), getuid()));
|
|
Petr Lautrbach |
d9e618 |
+}
|
|
Petr Lautrbach |
d9e618 |
+
|
|
Petr Lautrbach |
d9e618 |
# ifndef CUSTOM_SSH_AUDIT_EVENTS
|
|
Petr Lautrbach |
d9e618 |
/*
|
|
Petr Lautrbach |
d9e618 |
* Null implementations of audit functions.
|
|
Petr Lautrbach |
d9e618 |
@@ -274,5 +280,15 @@ audit_kex_body(int ctos, char *enc, char
|
|
Petr Lautrbach |
d9e618 |
(unsigned)geteuid(), ctos, enc, mac, compress, (long)pid,
|
|
Petr Lautrbach |
d9e618 |
(unsigned)uid);
|
|
Petr Lautrbach |
d9e618 |
}
|
|
Petr Lautrbach |
d9e618 |
+
|
|
Petr Lautrbach |
d9e618 |
+/*
|
|
Petr Lautrbach |
d9e618 |
+ * This will be called on succesfull session key discard
|
|
Petr Lautrbach |
d9e618 |
+ */
|
|
Petr Lautrbach |
d9e618 |
+void
|
|
Petr Lautrbach |
d9e618 |
+audit_session_key_free_body(int ctos, pid_t pid, uid_t uid)
|
|
Petr Lautrbach |
d9e618 |
+{
|
|
Petr Lautrbach |
d9e618 |
+ debug("audit session key discard euid %u direction %d from pid %ld uid %u",
|
|
Petr Lautrbach |
d9e618 |
+ (unsigned)geteuid(), ctos, (long)pid, (unsigned)uid);
|
|
Petr Lautrbach |
d9e618 |
+}
|
|
Petr Lautrbach |
d9e618 |
# endif /* !defined CUSTOM_SSH_AUDIT_EVENTS */
|
|
Petr Lautrbach |
d9e618 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/audit.h.audit4 openssh-6.0p1/audit.h
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/audit.h.audit4 2012-08-06 20:35:56.308789046 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/audit.h 2012-08-06 20:35:56.315789018 +0200
|
|
Petr Lautrbach |
d9e618 |
@@ -62,5 +62,7 @@ void audit_unsupported(int);
|
|
Petr Lautrbach |
d9e618 |
void audit_kex(int, char *, char *, char *);
|
|
Petr Lautrbach |
d9e618 |
void audit_unsupported_body(int);
|
|
Petr Lautrbach |
d9e618 |
void audit_kex_body(int, char *, char *, char *, pid_t, uid_t);
|
|
Petr Lautrbach |
d9e618 |
+void audit_session_key_free(int ctos);
|
|
Petr Lautrbach |
d9e618 |
+void audit_session_key_free_body(int ctos, pid_t, uid_t);
|
|
Petr Lautrbach |
d9e618 |
|
|
Petr Lautrbach |
d9e618 |
#endif /* _SSH_AUDIT_H */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/audit-linux.c.audit4 openssh-6.0p1/audit-linux.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/audit-linux.c.audit4 2012-08-06 20:35:56.307789050 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/audit-linux.c 2012-08-06 20:35:56.315789018 +0200
|
|
Jan F. Chadima |
cff1d0 |
@@ -294,6 +294,8 @@ audit_unsupported_body(int what)
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+const static char *direction[] = { "from-server", "from-client", "both" };
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
void
|
|
Jan F. Chadima |
69dd72 |
audit_kex_body(int ctos, char *enc, char *mac, char *compress, pid_t pid,
|
|
Jan F. Chadima |
69dd72 |
uid_t uid)
|
|
Jan F. Chadima |
cff1d0 |
@@ -301,7 +303,6 @@ audit_kex_body(int ctos, char *enc, char
|
|
Jan F. Chadima |
69dd72 |
#ifdef AUDIT_CRYPTO_SESSION
|
|
Jan F. Chadima |
69dd72 |
char buf[AUDIT_LOG_SIZE];
|
|
Jan F. Chadima |
69dd72 |
int audit_fd, audit_ok;
|
|
Jan F. Chadima |
69dd72 |
- const static char *direction[] = { "from-server", "from-client", "both" };
|
|
Jan F. Chadima |
69dd72 |
Cipher *cipher = cipher_by_name(enc);
|
|
Jan F. Chadima |
cff1d0 |
char *s;
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
cff1d0 |
@@ -327,4 +328,32 @@ audit_kex_body(int ctos, char *enc, char
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+audit_session_key_free_body(int ctos, pid_t pid, uid_t uid)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ char buf[AUDIT_LOG_SIZE];
|
|
Jan F. Chadima |
69dd72 |
+ int audit_fd, audit_ok;
|
|
Jan F. Chadima |
cff1d0 |
+ char *s;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ snprintf(buf, sizeof(buf), "op=destroy kind=session fp=? direction=%s spid=%jd suid=%jd rport=%d laddr=%s lport=%d ",
|
|
Jan F. Chadima |
69dd72 |
+ direction[ctos], (intmax_t)pid, (intmax_t)uid,
|
|
Jan F. Chadima |
69dd72 |
+ get_remote_port(),
|
|
Jan F. Chadima |
cff1d0 |
+ (s = get_local_ipaddr(packet_get_connection_in())),
|
|
Jan F. Chadima |
69dd72 |
+ get_local_port());
|
|
Jan F. Chadima |
cff1d0 |
+ xfree(s);
|
|
Jan F. Chadima |
69dd72 |
+ audit_fd = audit_open();
|
|
Jan F. Chadima |
69dd72 |
+ if (audit_fd < 0) {
|
|
Jan F. Chadima |
69dd72 |
+ if (errno != EINVAL && errno != EPROTONOSUPPORT &&
|
|
Jan F. Chadima |
69dd72 |
+ errno != EAFNOSUPPORT)
|
|
Jan F. Chadima |
69dd72 |
+ error("cannot open audit");
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+ audit_ok = audit_log_user_message(audit_fd, AUDIT_CRYPTO_KEY_USER,
|
|
Jan F. Chadima |
69dd72 |
+ buf, NULL, get_remote_ipaddr(), NULL, 1);
|
|
Jan F. Chadima |
69dd72 |
+ audit_close(audit_fd);
|
|
Jan F. Chadima |
69dd72 |
+ /* do not abort if the error is EPERM and sshd is run as non root user */
|
|
Jan F. Chadima |
69dd72 |
+ if ((audit_ok < 0) && ((audit_ok != -1) || (getuid() == 0)))
|
|
Jan F. Chadima |
69dd72 |
+ error("cannot write into audit");
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
#endif /* USE_LINUX_AUDIT */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/auditstub.c.audit4 openssh-6.0p1/auditstub.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/auditstub.c.audit4 2012-08-06 20:35:56.308789046 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/auditstub.c 2012-08-06 20:35:56.316789015 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -27,6 +27,8 @@
|
|
Jan F. Chadima |
69dd72 |
* Red Hat author: Jan F. Chadima <jchadima@redhat.com>
|
|
Jan F. Chadima |
69dd72 |
*/
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+#include <sys/types.h>
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
void
|
|
Jan F. Chadima |
69dd72 |
audit_unsupported(int n)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
@@ -37,3 +39,12 @@ audit_kex(int ctos, char *enc, char *mac
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+audit_session_key_free(int ctos)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+audit_session_key_free_body(int ctos, pid_t pid, uid_t uid)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/kex.c.audit4 openssh-6.0p1/kex.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/kex.c.audit4 2012-08-06 20:35:56.309789042 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/kex.c 2012-08-06 20:35:56.317789011 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -624,3 +624,34 @@ dump_digest(char *msg, u_char *digest, i
|
|
Jan F. Chadima |
69dd72 |
fprintf(stderr, "\n");
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+static void
|
|
Jan F. Chadima |
69dd72 |
+enc_destroy(Enc *enc)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ if (enc == NULL)
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (enc->key) {
|
|
Jan F. Chadima |
69dd72 |
+ memset(enc->key, 0, enc->key_len);
|
|
Jan F. Chadima |
69dd72 |
+ xfree(enc->key);
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (enc->iv) {
|
|
Jan F. Chadima |
69dd72 |
+ memset(enc->iv, 0, enc->block_size);
|
|
Jan F. Chadima |
69dd72 |
+ xfree(enc->iv);
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ memset(enc, 0, sizeof(*enc));
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+newkeys_destroy(Newkeys *newkeys)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ if (newkeys == NULL)
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ enc_destroy(&newkeys->enc);
|
|
Jan F. Chadima |
69dd72 |
+ mac_destroy(&newkeys->mac);
|
|
Jan F. Chadima |
69dd72 |
+ memset(&newkeys->comp, 0, sizeof(newkeys->comp));
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/kex.h.audit4 openssh-6.0p1/kex.h
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/kex.h.audit4 2010-09-24 14:11:14.000000000 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/kex.h 2012-08-06 20:35:56.317789011 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -156,6 +156,8 @@ void kexgex_server(Kex *);
|
|
Jan F. Chadima |
69dd72 |
void kexecdh_client(Kex *);
|
|
Jan F. Chadima |
69dd72 |
void kexecdh_server(Kex *);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+void newkeys_destroy(Newkeys *newkeys);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
void
|
|
Jan F. Chadima |
69dd72 |
kex_dh_hash(char *, char *, char *, int, char *, int, u_char *, int,
|
|
Jan F. Chadima |
69dd72 |
BIGNUM *, BIGNUM *, BIGNUM *, u_char **, u_int *);
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/mac.c.audit4 openssh-6.0p1/mac.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/mac.c.audit4 2012-01-17 04:03:38.000000000 +0100
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/mac.c 2012-08-06 20:35:56.318789007 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -171,6 +171,20 @@ mac_clear(Mac *mac)
|
|
Jan F. Chadima |
69dd72 |
mac->umac_ctx = NULL;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+mac_destroy(Mac *mac)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ if (mac == NULL)
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ if (mac->key) {
|
|
Jan F. Chadima |
69dd72 |
+ memset(mac->key, 0, mac->key_len);
|
|
Jan F. Chadima |
69dd72 |
+ xfree(mac->key);
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ memset(mac, 0, sizeof(*mac));
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
/* XXX copied from ciphers_valid */
|
|
Jan F. Chadima |
69dd72 |
#define MAC_SEP ","
|
|
Jan F. Chadima |
69dd72 |
int
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/mac.h.audit4 openssh-6.0p1/mac.h
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/mac.h.audit4 2007-06-11 06:01:42.000000000 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/mac.h 2012-08-06 20:35:56.318789007 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -28,3 +28,4 @@ int mac_setup(Mac *, char *);
|
|
Jan F. Chadima |
69dd72 |
int mac_init(Mac *);
|
|
Jan F. Chadima |
69dd72 |
u_char *mac_compute(Mac *, u_int32_t, u_char *, int);
|
|
Jan F. Chadima |
69dd72 |
void mac_clear(Mac *);
|
|
Jan F. Chadima |
69dd72 |
+void mac_destroy(Mac *);
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/monitor.c.audit4 openssh-6.0p1/monitor.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/monitor.c.audit4 2012-08-06 20:35:56.310789038 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/monitor.c 2012-08-06 20:35:56.319789003 +0200
|
|
Petr Lautrbach |
420ff0 |
@@ -189,6 +189,7 @@ int mm_answer_audit_command(int, Buffer
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_audit_end_command(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_audit_unsupported_body(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
int mm_answer_audit_kex_body(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
+int mm_answer_audit_session_key_free_body(int, Buffer *);
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
static int monitor_read_log(struct monitor *);
|
|
Petr Lautrbach |
420ff0 |
@@ -242,6 +243,7 @@ struct mon_table mon_dispatch_proto20[]
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F. Chadima |
69dd72 |
+ {MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
#ifdef BSD_AUTH
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_BSDAUTHQUERY, MON_ISAUTH, mm_answer_bsdauthquery},
|
|
Petr Lautrbach |
d9e618 |
@@ -281,6 +283,7 @@ struct mon_table mon_dispatch_postauth20
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_END_COMMAND, MON_PERMIT, mm_answer_audit_end_command},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F. Chadima |
69dd72 |
+ {MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
{0, 0, NULL}
|
|
Jan F. Chadima |
69dd72 |
};
|
|
Petr Lautrbach |
420ff0 |
@@ -314,6 +317,7 @@ struct mon_table mon_dispatch_proto15[]
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_EVENT, MON_PERMIT, mm_answer_audit_event},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F. Chadima |
69dd72 |
+ {MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
{0, 0, NULL}
|
|
Jan F. Chadima |
69dd72 |
};
|
|
Petr Lautrbach |
d9e618 |
@@ -328,6 +332,7 @@ struct mon_table mon_dispatch_postauth15
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_END_COMMAND, MON_PERMIT, mm_answer_audit_end_command},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_UNSUPPORTED, MON_PERMIT, mm_answer_audit_unsupported_body},
|
|
Jan F. Chadima |
69dd72 |
{MONITOR_REQ_AUDIT_KEX, MON_PERMIT, mm_answer_audit_kex_body},
|
|
Jan F. Chadima |
69dd72 |
+ {MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MON_PERMIT, mm_answer_audit_session_key_free_body},
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
{0, 0, NULL}
|
|
Jan F. Chadima |
69dd72 |
};
|
|
Petr Lautrbach |
420ff0 |
@@ -449,10 +454,6 @@ monitor_child_preauth(Authctxt *_authctx
|
|
Petr Lautrbach |
420ff0 |
authenticated = 0;
|
|
JFCH |
c2ea13 |
}
|
|
JFCH |
c2ea13 |
|
|
JFCH |
c2ea13 |
- /* Drain any buffered messages from the child */
|
|
Jan F. Chadima |
cff1d0 |
- while (pmonitor->m_log_recvfd >= 0 && monitor_read_log(pmonitor) == 0)
|
|
JFCH |
c2ea13 |
- ;
|
|
JFCH |
c2ea13 |
-
|
|
JFCH |
c2ea13 |
if (!authctxt->valid)
|
|
JFCH |
c2ea13 |
fatal("%s: authenticated invalid user", __func__);
|
|
JFCH |
c2ea13 |
if (strcmp(auth_method, "unknown") == 0)
|
|
Petr Lautrbach |
65ba94 |
@@ -1953,11 +1954,13 @@ mm_get_keystate(struct monitor *pmonitor
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
blob = buffer_get_string(&m, &bloblen);
|
|
Jan F. Chadima |
69dd72 |
current_keys[MODE_OUT] = mm_newkeys_from_blob(blob, bloblen);
|
|
Jan F. Chadima |
69dd72 |
+ memset(blob, 0, bloblen);
|
|
Jan F. Chadima |
69dd72 |
xfree(blob);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
debug3("%s: Waiting for second key", __func__);
|
|
Jan F. Chadima |
69dd72 |
blob = buffer_get_string(&m, &bloblen);
|
|
Jan F. Chadima |
69dd72 |
current_keys[MODE_IN] = mm_newkeys_from_blob(blob, bloblen);
|
|
Jan F. Chadima |
69dd72 |
+ memset(blob, 0, bloblen);
|
|
Jan F. Chadima |
69dd72 |
xfree(blob);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* Now get sequence numbers for the packets */
|
|
Petr Lautrbach |
65ba94 |
@@ -2003,6 +2006,21 @@ mm_get_keystate(struct monitor *pmonitor
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
buffer_free(&m);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+#ifdef SSH_AUDIT_EVENTS
|
|
Jan F. Chadima |
69dd72 |
+ if (compat20) {
|
|
Jan F. Chadima |
69dd72 |
+ buffer_init(&m);
|
|
Jan F. Chadima |
69dd72 |
+ mm_request_receive_expect(pmonitor->m_sendfd,
|
|
Jan F. Chadima |
69dd72 |
+ MONITOR_REQ_AUDIT_SESSION_KEY_FREE, &m);
|
|
Jan F. Chadima |
69dd72 |
+ mm_answer_audit_session_key_free_body(pmonitor->m_sendfd, &m);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_free(&m);
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
JFCH |
c2ea13 |
+
|
|
JFCH |
c2ea13 |
+ /* Drain any buffered messages from the child */
|
|
Jan F. Chadima |
cff1d0 |
+ while (pmonitor->m_log_recvfd >= 0 && monitor_read_log(pmonitor) == 0)
|
|
JFCH |
c2ea13 |
+ ;
|
|
JFCH |
c2ea13 |
+
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
65ba94 |
@@ -2449,4 +2467,22 @@ mm_answer_audit_kex_body(int sock, Buffe
|
|
Jan F. Chadima |
69dd72 |
return 0;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+int
|
|
Jan F. Chadima |
69dd72 |
+mm_answer_audit_session_key_free_body(int sock, Buffer *m)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ int ctos;
|
|
Jan F. Chadima |
69dd72 |
+ pid_t pid;
|
|
Jan F. Chadima |
69dd72 |
+ uid_t uid;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ ctos = buffer_get_int(m);
|
|
Jan F. Chadima |
69dd72 |
+ pid = buffer_get_int64(m);
|
|
Jan F. Chadima |
69dd72 |
+ uid = buffer_get_int64(m);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ audit_session_key_free_body(ctos, pid, uid);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ buffer_clear(m);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ mm_request_send(sock, MONITOR_ANS_AUDIT_SESSION_KEY_FREE, m);
|
|
Jan F. Chadima |
69dd72 |
+ return 0;
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/monitor.h.audit4 openssh-6.0p1/monitor.h
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/monitor.h.audit4 2012-08-06 20:35:56.310789038 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/monitor.h 2012-08-06 20:35:56.319789003 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -63,6 +63,7 @@ enum monitor_reqtype {
|
|
Jan F. Chadima |
69dd72 |
MONITOR_ANS_AUDIT_COMMAND, MONITOR_REQ_AUDIT_END_COMMAND,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_AUDIT_UNSUPPORTED, MONITOR_ANS_AUDIT_UNSUPPORTED,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_AUDIT_KEX, MONITOR_ANS_AUDIT_KEX,
|
|
Jan F. Chadima |
69dd72 |
+ MONITOR_REQ_AUDIT_SESSION_KEY_FREE, MONITOR_ANS_AUDIT_SESSION_KEY_FREE,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_TERM,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_JPAKE_STEP1, MONITOR_ANS_JPAKE_STEP1,
|
|
Jan F. Chadima |
69dd72 |
MONITOR_REQ_JPAKE_GET_PWDATA, MONITOR_ANS_JPAKE_GET_PWDATA,
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/monitor_wrap.c.audit4 openssh-6.0p1/monitor_wrap.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/monitor_wrap.c.audit4 2012-08-06 20:35:56.311789034 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/monitor_wrap.c 2012-08-06 20:35:56.320788999 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -653,12 +653,14 @@ mm_send_keystate(struct monitor *monitor
|
|
Jan F. Chadima |
69dd72 |
fatal("%s: conversion of newkeys failed", __func__);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
buffer_put_string(&m, blob, bloblen);
|
|
Jan F. Chadima |
69dd72 |
+ memset(blob, 0, bloblen);
|
|
Jan F. Chadima |
69dd72 |
xfree(blob);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
if (!mm_newkeys_to_blob(MODE_IN, &blob, &bloblen))
|
|
Jan F. Chadima |
69dd72 |
fatal("%s: conversion of newkeys failed", __func__);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
buffer_put_string(&m, blob, bloblen);
|
|
Jan F. Chadima |
69dd72 |
+ memset(blob, 0, bloblen);
|
|
Jan F. Chadima |
69dd72 |
xfree(blob);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
packet_get_state(MODE_OUT, &seqnr, &blocks, &packets, &bytes);
|
|
Jan F. Chadima |
28b0dc |
@@ -1522,4 +1524,19 @@ mm_audit_kex_body(int ctos, char *cipher
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
buffer_free(&m);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+mm_audit_session_key_free_body(int ctos, pid_t pid, uid_t uid)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ Buffer m;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ buffer_init(&m);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_int(&m, ctos);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_int64(&m, pid);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_put_int64(&m, uid);
|
|
Jan F. Chadima |
69dd72 |
+ mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUDIT_SESSION_KEY_FREE, &m);
|
|
Jan F. Chadima |
69dd72 |
+ mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_AUDIT_SESSION_KEY_FREE,
|
|
Jan F. Chadima |
69dd72 |
+ &m);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_free(&m);
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
#endif /* SSH_AUDIT_EVENTS */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/monitor_wrap.h.audit4 openssh-6.0p1/monitor_wrap.h
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/monitor_wrap.h.audit4 2012-08-06 20:35:56.311789034 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/monitor_wrap.h 2012-08-06 20:35:56.320788999 +0200
|
|
Jan F. Chadima |
28b0dc |
@@ -79,6 +79,7 @@ int mm_audit_run_command(const char *);
|
|
Jan F. Chadima |
69dd72 |
void mm_audit_end_command(int, const char *);
|
|
Jan F. Chadima |
69dd72 |
void mm_audit_unsupported_body(int);
|
|
Jan F. Chadima |
69dd72 |
void mm_audit_kex_body(int, char *, char *, char *, pid_t, uid_t);
|
|
Jan F. Chadima |
69dd72 |
+void mm_audit_session_key_free_body(int, pid_t, uid_t);
|
|
Jan F. Chadima |
69dd72 |
#endif
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
struct Session;
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/packet.c.audit4 openssh-6.0p1/packet.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/packet.c.audit4 2012-08-06 20:35:56.282789147 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/packet.c 2012-08-06 20:35:56.321788995 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -60,6 +60,7 @@
|
|
Jan F. Chadima |
69dd72 |
#include <signal.h>
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
#include "xmalloc.h"
|
|
Jan F. Chadima |
69dd72 |
+#include "audit.h"
|
|
Jan F. Chadima |
69dd72 |
#include "buffer.h"
|
|
Jan F. Chadima |
69dd72 |
#include "packet.h"
|
|
Jan F. Chadima |
69dd72 |
#include "crc32.h"
|
|
Petr Lautrbach |
65ba94 |
@@ -470,6 +471,13 @@ packet_get_connection_out(void)
|
|
Jan F. Chadima |
69dd72 |
return active_state->connection_out;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+static int
|
|
Jan F. Chadima |
69dd72 |
+packet_state_has_keys (const struct session_state *state)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ return state != NULL &&
|
|
Jan F. Chadima |
69dd72 |
+ (state->newkeys[MODE_IN] != NULL || state->newkeys[MODE_OUT] != NULL);
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
/* Closes the connection and clears and frees internal data structures. */
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
void
|
|
Petr Lautrbach |
65ba94 |
@@ -478,13 +486,6 @@ packet_close(void)
|
|
Jan F. Chadima |
69dd72 |
if (!active_state->initialized)
|
|
Jan F. Chadima |
69dd72 |
return;
|
|
Jan F. Chadima |
69dd72 |
active_state->initialized = 0;
|
|
Jan F. Chadima |
69dd72 |
- if (active_state->connection_in == active_state->connection_out) {
|
|
Jan F. Chadima |
69dd72 |
- shutdown(active_state->connection_out, SHUT_RDWR);
|
|
Jan F. Chadima |
69dd72 |
- close(active_state->connection_out);
|
|
Jan F. Chadima |
69dd72 |
- } else {
|
|
Jan F. Chadima |
69dd72 |
- close(active_state->connection_in);
|
|
Jan F. Chadima |
69dd72 |
- close(active_state->connection_out);
|
|
Jan F. Chadima |
69dd72 |
- }
|
|
Jan F. Chadima |
69dd72 |
buffer_free(&active_state->input);
|
|
Jan F. Chadima |
69dd72 |
buffer_free(&active_state->output);
|
|
Jan F. Chadima |
69dd72 |
buffer_free(&active_state->outgoing_packet);
|
|
Petr Lautrbach |
65ba94 |
@@ -493,8 +494,18 @@ packet_close(void)
|
|
Jan F. Chadima |
69dd72 |
buffer_free(&active_state->compression_buffer);
|
|
Jan F. Chadima |
69dd72 |
buffer_compress_uninit();
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
- cipher_cleanup(&active_state->send_context);
|
|
Jan F. Chadima |
69dd72 |
- cipher_cleanup(&active_state->receive_context);
|
|
Jan F. Chadima |
69dd72 |
+ if (packet_state_has_keys(active_state)) {
|
|
Jan F. Chadima |
69dd72 |
+ cipher_cleanup(&active_state->send_context);
|
|
Jan F. Chadima |
69dd72 |
+ cipher_cleanup(&active_state->receive_context);
|
|
Jan F. Chadima |
69dd72 |
+ audit_session_key_free(2);
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+ if (active_state->connection_in == active_state->connection_out) {
|
|
Jan F. Chadima |
69dd72 |
+ shutdown(active_state->connection_out, SHUT_RDWR);
|
|
Jan F. Chadima |
69dd72 |
+ close(active_state->connection_out);
|
|
Jan F. Chadima |
69dd72 |
+ } else {
|
|
Jan F. Chadima |
69dd72 |
+ close(active_state->connection_in);
|
|
Jan F. Chadima |
69dd72 |
+ close(active_state->connection_out);
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* Sets remote side protocol flags. */
|
|
Petr Lautrbach |
65ba94 |
@@ -729,6 +740,23 @@ packet_send1(void)
|
|
Jan F. Chadima |
69dd72 |
*/
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+static void
|
|
Jan F. Chadima |
69dd72 |
+newkeys_destroy_and_free(Newkeys *newkeys)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ if (newkeys == NULL)
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ xfree(newkeys->enc.name);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ mac_clear(&newkeys->mac);
|
|
Jan F. Chadima |
69dd72 |
+ xfree(newkeys->mac.name);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ xfree(newkeys->comp.name);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ newkeys_destroy(newkeys);
|
|
Jan F. Chadima |
69dd72 |
+ xfree(newkeys);
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
void
|
|
Jan F. Chadima |
69dd72 |
set_newkeys(int mode)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Petr Lautrbach |
65ba94 |
@@ -754,18 +782,9 @@ set_newkeys(int mode)
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
if (active_state->newkeys[mode] != NULL) {
|
|
Jan F. Chadima |
69dd72 |
debug("set_newkeys: rekeying");
|
|
Jan F. Chadima |
69dd72 |
+ audit_session_key_free(mode);
|
|
Jan F. Chadima |
69dd72 |
cipher_cleanup(cc);
|
|
Jan F. Chadima |
69dd72 |
- enc = &active_state->newkeys[mode]->enc;
|
|
Jan F. Chadima |
69dd72 |
- mac = &active_state->newkeys[mode]->mac;
|
|
Jan F. Chadima |
69dd72 |
- comp = &active_state->newkeys[mode]->comp;
|
|
Jan F. Chadima |
69dd72 |
- mac_clear(mac);
|
|
Jan F. Chadima |
69dd72 |
- xfree(enc->name);
|
|
Jan F. Chadima |
69dd72 |
- xfree(enc->iv);
|
|
Jan F. Chadima |
69dd72 |
- xfree(enc->key);
|
|
Jan F. Chadima |
69dd72 |
- xfree(mac->name);
|
|
Jan F. Chadima |
69dd72 |
- xfree(mac->key);
|
|
Jan F. Chadima |
69dd72 |
- xfree(comp->name);
|
|
Jan F. Chadima |
69dd72 |
- xfree(active_state->newkeys[mode]);
|
|
Jan F. Chadima |
69dd72 |
+ newkeys_destroy_and_free(active_state->newkeys[mode]);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
active_state->newkeys[mode] = kex_get_newkeys(mode);
|
|
Jan F. Chadima |
69dd72 |
if (active_state->newkeys[mode] == NULL)
|
|
Petr Lautrbach |
65ba94 |
@@ -1921,6 +1940,47 @@ packet_get_newkeys(int mode)
|
|
Jan F. Chadima |
69dd72 |
return (void *)active_state->newkeys[mode];
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+static void
|
|
Jan F. Chadima |
69dd72 |
+packet_destroy_state(struct session_state *state)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ if (state == NULL)
|
|
Jan F. Chadima |
69dd72 |
+ return;
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ cipher_cleanup(&state->receive_context);
|
|
Jan F. Chadima |
69dd72 |
+ cipher_cleanup(&state->send_context);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+ buffer_free(&state->input);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_free(&state->output);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_free(&state->outgoing_packet);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_free(&state->incoming_packet);
|
|
Jan F. Chadima |
69dd72 |
+ buffer_free(&state->compression_buffer);
|
|
Jan F. Chadima |
69dd72 |
+ newkeys_destroy_and_free(state->newkeys[MODE_IN]);
|
|
Jan F. Chadima |
69dd72 |
+ state->newkeys[MODE_IN] = NULL;
|
|
Jan F. Chadima |
69dd72 |
+ newkeys_destroy_and_free(state->newkeys[MODE_OUT]);
|
|
Jan F. Chadima |
69dd72 |
+ state->newkeys[MODE_OUT] = NULL;
|
|
Jan F. Chadima |
69dd72 |
+ mac_destroy(state->packet_discard_mac);
|
|
Jan F. Chadima |
69dd72 |
+// TAILQ_HEAD(, packet) outgoing;
|
|
Jan F. Chadima |
69dd72 |
+// memset(state, 0, sizeof(state));
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
+void
|
|
Jan F. Chadima |
69dd72 |
+packet_destroy_all(int audit_it, int privsep)
|
|
Jan F. Chadima |
69dd72 |
+{
|
|
Jan F. Chadima |
69dd72 |
+ if (audit_it)
|
|
Jan F. Chadima |
69dd72 |
+ audit_it = packet_state_has_keys (active_state) ||
|
|
Jan F. Chadima |
69dd72 |
+ packet_state_has_keys (backup_state);
|
|
Jan F. Chadima |
69dd72 |
+ packet_destroy_state(active_state);
|
|
Jan F. Chadima |
69dd72 |
+ packet_destroy_state(backup_state);
|
|
Jan F. Chadima |
69dd72 |
+ if (audit_it) {
|
|
Jan F. Chadima |
69dd72 |
+#ifdef SSH_AUDIT_EVENTS
|
|
Jan F. Chadima |
69dd72 |
+ if (privsep)
|
|
Jan F. Chadima |
69dd72 |
+ audit_session_key_free(2);
|
|
Jan F. Chadima |
69dd72 |
+ else
|
|
Jan F. Chadima |
69dd72 |
+ audit_session_key_free_body(2, getpid(), getuid());
|
|
Jan F. Chadima |
69dd72 |
+#endif
|
|
Jan F. Chadima |
69dd72 |
+ }
|
|
Jan F. Chadima |
69dd72 |
+}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
/*
|
|
Jan F. Chadima |
69dd72 |
* Save the state for the real connection, and use a separate state when
|
|
Jan F. Chadima |
69dd72 |
* resuming a suspended connection.
|
|
Petr Lautrbach |
65ba94 |
@@ -1928,18 +1988,12 @@ packet_get_newkeys(int mode)
|
|
Jan F. Chadima |
69dd72 |
void
|
|
Jan F. Chadima |
69dd72 |
packet_backup_state(void)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
69dd72 |
- struct session_state *tmp;
|
|
Jan F. Chadima |
69dd72 |
-
|
|
Jan F. Chadima |
69dd72 |
close(active_state->connection_in);
|
|
Jan F. Chadima |
69dd72 |
active_state->connection_in = -1;
|
|
Jan F. Chadima |
69dd72 |
close(active_state->connection_out);
|
|
Jan F. Chadima |
69dd72 |
active_state->connection_out = -1;
|
|
Jan F. Chadima |
69dd72 |
- if (backup_state)
|
|
Jan F. Chadima |
69dd72 |
- tmp = backup_state;
|
|
Jan F. Chadima |
69dd72 |
- else
|
|
Jan F. Chadima |
69dd72 |
- tmp = alloc_session_state();
|
|
Jan F. Chadima |
69dd72 |
backup_state = active_state;
|
|
Jan F. Chadima |
69dd72 |
- active_state = tmp;
|
|
Jan F. Chadima |
69dd72 |
+ active_state = alloc_session_state();
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/*
|
|
Petr Lautrbach |
65ba94 |
@@ -1956,9 +2010,7 @@ packet_restore_state(void)
|
|
Jan F. Chadima |
69dd72 |
backup_state = active_state;
|
|
Jan F. Chadima |
69dd72 |
active_state = tmp;
|
|
Jan F. Chadima |
69dd72 |
active_state->connection_in = backup_state->connection_in;
|
|
Jan F. Chadima |
69dd72 |
- backup_state->connection_in = -1;
|
|
Jan F. Chadima |
69dd72 |
active_state->connection_out = backup_state->connection_out;
|
|
Jan F. Chadima |
69dd72 |
- backup_state->connection_out = -1;
|
|
Jan F. Chadima |
69dd72 |
len = buffer_len(&backup_state->input);
|
|
Jan F. Chadima |
69dd72 |
if (len > 0) {
|
|
Jan F. Chadima |
69dd72 |
buf = buffer_ptr(&backup_state->input);
|
|
Petr Lautrbach |
65ba94 |
@@ -1966,4 +2018,10 @@ packet_restore_state(void)
|
|
Jan F. Chadima |
69dd72 |
buffer_clear(&backup_state->input);
|
|
Jan F. Chadima |
69dd72 |
add_recv_bytes(len);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+ backup_state->connection_in = -1;
|
|
Jan F. Chadima |
69dd72 |
+ backup_state->connection_out = -1;
|
|
Jan F. Chadima |
69dd72 |
+ packet_destroy_state(backup_state);
|
|
Jan F. Chadima |
69dd72 |
+ xfree(backup_state);
|
|
Jan F. Chadima |
69dd72 |
+ backup_state = NULL;
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/packet.h.audit4 openssh-6.0p1/packet.h
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/packet.h.audit4 2012-02-10 22:19:21.000000000 +0100
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/packet.h 2012-08-06 20:35:56.321788995 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -123,4 +123,5 @@ void packet_restore_state(void);
|
|
Jan F. Chadima |
69dd72 |
void *packet_get_input(void);
|
|
Jan F. Chadima |
69dd72 |
void *packet_get_output(void);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+void packet_destroy_all(int, int);
|
|
Jan F. Chadima |
69dd72 |
#endif /* PACKET_H */
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/session.c.audit4 openssh-6.0p1/session.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/session.c.audit4 2012-08-06 20:35:56.296789093 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/session.c 2012-08-06 20:35:56.322788991 +0200
|
|
Jan F. Chadima |
69dd72 |
@@ -1634,6 +1634,9 @@ do_child(Session *s, const char *command
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* remove hostkey from the child's memory */
|
|
Jan F. Chadima |
69dd72 |
destroy_sensitive_data();
|
|
Jan F. Chadima |
69dd72 |
+ /* Don't audit this - both us and the parent would be talking to the
|
|
Jan F. Chadima |
69dd72 |
+ monitor over a single socket, with no synchronization. */
|
|
Jan F. Chadima |
69dd72 |
+ packet_destroy_all(0, 1);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* Force a password change */
|
|
Jan F. Chadima |
69dd72 |
if (s->authctxt->force_pwchange) {
|
|
Petr Lautrbach |
65ba94 |
diff -up openssh-6.0p1/sshd.c.audit4 openssh-6.0p1/sshd.c
|
|
Petr Lautrbach |
65ba94 |
--- openssh-6.0p1/sshd.c.audit4 2012-08-06 20:35:56.312789030 +0200
|
|
Petr Lautrbach |
65ba94 |
+++ openssh-6.0p1/sshd.c 2012-08-06 20:35:56.323788987 +0200
|
|
Petr Lautrbach |
65ba94 |
@@ -690,6 +690,8 @@ privsep_preauth(Authctxt *authctxt)
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
+extern Newkeys *current_keys[];
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
static void
|
|
Jan F. Chadima |
69dd72 |
privsep_postauth(Authctxt *authctxt)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Petr Lautrbach |
65ba94 |
@@ -714,6 +716,10 @@ privsep_postauth(Authctxt *authctxt)
|
|
Jan F. Chadima |
69dd72 |
else if (pmonitor->m_pid != 0) {
|
|
Jan F. Chadima |
69dd72 |
verbose("User child is on pid %ld", (long)pmonitor->m_pid);
|
|
Jan F. Chadima |
69dd72 |
buffer_clear(&loginmsg);
|
|
Jan F. Chadima |
69dd72 |
+ newkeys_destroy(current_keys[MODE_OUT]);
|
|
Jan F. Chadima |
69dd72 |
+ newkeys_destroy(current_keys[MODE_IN]);
|
|
Jan F. Chadima |
69dd72 |
+ audit_session_key_free_body(2, getpid(), getuid());
|
|
Jan F. Chadima |
69dd72 |
+ packet_destroy_all(0, 0);
|
|
Jan F. Chadima |
69dd72 |
monitor_child_postauth(pmonitor);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* NEVERREACHED */
|
|
Petr Lautrbach |
65ba94 |
@@ -2005,6 +2011,7 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
*/
|
|
Jan F. Chadima |
69dd72 |
if (use_privsep) {
|
|
Jan F. Chadima |
69dd72 |
mm_send_keystate(pmonitor);
|
|
Jan F. Chadima |
69dd72 |
+ packet_destroy_all(1, 1);
|
|
Jan F. Chadima |
69dd72 |
exit(0);
|
|
Jan F. Chadima |
69dd72 |
}
|
|
Jan F. Chadima |
69dd72 |
|
|
Petr Lautrbach |
65ba94 |
@@ -2057,6 +2064,8 @@ main(int ac, char **av)
|
|
Jan F. Chadima |
69dd72 |
do_authenticated(authctxt);
|
|
Jan F. Chadima |
69dd72 |
|
|
Jan F. Chadima |
69dd72 |
/* The connection has been terminated. */
|
|
Jan F. Chadima |
69dd72 |
+ packet_destroy_all(1, 1);
|
|
Jan F. Chadima |
69dd72 |
+
|
|
Jan F. Chadima |
69dd72 |
packet_get_state(MODE_IN, NULL, NULL, NULL, &ibytes);
|
|
Jan F. Chadima |
69dd72 |
packet_get_state(MODE_OUT, NULL, NULL, NULL, &obytes);
|
|
Jan F. Chadima |
69dd72 |
verbose("Transferred: sent %llu, received %llu bytes",
|
|
Petr Lautrbach |
65ba94 |
@@ -2374,6 +2383,16 @@ do_ssh2_kex(void)
|
|
Jan F. Chadima |
39b26b |
void
|
|
Jan F. Chadima |
39b26b |
cleanup_exit(int i)
|
|
Jan F. Chadima |
69dd72 |
{
|
|
Jan F. Chadima |
39b26b |
+ static int in_cleanup = 0;
|
|
Jan F. Chadima |
39b26b |
+ int is_privsep_child;
|
|
Jan F. Chadima |
39b26b |
+
|
|
Jan F. Chadima |
39b26b |
+ /* cleanup_exit can be called at the very least from the privsep
|
|
Jan F. Chadima |
39b26b |
+ wrappers used for auditing. Make sure we don't recurse
|
|
Jan F. Chadima |
39b26b |
+ indefinitely. */
|
|
Jan F. Chadima |
39b26b |
+ if (in_cleanup)
|
|
Jan F. Chadima |
39b26b |
+ _exit(i);
|
|
Jan F. Chadima |
39b26b |
+ in_cleanup = 1;
|
|
Jan F. Chadima |
39b26b |
+
|
|
Petr Lautrbach |
65ba94 |
if (the_authctxt) {
|
|
Jan F. Chadima |
69dd72 |
do_cleanup(the_authctxt);
|
|
Petr Lautrbach |
65ba94 |
if (use_privsep && privsep_is_preauth && pmonitor->m_pid > 1) {
|
|
Petr Lautrbach |
65ba94 |
@@ -2384,6 +2403,8 @@ cleanup_exit(int i)
|
|
Petr Lautrbach |
65ba94 |
pmonitor->m_pid, strerror(errno));
|
|
Petr Lautrbach |
65ba94 |
}
|
|
Petr Lautrbach |
65ba94 |
}
|
|
Jan F. Chadima |
39b26b |
+ is_privsep_child = use_privsep && pmonitor != NULL && !mm_is_monitor();
|
|
Jan F. Chadima |
69dd72 |
+ packet_destroy_all(1, is_privsep_child);
|
|
Jan F. Chadima |
69dd72 |
#ifdef SSH_AUDIT_EVENTS
|
|
Jan F. Chadima |
69dd72 |
/* done after do_cleanup so it can cancel the PAM auth 'thread' */
|
|
Jan F. Chadima |
69dd72 |
if ((the_authctxt == NULL || !the_authctxt->authenticated) &&
|