Support KRB5_PRINCIPAL_UNPARSE_NO_QUOTE.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21073 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2007-06-12 22:23:41 +00:00
parent 757bafb34b
commit 6a38e8d297

View File

@@ -285,11 +285,11 @@ static const char replace_chars[] = " ntb\\/@";
#define add_char(BASE, INDEX, LEN, C) do { if((INDEX) < (LEN)) (BASE)[(INDEX)++] = (C); }while(0);
static size_t
quote_string(const char *s, char *out, size_t idx, size_t len)
quote_string(const char *s, char *out, size_t idx, size_t len, int no_quote)
{
const char *p, *q;
for(p = s; *p && idx < len; p++){
if((q = strchr(quotable_chars, *p))){
if(!no_quote && (q = strchr(quotable_chars, *p))){
add_char(out, idx, len, '\\');
add_char(out, idx, len, replace_chars[q - quotable_chars]);
}else
@@ -312,6 +312,7 @@ unparse_name_fixed(krb5_context context,
int i;
int short_form = (flags & KRB5_PRINCIPAL_UNPARSE_SHORT) != 0;
int no_realm = (flags & KRB5_PRINCIPAL_UNPARSE_NO_REALM) != 0;
int no_quote = (flags & KRB5_PRINCIPAL_UNPARSE_NO_QUOTE) != 0;
if (!no_realm && princ_realm(principal) == NULL) {
krb5_set_error_string(context, "Realm missing from principal, "
@@ -322,7 +323,7 @@ unparse_name_fixed(krb5_context context,
for(i = 0; i < princ_num_comp(principal); i++){
if(i)
add_char(name, idx, len, '/');
idx = quote_string(princ_ncomp(principal, i), name, idx, len);
idx = quote_string(princ_ncomp(principal, i), name, idx, len, no_quote);
if(idx == len) {
krb5_set_error_string(context, "Out of space printing principal");
return ERANGE;
@@ -341,7 +342,7 @@ unparse_name_fixed(krb5_context context,
}
if(!short_form && !no_realm) {
add_char(name, idx, len, '@');
idx = quote_string(princ_realm(principal), name, idx, len);
idx = quote_string(princ_realm(principal), name, idx, len, no_quote);
if(idx == len) {
krb5_set_error_string(context,
"Out of space printing realm of principal");