5 * Copyright 1990 by the Massachusetts Institute of Technology.
8 * For copying and distribution information, please see the file
11 * Registration functions for keytab.
14 #if !defined(lint) && !defined(SABER)
15 static char rcsid_ktbase_c[] =
17 #endif /* !lint & !SABER */
19 #include <krb5/krb5.h>
20 #include <krb5/ext-proto.h>
22 struct krb5_kt_typelist
25 struct krb5_kt_typelist *next;
27 static struct krb5_kt_typelist krb5_kt_typelist_dfl = { &krb5_kt_dfl_ops, 0 };
28 static struct krb5_kt_typelist *kt_typehead = &krb5_kt_typelist_dfl;
31 * Register a new key table type
32 * don't replace if it already exists; return an error instead.
39 struct krb5_kt_typelist *t;
40 for (t = kt_typehead;t && strcmp(t->ops->prefix,ops->prefix);t = t->next)
43 return KRB5_KT_TYPE_EXISTS;
45 if (!(t = (struct krb5_kt_typelist *) malloc(sizeof(*t))))
47 t->next = kt_typehead;
54 * Resolve a key table name into a keytab object.
56 * The name is currently constrained to be of the form "type:residual";
58 * The "type" portion corresponds to one of the registered key table
59 * types, while the "residual" portion is specific to the
60 * particular keytab type.
63 krb5_error_code krb5_kt_resolve (name, ktid)
67 struct krb5_kt_typelist *tlist;
68 char *pfx, *resid, *cp;
71 cp = strchr (name, ':');
73 return KRB5_KT_BADNAME;
75 pfxlen = cp - (char *)name;
76 resid = (char *)name + pfxlen + 1;
78 pfx = malloc (pfxlen+1);
82 memcpy (pfx, name, pfxlen);
85 *ktid = (krb5_keytab) 0;
87 for (tlist = kt_typehead; tlist; tlist = tlist->next) {
88 if (strcmp (tlist->ops->prefix, pfx) == 0) {
90 return (*tlist->ops->resolve)(resid, ktid);
94 return KRB5_KT_UNKNOWN_TYPE;