vishalmishra434 / rpms / openssh

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