Made the conversion process more flexible by allowing making the realm
authorTheodore Tso <tytso@mit.edu>
Thu, 24 Sep 1992 23:23:25 +0000 (23:23 +0000)
committerTheodore Tso <tytso@mit.edu>
Thu, 24 Sep 1992 23:23:25 +0000 (23:23 +0000)
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

index 340ec4894ea11761482757d6c572da632cbba45d..0edb170f5415bc5e4f5f00043960d79c42f7cdbb 100644 (file)
  */
 
 #include <krb5/krb5.h>
+#include <string.h>
 
 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));
-}
+    }