baodrate / snap-sync

Use snapper snapshots to backup to external drive

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't work without sudo

c-c-6ypo8 opened this issue · comments

I don't have sudo in my system and I don't want to use it. So my snap-sync tells this after run without arguments:

root is not in the sudoers file.
root is not in the sudoers file.
Exited due to error on line 163.
exit status: 1
command: sudo -u $u DISPLAY=:0 DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus notify-send -a $name "$1" "$2" --icon="dialog-$3"
bash line: 171
function name: notify

Also, even if I added root in sudoers, I get another error at line 163 because users command generates root user because I am logged in as root (because of not using sudo). So, your script doesn't respect non-sudo linux use. Also with sudo use it generates error if the root is logged in (because root cannot connect to DISPLAY to get notification). So I've fixed notify function to:

notify() {
    for u in $(users | tr ' ' '\n' | sort -u); do
        if [ $u != 'root' ]; then # I've added this line
          sudo -u $u DISPLAY=:0 \ 
          DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(sudo -u $u id -u)/bus \
          notify-send -a $name "$1" "$2" --icon="dialog-$3"
        fi
    done
}

And this variant seems to work properly (with root added to sudoers). But fully no-sudo variant still isn't working.