]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Use correct default principal for kadmin -n
authorGreg Hudson <ghudson@mit.edu>
Mon, 28 Oct 2013 17:33:05 +0000 (13:33 -0400)
committerGreg Hudson <ghudson@mit.edu>
Wed, 30 Oct 2013 16:31:00 +0000 (12:31 -0400)
Use WELLKNOWN/ANONYMOUS@realm as the default principal for kadmin -n,
just like we do for kinit -n.

ticket: 7741 (new)
target_version: 1.12
tags: pullup

src/kadmin/cli/kadmin.c

index b2b464b058cc92fe81eb01fa8f342531c8c0a571..f5ca8adf301198d754b8a07a3ce7ee3ae599adc5 100644 (file)
@@ -397,18 +397,26 @@ kadmin_startup(int argc, char *argv[])
     }
 
     /*
-     * If no principal name is specified: If a ccache was specified
-     * and its primary principal name can be read, it is used, else if
-     * a keytab was specified, the principal name is host/hostname,
-     * otherwise append "/admin" to the primary name of the default
-     * ccache, $USER, or pw_name.
+     * If no principal name is specified: If authenticating anonymously, use
+     * the anonymouse principal for the local realm, else if a ccache was
+     * specified and its primary principal name can be read, it is used, else
+     * if a keytab was specified, the principal name is host/hostname,
+     * otherwise append "/admin" to the primary name of the default ccache,
+     * $USER, or pw_name.
      *
      * Gee, 100+ lines to figure out the client principal name.  This
      * should be compressed...
      */
 
     if (princstr == NULL) {
-        if (ccache_name != NULL &&
+        if (use_anonymous) {
+            if (asprintf(&princstr, "%s/%s@%s", KRB5_WELLKNOWN_NAMESTR,
+                         KRB5_ANONYMOUS_PRINCSTR, def_realm) < 0) {
+                fprintf(stderr, _("%s: out of memory\n"), whoami);
+                exit(1);
+            }
+            freeprinc++;
+        } else if (ccache_name != NULL &&
             !krb5_cc_get_principal(context, cc, &princ)) {
             retval = krb5_unparse_name(context, princ, &princstr);
             if (retval) {