Blame SOURCES/gssproxy-0.3.0-gss_inquire_cred_by_mech.patch

4c520e
From 122b35f7adf37bc81f6d53bb5f9e058b68334cbb Mon Sep 17 00:00:00 2001
4c520e
From: Simo Sorce <simo@redhat.com>
4c520e
Date: Wed, 13 Nov 2013 18:12:44 -0500
4c520e
Subject: [PATCH 2/3] Add way to return regular oid from special
4c520e
MIME-Version: 1.0
4c520e
Content-Type: text/plain; charset=UTF-8
4c520e
Content-Transfer-Encoding: 8bit
4c520e
4c520e
In some cases we need to pass on the corresponding real oid, after we
4c520e
are given a special oid.
4c520e
Add helper functions to do that.
4c520e
4c520e
https://fedorahosted.org/gss-proxy/ticket/107
4c520e
4c520e
Reviewed-by: Günther Deschner <gdeschner@redhat.com>
4c520e
---
4c520e
 proxy/src/mechglue/gss_plugin.c | 55 +++++++++++++++++++++++++++++++----------
4c520e
 proxy/src/mechglue/gss_plugin.h |  1 +
4c520e
 2 files changed, 43 insertions(+), 13 deletions(-)
4c520e
4c520e
diff --git a/proxy/src/mechglue/gss_plugin.c b/proxy/src/mechglue/gss_plugin.c
4c520e
index 0e62990..5b40df9 100644
4c520e
--- a/proxy/src/mechglue/gss_plugin.c
4c520e
+++ b/proxy/src/mechglue/gss_plugin.c
4c520e
@@ -176,7 +176,8 @@ static bool gpp_special_equal(const gss_OID s, const gss_OID n)
4c520e
 }
4c520e
 
4c520e
 struct gpp_special_oid_list {
4c520e
-    gss_OID_desc oid;
4c520e
+    gss_OID_desc regular_oid;
4c520e
+    gss_OID_desc special_oid;
4c520e
     struct gpp_special_oid_list *next;
4c520e
     sig_atomic_t next_is_set;
4c520e
 };
4c520e
@@ -250,19 +251,25 @@ static const gss_OID gpp_new_special_mech(const gss_OID n)
4c520e
     if (!item) {
4c520e
         return GSS_C_NO_OID;
4c520e
     }
4c520e
-    item->oid.length = base->length + n->length;
4c520e
-    item->oid.elements = malloc(item->oid.length);
4c520e
-    if (!item->oid.elements) {
4c520e
+    item->regular_oid.length = n->length;
4c520e
+    item->regular_oid.elements = malloc(n->length);
4c520e
+    item->special_oid.length = base->length + n->length;
4c520e
+    item->special_oid.elements = malloc(item->special_oid.length);
4c520e
+    if (!item->regular_oid.elements ||
4c520e
+        !item->special_oid.elements) {
4c520e
+        free(item->regular_oid.elements);
4c520e
+        free(item->special_oid.elements);
4c520e
         free(item);
4c520e
         return GSS_C_NO_OID;
4c520e
     }
4c520e
 
4c520e
-    memcpy(item->oid.elements, base->elements, base->length);
4c520e
-    memcpy(item->oid.elements + base->length, n->elements, n->length);
4c520e
+    memcpy(item->regular_oid.elements, n->elements, n->length);
4c520e
+    memcpy(item->special_oid.elements, base->elements, base->length);
4c520e
+    memcpy(item->special_oid.elements + base->length, n->elements, n->length);
4c520e
 
4c520e
     gpp_add_special_oids(item);
4c520e
 
4c520e
-    return (const gss_OID)&item->oid;
4c520e
+    return (const gss_OID)&item->special_oid;
4c520e
 }
4c520e
 
4c520e
 const gss_OID gpp_special_mech(const gss_OID mech_type)
4c520e
@@ -278,14 +285,14 @@ const gss_OID gpp_special_mech(const gss_OID mech_type)
4c520e
     if (mech_type == GSS_C_NO_OID) {
4c520e
         /* return the first special one if none specified */
4c520e
         if (item) {
4c520e
-            return (const gss_OID)&item->oid;
4c520e
+            return (const gss_OID)&item->special_oid;
4c520e
         }
4c520e
         return GSS_C_NO_OID;
4c520e
     }
4c520e
 
4c520e
     while (item) {
4c520e
-        if (gpp_special_equal(&item->oid, mech_type)) {
4c520e
-            return (const gss_OID)&item->oid;
4c520e
+        if (gpp_special_equal(&item->special_oid, mech_type)) {
4c520e
+            return (const gss_OID)&item->special_oid;
4c520e
         }
4c520e
         item = gpp_next_special_oids(item);
4c520e
     }
4c520e
@@ -294,6 +301,26 @@ const gss_OID gpp_special_mech(const gss_OID mech_type)
4c520e
     return gpp_new_special_mech(mech_type);
4c520e
 }
4c520e
 
4c520e
+const gss_OID gpp_unspecial_mech(const gss_OID mech_type)
4c520e
+{
4c520e
+    struct gpp_special_oid_list *item = NULL;
4c520e
+
4c520e
+    if (!gpp_is_special_oid(mech_type)) {
4c520e
+        return mech_type;
4c520e
+    }
4c520e
+
4c520e
+    item = gpp_get_special_oids();
4c520e
+    while (item) {
4c520e
+        if (gss_oid_equal(&item->special_oid, mech_type)) {
4c520e
+            return (const gss_OID)&item->regular_oid;
4c520e
+        }
4c520e
+        item = gpp_next_special_oids(item);
4c520e
+    }
4c520e
+
4c520e
+    /* none matched */
4c520e
+    return mech_type;
4c520e
+}
4c520e
+
4c520e
 gss_OID_set gpp_special_available_mechs(const gss_OID_set mechs)
4c520e
 {
4c520e
     gss_OID_set amechs = GSS_C_NO_OID_SET;
4c520e
@@ -318,8 +345,9 @@ gss_OID_set gpp_special_available_mechs(const gss_OID_set mechs)
4c520e
                 }
4c520e
                 break;
4c520e
             }
4c520e
-            if (gpp_special_equal(&item->oid, &mechs->elements[i])) {
4c520e
-                maj = gss_add_oid_set_member(&min, &item->oid, &amechs);
4c520e
+            if (gpp_special_equal(&item->special_oid, &mechs->elements[i])) {
4c520e
+                maj = gss_add_oid_set_member(&min, &item->special_oid,
4c520e
+                                             &amechs);
4c520e
                 if (maj != GSS_S_COMPLETE) {
4c520e
                     goto done;
4c520e
                 }
4c520e
@@ -362,7 +390,8 @@ OM_uint32 gssi_internal_release_oid(OM_uint32 *minor_status, gss_OID *oid)
4c520e
     item = gpp_get_special_oids();
4c520e
 
4c520e
     while (item) {
4c520e
-        if (&item->oid == *oid) {
4c520e
+        if ((&item->regular_oid == *oid) ||
4c520e
+            (&item->special_oid == *oid)) {
4c520e
             *oid = GSS_C_NO_OID;
4c520e
             return GSS_S_COMPLETE;
4c520e
         }
4c520e
diff --git a/proxy/src/mechglue/gss_plugin.h b/proxy/src/mechglue/gss_plugin.h
4c520e
index 26e04c5..739ec26 100644
4c520e
--- a/proxy/src/mechglue/gss_plugin.h
4c520e
+++ b/proxy/src/mechglue/gss_plugin.h
4c520e
@@ -78,6 +78,7 @@ gss_OID_set gss_mech_interposer(gss_OID mech_type);
4c520e
 enum gpp_behavior gpp_get_behavior(void);
4c520e
 bool gpp_is_special_oid(const gss_OID mech_type);
4c520e
 const gss_OID gpp_special_mech(const gss_OID mech_type);
4c520e
+const gss_OID gpp_unspecial_mech(const gss_OID mech_type);
4c520e
 gss_OID_set gpp_special_available_mechs(const gss_OID_set mechs);
4c520e
 uint32_t gpp_map_error(uint32_t err);
4c520e
 uint32_t gpp_unmap_error(uint32_t err);
4c520e
-- 
4c520e
1.8.3.1
4c520e
4c520e
4c520e
From b8901d1d20a5d0ef1a3118bfe5816e04c09e6cf5 Mon Sep 17 00:00:00 2001
4c520e
From: Simo Sorce <simo@redhat.com>
4c520e
Date: Wed, 13 Nov 2013 18:13:44 -0500
4c520e
Subject: [PATCH 3/3] Fix calling gpm_inquire_cred_by_mech
4c520e
MIME-Version: 1.0
4c520e
Content-Type: text/plain; charset=UTF-8
4c520e
Content-Transfer-Encoding: 8bit
4c520e
4c520e
We need to pass the real mechanism oid here, not the spcial oid.
4c520e
special oids are used exclusively by the interposer and gssapi
4c520e
machinery that calls the interposer, they must never be propagated
4c520e
to clients or servers.
4c520e
4c520e
https://fedorahosted.org/gss-proxy/ticket/107
4c520e
4c520e
Reviewed-by: Günther Deschner <gdeschner@redhat.com>
4c520e
---
4c520e
 proxy/src/mechglue/gpp_creds.c | 3 ++-
4c520e
 1 file changed, 2 insertions(+), 1 deletion(-)
4c520e
4c520e
diff --git a/proxy/src/mechglue/gpp_creds.c b/proxy/src/mechglue/gpp_creds.c
4c520e
index aaaf577..dff9c44 100644
4c520e
--- a/proxy/src/mechglue/gpp_creds.c
4c520e
+++ b/proxy/src/mechglue/gpp_creds.c
4c520e
@@ -213,7 +213,8 @@ OM_uint32 gssi_inquire_cred_by_mech(OM_uint32 *minor_status,
4c520e
                                        initiator_lifetime, acceptor_lifetime,
4c520e
                                        cred_usage);
4c520e
     } else if (cred->remote) {
4c520e
-        maj = gpm_inquire_cred_by_mech(&min, cred->remote, mech_type,
4c520e
+        maj = gpm_inquire_cred_by_mech(&min, cred->remote,
4c520e
+                                       gpp_unspecial_mech(mech_type),
4c520e
                                        gpname ? &gpname->remote : NULL,
4c520e
                                        initiator_lifetime, acceptor_lifetime,
4c520e
                                        cred_usage);
4c520e
-- 
4c520e
1.8.3.1
4c520e