[systemd-devel] mkosi.postinst and user home permissions

Federico Bruni fede at inventati.org
Wed Jul 5 16:47:36 UTC 2017



Il giorno mer 5 lug 2017 alle 11:51, Federico Bruni 
<fede at inventati.org> ha scritto:
> 
> 
> Il giorno mar 4 lug 2017 alle 12:28, Federico Bruni 
> <fede at inventati.org> ha scritto:
>> Hi all
>> 
>> I hope this is the right place to ask questions about mkosi.
>> If not, please advise where I should ask.
>> 
>> I'm building fedora-26 in a directory.
>> I want to add a normal user, so I've added to mkosi.postinst:
>> 
>> useradd dev -p mypassword
>> usermod dev -a -G wheel
>> 
>> These two commands work fine, but the permissions are not correct:
>> 
>> # ls -l /home/
>> total 4
>> drwxrwxr-x 2 root root 4096 Jul  3 18:13 dev
>> 
>> Is this a bug? Or maybe what I'm trying to do should be accomplished 
>> in another way?
>> As a workaround, I might try add a third line to mkosi.postinst:
>> 
>> chown -R dev:dev /home/dev
>> 
>> 
> 
> Further to above, there are more problems:
> 
> - files in /etc/skel were not copied in /home/dev
> - dev user password is not saved in /etc/passwd, so I cannot log in 
> with that user
> 
> These problems do not occur if I create an user within the container:
> 
> # useradd test -p testing!
> # ls -a /home/test/
> .  ..  .bash_logout  .bash_profile  .bashrc
> # ls -l /home
> drwx------ 2 test test 4096 Jul  5 11:45 test
> 
> So it's not a bug in shadow-utils.
> It must be something about how mkosi.postinst work. Unfortunately I 
> don't have any mkosi examples to look at, in order to find any easy 
> mistake I might have done.
> 

Ok, problem found: I put a file in mkosi.extra/home/dev instead of 
mkosi.extra/etc/skel.
mkosi first copied that file, then launched the postinst script with 
the useradd command, which warned (correctly) that /home/dev already 
existed.

Sorry for the noise







More information about the systemd-devel mailing list