diff --git a/distrobox-init b/distrobox-init index 62b0d86647..e0dc2f72ea 100755 --- a/distrobox-init +++ b/distrobox-init @@ -1867,8 +1867,6 @@ if [ "${nvidia}" -eq 1 ]; then # First we find all non-lib files we need, this includes # - binaries # - confs - # - egl files - # - icd files # Excluding here the libs, we will threat them later specifically NVIDIA_FILES="$(find /run/host/etc/ /run/host/usr/ \ -path "/run/host/usr/lib/i386-linux-gnu/*" -prune -o \ @@ -1876,7 +1874,11 @@ if [ "${nvidia}" -eq 1 ]; then -path "/run/host/usr/lib32/*" -prune -o \ -path "/run/host/usr/lib64/*" -prune -o \ -path "/run/host/usr/lib/*" -prune -o \ - -path "/run/host/usr/include/boost/*" -prune -o \ + -path "/run/host/usr/share/*" -prune -o \ + -path "/run/host/usr/src/*" -prune -o \ + -path "/run/host/usr/include/*" -prune -o \ + -path "*.png" -prune -o \ + -path "*.svg" -prune -o \ -path "*.repo" -prune -o \ -iname "*nvidia*" -not -type d -print 2> /dev/null || :)" for nvidia_file in ${NVIDIA_FILES}; do @@ -1888,6 +1890,27 @@ if [ "${nvidia}" -eq 1 ]; then mount_bind "${nvidia_file}" "${dest_file}" ro"${locked_flags:+,${locked_flags}}" done + # First we find all non-lib files we need, this includes + # - egl files + # - icd files + # - doc files + # - src files + # Excluding here the libs, we will threat them later specifically + NVIDIA_FILES="$(find \ + /run/host/usr/share/*nvidia* \ + /run/host/usr/share/*vulkan* \ + /run/host/usr/share/doc/*nvidia* \ + /run/host/usr/src/*nvidia* \ + -not -type d -print 2> /dev/null || :)" + for nvidia_file in ${NVIDIA_FILES}; do + dest_file="$(printf "%s" "${nvidia_file}" | sed 's|/run/host||g')" + + # 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}")" + mount_bind "${nvidia_file}" "${dest_file}" ro"${locked_flags:+,${locked_flags}}" + done + # Then we find all directories with nvidia in the name and just mount them NVIDIA_DIRS="$(find /run/host/etc /run/host/usr -iname "*nvidia*" -type d 2> /dev/null || :)" for nvidia_dir in ${NVIDIA_DIRS}; do