Maxime Devos <maximede...@telenet.be> skribis: > I don't think the problem is that the uid of /home/... was wrong, > rather I think the problem is that Guix has forgotten the uid and hence > invents a new one to put in /etc/passwd instead of keeping the old one. > > A pitfall (noticed in the context of system accounts): the user could > have created files outside /home (e.g. in /tmp). IIUC, this would also > require a reboot to keep name<->uid consistent after "guix system > reconfigure". > > A 'chown -R' doesn't seem great to me from a security perspective > (seems very easy to get something wrong, and the TOCTTOU-free chownat > hasn't been merged yet in Guile), a performance perspective (what if > you have a huge $HOME). Also extra io -> slower boot + disk wear. > It also destroys some information, it's possible to intentionally have > files owned by other users inside $HOME.
There’s a talk by Lennart Poettering where he explains that, contrary to what one might think, “chown -R $HOME” turns out to be fast enough that systemd-homed can do that unconditionally (off the of my head). > Things that seem missing here to me: > > * a mechanism for remembering that an uid is still in use even though > the user has been removed (previously mentioned solutions: keep the > uid in /etc/passwd even though it is ‘removed’, or keep a separate > /etc/passwd-graveyard or such, etc.). For system accounts and user > accounts. Won't help in this particular case but would make more > general adding/removing user accounts less fragile (avoid > accidental reuse). How do you know that user “maxime” created today is “the same” as that “maxime” deleted a while back? You can’t. (gnu build accounts) is stateful in that it makes sure UIDs aren’t reused. (This is roughly the same algorithm as used by Shadow.) > * a mechanism for telling Guix ‘I'm renaming the user account, not > creating and removing a new one, so keep the uid’ Every system generation stands alone though; it’s functional, stateless, and all that. What does “rename” mean in this context? > * some heuristics for detecting mistakes (e.g.: if Guix thinks it > should create a directory /home/foo for uid 1234, but it notices > there is already a directory /home/bar with that uid 1234, then > that's super suspicious. Likewise, if Guix thinks the home > /home/foo should be owned by uid 1234, but it notices it's already > owned by 1235!=1234, that's also suspicious). Yeah. > * some mechanism for resolving mistakes Sure. Ludo’.