-
Notifications
You must be signed in to change notification settings - Fork 66
Stabilize UID/GID handling: create users before groups #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
### Summary Currently the entrypoint creates groups before users. On Alpine, this can cause user creation to fail if a `GROUP_*` and an `ACCOUNT_*` are configured with the same numeric ID (e.g. UID=1000 and GID=1000). In this case `adduser` fails and Samba does not export the shares. By creating users first, the UID can always be allocated. If the same numeric GID is later requested, `addgroup` fails harmlessly with "gid in use". The user is still created successfully and the container continues normally. ### Benefits - Prevents confusing failures when UID and GID collide in env configuration. - Still works for all existing setups (no regressions). - Safer and more predictable behavior in environments where UID=GID mappings are common for volume ownership. ### Notes This does not claim that UID=GID was previously impossible in all cases. It was always possible if no `GROUP_*` collided. The change simply hardens the entrypoint against collisions when both are defined.
Stabilize UID/GID handling: create users before groups
Hi thanks for your work. But I like to argue that as I clearly state in the readme, you should not try to create the usergroups yourself - it's the systems job - groups are for grouping only, take higher ids and try to avoid those collisions. if you don't need to group users to groups, ignore groups compleletly. do you see any flaw/problems I don't see right now? |
Hi and thanks for the quick feedback! I understand your point about the risk, and it makes sense to pay careful attention to this. My use case was simply to streamline UID/GID across my systems for consistency. I had the patch from the PR in place and it worked, but later I realized that using the environment variables correctly was already enough — so the patch wasn’t actually necessary for my setup. What confused me was that the container failed hard when I defined both a group and a user with ID 1000 (just for consistency as described above). I probably overlooked that part of the README, which added to my misunderstanding. I completely understand if you decide not to merge this PR for the reasons you mentioned, if you don’t see a benefit for the image. |
good to read, that you also see my point and that you don't see problems or other benefits in your contribution. If I suspect correctly I'll keep it open, maybe someone really needs this feature (for some active directory syncronisation stuff I'm currently not seeing) |
Thanks for the clarification. That helps me see the distinction better. Just to give a bit more background: I run the Samba containers as sidecars in unprivileged LXCs on a Proxmox cluster. The PVE host mounts the Samba shares and rebinds them into other unprivileged LXCs that cannot mount SMB themselves. Because of that, I need UID/GID 1000:1000 for consistency across host and containers. Since I only have a single user I don’t rely on group ACLs at all. What caused my issue originally was simply that I also added a
is already enough. While the following lead to the crash:
So I fully understand your concern about breaking group ACL semantics if both UID and GID are defined the same. In my case it was just a misconfiguration. I just wanted to share my use case and where the confusion came from, in case it helps others. |
Summary
Currently the entrypoint creates groups before users. On Alpine, this can cause
user creation to fail if a
GROUP_*
and anACCOUNT_*
are configured with thesame numeric ID (e.g. UID=1000 and GID=1000). In this case
adduser
fails andSamba does not export the shares.
By creating users first, the UID can always be allocated. If the same numeric
GID is later requested,
addgroup
fails harmlessly with "gid in use". The useris still created successfully and the container continues normally.
Benefits
common for volume ownership.
Notes
This does not claim that UID=GID was previously impossible in all cases. It was
always possible if no
GROUP_*
collided. The change simply hardens theentrypoint against collisions when both are defined.