• R
    fix uid/gid-setting error in faccessat with AT_EACCESS flag · 51635856
    Rich Felker 提交于
    this fixes an issue reported by Daniel Thau whereby faccessat with the
    AT_EACCESS flag did not work in cases where the process is running
    suid or sgid but without root privileges. per POSIX, when the process
    does not have "appropriate privileges", setuid changes the euid, not
    the real uid, and the target uid must be equal to the current real or
    saved uid; if this condition is not met, EPERM results. this caused
    the faccessat child process to fail.
    
    using the setreuid syscall rather than setuid works. POSIX leaves it
    unspecified whether setreuid can set the real user id to the effective
    user id on processes without "appropriate privileges", but Linux
    allows this; if it's not allowed, there would be no way for this
    function to work.
    51635856
faccessat.c 1.2 KB