Commit Graph

1179 Commits

Author SHA1 Message Date
Matthias Clasen
9783472eaa Fix error pileup
All the error handling in the for loop is meant to
use local_error, not error.

Closes: #1936
Approved by: mwleeds
2018-08-01 16:50:11 +00:00
Richard Hughes
0afef8a38a Fix a memory leak when calling flatpak_build_file()
Closes: #1898
Approved by: mwleeds
2018-07-12 13:14:03 +00:00
Richard Hughes
d8c5d9c3b9 Fix several memory leaks when debugging is turned on
Closes: #1898
Approved by: mwleeds
2018-07-12 13:14:03 +00:00
Matthew Leeds
11c9d124d7 dir: Propagate errors from copying summary{.sig}
This commit ensures that flatpak_remote_state_save_summary()
initializes the passed GError pointer when returning FALSE. I found this
when looking into https://github.com/flatpak/flatpak/issues/1255 because
at the time of that bug report flatpak_dir_update_appstream() had this
g_file_replace_contents() code in it, which would have caused a seg
fault in update_appstream() after an unsuccessful call to
flatpak_dir_update_appstream().

Fixes https://github.com/flatpak/flatpak/issues/1255

Closes: #1893
Approved by: alexlarsson
2018-07-11 18:22:32 +00:00
Matthew Leeds
bb59dc134d lib: Fix a small memory leak 2018-07-10 19:34:04 +02:00
Richard Hughes
07c4df4475 Fix two tiny memory leaks 2018-07-10 19:26:29 +02:00
Alexander Larsson
50fd8aee24 Add FLATPAK_ERROR_RUNTIME_NOT_FOUND error 2018-07-10 19:26:16 +02:00
Alexander Larsson
0ac154e913 lib: Add FLATPAK_ERROR_REMOTE_NOT_FOUND error
And return it where we look up remotes.

Partial fix of #1855
2018-07-10 19:26:16 +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
Matthew Leeds
b664a2981c transaction: Fix NULL pointer dereference
This fixes coverity issue 1471684, and ensures we can correctly generate
an error message in flatpak_transaction_add_install_flatpakref().
2018-07-10 19:25:51 +02:00
Alexander Larsson
adffe7d15f fixup! Add flatpak_transaction_operation_type_to_string() 2018-07-10 19:25:44 +02:00
Richard Hughes
53d3a741da Add flatpak_transaction_operation_type_to_string()
This seemed like a useful thing to have, and is what I used in gnome-software.
2018-07-10 19:25:44 +02:00
Richard Hughes
6a3a637248 Don't force flatpakrepo files to haved signed content 2018-07-10 19:25:44 +02:00
Alexander Larsson
a568740b20 transaction: drop installation caches when needed
If a remote is added or modified in the cloned FlatpakDir
we also drop caches in the one in the installation.

Fixes #1882

Closes: #1883
Approved by: alexlarsson
2018-07-10 14:29:17 +00:00
Alexander Larsson
35786c9529 update-remote-config: Fix potential NULL dereference
This fixed coverity issue 1471683.

Closes: #1880
Approved by: mwleeds
2018-07-10 12:46:48 +00:00
Matthew Leeds
e3ec1ec537 dir: Use flatpak_dir_use_system_helper() more
Use the helper function to decide whether to use the system helper in
one more place.

Closes: #1874
Approved by: alexlarsson
2018-07-09 23:02:16 +00:00
Alexander Larsson
e4dbd107b3 system-helper: Fix race condition with idle exit
If the system helper process exits due to being idle the
FlatpakSystemHelper dbus proxy will return errors on
all calls, because it resolves the well known name to
a unique name on creation, which means it will try
to talk to the old idle-exited instance.

The fix is to not use GDBusProxy, but instead manually
call g_dbus_connection_call_sync().

Fixes #1845

Closes: #1873
Approved by: mwleeds
2018-07-09 17:22:00 +00:00
Alexander Larsson
3f4518b15c Run uncrustify
Closes: #1870
Approved by: alexlarsson
2018-07-08 10:05:37 +00:00
Alexander Larsson
98fd052695 transaction: Move the handling of bundle runtime remote from cli code
This allows libflatpak users to also add runtime remotes
as needed by bundles.

Closes: #1868
Approved by: alexlarsson
2018-07-07 15:38:46 +00:00
Alexander Larsson
c0ebd3a121 transaction: Move flatpakref installation to transaction code
This adds the flatpak_transaction_add_install_flatpakref method
to easily install from flatpakref files. It additionally
adds a new signal called add-new-remote which is called in two
cases:

 To ask if the user wants to add a "normal" remote for the url
 specified by a flatpakref file.

 When a new remote is required for the runtimes the application
 depends on.

Closes: #1868
Approved by: alexlarsson
2018-07-07 15:38:46 +00:00
Alexander Larsson
1ecca029a8 transaction: Add flatpak_transaction_set_default_arch
This will be used as the default when installing something that
doesn't specify a ref, such as a flatpakref file.

Closes: #1868
Approved by: alexlarsson
2018-07-07 15:38:46 +00:00
Alexander Larsson
0d19e60ce3 system-helper: Add EnsureRepo operation
This is used to create the /var/lib/flatpak repo if
needed so that other later operations work. We have
some partial support for it not working in various
operations (using the allow_empty argument) but
this is in no way complete. For example, this
can easily happen if you have a per-user installation
but no system one and then you run flatpak install
with no --user, then it will try to figure out
which one to use and die.
2018-07-07 16:37:44 +02:00
Alexander Larsson
b999a785f2 flatpak_dir_deploy_appstream: Handle the no-local-commit exists case
For some reason I hit this with a test remote, and it crashes. Make
it return an error instead.

Closes: #1854
Approved by: alexlarsson
2018-07-05 07:38:35 +00:00
Matthew Leeds
dc3d86139d dir: Improve metadata fetch error message
In the case that the collection ID configured on a remote is NULL the
repo metadata comes from the summary file. But if there's an error
fetching the summary in _flatpak_dir_get_remote_state() and then
flatpak_remote_state_ensure_metadata() is called, the
metadata_fetch_error variable will be NULL and "unknown error" will be
returned as the error message. This commit returns the
summary_fetch_error message in that case so the user gets a slightly
more helpful error message.

Some Endless computers in Africa have recently been hitting this code
path and printing "unknown error" messages.

Closes: #1844
Approved by: alexlarsson
2018-07-02 07:57:37 +00:00
Grzegorz Antoniak
f9be8c0fcf Fixed a 'maybe uninitialized' warning and a code style change.
Closes: #1851
Approved by: alexlarsson
2018-07-02 07:48:39 +00:00
Grzegorz Antoniak
8155400fca NULL pointer check after calling getgrgid()
When the user runs with gid=X, but X doesn't have an entry in
/etc/groups, then a segmentation fault occured. This was happening
because flatpak-run.c didn't guard against a NULL pointer after calling
getgrgid() in flatpak_run_setup_base_argv.

Closes: #1850

Closes: #1851
Approved by: alexlarsson
2018-07-02 07:48:39 +00:00
Alexander Larsson
93ca5cdf45 transaction: Add get_installation()
Closes: #1841
Approved by: alexlarsson
2018-06-29 12:56:15 +00:00
Alexander Larsson
f504656890 transaction: Mark error const in operation-error signal
Closes: #1841
Approved by: alexlarsson
2018-06-29 12:56:15 +00:00
Philip Withnall
2968e511b4 common/dir: Fix a couple of leaks of GKeyFile config objects
ostree_repo_copy_config() returns (transfer full).

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #1831
Approved by: mwleeds
2018-06-27 19:16:02 +00:00
Alexander Larsson
5754208b19 Fix lock in instance id creation
When allocating an instance id we create a unique directory
in $XDG_RUN_DIR/.flatpak/$id and create a .ref file in it which
we then read-lock (with F_SETLK). This lock is also taken by
the bwrap pid 1, so it will be taken for as long as the
app lives.

To clean up old is we remove any directories where we can successfully
write-lock the .ref file. As long as the sandbox lives this should
make it safe against removal.

However, there is a tiny race in the sandbox setup between the inital
O_CREAT of the .ref file and the F_SETLK fcntl. A GC at this point
may find the .ref file existing but not locked and then remove the
directory.

We work around this by only trying to lock .ref files that are more
than 3 seconds old.
2018-06-27 14:07:07 +02:00
Christian Hergert
2ada826e74 build: work around guard changes in libsoup 2018-06-27 13:06:37 +02:00
Matthew Leeds
f8577e0791 Remove outdated ostree version check
Now that flatpak depends on ostree 2018.6 we don't need to check if we
have 2018.5. Remove the check and update a comment.

Closes: #1813
Approved by: alexlarsson
2018-06-23 11:26:26 +00:00
Alexander Larsson
f9af050a81 utils: Add g_key_file_load_from_bytes fallback for old glib 2018-06-21 18:52:01 +02:00
Alexander Larsson
54e958d202 Transaction: Use flatpak_dir_resolve_p2p_refs to resolve p2p refs
This allows us to resolve as many operations as possible in parallel
which is much faster than doing the p2p queries for each potential
update.

Fixes #1592

Closes: #1796
Approved by: alexlarsson
2018-06-20 09:10:31 +00:00
Alexander Larsson
c647c315ef dir: Add flatpak_dir_resolve_p2p_refs()
This takes a list of refs + remotes and optional commit, all
which need to be p2p (i.e. have collection-id != NULL) refs, and
uses the p2p API to resolve the refs to the latest available commit
it and the matching metadata for that version.

It does this by doing a find_remotes() and then a pull_from_remotes
with PULL_FLAG_COMMIT_ONLY and then extracting the metadata
from the commit object.

We also do some checking before pulling so that if we have the latest
reported commit already available locally then we don't pull anything
for that ref (instead resolving to the locally available metadata).

We always pull to a child repo so that we have write-rights even as a
user (in the system case) and so we can properly clean up the temporary
results.

Note, this unconditionally uses the p2p APIs, and it relies on the latest
ostree master which has a fix that allows us to read the latest refs from
the transaction.

Closes: #1796
Approved by: alexlarsson
2018-06-20 09:10:31 +00:00
Alexander Larsson
d15fe7f5b2 dir: Break out flatpak_dir_create_child_repo
This is broken out of latpak_dir_create_system_child_repo and now
allows you to create user child repos too.

Closes: #1796
Approved by: alexlarsson
2018-06-20 09:10:31 +00:00
Alexander Larsson
9901ce875f dir: Never fsync child repos
There is no need to force a fsync after pulling into the child repo,
because we will anyway copy/verify it into the system repo. It is
never used for stable storage.

This makes system installation faster.

Closes: #1808
Approved by: alexlarsson
2018-06-20 08:40:28 +00:00
Matthew Leeds
71d4539d5d transaction: Fix wording in docs for "ready" signal
Closes: #1802
Approved by: alexlarsson
2018-06-20 08:27:19 +00:00
Matthew Leeds
1a240ac686 transaction: Fix g-ir-scanner warnings
Closes: #1801
Approved by: alexlarsson
2018-06-20 07:52:55 +00:00
Matthew Leeds
4e73b51a0b dir: Avoid unnecessary fetches of ostree-metadata
This commit removes fetches of ostree-metadata from
flatpak_dir_install() and flatpak_dir_update(), which both pull it into
the child repo when doing system-helper deployments. Both functions have
a FlatpakRemoteState object passed in and when that is initialized,
_flatpak_dir_fetch_remote_state_metadata_branch() pulls and deploys
ostree-metadata so it can be queried against for repo metadata and
served onto LAN and USB peers. So there's no need to pull it again here.

The issue of resolving a ref and its metadata atomically remains, but
that will be addressed by https://github.com/flatpak/flatpak/pull/1796.

Closes: #1806
Approved by: alexlarsson
2018-06-20 07:40:21 +00:00
Alexander Larsson
491d174879 Make p2p build non-optional
Closes: #1800
Approved by: alexlarsson
2018-06-19 18:10:56 +00:00
Alexander Larsson
065053775b run: Never inherit permissions from the runtime
We want inherit environment variables, but not actual permissions,
those need to be requested by the app only.

Closes: #1799
Approved by: alexlarsson
2018-06-19 14:54:22 +00:00
Alexander Larsson
23f1df8a5b Transaction: Add operation getters for metadata and old_metadata
Closes: #1799
Approved by: alexlarsson
2018-06-19 14:54:22 +00:00
Alexander Larsson
35615cbe54 Transaction: Track old metadata (for updates)
Closes: #1799
Approved by: alexlarsson
2018-06-19 14:54:22 +00:00
Alexander Larsson
db305f7287 Transaction: Keep metadata as GBytes
This makes it more easy to expose these without constantly
duplicating the memory.

Closes: #1799
Approved by: alexlarsson
2018-06-19 14:54:22 +00:00
Alexander Larsson
0515e49140 transaction: Add APIs to set dependency sources
Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Alexander Larsson
5e8b5e5319 Transaction: Use flatpakTransactionOperation in signals
This changes the signals to use a FlatpakTransactionOperation
argument instead of a bunch of arguments in the signal, making
this easier to extend in the future.

This is an API break, but nobody is using this API yet, and it
was only available in one unstable release.

Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Alexander Larsson
462204462e Transaction: Add flatpak_transaction_operation_get_bundle_path
This is to match what you can get from the new_operation arguments.

Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Alexander Larsson
f9ad4e3eee transaction: Add ready signal
This signal is emitted after all the added operations and their dependencies
are resolved and we have the full list of things that will be
done as part of the transaction. At this point you can call
flatpak_transaction_get_operations() and decide if you want to
continue with the operation.

Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00
Alexander Larsson
4c8f788ecd transaction: Make FlatpakTransactionOperation a (public) GObject
Only the type itself is exposed atm, not members, etc.

Closes: #1797
Approved by: alexlarsson
2018-06-19 08:30:21 +00:00