svn rev #23538: trunk/src/lib/krb5/krb/
tsitkova@MIT.EDU
tsitkova at MIT.EDU
Tue Dec 29 15:30:29 EST 2009
http://src.mit.edu/fisheye/changelog/krb5/?cs=23538
Commit By: tsitkova
Log Message:
Create a separate file for krb5_copy_context for better code modularity.
Changed Files:
U trunk/src/lib/krb5/krb/Makefile.in
A trunk/src/lib/krb5/krb/copy_ctx.c
U trunk/src/lib/krb5/krb/init_ctx.c
Modified: trunk/src/lib/krb5/krb/Makefile.in
===================================================================
--- trunk/src/lib/krb5/krb/Makefile.in 2009-12-29 20:08:42 UTC (rev 23537)
+++ trunk/src/lib/krb5/krb/Makefile.in 2009-12-29 20:30:29 UTC (rev 23538)
@@ -55,6 +55,7 @@
gic_pwd.o \
in_tkt_sky.o \
init_ctx.o \
+ copy_ctx.o \
init_keyblock.o \
kdc_rep_dc.o \
kerrs.o \
@@ -148,6 +149,7 @@
$(OUTPRE)gic_pwd.$(OBJEXT) \
$(OUTPRE)in_tkt_sky.$(OBJEXT) \
$(OUTPRE)init_ctx.$(OBJEXT) \
+ $(OUTPRE)copy_ctx.$(OBJEXT) \
$(OUTPRE)init_keyblock.$(OBJEXT) \
$(OUTPRE)kdc_rep_dc.$(OBJEXT) \
$(OUTPRE)kerrs.$(OBJEXT) \
@@ -242,6 +244,7 @@
$(srcdir)/gic_pwd.c \
$(srcdir)/in_tkt_sky.c \
$(srcdir)/init_ctx.c \
+ $(srcdir)/copy_ctx.c \
$(srcdir)/init_keyblock.c \
$(srcdir)/kdc_rep_dc.c \
$(srcdir)/kerrs.c \
Added: trunk/src/lib/krb5/krb/copy_ctx.c
===================================================================
--- trunk/src/lib/krb5/krb/copy_ctx.c (rev 0)
+++ trunk/src/lib/krb5/krb/copy_ctx.c 2009-12-29 20:30:29 UTC (rev 23538)
@@ -0,0 +1,138 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * lib/krb5/krb/copy_ctx.c
+ *
+ * Copyright 1994,1999,2000, 2002, 2003, 2007, 2008, 2009 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ * krb5_copy_contex()
+ */
+
+/*
+ * Copyright (C) 1998 by the FundsXpress, INC.
+ *
+ * All rights reserved.
+ *
+ * Export of this software from the United States of America may require
+ * a specific license from the United States Government. It is the
+ * responsibility of any person or organization contemplating export to
+ * obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of FundsXpress. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. FundsXpress makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include "k5-int.h"
+#include <ctype.h>
+
+/* Copy the zero-terminated enctype list old_list into *new_list. */
+static krb5_error_code
+copy_enctypes(krb5_context context, const krb5_enctype *old_list,
+ krb5_enctype **new_list)
+{
+ unsigned int count;
+ krb5_enctype *list;
+
+ *new_list = NULL;
+ for (count = 0; old_list[count]; count++);
+ list = malloc(sizeof(krb5_enctype) * (count + 1));
+ if (list == NULL)
+ return ENOMEM;
+ memcpy(list, old_list, sizeof(krb5_enctype) * (count + 1));
+ *new_list = list;
+ return 0;
+}
+
+krb5_error_code KRB5_CALLCONV
+krb5_copy_context(krb5_context ctx, krb5_context *nctx_out)
+{
+ krb5_error_code ret;
+ krb5_context nctx;
+
+ *nctx_out = NULL;
+ if (ctx == NULL)
+ return EINVAL; /* XXX */
+
+ nctx = malloc(sizeof(*nctx));
+ if (nctx == NULL)
+ return ENOMEM;
+
+ *nctx = *ctx;
+
+ nctx->in_tkt_etypes = NULL;
+ nctx->tgs_etypes = NULL;
+ nctx->default_realm = NULL;
+ nctx->profile = NULL;
+ nctx->dal_handle = NULL;
+ nctx->ser_ctx_count = 0;
+ nctx->ser_ctx = NULL;
+ nctx->prompt_types = NULL;
+ nctx->os_context.default_ccname = NULL;
+
+ memset(&nctx->preauth_plugins, 0, sizeof(nctx->preauth_plugins));
+ nctx->preauth_context = NULL;
+
+ memset(&nctx->libkrb5_plugins, 0, sizeof(nctx->libkrb5_plugins));
+ nctx->vtbl = NULL;
+ nctx->locate_fptrs = NULL;
+
+ memset(&nctx->err, 0, sizeof(nctx->err));
+
+ ret = copy_enctypes(nctx, ctx->in_tkt_etypes, &nctx->in_tkt_etypes);
+ if (ret)
+ goto errout;
+ ret = copy_enctypes(nctx, ctx->tgs_etypes, &nctx->tgs_etypes);
+ if (ret)
+ goto errout;
+
+ if (ctx->os_context.default_ccname != NULL) {
+ nctx->os_context.default_ccname =
+ strdup(ctx->os_context.default_ccname);
+ if (nctx->os_context.default_ccname == NULL) {
+ ret = ENOMEM;
+ goto errout;
+ }
+ }
+ ret = krb5_get_profile(ctx, &nctx->profile);
+ if (ret)
+ goto errout;
+
+errout:
+ if (ret) {
+ krb5_free_context(nctx);
+ } else {
+ *nctx_out = nctx;
+ }
+ return ret;
+}
Modified: trunk/src/lib/krb5/krb/init_ctx.c
===================================================================
--- trunk/src/lib/krb5/krb/init_ctx.c 2009-12-29 20:08:42 UTC (rev 23537)
+++ trunk/src/lib/krb5/krb/init_ctx.c 2009-12-29 20:30:29 UTC (rev 23538)
@@ -584,66 +584,3 @@
return(ret);
}
-
-krb5_error_code KRB5_CALLCONV
-krb5_copy_context(krb5_context ctx, krb5_context *nctx_out)
-{
- krb5_error_code ret;
- krb5_context nctx;
-
- *nctx_out = NULL;
- if (ctx == NULL)
- return EINVAL; /* XXX */
-
- nctx = malloc(sizeof(*nctx));
- if (nctx == NULL)
- return ENOMEM;
-
- *nctx = *ctx;
-
- nctx->in_tkt_etypes = NULL;
- nctx->tgs_etypes = NULL;
- nctx->default_realm = NULL;
- nctx->profile = NULL;
- nctx->dal_handle = NULL;
- nctx->ser_ctx_count = 0;
- nctx->ser_ctx = NULL;
- nctx->prompt_types = NULL;
- nctx->os_context.default_ccname = NULL;
-
- memset(&nctx->preauth_plugins, 0, sizeof(nctx->preauth_plugins));
- nctx->preauth_context = NULL;
-
- memset(&nctx->libkrb5_plugins, 0, sizeof(nctx->libkrb5_plugins));
- nctx->vtbl = NULL;
- nctx->locate_fptrs = NULL;
-
- memset(&nctx->err, 0, sizeof(nctx->err));
-
- ret = copy_enctypes(nctx, ctx->in_tkt_etypes, &nctx->in_tkt_etypes);
- if (ret)
- goto errout;
- ret = copy_enctypes(nctx, ctx->tgs_etypes, &nctx->tgs_etypes);
- if (ret)
- goto errout;
-
- if (ctx->os_context.default_ccname != NULL) {
- nctx->os_context.default_ccname =
- strdup(ctx->os_context.default_ccname);
- if (nctx->os_context.default_ccname == NULL) {
- ret = ENOMEM;
- goto errout;
- }
- }
- ret = krb5_get_profile(ctx, &nctx->profile);
- if (ret)
- goto errout;
-
-errout:
- if (ret) {
- krb5_free_context(nctx);
- } else {
- *nctx_out = nctx;
- }
- return ret;
-}
More information about the cvs-krb5
mailing list