Alter permissions when adding and removing users

This commit is contained in:
Bob Mottram 2016-11-29 14:42:27 +00:00
parent 0d568644e0
commit 4b81fde030
2 changed files with 8 additions and 0 deletions

View File

@ -75,8 +75,12 @@ fi
MINIMUM_PASSWORD_LENGTH=$(cat /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-passwords | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
NEW_USER_PASSWORD="$(openssl rand -base64 30 | cut -c1-${MINIMUM_PASSWORD_LENGTH})"
chmod 700 /etc/shadow
chmod 700 /etc/gshadow
useradd -m -p "$NEW_USER_PASSWORD" -s /bin/bash $ADD_USERNAME
adduser $ADD_USERNAME sasl
chmod 0000 /etc/shadow
chmod 0000 /etc/gshadow
if [ ! -d /home/$ADD_USERNAME ]; then
echo $'Home directory was not created'

View File

@ -136,7 +136,11 @@ do
fi
done
chmod 700 /etc/shadow
chmod 700 /etc/gshadow
userdel -r $REMOVE_USERNAME
chmod 0000 /etc/shadow
chmod 0000 /etc/gshadow
if [ -d /home/$REMOVE_USERNAME ]; then
rm -rf /home/$REMOVE_USERNAME