Skip to content

[BUG] USER_NAME=b falsely matches 'bin' user due to loose grep pattern #118

Description

@brendandebeasi

Current Behavior

Setting USER_NAME=b causes the container to fail with:

*** USER_NAME cannot be set to an user that already exists in /etc/passwd. Halting init. ***

However, there is no user b in /etc/passwd. The init script appears to use a loose pattern match (e.g., grep "^b") which incorrectly matches the bin user.

Expected Behavior

Short usernames like b should work if they don't exactly match an existing username. The check should use exact matching, e.g.:

grep "^${USER_NAME}:" /etc/passwd

instead of:

grep "^${USER_NAME}" /etc/passwd

Steps To Reproduce

  1. Run container with USER_NAME=b:
docker run --rm -e USER_NAME=b -e PUBLIC_KEY="ssh-ed25519 AAAA..." lscr.io/linuxserver/openssh-server:latest
  1. Observe error: USER_NAME cannot be set to an user that already exists

  2. Verify b doesn't exist:

docker run --rm lscr.io/linuxserver/openssh-server:latest cat /etc/passwd | grep "^b:"
# No output - user 'b' does not exist
  1. The bin user exists and starts with 'b', causing false positive:
bin:x:1:1:bin:/bin:/sbin/nologin

CPU Architecture

x86-64

Docker Creation

docker run -d \
  -e PUID=1000 \
  -e PGID=1000 \
  -e USER_NAME=b \
  -e PUBLIC_KEY="ssh-ed25519 AAAA..." \
  -p 2222:2222 \
  lscr.io/linuxserver/openssh-server:latest

Container Logs

[migrations] started
[migrations] no migrations found
*** USER_NAME cannot be set to an user that already exists in /etc/passwd. Halting init. ***

Environment

  • OS: Ubuntu 22.04 on Dokploy
  • Docker: Docker Swarm mode
  • Image version: 10.2_p1-r0-ls213

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions