diff --git a/images/linux/post-generation/homebrew-permissions.sh b/images/linux/post-generation/homebrew-permissions.sh index 1dbd043e..edd15fb7 100644 --- a/images/linux/post-generation/homebrew-permissions.sh +++ b/images/linux/post-generation/homebrew-permissions.sh @@ -2,10 +2,13 @@ # Fix permissions for Homebrew # https://github.com/actions/virtual-environments/issues/1568 + brew_folder="/home/linuxbrew/" +homebrew_user=$(cut -d: -f1 /etc/passwd | tail -1) + if [ -d "$brew_folder" ]; then brew_folder_owner=$(ls -ld $brew_folder | awk '{print $3}') - if [ "$USER" != "$brew_folder_owner" ]; then - chown "$USER":docker -R $brew_folder + if [ "$homebrew_user" != "$brew_folder_owner" ]; then + chown "$homebrew_user":docker -R $brew_folder fi fi diff --git a/images/linux/post-generation/rust-permissions.sh b/images/linux/post-generation/rust-permissions.sh index 6673686b..aff56ca1 100644 --- a/images/linux/post-generation/rust-permissions.sh +++ b/images/linux/post-generation/rust-permissions.sh @@ -2,10 +2,13 @@ # Fix permissions for the Rust folder # https://github.com/actions/virtual-environments/issues/572 + rust_folder="/usr/share/rust" +rust_user=$(cut -d: -f1 /etc/passwd | tail -1) + if [ -d "$rust_folder" ]; then rust_folder_owner=$(ls -ld $rust_folder | awk '{print $3}') - if [ "$USER" != "$rust_folder_owner" ]; then - chown "$USER":docker -R $rust_folder + if [ "$rust_user" != "$rust_folder_owner" ]; then + chown "$rust_user":docker -R $rust_folder fi fi