bkw777/mainline

Authentication fails if mainline is run without sudo

shrx opened this issue · 7 comments

shrx commented
$ mainline --install-latest
mainline 1.3.4
Distribution: Pop!_OS 22.04 LTS
Architecture: amd64
Running kernel: 6.3.1-060301-generic
Updating from: 'https://kernel.ubuntu.com/~kernel-ppa/mainline/'
OK
Found installed: linux-image-6.2.6-76060206-generic
Found installed: linux-image-generic
Found installed: linux-image-unsigned-6.3.1-060301-generic
Found installed: linux-image-unsigned-6.3.3-060303-generic
Latest point update: 6.3.5

Install Kernel Version 6.3.5 ? (y/n): 
y
Downloading 6.3.5
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===                     
Authentication is needed to run `/usr/bin/env' as the super user
Multiple identities can be used for authentication:
 1.  Support IT (localroot)
 2.  My Account (myaccount)
Choose identity to authenticate as (1-2): 2
Password: 
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized

What happens when you try this in a terminal as a user?:
pkexec env DISPLAY=${DISPLAY} XAUTHORITY=${XAUTHORITY} dpkg --version

If this is a remote or headless box and you're ssh's into it, maybe you need something like this?:
https://9to5tutorial.com/running-pkexec-on-environments-without-gui-and-with-x-transfer
but I don't really know.

shrx commented

What happens when you try this in a terminal as a user?: pkexec env DISPLAY=${DISPLAY} XAUTHORITY=${XAUTHORITY} dpkg --version

Password: 
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized

This incident has been reported.

I'm executing the commands on my laptop, not over ssh.

shrx commented

If this is a remote or headless box and you're ssh's into it, maybe you need something like this?: https://9to5tutorial.com/running-pkexec-on-environments-without-gui-and-with-x-transfer but I don't really know.

This worked (apart from some GTK warnings), I now get:

Debian 'dpkg' package management program version 1.21.21 (amd64).
This is free software; see the GNU General Public License version 2 or
later for copying conditions. There is NO warranty.

I'm adding an option to use sudo instead of pkexec. There is no special reason to use pkexec since the auth prompt always happens in a terminal window anyway even in gui mode, so sudo is usable as a drop in alternative without having to change anything else.

Plus a custom option to supply your own command.

That should facilitate use it more environments.

1.3.8 adds a config option for the auth command.
The pkexec command is built-in and always resettable by just blanking out the field.
Or you may replace the whole command with "sudo', or with anything else.
It's normally edited from the settings screen in the gui, but for non-gui, the setting is in ~/.config/mainline/config.json, which you can edit manually if needed.
"auth_cmd" : "pkexec env DISPLAY=${DISPLAY} XAUTHORITY=${XAUTHORITY}",
change to
"auth_cmd" : "sudo",

shrx commented

Awesome, thanks! I tested the latest version with the "auth_cmd" : "sudo" config and it works great.