polkit-github-migration-bot / t4_polkit

Other
0 stars 0 forks source link

pkexec fails with "GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie" #19

Open polkit-github-migration-bot opened 8 years ago

polkit-github-migration-bot commented 8 years ago

In gitlab.freedesktop.org by bugzilla-migration on Aug 22, 2016, 23:00

Link to the original issue: https://gitlab.freedesktop.org/polkit/polkit/-/issues/17

Submitted by Michal Soltys

Assigned to David Zeuthen @david

Link to original bug (#97445)

Description

When no authentication agents are registered and pkexec falls back to pkttyagent, any attempt to authenticate ends with:

pkexec bash ==== AUTHENTICATING FOR org.freedesktop.policykit.exec === Authentication is needed to run `/usr/bin/bash' as the super user Authenticating as: nozo 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

Note that pkexec works fine with any other authentication agent, for example if I preceeded the above with

/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &

everything would work fine. By itself, pkttyagent works fine with other commands needing authentication, e.g.

systemctl restart systemd-udevd.service

would execute correctly.

Looks like something is amiss between pkexec and pkttyagent in 0.113. Tested on recent and fully updated Archlinux. For the record, polkit is compiled with following configure line on arch:

./configure --prefix=/usr --sysconfdir=/etc \ --localstatedir=/var --libexecdir=/usr/lib/polkit-1 \ --enable-libsystemd-login=yes --disable-static \ --enable-gtk-doc --with-os-type=redhat

polkit-github-migration-bot commented 7 years ago

In gitlab.freedesktop.org by bugzilla-migration on Nov 21, 2016, 20:27

:speech_balloon: Tom Seewald said:

I have ran into this bug as well, fc24 with MATE desktop. Also tried polkit-devel, and mate-polkit-devel with no change in behavior.

What can I do to help troubleshoot this issue?

polkit-github-migration-bot commented 5 years ago

In gitlab.freedesktop.org by cubanpit on Oct 27, 2018, 15:06

I have a similar problem on Manjaro Linux, based on Arch Linux, pkexec version 0.114.

If I try to use pkexec in a TTY it prints the No session for cookie error. Any systemctl command works without problems prompting for password.

There are two workaround: open another TTY and run pkttyagent -p [tty_pid_here] in it or using a pipe command pkttyagent -p $(echo $$) | pkexec command (it requires a ^C to stop).

These workarounds does work in an interactive environment but, for example, they are not usable in a script.

polkit-github-migration-bot commented 5 years ago

In gitlab.freedesktop.org by sparcbr on Dec 8, 2018, 22:22

How can I fix this for Ubuntu 16.04 ?

polkit-github-migration-bot commented 5 years ago

In gitlab.freedesktop.org by azzaronea on Mar 29, 2019, 18:46

mentioned in commit azzaronea/polkit@0198262d7819ccf671b850129647bf30498d4302

polkit-github-migration-bot commented 5 years ago

In gitlab.freedesktop.org by azzaronea on Apr 3, 2019, 10:33

mentioned in commit azzaronea/polkit@bf7149631a692c095873bb122273e520b4027406

polkit-github-migration-bot commented 5 years ago

In gitlab.freedesktop.org by azzaronea on Apr 26, 2019, 11:45

mentioned in commit azzaronea/polkit@d3366e8f23e3fb8300e187312dfe5ee9bd8064cf

polkit-github-migration-bot commented 5 years ago

In gitlab.freedesktop.org by raveit65 on Jul 4, 2019, 17:22

for Mate desktop:

Is %{_sysconfdir}/xdg/autostart/polkit-mate-authentication-agent-1.desktop in autostart enabled?

If not you will run into this issue.

polkit-github-migration-bot commented 4 years ago

In gitlab.freedesktop.org by cubanpit on Dec 13, 2019, 23:23

I found a partial solution in order to use pkexec in a script, without causing problems if this is run in a TTY.

At the beginning of the script start a new agent:

# start pkttyagent for this shell, so pkexec is able to ask for authentication
_SHPID=$BASHPID
pkttyagent -p "$_SHPID" &
_PKPID=$!

Then you can freely use pkexec inside the script and it will work flawlessly. At the end of the script just kill the agent:

# Kill pkttyagent process
kill "$_PKPID"

The only problem is that any command that uses polkit fo authentication (systemctl, journalctl and others) does not work until the new agent is killed, according to my tests. Maybe I am missing something obvious but I could not find a solution for this last problem.

EDIT: the problem with journalctl and such was just my error, I ran it in a sub-shell with a PID different from $BASHPID, there was just no agent in the sub-shell.

polkit-github-migration-bot commented 4 years ago

In gitlab.freedesktop.org by huxiaodong on Jul 15, 2020, 09:36

mentioned in commit huxiaodong/polkit@716a273ce0af467968057f3e107156182bd290b0

polkit-github-migration-bot commented 4 years ago

In gitlab.freedesktop.org by huxiaodong on Jul 15, 2020, 09:42

This commit may fix this bug.

https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/59/diffs?commit_id=716a273ce0af467968057f3e107156182bd290b0

polkit-github-migration-bot commented 4 years ago

In gitlab.freedesktop.org by mliszcz on Aug 27, 2020, 16:49

Hi all,

What is the way forward for this issue? I just hit the same problem on Arch with polkit 0.177-1 and !59 fixed this for me.

polkit-github-migration-bot commented 3 years ago

In gitlab.freedesktop.org by swills on Oct 23, 2020, 16:10

I've run into this as well. But !59 didn't seem to fix it for me. And !28 didn't fix it for me either.

polkit-github-migration-bot commented 3 years ago

In gitlab.freedesktop.org by AkechiShiro on Mar 31, 2021, 05:29

Any news on this I'm hitting this issue on ArchLinux as well (executing pkexec just give me this error consistently, here are versions related to Polkit software that I have installed :

local/lib32-polkit 0.118-1
    Application development toolkit for controlling system-wide privileges
local/polkit 0.118-1
    Application development to toolkit for controlling system-wide privileges
local/polkit-qt5 0.113.0-2
    A library that allows developers to access PolicyKit API with a nice Qt-style API

And I'm unable to install a package due to Meson/ninja needing the authentication in order to install some compiled software, !59 did not work for me as well and as for !28 I haven't tried it yet, but I wonder why this issue affects only few people or why it isn't of some higher priority than say adding a new feature in Polkit, what's going on with this issue ?

Just in case it could help, here is some more info about my specific Polkit package :

Name            : polkit
Version         : 0.118-1
Description     : Application development toolkit for controlling system-wide privileges
Architecture    : x86_64
URL             : https://www.freedesktop.org/wiki/Software/polkit/
Licenses        : LGPL
Groups          : None
Provides        : None
Depends On      : glib2  pam  expat  systemd  js78
Optional Deps   : None
Required By     : None
Optional For    : systemd
Conflicts With  : None
Replaces        : None
Installed Size  : 1887.56 KiB
Packager        : Antonio Rojas <arojas@archlinux.org>
Build Date      : ven. 25 sept. 2020 13:13:30
Install Date    : lun. 28 sept. 2020 01:22:35
Install Reason  : Installed as a dependency for another package
Install Script  : No
Validated By    : Signature
polkit-github-migration-bot commented 2 years ago

In gitlab.freedesktop.org by jrybar on May 4, 2022, 14:53

Hello,

do you have any reproducer of this issue, please?

polkit-github-migration-bot commented 2 years ago

In gitlab.freedesktop.org by AkechiShiro on May 4, 2022, 18:22

Hi @jrybar, how should I be able to provide a reproducer of this issue ? Is there any documentation on how to do this ?

I've recently reinstalled my whole OS (ArchLinux) and I'm still hiting this issue just the same by just writing inside the command line of a terminal pkexec I input my password and I get the same error.

Output:

$ pkexec
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ====
Authentication is needed to run `/bin/bash' as the super user
Authenticating as: 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.

pkexec's version: pkexec version 0.120

polkit software versions :

extra/polkit 0.120-5 [399.97KiB 1.86MiB] [Installed]
extra/polkit-qt5 0.114.0-1 [75.89KiB 300.24KiB] [Installed]
polkit-github-migration-bot commented 2 years ago

In gitlab.freedesktop.org by Samisafool on May 29, 2022, 09:27

do you have any reproducer of this issue, please?

Not sure what you mean, but I can reproduce it

  1. Use Arch Linux
  2. Switch into a TTY
  3. Run pkexec true
  4. Put in password
  5. See bug

If you need any help debugging please lmk

polkit-github-migration-bot commented 2 years ago

In gitlab.freedesktop.org by Mark_4158 on May 31, 2022, 22:01

mentioned in commit Mark_4158/polkit@17d2e52d2f1deae30b1e6f991b9cc50a9b72c6b1

polkit-github-migration-bot commented 2 years ago

In gitlab.freedesktop.org by Mark_4158 on Jun 1, 2022, 02:53

mentioned in commit Mark_4158/polkit@1fa49aca64d44116b14cf0fa9449bd407e220049

polkit-github-migration-bot commented 2 years ago

In gitlab.freedesktop.org by AkechiShiro on Jun 5, 2022, 13:56

@jrybar Any news, I just hope it won't take another year for an anwser, I know this is open source and polkit is a big project ran by a few volonteers, but I don't think I'm ready to wait another year for a fix, might as well work on it. Maybe @Mark_4158 could tell me more about the fix that he is working on or mentioned here ?

polkit-github-migration-bot commented 2 years ago

In gitlab.freedesktop.org by Mark_4158 on Jun 6, 2022, 15:19

Currently, pkexec tries to use itself as a backup authentication agent. With https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/122, it instead spawns pkttyagent and uses that.

polkit-github-migration-bot commented 2 years ago

In gitlab.freedesktop.org by AkechiShiro on Jun 6, 2022, 18:33

Thank you for the fix, any idea when this !122 will land in master, maybe soon, was it tested also as a working fix by anyone under Arch Linux encountering the issue ??

polkit-github-migration-bot commented 2 years ago

In gitlab.freedesktop.org by Mark_4158 on Jul 13, 2022, 24:32

mentioned in commit Mark_4158/polkit@4a13d42d6c336c98fb8ae85b508fee874d899dd5

polkit-github-migration-bot commented 2 years ago

In gitlab.freedesktop.org by Mark_4158 on Jul 13, 2022, 24:38

mentioned in commit Mark_4158/polkit@5028b9b0913e29ca344baf0030e414a0811dd670

polkit-github-migration-bot commented 1 year ago

In gitlab.freedesktop.org by AlynxZhou on Nov 9, 2022, 09:58

It's a 6 years old bug and now I still get blocked by this, today I want to connect to VPN on my NAS from ssh via pkexec nmcli connection up XXX --ask and it reminds me "oh no pkexec has bug on tty".

I don't want to be just complaining, but I think we already have https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/59 and https://gitlab.freedesktop.org/polkit/polkit/-/merge_requests/122 here, but it seems no maintainer is looking at it.

polkit-github-migration-bot commented 1 year ago

In gitlab.freedesktop.org by alkisg on Jan 14, 2023, 03:35

I can reproduce this on Ubuntu 18.04 / 20.04 / 22.04, Debian 10 / 11 etc, but just running ssh localhost to avoid the graphical polkit agent.

To avoid the issue, I had to ship updated versions of my programs that prefer sudo over policykit whenever possible.

administrator@pc:~$ ssh localhost

administrator@pc:~$ pkexec bash
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/bin/bash' as the super user
Authenticating as: Administrator,,, (administrator)
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.
polkit-github-migration-bot commented 1 year ago

In gitlab.freedesktop.org by septatrix on Apr 14, 2023, 17:40

The assignee @david seems to be inactive. At the maintainers: Maybe someone else should be assigned?

polkit-github-migration-bot commented 1 year ago

In gitlab.freedesktop.org by jrybar on Apr 19, 2023, 13:49

Hello, I'll look into it if no other high priority jumps in...

polkit-github-migration-bot commented 1 year ago

In gitlab.freedesktop.org by Nukiloco on Jul 9, 2023, 11:19

I noticed this issue has appeared for me on Linux Mint. What is the current status of this issue?

polkit-github-migration-bot commented 11 months ago

In gitlab.freedesktop.org by Artturin on Sep 26, 2023, 02:09

Here's a report in the thread of the patch that caused this bug

https://gitlab.freedesktop.org/polkit/polkit/-/issues/39#note_20383