5 * Copyright 1990 by the Massachusetts Institute of Technology.
8 * Export of this software from the United States of America is assumed
9 * to require a specific license from the United States Government.
10 * It is the responsibility of any person or organization contemplating
11 * export to obtain such a license before exporting.
13 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
14 * distribute this software and its documentation for any purpose and
15 * without fee is hereby granted, provided that the above copyright
16 * notice appear in all copies and that both that copyright notice and
17 * this permission notice appear in supporting documentation, and that
18 * the name of M.I.T. not be used in advertising or publicity pertaining
19 * to distribution of the software without specific, written prior
20 * permission. M.I.T. makes no representations about the suitability of
21 * this software for any purpose. It is provided "as is" without express
22 * or implied warranty.
25 * Registration functions for keytab.
28 #if !defined(lint) && !defined(SABER)
29 static char rcsid_ktbase_c[] =
31 #endif /* !lint & !SABER */
33 #include <krb5/krb5.h>
34 #include <krb5/ext-proto.h>
36 struct krb5_kt_typelist
39 struct krb5_kt_typelist *next;
41 static struct krb5_kt_typelist krb5_kt_typelist_dfl = { &krb5_kt_dfl_ops, 0 };
42 static struct krb5_kt_typelist *kt_typehead = &krb5_kt_typelist_dfl;
45 * Register a new key table type
46 * don't replace if it already exists; return an error instead.
53 struct krb5_kt_typelist *t;
54 for (t = kt_typehead;t && strcmp(t->ops->prefix,ops->prefix);t = t->next)
57 return KRB5_KT_TYPE_EXISTS;
59 if (!(t = (struct krb5_kt_typelist *) malloc(sizeof(*t))))
61 t->next = kt_typehead;
68 * Resolve a key table name into a keytab object.
70 * The name is currently constrained to be of the form "type:residual";
72 * The "type" portion corresponds to one of the registered key table
73 * types, while the "residual" portion is specific to the
74 * particular keytab type.
77 krb5_error_code krb5_kt_resolve (name, ktid)
81 struct krb5_kt_typelist *tlist;
82 char *pfx, *resid, *cp;
85 cp = strchr (name, ':');
87 return KRB5_KT_BADNAME;
89 pfxlen = cp - (char *)name;
90 resid = (char *)name + pfxlen + 1;
92 pfx = malloc (pfxlen+1);
96 memcpy (pfx, name, pfxlen);
99 *ktid = (krb5_keytab) 0;
101 for (tlist = kt_typehead; tlist; tlist = tlist->next) {
102 if (strcmp (tlist->ops->prefix, pfx) == 0) {
104 return (*tlist->ops->resolve)(resid, ktid);
108 return KRB5_KT_UNKNOWN_TYPE;