diff --git a/images/macos/scripts/build/configure-machine.sh b/images/macos/scripts/build/configure-machine.sh index abd1f9872..7c7b36705 100644 --- a/images/macos/scripts/build/configure-machine.sh +++ b/images/macos/scripts/build/configure-machine.sh @@ -90,6 +90,12 @@ if [[ ! "$(automationmodetool)" =~ "DOES NOT REQUIRE" ]]; then exit 1 fi +# Fix sudoers file permissions +sudo chmod 440 /etc/sudoers.d/* + +# Add NOPASSWD for the current user to sudoers +sudo sed -i '' 's/%admin ALL = (ALL) ALL/%admin ALL = (ALL) NOPASSWD: ALL/g' /etc/sudoers + # Create symlink for tests running if [[ ! -d "/usr/local/bin" ]];then sudo mkdir -p -m 775 /usr/local/bin diff --git a/images/macos/scripts/tests/Common.Tests.ps1 b/images/macos/scripts/tests/Common.Tests.ps1 index 8e6be12f5..353815d04 100644 --- a/images/macos/scripts/tests/Common.Tests.ps1 +++ b/images/macos/scripts/tests/Common.Tests.ps1 @@ -87,3 +87,12 @@ Describe "Unxip" { "unxip --version" | Should -ReturnZeroExitCode } } + +Describe "Sudoers" { + It "Sudo Cache" { + "sudo -v" | Should -ReturnZeroExitCode + } + It "Sudoers files" { + "sudo visudo -c" | Should -ReturnZeroExitCode + } +}