Commit Graph

382 Commits

Author SHA1 Message Date
Alexander Larsson
af76206ba5 common: Add flatpak_variant_builder_init_from_variant 2016-09-27 12:39:27 +02:00
Alexander Larsson
636130db49 Merge pull request #299 from matthiasclasen/keyring
flatpak should close up access to kernel keyring
2016-09-21 07:12:30 +02:00
Alexander Larsson
acc561c6fc Add versioning info to the appinfo file. 2016-09-19 16:33:48 +02:00
Alexander Larsson
9e6421d0d9 common: Accept empty/no url in modify_remote
This means that the remote is there, but disabled.
This is needed for e.g. bundles without origin url, and when bundles
starting using this codepath this regressed like in:
 https://github.com/flatpak/flatpak/issues/314
2016-09-19 16:27:54 +02:00
Matthias Clasen
2bfb1b435a Don't allow access to the kernel keyring
For now, we don't use the kernel keyring for anything, so it is
better to shut off the access to it.
2016-09-18 16:50:32 -04:00
Alexander Larsson
5c075525a8 Allow application ids containing "-"
For a long time we have been disallowing "-" in application names,
which is different than what dbus allows for bus names. Also "-" used
to be not allowed by GApplication in glib. This is in part because
dbus object paths do *not* allow dashes, so you can't legally map
from e.g. a valid name like "org.foo-bar.gazonk" to a valid path
like "/org/foo-bar/gazonk".

This is a problem because many existing apps already use "-" in the
name, either as the last part (org.gnome.font-viewer) or because
the dns name it refers to has a dash.

This was recently discussed in the dbus community, and the result
is to recommend that "-" in the bus names be converted to "_" in object
paths.

This change makes it also allowed to have "-" in a flatpak app id.

For flatpak specifically we were relying on "-" not being allowed to
handle the case of exporting "org.foo.App-symbolic.png". If "-" is
allowed this name can conflict between apps called "org.foo.App-symbolic"
and "org.foo.App".

To handle this we add two special cases:
 * App ids can't end with "-symbolic".
 * Apps are allowed to export files with $appid-symbolic as prefix.
2016-09-16 16:44:05 +02:00
Sebastian Rasmussen
135476e69a run: Print errno error code consistently
Commit 352e761c0e started the trend
to print the errno error code when unable to open a file, make all
occurrences where files are opened print the same kind of message.
2016-09-15 01:23:05 +08: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
Alexander Larsson
1d1189aeab Fix crash if completing with NULL shell_cur
This happens if you do e.g.
  flatpak complete "flatpak install " 11

Reported by aki237
2016-09-14 14:31:33 +02:00
Matthias Clasen
06c7aca9f9 Make flatpak_is_valid_branch set a GError
Return detailed information about the problem with the branch in
the GError. Update all callers.
2016-09-13 13:28:42 -04:00
Matthias Clasen
fe91657a44 Update the docs
Update the doc comment for flatpak_is_valid_name to reflect
current reality.
2016-09-13 13:15:41 -04:00
Matthias Clasen
687cae783e Always set an error when failing name validation
This was an oversight in the previous patch to improve
name validation error messages.
2016-09-13 13:13:43 -04: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
edac377e86 origin remotes: Store main ref
If you install an app via a bundle of a .flatpakref file then
the ref of the app is also saved with the remote metadata.
2016-09-12 11:58:22 +02:00
Alexander Larsson
968d9b1169 app-info: Fix saving of features to keyfile
This was accidentally using the devices bitmask instead
2016-09-12 11:11:50 +02:00
Alexander Larsson
fba645a999 Remove unused local variables reported by clang 2016-09-12 11:11:35 +02:00
Alexander Larsson
3fafba8b1e Don't use deprecated ostree_repo_checkout_tree_at function
We now use the new (almost identical) ostree_repo_checkout_at.
2016-09-12 09:03:33 +02:00
Alexander Larsson
71500ae5ec Add support for .flatpakref files
These are similar to .flatpakrepo, but for a single app.

For example, if you have a file gedit.flatpakref with this:

[Flatpak Ref]
Title=GEdit
Name=org.gnome.gedit
Branch=stable
Url=http://sdk.gnome.org/repo-apps/
IsRuntime=False
GPGKey=mQENBFUUCGcBCAC/K9WeV4xCaKr3NKRqPXeY5mpaXAJyasLqCtrDx92WUgbu0voWrhohNAKpqizod2dvzc/XTxm3rHyIxmNfdhz1gaGhynU75Qw4aJVcly2eghTIl++gfDtOvrOZo/VuAq30f32dMIgHQdRwEpgCwz7WyjpqZYltPAEcCNL4MTChAfiHJeeiQ5ibystNBW8W6Ymf7sO4m4g5+/aOxI54oCOzD9TwBAe+yXcJJWtc2rAhMCjtyPJzxd0ZVXqIzCe1xRvJ6Rq7YCiMbiM2DQFWXKnmYQbj4TGNMnwNdAajCdrcBWEMSbzq7EzuThIJRd8Ky4BkEe1St6tuqwFaMZz+F9eXABEBAAG0KEdub21lIFNESyAzLjE2IDxnbm9tZS1vcy1saXN0QGdub21lLm9yZz6JATgEEwECACIFAlUUCGcCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEArkz6VV0VKBa5cH/0vXa31YgEjNk78gGFXqnQxdD1WYA87OYxDi189l4lA802EFTF4wCBuZyDOqdd5BhS3Ab0cR778DmZXRUP2gwe+1zTJypU2JMnDpkwJ4NK1VP6/tE4SAPrznBtmb76BKaWBqUfZ9Wq1zg3ugvqkZB/Exq+usypIOwQVp1KL58TrjBRda0HvRctzkNhr0qYAtkfLFe0GvksBp4vBm8uGwAx7fw/HbhIjQ9pekTwvB+5GwDPO/tSip/1bQfCS+XJB8Ffa04HYPLGedalnWBrwhYY+G/kn5Zh9L/AC8xeLwTJTHM212rBjPa9CWs9C6a57MSaeGIEHLC1hEyiJJ15w8jmY=

You can then install gedit with
  flatpak install --from gedit.flatpakref
2016-09-09 16:50:32 +02:00
Alexander Larsson
65a1ba186f bundles: Support updating from a bundle
Now:
 flatpak install --bundle $file
Will update the bundle if its already installed.
2016-09-09 14:54:38 +02:00
Alexander Larsson
6689c5c7f1 Switch back to mtime==0 for ostree checkouts
OSTree upstream changed back from mtime 1
2016-09-09 09:22:56 +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
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
Alexander Larsson
4408468e78 common: Remove leftover spew 2016-09-08 12:36:11 +02:00
Alexander Larsson
b53b78b2a2 run: Drop/Hide --no-desktop option
This is no longer needed, as we don't hard-require systemd --user.
We keep the opion there, but hidden in order to be backwards compatible
with old code that used this.
2016-09-08 11:40:49 +02:00
Alexander Larsson
7f01e5113b run: Make cgroup (and the systemd --user requirements) optional
We no longer hard-depend on this, so if it fails, we just run on.
2016-09-08 11:37:17 +02:00
Alexander Larsson
0d22bad5e6 document-portal: Detect remote peer app id using flatpak-info
This drops the requirement on unprivileged cgroups, and thus the
dependency on systemd --user.
2016-09-08 11:24:10 +02:00
Alexander Larsson
352e761c0e run: Run dbus proxy under bubblewrap
This has two advantages. First of all (and most important) it
lets us put a /.flatpak-info file in it, so that the dbus peers
it talks to have the right "source" app id and sandboxed status.

Secondly, it lets us run the bus with readonly access to things,
thus being somewhat more secure.
2016-09-08 11:21:00 +02:00
Alexander Larsson
e5ff76fa77 run: Fail hard if we can't create the flatpak-info file
We want to base security on this, so we need it to be there.
2016-09-08 10:16:40 +02:00
Alexander Larsson
5bf37574f1 flatpak-info: Flatten the metadata to make it more easy to parse
The info file is always standalone, as it never needs to stack on top
of another context. This means we can remove all "negative" attributes
such as "shared=!network", making it easier to parse this file.
2016-09-07 14:32:10 +02:00
Alexander Larsson
e1ad3a7a3c flatpak-info: Add application branch info
Note: This is only available in flatpak run, not flatpak build, where
this info is not available.
2016-09-07 12:31:56 +02:00
Alexander Larsson
0fc06022c8 flatpak-info: Add runtime path 2016-09-07 12:19:13 +02:00
Alexander Larsson
32c571ae79 Move $XDG_RUNTIME_DIR/flatpak-info to /.flatpak-info and make it read-only
The old location keeps working because we create a symlink.

The interesting part of this is that the sandbox now can't modify,
remove or replace the file, and it is in a fixed position. This means
that given a sandboxed pid, we can find this file as
"/proc/$pid/root/.flatpak-info".

This is very nice for two reasons:
 * We can use this instead of the cgroup to find out if a pid is
   sandboxed or not. This means we can drop the dependency on
   systemd --user for this.
 * We can get more information about the peer process that the
   app id. For instance, we can see what permissions the sandboxed
   app has.
2016-09-07 11:53:05 +02:00
Alexander Larsson
983b2a5db1 lib: Look for "bwrap" in PATH when launching from libflatpak
We forgot to look in the path, which made it fail when using
the system bwrap and not passing a full path.
2016-09-06 15:29:36 +02:00
Alexander Larsson
e6a85a7fdd utils: Fix support for old glib without g_autoptr 2016-09-06 09:26:02 +02:00
Alexander Larsson
fbca999cc9 Create /app/(.updated|.removed) file after update/uninstall
This way running apps can easily detect this and restart themselves.
2016-09-06 09:16:04 +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
aafc0f3b66 run/metadata: Add support for --allow=devel
This enables support for ptrace and perf for the app, similar
to what run -d manually gave you before. This is nice to be
able to package an app like gnome-software.
2016-09-05 21:41:14 +02:00
Alexander Larsson
a788965eec Support FLATPAK_USER_DIR env var 2016-09-05 21:41:14 +02:00
Alexander Larsson
ff6839a291 utils: Add flatpak_is_in_sandbox() helper 2016-09-05 11:54:12 +02:00
Alexander Larsson
4865d1edd2 common: Export flatpak_run_add_app_info_args
We want to use this from flatpak build too
2016-09-05 11:54:12 +02:00
Alexander Larsson
3ec0ecba93 common: add_app_info_args() talk GFile *app_files instead of a deploy
We don't really need the full deploy anyway.
2016-09-05 11:54:12 +02:00
Alexander Larsson
e50f7a363f build-update-repo: Reuse cache info from old summary
This makes rebuilding partial changes much faster.
2016-09-02 11:13:11 +02:00
Alexander Larsson
ba377b29e6 common: Add utility function to load summary file from local repo 2016-09-02 11:10:29 +02:00
Dan Nicholson
d2d9804187 utils: Only collect cache data once per revision
If there are multiple refs pointing to the same revision, then
collecting the size and metadata info for each of them is wasteful.
Maintain a hash table of the data so that it's only collected once per
revision.

This slightly widens an existing race where a ref could be updated
before the summary file is regenerated. In that case, the data in the
xa.cache variant would correspond to the wrong revision. I don't believe
this can be fixed unless there's locking at the ostree level.
2016-09-01 10:11:13 -07:00
Dan Nicholson
e86ae01ba0 utils: Only update summary info for flatpak refs
If there are non-flatpak refs in the ostree repo, there's no use in
collecting size or metadata information for them. Instead, only operate
on refs in the appstream, app or runtime prefixes.
2016-09-01 10:11:13 -07:00
Dan Nicholson
d304c4eca1 utils: Free list of refs in flatpak_repo_update
Although the data is owned by the hash table, the list storage needs to
be freed with g_list_free(). Use g_autoptr for that.
2016-09-01 10:11:07 -07:00
Alexander Larsson
509bb33a2b Merge pull request #237 from mwleeds/add-trace-msg
utils: Print a debug message when launching subprocesses
2016-08-30 09:22:02 +02:00
Alexander Larsson
b39c2e81ee Merge pull request #265 from ipuustin/fix-build
Create directories before attempting to generate code into them
2016-08-29 12:35:29 +02:00
Alexander Larsson
b678431197 Treat remotes with empty url as disabled
This happens with e.g. remotes from a bundle with no origin.

Fixes https://github.com/flatpak/flatpak/issues/270
2016-08-29 12:03:33 +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