Package: runit
Version: 2.1.2-50
Severity: normal

Hi,

/lib/runit/run_sysv_scripts has this:

for script in "$initdir/$rX"* ; do
        [ ! -x "$script" ] && continue
        path=$(realpath "$script")
        name=${path##*/}
        # Special case for wicd. Runscript is called "wicd-daemon",
        # to match binary package name.
        [ -d "/etc/sv/$name" ] && continue
        [ -d "/etc/sv/$name-daemon" ] && continue
        "$script" "$rcommand"
done

Checking for /etc/sv/$name and skipping initscripts if those directories exist 
is wrong for two reasons:

 1. /etc/sv/$name may not be symlinked into /etc/service (false positive);

 2. /etc/service may contain a symlink to a service directory for this service 
that is elsewhere in the filesystem, not in /etc/sv (false negative).

As a minimum, I suggest the following: instead of /etc/sv/$name, check for 
/etc/service/$name (and $name-daemon if necessary), and not with "-d" but "-L" 
(because when running rcS.d, the target of the symlink may only appear later, 
for example when a new filesystem is mounted).

This is still imperfect during boot because /etc/service may point to some 
directory that is not the one we'll switch to with runsvdir in stage 2. I don't 
know what the best way of handling this (likely rare) case is, but the 
following solutions come to mind:

 1. have a /etc/runit/override-init.d/ directory. If $name exists in it, don't 
invoke the initscript in /lib/runit/run_sysv_scripts. This places the entire 
administration/configuration burden on the admin but is very simple to do, and 
easy enough for the admin to automate (e.g. your own service scripts can just 
create these files when they're first run).

 2. pass the name of the /etc/runit/runsv directory that we expect to be used 
to /lib/runit/run_sysv_scripts somehow (for example, in an environment 
variable). This looks brittle (riddled with race conditions) and complicated to 
me, but it would require no effort from the admin.

 3. invoke runsvchdir earlier during boot. This is problematic on systems where 
/ is read-only before some initscripts are run.

 4. [other kludges]

AndrĂ¡s

-- 
         Reality is merely an illusion, albeit a very persistent one.

Reply via email to