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

portals.conf: The wrong portals are picked up #1417

Closed
A6GibKm opened this issue Aug 10, 2024 · 4 comments
Closed

portals.conf: The wrong portals are picked up #1417

A6GibKm opened this issue Aug 10, 2024 · 4 comments
Labels

Comments

@A6GibKm
Copy link
Contributor

A6GibKm commented Aug 10, 2024

Operating System

Fedora

XDG Desktop Portal version

1.18

XDG Desktop Portal version (Other)

No response

Desktop Environment

GNOME

Desktop Environment (Other)

No response

Expected Behavior

The order in which portals implementations set in gnome-portal.conf should be followed.

If the config says, for example,

[preferred]
default=gnome;gtk;
org.freedesktop.impl.portal.Secret=oo7-portal;gnome-keyring;

oo7-portal should be selected.

Current Behavior

The order in which portals implementations set in gnome-portal.conf is not followed. In the example above gnome-keyring is selected.

Steps to Reproduce

In a GNOME based distro, setup a dummy portal:

$ cat /usr/share/xdg-desktop-portal/portals/oo7-portal.portal 
[portal]
DBusName=org.freedesktop.impl.portal.desktop.oo7
Interfaces=org.freedesktop.impl.portal.Secret;

and all the required files (dbus activation file, binary, etc)

Setup a config file ~/.config/gnome-portals.conf with contents:

[preferred]
default=gnome;gtk;
org.freedesktop.impl.portal.Secret=oo7-portal;gnome-keyring;

and start xdg-desktop-portal -r -v. It will print

...
XDP: Found 'gnome-keyring' in configuration for org.freedesktop.impl.portal.Secret
XDP: Using gnome-keyring.portal for org.freedesktop.impl.portal.Secret (config)

The fn

// src/portal-impl.c:238
static gint
sort_impl_by_use_in_and_name (gconstpointer a,
                              gconstpointer b)
{
  const PortalImplementation *pa = a;
  const PortalImplementation *pb = b;
  const char **desktops;
  int i;

  desktops = get_current_lowercase_desktops ();

  for (i = 0; desktops[i] != NULL; i++)
    {
      gboolean use_a = pa->use_in != NULL
                     ? g_strv_case_contains ((const char **)pa->use_in, desktops[i])
                     : FALSE;
      gboolean use_b = pb->use_in != NULL
                     ? g_strv_case_contains ((const char **)pb->use_in, desktops[i])
                     : FALSE;

      if (use_a != use_b)
        return use_b - use_a;
      else if (use_a)
        break;
      else
        continue;
    }

  return strcmp (pa->source, pb->source);
}

Will always pickup gnome-keyring because:

  1. The deprecated key UseIn=gnome is not set on the new portal
  2. oo7-portal goes after gnome-keyring alphabetically
  3. Even if the two above are fixed, gnome-keyring is added to the list before oo7-portal

As per man portals.conf:

org.freedesktop.impl.portal.* (string)

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.

alphabetical order should not take preference over the position in the config file.

I tested removing gnome-keyring from the config file and that works fine.

Anything else we should know?

Here is the actual portal impl bilelmoussaoui/oo7#101

@A6GibKm A6GibKm added the bug label Aug 10, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Aug 10, 2024
@smcv
Copy link
Collaborator

smcv commented Aug 10, 2024

Did you label the expected behaviour and the current (actual) behaviour in your issue report the wrong way round? The text of the report doesn't seem to match the headings.

@smcv
Copy link
Collaborator

smcv commented Aug 10, 2024

If my guess is correct and you've labelled expected behaviour and current behaviour the wrong way round, then this is probably the same issue that #1378 aims to solve.

@A6GibKm
Copy link
Contributor Author

A6GibKm commented Aug 10, 2024

I edited it, yes it is the same issue. However I am not sure if the point about UseIn was raised previously (portals with it will always go first).

@GeorgesStavracas
Copy link
Member

Fixed by #1378

@github-project-automation github-project-automation bot moved this from Needs Triage to Triaged in Triage Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Triaged
Development

No branches or pull requests

3 participants