Blame SOURCES/cvs-1.11.23-Allow-CVS-server-to-use-any-Kerberos-key-with-cvs-se.patch

814382
From 8a186b2754997ed35f8a88d11457699517dd737c Mon Sep 17 00:00:00 2001
814382
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
814382
Date: Fri, 21 Jun 2013 13:01:55 +0200
814382
Subject: [PATCH] Allow CVS server to use any Kerberos key with cvs service
814382
 name
814382
MIME-Version: 1.0
814382
Content-Type: text/plain; charset=UTF-8
814382
Content-Transfer-Encoding: 8bit
814382
814382
This removes restriction for host to be equalled to local hostname.
814382
Previous pinning to hostname prevented from deploying multiple
814382
instances of a CVS server into a cluster where each node has different
814382
hostname.
814382
814382
<https://bugzilla.redhat.com/show_bug.cgi?id=671460>
814382
<https://bugzilla.redhat.com/show_bug.cgi?id=722972>
814382
814382
Signed-off-by: Petr Písař <ppisar@redhat.com>
814382
---
814382
 doc/cvs.texinfo |  8 ++++----
814382
 src/server.c    | 19 +++----------------
814382
 2 files changed, 7 insertions(+), 20 deletions(-)
814382
814382
diff --git a/doc/cvs.texinfo b/doc/cvs.texinfo
814382
index ad3a414..3c7796a 100644
814382
--- a/doc/cvs.texinfo
814382
+++ b/doc/cvs.texinfo
814382
@@ -2771,10 +2771,10 @@ an empty @file{CVSROOT/passwd} password file, and set
814382
 @code{SystemAuth=no} in the config file
814382
 (@pxref{config}).
814382
 
814382
-The GSSAPI server uses a principal name of
814382
-cvs/@var{hostname}, where @var{hostname} is the
814382
-canonical name of the server host.  You will have to
814382
-set this up as required by your GSSAPI mechanism.
814382
+The GSSAPI server uses a principal name of cvs/@var{hostname}, where
814382
+@var{hostname} can be any name.  There is no restriction to canonical
814382
+hostname to allow DNS load-balanced clusters.  It assumes your GSSAPI
814382
+mechanism can select a key with a host name matching client's request.
814382
 
814382
 To connect using GSSAPI, use the @samp{:gserver:} method.  For
814382
 example,
814382
diff --git a/src/server.c b/src/server.c
814382
index 0505ab9..586b5da 100644
814382
--- a/src/server.c
814382
+++ b/src/server.c
814382
@@ -6168,9 +6168,7 @@ error 0 kerberos: can't get local name: %s\n", krb_get_err_text(status));
814382
 static void
814382
 gserver_authenticate_connection ()
814382
 {
814382
-    char hostname[MAXHOSTNAMELEN];
814382
     char hbuf[1025];
814382
-    struct addrinfo hints, *res0;
814382
     gss_buffer_desc tok_in, tok_out;
814382
     char buf[1024];
814382
     char *credbuf;
814382
@@ -6181,23 +6179,12 @@ gserver_authenticate_connection ()
814382
     int nbytes;
814382
     gss_OID mechid;
814382
 
814382
-    gethostname (hostname, sizeof hostname);
814382
-    hostname[sizeof(hostname)-1] = '\0';
814382
-    memset (&hints, 0, sizeof(hints));
814382
-    hints.ai_family = af;
814382
-    hints.ai_socktype = SOCK_STREAM;
814382
-    hints.ai_flags = AI_CANONNAME;
814382
-    if (getaddrinfo (hostname, NULL, &hints, &res0))
814382
-	error (1, 0, "can't get canonical hostname");
814382
-
814382
-    sprintf (buf, "cvs@%s", res0->ai_canonname);
814382
-    freeaddrinfo (res0);
814382
-    tok_in.value = buf;
814382
-    tok_in.length = strlen (buf);
814382
+    tok_in.value = "cvs";
814382
+    tok_in.length = strlen (tok_in.value);
814382
 
814382
     if (gss_import_name (&stat_min, &tok_in, GSS_C_NT_HOSTBASED_SERVICE,
814382
 			 &server_name) != GSS_S_COMPLETE)
814382
-	error (1, 0, "could not import GSSAPI service name %s", buf);
814382
+	error (1, 0, "could not import GSSAPI service name %s", tok_in.value);
814382
 
814382
     /* Acquire the server credential to verify the client's
814382
        authentication.  */
814382
-- 
814382
1.8.1.4
814382