Thursday, March 23, 2023

Re: Home folder default permission

On 2023-03-23 7:54 am, chuck@qatland.com wrote:
>
> useradd makes use of the permissions of /etc/skel The defaults is 755.
> If you change it to 750 new user directories will then have 750 as the
> default on their home directories.

Does it? Looking at the code, it doesn't copy /etc/skel, it runs "mkdir
-p $HOME"
(https://github.com/openbsd/src/blob/869ed59d760a94e6086f364d91f2b56074421cc9/usr.sbin/user/user.c#L1208)

I wonder if running
UMASK=`umask` && umask 077 && useradd .... ; umask "$UMASK"
would be sufficient.

The related adduser command
(https://github.com/openbsd/src/blob/master/usr.sbin/adduser/adduser.perl)
explicitly creates the home directory with permissions 0755, although
that
should be affected by umask as well.

Matthew

No comments:

Post a Comment