summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/krb5/principal.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2005-09-10 22:25:13 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:38:03 -0500
commitcfdcc32f8480e538246ca1771e58e9a4835f22b6 (patch)
treefe87e5e989f161ba79e081b28599b5ad8c80656c /source4/heimdal/lib/krb5/principal.c
parent00d69bdf238eeeb38ad7781b5841820796c07d6a (diff)
downloadsamba-cfdcc32f8480e538246ca1771e58e9a4835f22b6.tar.gz
samba-cfdcc32f8480e538246ca1771e58e9a4835f22b6.tar.bz2
samba-cfdcc32f8480e538246ca1771e58e9a4835f22b6.zip
r10149: Update Samba4 to current lorikeet-heimdal.
Andrew Bartlett (This used to be commit b9695d5e7cc052a952d8d60bc1ab08e00f4827e8)
Diffstat (limited to 'source4/heimdal/lib/krb5/principal.c')
-rw-r--r--source4/heimdal/lib/krb5/principal.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/source4/heimdal/lib/krb5/principal.c b/source4/heimdal/lib/krb5/principal.c
index 8540636403..ae5c8c1de8 100644
--- a/source4/heimdal/lib/krb5/principal.c
+++ b/source4/heimdal/lib/krb5/principal.c
@@ -91,10 +91,16 @@ krb5_principal_get_comp_string(krb5_context context,
return princ_ncomp(principal, component);
}
-krb5_error_code
+enum realm_presence {
+ MAY,
+ MUSTNOT,
+ MUST
+};
+
+static krb5_error_code
parse_name(krb5_context context,
const char *name,
- krb5_boolean short_form,
+ enum realm_presence realm_presence,
krb5_principal *principal)
{
krb5_error_code ret;
@@ -186,7 +192,7 @@ parse_name(krb5_context context,
*q++ = c;
}
if (got_realm) {
- if (short_form) {
+ if (realm_presence == MUSTNOT) {
krb5_set_error_string (context, "realm found in 'short' principal expected to be without one!");
ret = KRB5_PARSE_MALFORMED;
goto exit;
@@ -201,12 +207,16 @@ parse_name(krb5_context context,
realm[q - start] = 0;
}
}else{
- if (short_form) {
+ if (realm_presence == MAY) {
ret = krb5_get_default_realm (context, &realm);
if (ret)
goto exit;
- } else {
+ } else if (realm_presence == MUSTNOT) {
realm = NULL;
+ } else if (realm_presence == MUST) {
+ krb5_set_error_string (context, "realm NOT found in principal expected to be with one!");
+ ret = KRB5_PARSE_MALFORMED;
+ goto exit;
}
comp[n] = malloc(q - start + 1);
@@ -245,7 +255,7 @@ krb5_parse_name(krb5_context context,
const char *name,
krb5_principal *principal)
{
- return parse_name(context, name, FALSE, principal);
+ return parse_name(context, name, MAY, principal);
}
krb5_error_code KRB5_LIB_FUNCTION
@@ -253,7 +263,15 @@ krb5_parse_name_norealm(krb5_context context,
const char *name,
krb5_principal *principal)
{
- return parse_name(context, name, TRUE, principal);
+ return parse_name(context, name, MUSTNOT, principal);
+}
+
+krb5_error_code KRB5_LIB_FUNCTION
+krb5_parse_name_mustrealm(krb5_context context,
+ const char *name,
+ krb5_principal *principal)
+{
+ return parse_name(context, name, MUST, principal);
}
static const char quotable_chars[] = " \n\t\b\\/@";
static const char replace_chars[] = " ntb\\/@";