Ensure to setup correct permissions on homedir
This commit is contained in:
parent
ec39784e14
commit
8eb7a52aef
|
@ -341,6 +341,28 @@ Error in 'mkdir' command for ${RED}${local_directory}${COLOR_DEBUG} directory."
|
|||
return "${return_create_directory}"
|
||||
}
|
||||
# }}}
|
||||
fix_directory_permissions() { # {{{
|
||||
|
||||
local_directory="${1}"
|
||||
local_username="${2}"
|
||||
local_user_groupname="${3}"
|
||||
|
||||
## Setting new permissions fail by default
|
||||
return_fix_directory_permissions="1"
|
||||
|
||||
if chown --silent "${local_username}" -- "${local_directory}" 2> /dev/null; then
|
||||
debug_message "fix_directory_permissions − \
|
||||
Successfully fix permissions for ${RED}${local_directory}${COLOR_DEBUG} (user: ${local_username})."
|
||||
return_fix_directory_permissions="0"
|
||||
else
|
||||
debug_message "fix_directory_permissions − \
|
||||
Error in 'chown' command for ${RED}${local_directory}${COLOR_DEBUG} directory (user: ${local_username})."
|
||||
return_fix_directory_permissions="1"
|
||||
fi
|
||||
|
||||
return "${return_fix_directory_permissions}"
|
||||
}
|
||||
# }}}
|
||||
main() { # {{{
|
||||
|
||||
## If ldapsearch command is not available {{{
|
||||
|
@ -393,6 +415,11 @@ main() { # {{{
|
|||
create_directory "${home_base}/${username}" \
|
||||
|| error_message "Can't create home directory (${home_base}/${username}) for ${username} user. Please use --debug option." 5
|
||||
### }}}
|
||||
### Fix permissions for this directory {{{
|
||||
### OR Exit
|
||||
fix_directory_permissions "${home_base}/${username}" "${username}" \
|
||||
|| error_message "Can't fix permissions for ${username} home directory (path: ${home_base}/${username}, username: ${username}. Please use --debug option." 7
|
||||
### }}}
|
||||
|
||||
done < "${ldap_user_list_path}"
|
||||
## }}}
|
||||
|
|
Loading…
Reference in New Issue