-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This environment variable allows telling Homebrew to use the `SUDO_USER` variable to `sudo` through that user when Homebrew (Cask) attempts to run `sudo`. While we're here, clarify in some messaging that we're running `sudo` and that that's the password we're asking for; the specific password is configuration dependent and not the specific password for the user. Similarly, remove the `Package installers may write to any location` output; it's kinda spammy and doesn't feel like the right place.
- Loading branch information
1 parent
5ec560a
commit eb1355e
Showing
8 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,11 +157,25 @@ def env_args | |
set_variables | ||
end | ||
|
||
sig { returns(T.nilable(String)) } | ||
def homebrew_sudo_user | ||
ENV.fetch("HOMEBREW_SUDO_USER", nil) | ||
end | ||
|
||
sig { returns(T::Array[String]) } | ||
def sudo_prefix | ||
user_flags = [] | ||
user_flags += ["-u", "root"] if sudo_as_root? | ||
askpass_flags = ENV.key?("SUDO_ASKPASS") ? ["-A"] : [] | ||
user_flags = [] | ||
if Homebrew::EnvConfig.sudo_through_sudo_user? | ||
raise ArgumentError, "HOMEBREW_SUDO_THROUGH_SUDO_USER set but SUDO_USER unset!" if homebrew_sudo_user.blank? | ||
|
||
user_flags += ["--prompt", "Password for %p:", "-u", homebrew_sudo_user, | ||
*askpass_flags, | ||
"-E", *env_args, | ||
"--", "/usr/bin/sudo"] | ||
elsif sudo_as_root? | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
carlocab
Member
|
||
user_flags += ["-u", "root"] | ||
end | ||
["/usr/bin/sudo", *user_flags, *askpass_flags, "-E", *env_args, "--"] | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@MikeMcQuaid I don't think this is the right approach. The idea of
sudo_as_root
is that some commands must be run asroot
androot
only. No other user, regardless of its group and/or ACLs, can suffice. I thinksudo_as_root
should take precedence overHOMEBREW_SUDO_THROUGH_SUDO_USER
.