summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-06-09 23:47:11 -0400
committerIan Moffett <ian@osmora.org>2025-06-09 23:47:11 -0400
commit4a61fabf489b8c384342c31bf29087e298c9246c (patch)
treec6f4d6b99992986bb0a90bf3cfdb3163628256ce
parent375bd43d352585638484b2c52cbf677af1408b9a (diff)
usr.bin: osh: Check bin_path with access()
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--usr.bin/osh/osh.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/usr.bin/osh/osh.c b/usr.bin/osh/osh.c
index 4064c12..93ac876 100644
--- a/usr.bin/osh/osh.c
+++ b/usr.bin/osh/osh.c
@@ -222,6 +222,12 @@ cmd_run(const char *input, int argc, char *argv[])
int error;
snprintf(bin_path, sizeof(bin_path), "/usr/bin/%s", input);
+
+ /* See if we can access it */
+ if (access(bin_path, F_OK) != 0) {
+ return -1;
+ }
+
if ((error = spawn(bin_path, SPAWN_WAIT)) < 0) {
return error;
}