Prefix sudoers related to backuppc with BACKUP_
This commit is contained in:
parent
4d3bfc9730
commit
e0e6800c3c
|
@ -11,10 +11,10 @@ DEBUG=1
|
|||
USER_ID=$(id -u)
|
||||
|
||||
BACKUP_USER_LOGIN="backup"
|
||||
SUDOERS_LINE_REGEXP="backuppc.*ALL.*=.*(ALL:ALL).*NOEXEC:NOPASSWD:.*/usr/bin/rsync"
|
||||
SUDOERS_LINE="backup ALL=(ALL:ALL) NOEXEC:NOPASSWD: /usr/bin/rsync
|
||||
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
|
||||
backuppc ALL=(ALL:ALL) NOEXEC:NOPASSWD: /usr/bin/rsync"
|
||||
SUDOERS_FILE="/etc/sudoers.d/backuppc_noexec"
|
||||
BACKUP_SUDOERS_FILE="/etc/sudoers.d/backuppc_noexec"
|
||||
# ]]]
|
||||
|
||||
# Functions [[[
|
||||
|
@ -78,16 +78,16 @@ fi
|
|||
is_user "${BACKUP_USER_LOGIN}"
|
||||
|
||||
# Test if sudoers conf is already set
|
||||
if ! is_sudoers_line "${SUDOERS_LINE_REGEXP}"
|
||||
if ! is_sudoers_line "${BACKUP_SUDOERS_LINE_REGEXP}"
|
||||
then
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : First try — ${SUDOERS_LINE_REGEXP} was not found in sudo configuration."
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : First try — ${BACKUP_SUDOERS_LINE_REGEXP} was not found in sudo configuration."
|
||||
## Add sudoers configuration
|
||||
add_sudoers_conf "${SUDOERS_LINE}" "${SUDOERS_FILE}"
|
||||
add_sudoers_conf "${BACKUP_SUDOERS_LINE}" "${BACKUP_SUDOERS_FILE}"
|
||||
|
||||
## Test if sudoers conf was successfully modified
|
||||
if ! is_sudoers_line "${SUDOERS_LINE_REGEXP}"
|
||||
if ! is_sudoers_line "${BACKUP_SUDOERS_LINE_REGEXP}"
|
||||
then
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Second try — ${SUDOERS_LINE_REGEXP} was not found in sudo configuration."
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Second try — ${BACKUP_SUDOERS_LINE_REGEXP} was not found in sudo configuration."
|
||||
printf '\e[1;31m%-6s\e[m\n' "ERROR : The sudo configuration was not successfully modified."
|
||||
printf '\e[1;31m%-6s\e[m\n' "ERROR : Please contact your administrator."
|
||||
exit "${ERROR}"
|
||||
|
|
Loading…
Reference in New Issue