> On 2023-03-23 7:54 am, ch...@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 >
Give it a try. I tested it on a version 7.2 stable system. Get the permissions of /etc/skel Mine at 755 by default. Run: useradd -m testuser Verify /home/testuser is set to 755 Run: chmod 750 /etc/skel Run: useradd -m testuser2 Verify /home/testuser2 is set to 750 Run: chmod 755 /etc/skel Run: useradd -m testuser3 Verify /home/testuser3 is set to 755 I did not look at the code at all for this. Only using existing programs. If this should not be working then a patch will be needed somewhere. However I will state that having the ability to set the default permissions somewhere would be useful, and a requirement in some environments. Chuck