]> Cypherpunks repositories - gostls13.git/commit
internal/syscall/unix: Eaccess: return ENOSYS on Android
authorKir Kolyshkin <kolyshkin@gmail.com>
Thu, 5 Sep 2024 21:14:59 +0000 (14:14 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 6 Sep 2024 13:49:31 +0000 (13:49 +0000)
commit8cd550a2327e921ddc202e960df6db8bfe4ef222
treea3e514618110bb50b9486b01cc4dafef9078912e
parenta0d7bfa28683c2f7cf7868330295c9942a2fcdfd
internal/syscall/unix: Eaccess: return ENOSYS on Android

On Android, faccessat2 syscall (which supports flags like AT_EACCESS) is
not allowed, so syscall.Faccessat tries to emulate AT_EACCESS check in
userspace using os.Stat, os.Geteuid etc.

Also, according to [1],

> Android doesn't have setuid programs, and never runs code with euid!=uid.

This means on Android the proper AT_EACCESS check is neither possible
nor really needed.

Let's skip the syscall.Faccessat userspace emulation of AT_EACCESS
check and return ENOSYS, so the callers can use a fallback.

This should speed up exec.LookPath on Android.

[1]: https://android.googlesource.com/platform/bionic/+/508b2f6e5cba4bdadf1e47a4ff27e25ce66c40e3/libc/bionic/faccessat.cpp#50

Change-Id: If7b529fa314480b70e9ae9cdd8c7ce82cd55d233
Reviewed-on: https://go-review.googlesource.com/c/go/+/611298
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/internal/syscall/unix/eaccess.go