My system, the Android operating system, uses SELinux to disallow stat() for a large number of files and directories. This prevents side channel leakage between various untrustworthy processes, helping preserve user privacy and preserve the confidentiality of the system. For good reason, the ability to disallow stat is a common operation by all Linux Security Modules.
access() is defined by the relevant POSIX standards, so I'm surprised to hear you say it's not portable and buggy. AFAIK, it's not buggy on your largest platform - Linux - and it is more reliable and efficient than relying on stat(), which may be disallowed. Thank you for evaluating this patch and your time. -- You received this bug notification because you are a member of mksh Mailing List, which is subscribed to mksh. Matching subscriptions: mkshlist-to-mksh-bugmail https://bugs.launchpad.net/bugs/1817959 Title: "test -e" inaccurately returns false when stat() is disallowed Status in mksh: Invalid Bug description: From "man 1 test" NAME test - check file types and compare values DESCRIPTION Exit with the status determined by EXPRESSION. [deleted] -e FILE FILE exists When "test -e" is called, it is intended to determine the existence or non-existence of a file. However, the "test" command is implemented using stat(), which may be disallowed by security policy. If stat() is disallowed, "test" will falsely claim a file doesn't exist when it really exists. Replacing "stat() == 0" with "access(F_OK) == 0" fixes this problem. See attached patch. To manage notifications about this bug go to: https://bugs.launchpad.net/mksh/+bug/1817959/+subscriptions