Skip to content

[BUG] Webcam setup is skipped on every start after the first when /dev persists and mknod is not permitted #195

Closed

Description

@TwentyOneLife

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

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

  1. 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).
  2. Look at /run/s6/container_environment/: LD_PRELOAD and SELKIES_WEBCAM_ENABLED are absent.
  3. 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.

Activity

  1. thelamer commented on Oct 3, 2026

    @thelamer
    Member

    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 ?

  2. TwentyOneLife commented on Oct 3, 2026

    @TwentyOneLife
    Author

    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.

  3. thelamer commented on Oct 3, 2026

    @thelamer
    Member

    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.

  4. TwentyOneLife commented on Oct 7, 2026

    @TwentyOneLife
    Author

    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.

  5. added a commit that references this issue on Oct 7, 2026
    64e29a3
  6. thelamer commented on Oct 9, 2026

    @thelamer
    Member

    This is in all bases now it will take time to build and waterfall to downstream images

  7. moved this from Issues to Done in Issue & PR Trackeron Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions