diff options
author | Chris Down <chris@chrisdown.name> | 2019-09-25 17:09:38 +0100 |
---|---|---|
committer | Chris Down <chris@chrisdown.name> | 2019-09-26 09:19:20 +0100 |
commit | 4e1ddb661272ddb2f03d6046369c973657dfdd62 (patch) | |
tree | bdf9120a129766893cc85ef4a40d1e3b5772c2e7 /src/basic/path-util.c | |
parent | afe42aef39d027a8c74e0f5dd1e496b8de5daa95 (diff) | |
download | systemd-4e1ddb661272ddb2f03d6046369c973657dfdd62.tar.gz |
util-lib: Don't propagate EACCES from find_binary PATH lookup to caller
On one of my test machines, test-path-util was failing because the
find_binary("xxxx-xxxx") was returning -EACCES instead of -ENOENT. This
happens because the PATH entry on that host contains a directory which
the user in question doesn't have access to. Typically applications
ignore permission errors when searching through PATH, for example in
bash:
$ whoami
cdown
$ PATH=/root:/bin type sh
sh is /bin/sh
This behaviour is present on zsh and other shells as well, though. This
patch brings our PATH search behaviour closer to other major Unix tools.
Diffstat (limited to 'src/basic/path-util.c')
-rw-r--r-- | src/basic/path-util.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/basic/path-util.c b/src/basic/path-util.c index 18c7dabbae..b9544b4bac 100644 --- a/src/basic/path-util.c +++ b/src/basic/path-util.c @@ -651,7 +651,9 @@ int find_binary(const char *name, char **ret) { return 0; } - last_error = -errno; + /* PATH entries which we don't have access to are ignored, as per tradition. */ + if (errno != EACCES) + last_error = -errno; } return last_error; |