[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug in mintlib44's access() function
> So if this function
> tells me I can access a file, it will be true.
No. Not even that. If access() returns 0, it tells you you would have
access, if your effective id was equal to your real id, i.e. if you
execute another user's setuid program you may not have access to your
own files (if that user doesn't have), although access() returns 0
because it checks your real uid.
> But the negation of that
> mustn't necessarily also be true: If this function tells me I'm *not*
> allowed to access a file, I *may* in fact perhaps be allowed to, and thus,
> there's no point in calling this functions in the first place. Just open
> the file and see if it works...
This function is useful if don't want a user to have access to files
through execution of setuid programs, that he otherwise couldn't
access. In that case, you check if he should be granted access by
calling access() just before you open the file.
If you want to know if you really have access to a file, just try to
open it and check the return code.
Urs