From fee6fec141c470f87c21eb23961dc5ab5280c660 Mon Sep 17 00:00:00 2001 From: Chris Brown Date: Tue, 14 May 2019 16:55:27 -0400 Subject: [PATCH] Fix "sudo: sorry, you are not allowed to preserve the environment" messages If you've previously run `valet trust` to allow valet to run without specifying `sudo` repeatedly or entering your password with various valet commands, recent updates to MacOS may give you a `sudo: sorry, you are not allowed to preserve the environment` response when trying to run those `valet` commands. The fix is in updating the sudoers entry that `valet trust` creates. This PR tells valet how to update the sudoers entry so that this message doesn't continue. YOU WILL NEED TO RE-RUN `valet trust` IF YOU HAD PREVIOUSLY RUN IT, after installing this update, in order for this code change to have any effect. (Technical explanation: the sudoers protections have become stricter, so we have to be more explicit that we do indeed want environment variables to flow through to the sudo user's environment when using valet via sudoers entries.) --- cli/Valet/Brew.php | 2 +- cli/Valet/Valet.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/Valet/Brew.php b/cli/Valet/Brew.php index 25fba14..75586b6 100644 --- a/cli/Valet/Brew.php +++ b/cli/Valet/Brew.php @@ -272,7 +272,7 @@ function createSudoersEntry() $this->files->ensureDirExists('/etc/sudoers.d'); $this->files->put('/etc/sudoers.d/brew', 'Cmnd_Alias BREW = /usr/local/bin/brew * -%admin ALL=(root) NOPASSWD: BREW'.PHP_EOL); +%admin ALL=(root) NOPASSWD:SETENV: BREW'.PHP_EOL); } /** diff --git a/cli/Valet/Valet.php b/cli/Valet/Valet.php index dd6e5a1..1f9352f 100644 --- a/cli/Valet/Valet.php +++ b/cli/Valet/Valet.php @@ -79,6 +79,6 @@ function createSudoersEntry() $this->files->ensureDirExists('/etc/sudoers.d'); $this->files->put('/etc/sudoers.d/valet', 'Cmnd_Alias VALET = /usr/local/bin/valet * -%admin ALL=(root) NOPASSWD: VALET'.PHP_EOL); +%admin ALL=(root) NOPASSWD:SETENV: VALET'.PHP_EOL); } }