Commit Graph

118 Commits

Author SHA1 Message Date
Alexander Larsson
c620ba642d document portal: Fix race condition when unmounting old version
Fixes https://github.com/flatpak/flatpak/issues/814
2017-05-26 16:56:58 +02:00
Alexander Larsson
4a54450400 documents: paths in the apps dir ar always accessible
When using the as-needed flag in AddFull, we need to consider
the files in the target apps app-specific dir also accessible.

Fixes https://github.com/flatpak/flatpak/issues/815
2017-05-26 13:05:43 +02:00
Alexander Larsson
dfaf925dd0 document-portal: Add XDP_ADD_FLAGS_AS_NEEDED_BY_APP to AddFull
If this is set, we only rewrite paths that are needed for the
target application. I.e. the ones that are *not* accessible by
that application.
2017-05-22 13:12:13 +02:00
Alexander Larsson
c08dff31a9 document-portal: Lock just once in AddFull for many paths 2017-05-22 13:12:01 +02:00
Matthias Clasen
ea0f97efe7 Correct mountpoint handling
As a file path, the mountpoint should probably be sent
as ay. Also, remove an extra level of gvariant wrapping.
2017-05-22 09:26:23 +02:00
Alexander Larsson
e63d089435 Remove unused variable
Fixes clang warning
2017-05-22 09:25:00 +02:00
Alexander Larsson
77a7aa6adb document-portal: Bump version to 2 due to new AddFull method 2017-05-19 17:03:15 +02:00
Alexander Larsson
6ce8521b64 document-portal: Add AddFull() operation
This allows you to add multiple paths at the same time, plus
grant an app access to it, plus it returns the fuse mount path.

This allows you to avoid a lot of roundtrip in common cases.
2017-05-19 17:01:46 +02:00
Alexander Larsson
bda7575e79 Add version property to all dbus interfaces 2017-05-19 14:38:22 +02:00
Alexander Larsson
96cdf9acfc Don't use gdbus-codegen autoptr generation
This requires a glib more recent than what we want, so just do it
manually.
2017-05-10 17:22:05 +02:00
Matthias Clasen
1742881509 Generate fd-passing arguments for document portal
Add an annotation that lets us pass an fd-list to
the generated wrapper around Add(). This is more
convenient than calling the method manually.

Currently, we have no callers for the wrapper, so
this does not affect any other code.
2017-05-03 13:27:52 +02:00
Alexander Larsson
fb6695e9a4 Add macros for common ANSI tty escape codes 2017-05-03 11:17:41 +02:00
Matthias Clasen
b07240f525 Use the new output helper
Instead of open-coding isatty(), use flatpak_fancy_output().
2017-05-03 11:06:43 +02:00
Alexander Larsson
4fdac9e5d4 document portal: Disable spice_read as it seems broken
We're getting "fuse: copy from pipe: short read" from
libfuse and a broken filesystem with this. See
https://github.com/flatpak/flatpak/issues/570

I've tried to look into if this is fixable, but I can't
really find any way we could do things differently that
may help, so the fix is to disable spice_read.
2017-02-23 16:55:49 +01:00
Alexander Larsson
84246b6ec5 document-portal: Fix ownership of basic directories
We now report these as the user uid+gid instead of root.
2017-02-14 09:07:15 +01:00
Alexander Larsson
9791268c6b document portal: Support access() on directories 2017-01-18 11:32:44 +01:00
Alexander Larsson
4be202442d document portal: Add some debug spew 2017-01-18 11:32:44 +01:00
Alexander Larsson
8909b5437d document-portal: Treat newly created files (EXCL) as truncated ones
The EXCL pretty much guarantees it is a new file.
2017-01-18 11:32:44 +01:00
Alexander Larsson
13b0c78fe5 document portal: Report right error for setattr 2017-01-18 11:32:44 +01:00
Alexander Larsson
652f64faad Fix document portal add_named
This regressed in d488914614 where
it used to require a dir fd, but then required a regular fd.
2016-12-08 14:09:22 +01:00
Alexander Larsson
b744cd2493 Add backport of g_autoptr support for json-glib 2016-11-29 10:14:33 +01:00
Alexander Larsson
bd3eae146a document-portal: Fix warnings on 32bit builds
fi->fh is a uint64, and if we cast that directly to a pointer
on a 32bit arch then we get a warning, so lets first cast
to gsize, and then to pointer.

Should fix https://github.com/flatpak/flatpak/issues/173
2016-11-15 11:32:28 +01:00
Alexander Larsson
5c2d0065db document-portal: Correctly detect truncation and exclusive mode 2016-11-11 11:19:46 +01:00
Alexander Larsson
b61259dc79 document-portal: Fix file trucation
We were checking the error return in the wrong way.
2016-11-11 11:00:30 +01:00
Alexander Larsson
786f87fb9c document-portal: Fail fd validation if we can't open directory
We need to check if the open succeeded.
2016-11-11 10:56:25 +01:00
Alexander Larsson
46889979ea document-portal: Fix fd leak 2016-11-11 10:42:29 +01:00
Mario Sanchez Prada
5105027499 document-portal: Removed variables not used since commit 894df2ff 2016-11-03 11:17:54 +00:00
Alexander Larsson
c23316cb5d Add FlatpakKinds flag and use instead of booleans 2016-10-14 11:20:53 +02:00
Sebastian Rasmussen
b21f4bf542 Prefer g_strerror() to strerror()
It handles encodins better, is thread-safe and more portable.
2016-09-15 01:22:54 +08:00
Matthias Clasen
b2b281e485 Make flatpak_is_valid_name set a GError
Return detailed information about the problem with the name in
the GError. Update all callers.
2016-09-12 23:25:54 -04:00
Alexander Larsson
d287415150 Merge pull request #287 from smcv/tests
Various test fixes
2016-09-12 08:48:05 +02:00
Alexander Larsson
96f383198d flatpak-info: Move the instance specific data to a separate group
We don't want to confuse whats in the metadata file with this
runtime instance info.
2016-09-08 14:10:18 +02:00
Alexander Larsson
894df2ffb6 document portal: Rewrite sandboxed /app and /usr to the right place
This uses the sandboxed instance flatpak-info to find the actual
real files that are in use.
2016-09-08 12:54:54 +02:00
Alexander Larsson
e16ca25a67 utils: Change flatpak_invocation_lookup_app_id to lookup_app_info
This lets you get the entire app info rather than just the id.
For host processes you'll get an empty info with just an empty
name.
2016-09-08 12:37:32 +02:00
Simon McVittie
0160ed937d document portal: cope with multiple events that would cause failure
If the name is lost *and* the session bus is closed, we would
crash with an assertion failure when the GError is overwritten.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-09-07 17:04:44 +01:00
Juan Pablo Ugarte
cd574cfbfe document-portal: Fix the document portal for files outside /app
Strip /newroot prefix from document path since validate_parent_dir()
depends on a system path to get the parent directory stat.
2016-09-05 15:44:02 -03:00
Alexander Larsson
d10409cb3e document-portal: Fix the document portal
This was using libflatpak which is the public API, instead of the internal
library, so it was breaking in all sorts of mysterious ways. This is fixed
by just directly calling the lowlevel common/* APIs.

Also, it didn't properly handle the case where the sandboxed app passed a
path that was not in /app, this should be allowed if the fd validation
passes, that is the whole point of the checks after all.
2016-09-05 17:10:15 +02:00
Alexander Larsson
8475dfeee9 document-portal: Don't link to libflatpak.so 2016-09-05 16:18:26 +02:00
Ismo Puustinen
2d26a7d0a6 Create directories before attempting to generate code into them
If flatpak is built from a separate build directory, code generation
fails because the directory structure is not in place. Create the
necessary directories before code generation.
2016-08-26 12:36:35 +03:00
Matthias Clasen
d245ba3574 fuse: Always fail X_OK in access()
Pointed out by Ray Strode.
2016-07-27 16:00:44 -04:00
Matthias Clasen
0e8faa8c31 document-portal: Implement access()
In testing readonly exports, I noticed that gedit is does not believe
the mode it gets from stat()ing a file a million times. Instead
it calls access() to determine whether to treat it as readonly.
Since the document portal fuse file system did not implement
access(), gedit treated my file as writable and then failed when
I clicked "Save". With this patch, gedit treats the file as read-only
from the get-go.
2016-07-26 14:55:18 -04:00
Matthias Clasen
369eab84e7 Fix a typo
We were trying to check if O_NOFOLLOW was set here.
(flags & BIT_A) == BIT_B never make sense.
2016-07-25 14:28:57 -04:00
Eric Curtin
930a0a04e2 Remove unused variable in this file 2016-07-17 12:18:57 +01:00
Matthias Clasen
b6db220f7c document portal: Add --version
It is expected that --version works.
2016-07-14 23:28:53 -04:00
Cosimo Cecchi
90a3522148 document-portal: add support to activate paths inside /app
When the document portal is called from within the sandbox with an
app-private file path, translate the path to a document portal URI in
order to make it available to other applications.
2016-07-11 15:58:29 -07:00
Cosimo Cecchi
d488914614 document-portal: factor out common code to validate FD
We're going to reuse this in another location.
2016-07-11 15:56:59 -07:00
matthiasclasen
d1d881edf3 Merge pull request #172 from hadess/origin/wip/glib-reqs
Allow building on GLib 2.40 or older
2016-07-04 21:06:42 -04:00
Bastien Nocera
98356356e6 document-portal: Allow to build on the minimum GLib version
G_IO_ERROR_NOT_CONNECTED is new in 2.44, use the older
G_IO_ERROR_BROKEN_PIPE which is synonymous with the more readable
G_IO_ERROR_CONNECTION_CLOSED.
2016-07-05 01:16:33 +02:00
Alexander Larsson
51663de427 Remove unused variables 2016-07-01 14:45:53 +02:00
Simon McVittie
dab1d99c46 document portal: don't reply to GetMountPoint() until ready
As soon as we get our D-Bus name, we can start receiving method calls. If
we reply immediately, callers will think our mount point is ready.

In particular, if FUSE is unavailable, we want "flatpak run" to proceed
with no document portal; it currently tries and fails to bind-mount the
nonexistent document portal mount-point into the container.

Signed-off-by: Simon McVittie <smcv@debian.org>
2016-06-24 21:07:57 +01:00