if (auth)
{
status = mr_krb5_auth(client);
+
+ /* New client talking to old server, try krb4. */
+ if (status == MR_UNKNOWN_PROC)
+ status = mr_auth(client);
+
if (status)
{
com_err(whoami, status, "while authenticating to Moira.");
{
int flags = 0;
krb5_ccache cache = NULL;
- krb5_principal princ;
+ krb5_principal princ = NULL;
krb5_error_code status;
- char *name;
+ char *username = NULL;
if (!context)
krb5_init_context(&context);
if (status)
{
com_err(whoami, status, "while reading Kerberos ticket file.");
- return NULL;
+ goto out;
}
status = krb5_cc_get_principal(context, cache, &princ);
if (status)
{
com_err(whoami, status, "while retrieving principal name.");
- return NULL;
+ goto out;
}
- return (char *)krb5_princ_component(context, princ, 0);
+ username = malloc(krb5_princ_component(context, princ, 0)->length + 1);
+ if (!username)
+ goto out;
+
+ strncpy(username, krb5_princ_component(context, princ, 0)->data,
+ krb5_princ_component(context, princ, 0)->length);
+ username[krb5_princ_component(context, princ, 0)->length] = '\0';
+
+ out:
+ if (cache)
+ krb5_cc_close(context, cache);
+ if (princ)
+ krb5_free_principal(context, princ);
+ return username;
}
char *partial_canonicalize_hostname(char *s)