Commit Graph

67 Commits

Author SHA1 Message Date
Rafael Fontenelle
95e692794b Fix misspellings
Closes: #2807
Approved by: matthiasclasen
2019-04-08 12:50:42 +00:00
Matthew Leeds
e8816b7663 Remove extra newlines in variable definiton blocks
Uncrustify has an option "nl_func_var_def_blk" which is supposed to
ensure there's a newline character between the block of variable
definitions and the rest of the function body, but it gets confused and
thinks that the first instance of "g_autoptr" or "g_auto" being used on
a variable is the start of the function body. So this commit removes
those extra newline characters and removes that option in uncrustify.cfg
so they don't get re-added the next time uncrustify is run.

Here's the command I used:

perl -0777 -i -pe 's/\n(\n\s*g_auto\()/\1/g' `git ls-tree --name-only
-r HEAD | grep \\\.[ch]$ | grep -v common/valgrind-private.h |
grep -v app/flatpak-polkit-agent-text-listener\\\.[ch]`

I ran it again with "g_autoptr" in place of "g_auto", and made a few
manual edits to add back the newline when the g_auto* was in the middle
of a function body rather than at the top.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Matthew Leeds
8d962a686f Run uncrustify
I had to make a few manual edits but other than those the changes look
reasonable.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Matthias Clasen
64e6764137 session-helper: Drop the unused RequestMonitor api
Nothing is using this now that we have RequestSession.
No need to carry this round.

Closes: #2533
Approved by: alexlarsson
2019-01-11 13:05:58 +00:00
Simon McVittie
4111dbadaf session-helper: Don't crash on NameOwnerChanged
There was a typo here: (gpointer *) pid_data should have been
(gpointer *) &pid_data, so that g_hash_table_iter_next() would make
pid_data a pointer to a PidData struct. Instead, the previous
implementation left pid_data set to NULL, leading to a NULL dereference
and segmentation fault whenever a name fell off the bus while a watched
client existed.

Instead of directly inserting the missing "&", I've used a pattern
that avoids needing the cast, in an attempt to make it more obviously
correct.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2417
Approved by: matthiasclasen
2018-12-11 15:43:37 +00:00
Matthias Clasen
c516a22e4d session-helper: Improve HostCommand life-cycle handling
Add flag that instructs the session-helper to kill
the spawned command when the caller drops off the bus.

Closes: #2326

Closes: #2365
Approved by: alexlarsson
2018-12-06 13:10:51 +00:00
Matthias Clasen
972804f222 session-helper: Validate HostCommand arguments
This is not a portal, but we should still do some
due diligence.

Closes: #2365
Approved by: alexlarsson
2018-12-06 13:10:51 +00:00
Will Thompson
97983ba377 portal, session-helper: fix typo in TIOCSCTTY comment
Closes: #2382
Approved by: matthiasclasen
2018-12-04 13:41:29 +00:00
Matthias Clasen
4ef317c9ba session-helper: Properly report p11-kit exit status
Use the API that GLib offers for this.

Closes: #2252
Approved by: matthiasclasen
2018-10-23 20:10:37 +00:00
Alexander Larsson
0b6844f39e sandbox: Expose /etc/timezone
This exposes a /etc/timezone with the current timezone, as per the old
debian spec: https://wiki.debian.org/TimeZoneChanges

In case we're using the session-helper this will be extracted from
the host config and applied whenever that changes.

Normally timezone info is specified by /etc/localtime being a symlink
into the locale data, and you can look at the symlink value itself.
However, in the sandbox we can't update a symlink in /etc at runtime,
nor can we make it of the canonical form as that would point into the
runtime. This is why /etc/timezone is used.

This fixes https://github.com/flatpak/flatpak/issues/2190

Closes: #2214
Approved by: alexlarsson
2018-10-10 15:12:21 +00:00
Matthias Clasen
40f413836a Drop xdg-app migration support
It has been long enough. It is unlikely that we can still
find any xdg-app installations in the wild.
2018-10-10 12:20:27 +02:00
Alexander Larsson
aecc6285d6 utils: Add flatpak_fail_error that takes an error code
This makes it easy to return FlatpakErrors
2018-07-10 19:26:16 +02:00
Alexander Larsson
3f4518b15c Run uncrustify
Closes: #1870
Approved by: alexlarsson
2018-07-08 10:05:37 +00:00
Alexander Larsson
11d9b5b0b6 session-helper: Disable p11-kit for older broken versions
p11-kit server version < 0.23.10 doesn't properly daemonize which
causes g_spawn_sync() to hang forever waiting for the pipe to
close.

We work around this by passing --sh, which is only available in the
working version, and fill fail the old ones.

https://github.com/flatpak/flatpak/issues/1768

Closes: #1782
Approved by: alexlarsson
2018-06-13 10:08:56 +00:00
Alexander Larsson
ab87617ac1 session-helper: break out the p11-kit code to a separate function
This makes it easier to read. Also, we convert some nested ifs
to early returns.

Closes: #1782
Approved by: alexlarsson
2018-06-13 10:08:56 +00:00
Alexander Larsson
66b2ff40f7 run: Support accessing host trusted certificates
If p11-kit server is installed on the host, we spawn a copy of this, forwarding the access to the
p11-kit trust module in a read-only way.

We then (if the above worked) bind mount the socket as /run/user/$UID/p11-kit/pkcs11 in the sandbox,
which is the default socket path for the p11-kit-client module.

We also add a configuration file in /etc/pkcs11/modules/p11-kit-trust.module that makes the trust
module actually load the client module instead. This means applications automatically switch
to using the host certs for trust if possible, and use the runtime ca-certificates otherwise.

Additionally we add a config file that always disables pkcs user
config merging, because pkcs11 modules on the host are unlikely to work in a random runtime.

Closes: #1757
Approved by: alexlarsson
2018-06-07 12:25:21 +00:00
Alexander Larsson
b4bb890516 session-helper: Add new more generic helper start method
This does the same as RequestMonitor, but returns the status via a
a{sv} so that its more extensible.

Closes: #1757
Approved by: alexlarsson
2018-06-07 12:25:21 +00:00
Alexander Larsson
c570e09ac9 common: Rename all generated files to *-dbus-generated.[ch]
Easier to spot them this way

Closes: #1706
Approved by: alexlarsson
2018-05-24 11:59:52 +00:00
Alexander Larsson
960d20448c common: Rename all private headers to *-private.h
This is the start of the merging of lib/* into common/*

Closes: #1706
Approved by: alexlarsson
2018-05-24 11:59:52 +00:00
Robert McQueen
6475f7663c session-helper: refactor creation and updating of real path monitors
I think this enhances readability significantly, reduces code duplication
and allows you to follow the rationale behind why monitors are being
added/removed a lot more clearly than the previous nested/ad-hoc logic in
file_changed. Also adds debug printouts in the case that file monitors
are not created successfully.

Closes: #1194
Approved by: pwithnall
2017-11-23 14:47:12 +00:00
Robert McQueen
46fa8492ac session-helper: avoid theoretical GFile leaks with g_autoptr
Closes: #1194
Approved by: pwithnall
2017-11-23 14:47:12 +00:00
Robert McQueen
bdf0f8c554 session-helper: add comment documenting rationale for two monitors
Closes: #1194
Approved by: pwithnall
2017-11-23 14:47:12 +00:00
Robert McQueen
2b516e5df1 session-helper: remove unused file_monitor_hash
The monitor data structures are never replaced in the hash table, so
it's not necessary. Keep MonitorData pointers in scope in main() and
set up g_autoptr instead.

Closes: #1194
Approved by: pwithnall
2017-11-23 14:47:12 +00:00
Robert McQueen
dc6a880238 session-helper: monitor canonical files for changes
Closes: #1190
Approved by: alexlarsson
2017-11-23 10:39:44 +00:00
Robert McQueen
c59f41a5f4 session-helper: store file monitor & source in a hash table
Closes: #1190
Approved by: alexlarsson
2017-11-23 10:39:44 +00:00
Robert McQueen
b31773b097 session-helper: remove un-needed file monitor actions on CREATED
CHANGES_DONE always fires after CREATED.

Closes: #1190
Approved by: alexlarsson
2017-11-23 10:39:44 +00:00
Alexander Larsson
4c91eeeada Change debug prefix from XA to F
We're not xdg-app anymore

Closes: #1173
Approved by: mwleeds
2017-11-16 08:15:15 +00:00
Matthias Clasen
ed08538f92 Merge pull request #900 from pwithnall/lan-and-usb-preparation
LAN/USB preparation refactoring
2017-07-08 20:54:28 -04:00
Philip Withnall
81301f0ef4 general: Remove trailing \n from GLib log messages
The GLib logging framework automatically appends a \n to messages, so it
doesn’t need to be added by callers.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2017-07-07 17:18:24 +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
Alexander Larsson
bda7575e79 Add version property to all dbus interfaces 2017-05-19 14:38:22 +02:00
Alexander Larsson
4d2d07d033 Expose host /etc/hosts and /etc/host.conf
These are local network configuration, very much similar to
resolv.conf, so should also be exposed.

Fixes https://github.com/alexlarsson/spotify-app/issues/42
2017-05-04 13:08:25 +02:00
Owen W. Taylor
5f12c9e328 flatpak-session-helper.c: Make failure of TIOCSCTTY a g_debug()
Just because stdout/stderr happen to be going to a terminal doesn't
necessarily mean that we want the command launched by HostCommand
to take ownership of the terminal - in the case where 'flatpak run'
is launched from a terminal, stderr will typically be left pointing
to the terminal for any command. In that case the terminal already
has a controlling process, and TIOCSCTTY will fail; avoid scary
messages by making the failure only a g_debug()
2017-01-27 10:47:13 +01:00
Alexander Larsson
b744cd2493 Add backport of g_autoptr support for json-glib 2016-11-29 10:14:33 +01:00
Alexander Larsson
cecae8295c Fix build due to missing include 2016-11-11 11:15:00 +01:00
Christian Hergert
b3489c3557 session-helper: use proper fd with ioctl() for tty setup
This was using the "from" fd from the fd_map, which will have already been
closed by time we reach this portion of the child setup.

Tracking the movement of FDs while resolving the remappings is rather
tedious and error prone, so just locate the final fd before calling
the ioctl() in child setup.
2016-09-15 21:38:06 -07:00
Alexander Larsson
8628ec938e HostCommand: Return actual PID
This is needed by e.g gnome-builder that want to pass this pid to
a profiler service. Its not really less secure/sandboxed this way,
because the app can launch whatever he wants in the host, which could
anyway talk back and report the real pid.
2016-09-14 10:03:15 +02:00
Christian Hergert
bed5eb5863 session-helper: return after sending DBus error
Make sure we let the caller know we handled the message immediately after
sending our error reply.
2016-09-12 01:37:50 -07:00
Tobias Mueller
2422c386e2 flatpak-session-helper: Check for arg_argv being NULL
To prevent crashers like the following:

Starting program: /var/tmp/flatpak/libexec/flatpak-session-helper
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffed8a9700 (LWP 7893)]
[New Thread 0x7fffed0a8700 (LWP 7894)]
[New Thread 0x7fffec439700 (LWP 7895)]
session-helper/flatpak-session-helper.c:176:20: runtime error: load of null pointer of type 'const gchar'

Thread 1 "flatpak-session" received signal SIGSEGV, Segmentation fault.
0x000000000040d6ce in handle_host_command (object=0x62100001ab90,
    invocation=0x61d000014dc0, arg_cwd_path=0x0, arg_argv=0x602000003dd0,
    arg_fds=0x61900000b130, arg_envs=0x61900001d2a0, flags=1)
    at session-helper/flatpak-session-helper.c:176
176   if (*arg_argv[0] == 0)
(gdb)
2016-09-08 17:50:46 +02:00
Alexander Larsson
41443313ca session-helper: Move HostCommand to its own interface 2016-09-06 15:30:38 +02:00
Alexander Larsson
c8df0e6208 SessionHelper: Add calls to spawn processes on the host
This lets any client, possibly in a sandbox if it has access to the
session helper, spawn a process on the host, outside any sandbox.

Clearly this is not something you typically want a sandboxed app to
do. However, it is sometimes very useful when using flatpak mainly
for distribution. For instance, an IDE needs to use this to launch a
flatpak build operation inside the sandbox. (Because otherwise recursive
calls to flatpak will not work.)
2016-09-05 21:41:14 +02:00
Alexander Larsson
0a20f28f89 session-helper: Add support for -r -v --help --version 2016-09-05 11:54:12 +02:00
Matthias Clasen
75218c4a65 Fix license headers
We were referring to the nonexisting "version 2" of the
Lesser GPL. It should be "version 2.1".
2016-07-29 14:27:49 -04:00
Alexander Larsson
28b549156a Split out permission store from session helper
This is now available as org.freedesktop.impl.portal.PermissionStore
2016-05-09 14:07:22 +02:00
Alexander Larsson
5e9b247d26 Migrate ~/.local/share/xdg-app to ~/.local/share/flatpak 2016-05-09 12:21:28 +02:00
Alexander Larsson
8abbc0186e Rename everything but the on-disk location to flatpak 2016-05-09 11:11:55 +02:00
Alexander Larsson
ba37b22d78 Rename library to libflatpak 2016-05-09 09:46:26 +02:00
Alexander Larsson
c24528d369 Rename source files to flatpak 2016-05-09 09:00:20 +02:00
Alexander Larsson
6a613d1fab Rename all non-autogenerated symbols to flatpak 2016-05-09 09:00:20 +02:00
Alexander Larsson
1ffdf27d92 uncruftify: Initial run, all non-problematic changes 2016-05-06 16:03:27 +02:00