summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-08-23 06:16:48 +0900
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-10-12 17:49:12 +0200
commit2d388e6c534509d140aea40852ea543ed7054ac1 (patch)
tree86a286f80b9644260c1b05bc2c2f1baaa42dff64
parent1f77dbfaaedcb8bdecc6610fa96f7fed80bfb8d8 (diff)
downloadsystemd-2d388e6c534509d140aea40852ea543ed7054ac1.tar.gz
path-util: make find_executable() work without /proc mounted
Follow-up for 888f65ace6296ed61285d31db846babf1c11885e. Hopefully fixes #20514. (cherry picked from commit 93413acd3ef3a637a0f31a1d133b103e1dc81fd6) (cherry picked from commit 727d0b55f46468d6171f4a326bd3139bab3c93ab)
-rw-r--r--src/basic/path-util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/basic/path-util.c b/src/basic/path-util.c
index 15bb45da0a..086f7a9e52 100644
--- a/src/basic/path-util.c
+++ b/src/basic/path-util.c
@@ -600,7 +600,11 @@ static int check_x_access(const char *path, int *ret_fd) {
return r;
r = access_fd(fd, X_OK);
- if (r < 0)
+ if (r == -ENOSYS) {
+ /* /proc is not mounted. Fallback to access(). */
+ if (access(path, X_OK) < 0)
+ return -errno;
+ } else if (r < 0)
return r;
if (ret_fd)