Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 720948 - sys-apps/shadow: unconditionally depend on the mail group
Summary: sys-apps/shadow: unconditionally depend on the mail group
Status: RESOLVED WONTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal trivial (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2020-05-04 14:37 UTC by David Michael
Modified: 2020-09-09 20:32 UTC (History)
2 users (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 David Michael 2020-05-04 14:37:53 UTC
The modes of mail spool directories change depending on if acct-group/mail was installed at the time of user creation.  This is due to an intentional runtime check to support the mail group:

https://github.com/shadow-maint/shadow/blob/master/src/useradd.c#L2311-L2320

Since not much depends on acct-group/mail, early users on a minimal system will have 0600 mail spools, while users created after installing something that depends on it (e.g. Emacs) will have 0660.

I'm opening this as a feature request to suggest an unconditional RDEPEND="acct-group/mail" on sys-apps/shadow to fix this inconsistency, since the mail group is considered a base system group included by default in other distros (Fedora, Arch, etc.).

Reproducible: Always
Comment 1 Larry the Git Cow gentoo-dev 2020-09-07 20:44:31 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f065b54fc2420c72d1d248b6a96c52c81f00d141

commit f065b54fc2420c72d1d248b6a96c52c81f00d141
Author:     David Michael <fedora.dm0@gmail.com>
AuthorDate: 2020-09-03 12:28:25 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2020-09-07 20:43:57 +0000

    sys-apps/shadow: require the mail group at runtime
    
    Closes: https://bugs.gentoo.org/720948
    Package-Manager: Portage-3.0.4, Repoman-2.3.23
    Signed-off-by: David Michael <fedora.dm0@gmail.com>
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 sys-apps/shadow/shadow-4.8-r5.ebuild   | 1 +
 sys-apps/shadow/shadow-4.8.1-r3.ebuild | 1 +
 2 files changed, 2 insertions(+)
Comment 2 Andrew Aladjev 2020-09-08 14:10:44 UTC
Hekki
Comment 3 Andrew Aladjev 2020-09-08 14:22:32 UTC
Hello, there is a problem with this commit. "sys-apps/shadow" provides /usr/sbin/groupadd which is required for "acct-group/mail". This dependency is circular. System without "sys-apps/shadow" is not able to install "acct-group/mail":

>>> Merging acct-group/mail-0 to /                                                                                                                                                                                
 * Adding group 'mail' to your system ...                                                                                                                                                                         
 *  - Groupid: 12                                                                                                                                                                                                 /var/tmp/portage/acct-group/mail-0/temp/environment: line 625: groupadd: command not found                                                                                                                        
 * ERROR: acct-group/mail-0::gentoo failed (preinst phase):                                                                                                                                                       
 *   (no error message)                                                                                                                                                                                           
 *                                                                                                                                                                                                                
 * Call stack:                                                                                                                                                                                                    
 *     ebuild.sh, line 125:  Called pkg_preinst                                                                                                                                                                   
 *   environment, line 971:  Called acct-group_pkg_preinst                                                                                                                                                        
 *   environment, line 273:  Called enewgroup 'mail' '12'                                                                                                                                                         
 *   environment, line 625:  Called die                                                                                                                                                                           
 * The specific snippet of code:                                                                                                                                                                                  
 *               groupadd -r ${opts} "${egroup}" || die

Please add condition that will allow to resolve circular dependency.
I think the right solution will be to add something like "shadow" use that will force "acct-group" not to try creating user and group.
Comment 4 Andrew Aladjev 2020-09-08 14:28:03 UTC
Solution for now: cross compile shadow before using portage.
Comment 5 Larry the Git Cow gentoo-dev 2020-09-08 15:17:12 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=eee1262e647de4719dfadb1ff93ca0b4c6476feb

commit eee1262e647de4719dfadb1ff93ca0b4c6476feb
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2020-09-08 15:12:02 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2020-09-08 15:12:02 +0000

    Revert "sys-apps/shadow: require the mail group at runtime"
    
    The acct-{user,group} eclasses call useradd and groupadd to create
    users and groups. This is esentually a circular dependency that needs
    to be resolved somehow.
    
    Bug: https://bugs.gentoo.org/720948
    Reverts: f065b54fc2420c72d1d248b6a96c52c81f00d141
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 sys-apps/shadow/shadow-4.8-r5.ebuild   | 1 -
 sys-apps/shadow/shadow-4.8.1-r3.ebuild | 1 -
 2 files changed, 2 deletions(-)
Comment 6 Andrew Aladjev 2020-09-08 21:17:09 UTC
This solutions looks fine, thank you.
Comment 7 Mikle Kolyada (RETIRED) archtester Gentoo Infrastructure gentoo-dev Security 2020-09-09 15:54:55 UTC
This does not sound correct to me at all. If we only care about users' spools (do I understand you correctly?), why are we in need of creating a depepndency resolution mess if we can modify /etc/default/useradd?
Comment 8 David Michael 2020-09-09 17:03:35 UTC
The issue is mail spools being created inconsistently because acct-group/mail is only installed by unexpected packages.  The mail group won't have access to spool files for users created before something like Emacs is installed which depends on acct-group/mail (for some configurations).

The useradd command is what looks for the mail group when creating spool files, so having sys-apps/shadow PDEPEND on it sounds reasonably correct to me.  What setting in /etc/default/useradd affects this?
Comment 9 Mikle Kolyada (RETIRED) archtester Gentoo Infrastructure gentoo-dev Security 2020-09-09 19:02:18 UTC
(In reply to David Michael from comment #8)
> The issue is mail spools being created inconsistently because
> acct-group/mail is only installed by unexpected packages. The mail group
> won't have access to spool files for users created before something like
> Emacs is installed which depends on acct-group/mail (for some
> configurations).
>
> The useradd command is what looks for the mail group when creating spool
> files, so having sys-apps/shadow PDEPEND on it sounds reasonably correct to
> me. What setting in /etc/default/useradd affects this?
​
No, your logic is incorrect, let me explain:
​
1.) we have the default mail spool path shadow respects
​
~ % grep "/var/spool/mail" /etc/login.defs
MAIL_DIR /var/spool/mai
​
2.) In the meantime, the directory itself belongs to:
​
~ % equery b /var/spool/mail
* Searching for /var/spool/mail ...
acct-user/mail-0 (/var/spool/mail)
acct-user/postmaster-0 (/var/spool/mail)
​
3.) useradd will create a mail spool file if only:
a.) the /var/spool/mail directory existed before an useradd call
(useradd itslef does not create the directory)
b.) the option CREATE_MAIL_SPOOL in the /etc/default/useradd is explicitly set to yes. In gentoo we are shipping our own useradd config with this option being disabled (simply not being enabled). As a result useradd does not create spool files at all.
​
All above said that change you are proposing is incorrect.
Comment 10 David Michael 2020-09-09 20:01:46 UTC
If your point boils down to that you think /var/spool/mail can only exist from installing acct-group/mail, then that explains our difference.  My systems first boot after provisioning with a blank /var, and I have tmpfiles create the FHS layout (and whatever else Gentoo needs but doesn't create like /var/empty).  So I do have the /var/spool/mail directory while nothing installs acct-group/mail.
Comment 11 Mikle Kolyada (RETIRED) archtester Gentoo Infrastructure gentoo-dev Security 2020-09-09 20:20:33 UTC
(In reply to David Michael from comment #10)
> If your point boils down to that you think /var/spool/mail can only exist
> from installing acct-group/mail, then that explains our difference.  My
> systems first boot after provisioning with a blank /var, and I have tmpfiles
> create the FHS layout (and whatever else Gentoo needs but doesn't create
> like /var/empty).  So I do have the /var/spool/mail directory while nothing
> installs acct-group/mail.

Nobody prevents you from having pretty custom installation, that is ok, the point is it has nothing to do with shadow.
Comment 12 Mike Gilbert gentoo-dev 2020-09-09 20:32:14 UTC
I wouldn't really call this "invalid"; we do have some automagic behavior here. It seems like there really should be a config option to allow the sysadmin to control the group assigned to new spool directories.

Changing to WONTFIX instead.