Hardening: Fall-back double-checkprocname()
vs. current daemon program name (and add NUT_IGNORE_CHECKPROCNAME=true
toggle)
#2471
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Follow-up to issue #2463 and PR #2464
Earlier work introduced a way to check that a running PID's process name (if we can detect it) matches our expectations (
upsmon
,upsd
, driver name) before we send signals - as we did, blindly and naively.This PR adds a way to disable this feature if it causes problems (e.g. embedded builds tend to have undecipherable NUT version strings to match a firmware name, and I can imagine someone tweaking program names or using symlinks as well... some
snmp-ups-dmf
comes to mind).It also adds a fallback ability to optionally check the other PID's process name against the current PID's process name (not requested from
upsdrvctl
which manages variously-named driver programs, but is requested from drivers,upsd
andupsmon
) to hopefully alleviate this problem with tweaked names, nip it in the bud.CC @yoyoma2
CC @arnaudquette-eaton @ericclappier-eaton : this one more internal API change for
sendsignal*()
methods may impact or benefit your work too, pinging just in case :)Screenshot with a tweaked
upsmon
that would checkNULL
instead ofprogname
- this example looks for name of its own PID:...and with
upsmon.c
tweaked to just look for abogus-name
, so it falls back togetpid()
when the first test fails:...and as before, by default it uses the built-in
progname
(upsmon
here):Note the fallback check resolves the name of the other PID again. A small inefficiency on an infrequent code-path, can live with that.
Test of the emergency envvar toggle to disable the PID sanity check (still sending to un-owned
sshd
so fails):Note that "raw"
perror()
happens when debug is enabled or internalnut_sendsignal_debug_level
is sufficiently high (e.g. toned down where we "just ping"), to not scare casual users. Normally this looks like this: