* conv_princ.c (struct krb_convert): Add new field 'len'.
authorKen Raeburn <raeburn@mit.edu>
Fri, 12 Apr 2002 08:21:17 +0000 (08:21 +0000)
committerKen Raeburn <raeburn@mit.edu>
Fri, 12 Apr 2002 08:21:17 +0000 (08:21 +0000)
(RC, R, NR): New macros.
(sconv_list): Use them.
(krb5_524_conv_principal): Compare lengths and then use memcmp.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14391 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/ChangeLog
src/lib/krb5/krb/conv_princ.c

index 9e062c3e7b20686ac77bda56adca73ce5e499abe..4a1a765205ad636e03abd31c632da45959808d68 100644 (file)
@@ -1,3 +1,10 @@
+2002-04-12  Ken Raeburn  <raeburn@mit.edu>
+
+       * conv_princ.c (struct krb_convert): Add new field 'len'.
+       (RC, R, NR): New macros.
+       (sconv_list): Use them.
+       (krb5_524_conv_principal): Compare lengths and then use memcmp.
+
 2002-04-05  Ken Raeburn  <raeburn@mit.edu>
 
        * decrypt_tk.c (krb5_decrypt_tkt_part): Call krb5_c_valid_enctype
index 5c1853c4a8ce87e892ae063726a50bd2c9a67132..e6595817a9f50e3ecd67e82b082903974de5cff8 100644 (file)
 #define                INST_SZ         40
 
 struct krb_convert {
-       char    *v4_str;
-       char    *v5_str;
-       int     flags;
+    char               *v4_str;
+    char               *v5_str;
+    unsigned int       flags : 8;
+    unsigned int       len : 8;
 };
 
 #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.
+ * kadmin/REALM.NAME.  Zephyr doesn't because it's just zephyr/zephyr.
+ *
+ * "Realm conversion" is a bit of a misnomer; really, the v5 name is
+ * using a FQDN or something that looks like it, where the v4 name is
+ * just using the first label.  Sometimes that second principal name
+ * component is a hostname, sometimes the realm name, sometimes it's
+ * neither.
+ *
+ * This list should probably be more configurable, and more than
+ * likely on a per-realm basis, so locally-defined services can be
+ * added, or not.
  */
 static const struct krb_convert sconv_list[] = {
-    {"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},
-    {"imap",   "imap",         DO_REALM_CONVERSION},
-    {"ftp",    "ftp",          DO_REALM_CONVERSION},
-    {"ecat",   "ecat",         DO_REALM_CONVERSION},
-    {"daemon",        "daemon",       DO_REALM_CONVERSION},
-    {"gnats", "gnats",        DO_REALM_CONVERSION},
-    {"moira", "moira",        DO_REALM_CONVERSION},
-    {"prms",  "prms",         DO_REALM_CONVERSION},
-    {"mandarin",      "mandarin",     DO_REALM_CONVERSION},
-    {"register",      "register",     DO_REALM_CONVERSION},
-    {"changepw",      "changepw",     DO_REALM_CONVERSION},
-    {"sms",   "sms",          DO_REALM_CONVERSION},
-    {"afpserver",     "afpserver",    DO_REALM_CONVERSION},
-    {"gdss",  "gdss",         DO_REALM_CONVERSION},
-    {"news",  "news",         DO_REALM_CONVERSION},
-    {"abs",   "abs",          DO_REALM_CONVERSION},
-    {"nfs",   "nfs",          DO_REALM_CONVERSION},
-    {"tftp",  "tftp",         DO_REALM_CONVERSION},
-    {"zephyr",        "zephyr",       0},
-    {"http",  "http",         DO_REALM_CONVERSION},
-    {"khttp", "khttp",        DO_REALM_CONVERSION},
-    {"pgpsigner", "pgpsigner",        DO_REALM_CONVERSION},
-    {"irc",   "irc",          DO_REALM_CONVERSION},
-    {"mandarin-agent",        "mandarin-agent",       DO_REALM_CONVERSION},
-    {"write", "write",        DO_REALM_CONVERSION},
-    {"palladium", "palladium",        DO_REALM_CONVERSION},
-    {0,                0,              0},
+    /* Realm conversion, Change service name */
+#define RC(V5NAME,V4NAME) { V5NAME, V4NAME, DO_REALM_CONVERSION, sizeof(V5NAME)-1 }
+    /* Realm conversion */
+#define R(NAME)                { NAME, NAME, DO_REALM_CONVERSION, sizeof(NAME)-1 }
+    /* No Realm conversion */
+#define NR(NAME)       { NAME, NAME, 0, sizeof(NAME)-1 }
+
+    NR("kadmin"),
+    RC("rcmd", "host"),
+    R("discuss"),
+    R("rvdsrv"),
+    R("sample"),
+    R("olc"),
+    R("pop"),
+    R("sis"),
+    R("rfs"),
+    R("imap"),
+    R("ftp"),
+    R("ecat"),
+    R("daemon"),
+    R("gnats"),
+    R("moira"),
+    R("prms"),
+    R("mandarin"),
+    R("register"),
+    R("changepw"),
+    R("sms"),
+    R("afpserver"),
+    R("gdss"),
+    R("news"),
+    R("abs"),
+    R("nfs"),
+    R("tftp"),
+    NR("zephyr"),
+    R("http"),
+    R("khttp"),
+    R("pgpsigner"),
+    R("irc"),
+    R("mandarin-agent"),
+    R("write"),
+    R("palladium"),
+    {0, 0, 0, 0},
+#undef R
+#undef RC
+#undef NR
 };
 
 /*
@@ -148,7 +168,8 @@ krb5_524_conv_principal(context, princ, name, inst, realm)
          compo = krb5_princ_component(context, princ, 0);
          p = sconv_list;
          while (p->v4_str) {
-              if (strncmp(p->v5_str, compo->data, compo->length) == 0) {
+              if (p->len == compo->length
+                  && memcmp(p->v5_str, compo->data, compo->length) == 0) {
                   /*
                    * It is, so set the new name now, and chop off
                    * instance's domain name if requested.