Also fix permissions on homedir

This commit is contained in:
Jeremy Gardais 2022-12-05 11:43:35 +01:00
parent 06341fa303
commit c30debad59
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 16 additions and 1 deletions

View File

@ -356,15 +356,30 @@ fix_directory_permissions() { # {{{
## Setting new permissions fail by default ## Setting new permissions fail by default
return_fix_directory_permissions="1" return_fix_directory_permissions="1"
## Change owner {{{
if chown --silent "${local_username}:${local_user_groupname}" -- "${local_directory}" 2> /dev/null; then if chown --silent "${local_username}:${local_user_groupname}" -- "${local_directory}" 2> /dev/null; then
debug_message "fix_directory_permissions \ debug_message "fix_directory_permissions \
Successfully fix permissions for ${RED}${local_directory}${COLOR_DEBUG} (user: ${local_username})." Successfully fix permissions for ${RED}${local_directory}${COLOR_DEBUG} (user: ${local_username})."
## }}}
## Remove group and others permissions {{{
## Cause users might share the same group…
if chmod --silent g-rwx,o-rwx -- "${local_directory}" 2> /dev/null; then
debug_message "fix_directory_permissions \
Successfully remove permissions for group and other on ${RED}${local_directory}${COLOR_DEBUG}."
return_fix_directory_permissions="0" return_fix_directory_permissions="0"
## }}}
## If something went wrong with chmod or chown {{{
else
debug_message "fix_directory_permissions \
Error in 'chmod' command for ${RED}${local_directory}${COLOR_DEBUG} directory (user: ${local_username})."
return_fix_directory_permissions="1"
fi
else else
debug_message "fix_directory_permissions \ debug_message "fix_directory_permissions \
Error in 'chown' command for ${RED}${local_directory}${COLOR_DEBUG} directory (user: ${local_username})." Error in 'chown' command for ${RED}${local_directory}${COLOR_DEBUG} directory (user: ${local_username})."
return_fix_directory_permissions="1" return_fix_directory_permissions="1"
fi fi
## }}}
return "${return_fix_directory_permissions}" return "${return_fix_directory_permissions}"
} }