Discussion:
[systemd-devel] mkosi.postinst and user home permissions
Federico Bruni
2017-07-04 10:28:34 UTC
Permalink
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

Thanks in advance
Federico
Federico Bruni
2017-07-05 09:51:29 UTC
Permalink
Il giorno mar 4 lug 2017 alle 12:28, Federico Bruni
Post by Federico Bruni
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.
useradd dev -p mypassword
usermod dev -a -G wheel
# 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?
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.
Federico Bruni
2017-07-05 16:47:36 UTC
Permalink
Il giorno mer 5 lug 2017 alle 11:51, Federico Bruni
Post by Federico Bruni
Il giorno mar 4 lug 2017 alle 12:28, Federico Bruni
Post by Federico Bruni
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.
useradd dev -p mypassword
usermod dev -a -G wheel
# 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?
chown -R dev:dev /home/dev
- 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
# 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
Lennart Poettering
2017-07-10 08:46:06 UTC
Permalink
Post by Federico Bruni
Hi all
I hope this is the right place to ask questions about mkosi.
Hmm, not really. We currently have no mailing list for mkosi
though. Maybe the github issue tracker of mkosi would be the best
place to discuss things like this for now.

But anyway, let's discuss this one issue here, given that it already
has been posted here.
Post by Federico Bruni
I'm building fedora-26 in a directory.
useradd dev -p mypassword
usermod dev -a -G wheel
# 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?
Uh, this appears very strange to me, this feels like a bug in
"useradd" indeed. I have no idea why the directory isn#t created
properly...

if you invoke "stat /home/dev" in that same script right after you
created the user, does it appear correct then?


Lennart
--
Lennart Poettering, Red Hat
Federico Bruni
2017-07-10 08:58:23 UTC
Permalink
Il giorno lun 10 lug 2017 alle 10:46, Lennart Poettering
Post by Lennart Poettering
Post by Federico Bruni
I'm building fedora-26 in a directory.
useradd dev -p mypassword
usermod dev -a -G wheel
# 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?
Uh, this appears very strange to me, this feels like a bug in
"useradd" indeed. I have no idea why the directory isn#t created
properly...
I guess you missed my follow-ups in this thread.
The problem was caused by a file (.bashrc) I placed in
mkosi.extra/home/dev.
My understanding is that mkosi first copied that file, then run the
postinst script containing the useradd command, which failed
(correctly) as /home/dev already existed.

I've moved the file to mkosi.extra/etc/skel and now everything works
fine.

Loading...