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

opening repo: opendir() fails when path contains non-ASCII chars or spaces #4378

Closed
Lesik opened this issue Aug 20, 2021 · 4 comments
Closed

Comments

@Lesik
Copy link

Lesik commented Aug 20, 2021

Linux distribution and version

Debian 10

Flatpak version

Flatpak 1.10.2
flatpak-builder 1.0.5

Description of the problem

My understanding is that when using --install flag on flatpak-builder, it adds a local remote to flatpak. If the directory where flatpak.{yaml,json} is located contains non-ASCII characters or spaces, adding the local remote fails. This sucks for non-English speakers and non-technical people who might use spaces in their folder names.

Downloading sources
Initializing build dir
Committing stage init to cache
Starting build of org.flatpak.Hello
========================================================================
Building module hello in /home/user/работа/flatpak-bug/.flatpak-builder/build/hello-1
========================================================================
Running: install -D hello.sh /app/bin/hello.sh
Committing stage build-hello to cache
Cleaning up
Committing stage cleanup to cache
Finishing app
Please review the exported files and the metadata
Committing stage finish to cache
Exporting org.flatpak.Hello to repo
Commit: [hash]
Metadata Total: 9
Metadata Written: 2
Content Total: 3
Content Written: 0
Content Bytes Written: 0 (0 bytes)
Installing app/org.flatpak.Hello/x86_64/master
Error: Failed to install org.flatpak.Hello: While pulling app/org.flatpak.Hello/x86_64/master from remote hello-origin: opening repo: opendir(/home/user/%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D0%B0/flatpak-bug/.flatpak-builder/cache): No such file or directory
Install failed: Child process exited with code 1

Steps to reproduce

  1. Create a directory that somewhere in its path has a non-ASCII character or space (e.g. /home/user/работа/, /tmp/GüntherJauch/, /mnt/施氏食獅史/flatpak, /home/user/work for client/)
  2. Inside, create hello.sh and flatpak.yaml as described in https://docs.flatpak.org/en/latest/first-build.html
  3. Run flatpak-builder build-dir flatpak.yml --install --user
@smcv
Copy link
Collaborator

smcv commented Aug 20, 2021

What version of libostree are you using? This might be the same issue fixed in ostreedev/ostree#2293.

@Lesik
Copy link
Author

Lesik commented Aug 20, 2021

@smcv Does this help? libostree-1-1/buster-backports,now 2020.8-2~bpo10+1

@smcv
Copy link
Collaborator

smcv commented Aug 20, 2021

Yes, that's libostree, and that version does not have the fix I linked to.

@refi64
Copy link
Collaborator

refi64 commented Nov 13, 2021

This seems to have been an OSTree bug that's now fixed, so closing.

@refi64 refi64 closed this as completed Nov 13, 2021
raspbian-autopush pushed a commit to raspbian-packages/ostree that referenced this issue Mar 27, 2022
Currently if a file path contains a special character such as '\', and
that character is encoded into a file:// URI that is passed to
ostree_repo_pull_with_options(), the percent encoding will remain in the
path passed to g_file_new() (in the case of backslash %5C) and the pull
will then fail with a file not found error. This is an important edge
case to handle because by default on many Linux distributions a
filesystem with no label is mounted at a path based on its UUID, and
this is then passed to systemd-escape by Flatpak (when
--enable-auto-sideloading was used at compile time) to create a symbolic
link such as this which contains backslashes:

$ ls -l /run/flatpak/sideload-repos/
total 0
lrwxrwxrwx 1 mwleeds mwleeds 55 Mar  9 14:21
'automount-run-media-mwleeds-29419e8f\x2dc680\x2d4e95\x2d9a31\x2d2cc907d421cb'
-> /run/media/mwleeds/29419e8f-c680-4e95-9a31-2cc907d421cb

And Flatpak then passes libostree a file:// URI containing that path, to
implement sideloading (pulling content from the USB drive).

This results in an error like:

Error: While pulling app/org.videolan.VLC/x86_64/stable from remote
flathub:
/run/flatpak/sideload-repos/automount-run-media-mwleeds-29419e8f%5Cx2dc680%5Cx2d4e95%5Cx2d9a31%5Cx2d2cc907d421cb/.ostree/repo:
opendir(/run/flatpak/sideload-repos/automount-run-media-mwleeds-29419e8f%5Cx2dc680%5Cx2d4e95%5Cx2d9a31%5Cx2d2cc907d421cb/.ostree/repo):
No such file or directory

This patch avoids such errors by using g_file_new_for_uri() instead of
g_file_new_for_path(), so that GLib handles the %-decoding for us.

Bug: https://community.endlessos.com/t/can-not-install-vlc-from-usb-drive-3-9-3/16353
Bug: flatpak/flatpak#4378
Origin: upstream, 2021.1, commit:19577522f8eacd868cf25d53e1ac0e7f424e952b

Gbp-Pq: Name Fix-translation-of-file-URIs-into-paths.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants