supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* Handle ENOTDIR in pathexec_run
@ 2019-11-11 17:00 Jacob Vosmaer via supervision
  2020-02-19  8:18 ` Jonathan de Boyne Pollard
       [not found] ` <5afb3f20-239b-f09a-c696-fe36d141b2cd@ntlworld.com>
  0 siblings, 2 replies; 3+ messages in thread
From: Jacob Vosmaer via supervision @ 2019-11-11 17:00 UTC (permalink / raw)
  To: supervision

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-02-19 10:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-11 17:00 Handle ENOTDIR in pathexec_run Jacob Vosmaer via supervision
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

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).