Check fcache st_uid == geteuid(), not getuid()

Programs like sshd may create or access a ccache with
ruid != user's UID, euid == user's UID.

Set-uid-0 programs (ob reminder: they start life as ruid == user's UID,
euid == 0) shouldn't unintentionally access ccaches.  Therefore we
shouldn't check both of ruid and euid, just euid.
This commit is contained in:
Nicolas Williams
2013-10-04 18:24:38 -05:00
parent 0b9891214e
commit f10de508a6

View File

@@ -494,10 +494,9 @@ again:
/*
* XXX Should probably add options to improve control over this
* check. We might want strict checking of everything except
* this, and we might want st_uid == getuid() || st_uid == geteuid()
* to be OK.
* this.
*/
if (sb2.st_uid != getuid()) {
if (sb2.st_uid != geteuid()) {
krb5_set_error_message(context, EPERM, N_("Refuses to open cache files not own by myself FILE:%s (owned by %d)", ""), filename, (int)sb2.st_uid);
close(fd);
return EPERM;