Commit Graph

132 Commits

Author SHA1 Message Date
Jan Grulich
c226288dd6 Document portal: implement add_named_full() function
This is a convenient function which can be used with flags, adding option to return
real path of the file we are trying to open in case the sandboxed app has access
to it. It also registers this file automatically to document store so there is no
need to call grant_permission() afterwards.

Closes: #1335
Approved by: alexlarsson
2018-01-25 09:22:21 +00:00
Alexander Larsson
9eedc60cd2 run: Expose /usr and /etc if --filesystem=host
Some apps, such as gnome-builder wants to access data from the
host, for instance in builders case the system includes. If you
have full filesystem access it is not really a loss of security
to also have /ect and /usr access, but for technical reasons
we can't expose them in the normal locations. However, we
can expose them in /run/host, so do that.

Closes: #1193
Approved by: alexlarsson
2017-11-24 10:47:36 +00:00
Alexander Larsson
7493b9f6de document-portal: Fix exports of files in runtime
The check for /usr prefixed checked against the wrong variable.

Closes: #1193
Approved by: alexlarsson
2017-11-24 10:47:36 +00:00
Alexander Larsson
f6658ad712 Use the new glnx glnx_autofd name for glnx_fd_close
This is a lot clearer

Closes: #1091
Approved by: alexlarsson
2017-10-09 10:19:00 +00:00
Alexander Larsson
898e816d17 Don't enable debug output from fuse
Fixes https://github.com/alexlarsson/xdg-document-portal/issues/29

Closes: #1083
Approved by: pwithnall
2017-10-05 21:57:45 +00:00
Colin Walters
4bc46338d9 document-portal: Handle bubblewrap changing to drop /newroot
There's an oustanding bubblewrap PR where we'd like to change how
we set up the rootfs; a side effect of this will be that /newroot
disappears from the `/proc` links:
[bubblewrap pull 172](https://github.com/projectatomic/bubblewrap/pull/172).

I took a stab here at adapting the code to work in both the old and new cases.
Just compile tested at the moment. There's a lot of subtleties in this code; in
particular how we end up mutating-in-place the path buffer and how that
interacts with inspecting it.

Closes: #1063
Approved by: alexlarsson
2017-10-05 16:54:20 +00:00
Matthias Clasen
261ff03b63 Merge pull request #907 from smcv/metadata
Document all metadata groups and keys
2017-07-07 17:50:15 -04:00
Simon McVittie
489bfddfb3 common: Add and use constants for flatpak-metadata(5) groups and keys
This makes it easier to avoid typos, and also makes it easier to see
what groups and keys are in use. In the header file, they are
clustered according to the group in which the keys are used.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-07-07 16:06:21 +01:00
Philip Withnall
f47a696392 build: Add AM_* variables to all per-target special variables
For example, add $(AM_CFLAGS) to mumble_CFLAGS. Since $(WARN_CFLAGS) is
only added to $(AM_CFLAGS), this fixes the lack of inclusion of the
compiler warning flags in the compilation of half of flatpak.

Note that $(AM_*) variables are only used by automake if a more specific
(per-target) special variable is not defined instead. So if you define
mumble_CFLAGS, AM_CFLAGS will not be used for that target unless
explicitly included in mumble_CFLAGS.

See
https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html.

Do the same for $(AM_LIBADD), $(AM_LDFLAGS), etc. These are not
currently defined, but it’s good practice to include them in
mumble_LIBADD (etc.) just in case they’re defined in future. Hopefully
their inclusions will be cargo-culted to any new targets which are
added, retaining full coverage of the code base.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 15:05:58 +01:00
Philip Withnall
548f60ebc0 general: Add missing static modifier to various local methods
The compiler warning flag which was supposed to warn about this was not
being included in the CFLAGS for these targets. That will be fixed in an
upcoming commit.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-06 14:41:21 +01:00
Simon McVittie
8e03e7b719 build: Re-run gdbus-codegen if the Makefile changes
Changes to the Makefile could include changes to the options passed
to gdbus-codegen, which would invalidate the output.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-06-30 21:21:06 +02:00
Simon McVittie
f4c4abfb1e build: Only run each instance of gdbus-codegen once
A rule of the form

    foo.c foo.h: foo.in
        some-generator --output=foo foo.in

is essentially equivalent to writing the same rule once for each target:

    foo.c: foo.in
        some-generator --output=foo foo.in
    foo.h: foo.in
        some-generator --output=foo foo.in

In a parallel build, this can result in some-generator being run more
than once with the same inputs and outputs, leading to unpredictable
results if the outputs are overwritten in-place by two parallel copies
(particularly if the generator does not use the standard atomic-writing
trick of writing out a temporary file and renaming it over the top of
the intended name, which gdbus-codegen does not).

gdbus-codegen happens to write the .h file before the .c file, so
use the real build rules to generate the .c file, and consider the
.h file to be a side-effect.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2017-06-30 21:21:06 +02:00
Philip Withnall
95106a34d5 xdp-main: Fix a typo in a comparison
This was almost certainly meant to be a logical AND, not a bitwise one.
As spotted from compiler warnings.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-06 19:43:09 +01:00
Philip Withnall
a4d366f0d5 xdp-fuse: Add parentheses to clarify precedence in a conditional
As suggested by the compiler.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-06-06 19:43:09 +01:00
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