Skip to content

Commit

Permalink
init: improve nvidia integration, skip files when directory is alread…
Browse files Browse the repository at this point in the history
…y a ro-mountpoint, log with warnings

Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed Jan 19, 2025
1 parent 855e284 commit 236e2bf
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions distrobox-init
Original file line number Diff line number Diff line change
Expand Up @@ -1887,6 +1887,10 @@ if [ "${nvidia}" -eq 1 ]; then
for nvidia_file in ${NVIDIA_FILES}; do
dest_file="$(printf "%s" "${nvidia_file}" | sed 's|/run/host||g')"

if [ ! -w "$(dirname "${dest_file}")" ]; then
printf "Warning: skpping file %s, %s mounted as read-only\n" "${dest_file}" "$(dirname "${dest_file}")"
continue
fi
# Mounting read-only in a user namespace will trigger a check to see if certain
# "locked" flags (line noexec,nodev,nosuid) are changed. This ensures we explicitly reuse those flags.
locked_flags="$(get_locked_mount_flags "${nvidia_file}")"
Expand All @@ -1908,6 +1912,10 @@ if [ "${nvidia}" -eq 1 ]; then
for nvidia_file in ${NVIDIA_FILES}; do
dest_file="$(printf "%s" "${nvidia_file}" | sed 's|/run/host||g')"

if [ ! -w "$(dirname "${dest_file}")" ]; then
printf "Warning: skpping file %s, %s mounted as read-only\n" "${dest_file}" "$(dirname "${dest_file}")"
continue
fi
# Mounting read-only in a user namespace will trigger a check to see if certain
# "locked" flags (line noexec,nodev,nosuid) are changed. This ensures we explicitly reuse those flags.
locked_flags="$(get_locked_mount_flags "${nvidia_file}")"
Expand Down Expand Up @@ -1969,6 +1977,11 @@ if [ "${nvidia}" -eq 1 ]; then
continue
fi

if [ ! -w "$(dirname "${dest_file}")" ]; then
printf "Warning: skpping file %s, %s mounted as read-only\n" "${dest_file}" "$(dirname "${dest_file}")"
continue
fi

type="file"
if [ -L "${nvidia_lib}" ]; then
type="link"
Expand Down

0 comments on commit 236e2bf

Please sign in to comment.