When finit calls out to external tools, like `ifup $IFACE`, that tool in
turn may use other external tools. On systems with BusyBox our calling
`ifup $IFACE` will result in BusyBox casting a magic spell: if $SHELL is
unset it goes looking in the file /etc/passwd for the shell of $USER
which may not be set to a Bourne compatible UNIX shell, so commands like
`ip link ...` or `run-parts ...` will fail hard.
This patch adds SHELL=/bin/sh as a sane early default.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Some systems, usually those built around BusyBox, have mdev installed
but have an option to install udev. In those cases the user likely
prefers to use udev over mdev and this patch addresses that.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This patch introduces a new option to initctl; -b, --batch skips
screen_init(), which might otherwise leak ANSI screen resize codes
to the console.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
As a precaution, services who are being stopped are automatically sent
a SIGKILL after 3 seconds if they refuse to go away willingly.
Unfortunately this backup mechanism was also enabled for inetd
services which are not backed by a real process. When the service was
freed the timer was not stopped, since it was not expected to be
armed. The timer would then trigger, causing a use-after-free on the
timer watcher containing a bogus callback pointer.
When an UDP inetd connection terminates we must make sure to unblock the
parent, which is (currently) blocked during the transaction.
This patch is a fix to a regression introduced in 2c904b5, for v3.1
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Starting in debug mode and disabling debug at runtime did not exhibit
the same behavior as if starting in normal mode and toggling debug mode
at runtime. This patch adds toggling of silent mode (progress output)
to runtime debug toggling.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The screen_init() call for each print() & C:o caused serious screen
artefacts in debug mode. This patch reworks f858d94 to only re-init
screen when toggling debug.
Also, avoid screen_init() completely if started in debug mode.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
- Don't warn of missing PID, even if only _d(), perfectly normal
- Allow stopping restart timer of non-services (e.g. task/run)
- Allow stopping services with no PID rn, i.e. stop libuEv timer
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
On `initctl reload` we reassert conditions, i.e. bring each still viable
condition back in sync with the new reconf generation. This patch fixes
an assumption in the reassert() callback that caused the following nasty
transformation:
/run/finit/cond/net/lo/up --> /run/finit/cond/lo/up
The transformation was caused by the reassert() code assuming a /var/run
prefix rather than /run. We must check the actual runpath, or like this
patch does, use a path neutral way to find the base condition string.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The cond_init() function is called before the bootmisc.so plugin has
run. It is responsble for setting up the /var/run symlink to /run on
systems with the new layout. Therefore we must wrap COND_PATH with
pid_runpath() to create the correct runtime path.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Finit tries to restart crashing services. If a service is removed
before Finit has given up restarting it, then the background timer
responsible the restart may dereference a free():d svc_t.
Hence, make sure to properly stop (and step) a service and its timer
callbacks in service_unregister() before calling svc_del().
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
In service_stop() we call svc_del() which, as of Finit v3.1, free():s
the svc_t, so we don't want any lingering restart timers to wake up
after free() and start dereferencing the svc_t.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
To improve debug possibilities at shutdown, keep gdbserver running even
during shutdown.
Note: The gdbserver service runlevels must be sth like [123456789] for
this to work in the first place.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
On most modern Linux systems /run is a tmpfs that replaces /var/run.
The latter is set up as a symlink to /run by the bootmisc.so plugin.
However, Finit conditions rely on the /var/run/finit/cond prefix, which
does not exist until bootmisc.so has run, which is *after* `mount -a`
has run. Therefore, to have working conditions before we run `mount -a`
we must normalize the path constructed by cond_path() to use either the
/run or /var/run (default) prefix.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This gives the operator a way to add a post-mount script, e.g. to peform
a 2nd stage mount or mount preparations, before the bootmisc.so plugin
and others run in hook/mount/all
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
The job:id field can now be used to display job:INET_PORT_NUMBER, e.g.
100:16161 for job 100 localhost SNMP port 16161.
The service name field has been reduced from 20 --> 16 bytes since the
full path has been reduced to display the basename.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>