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

portal-impl: fix config ordering #1240

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

alyssais
Copy link
Contributor

Quoting portals.conf(5):

Each key in the group contains a semi-colon separated list of portal backend
implementation, to be searched for an implementation of the requested interface,
in the same order as specified in the configuration file.

But this wasn't actually true. If the portals were set to z;y and z and y both implemented the same portal, y would be used.

Fixing this requires reworking how portals are selected — going through the config file and selecting the first available configured portal, rather than going through each known portal and checking whether it's allowed in the config file.

find_all_portal_implementations() is unchanged. The portal-first approach is fine for it, and it would be difficult for it to share as much code with find_portal_implementation() now that it's written to stop as soon as a configured portal is found.

Fixes: #1111

src/portal-impl.c Outdated Show resolved Hide resolved
src/portal-impl.c Outdated Show resolved Hide resolved
Copy link
Member

@GeorgesStavracas GeorgesStavracas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just two minor changes I didn't spot before, LGTM other than that

src/portal-impl.c Outdated Show resolved Hide resolved
src/portal-impl.c Outdated Show resolved Hide resolved
Copy link
Member

@GeorgesStavracas GeorgesStavracas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with the final comment above, but I'd like to have @ebassi's review before landing

src/portal-impl.c Outdated Show resolved Hide resolved
Quoting portals.conf(5):

> Each key in the group contains a semi-colon separated list of portal backend
> implementation, to be searched for an implementation of the requested interface,
> in the same order as specified in the configuration file.

But this wasn't actually true.  If the portals were set to z;y and z
and y both implemented the same portal, y would be used.

Fixing this requires reworking how portals are selected — going
through the config file and selecting the first available configured
portal, rather than going through each known portal and checking
whether it's allowed in the config file.

find_all_portal_implementations() is unchanged.  The portal-first
approach is fine for it, and it would be difficult for it to share as
much code with find_portal_implementation() now that it's written to
stop as soon as a configured portal is found.

Fixes: flatpak#1111
@swick
Copy link
Contributor

swick commented Apr 3, 2024

ping @ebassi

@alyssais
Copy link
Contributor Author

alyssais commented Apr 3, 2024

(I'm not sure to what extent 1394bb2 affected this — there's definitely some overlap, because I also fixed that bug. But given it's caused complicated merge conflicts, and it was merged instead of this despite my PR being open way longer, I want to feel confident that's not going to happen again before I put any more time in.)

@SoumyaRanjanPatnaik
Copy link
Contributor

SoumyaRanjanPatnaik commented May 7, 2024

(I'm not sure to what extent 1394bb2 affected this — there's definitely some overlap, because I also fixed that bug. But given it's caused complicated merge conflicts, and it was merged instead of this despite my PR being open way longer, I want to feel confident that's not going to happen again before I put any more time in.)

Hi @alyssais, I'm the author of 1394bb2. I was aware of this PR when I wrote that patch, and I tried it out see if the bug was already fixed (it didn't).

I think the only reason that my PR was merged faster than yours was that it was bumped up by several users from the Arch community.

I think this is a very important PR that I think should get merged since it has been the cause of bugs like this in the distribution that I contribute to. We currently use a very hacky workaround, which this PR would remove the need for.

@SoumyaRanjanPatnaik
Copy link
Contributor

LMK if you need any help with testing or resolving conflicts.

@alyssais
Copy link
Contributor Author

alyssais commented May 8, 2024

@SoumyaRanjanPatnaik if you want to resolve the conflicts that'd be great! I had a go but I found it difficult because it's been so long I've forgotten a lot of the nuances I was trying to get right here.

@smcv
Copy link
Collaborator

smcv commented May 8, 2024

@SoumyaRanjanPatnaik, if you can provide a separate PR that supersedes this one, using Co-authored-by to credit both yourself and @alyssais, that would probably be the way forward here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug config Issues with the portal configuration mechanism
Projects
Status: Triaged
Status: No status
Development

Successfully merging this pull request may close these issues.

The portal config file does not actually specify the order of portals to be tried
5 participants