Handle Windows pathnames properly in krb5_cc_resolve()

On Windows, a pathname can contain a drive letter and a colon.
krb5_cc_resolve() used to check whether there were any colons in the
ccache name string and assume it is a FILE: cache if there weren't.
In addition, on Windows, check for a drive specification.
This commit is contained in:
Asanka Herath
2010-09-02 17:15:01 -04:00
committed by Asanka C. Herath
parent 91bfec3059
commit fa4021698e

View File

@@ -217,6 +217,25 @@ allocate_ccache (krb5_context context,
return ret;
}
static int
is_possible_path_name(const char * name)
{
const char * colon;
if ((colon = strchr(name, ':')) == NULL)
return TRUE;
#ifdef _WIN32
/* <drive letter>:\path\to\cache ? */
if (colon == name + 1 &&
strchr(colon + 1, ':') == NULL)
return TRUE;
#endif
return FALSE;
}
/**
* Find and allocate a ccache in `id' from the specification in `residual'.
* If the ccache name doesn't contain any colon, interpret it as a file name.
@@ -251,7 +270,7 @@ krb5_cc_resolve(krb5_context context,
id);
}
}
if (strchr (name, ':') == NULL)
if (is_possible_path_name(name))
return allocate_ccache (context, &krb5_fcc_ops, name, id);
else {
krb5_set_error_message(context, KRB5_CC_UNKNOWN_TYPE,