svn rev #25862: trunk/src/ include/krb5/ lib/krb5/krb/

ghudson@MIT.EDU ghudson at MIT.EDU
Thu May 10 13:34:10 EDT 2012


http://src.mit.edu/fisheye/changelog/krb5/?cs=25862
Commit By: ghudson
Log Message:
Add krb5_parse_name flag to ignore realm

The flag KRB5_PRINCIPAL_PARSE_IGNORE_REALM causes krb5_parse_name to
return the principal with an empty realm whether or not a realm is
present in the name.

ticket: 7129


Changed Files:
U   trunk/src/include/krb5/krb5.hin
U   trunk/src/lib/krb5/krb/parse.c
Modified: trunk/src/include/krb5/krb5.hin
===================================================================
--- trunk/src/include/krb5/krb5.hin	2012-05-10 17:34:07 UTC (rev 25861)
+++ trunk/src/include/krb5/krb5.hin	2012-05-10 17:34:10 UTC (rev 25862)
@@ -3409,6 +3409,7 @@
 #define KRB5_PRINCIPAL_PARSE_REQUIRE_REALM 0x2 /**< Error if realm is not present */
 #define KRB5_PRINCIPAL_PARSE_ENTERPRISE    0x4 /**< Create single-component
                                                   enterprise principle */
+#define KRB5_PRINCIPAL_PARSE_IGNORE_REALM  0x8 /**< Ignore realm if present */
 
 /**
  * Convert a string principal name to a krb5_principal with flags.
@@ -3426,7 +3427,13 @@
  * @li #KRB5_PRINCIPAL_PARSE_REQUIRE_REALM - realm must be present in @a name
  * @li #KRB5_PRINCIPAL_PARSE_ENTERPRISE - create single-component enterprise
  *                                        principal
+ * @li #KRB5_PRINCIPAL_PARSE_IGNORE_REALM - ignore realm if present in @a name
  *
+ * If @c KRB5_PRINCIPAL_PARSE_NO_REALM or @c KRB5_PRINCIPAL_PARSE_IGNORE_REALM
+ * is specified in @a flags, the realm of the new principal will be empty.
+ * Otherwise, the default realm for @a context will be used if @a name does not
+ * specify a realm.
+ *
  * Use krb5_free_principal() to free @a principal_out when it is no longer
  * needed.
  *

Modified: trunk/src/lib/krb5/krb/parse.c
===================================================================
--- trunk/src/lib/krb5/krb/parse.c	2012-05-10 17:34:07 UTC (rev 25861)
+++ trunk/src/lib/krb5/krb/parse.c	2012-05-10 17:34:10 UTC (rev 25862)
@@ -180,6 +180,7 @@
     krb5_boolean enterprise = (flags & KRB5_PRINCIPAL_PARSE_ENTERPRISE);
     krb5_boolean require_realm = (flags & KRB5_PRINCIPAL_PARSE_REQUIRE_REALM);
     krb5_boolean no_realm = (flags & KRB5_PRINCIPAL_PARSE_NO_REALM);
+    krb5_boolean ignore_realm = (flags & KRB5_PRINCIPAL_PARSE_IGNORE_REALM);
 
     *principal_out = NULL;
 
@@ -201,7 +202,7 @@
                                    name);
             goto cleanup;
         }
-        if (!no_realm) {
+        if (!no_realm && !ignore_realm) {
             ret = krb5_get_default_realm(context, &default_realm);
             if (ret)
                 goto cleanup;
@@ -212,6 +213,9 @@
         krb5_set_error_message(context, ret,
                                _("Principal %s has realm present"), name);
         goto cleanup;
+    } else if (ignore_realm) {
+        krb5_free_data_contents(context, &princ->realm);
+        princ->realm = empty_data();
     }
 
     princ->type = (enterprise) ? KRB5_NT_ENTERPRISE_PRINCIPAL :



More information about the cvs-krb5 mailing list