summaryrefslogtreecommitdiff
path: root/src/libostree/ostree-repo-finder-avahi.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: Run clang-formatColin Walters2023-05-021-291/+212
| | | | | This is a one-time tree wide reformatting to ensure consistency going forward.
* glib: bump glib requirement to 2.66 and port to GUriDaniel Kolesa2022-03-121-10/+6
| | | | | This removes the old SoupURI copypasta from previous generation of libsoup and opens up a path for a simple libsoup3 port.
* Update FSF license notices to use URL instead of addressJoseph Marrero2021-12-071-3/+1
|
* lib: fix typo in function docsFelix Krull2020-04-011-1/+1
|
* avahi: Be robust to missing refs in peer summariesMatthew Leeds2018-09-071-18/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the OstreeRepoFinderAvahi implementation, ostree_avahi_service_build_repo_finder_result() is where the DNS-SD records are processed and turned into OstreeRepoFinderResult objects. Each result object is supposed to have a hash table mapping refs to checksums, so this is accomplished by first adding a placeholder (a ref mapping to a NULL checksum) for each ref matched by the bloom filter, and later filling in the checksums using the remote's summary file, which happens in get_checksums(). The problem is that there's no guarantee all the checksums will be resolved (non-NULL), so the ostree_repo_finder_result_new() call then hits an assertion failure in is_valid_collection_ref_map() leading to a crash (in the case that one or more refs had NULL checksums). There are at least two situations where the ref checksum might not be found in the peer remote's summary file: 1) The bloom filter match was a false positive. This is going to happen sometimes by design. 2) The peer remote's summary is out of sync with its DNS-SD records. This shouldn't normally happen but it's still good to be robust to the possibility; in Endless OS nothing guarantees the atomicity of updating the summary and DNS-SD records. This commit changes libostree to be robust to the possibility of refs missing from the peer remote's summary, by removing any that still have a NULL checksum associated with them after the summary has been fetched and processed. The other OstreeRepoFinder implementations don't have this issue because they use summary files directly and therefore always have access to the checksum. Closes: #1717 Approved by: pwithnall
* avahi: Fail immediately if we can't talk to D-Bus or AvahiSimon McVittie2018-06-231-2/+1
| | | | | | | | | | | | | We special-case AVAHI_ERR_NO_DAEMON to not cause warnings, but if we pass AVAHI_CLIENT_NO_FAIL to avahi_client_new, we never actually see AVAHI_ERR_NO_DAEMON. Instead, we will get AVAHI_ERR_BAD_STATE when we try to use the client. Closes: #1618 Signed-off-by: Simon McVittie <smcv@debian.org> Closes: #1639 Approved by: cgwalters
* Fix building against old glib versionsMatthew Leeds2018-06-071-0/+1
| | | | | | | | | We need to include libglnx.h in places where ostree-autocleanups.h is included, so that we get backports of G_DEFINE_AUTOPTR_CLEANUP_FUNC and friends. Closes: #1615 Approved by: jlebon
* Make P2P API public (no longer experimental)Matthew Leeds2018-06-041-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the API that allows P2P operations (e.g. pulling an ostree ref from a LAN or USB source) is hidden behind the configure flag --enable-experimental-api. This commit makes the API public and makes that flag essentially a no-op (leaving it in place in case we want to use it again in the future). The P2P API has been tested over the last several months and proven to work. This means that since we're no longer using the "experimental" feature flag, P2P builds of Flatpak will fail when using versions of OSTree from this commit onwards, until Flatpak is patched in the near future. If you want to build Flatpak < 0.11.8 with P2P enabled and link against OSTree 2018.6, you'll have to patch Flatpak. However, since Flatpak won't yet have a hard dependency on OSTree 2018.6, it needs a new way to determine if the P2P API in OSTree is available, so this commit adds a "p2p" feature flag. This way the feature set is more semantically correct than if we had continued to use the "experimental" feature flag. In addition to making the P2P API public, this commit makes the P2P unit tests run by default, removes the f27-experimental CI instance that's no longer needed, changes a few man pages to reflect the changes, and updates the bash completion script to accept the new commands and options. Closes: #1596 Approved by: cgwalters
* Allow compiling OstreeRepoFinderAvahi without libsoupMatthew Leeds2018-05-301-1/+1
| | | | | Closes: #1605 Approved by: cgwalters
* avahi: Don't complain with g_warning if the daemon wasn't runningSam Spilsbury2018-04-181-3/+9
| | | | | | | | | | | | This is a normal case when running unit tests in client code on continuous integration infrastructure. When those tests are running they will set G_DEBUG=fatal-warnings which will cause the program to abort if a warning is emitted. Instead, emit a debug message if the problem was that we couldn't connect to the daemon. Closes: #1542 Approved by: jlebon
* lib/repo: Add timestamps to OstreeRepoFinderResultMatthew Leeds2018-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently OstreeRepoFinderResult, a data structure used by pull code that supports P2P operations, has a hash table mapping refs to checksums but doesn't include timestamp information. This means that clients have no way of knowing just from the OstreeRepoFinderResult information if a commit being offered by a peer remote is an update or downgrade until they start pulling it. The client could check the summary or the commit metadata for the timestamps, but this requires adding the temporary remotes to the repo config, and ostree is already checking timestamps before returning the results, so I think it makes more sense for them to be returned rather than leaving it to the client. This limitation is especially important for offline computers, because for online computers the latest commit available from any remote is the latest commit, period. This commit adds a "ref_to_timestamp" hash table to OstreeRepoFinderResult that is symmetric to "ref_to_checksum" in that it shares the same keys. This is an API break, but it's part of the experimental API, and none of the current users of that (flatpak, eos-updater, and gnome-software) are affected. See the documentation for more details on "ref_to_timestamp". One thing to note is the data structure currently gets initialized in find_remotes_cb(), so only users of ostree_repo_find_remotes_async() will get them, not users of, say, ostree_repo_finder_resolve_all_async(). This is because the individual OstreeRepoFinder implementations don't currently access the timestamps (but I think this could be changed in the future if there's a need). This commit will allow P2P support to be added to flatpak_installation_list_installed_refs_for_update, which will allow GNOME Software to update apps from USB drives while offline (it's already possible online). Closes: #1518 Approved by: cgwalters
* Add SPDX-License-Identifier to source filesMarcus Folkesson2018-01-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | SPDX License List is a list of (common) open source licenses that can be referred to by a “short identifier”. It has several advantages compared to the common "license header texts" usually found in source files. Some of the advantages: * It is precise; there is no ambiguity due to variations in license header text * It is language neutral * It is easy to machine process * It is concise * It is simple and can be used without much cost in interpreted environments like java Script, etc. * An SPDX license identifier is immutable. * It provides simple guidance for developers who want to make sure the license for their code is respected See http://spdx.org for further reading. Signed-off-by: Marcus Folkesson <marcus.folkesson@gmail.com> Closes: #1439 Approved by: cgwalters
* lib/repo-finder-avahi: Fix memory corruption of a GVariantIterPhilip Withnall2017-10-241-4/+6
| | | | | | | | | | | | | A GVariantIter* was being passed to a GVariant format string varargs, rather than a GVariantIter**. This resulted in memory corruption. So we can continue to reuse ref_map throughout the function, make it a GVariantIter* rather than a stack-allocated GVariantIter. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1301 Approved by: cgwalters
* lib/repo-finder-avahi: Fix a leak in a GVariantIter loopPhilip Withnall2017-10-191-1/+1
| | | | | | | | | | | Use g_variant_iter_loop() rather than next(), since it automatically handles freeing the child memory each iteration. Previously, we leaked it for all but the last iteration. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1293 Approved by: cgwalters
* lib/remote: Store name of remote providing keyring for dynamic remotesPhilip Withnall2017-09-271-1/+1
| | | | | | | | | | | | | | | | | | When pulling from a dynamic (peer to peer) remote, the remote’s name is set to a unique, generated string which doesn’t exist in repo/config. If doing a non-mirror pull, however, we don’t want to use this name in the refspecs for newly created or updated refs — we want to use the name of the remote which provided the keyring for the pull (this will be a remote from repo/config whose collection ID matches that being used for the peer to peer pull). Store both names in OstreeRemote. The name to use for refspecs is stored as refspec_name, and is typically NULL unless it differs from name. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1202 Approved by: cgwalters
* lib/repo: Change resolve_keyring_for_collection() to return a remotePhilip Withnall2017-09-271-16/+19
| | | | | | | | | | | | Instead of returning just the keyring filename, return the entire OstreeRemote, which has the keyring filename as one of its members. This will simplify some upcoming changes, and allows slightly improved debug logging. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1202 Approved by: cgwalters
* tree-wide: Remove Emacs modelinesColin Walters2017-09-211-2/+1
| | | | | | | | | We added a `.dir-locals.el` in commit: 9a77017d87b74c5e2895cdd64ad098018929403f There's no need to have it per-file, with that people might think to add other editors, which is the wrong direction. Closes: #1206 Approved by: jlebon
* lib/repo-finder: Emit gpg-verify-summary=false in dynamic remote configPhilip Withnall2017-08-081-1/+2
| | | | | | | | | | | | | | | | | | | When returning results from finding repos, set gpg-verify-summary=false in their configs, since any pulls from such remotes will necessarily involve collection IDs, and hence should be using the unsigned summary support. In the intended deployment mode for P2P transmission of OSTree refs, summaries *cannot* be signed, so setting gpg-verify-summary=true would cause all the pulls to fail. The unsigned summary support is the move of repository metadata from the summary file (not spliceable) to the well-known ostree-metadata ref (spliceable, as it can exist for multiple collection IDs in the same repository). Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1066 Approved by: cgwalters
* lib/repo: Fix handling of missing summary files when downloadingPhilip Withnall2017-08-081-1/+9
| | | | | | | | | | | | | | | | The API for downloading a summary file can legitimately return NULL for the summary file contents when it returns TRUE (success). This indicates an error 404 — the summary file was not found. Two call sites were not handling that correctly, which was causing later assertion failures. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1061 Closes: #1065 Approved by: cgwalters
* lib/repo-finder-avahi: Drop redundant conditionalPhilip Withnall2017-08-081-1/+1
| | | | | | | | | | | | summary_timestamp is checked for non-NULL-ness above, and the function bails if it’s NULL. Fixes Coverity issue #1452616. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #1059 Approved by: cgwalters
* lib/repo-finder: Add Avahi based OstreeRepoFinder implementationPhilip Withnall2017-06-261-0/+1506
This is a more complex implementation of OstreeRepoFinder which resolves ref names to remote URIs by looking for refs advertised by peers on the local network using DNS-SD records and mDNS (Avahi). The idea is to allow OS and app updates to be propagated over local networks, without the internet. It requires an OSTree server and code to generate the DNS-SD adverts in order to be fully functional — support for this will be added separately. Unit tests are included. Includes fixes by Krzesimir Nowak <krzesimir@kinvolk.io>. Signed-off-by: Philip Withnall <withnall@endlessm.com> Closes: #924 Approved by: cgwalters