89luca89 / 89luca89/distrobox

[Error] Avoid adding unmounted autofs root paths to the container

Open
#1,706 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
13k
Forks
541
Avg merge
20h 47m
Merged PRs (30d)
4

Description

**Describe the bug**

When the host root filesystem contains unmounted mountpoints to autofs mounts, the container creation step hangs for a long time, sometimes fails, and distrobox enter fails.
Recreating the container sometimes works (possibly because the filesystems where mounted by autofs)

**To Reproduce**
- Create directory under hosts '/' and add an autofs mountpoint for it.
- distrobox create
- distrobox enter

**Expected behavior**
Distrobox runs correctly

**Desktop (please complete the following information):**
- Podman version 4.9.4-rhel
- Host: Red Hat Enterprise Linux release 8.10 (Ootpa)
- Image: arch-toolbox
- Distrobox: 1.8.1.2
- Distrobox installed via install script into custom location

**Additional context**

Ignoring autofs mountpoints seems to fix the issue. I implemented this locally as a POC like this, in distrobox-create/generate_create_command():
```
for rootdir in /*; do

# Skip symlinks
if [ -L "${rootdir}" ]; then
continue
fi

target_opts=$(findmnt --notruncate --noheadings --list -t noautofs --output OPTIONS --target "${rootdir}" || true)

# Skip unmounted autofs targets
if [ -z "$target_opts" ]; then
continue
fi

# Find if the directory belongs to a RO mount, if do, mount it as RO+Rslave
if echo "$target_opts" | tr ',' '\n' | grep -q "^ro$"; then

result_command="${result_command}
--volume ${rootdir}:/run/host${rootdir}:ro,rslave"
continue
fi

# Else we mount it RW+Rslave
result_command="${result_command}
--volume ${rootdir}:/run/host${rootdir}:rslave"
done
```
Note the `-t noautofs` in `findmnt` command, this filters the results by filesystem type. Perhaps it would be wise to ignore other "problematic" filesystems like network filesystems (nfs, smb, etc) too.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.