Skip to content

Commit

Permalink
virtme-ng: hide additional sudo settings
Browse files Browse the repository at this point in the history
Try to keep sudo settings as simple as possible and rely only on our
custom /etc/sudoers.

This can help to prevent potential permissions errors while using sudo
inside a virtme-ng guest.

Signed-off-by: Andrea Righi <[email protected]>
  • Loading branch information
Andrea Righi committed Feb 22, 2024
1 parent ef88452 commit e0d48fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions virtme/guest/virtme-init
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ fi
# Additional rw dirs required by snapd (if present)
[ -e /var/lib/snapd/cookie ] && mount -t tmpfs tmpfs /var/lib/snapd/cookie &

# Hide additional sudo settings
[ -e /var/lib/sudo ] && mount -t tmpfs tmpfs /var/lib/sudo &

# Fix up /etc a little bit
touch /tmp/fstab
mount --bind /tmp/fstab /etc/fstab
Expand Down Expand Up @@ -212,6 +215,9 @@ ip link set dev lo up

# Setup sudoers
real_sudoers=/etc/sudoers
if [ ! -e ${real_sudoers} ]; then
touch ${real_sudoers}
fi
tmpfile="`mktemp --tmpdir=/tmp`"
echo "Defaults secure_path=\"/usr/sbin:/usr/bin:/sbin:/bin\"" > $tmpfile
echo "root ALL = (ALL) NOPASSWD: ALL" >> $tmpfile
Expand Down
2 changes: 1 addition & 1 deletion virtme_ng_init
Submodule virtme_ng_init updated 1 files
+10 −0 src/main.rs

0 comments on commit e0d48fc

Please sign in to comment.