aklog-attempt-order-comments-20081029
[openafs.git] / src / aklog / aklog_main.c
index a33314c..f16c730 100644 (file)
@@ -453,7 +453,27 @@ static int auth_to_cell(krb5_context context, char *cell, char *realm)
        retry = 1;
        
        while(retry) {
-           
+
+           /* This code tries principals in the following, much debated,
+            * order:
+            * 
+            * If the realm is specified on the command line we do
+            *    - afs/cell@COMMAND-LINE-REALM
+            *    - afs@COMMAND-LINE-REALM
+            * 
+            * Otherwise, we do
+            *    - afs/cell@REALM-FROM-USERS-PRINCIPAL
+            *    - afs/cell@krb5_get_host_realm(db-server)
+            *   Then, if krb5_get_host_realm(db-server) is non-empty
+            *      - afs@ krb5_get_host_realm(db-server)
+            *   Otherwise
+            *      - afs/cell@ upper-case-domain-of-db-server
+            *      - afs@ upper-case-domain-of-db-server
+            * 
+            * In all cases, the 'afs@' variant is only tried where the
+            * cell and the realm match case-insensitively.
+            */
+               
            /* Cell on command line - use that one */
            if (realm && realm[0]) {
                realm_of_cell = realm;
@@ -518,8 +538,10 @@ static int auth_to_cell(krb5_context context, char *cell, char *realm)
                                    "%s.\n", progname, cell_to_use);
                            exit(AKLOG_MISC);
                        }
-                       printf("We've deduced that we need to authenticate to"
-                              " realm %s.\n", realm_of_cell);
+                       if (dflag) {
+                           printf("We've deduced that we need to authenticate"
+                                  " to realm %s.\n", realm_of_cell);
+                       }
                    }
                    status = get_credv5(context, AFSKEY, cell_to_use, 
                                        realm_of_cell, &v5cred);
@@ -1820,8 +1842,8 @@ static krb5_error_code get_credv5(krb5_context context,
     static krb5_principal client_principal = 0;
 
     if (dflag) {
-       printf("Getting tickets: %s%s%s@%s\n", name, inst[0] ? "/" : "",
-              inst, realm);
+       printf("Getting tickets: %s%s%s@%s\n", name, (inst && inst[0])
+              ? "/" : "", inst ? inst : "", realm);
     }
     
     memset((char *)&increds, 0, sizeof(increds));