Bug 2244876 - authentication is required to update metadata
Summary: authentication is required to update metadata
Keywords:
Status: ASSIGNED
Alias: None
Product: Fedora
Classification: Fedora
Component: flatpak
Version: 38
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: David King
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-10-18 17:19 UTC by Martin Rixham
Modified: 2024-03-11 15:40 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Martin Rixham 2023-10-18 17:19:43 UTC
When I switch users after authenticating in GDM I get a dialog that says "authentication is required to update metadata".

I have to give my password to two of these dialogs in succession for it to go away.

This happens when switching between to admin accounts in either direction, haven't tried with non-admin account.

Reproducible: Always

Steps to Reproduce:
1. create two admin accounts
2. log in to one account
3. switch users and log in to the other
4. switch back to see the authentication dialog
Actual Results:  
two dialogs in succession asking for admin password

Expected Results:  
having just authenticated in GDM I wouldbn't expect to be asked for the same password twice again

Comment 1 Jan Rybar 2023-10-19 12:20:25 UTC
Hello, this is usually PackageKit requesting authentization to get authorization for updating repository metadata.  
Can you please confirm by running `journalctl -S -2m -u polkit.service` in terminal right after this happens and copying the output lines here?  

Thank you.

Comment 2 Martin Rixham 2023-10-19 21:17:18 UTC
thanks, here's the log:

[martin@localhost-live ~]$ journalctl -S -2m -u polkit.service
Oct 19 22:15:19 fedora polkitd[27417]: Operator of unix-session:19 successfully authenticated as unix-user:martin to >
Oct 19 22:15:21 fedora polkitd[27417]: Operator of unix-session:19 successfully authenticated as unix-user:martin to >
Oct 19 22:15:26 fedora polkitd[27417]: Unregistered Authentication Agent for unix-session:c19 (system bus name :1.368>

Comment 3 Thomas 2024-03-11 12:04:38 UTC
Hi, I have hit a similar issue on a new box where I'm segregating accounts. I have one unprivileged account ($UNPRIVUSER) with user flatpaks from the flathub repo and one privileged account ($PRIVUSER) to install system flatpaks from the fedora repo. 

With Fedora 39, switching between sessions with ctrl + alt + # throws up the authentication request: "authentication is required to update metadata" when switching from privileged account => unprivileged and again when switching back. I've reproduced it onto a clean install in a VM using one --user flatpak (flatseal) and one system flatpak (epiphany).

When switching to unprivileged user
Operator of unix-session:9 FAILED to authenticate to gain authorization for action org.freedesktop.Flatpak.metadata-update for system-bus-name:: 1.733 [/usr/bin/gnome-software --gapplication-service] (owned by unix-user:$UNPRIVUSER).
Or
Operator of unix-session:1 successfully authenticated as unix-user:$PRIVUSER to gain ONE-SHOT authorization for action org.freedesktop.Flatpak.metadata-update for system-bus-name::1.87 [/usr/bin/gnome-software --gapplication-service] (owned by unix-user:$UNPRIVUSER)

When switching back to privileged user
Operator of unix-session:9 FAILED to authenticate to gain authorization for action org.freedesktop.Flatpak.metadata-update for system-bus-name:: 1.189 [/usr/bin/gnome-software --gapplication-service] (owned by unix-user:$PRIVUSER).
Or 
Operator of unix-session:4 successfully authenticated as unix-user:$PRIVUSER to gain ONE-SHOT authorization for action org.freedesktop.Flatpak.metadata-update for system-bus-name::1.194 [/usr/bin/gnome-software --gapplication-service] (owned by unix-user:$PRIVUSER)

Prompt does not appaer when switching back if I authenticated during the initial privileged => unprivileged switch. It's probably possible to resolve it with polkit rules. It may need to be reported upstream? Unsure of the "problematic" component between polkit, flatpak, gnome-software or something else altogether.

I don't have the time to learn about it so for now I "fixed" it removing gnome-software since I do everything on the command line anyway. I had another issue where all user platpaks refs where temporarily broken and I could not update at all, but I could not reproduce it after a reboot of my main box.

Some posts which are likely related: 
https://discussion.fedoraproject.org/t/authentication-is-required-to-update-metadata/78226
https://discussion.fedoraproject.org/t/authentication-is-required-to-update-metadata/78226

And bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=2055956

Comment 4 Jan Rybar 2024-03-11 15:40:09 UTC
Hello,

here it is in the [report](https://bugzilla.redhat.com/show_bug.cgi?id=2244876#c3) provided by Thomas. Thanks!
I suspected packagekitd, but it's generally gnome-software and the repository backend it uses.  

You know, apps and services define their actions and rulesets to polkit so it can authentize/authorize users (whether automatically or not) to execute those actions accordingly to the rules.  
These kinds of information are defined in files vendored within that app/service itself, because they're the ones to know best what they want (their users) to do.  
It is out of hands of polkit. Polkit just takes the information, interprets it and executes it when needed.  

This issue can be resolved by Flatpak maintainers by extending file /usr/share/polkit-1/rules.d/org.freedesktop.Flatpak.rules with the new action rule (or merge the followin if-block in the existing rules):
```
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.Flatpak.metadata-update") {
            return polkit.Result.YES;
    }

    return polkit.Result.NOT_HANDLED;
});
```

I don't know the details about Flatpak, but I guess updating metadata should be a safe operation for all users.


Note You need to log in before you can comment on or make changes to this bug.