Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 958979 - acct-user/* ACCT_USER_HOME_PERMS and ACCT_USER_HOME_OWNER do not update owner or perms
Summary: acct-user/* ACCT_USER_HOME_PERMS and ACCT_USER_HOME_OWNER do not update owner...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2025-06-24 14:35 UTC by Henning Schild
Modified: 2025-06-24 15:28 UTC (History)
6 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 Henning Schild 2025-06-24 14:35:11 UTC
ACCT_USER_HOME_PERMS and ACCT_USER_HOME_OWNER should control the owner and the permission bits of the users homedir. But they only really work for the first time the package gets installed. Or for the first install of one of several packages, i.e. acct-user/mail and acct-user/postmaster share /var/spool/mail
If a directory already pre-existed before merge, neither perms nor owner will ever be updated.

I found this when debugging local mail delivery problems on two rather old gentoo installations, even predating acct-user. What acct-user/mail should have set was rather off.

Steps to repro (best do this in docker or remember to undo):

1. check your current perms/owner on /var/spool/mail (assuming acct-user/mail is installed already)
  ls /var/spool/mail/ -al
  > drwxrwsr-t 2 root mail 4096 Jun 22 17:29 .

if it differs you already reproduced and likely used an older system

2. mess it up a bit
  chmod o-rtx /var/spool/mail
  chown mail:mail /var/spool/mail/
  ls /var/spool/mail/ -al
  > drwxr-s--- 1 mail mail 4096 Jun 22 17:29 .

3. repair it
  emerge acct-user/mail
  ls /var/spool/mail/ -al
  drwxr-s--- 1 root mail 4096 Jun 22 17:29 .

4. finally really repair it in case you care about that system you used
  chmod 03755 /var/spool/mail
  chown root:mail /var/spool/mail

Expected result would be that "emerge acct-user/mail" would control via ACCT_USER_HOME_OWNER and ACCT_USER_HOME_PERMS and therefore repair the damage done in step 2.
The actual result is that nothing happens and ACCT_USER_HOME_OWNER/_PERMS have no effect on a reinstall or upgrade.

This is bad because permission bits can never be updated using these two variables, which smell like security for sure. And updates are necessary over time.
Comment 1 Henning Schild 2025-06-24 14:35:22 UTC
https://github.com/gentoo/portage/pull/1381
Comment 2 Henning Schild 2025-06-24 14:46:30 UTC
Here is one example where a shared dir and merge order have been a problem before

https://bugs.gentoo.org/913346
Comment 3 Henning Schild 2025-06-24 14:54:12 UTC
And here are two examples of commits which likely never worked as intended when the package was previously installed.

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

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=a356dc6c6272ec93eca5c34e008d12fe2f9a7475
Comment 4 Mike Gilbert gentoo-dev 2025-06-24 15:06:15 UTC
This is a general issue with any directory installed by Portage: the permissions are only set by the initial merge. acct-user isn't really special here.
Comment 5 Henning Schild 2025-06-24 15:20:51 UTC
The general issue is known and it for sure is also a feature and not just an issue. However the two variables even existing strongly suggest that owner/perm manipulation is possible.

In my PR i suggested a patch which likely goes way too far. But maybe an "ewarn" in postinst could do the trick in the end. Or some sort of dispatch-fperms tool, where users decide which local changes to keep and which upstream changes to apply.
Comment 6 Mike Gilbert gentoo-dev 2025-06-24 15:26:41 UTC
Gotcha, I'm just catching up on the backstory here and all the linked bugs.

I added a PR to work around the issue for acct-user.eclass.