From 825b7f6cc96bb0f89d826500b6b6741eb701d1bf Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Thu, 24 Sep 1992 23:23:25 +0000 Subject: [PATCH] Made the conversion process more flexible by allowing making the realm conversion optional on a per-service basis. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@2398 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/krb/conv_princ.c | 97 ++++++++++++++++++++--------------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/src/lib/krb5/krb/conv_princ.c b/src/lib/krb5/krb/conv_princ.c index 340ec4894..0edb170f5 100644 --- a/src/lib/krb5/krb/conv_princ.c +++ b/src/lib/krb5/krb/conv_princ.c @@ -32,21 +32,32 @@ */ #include +#include struct krb_convert { char *v4_str; char *v5_str; + int flags; }; +#define DO_REALM_CONVERSION 0x00000001 + +/* + * Kadmin doesn't do realm conversion because it's currently + * kadmin/REALM.NAME. It should be kadmin/kerberos.master.host, but + * we'll fix that in the next release. + */ static struct krb_convert sconv_list[] = { - "rcmd", "host", - "discuss", "discuss", - "rvdsrv", "rvdsrv", - "olc", "olc", - "pop", "pop", - "sis", "sis", - "rfs", "rfs", - 0, 0, + "kadmin", "kadmin", 0, + "rcmd", "host", DO_REALM_CONVERSION, + "discuss", "discuss", DO_REALM_CONVERSION, + "rvdsrv", "rvdsrv", DO_REALM_CONVERSION, + "sample", "sample", DO_REALM_CONVERSION, + "olc", "olc", DO_REALM_CONVERSION, + "pop", "pop", DO_REALM_CONVERSION, + "sis", "sis", DO_REALM_CONVERSION, + "rfs", "rfs", DO_REALM_CONVERSION, + 0, 0, }; static struct krb_convert rconv_list[] = { @@ -56,43 +67,45 @@ static struct krb_convert rconv_list[] = { krb5_error_code krb5_425_conv_principal(name, instance, realm, princ) - const char *name; - const char *instance; - const char *realm; - krb5_principal *princ; + const char *name; + const char *instance; + const char *realm; + krb5_principal *princ; { - struct krb_convert *p; - char buf[256]; /* V4 instances are limited to 40 characters */ + struct krb_convert *p; + char buf[256]; /* V4 instances are limited to 40 characters */ - if (instance) { - if (instance[0] == '\0') { - instance = 0; - goto not_service; - } - p = sconv_list; - while (1) { - if (!p->v4_str) - goto not_service; - if (!strcmp(p->v4_str, name)) - break; - p++; - } - name = p->v5_str; - strcpy(buf, instance); - p = rconv_list; - while (1) { - if (!p->v4_str) - break; - if (!strcmp(p->v4_str, realm)) - break; - p++; - } - if (p->v5_str) - strcat(buf, p->v5_str); - instance = buf; + if (instance) { + if (instance[0] == '\0') { + instance = 0; + goto not_service; + } + p = sconv_list; + while (1) { + if (!p->v4_str) + goto not_service; + if (!strcmp(p->v4_str, name)) + break; + p++; + } + name = p->v5_str; + if (p->flags & DO_REALM_CONVERSION) { + strcpy(buf, instance); + p = rconv_list; + while (1) { + if (!p->v4_str) + break; + if (!strcmp(p->v4_str, realm)) + break; + p++; + } + if (p->v5_str) + strcat(buf, p->v5_str); + instance = buf; + } } -not_service: + not_service: return(krb5_build_principal(princ, strlen(realm), realm, name, instance, 0)); -} + } -- 2.26.2