Skip to content

WIP: Remove passwordless sudo check in lib/common.sh - #1716

Open
UncivilizedGhost wants to merge 1 commit into
metal3-io:mainfrom
Nordix:saad/remove_pass_check
Open

WIP: Remove passwordless sudo check in lib/common.sh#1716
UncivilizedGhost wants to merge 1 commit into
metal3-io:mainfrom
Nordix:saad/remove_pass_check

Conversation

@UncivilizedGhost

@UncivilizedGhost UncivilizedGhost commented Aug 20, 2026

Copy link
Copy Markdown
Member

Replace sudo check with root check then remove all sudo instances

Fix #1288

@metal3-io-bot metal3-io-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 20, 2026
@metal3-io-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tuminoid for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@metal3-io-bot metal3-io-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 20, 2026
@metal3-io-bot metal3-io-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 21, 2026
@UncivilizedGhost

Copy link
Copy Markdown
Member Author

/test metal3-dev-env-integration-test-ubuntu-main

@UncivilizedGhost

Copy link
Copy Markdown
Member Author

/copilot-review

@metal3-io-bot
metal3-io-bot requested a balanced review from Copilot August 21, 2026 10:41
@metal3-io-bot

Copy link
Copy Markdown
Collaborator

Copilot code review has been requested by @UncivilizedGhost. Please allow a few moments for the review to be added.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Transitions Metal3 dev-env scripts to root execution and removes host-side sudo usage.

Changes:

  • Replaces passwordless-sudo validation with a root check.
  • Removes sudo from setup, configuration, launch, and verification commands.
  • Updates privileged container, networking, and libvirt operations.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/common.sh Adds root enforcement and removes shared sudo calls.
01_prepare_host.sh Runs dependency installation directly as root.
02_configure_host.sh Removes sudo from host and container configuration.
03_launch_mgmt_cluster.sh Removes sudo from cluster launch operations.
04_verify.sh Runs verification commands directly as root.
Suppressed comments (2)

lib/common.sh:9

  • When this is invoked as instructed via sudo, whoami above sets USER=root. As a result, the documented config_${user}.sh is replaced by a newly generated config_root.sh, working directories are owned by root, and kind/minikube are launched as root instead of as the invoking user. Preserve the caller identity (for example, from SUDO_USER) while using EUID only for this privilege check.
if [[ "${EUID}" -ne 0 ]]; then

lib/common.sh:10

  • The README quickstart still tells users to run each script directly or run plain make (README.md:85–95), both of which now exit here. Update the documented invocation and configuration/environment guidance to match the new root-only entry point.
    echo "ERROR: metal3-dev-env must be run as root. Call the script with sudo!"

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread 03_launch_mgmt_cluster.sh Outdated
if [[ -n "${MINIKUBE_BMNET_V6_IP:-}" ]]; then
sudo su -l -c "minikube ssh -- sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0" "${USER}"
sudo su -l -c "minikube ssh -- sudo ip addr add ${MINIKUBE_BMNET_V6_IP}/64 dev eth3" "${USER}"
su -l -c "minikube ssh -- sysctl -w net.ipv6.conf.all.disable_ipv6=0" "${USER}"
Comment thread lib/common.sh
Comment on lines +8 to +9
# Verify the script is running as root
if [[ "${EUID}" -ne 0 ]]; then
@UncivilizedGhost

Copy link
Copy Markdown
Member Author

/copilot-review

@metal3-io-bot
metal3-io-bot requested a balanced review from Copilot August 21, 2026 10:55
@metal3-io-bot

Copy link
Copy Markdown
Collaborator

Copilot code review has been requested by @UncivilizedGhost. Please allow a few moments for the review to be added.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

lib/common.sh:10

  • This changes every script sourcing common.sh to reject the existing unprivileged invocation, but the user documentation still tells users to run make or ./01_prepare_host.sh directly (README.md:85-95). Update the deployment and cleanup/test instructions to show the required privileged entry point so the documented workflow does not immediately exit here.
    echo "ERROR: metal3-dev-env must be run as root. Call the script with sudo!"

Comment thread lib/common.sh
@UncivilizedGhost
UncivilizedGhost force-pushed the saad/remove_pass_check branch 4 times, most recently from 4a64e86 to 8effbc0 Compare August 24, 2026 08:32
@UncivilizedGhost

Copy link
Copy Markdown
Member Author

/test metal3-dev-env-integration-test-ubuntu-main

@metal3-io-bot

Copy link
Copy Markdown
Collaborator

@UncivilizedGhost: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
metal3-dev-env-integration-test-ubuntu-main 8effbc0 link true /test metal3-dev-env-integration-test-ubuntu-main

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@UncivilizedGhost
UncivilizedGhost force-pushed the saad/remove_pass_check branch 2 times, most recently from 0aab6fb to b79cff3 Compare August 24, 2026 12:04
Replace sudo check with root check then remove all sudo instances
Signed-off-by: Saad Zia <saad.zia@est.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lib/common.sh has passwordless sudo check

3 participants