use new krb5_sname_to_principal
authorJohn Kohl <jtkohl@mit.edu>
Thu, 21 Mar 1991 13:55:56 +0000 (13:55 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Thu, 21 Mar 1991 13:55:56 +0000 (13:55 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1942 dc483132-0cff-0310-8789-dd5450dbe970

src/appl/movemail/movemail.c

index 4ff3d342c2507d684e41cf42c2b5c5ba6c94ee5f..1bf9bb88fb8dbf3daaed8b9e06cd46ee88e30a91 100644 (file)
@@ -350,6 +350,7 @@ xmalloc (size)
 #include <des.h>
 #endif /* KRB4 */
 #ifdef KRB5
+#include <krb5/los-proto.h>
 #include <com_err.h>
 #include <ctype.h>
 #endif /* KRB5 */
@@ -507,12 +508,9 @@ char *host;
 #endif /* KRB4 */
 #ifdef KRB5
     krb5_error_code retval;
-    char **hrealms;
-    krb5_data aserver[3], *server[4];
     krb5_ccache ccdef;
-    krb5_principal client;
+    krb5_principal client, server;
     krb5_error *err_ret;
-    char *remote_host;
     register char *cp;
 #endif /* KRB5 */
 #endif /* KERBEROS */
@@ -584,29 +582,18 @@ char *host;
        goto krb5error;
     }
 
-    /* copy the hostname into non-volatile storage */
-    remote_host = malloc(strlen(hp->h_name) + 1);
-    (void) strcpy(remote_host, hp->h_name);
-
-    if (retval = krb5_get_host_realm(remote_host, &hrealms)) {
-       goto krb5error;
-    }
-
     /* lower-case to get name for "instance" part of service name */
-    for (cp = remote_host; *cp; cp++)
+    for (cp = hp->h_name; *cp; cp++)
        if (isupper(*cp))
            *cp = tolower(*cp);
 
-    aserver[0].length = strlen(hrealms[0]);
-    aserver[0].data = hrealms[0];
-    aserver[1].length = strlen(POP_SERVICE);
-    aserver[1].data = POP_SERVICE;
-    aserver[2].length = strlen(remote_host);
-    aserver[2].data = remote_host;
-    server[0] = &aserver[0];
-    server[1] = &aserver[1];
-    server[2] = &aserver[2];
-    server[3] = 0;
+    if (retval = krb5_sname_to_principal(hp->h_name, POP_SERVICE,
+                                        FALSE, /* FALSE means don't
+                                                  canonicalize hostname
+                                                  (we already have...) */
+                                        &server)) {
+       goto krb5error;
+    }
 
     retval = krb5_sendauth((krb5_pointer) &s, "KPOPV1.0", client, server,
                           AP_OPTS_MUTUAL_REQUIRED,