Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkexec doesn't work #72

Closed
mcelrath opened this issue Nov 17, 2023 · 17 comments
Closed

pkexec doesn't work #72

mcelrath opened this issue Nov 17, 2023 · 17 comments
Labels
info needed Further information is requested

Comments

@mcelrath
Copy link

You guys default to pkexec to run commands at root, which doesn't work on my Arch linux distro:

$ pkexec 
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/bin/bash' as the super user
Authenticating as: Bob McElrath,,, (mcelrath)
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 usually use sudo on my system, I've never heard of pkexec.

@the-sane
Copy link
Member

Hi! pkexec is part of Polkit and is a better, safer way to ask for elevated privileges:

https://wiki.archlinux.org/title/Polkit

In contrast to systems such as sudo, it does not grant root permission to an entire process, but rather allows a finer level of control of centralized system policy

Sounds like polkit may be improperly configured on your system. Are you by any chance trying to do this over ssh?
We do our best to detect polkit errors and gracefully fall back to sudo if it's not available.

Things you can do to help me print a more useful error message:

  1. Paste the actual output from our Helper so I can see what it's saying
  2. Go to this line in the script and add echo "DEBUG Polkit status code: $statuscode" to find out what error code polkit is throwing. Paste that value here as well

Things you can do to fix the problem:

  1. Visit the arch wiki page above and investigate why your polkit isn't working
  2. Head over to our Discord tech support channel (linked in our wiki) and ask the folks there for help investigating

@mcelrath
Copy link
Author

The problem is that polkit requires an additional authentication daemon to be running, which it was not. Just because pkexec is installed doesn't mean a daemon is running. I'm not sure how to detect if polkit is functional but something more is required than looking for the pkexec binary...

@the-sane
Copy link
Member

You're right and, if you want to help, I put a couple steps above that you can follow to get an error code from pkexec and print it here.

@mcelrath
Copy link
Author

I got it working, just telling you guys of the error in case you want to fix it.

@the-sane
Copy link
Member

And I appreciate that, but I need more information to fix it, specifically the things I asked for above. No pressure though, if you're not interested in helping provide that info, you may just close this issue.

@mcelrath
Copy link
Author

It's exactly the same on any command. This is the output from the helper:

$ lug-helper
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/usr/bin/sh -c mkdir -p /etc/systemd/s ... limit.conf && systemctl daemon-reexec' as the super user
Authenticating as: Bob McElrath,,, (mcelrath)
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.

@the-sane
Copy link
Member

Great, thanks. Step 2 from my list of requested information is also crucial to my ability to make any changes that would fix this.

@arbog
Copy link

arbog commented Nov 18, 2023

Seeing the same with Fedora 38:
`➜ arbo@lunchbox ~/lug-helper git:(main) ./lug-helper.sh

Editing hosts file...
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/usr/bin/sh -c printf '\n127.0.0.1 mod ... tizen EAC workaround\n' >> /etc/hosts' as the super user
Authenticating as: Paul Arbogast (arbo)
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.`

@arbog
Copy link

arbog commented Nov 18, 2023

Please disregard. Reading up on polkit the reason it isn't working is because I'm using xmonad and it requires more configuration before it will work in this environment.

@the-sane
Copy link
Member

@arbog If you're willing to help get an error code from Polkit, that's what I'd need to make the Helper provide a more useful error message to users. Instructions are in step 2 of this comment.

@the-sane the-sane added the info needed Further information is requested label Dec 21, 2023
@the-sane
Copy link
Member

Closing this for now. Would need the quested info to do anything further about it.

@crocodile13
Copy link

crocodile13 commented Sep 22, 2024

Hi, same for me.
I "resolved" the issue using the echo $$ and pkttyagent --process $PID from this issue

I tried to write in /etc/polkit-1/rules.d/50-default.rules this:
polkit.addAdminRule(function(action, subject) { return ["unix-group:wheel"]; });

but new error:
`

user@rootme:~/Games/lug-helper$ pkexec 'top'
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run /usr/bin/top' as the super user Authenticating as: user,,, (user) 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.

crocodile13 added a commit to crocodile13/lug-helper that referenced this issue Sep 22, 2024
Solution to the issue starcitizen-lug#72. It's not very clean since I didn't really understand the core of the problem and its resolution... it's an 'implementation' of polkit-org/polkit#201.
@the-sane the-sane reopened this Sep 22, 2024
@the-sane
Copy link
Member

@crocodile13 From everything I'm reading, it sounds like this is due to a misconfigured/outdated OS and/or extremely outdated version of polkit. Rather than add workarounds for a broken polkit, such as the one mentioned, I'd prefer to just gracefully fall back to sudo. In order to do that, I need pkexec's exit status code.

If you're willing to help, please see my #72 (comment) above and perform step number 2 to get the error code for pkexec without your workaround. I can capture that and fall back to sudo. Thanks!

@crocodile13
Copy link

crocodile13 commented Sep 22, 2024

I'm sorry, I'm quite surprised, I can't reproduce the bug o_o. I tried using -x, but without success... In the meantime, I updated Wine and Lutris to their latest release, could it be related? I tried cloning the repo from scratch again but it's still the same... 'unfortunately,' it works. If you have any ideas on what to remove to return to the initial state, feel free to let me know, I'd be happy to help... If I get motivated, I might set up a VM this evening. As for me, I didn't want to update polkit because there are too many 'critical' dependencies on the system...

edit: I just try to downgrade wine and lutris.... no difference

@the-sane
Copy link
Member

It's not likely anything to do with lutris or wine. You'd have to revert any workarounds or updates you performed on your system, potentially reboot, and then try again to reproduce the error

@crocodile13
Copy link

Hello, sorry for the delay, I did a wrong manipulation and I deleted the /lib ... I completely reinstalled my OS to go to debian. I will do the manipulation during the week to see if the problem is also present here.

@the-sane
Copy link
Member

I've made a change that hopefully will help improve the fallback to sudo, but without the relevant pkexec error code I can't be sure it would have helped with the misconfiguration issues above. I'll close this again for now unless someone can get me an error code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
info needed Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants