common: warn when become_user() leaves root credentials - #3609
common: warn when become_user() leaves root credentials#3609user01010111 wants to merge 2 commits into
Conversation
Check the real and effective UIDs after the POSIX credential transition, and warn once if either remains zero. Keep non-root starts and the intentionally privileged upsmon -p path unchanged. Fixes networkupstools#3471. AI assistance: OpenAI Codex gpt-5.6-sol at high reasoning was used for investigation, implementation and validation. The human contributor remains responsible for the change. Signed-off-by: user01010111 <lapses.50.booster@icloud.com>
|
A ZIP file with standard source tarball and another tarball with pre-built docs for commit 75d5b30 is temporarily available: NUT-tarballs-PR-3609.zip. |
|
✅ Build nut 2.8.5.5181-master completed (commit 3802a9a93c by @)
|
jimklimov
left a comment
There was a problem hiding this comment.
LGTM, but a NEWS.adoc entry would be welcome.
Honour EXEEXT, pass the exact build-tree upslog path, and use the current UID-0 account name. Treat an empty TMPDIR as unset and add the requested NEWS entry. Refs networkupstools#3471. AI assistance: OpenAI Codex gpt-5.6-sol at high reasoning was used for investigation, implementation and validation. The human contributor remains responsible for the change. Signed-off-by: user01010111 <lapses.50.booster@icloud.com>
|
Thanks Jim — I’ve added a concise NEWS entry under common code. I also corrected the new regression’s build-tree wiring to honour |
|
✅ Build nut 2.8.5.5186-master completed (commit 117bf537d9 by @)
|
|
✅ Build nut 2.8.5.5186-master completed (commit 117bf537d9 by @) |
Aims to close #3471, pending maintainer review and approval.
This makes the shared POSIX
become_user()path warn once when a daemon's real or effective UID remains zero after a successful credential transition.The previous code reported the resulting UID only in a debug-level success message after
initgroups(),setgid()andsetuid(), and did not warn when the resulting credentials remained root. Checking both resulting UIDs in the shared helper gives daemon callers one consistent invariant without duplicating warnings. Non-root starts retain their existing behaviour, and the intentionally privilegedupsmon -ppath retains its existing warning without receiving another one.Validation:
common.o,upslog,upsmon,upsdanddummy-upssuccessfully. Clang 22.1.8 built the same targets with-Weverything -Werror.upslog -u rootcompleted with no root warning. The candidate emitted exactly oneWarning: running as root (UID=0 EUID=0).upsmon -prun retained exactly one existing intentional-root warning and emitted no new shared warning.make -C tests checkpassed all 9 tests.git diff --check, the shell syntax check andmake stylecheckpassed. A supplementary non-ASCII scan found only an unchanged character outside the diff.distcheck-lightcreated and built the clean source archive, including the new regression, then failed at the final spellcheck on unchangeddocs/man/apcmicrolink.txttext.AI assistance: OpenAI Codex gpt-5.6-sol at high reasoning was used for investigation, implementation and validation. The human contributor remains responsible for the change.