Skip to content

Use sudo -n if --interactive=false #19531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/minikube/firewall/firewall.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os/exec"
"regexp"
"runtime"
"slices"
"strings"

"github.com/spf13/viper"
Expand Down Expand Up @@ -65,7 +66,7 @@ func UnblockBootpd() error {
cmdString.WriteString(fmt.Sprintf(" $ %s \n", strings.Join(c.Args, " ")))
}

out.Styled(style.Permissions, "Your firewall is blocking bootpd which is required for socket_vmnet. The following commands will be executed to unblock bootpd:\n\n{{.commands}}\n", out.V{"commands": cmdString.String()})
out.Styled(style.Permissions, "Your firewall is blocking bootpd which is required for this configuration. The following commands will be executed to unblock bootpd:\n\n{{.commands}}\n", out.V{"commands": cmdString.String()})

for _, c := range cmds {
testArgs := append([]string{"-n"}, c.Args[1:]...)
Expand All @@ -75,6 +76,7 @@ func UnblockBootpd() error {
klog.Infof("%v may require a password: %v", c.Args, err)
if !viper.GetBool("interactive") {
klog.Warningf("%s requires a password, and --interactive=false", c.Args)
c.Args = slices.Insert(c.Args, 1, "-n")
Copy link
Member

Choose a reason for hiding this comment

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

thanks for limitting it only for "interactive" to avoid Unintended Privilege Escalation like if the user has recently used sudo for a different purpose. This could pose a security risk if the script is compromised or contains errors.
but it makes sense for not interactive

}
}
klog.Infof("running: %s", c.Args)
Expand Down
Loading