New comment by sgn on void-packages repository https://github.com/void-linux/void-packages/pull/24754#issuecomment-690304351 Comment: On 2020-09-10 06:48:52-0700, "Andrew J. Hesford" wrote: > The more I look at this, the more I see breakage when populating an > alternate root. Won't `useradd`, `usermod` and `groupadd` always act > on the system root? These commands provide a `--root` option that > seems to redirect their actions in the way we want, but we aren't > using that option now. It's also not clear from their man pages how > well these commands get along with directory services. Yes, it's broken. > Ignoring `system-accounts` unless `$ROOTDIR = /` like @ericonr > suggests is a reasonable way to avoid the worst of these issues. If > you go that route, the hook should at least print all of the users > and groups that should exist (along with ID numbers, if provided) > for the package to function as expected. Agree. > If we really want to do this the "right" way, it's not obvious to me > that the existence tests add value. For groups, just `groupadd > --root ...` and catch the return code to know the difference between > a real failure and an attempt to create a group that already exists. > For users, just `useradd --root ...` and, if the return code > indicates that the username already exists, try `usermod --root ...` > instead. Hm, I think we need `groupadd --prefix` and `useradd --prefix` instead.