Skip to content

run0 cannot be overridden despite insufficient checks whether it works, and no fallback is attempt when it fails #2734

@creshal

Description

@creshal

Affected Version

Any version supporting run0

Describe the bug

  1. run0 "support" is detected by checking for the existence of the binary. Unlike with doas/sudo/pkexec, this check is insufficient to ensure a working configuration: The systemd package creates the symlink no matter whether you have polkit installed or not, and without polkit installed run0 just crashes
  2. If run0 crashes, no other elevator is attempted
  3. Additionally, the sudo config file setting is ignored
  4. That means yay cannot not crash on a system with systemd installed but not polkit; unless you manually pass --sudo on every yay invocation

Reproduction Steps

  1. Set up Arch with only base installed (=no polkit)
  2. Install yay
  3. Watch yay crash with Failed to start transient service unit: Access denied
  4. Try setting "sudo": "sudo", or any other working configuration in your config file
  5. Watch yay crash anyway

Expected behavior

  1. sudo config file option actually works
  2. yay does not crash without manual configuration

Possible mechanisms:

  1. Just try elevation mechanisms in order – would still throw an error, but a harmless one
  2. De-prioritize run0 – easiest solution, but probably sucks for people who do have polkit?
  3. Check for pkexec existence, prioritize run0 if pkexec exists – slightly more complicated, but would keep run0 as default for polkit-enabled systems

Output

> python -mjson.tool ~/.config/yay/config.json && echo " --> valid json file"
{
    "buildDir": "/home/creshal/.cache/yay/",
    "editor": "",
    "makepkgbin": "/usr/bin/makepkg",
    "pacmanbin": "/usr/bin/pacman",
    "pacmanconf": "/etc/pacman.conf",
    "tarbin": "/usr/bin/bsdtar",
    "requestsplitn": 150,
    "sortmode": 0,
    "sudo": "/usr/bin/doas",
    "sudoloop": false,
    "timeupdate": false,
    "devel": false,
    "cleanAfter": false
}
 --> valid json file
> yay --debug
[DEBUG:runner] running /usr/sbin/run0 /usr/bin/pacman --debug -S -y --config /etc/pacman.conf --
Failed to start transient service unit: Access denied
 -> error refreshing databases - exit status 1
> yay --debug --sudo /usr/bin/doas
[DEBUG:runner] running /usr/bin/doas /usr/bin/pacman --debug -S -y --config /etc/pacman.conf --
doas (creshal@localhost) password:

(It would be helpful if --debug did debug config file parsing. Or was documented in the manpage.)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions