jonathancammack / rpms / openssh

Forked from rpms/openssh 8 months ago
Clone

Blame SOURCES/openssh-7.9p1-gsskex-method.patch

f5835d
From bc74944ce7a2eabd228d47051f277ce108914c96 Mon Sep 17 00:00:00 2001
f5835d
From: Jakub Jelen <jjelen@redhat.com>
f5835d
Date: Tue, 16 Oct 2018 16:44:40 +0200
f5835d
Subject: [PATCH] Unbreak authentication using gssapi-keyex (#1625366)
f5835d
f5835d
---
f5835d
 auth2-gss.c    |  6 +++---
f5835d
 gss-serv.c     |  4 +++-
f5835d
 monitor.c      | 13 ++++++++++---
f5835d
 monitor_wrap.c |  4 +++-
f5835d
 monitor_wrap.h |  2 +-
f5835d
 ssh-gss.h      |  2 +-
f5835d
 6 files changed, 21 insertions(+), 10 deletions(-)
f5835d
f5835d
diff --git a/auth2-gss.c b/auth2-gss.c
f5835d
index 3f2ad21d..a61ac089 100644
f5835d
--- a/auth2-gss.c
f5835d
+++ b/auth2-gss.c
f5835d
@@ -84,7 +84,7 @@ userauth_gsskeyex(Authctxt *authctxt)
f5835d
 	if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gss_kex_context, 
f5835d
 	    &gssbuf, &mic))))
f5835d
 		authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user,
f5835d
-		    authctxt->pw));
f5835d
+		    authctxt->pw, 1));
f5835d
 	
f5835d
 	sshbuf_free(b);
f5835d
 	free(mic.value);
f5835d
@@ -299,7 +299,7 @@ input_gssapi_exchange_complete(int type, u_int32_t plen, struct ssh *ssh)
f5835d
 		fatal("%s: %s", __func__, ssh_err(r));
f5835d
 
f5835d
 	authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user,
f5835d
-	    authctxt->pw));
f5835d
+	    authctxt->pw, 1));
f5835d
 
f5835d
 	if ((!use_privsep || mm_is_monitor()) &&
f5835d
 	    (displayname = ssh_gssapi_displayname()) != NULL)
f5835d
@@ -347,7 +347,7 @@ input_gssapi_mic(int type, u_int32_t plen, struct ssh *ssh)
f5835d
 
f5835d
 	if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gssctxt, &gssbuf, &mic))))
f5835d
 		authenticated = 
f5835d
-		    PRIVSEP(ssh_gssapi_userok(authctxt->user, authctxt->pw));
f5835d
+		    PRIVSEP(ssh_gssapi_userok(authctxt->user, authctxt->pw, 0));
f5835d
 	else
f5835d
 		logit("GSSAPI MIC check failed");
f5835d
 
f5835d
diff --git a/gss-serv.c b/gss-serv.c
f5835d
index 786ac95c..87de2baa 100644
f5835d
--- a/gss-serv.c
f5835d
+++ b/gss-serv.c
f5835d
@@ -493,10 +493,12 @@ verify_authentication_indicators(Gssctxt *gssctxt)
f5835d
 
f5835d
 /* Privileged */
f5835d
 int
f5835d
-ssh_gssapi_userok(char *user, struct passwd *pw)
f5835d
+ssh_gssapi_userok(char *user, struct passwd *pw, int kex)
f5835d
 {
f5835d
 	OM_uint32 lmin;
f5835d
 
f5835d
+	(void) kex; /* used in privilege separation */
f5835d
+
f5835d
 	if (gssapi_client.exportedname.length == 0 ||
f5835d
 	    gssapi_client.exportedname.value == NULL) {
f5835d
 		debug("No suitable client data");
f5835d
diff --git a/monitor.c b/monitor.c
f5835d
index 9bbe8cc4..7b1903af 100644
f5835d
--- a/monitor.c
f5835d
+++ b/monitor.c
f5835d
@@ -1877,14 +1877,17 @@ mm_answer_gss_checkmic(int sock, struct sshbuf *m)
f5835d
 int
f5835d
 mm_answer_gss_userok(int sock, struct sshbuf *m)
f5835d
 {
f5835d
-	int r, authenticated;
f5835d
+	int r, authenticated, kex;
f5835d
 	const char *displayname;
f5835d
 
f5835d
 	if (!options.gss_authentication && !options.gss_keyex)
f5835d
 		fatal("%s: GSSAPI authentication not enabled", __func__);
f5835d
 
f5835d
+	if ((r = sshbuf_get_u32(m, &kex)) != 0)
f5835d
+		fatal("%s: buffer error: %s", __func__, ssh_err(r));
f5835d
+
f5835d
 	authenticated = authctxt->valid &&
f5835d
-	    ssh_gssapi_userok(authctxt->user, authctxt->pw);
f5835d
+	    ssh_gssapi_userok(authctxt->user, authctxt->pw, kex);
f5835d
 
f5835d
 	sshbuf_reset(m);
f5835d
 	if ((r = sshbuf_put_u32(m, authenticated)) != 0)
f5835d
@@ -1893,7 +1896,11 @@ mm_answer_gss_userok(int sock, struct sshbuf *m)
f5835d
 	debug3("%s: sending result %d", __func__, authenticated);
f5835d
 	mm_request_send(sock, MONITOR_ANS_GSSUSEROK, m);
f5835d
 
f5835d
-	auth_method = "gssapi-with-mic";
f5835d
+	if (kex) {
f5835d
+		auth_method = "gssapi-keyex";
f5835d
+	} else {
f5835d
+		auth_method = "gssapi-with-mic";
f5835d
+	}
f5835d
 
f5835d
 	if ((displayname = ssh_gssapi_displayname()) != NULL)
f5835d
 		auth2_record_info(authctxt, "%s", displayname);
f5835d
diff --git a/monitor_wrap.c b/monitor_wrap.c
f5835d
index fb52a530..508d926d 100644
f5835d
--- a/monitor_wrap.c
f5835d
+++ b/monitor_wrap.c
f5835d
@@ -984,13 +984,15 @@ mm_ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
f5835d
 }
f5835d
 
f5835d
 int
f5835d
-mm_ssh_gssapi_userok(char *user, struct passwd *pw)
f5835d
+mm_ssh_gssapi_userok(char *user, struct passwd *pw, int kex)
f5835d
 {
f5835d
 	struct sshbuf *m;
f5835d
 	int r, authenticated = 0;
f5835d
 
f5835d
 	if ((m = sshbuf_new()) == NULL)
f5835d
 		fatal("%s: sshbuf_new failed", __func__);
f5835d
+	if ((r = sshbuf_put_u32(m, kex)) != 0)
f5835d
+		fatal("%s: buffer error: %s", __func__, ssh_err(r));
f5835d
 
f5835d
 	mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSUSEROK, m);
f5835d
 	mm_request_receive_expect(pmonitor->m_recvfd,
f5835d
diff --git a/monitor_wrap.h b/monitor_wrap.h
f5835d
index 494760dd..5eba5ecc 100644
f5835d
--- a/monitor_wrap.h
f5835d
+++ b/monitor_wrap.h
f5835d
@@ -60,7 +60,7 @@ int mm_sshkey_verify(const struct sshkey *, const u_char *, size_t,
f5835d
 OM_uint32 mm_ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
f5835d
 OM_uint32 mm_ssh_gssapi_accept_ctx(Gssctxt *,
f5835d
    gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
f5835d
-int mm_ssh_gssapi_userok(char *user, struct passwd *);
f5835d
+int mm_ssh_gssapi_userok(char *user, struct passwd *, int kex);
f5835d
 OM_uint32 mm_ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
f5835d
 OM_uint32 mm_ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
f5835d
 int mm_ssh_gssapi_update_creds(ssh_gssapi_ccache *);
f5835d
diff --git a/ssh-gss.h b/ssh-gss.h
f5835d
index 39b6ce69..98262837 100644
f5835d
--- a/ssh-gss.h
f5835d
+++ b/ssh-gss.h
f5835d
@@ -162,7 +162,7 @@ gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int);
f5835d
 int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *, 
f5835d
     const char *);
f5835d
 OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
f5835d
-int ssh_gssapi_userok(char *name, struct passwd *);
f5835d
+int ssh_gssapi_userok(char *name, struct passwd *, int kex);
f5835d
 OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
f5835d
 void ssh_gssapi_do_child(char ***, u_int *);
f5835d
 void ssh_gssapi_cleanup_creds(void);
f5835d
-- 
f5835d
2.17.2
f5835d