88 Commits

Author SHA1 Message Date
Bo Anderson
5ab907f2fa
system_command: fix EBADF on Ctrl+C 2024-07-23 18:48:42 +01:00
Bo Anderson
19617cb161
system_command: add reset_uid option 2024-07-17 06:33:03 +01:00
Markus Reiter
78d18354b6
Remove ignore_interrupts in SystemCommand. 2024-07-14 15:03:31 -04:00
Mike McQuaid
c5dbd3ca24
Rearrange requires
This improves the load time of most brew commands. For an example of
one of the simplest commands this speeds up:

Without Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     525.0 ms ±  35.8 ms    [User: 229.9 ms, System: 113.1 ms]
  Range (min … max):   465.3 ms … 576.6 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     383.3 ms ±  25.1 ms    [User: 133.0 ms, System: 72.1 ms]
  Range (min … max):   353.0 ms … 443.6 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.37 ± 0.13 times faster than git checkout master; brew help
```

With Bootsnap:
```
$ hyperfine 'git checkout master; brew help' 'git checkout optimise_requires; brew help'
Benchmark 1: git checkout master; brew help
  Time (mean ± σ):     386.0 ms ±  30.9 ms    [User: 130.2 ms, System: 93.8 ms]
  Range (min … max):   359.5 ms … 469.3 ms    10 runs

Benchmark 2: git checkout optimise_requires; brew help
  Time (mean ± σ):     330.2 ms ±  32.4 ms    [User: 93.4 ms, System: 73.0 ms]
  Range (min … max):   302.9 ms … 413.9 ms    10 runs

Summary
  git checkout optimise_requires; brew help ran
    1.17 ± 0.15 times faster than git checkout master; brew help
```
2024-07-14 08:49:39 -04:00
Markus Reiter
5e636174e8
Explicitly mark non-public APIs. 2024-04-23 19:10:45 +02:00
Douglas Eichelberger
c4db19232d git grep -lE '\(\&[A-Za-z._]+method\(:' | xargs gsed -i -E 's|\(\&([A-Za-z._]+)method\(:([a-z?_]+)\)\)| { \1\2(_1) }|g' 2024-03-03 18:55:56 -08:00
Douglas Eichelberger
eb7c3e52a0 Require SystemInclude only where needed 2024-01-31 11:42:01 -08:00
Douglas Eichelberger
e00d066d87 Replace Time refinement with Timer Util 2024-01-29 18:50:12 -08:00
Douglas Eichelberger
ffd761d2e9 Create dedicated Attrable mixin for attr_ methods 2023-12-28 11:46:27 -08:00
Ilya Kulakov
5f7db2b732
Fix syntax errors.
Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2023-12-21 01:16:09 -08:00
Ilya Kulakov
4783c5b9fe Fix syntax errors. 2023-12-20 10:05:43 -08:00
Ilya Kulakov
9b672b0e45 sudo: sudo_as_root should apply on top of HOMEBREW_SUDO_THROUGH_SUDO_USER
System commands run with sudo_as_root must be run as  regardless of who is running sudo.
2023-12-20 09:39:10 -08:00
Ilya Kulakov
f71189ae4d Revert "sudo: Prioritize sudo_as_root over HOMEBREW_SUDO_THROUGH_SUDO_USER."
This reverts commit 907da26e335b84c29b159d082fdc6ee23fcfba69.
2023-12-20 09:36:46 -08:00
Ilya Kulakov
907da26e33 sudo: Prioritize sudo_as_root over HOMEBREW_SUDO_THROUGH_SUDO_USER. 2023-12-19 22:39:44 -08:00
Bo Anderson
dd9359df12
system_command: fix potential issue of stderr not being read 2023-10-29 04:00:15 +00:00
Markus Reiter
4b7aed84fa
Add test for print_stdout: :debug. 2023-10-10 03:42:22 +02:00
Markus Reiter
5d87da135a
Allow printing command output when HOMEBREW_DEBUG/--debug is set. 2023-10-10 03:42:22 +02:00
Mike McQuaid
eb1355e624
Add HOMEBREW_SUDO_THROUGH_SUDO_USER
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.
2023-09-29 18:49:44 +01:00
Ilya Kulakov
476d97934f sudo: change sudo_user to sudo_as_root. 2023-04-28 11:22:54 -07:00
Ilya Kulakov
d470661b37 sudo: add the sudo_user arg to SystemCommand. 2023-04-28 11:11:53 -07:00
Ilya Kulakov
563387a7b4 sudo: explicitly specify the root user where necessary
With sudoers one may override default sudo user. This mostly works
provided the admin configured the replacement appropriately. However
there are exceptions that absolutely must be run by root such as
/usr/sbin/installer and, under certain circumstances, /bin/launchctl.
2023-04-28 11:11:53 -07:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Markus Reiter
c480adad4f
Pass TTY width to Open3. 2023-04-17 23:30:25 +02:00
Douglas Eichelberger
79f6c7c7da brew style --fix 2023-04-03 17:35:47 -07:00
Douglas Eichelberger
f3a8241e69 Remove useless T.unsafe wrappers 2023-04-03 17:34:39 -07:00
Douglas Eichelberger
4dcd5ac47f Remove HashValidator 2023-03-19 17:37:58 -07:00
Douglas Eichelberger
1943132cf6 Move i18n out of global 2023-03-11 17:27:53 -08:00
Bo Anderson
5ecf76a611
Harden plist parsing 2023-02-22 22:52:06 +00:00
Mike McQuaid
9725e764f5
system_command: fix typo. 2023-02-14 13:02:59 +00:00
Ilya Kulakov
9ff7ceb563 sudo: pass env variables without /usr/bin/env
Using /usr/bin/env as a frontend for the actual command
prevents sudoers from restricting allowed commands and configuring
detailed command environment.
2023-02-13 22:10:35 -08:00
Bo Anderson
9b99594753
Preliminary compatibility fixes for Ruby 3 2022-10-11 02:53:27 +01:00
Caleb Xu
227b8148eb
system_command: redact secrets in stdout/stderr
We already redact secrets when printing the command-line invocation
itself. Make sure that stdout/stderr doesn't leak secrets either.
2021-11-10 10:36:16 -05:00
Bo Anderson
d83b8002ef
system_command: better handle race conditions when interrupting 2021-05-11 13:44:32 +01:00
Bo Anderson
aea107b55a
system_command: fix rare scenario of interrupt being reported to stderr 2021-05-11 02:32:29 +01:00
Bo Anderson
6c10adab2f
system_command: avoid waiting on pipes after process termination 2021-05-10 15:48:15 +01:00
Markus Reiter
06a5811b4b
Simplify and fix each_line_from. 2021-04-03 20:10:33 +02:00
Markus Reiter
59f4a711cd
Deprecate _fetch without timeout option. 2021-04-03 20:10:33 +02:00
Markus Reiter
24c9b599a6
Revert "Revert "Merge pull request #10864 from reitermarkus/command-timeout""
This reverts commit 57b2660cae8cf43efd2b88d84a7174706328c001.
2021-04-03 20:10:32 +02:00
Bo Anderson
e30f2af987
system_command: improve EOF handling 2021-04-01 17:11:29 +01:00
Rylan Polster
57b2660cae
Revert "Merge pull request #10864 from reitermarkus/command-timeout"
This reverts commit d55bdd3ddbe7ff2b1f106a41bd994dc117ca5142, reversing
changes made to 3c3bf1c74d1d7ef1d2c792719574623b6c3c4d25.
2021-03-24 01:22:18 -04:00
Markus Reiter
712a95fdd0 Allow specifying timeouts for commands and downloads. 2021-03-16 18:15:21 +01:00
EricFromCanada
6fc116318e fixes for grammar and wording 2021-01-26 16:19:47 -05:00
Seeker
fbafaff4fe rubocop: require braces for Sorbet sig 2021-01-18 16:52:45 -08:00
Markus Reiter
3f6a930044
Merge pull request #10067 from reitermarkus/sudo-prompt
Fix `sudo` prompt.
2020-12-19 21:40:16 +01:00
Markus Reiter
b1b4518998 Fix sudo prompt. 2020-12-19 19:41:24 +01:00
Sam Ford
778e1d6234
SystemCommand: Default debug and verbose to nil 2020-12-19 10:01:43 -05:00
Sam Ford
d94afb91dd
SystemCommand: Add debug parameter 2020-12-19 09:33:28 -05:00
Markus Reiter
3db55d13d6 Improve handling of SIGINT. 2020-12-18 16:48:49 +01:00
Jonathan Chang
ed73d5b635 system_command: widen type for secrets 2020-11-27 17:45:18 +11:00
Markus Reiter
5be4c9b5e0 Upgrade typed sigils. 2020-11-25 17:04:19 +01:00