Prepare for new context format by splitting out the old "v1" context processing function. From: J. Bruce Fields Signed-off-by: Kevin Coffman ---------- net/sunrpc/auth_gss/gss_krb5_mech.c | 62 +++++++++++++++++++++++------------ 1 files changed, 40 insertions(+), 22 deletions(-) diff -up linux-2.6.29.noarch/net/sunrpc/auth_gss/gss_krb5_mech.c.orig linux-2.6.29.noarch/net/sunrpc/auth_gss/gss_krb5_mech.c --- linux-2.6.29.noarch/net/sunrpc/auth_gss/gss_krb5_mech.c.orig 2009-04-30 15:26:35.904693000 -0400 +++ linux-2.6.29.noarch/net/sunrpc/auth_gss/gss_krb5_mech.c 2009-04-30 15:40:41.715920000 -0400 @@ -123,9 +123,7 @@ out_err: } static int -gss_import_sec_context_kerberos(const void *p, - size_t len, - struct gss_ctx *ctx_id) +gss_import_v1_context(const void *p, const void *end, struct krb5_ctx *ctx) { const void *end = (const void *)((const char *)p + len); struct krb5_ctx *ctx; @@ -137,7 +135,10 @@ gss_import_sec_context_kerberos(const vo p = simple_get_bytes(p, end, &ctx->initiate, sizeof(ctx->initiate)); if (IS_ERR(p)) goto out_err_free_ctx; + + /* Old format supports only DES! Any other enctype uses new format */ ctx->enctype = ENCTYPE_DES_CBC_RAW; + /* The downcall format was designed before we completely understood * the uses of the context fields; so it includes some stuff we * just give some minimal sanity-checking, and some we ignore @@ -179,9 +180,6 @@ gss_import_sec_context_kerberos(const vo goto out_err_free_key2; } - ctx_id->internal_ctx_id = ctx; - - dprintk("RPC: Successfully imported new context.\n"); return 0; out_err_free_key2: @@ -190,12 +188,37 @@ out_err_free_key1: crypto_free_blkcipher(ctx->enc); out_err_free_mech: kfree(ctx->mech_used.data); -out_err_free_ctx: - kfree(ctx); out_err: return PTR_ERR(p); } +static int +gss_import_sec_context_kerberos(const void *p, size_t len, + struct gss_ctx *ctx_id) +{ + const void *end = (const void *)((const char *)p + len); + struct krb5_ctx *ctx; + int ret; + + ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); + if (ctx == NULL) + return -ENOMEM; + memset(ctx, 0, sizeof(*ctx)); + + if (len == 85) + ret = gss_import_v1_context(p, end, ctx); + else + ret = -EINVAL; + + if (ret == 0) + ctx_id->internal_ctx_id = ctx; + else + kfree(ctx); + + dprintk("RPC: %s: returning %d\n", __func__, ret); + return ret; +} + static void gss_delete_sec_context_kerberos(void *internal_ctx) { struct krb5_ctx *kctx = internal_ctx;