(krb5_aname_to_localname): when converting too root, make sure user is
ok according to krb5_kuserok before allowing it. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@11956 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -43,7 +43,7 @@ krb5_aname_to_localname (krb5_context context,
|
||||
{
|
||||
krb5_error_code ret;
|
||||
krb5_realm *lrealms, *r;
|
||||
int foo = 1;
|
||||
int valid;
|
||||
size_t len;
|
||||
const char *res;
|
||||
|
||||
@@ -51,26 +51,42 @@ krb5_aname_to_localname (krb5_context context,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
valid = 0;
|
||||
for (r = lrealms; *r != NULL; ++r) {
|
||||
foo = strcmp (*r, aname->realm);
|
||||
if (foo == 0)
|
||||
if (strcmp (*r, aname->realm) == 0) {
|
||||
valid = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
krb5_free_host_realm (context, lrealms);
|
||||
if (foo != 0)
|
||||
if (valid == 0)
|
||||
return KRB5_NO_LOCALNAME;
|
||||
|
||||
if (aname->name.name_string.len == 1)
|
||||
res = aname->name.name_string.val[0];
|
||||
else if (aname->name.name_string.len == 2
|
||||
&& strcmp (aname->name.name_string.val[1], "root") == 0)
|
||||
&& strcmp (aname->name.name_string.val[1], "root") == 0) {
|
||||
krb5_principal rootprinc;
|
||||
krb5_boolean userok;
|
||||
|
||||
res = "root";
|
||||
else
|
||||
|
||||
ret = krb5_copy_principal(context, aname, &rootprinc);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
userok = krb5_kuserok(context, rootprinc, res);
|
||||
krb5_free_principal(context, rootprinc);
|
||||
if (!userok)
|
||||
return KRB5_NO_LOCALNAME;
|
||||
|
||||
} else
|
||||
return KRB5_NO_LOCALNAME;
|
||||
|
||||
len = strlen (res);
|
||||
if (len >= lnsize)
|
||||
return ERANGE;
|
||||
strcpy (lname, res);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user