commit 307334353f0b9af87e4cad88f1289addcb3553be
parent 7c8dc59f8a5d35b5490893665ad8957c8c61e7e9
Author: Drew DeVault <sir@cmpwn.com>
Date: Wed, 24 Feb 2021 10:50:33 -0500
os::exec: use O_PATH for exec fd
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/os/exec/+linux.ha b/os/exec/+linux.ha
@@ -36,7 +36,9 @@ fn open(path: str) (platform | os_error) = {
return errno_to_os(rt::EACCES);
},
};
- return match (rt::open(path: *const char, rt::O_RDONLY, 0u)) {
+ // O_PATH is used because it allows us to use an executable for which we
+ // have execute permissions, but not read permissions.
+ return match (rt::open(path: *const char, rt::O_PATH, 0u)) {
fd: int => fd,
err: rt::errno => errno_to_os(err),
};