Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[gentoo-dev] RFC: Setting default HOME_MODE in /etc/login.defs

11 views
Skip to first unread message

Daniel Simionato

unread,
Feb 10, 2024, 12:00:03 PMFeb 10
to
Hello,
 I'd like to start a discussion regarding setting HOME_MODE by default in the /etc/login.defs file (owned by sys-apps/shadow package).


HOME_MODE affects only useradd and newuser commands: if HOME_MODE is set, they will use the specified permission when creating a user home directory, otherwise the default UMASK will be used.
Since the default umask is 022, keeping HOME_MODE unset will result in home readable home directories created by useradd, which goes against security best practices.

The proposal is to set HOME_MODE to 0700, or at least 0750: RedHat and RH based distros, OpenSuse, ArchLinux all set it to 0700, Ubuntu has it at 0750. Debian and Gentoo are two exceptions, keeping the upstream value of HOME_MODE (although login.defs is changed in other ways).

I previously made a PR on github where you can find more details (https://github.com/gentoo/gentoo/pull/35231), but as pointed in the comments this probably warrants some discussion beforehand.

I can understand the argument against the change, which is keeping in sync with upstream and don't risk changing the historic default behaviour of tools some users might rely upon.

I do believe though there's merit in providing safer and secure defaults, so I would like HOME_MODE to have a safe default value for Gentoo and Gentoo based distros.

Have a nice day,
 Daniel

John Helmert III

unread,
Feb 10, 2024, 7:00:04 PMFeb 10
to
Setting it to 0700 makes good sense to me, unless someone has some
good example of this breaking anything. Deviating from upstream
defaults in following other distributions isn't exactly treading new
ground for us. And it's easy for the administrator to change to suit
their liking anyway (hopefully covering the "keep the status quo"
class of objections).
signature.asc

Alex Boag-Munroe

unread,
Feb 10, 2024, 8:10:04 PMFeb 10
to
0700 should be the default as far as I'm concerned. 750 makes sense in
some environments, but in those environments a sysadmin should know
well enough to make the changes when it is useful. I never understood
why world readable was default on Gentoo.

Alex Boag-Munroe

unread,
Feb 10, 2024, 9:30:05 PMFeb 10
to
On Sun, 11 Feb 2024 at 02:12, Eli Schwartz <eschw...@gmail.com> wrote:
<snip>
> - someone who added another account to their user group probably did so
> with the expectation that they'd be sharing files with that other
> account, and 700 mode in particular feels like going against that

This change of default would only affect creation of new
accounts/setup on new installs so anyone that already has another user
in their group would be unaffected. A notification on change of
default/updated documentation should be sufficient for people looking
to create accounts and give groups access to things in the future.

Ulrich Mueller

unread,
Feb 11, 2024, 3:10:04 AMFeb 11
to
I see no strong argument either way. However, changing the default is
somewhat intrusive, so I'd prefer staying with upstream. Also, are we
aware of any breakage caused by this?

As you've pointed out yourself, distros are inconsistent about it,
i.e. not much guidance from there. Maybe upstream would be a better
place for this discussion?

Ulrich
signature.asc

Sam James

unread,
Feb 11, 2024, 5:20:04 AMFeb 11
to

Michael Orlitzky <m...@gentoo.org> writes:

> On Sat, 2024-02-10 at 17:57 +0100, Daniel Simionato wrote:
>> Hello,
>> I'd like to start a discussion regarding setting HOME_MODE by default in
>> the /etc/login.defs file (owned by sys-apps/shadow package).
>>
>> Upstream keeps HOME_MODE commented:
>> https://github.com/shadow-maint/shadow/blob/3e59e9613ec40c51c19c7bb5c28468e33a4529d5/etc/login.defs#L207
>>
>> HOME_MODE affects only useradd and newuser commands: if HOME_MODE is set,
>> they will use the specified permission when creating a user home directory,
>> otherwise the default UMASK will be used.
>> Since the default umask is 022, keeping HOME_MODE unset will result in home
>> readable home direct
>
> umask 022 is also egregious, changing it to 027 would kill two birds.
> But in lieu of that, yes.

mgorny wrote in favour of this 13 years ago too:
https://blogs.gentoo.org/mgorny/2011/10/18/027-umask-a-compromise-between-security-and-simplicity/.

It would be a bigger change and require us to do a lot of daily-driver
testing first though.
signature.asc

Sam James

unread,
Feb 11, 2024, 5:20:04 AMFeb 11
to
I'm in favour, although I'd be curious as to why upstream shadow don't
just set it. It would be interesting to see if the discussion already
happened there at some point (surely it has?) and find out their
reasoning. (But that's not a blocker for proceeding.)

I want to hear more opinions first though. Thanks for raising this,
it's been in the back of my head.

>
> Have a nice day,
> Daniel

best,
sam
signature.asc

Eray Aslan

unread,
Feb 11, 2024, 6:00:03 AMFeb 11
to
On Sun, Feb 11, 2024 at 10:10:13AM +0000, Sam James wrote:
> I'm in favour, although I'd be curious as to why upstream shadow don't
> just set it. It would be interesting to see if the discussion already
> happened there at some point (surely it has?) and find out their
> reasoning. (But that's not a blocker for proceeding.)

I believe it is for historical reasons. Computer networks and terminals
used to be much friendlier places.

> I want to hear more opinions first though. Thanks for raising this,
> it's been in the back of my head.

Even though I do not really care either way, what problem exactly are we
trying to solve? Better security is just too vague an argument. I can
see the argument if we were selling to business (*cough*red hat*cough*)
but on the other hand, an argument can also be made for keeping to the
roots of computer networks and their naivete (keep information free and
all that stuff). In this regard, it is telling that only debian and
gentoo keep 022.

Consider taking it upstream as someone else (ulm?) already mentioned in
the discussion.

Thanks
--
Eray

Daniel Simionato

unread,
Feb 11, 2024, 6:20:05 AMFeb 11
to
The only previous upstream discussion I was able to find was this on the pkg-shadow-devel: https://marc.info/?l=pkg-shadow-devel&m=167120074926229&w=2(
(I don't think the unprivileged container limitation still applies, or at least it doesn't on my user with a 700 /home)

I can see the argument for keeping the status quo, but I still think it's better to err on the side of caution with default settings.
But I understand that my point of view might be skewed by personal preference or by professional experience, so I appreciate the everyone contributing their opinion.

I have opened a PR upstream to start discussion there https://github.com/shadow-maint/shadow/pull/946 .

For reference, the concrete use case that put me onto this (https://github.com/flatcar/Flatcar/issues/1353): provisioning users in Flatcar through ignition (cloud-init like) at first boot time, even if in the same config /etc/login.defs is changed, results in 755 home directories. Some more comments in this PR https://github.com/kubernetes-sigs/image-builder/pull/1400

The original PR that added HOME_MODE also refers generically to user bug reports due to the many ways umask can be overriden: https://github.com/shadow-maint/shadow/pull/208#issue-546914572

Thanks,
 Daniel

Michał Górny

unread,
Feb 11, 2024, 8:10:05 AMFeb 11
to
...and I've stopped using that a long time ago too because I kept
messing permissions up. These days I just explicitly switch umask if I
need something to be secure.

--
Best regards,
Michał Górny

signature.asc

Arsen Arsenović

unread,
Feb 11, 2024, 8:40:04 AMFeb 11
to
+1 for 0700. I also like the umask suggestions.
--
Arsen Arsenović
signature.asc

Daniel Simionato

unread,
Feb 13, 2024, 3:10:05 PMFeb 13
to
Hi,
the upstream PR was closed, this was the answer:

> No - distros like debian may get caught off guard. There's nothing wrong with downstreams patching their values in their deltas. We do not lightly make changes which change defaults.

https://github.com/shadow-maint/shadow/pull/946#issuecomment-1939667729

Have a nice day,
Daniel

Il giorno lun 12 feb 2024 alle ore 21:16 Michael Vetter
<jub...@iodoru.org> ha scritto:
>
> Hello,
>
> In case this mail is weirdly formatted please let me know. And if yes,
> please excuse me in advance..
> I 'm in favour as well. And in openSUSE we did this as well.
>
> Honestly I don't remember any upstream discussion about this and have no
> idea what it was done this way.
>
> I see Daniel already created
> https://github.com/shadow-maint/shadow/pull/946 for upstream yesterday.
>
>
> Best,
>
> Michael
>
>
0 new messages