summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-11-13 18:12:44 -0500
committerGünther Deschner <gdeschner@redhat.com>2013-11-19 14:04:03 +0100
commit122b35f7adf37bc81f6d53bb5f9e058b68334cbb (patch)
treed083147827f7e8e1369aa574c9744f2bd099e9d1
parentcc538c36ca32850e0b3280b7d8524d23345eed9e (diff)
downloadgss-proxy-122b35f7adf37bc81f6d53bb5f9e058b68334cbb.tar.gz
gss-proxy-122b35f7adf37bc81f6d53bb5f9e058b68334cbb.tar.xz
gss-proxy-122b35f7adf37bc81f6d53bb5f9e058b68334cbb.zip
Add way to return regular oid from special
In some cases we need to pass on the corresponding real oid, after we are given a special oid. Add helper functions to do that. https://fedorahosted.org/gss-proxy/ticket/107 Reviewed-by: Günther Deschner <gdeschner@redhat.com>
-rw-r--r--proxy/src/mechglue/gss_plugin.c55
-rw-r--r--proxy/src/mechglue/gss_plugin.h1
2 files changed, 43 insertions, 13 deletions
diff --git a/proxy/src/mechglue/gss_plugin.c b/proxy/src/mechglue/gss_plugin.c
index 0e62990..5b40df9 100644
--- a/proxy/src/mechglue/gss_plugin.c
+++ b/proxy/src/mechglue/gss_plugin.c
@@ -176,7 +176,8 @@ static bool gpp_special_equal(const gss_OID s, const gss_OID n)
}
struct gpp_special_oid_list {
- gss_OID_desc oid;
+ gss_OID_desc regular_oid;
+ gss_OID_desc special_oid;
struct gpp_special_oid_list *next;
sig_atomic_t next_is_set;
};
@@ -250,19 +251,25 @@ static const gss_OID gpp_new_special_mech(const gss_OID n)
if (!item) {
return GSS_C_NO_OID;
}
- item->oid.length = base->length + n->length;
- item->oid.elements = malloc(item->oid.length);
- if (!item->oid.elements) {
+ item->regular_oid.length = n->length;
+ item->regular_oid.elements = malloc(n->length);
+ item->special_oid.length = base->length + n->length;
+ item->special_oid.elements = malloc(item->special_oid.length);
+ if (!item->regular_oid.elements ||
+ !item->special_oid.elements) {
+ free(item->regular_oid.elements);
+ free(item->special_oid.elements);
free(item);
return GSS_C_NO_OID;
}
- memcpy(item->oid.elements, base->elements, base->length);
- memcpy(item->oid.elements + base->length, n->elements, n->length);
+ memcpy(item->regular_oid.elements, n->elements, n->length);
+ memcpy(item->special_oid.elements, base->elements, base->length);
+ memcpy(item->special_oid.elements + base->length, n->elements, n->length);
gpp_add_special_oids(item);
- return (const gss_OID)&item->oid;
+ return (const gss_OID)&item->special_oid;
}
const gss_OID gpp_special_mech(const gss_OID mech_type)
@@ -278,14 +285,14 @@ const gss_OID gpp_special_mech(const gss_OID mech_type)
if (mech_type == GSS_C_NO_OID) {
/* return the first special one if none specified */
if (item) {
- return (const gss_OID)&item->oid;
+ return (const gss_OID)&item->special_oid;
}
return GSS_C_NO_OID;
}
while (item) {
- if (gpp_special_equal(&item->oid, mech_type)) {
- return (const gss_OID)&item->oid;
+ if (gpp_special_equal(&item->special_oid, mech_type)) {
+ return (const gss_OID)&item->special_oid;
}
item = gpp_next_special_oids(item);
}
@@ -294,6 +301,26 @@ const gss_OID gpp_special_mech(const gss_OID mech_type)
return gpp_new_special_mech(mech_type);
}
+const gss_OID gpp_unspecial_mech(const gss_OID mech_type)
+{
+ struct gpp_special_oid_list *item = NULL;
+
+ if (!gpp_is_special_oid(mech_type)) {
+ return mech_type;
+ }
+
+ item = gpp_get_special_oids();
+ while (item) {
+ if (gss_oid_equal(&item->special_oid, mech_type)) {
+ return (const gss_OID)&item->regular_oid;
+ }
+ item = gpp_next_special_oids(item);
+ }
+
+ /* none matched */
+ return mech_type;
+}
+
gss_OID_set gpp_special_available_mechs(const gss_OID_set mechs)
{
gss_OID_set amechs = GSS_C_NO_OID_SET;
@@ -318,8 +345,9 @@ gss_OID_set gpp_special_available_mechs(const gss_OID_set mechs)
}
break;
}
- if (gpp_special_equal(&item->oid, &mechs->elements[i])) {
- maj = gss_add_oid_set_member(&min, &item->oid, &amechs);
+ if (gpp_special_equal(&item->special_oid, &mechs->elements[i])) {
+ maj = gss_add_oid_set_member(&min, &item->special_oid,
+ &amechs);
if (maj != GSS_S_COMPLETE) {
goto done;
}
@@ -362,7 +390,8 @@ OM_uint32 gssi_internal_release_oid(OM_uint32 *minor_status, gss_OID *oid)
item = gpp_get_special_oids();
while (item) {
- if (&item->oid == *oid) {
+ if ((&item->regular_oid == *oid) ||
+ (&item->special_oid == *oid)) {
*oid = GSS_C_NO_OID;
return GSS_S_COMPLETE;
}
diff --git a/proxy/src/mechglue/gss_plugin.h b/proxy/src/mechglue/gss_plugin.h
index 26e04c5..739ec26 100644
--- a/proxy/src/mechglue/gss_plugin.h
+++ b/proxy/src/mechglue/gss_plugin.h
@@ -78,6 +78,7 @@ gss_OID_set gss_mech_interposer(gss_OID mech_type);
enum gpp_behavior gpp_get_behavior(void);
bool gpp_is_special_oid(const gss_OID mech_type);
const gss_OID gpp_special_mech(const gss_OID mech_type);
+const gss_OID gpp_unspecial_mech(const gss_OID mech_type);
gss_OID_set gpp_special_available_mechs(const gss_OID_set mechs);
uint32_t gpp_map_error(uint32_t err);
uint32_t gpp_unmap_error(uint32_t err);