You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Webcam setup is skipped on every start after the first when /dev persists and mknod is not permitted #195
Hello, and thank you for this image. We build a small application image on top of it and found something in the webcam setup that may affect others who run without CAP_MKNOD.
In init-selkies-config, the webcam block runs only when /dev/video0 does not exist:
if [[ -z ${NO_WEBCAM+x} ]] && [[ ! -e /dev/video0 ]] && { mknod /dev/video0 c 81 0 2>/dev/null || touch /dev/video0 2>/dev/null; }; then
Where mknod is not permitted, touch leaves an empty regular file. If the container's /dev survives a restart of the init, the file is still there on the next start, the ! -e test is false and the whole block is skipped. SELKIES_WEBCAM_ENABLED is not set, the sidebar toggle is not shown and the interposer is not added to LD_PRELOAD. The webcam works on the first start and not on any later one.
The gamepad block just above does not have this problem, because it has no existence test and touch succeeds on a file that is already there.
We saw it on a host that runs the image inside a long-lived LXC container and restarts only the service inside it, so /dev (a tmpfs) outlives the restart.
Expected Behavior
The webcam is set up on every start, as the gamepad devices are.
A possible fix: dropping the [[ ! -e /dev/video0 ]] test would make the block behave like the gamepad one, since touch is harmless on an existing file. If the test is there to protect a real device passed in from the host, testing for a character device instead ([[ ! -c /dev/video0 ]]) would keep that and still recover from a leftover file.
Steps To Reproduce
Start the image without CAP_MKNOD and with a regular file already at /dev/video0, which is what a second start looks like on such a host (command below).
Look at /run/s6/container_environment/: LD_PRELOAD and SELKIES_WEBCAM_ENABLED are absent.
Repeat without the touch: both are set.
Environment
- OS: Debian based host, image run inside an LXC container
- How docker service was installed: reproduced with stock Docker on a desktop
CPU architecture
x86-64
Docker creation
docker run --rm --cap-drop=MKNOD \
--entrypoint sh ghcr.io/linuxserver/baseimage-selkies:dev-5e1478e9-ls23 \
-c 'touch /dev/video0; exec /init'
The same line is on master and ubunturesolute today.
Container logs
Nothing is logged for this: the block is skipped silently. State after start:
$ ls -la /dev/video0
-rwxrwxrwx 1 root root 0 ... /dev/video0
$ cat /run/s6/container_environment/LD_PRELOAD
cat: /run/s6/container_environment/LD_PRELOAD: No such file or directory
$ cat /run/s6/container_environment/SELKIES_WEBCAM_ENABLED
cat: /run/s6/container_environment/SELKIES_WEBCAM_ENABLED: No such file or directory
We work around it by removing a regular-file /dev/video0 before /init, so there is no urgency on our side, and we are glad to test a change. Thank you for your work on this.
Thank you, that makes sense. The host is StartOS, which runs the image's root filesystem inside a long-lived LXC container and, on a service restart, starts the image's entrypoint (/init) again in that same container. The root filesystem is fresh (a new overlay each time) but /dev is a tmpfs that belongs to the outer container, so it carries over. So it is not a clean container init in your sense, and we understand if you consider that outside what the image supports. We remove the leftover file before /init on our side, which is enough for us. If testing for a character device instead of existence is something you would take, it would make the block robust to this case, but we are happy for this to be closed otherwise.
I mean I see no harm if you want to PR a change to init to the dev branch, we do other cleanup like /dev/shm for podman, there is no great reason we could not do the same here if what is detected in the FS is allready a file then proceed with the env changes. I am weary of detecting devices via mknod though as someone could be mounting in a real video device and using v4l2 loopback. So you would want to scope it to is /dev/video0 a file or is /dev/js0 a file for example, not just that it is exists.
Thank you, that is a fair concern about real video devices. We have opened #196 against dev. It follows your suggestion: the block proceeds when /dev/video0 is already a regular file, and a character device there is left alone as before, so a mounted device or a v4l2 loopback is not touched.
We tested it on the current dev image without CAP_MKNOD, with /dev/video0 absent, as a regular file, and as a character device; the details are in the PR. Happy to change anything there.
Activity
thelamer commentedon Oct 3, 2026
The init in general is assumed to be oneshot on a clean container init. There are likely other assumed logic points revolving around this.
When you say restarting the service what does that mean how are you restarting it ?
TwentyOneLife commentedon Oct 3, 2026
Thank you, that makes sense. The host is StartOS, which runs the image's root filesystem inside a long-lived LXC container and, on a service restart, starts the image's entrypoint (
/init) again in that same container. The root filesystem is fresh (a new overlay each time) but/devis a tmpfs that belongs to the outer container, so it carries over. So it is not a clean container init in your sense, and we understand if you consider that outside what the image supports. We remove the leftover file before/initon our side, which is enough for us. If testing for a character device instead of existence is something you would take, it would make the block robust to this case, but we are happy for this to be closed otherwise.thelamer commentedon Oct 3, 2026
I mean I see no harm if you want to PR a change to init to the dev branch, we do other cleanup like /dev/shm for podman, there is no great reason we could not do the same here if what is detected in the FS is allready a file then proceed with the env changes. I am weary of detecting devices via mknod though as someone could be mounting in a real video device and using v4l2 loopback. So you would want to scope it to is /dev/video0 a file or is /dev/js0 a file for example, not just that it is exists.
TwentyOneLife commentedon Oct 7, 2026
Thank you, that is a fair concern about real video devices. We have opened #196 against
dev. It follows your suggestion: the block proceeds when/dev/video0is already a regular file, and a character device there is left alone as before, so a mounted device or a v4l2 loopback is not touched.We tested it on the current dev image without
CAP_MKNOD, with/dev/video0absent, as a regular file, and as a character device; the details are in the PR. Happy to change anything there.set up the webcam when /dev/video0 is a leftover regular file (#196)
thelamer commentedon Oct 9, 2026
This is in all bases now it will take time to build and waterfall to downstream images