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

Also load portals from XDG_DATA_DIRS #1561

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

andychenbruce
Copy link

@andychenbruce andychenbruce commented Jan 9, 2025

Addresses issue #603. The only place it searches for portals is the DATADIR or XDG_DESKTOP_PORTAL_DIR, but if XDG_DESKTOP_PORTAL_DIR is set, then it doesn't read configuration files.

This is a problem because any system that doesn't follow the FHS must set XDG_DESKTOP_PORTAL_DIR for it to find the portals, but then can't load any configuration files which leaves everything broken. A simple solution is to search all the directories in XDG_DATA_DIRS.

@andychenbruce andychenbruce force-pushed the main branch 4 times, most recently from 5efb882 to c0322a2 Compare January 9, 2025 21:17
@swick
Copy link
Contributor

swick commented Jan 9, 2025

I really would want to have tests for the configs. With the pytest setup we currently have, we can only test config in $HOME but we could modify things for this test to launch x-d-p in a new mount namespace with /usr/local/share/xdg-desktop-portal etc under our control.

Is that something you could look into?

Copy link
Collaborator

@smcv smcv left a comment

Choose a reason for hiding this comment

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

Reserving judgement on whether this is a desired feature or not (other maintainers might have an opinion on that, I think it's a reasonable thing to want):

If x-d-p is going to look in more than one directory, then I think it should remember all the filenames that it has already seen, and ignore any file of the same name in the lower-precedence directories. (Probably easiest done with a global hash table.)

if(dir_set_from_env)
return

const char * const *dirs = g_get_system_data_dirs ();
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're going to load from XDG_DATA_DIRS then we should also try XDG_DATA_HOME, for completeness and to be consistent with the basedir spec.

src/xdp-portal-impl.c Outdated Show resolved Hide resolved
src/xdp-portal-impl.c Outdated Show resolved Hide resolved
src/xdp-portal-impl.c Show resolved Hide resolved
@smcv
Copy link
Collaborator

smcv commented Jan 9, 2025

With the pytest setup we currently have, we can only test config in $HOME but we could modify things for this test to launch x-d-p in a new mount namespace with /usr/local/share/xdg-desktop-portal etc under our control.

If we do this, please only do it as additional test coverage, and not as the only way some other thing gets tested. Linux distributions' autobuilders usually can't create new mount namespaces so this would have to be skipped.

@swick
Copy link
Contributor

swick commented Jan 15, 2025

Alternative to unshare for testing: introduce environment variables that overwrites the "system" dirs. Should work everywhere then at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

3 participants