bmh10 / rpms / openssh

Forked from rpms/openssh 2 days ago
Clone
017ff1
diff --git a/audit-bsm.c b/audit-bsm.c
017ff1
index 5160869..c7a1b47 100644
017ff1
--- a/audit-bsm.c
017ff1
+++ b/audit-bsm.c
017ff1
@@ -481,7 +481,7 @@ audit_unsupported_body(int what)
017ff1
 }
017ff1
 
017ff1
 void
017ff1
-audit_kex_body(int ctos, char *enc, char *mac, char *compress, pid_t pid, uid_t uid)
017ff1
+audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid, uid_t uid)
017ff1
 {
017ff1
 	/* not implemented */
017ff1
 }
017ff1
diff --git a/audit-linux.c b/audit-linux.c
017ff1
index 6954fc1..6686f6a 100644
017ff1
--- a/audit-linux.c
017ff1
+++ b/audit-linux.c
017ff1
@@ -297,7 +297,7 @@ audit_unsupported_body(int what)
017ff1
 const static char *direction[] = { "from-server", "from-client", "both" };
017ff1
 
017ff1
 void
017ff1
-audit_kex_body(int ctos, char *enc, char *mac, char *compress, pid_t pid,
017ff1
+audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid,
017ff1
 	       uid_t uid)
017ff1
 {
017ff1
 #ifdef AUDIT_CRYPTO_SESSION
017ff1
@@ -306,8 +306,8 @@ audit_kex_body(int ctos, char *enc, char *mac, char *compress, pid_t pid,
017ff1
 	Cipher *cipher = cipher_by_name(enc);
017ff1
 	char *s;
017ff1
 
017ff1
-	snprintf(buf, sizeof(buf), "op=start direction=%s cipher=%s ksize=%d mac=%s spid=%jd suid=%jd rport=%d laddr=%s lport=%d ",
017ff1
-		direction[ctos], enc, cipher ? 8 * cipher->key_len : 0, mac,
017ff1
+	snprintf(buf, sizeof(buf), "op=start direction=%s cipher=%s ksize=%d mac=%s pfs=%s spid=%jd suid=%jd rport=%d laddr=%s lport=%d ",
017ff1
+		direction[ctos], enc, cipher ? 8 * cipher->key_len : 0, mac, pfs,
017ff1
 		(intmax_t)pid, (intmax_t)uid,
017ff1
 		get_remote_port(), (s = get_local_ipaddr(packet_get_connection_in())), get_local_port());
017ff1
 	free(s);
017ff1
diff --git a/audit.c b/audit.c
017ff1
index 13c6849..5b49434 100644
017ff1
--- a/audit.c
017ff1
+++ b/audit.c
017ff1
@@ -135,9 +135,9 @@ audit_unsupported(int what)
017ff1
 }
017ff1
 
017ff1
 void
017ff1
-audit_kex(int ctos, char *enc, char *mac, char *comp)
017ff1
+audit_kex(int ctos, char *enc, char *mac, char *comp, char *pfs)
017ff1
 {
017ff1
-	PRIVSEP(audit_kex_body(ctos, enc, mac, comp, getpid(), getuid()));
017ff1
+	PRIVSEP(audit_kex_body(ctos, enc, mac, comp, pfs, getpid(), getuid()));
017ff1
 }
017ff1
 
017ff1
 void
017ff1
@@ -270,11 +270,11 @@ audit_unsupported_body(int what)
017ff1
  * This will be called on succesfull protocol negotiation.
017ff1
  */
017ff1
 void
017ff1
-audit_kex_body(int ctos, char *enc, char *mac, char *compress, pid_t pid,
017ff1
+audit_kex_body(int ctos, char *enc, char *mac, char *compress, char *pfs, pid_t pid,
017ff1
 	       uid_t uid)
017ff1
 {
017ff1
-	debug("audit protocol negotiation euid %d direction %d cipher %s mac %s compresion %s from pid %ld uid %u",
017ff1
-		(unsigned)geteuid(), ctos, enc, mac, compress, (long)pid,
017ff1
+	debug("audit protocol negotiation euid %d direction %d cipher %s mac %s compresion %s pfs %s from pid %ld uid %u",
017ff1
+		(unsigned)geteuid(), ctos, enc, mac, compress, pfs, (long)pid,
017ff1
 	        (unsigned)uid);
017ff1
 }
017ff1
 
017ff1
diff --git a/audit.h b/audit.h
017ff1
index a2dc3ff..903df66 100644
017ff1
--- a/audit.h
017ff1
+++ b/audit.h
017ff1
@@ -61,9 +61,9 @@ ssh_audit_event_t audit_classify_auth(const char *);
017ff1
 int	audit_keyusage(int, const char *, unsigned, char *, int);
017ff1
 void	audit_key(int, int *, const Key *);
017ff1
 void	audit_unsupported(int);
017ff1
-void	audit_kex(int, char *, char *, char *);
017ff1
+void	audit_kex(int, char *, char *, char *, char *);
017ff1
 void	audit_unsupported_body(int);
017ff1
-void	audit_kex_body(int, char *, char *, char *, pid_t, uid_t);
017ff1
+void	audit_kex_body(int, char *, char *, char *, char *, pid_t, uid_t);
017ff1
 void	audit_session_key_free(int ctos);
017ff1
 void	audit_session_key_free_body(int ctos, pid_t, uid_t);
017ff1
 void	audit_destroy_sensitive_data(const char *, pid_t, uid_t);
017ff1
diff --git a/auditstub.c b/auditstub.c
017ff1
index 45817e0..116f460 100644
017ff1
--- a/auditstub.c
017ff1
+++ b/auditstub.c
017ff1
@@ -35,7 +35,7 @@ audit_unsupported(int n)
017ff1
 }
017ff1
 
017ff1
 void
017ff1
-audit_kex(int ctos, char *enc, char *mac, char *comp)
017ff1
+audit_kex(int ctos, char *enc, char *mac, char *comp, char *pfs)
017ff1
 {
017ff1
 }
017ff1
 
017ff1
diff --git a/kex.c b/kex.c
017ff1
index ede7b67..eb5f333 100644
017ff1
--- a/kex.c
017ff1
+++ b/kex.c
017ff1
@@ -553,13 +553,12 @@ kex_choose_conf(Kex *kex)
017ff1
 		    newkeys->enc.name,
017ff1
 		    authlen == 0 ? newkeys->mac.name : "<implicit>",
017ff1
 		    newkeys->comp.name);
017ff1
-#ifdef SSH_AUDIT_EVENTS
017ff1
-		audit_kex(ctos, newkeys->enc.name, newkeys->mac.name, newkeys->comp.name);
017ff1
-#endif
017ff1
 	}
017ff1
+
017ff1
 	choose_kex(kex, cprop[PROPOSAL_KEX_ALGS], sprop[PROPOSAL_KEX_ALGS]);
017ff1
 	choose_hostkeyalg(kex, cprop[PROPOSAL_SERVER_HOST_KEY_ALGS],
017ff1
 	    sprop[PROPOSAL_SERVER_HOST_KEY_ALGS]);
017ff1
+
017ff1
 	need = dh_need = 0;
017ff1
 	for (mode = 0; mode < MODE_MAX; mode++) {
017ff1
 		newkeys = kex->newkeys[mode];
017ff1
@@ -571,11 +570,16 @@ kex_choose_conf(Kex *kex)
017ff1
 		dh_need = MAX(dh_need, newkeys->enc.block_size);
017ff1
 		dh_need = MAX(dh_need, newkeys->enc.iv_len);
017ff1
 		dh_need = MAX(dh_need, newkeys->mac.key_len);
017ff1
+		debug("kex: %s need=%d dh_need=%d", kex->name, need, dh_need);
017ff1
+#ifdef SSH_AUDIT_EVENTS
017ff1
+		audit_kex(mode, newkeys->enc.name, newkeys->mac.name, newkeys->comp.name, kex->name);
017ff1
+#endif
017ff1
 	}
017ff1
 	/* XXX need runden? */
017ff1
 	kex->we_need = need;
017ff1
 	kex->dh_need = dh_need;
017ff1
 
017ff1
+
017ff1
 	/* ignore the next message if the proposals do not match */
017ff1
 	if (first_kex_follows && !proposals_match(my, peer) &&
017ff1
 	    !(datafellows & SSH_BUG_FIRSTKEX)) {
017ff1
diff --git a/monitor.c b/monitor.c
017ff1
index 70b9b4c..81bc9c1 100644
017ff1
--- a/monitor.c
017ff1
+++ b/monitor.c
017ff1
@@ -2396,7 +2396,7 @@ int
017ff1
 mm_answer_audit_kex_body(int sock, Buffer *m)
017ff1
 {
017ff1
 	int ctos, len;
017ff1
-	char *cipher, *mac, *compress;
017ff1
+	char *cipher, *mac, *compress, *pfs;
017ff1
 	pid_t pid;
017ff1
 	uid_t uid;
017ff1
 
017ff1
@@ -2404,14 +2404,16 @@ mm_answer_audit_kex_body(int sock, Buffer *m)
017ff1
 	cipher = buffer_get_string(m, &len;;
017ff1
 	mac = buffer_get_string(m, &len;;
017ff1
 	compress = buffer_get_string(m, &len;;
017ff1
+	pfs = buffer_get_string(m, &len;;
017ff1
 	pid = buffer_get_int64(m);
017ff1
 	uid = buffer_get_int64(m);
017ff1
 
017ff1
-	audit_kex_body(ctos, cipher, mac, compress, pid, uid);
017ff1
+	audit_kex_body(ctos, cipher, mac, compress, pfs, pid, uid);
017ff1
 
017ff1
 	free(cipher);
017ff1
 	free(mac);
017ff1
 	free(compress);
017ff1
+	free(pfs);
017ff1
 	buffer_clear(m);
017ff1
 
017ff1
 	mm_request_send(sock, MONITOR_ANS_AUDIT_KEX, m);
017ff1
diff --git a/monitor_wrap.c b/monitor_wrap.c
017ff1
index 93f6535..69b29d8 100644
017ff1
--- a/monitor_wrap.c
017ff1
+++ b/monitor_wrap.c
017ff1
@@ -1408,7 +1408,7 @@ mm_audit_unsupported_body(int what)
017ff1
 }
017ff1
 
017ff1
 void
017ff1
-mm_audit_kex_body(int ctos, char *cipher, char *mac, char *compress, pid_t pid,
017ff1
+mm_audit_kex_body(int ctos, char *cipher, char *mac, char *compress, char *fps, pid_t pid,
017ff1
 		  uid_t uid)
017ff1
 {
017ff1
 	Buffer m;
017ff1
@@ -1418,6 +1418,7 @@ mm_audit_kex_body(int ctos, char *cipher, char *mac, char *compress, pid_t pid,
017ff1
 	buffer_put_cstring(&m, cipher);
017ff1
 	buffer_put_cstring(&m, (mac ? mac : ""));
017ff1
 	buffer_put_cstring(&m, compress);
017ff1
+	buffer_put_cstring(&m, fps);
017ff1
 	buffer_put_int64(&m, pid);
017ff1
 	buffer_put_int64(&m, uid);
017ff1
 
017ff1
diff --git a/monitor_wrap.h b/monitor_wrap.h
017ff1
index 4cf0c78..e43109f 100644
017ff1
--- a/monitor_wrap.h
017ff1
+++ b/monitor_wrap.h
017ff1
@@ -83,7 +83,7 @@ void mm_audit_event(ssh_audit_event_t);
017ff1
 int mm_audit_run_command(const char *);
017ff1
 void mm_audit_end_command(int, const char *);
017ff1
 void mm_audit_unsupported_body(int);
017ff1
-void mm_audit_kex_body(int, char *, char *, char *, pid_t, uid_t);
017ff1
+void mm_audit_kex_body(int, char *, char *, char *, char *, pid_t, uid_t);
017ff1
 void mm_audit_session_key_free_body(int, pid_t, uid_t);
017ff1
 void mm_audit_destroy_sensitive_data(const char *, pid_t, uid_t);
017ff1
 #endif
017ff1
diff --git a/sshd.c b/sshd.c
017ff1
index ee94825..41a94a7 100644
017ff1
--- a/sshd.c
017ff1
+++ b/sshd.c
017ff1
@@ -2430,7 +2430,7 @@ do_ssh1_kex(void)
017ff1
 			packet_disconnect("IP Spoofing check bytes do not match.");
017ff1
 
017ff1
 #ifdef SSH_AUDIT_EVENTS
017ff1
-	audit_kex(2, cipher_name(cipher_type), "crc", "none");
017ff1
+	audit_kex(2, cipher_name(cipher_type), "crc", "none", "none");
017ff1
 #endif
017ff1
 
017ff1
 	debug("Encryption type: %.200s", cipher_name(cipher_type));