From: "Jacob Vosmaer via supervision" <supervision@list.skarnet.org>
To: supervision@list.skarnet.org
Subject: Handle ENOTDIR in pathexec_run
Date: Mon, 11 Nov 2019 18:00:21 +0100 [thread overview]
Message-ID: <CADMWQoN4XCNAzm5weVd8kuBMMsZy+RP5KsFcBhAh1yqnmyjgRQ@mail.gmail.com> (raw)
Hello,
First time on this list. Long time fan of Runit.
We have recently run into an edge case in Runit, which I think might
be worth patching.
If a user starts up runsvdir with existing-but-not-directory garbage
in their PATH,
runsvdir ends up in a broken state with a cryptic error. This is how
you can reproduce it:
mkdir -p svcs/foo
cat >svcs/foo/run <<EOF
#!/bin/sh
echo hello world
while true; do
sleep 1
done
EOF
chmod +x svcs/foo/run
PATH=/dev/null:$PATH runsvdir svcs
This will fail to launch runsv for svcs/foo. My understanding is this
happens because pathexec_run tries to call execve("/dev/null/runsv",
...) which fails with ENOTDIR.
Clearly this is a pathological PATH, but apparently there are people
out there who have this. And most other tools seem to ignore such
garbage entries. For example:
PATH=/dev/null:$PATH bash -c ls
The patch below makes runit ignore this type of bad path entry.
--- a/src/pathexec_run.c
+++ b/src/pathexec_run.c
@@ -35,7 +35,7 @@ void pathexec_run(const char *file,const char *
const *argv,const char * const *
execve(tmp.s,argv,envp);
if (errno != error_noent) {
savederrno = errno;
- if ((errno != error_acces) && (errno != error_perm) && (errno
!= error_isdir)) return;
+ if ((errno != error_acces) && (errno != error_perm) && (errno
!= error_isdir) && (errno != error_notdir)) return;
}
if (!path[split]) {
What do you think?
Best regards,
Jacob Vosmaer
GitLab, Inc.
next reply other threads:[~2019-11-11 17:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-11 17:00 Jacob Vosmaer via supervision [this message]
2020-02-19 8:18 ` Jonathan de Boyne Pollard
[not found] ` <5afb3f20-239b-f09a-c696-fe36d141b2cd@ntlworld.com>
2020-02-19 10:14 ` Laurent Bercot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CADMWQoN4XCNAzm5weVd8kuBMMsZy+RP5KsFcBhAh1yqnmyjgRQ@mail.gmail.com \
--to=supervision@list.skarnet.org \
--cc=jacob@gitlab.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).