gravity-sync icon indicating copy to clipboard operation
gravity-sync copied to clipboard

gravity-sync sudo check broken on Debian

Open TheLastChosenOne opened this issue 3 years ago • 0 comments

While installing gravity-sync for a specific user (not root) it's creating a sudoers config file so that this user can run any command without password:

root@pihole:~# cat /etc/sudoers.d/gs-nopasswd 
gravitysync ALL=(ALL) NOPASSWD: ALL

But when running /usr/local/bin/gravity-sync as this specified user, the shell function "validate_sudo_status" fails and exits with an error. This function is not checking if the user has sudo permissions, it's just checking if the user is a member of the local groups "sudo" or "wheel" and fails if not.

function validate_sudo_status {
    OS_CURRENT_USER=$(whoami)
    if [ ! "$EUID" -ne 0 ]; then
        OS_LOCAL_ADMIN=""
    else
        OS_SUDO_CHECK=$(groups ${OS_CURRENT_USER} | grep -e 'sudo' -e 'wheel')
        if [ "$OS_SUDO_CHECK" == "" ]; then
            OS_LOCAL_ADMIN="nosudo"
        else
            OS_LOCAL_ADMIN="sudo"
        fi
    fi

[...]
}

On Debian there is no "wheel" group (thats the default for RedHat/CentOS).

This function probably should check if sudo -l or sudo --validate is working instead of checking non-existing groups.


Workaround on Debian (and probably Ubuntu also):

Create a group "wheel" and add your non-root user as a member. Run these commands as your sync user after you created the sudo config manually / automatically after installation.

sudo groupadd wheel
sudo usermod -aG wheel $(whoami)

TheLastChosenOne avatar Jun 20 '22 09:06 TheLastChosenOne