diff --git a/client/fix_backuppc_linux_sudo.sh b/client/fix_backuppc_linux_sudo.sh index 46c8c6a..a74e38c 100755 --- a/client/fix_backuppc_linux_sudo.sh +++ b/client/fix_backuppc_linux_sudo.sh @@ -13,6 +13,7 @@ USER_ID=$(id -u) BACKUP_USER_LIST="backup backuppc" SUDOERS_D_INCLUDE_LINE="#includedir /etc/sudoers.d" +SUDOERS_MAIN_CONF="/etc/sudoers" BACKUP_SUDOERS_LINE_REGEXP="backuppc.*ALL.*=.*(ALL:ALL).*NOEXEC:NOPASSWD:.*/usr/bin/rsync" BACKUP_SUDOERS_LINE="backup ALL=(ALL:ALL) NOEXEC:NOPASSWD: /usr/bin/rsync @@ -44,7 +45,7 @@ is_sudoers_line() { line_to_check="${1}" - if grep -q -- "${line_to_check}" /etc/sudoers + if grep -q -- "${line_to_check}" "${SUDOERS_MAIN_CONF}" then [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Function is_sudoers_line() — ${line_to_check} line is available in sudo configuration." return "${SUCCESS}" @@ -73,15 +74,14 @@ is_backup_sudoers_line() add_sudoers_conf() { sudoers_conf="${1}" - sudoers_file="/etc/sudoers" ## Set sudoers configuration for BackupPC - cat << EOF >> "${sudoers_file}" + cat << EOF >> "${SUDOERS_MAIN_CONF}" # Added by a script ${sudoers_conf} EOF - [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Function add_sudoers_conf() — ${sudoers_file} was modified." + [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Function add_sudoers_conf() — ${SUDOERS_MAIN_CONF} was modified." } ## ]]] ## Add some configuration to a specific file under sudoers.d/ [[[