Stop self-invoking sudo in the Makefile (#36) #79
No reviewers
Labels
No labels
Bug
BuildIssue
Claude-fixed
Enhancement
In Progress
Low priority
On Hold
Rejected
Security
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
keyop-go/nfq_forwarder!79
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "issue36_makefile_no_sudo"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #36.
Both
check-build-requirementsandinstallused to self-elevate viasudo, which is counter-intuitive for a caller without passwordless sudo configured.check-build-requirementsnow prints the exact install command for the detected package manager and exits 1, rather than callingsudo apt-get/dnf/yum installitself.installdrops itsbuildprerequisite and every internalsudoprefix. It guards onid -ubeing 0 ("try: sudo make install") and ondist/nfq_forwarder/dist/iptablesalready existing ("run 'make build' first, as yourself"). This also directly addresses the "sane environment" half of the ticket:sudo make install'sinstall: buildprerequisite used to run the entire recipe - includingbuild, which needs the full dev toolchain (goreleaser, etc.) - under sudo's own environment, which commonly resetsPATH/HOME. Splitting the unprivilegedbuildstep away from the privilegedinstall(1)/setcapcalls avoids needing any PATH-preservation workaround at all.Verified end to end, not just reasoned about: non-root
make installfails with guidance, rootmake installwithout a priormake buildfails with guidance, and a fullmake build&&sudo make installsucceeds - binary/iptables copied, capabilities set correctly (confirmed viagetcap), PAM file installed.CI is unaffected -
.gitlab-ci.yml'sbefore_scriptalready installslibpam0g-devdirectly (nosudo, since the CI job already runs as root), socheck-build-requirementsnever reaches its failure branch there.requested review from @danny
assigned to @claude
I would prefer this gated similarly to the 'install' target - If we're running as root, the fixes should be applied (without 'sudo').
If we're not running as root and:
See comments.
requested changes
mentioned in commit
6c88be75e0added 4 commits
main14f847bf- Stop self-invoking sudo in the Makefile (#36)6c88be75- Address review: gate check-build-requirements like install (#36)Compare with previous version
Done in
6c88be7- check-build-requirements now checksid -uthe same way install does: root+missing installs directly (no sudo), non-root+present is silent, non-root+missing only warns and suggestssudo make check-build-requirementsrather than hard-failing (the real cgo compiler error surfaces on its own moments later if the header genuinely can't be found). Verified all four branches with a standalone harness faking id -u/header-presence, plus both reachable-on-this-host cases for real.Rebased onto main (now includes !78's CGO_CFLAGS fix) - no conflicts remaining.
resolved all threads
resolved all threads
Rebased onto
main(no more conflicts) and reworkedcheck-build-requirementsper the review comments (6c88be7): it now checksid -uthe same wayinstalldoes, self-heals directly when already root, and only warns (doesn't hard-fail) when not root and something's missing.make lint/make test/make build+ a fullsudo make installall verified again on this host. Ready for another look.Ok, that looks better.
approved this merge request
mentioned in commit
ad5d4b4646mentioned in issue #36