]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Add SPI calls to import objects by mech oid
authorSimo Sorce <simo@redhat.com>
Tue, 28 Aug 2012 14:47:23 +0000 (16:47 +0200)
committerGreg Hudson <ghudson@mit.edu>
Tue, 2 Oct 2012 04:54:36 +0000 (00:54 -0400)
An interposer mech needs to be able to handle multiple mechanisms.
When importing a mech token for a name, cred, or context, the
interposer mech needs to know the mech type of the token being
imported.  To make this work, add SPI calls which accept a mech type
argument.

[ghudson@mit.edu: Stylistic changes, commit squashing, commit message]

src/lib/gssapi/mechglue/g_glue.c
src/lib/gssapi/mechglue/g_imp_cred.c
src/lib/gssapi/mechglue/g_imp_name.c
src/lib/gssapi/mechglue/g_imp_sec_context.c
src/lib/gssapi/mechglue/g_initialize.c
src/lib/gssapi/mechglue/mglueP.h

index e9ff4c8075a204761a8a5b94221915e475160a66..e438a032caf0e5fb868b1160a2e9c33111a35b7e 100644 (file)
@@ -358,6 +358,7 @@ gss_name_t  *internal_name;
 {
     OM_uint32          status, tmpMinor;
     gss_mechanism      mech;
+    gss_OID            public_mech;
 
     mech = gssint_get_mechanism (mech_type);
     if (mech == NULL)
@@ -381,13 +382,19 @@ gss_name_t        *internal_name;
        }
     }
 
-    if (mech->gss_import_name == NULL)
+    if (mech->gssspi_import_name_by_mech) {
+       public_mech = gssint_get_public_oid(mech_type);
+       status = mech->gssspi_import_name_by_mech(minor_status, public_mech,
+                                                 union_name->external_name,
+                                                 union_name->name_type,
+                                                 internal_name);
+    } else if (mech->gss_import_name) {
+       status = mech->gss_import_name(minor_status, union_name->external_name,
+                                      union_name->name_type, internal_name);
+    } else {
        return (GSS_S_UNAVAILABLE);
+    }
 
-    status = mech->gss_import_name(minor_status,
-                                  union_name->external_name,
-                                  union_name->name_type,
-                                  internal_name);
     if (status == GSS_S_COMPLETE) {
         /* Attempt to round-trip attributes */
        (void) import_internal_attributes(&tmpMinor, mech,
index 1611daf043a38465e331786f0a833788195c58a3..77e2ff55ce574f1e1aafd9196df7248beaa30379 100644 (file)
@@ -134,11 +134,19 @@ gss_import_cred(OM_uint32 *minor_status, gss_buffer_t token,
         if (status != GSS_S_COMPLETE)
             goto error;
         mech = gssint_get_mechanism(selected_mech);
-        if (mech == NULL || mech->gss_import_cred == NULL) {
+        if (mech == NULL || (mech->gss_import_cred == NULL &&
+                             mech->gssspi_import_cred_by_mech == NULL)) {
             status = GSS_S_DEFECTIVE_TOKEN;
             goto error;
         }
-        status = mech->gss_import_cred(minor_status, &mech_token, &mech_cred);
+        if (mech->gssspi_import_cred_by_mech) {
+            status = mech->gssspi_import_cred_by_mech(minor_status,
+                                        gssint_get_public_oid(selected_mech),
+                                        &mech_token, &mech_cred);
+        } else {
+            status = mech->gss_import_cred(minor_status, &mech_token,
+                                           &mech_cred);
+        }
         if (status != GSS_S_COMPLETE) {
             map_error(minor_status, mech);
             goto error;
index 8fcc3d0f267ae49e1e3fc939a3579425a9d713c3..b2c5091fde1b1eb7967afe6f43fbb1280ec51c08 100644 (file)
@@ -250,7 +250,8 @@ importExportName(minor, unionName)
     if ((mech = gssint_get_mechanism(&mechOid)) == NULL)
        return (GSS_S_BAD_MECH);
 
-    if (mech->gss_import_name == NULL)
+    if (mech->gssspi_import_name_by_mech == NULL &&
+       mech->gss_import_name == NULL)
        return (GSS_S_UNAVAILABLE);
 
     /*
@@ -260,9 +261,15 @@ importExportName(minor, unionName)
      * have created it.
      */
     if (mech->gss_export_name) {
-       major = mech->gss_import_name(minor,
-                                     &expName, (gss_OID)GSS_C_NT_EXPORT_NAME,
-                                     &unionName->mech_name);
+       if (mech->gssspi_import_name_by_mech) {
+           major = mech->gssspi_import_name_by_mech(minor, &mechOid, &expName,
+                                                    GSS_C_NT_EXPORT_NAME,
+                                                    &unionName->mech_name);
+       } else {
+           major = mech->gss_import_name(minor, &expName,
+                                         GSS_C_NT_EXPORT_NAME,
+                                         &unionName->mech_name);
+       }
        if (major != GSS_S_COMPLETE)
            map_error(minor, mech);
        else {
@@ -358,8 +365,14 @@ importExportName(minor, unionName)
      */
     expName.length = nameLen;
     expName.value = nameLen ? (void *)buf : NULL;
-    major = mech->gss_import_name(minor, &expName,
-                                 GSS_C_NULL_OID, &unionName->mech_name);
+    if (mech->gssspi_import_name_by_mech) {
+       major = mech->gssspi_import_name_by_mech(minor, &mechOid, &expName,
+                                                GSS_C_NULL_OID,
+                                                &unionName->mech_name);
+    } else {
+       major = mech->gss_import_name(minor, &expName,
+                                     GSS_C_NULL_OID, &unionName->mech_name);
+    }
     if (major != GSS_S_COMPLETE) {
        map_error(minor, mech);
        return (major);
index 8207488aaa3667ea00a40ed56ac0e9310bc409ae..53310ddcea791a901b787e94b760fc8217c45549 100644 (file)
@@ -82,8 +82,10 @@ gss_ctx_id_t *               context_handle;
     OM_uint32          status;
     char               *p;
     gss_union_ctx_id_t ctx;
+    gss_ctx_id_t       mctx;
     gss_buffer_desc    token;
     gss_OID            selected_mech = GSS_C_NO_OID;
+    gss_OID            public_mech;
     gss_mechanism      mech;
 
     status = val_imp_sec_ctx_args(minor_status,
@@ -144,15 +146,22 @@ gss_ctx_id_t *            context_handle;
        status = GSS_S_BAD_MECH;
        goto error_out;
     }
-    if (!mech->gss_import_sec_context) {
+    if (!mech->gssspi_import_sec_context_by_mech &&
+       !mech->gss_import_sec_context) {
        status = GSS_S_UNAVAILABLE;
        goto error_out;
     }
 
-    status = mech->gss_import_sec_context(minor_status,
-                                         &token, &ctx->internal_ctx_id);
-
+    if (mech->gssspi_import_sec_context_by_mech) {
+       public_mech = gssint_get_public_oid(selected_mech);
+       status = mech->gssspi_import_sec_context_by_mech(minor_status,
+                                                        public_mech,
+                                                        &token, &mctx);
+    } else {
+       status = mech->gss_import_sec_context(minor_status, &token, &mctx);
+    }
     if (status == GSS_S_COMPLETE) {
+       ctx->internal_ctx_id = mctx;
        ctx->loopback = ctx;
        *context_handle = (gss_ctx_id_t)ctx;
        return (GSS_S_COMPLETE);
index fbd0b07e63320047271a8d484735517cf38ce1aa..b4cc4da6281108477f65b4588a80fbb5f241b944 100644 (file)
@@ -690,6 +690,9 @@ build_dynamicMech(void *dl, const gss_OID mech_type)
         /* RFC 5587 */
         GSS_ADD_DYNAMIC_METHOD_NOLOOP(dl, mech, gss_inquire_attrs_for_mech);
        GSS_ADD_DYNAMIC_METHOD(dl, mech, gssspi_acquire_cred_with_password);
+       GSS_ADD_DYNAMIC_METHOD(dl, mech, gssspi_import_sec_context_by_mech);
+       GSS_ADD_DYNAMIC_METHOD(dl, mech, gssspi_import_name_by_mech);
+       GSS_ADD_DYNAMIC_METHOD(dl, mech, gssspi_import_cred_by_mech);
 
        assert(mech_type != GSS_C_NO_OID);
 
@@ -785,6 +788,9 @@ build_interMech(void *dl, const gss_OID mech_type)
        /* RFC 5587 */
        RESOLVE_GSSI_SYMBOL(dl, mech, gss, _inquire_attrs_for_mech);
        RESOLVE_GSSI_SYMBOL(dl, mech, gssspi, _acquire_cred_with_password);
+       RESOLVE_GSSI_SYMBOL(dl, mech, gssspi, _import_sec_context_by_mech);
+       RESOLVE_GSSI_SYMBOL(dl, mech, gssspi, _import_name_by_mech);
+       RESOLVE_GSSI_SYMBOL(dl, mech, gssspi, _import_cred_by_mech);
 
        mech->mech_type = *mech_type;
        return mech;
index 2d0fd4a834bc0b873e0169113fe9ed69829a9991..9e02474a82d8f1dcd0304c54d333c9ca19bd61fb 100644 (file)
@@ -649,6 +649,31 @@ typedef struct gss_config {
                gss_cred_id_t *         /* cred_handle */
        /* */);
 
+       OM_uint32       (KRB5_CALLCONV *gssspi_import_sec_context_by_mech)
+       (
+           OM_uint32 *,                /* minor_status */
+           gss_OID,                    /* desired_mech */
+           gss_buffer_t,               /* interprocess_token */
+           gss_ctx_id_t *              /* context_handle */
+       /* */);
+
+       OM_uint32       (KRB5_CALLCONV *gssspi_import_name_by_mech)
+       (
+           OM_uint32 *,                /* minor_status */
+           gss_OID,                    /* mech_type */
+           gss_buffer_t,               /* input_name_buffer */
+           gss_OID,                    /* input_name_type */
+           gss_name_t*                 /* output_name */
+       /* */);
+
+       OM_uint32       (KRB5_CALLCONV *gssspi_import_cred_by_mech)
+       (
+           OM_uint32 *,                /* minor_status */
+           gss_OID,                    /* mech_type */
+           gss_buffer_t,               /* token */
+           gss_cred_id_t *             /* cred_handle */
+       /* */);
+
 } *gss_mechanism;
 
 /*