Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 668180 - user.eclass: enewuser not setting group when creating home directory
Summary: user.eclass: enewuser not setting group when creating home directory
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-09 17:35 UTC by Christian Buchinger
Modified: 2022-12-07 00:01 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Buchinger 2018-10-09 17:35:11 UTC
As a follow-up of bug 668158 I'd like to mention that I think enewuser behaves not as intended when creating new users home directory.

enewuser calls useradd with -r, which means the home directory will not be created by useradd.

Therefore the following gets executed in enewuser() if the home dir was not created:

> mkdir -p "${ROOT}/${ehome}"
> chown "${euser}" "${ROOT}/${ehome}"
> chmod 755 "${ROOT}/${ehome}"

chown does not add a :<group> here. I think that's why the home directory is created with <user>:root instead of <user>:<group>.

A possible solution could be either adding -m to adduser or ${defgroup} to chown.
Comment 1 Thomas Deutschmann (RETIRED) gentoo-dev 2018-10-09 19:40:07 UTC
(In reply to Christian Buchinger from comment #0)
> Therefore the following gets executed in enewuser() if the home dir was not
> created:
> 
> > mkdir -p "${ROOT}/${ehome}"
> > chown "${euser}" "${ROOT}/${ehome}"
> > chmod 755 "${ROOT}/${ehome}"
> 
> chown does not add a :<group> here. I think that's why the home directory is
> created with <user>:root instead of <user>:<group>.

Well, mkdir is running as root, therefore the folder will be created with root's default permission. When calling chown we only specify user, therefore we don't tell chown that we want to change group as well.


> A possible solution could be either adding -m to adduser or ${defgroup} to
> chown.

Right, we would need to add group to that call. On first view it looks like you are right and we could use $defgroup but I need more testing/thinking about this.

But due to bug 668158 and friends, we wouldn't see any outcome of that change at the moment. So I am also not sure if we should mark this bug to depend on the portage change and only consider eclass change once portage was fixed.
Comment 2 Christian Buchinger 2018-10-09 20:02:20 UTC
(In reply to Thomas Deutschmann from comment #1)
> [...] 
> Right, we would need to add group to that call. On first view it looks like
> you are right and we could use $defgroup but I need more testing/thinking
> about this.

Yes, I guess we'd need to catch case when groups are not set at least.

> But due to bug 668158 and friends, we wouldn't see any outcome of that
> change at the moment. So I am also not sure if we should mark this bug to
> depend on the portage change and only consider eclass change once portage
> was fixed.

I see it as an isolated bug for enewuser(), yes. Just added your bug as reference because I found quite some ebuilds in the tree with the same pattern (enewgroup; enewuser with homedir; fowners for homedir;) but I didn't meant to depend on it.

The other problem (changes from src_install not being merged over existing stuff) still exists. (E.g. setting permissions.)
Comment 3 Sophie Hamilton 2018-10-22 21:16:08 UTC
This sounds like exactly the same bug which led to me documenting this behaviour at bug 614396 comment 7. They decided that the way to fix that bug was to fix the permissions afterwards... it didn't sound right to me at the time but I'm not a Gentoo dev, so.

It'd be nice to have this bug fixed once and for all!
Comment 4 Mike Gilbert gentoo-dev 2022-12-07 00:01:24 UTC
user.eclass has been removed from the gentoo repo.