From 4301c4c7ebf5d162aed1b9fef46d0925d59fcbb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Wed, 30 Mar 2022 10:39:10 +0200 Subject: [PATCH] Fix group permission --- duplicati/create.homedir.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/duplicati/create.homedir.sh b/duplicati/create.homedir.sh index 13a88a7..5662312 100755 --- a/duplicati/create.homedir.sh +++ b/duplicati/create.homedir.sh @@ -350,7 +350,7 @@ fix_directory_permissions() { # {{{ ## Setting new permissions fail by default return_fix_directory_permissions="1" - if chown --silent "${local_username}" -- "${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 − \ Successfully fix permissions for ${RED}${local_directory}${COLOR_DEBUG} (user: ${local_username})." return_fix_directory_permissions="0" @@ -410,6 +410,8 @@ main() { # {{{ ## Parse users list {{{ while IFS= read -r username; do + user_groupname=$(id --group -- "${username}" \ + || error_message "Can't get the primary group uid for ${username} user." 6) ### Create user's home directory {{{ ### OR Exit create_directory "${home_base}/${username}" \ @@ -417,8 +419,8 @@ main() { # {{{ ### }}} ### 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 + fix_directory_permissions "${home_base}/${username}" "${username}" "${user_groupname}" \ + || error_message "Can't fix permissions for ${username} home directory (path: ${home_base}/${username}, username: ${username}, group: ${user_groupname}. Please use --debug option." 7 ### }}} done < "${ldap_user_list_path}"