Skip to content

Commit

Permalink
scripts/sudo-cwd.sh: don't try to copy missing sudoers.d/ permissions
Browse files Browse the repository at this point in the history
Copying a file that does not exist obviously fails.

This bug was found when trying to switch from the current "Developer
Image" to the smaller "CI Image":
https://github.com/zephyrproject-rtos/docker-image/pkgs/container/zephyr-build

Signed-off-by: Marc Herbert <[email protected]>
(cherry picked from commit 75fa04d)
  • Loading branch information
marc-hb authored and lgirdwood committed Sep 26, 2023
1 parent 4b7d52b commit 0b3478a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/sudo-cwd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ exec_as_cwd_uid()
local current_user; current_user="$(id -un)"

# Copy sudo permissions just in case the build needs it
sudo sed -e "s/$current_user/$cwd_user/" /etc/sudoers.d/"$current_user" |
if test -e /etc/sudoers.d/"$current_user"; then
sudo sed -e "s/$current_user/$cwd_user/" /etc/sudoers.d/"$current_user" |
sudo tee -a /etc/sudoers.d/"$cwd_user"
sudo chmod --reference=/etc/sudoers.d/"$current_user" \
sudo chmod --reference=/etc/sudoers.d/"$current_user" \
/etc/sudoers.d/"$cwd_user"
fi
}

# Double sudo to work around some funny restriction in
Expand Down

0 comments on commit 0b3478a

Please sign in to comment.