"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "common/flatpak-dir.c" between
flatpak-1.15.1.tar.xz and flatpak-1.15.2.tar.xz

About: Flatpak is a Linux application sandboxing and distribution framework. Pre-release.

flatpak-dir.c  (flatpak-1.15.1.tar.xz):flatpak-dir.c  (flatpak-1.15.2.tar.xz)
skipping to change at line 434 skipping to change at line 434
FlatpakSideloadState *ss = g_new0 (FlatpakSideloadState, 1); FlatpakSideloadState *ss = g_new0 (FlatpakSideloadState, 1);
ss->repo = g_steal_pointer (&sideload_repo); ss->repo = g_steal_pointer (&sideload_repo);
ss->summary = g_variant_ref_sink (g_variant_new_from_bytes (OSTREE_SUMMARY _GVARIANT_FORMAT, summary_bytes, TRUE)); ss->summary = g_variant_ref_sink (g_variant_new_from_bytes (OSTREE_SUMMARY _GVARIANT_FORMAT, summary_bytes, TRUE));
if (!_validate_summary_for_collection_id (ss->summary, self->collection_id , &local_error)) if (!_validate_summary_for_collection_id (ss->summary, self->collection_id , &local_error))
{ {
/* We expect to hit this code path when the repo is providing things /* We expect to hit this code path when the repo is providing things
* from other remotes * from other remotes
*/ */
g_debug ("Sideload repo at path %s not valid for remote %s: %s", g_info ("Sideload repo at path %s not valid for remote %s: %s",
flatpak_file_get_path_cached (dir), self->remote_name, local_ flatpak_file_get_path_cached (dir), self->remote_name, local_e
error->message); rror->message);
flatpak_sideload_state_free (ss); flatpak_sideload_state_free (ss);
} }
else else
{ {
g_ptr_array_add (self->sideload_repos, ss); g_ptr_array_add (self->sideload_repos, ss);
g_debug ("Using sideloaded repo %s for remote %s", flatpak_file_get_pa th_cached (dir), self->remote_name); g_info ("Using sideloaded repo %s for remote %s", flatpak_file_get_pat h_cached (dir), self->remote_name);
} }
} }
} }
static void add_sideload_subdirs (GPtrArray *res, static void add_sideload_subdirs (GPtrArray *res,
GFile *parent, GFile *parent,
gboolean recurse); gboolean recurse);
static void static void
add_sideload_create_usb_subdirs (GPtrArray *res, add_sideload_create_usb_subdirs (GPtrArray *res,
skipping to change at line 809 skipping to change at line 809
} }
GPtrArray * GPtrArray *
flatpak_remote_state_match_subrefs (FlatpakRemoteState *self, flatpak_remote_state_match_subrefs (FlatpakRemoteState *self,
FlatpakDecomposed *ref) FlatpakDecomposed *ref)
{ {
GVariant *summary; GVariant *summary;
if (self->summary == NULL && self->index == NULL) if (self->summary == NULL && self->index == NULL)
{ {
g_debug ("flatpak_remote_state_match_subrefs with no summary"); g_info ("flatpak_remote_state_match_subrefs with no summary");
return g_ptr_array_new_with_free_func ((GDestroyNotify)flatpak_decomposed_ unref); return g_ptr_array_new_with_free_func ((GDestroyNotify)flatpak_decomposed_ unref);
} }
summary = get_summary_for_ref (self, flatpak_decomposed_get_ref (ref)); summary = get_summary_for_ref (self, flatpak_decomposed_get_ref (ref));
if (summary == NULL) if (summary == NULL)
return g_ptr_array_new_with_free_func ((GDestroyNotify)flatpak_decomposed_un ref); return g_ptr_array_new_with_free_func ((GDestroyNotify)flatpak_decomposed_un ref);
return flatpak_summary_match_subrefs (summary, NULL, ref); return flatpak_summary_match_subrefs (summary, NULL, ref);
} }
skipping to change at line 1638 skipping to change at line 1638
g_auto(GStrv) groups = NULL; g_auto(GStrv) groups = NULL;
g_autoptr(GError) my_error = NULL; g_autoptr(GError) my_error = NULL;
gboolean ret = FALSE; gboolean ret = FALSE;
gsize n_groups; gsize n_groups;
int i; int i;
keyfile = g_key_file_new (); keyfile = g_key_file_new ();
if (!g_key_file_load_from_file (keyfile, file_path, G_KEY_FILE_NONE, &my_error )) if (!g_key_file_load_from_file (keyfile, file_path, G_KEY_FILE_NONE, &my_error ))
{ {
g_debug ("Could not get list of system installations from '%s': %s", file_ path, my_error->message); g_info ("Could not get list of system installations from '%s': %s", file_p ath, my_error->message);
g_propagate_error (error, g_steal_pointer (&my_error)); g_propagate_error (error, g_steal_pointer (&my_error));
goto out; goto out;
} }
/* One configuration file might define more than one installation */ /* One configuration file might define more than one installation */
groups = g_key_file_get_groups (keyfile, &n_groups); groups = g_key_file_get_groups (keyfile, &n_groups);
for (i = 0; i < n_groups; i++) for (i = 0; i < n_groups; i++)
{ {
g_autofree char *id = NULL; g_autofree char *id = NULL;
g_autofree char *path = NULL; g_autofree char *path = NULL;
skipping to change at line 1684 skipping to change at line 1684
if (has_system_location (locations, id)) if (has_system_location (locations, id))
{ {
g_warning ("While reading '%s': Duplicate installation ID '%s'. Ignori ng", file_path, id); g_warning ("While reading '%s': Duplicate installation ID '%s'. Ignori ng", file_path, id);
continue; continue;
} }
path = g_key_file_get_string (keyfile, groups[i], "Path", &my_error); path = g_key_file_get_string (keyfile, groups[i], "Path", &my_error);
if (path == NULL) if (path == NULL)
{ {
g_debug ("While reading '%s': Unable to get path for installation '%s' : %s", file_path, id, my_error->message); g_info ("While reading '%s': Unable to get path for installation '%s': %s", file_path, id, my_error->message);
g_propagate_error (error, g_steal_pointer (&my_error)); g_propagate_error (error, g_steal_pointer (&my_error));
goto out; goto out;
} }
else else
{ {
GFile *location = NULL; GFile *location = NULL;
g_autofree char *display_name = NULL; g_autofree char *display_name = NULL;
g_autofree char *priority = NULL; g_autofree char *priority = NULL;
g_autofree char *storage_type = NULL; g_autofree char *storage_type = NULL;
gint priority_val = 0; gint priority_val = 0;
skipping to change at line 1752 skipping to change at line 1752
g_autoptr(GError) my_error = NULL; g_autoptr(GError) my_error = NULL;
g_autofree char *config_dir = NULL; g_autofree char *config_dir = NULL;
locations = g_ptr_array_new_with_free_func (g_object_unref); locations = g_ptr_array_new_with_free_func (g_object_unref);
config_dir = g_strdup_printf ("%s/%s", config_dir = g_strdup_printf ("%s/%s",
get_config_dir_location (), get_config_dir_location (),
SYSCONF_INSTALLATIONS_DIR); SYSCONF_INSTALLATIONS_DIR);
if (!g_file_test (config_dir, G_FILE_TEST_IS_DIR)) if (!g_file_test (config_dir, G_FILE_TEST_IS_DIR))
{ {
g_debug ("No installations directory in %s. Skipping", config_dir); g_info ("No installations directory in %s. Skipping", config_dir);
goto out; goto out;
} }
conf_dir = g_file_new_for_path (config_dir); conf_dir = g_file_new_for_path (config_dir);
dir_enum = g_file_enumerate_children (conf_dir, dir_enum = g_file_enumerate_children (conf_dir,
G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FIL E_ATTRIBUTE_STANDARD_TYPE, G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FIL E_ATTRIBUTE_STANDARD_TYPE,
G_FILE_QUERY_INFO_NONE, G_FILE_QUERY_INFO_NONE,
cancellable, &my_error); cancellable, &my_error);
if (my_error != NULL) if (my_error != NULL)
{ {
g_debug ("Unexpected error retrieving extra installations in %s: %s", g_info ("Unexpected error retrieving extra installations in %s: %s",
config_dir, my_error->message); config_dir, my_error->message);
g_propagate_error (error, g_steal_pointer (&my_error)); g_propagate_error (error, g_steal_pointer (&my_error));
goto out; goto out;
} }
while (TRUE) while (TRUE)
{ {
GFileInfo *file_info; GFileInfo *file_info;
GFile *path; GFile *path;
const char *name; const char *name;
guint32 type; guint32 type;
if (!g_file_enumerator_iterate (dir_enum, &file_info, &path, if (!g_file_enumerator_iterate (dir_enum, &file_info, &path,
cancellable, &my_error)) cancellable, &my_error))
{ {
g_debug ("Unexpected error reading file in %s: %s", g_info ("Unexpected error reading file in %s: %s",
config_dir, my_error->message); config_dir, my_error->message);
g_propagate_error (error, g_steal_pointer (&my_error)); g_propagate_error (error, g_steal_pointer (&my_error));
goto out; goto out;
} }
if (file_info == NULL) if (file_info == NULL)
break; break;
name = g_file_info_get_attribute_byte_string (file_info, "standard::name") ; name = g_file_info_get_attribute_byte_string (file_info, "standard::name") ;
type = g_file_info_get_attribute_uint32 (file_info, "standard::type"); type = g_file_info_get_attribute_uint32 (file_info, "standard::type");
skipping to change at line 2167 skipping to change at line 2167
g_once_init_leave (&self->system_helper_bus, system_helper_bus ? system_he lper_bus : (gpointer) 1 ); g_once_init_leave (&self->system_helper_bus, system_helper_bus ? system_he lper_bus : (gpointer) 1 );
} }
if (self->system_helper_bus == (gpointer) 1) if (self->system_helper_bus == (gpointer) 1)
{ {
flatpak_fail (error, _("Unable to connect to system bus")); flatpak_fail (error, _("Unable to connect to system bus"));
return NULL; return NULL;
} }
g_debug ("Calling system helper: %s", method_name); g_info ("Calling system helper: %s", method_name);
res = g_dbus_connection_call_with_unix_fd_list_sync (self->system_helper_bus, res = g_dbus_connection_call_with_unix_fd_list_sync (self->system_helper_bus,
FLATPAK_SYSTEM_HELPER_BUS _NAME, FLATPAK_SYSTEM_HELPER_BUS _NAME,
FLATPAK_SYSTEM_HELPER_PAT H, FLATPAK_SYSTEM_HELPER_PAT H,
FLATPAK_SYSTEM_HELPER_INT ERFACE, FLATPAK_SYSTEM_HELPER_INT ERFACE,
method_name, method_name,
parameters, parameters,
reply_type, reply_type,
G_DBUS_CALL_FLAGS_NONE, G _MAXINT, G_DBUS_CALL_FLAGS_NONE, G _MAXINT,
NULL, out_fd_list, NULL, out_fd_list,
cancellable, cancellable,
skipping to change at line 2472 skipping to change at line 2472
flatpak_dir_system_helper_call_cancel_pull (FlatpakDir *self, flatpak_dir_system_helper_call_cancel_pull (FlatpakDir *self,
guint arg_flags, guint arg_flags,
const gchar *arg_installation, const gchar *arg_installation,
const gchar *arg_src_dir, const gchar *arg_src_dir,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
if (flatpak_dir_get_no_interaction (self)) if (flatpak_dir_get_no_interaction (self))
arg_flags |= FLATPAK_HELPER_CANCEL_PULL_FLAGS_NO_INTERACTION; arg_flags |= FLATPAK_HELPER_CANCEL_PULL_FLAGS_NO_INTERACTION;
g_debug ("Calling system helper: CancelPull"); g_info ("Calling system helper: CancelPull");
g_autoptr(GVariant) ret = g_autoptr(GVariant) ret =
flatpak_dir_system_helper_call (self, "CancelPull", flatpak_dir_system_helper_call (self, "CancelPull",
g_variant_new ("(uss)", g_variant_new ("(uss)",
arg_flags, arg_flags,
arg_installation, arg_installation,
arg_src_dir), arg_src_dir),
NULL, NULL, NULL, NULL,
cancellable, error); cancellable, error);
skipping to change at line 2502 skipping to change at line 2502
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
g_autoptr(GUnixFDList) out_fd_list = NULL; g_autoptr(GUnixFDList) out_fd_list = NULL;
gint fd = -1; gint fd = -1;
gint fd_index = -1; gint fd_index = -1;
if (flatpak_dir_get_no_interaction (self)) if (flatpak_dir_get_no_interaction (self))
arg_flags |= FLATPAK_HELPER_GET_REVOKEFS_FD_FLAGS_NO_INTERACTION; arg_flags |= FLATPAK_HELPER_GET_REVOKEFS_FD_FLAGS_NO_INTERACTION;
g_debug ("Calling system helper: GetRevokefsFd"); g_info ("Calling system helper: GetRevokefsFd");
g_autoptr(GVariant) ret = g_autoptr(GVariant) ret =
flatpak_dir_system_helper_call (self, "GetRevokefsFd", flatpak_dir_system_helper_call (self, "GetRevokefsFd",
g_variant_new ("(us)", g_variant_new ("(us)",
arg_flags, arg_flags,
arg_installation), arg_installation),
G_VARIANT_TYPE ("(hs)"), G_VARIANT_TYPE ("(hs)"),
&out_fd_list, &out_fd_list,
cancellable, error); cancellable, error);
skipping to change at line 3778 skipping to change at line 3778
if (!ostree_repo_remote_get_gpg_verify (self->repo, remote, &gpg_verify, N ULL)) if (!ostree_repo_remote_get_gpg_verify (self->repo, remote, &gpg_verify, N ULL))
continue; continue;
if (gpg_verify && !gpg_verify_summary) if (gpg_verify && !gpg_verify_summary)
{ {
g_autofree char *group = g_strdup_printf ("remote \"%s\"", remote); g_autofree char *group = g_strdup_printf ("remote \"%s\"", remote);
if (config == NULL) if (config == NULL)
config = ostree_repo_copy_config (flatpak_dir_get_repo (self)); config = ostree_repo_copy_config (flatpak_dir_get_repo (self));
g_debug ("Migrating remote '%s' to gpg-verify-summary", remote); g_info ("Migrating remote '%s' to gpg-verify-summary", remote);
g_key_file_set_boolean (config, group, "gpg-verify-summary", TRUE); g_key_file_set_boolean (config, group, "gpg-verify-summary", TRUE);
} }
} }
if (config != NULL) if (config != NULL)
{ {
if (flatpak_dir_use_system_helper (self, NULL)) if (flatpak_dir_use_system_helper (self, NULL))
{ {
g_autoptr(GError) local_error = NULL; g_autoptr(GError) local_error = NULL;
const char *installation = flatpak_dir_get_id (self); const char *installation = flatpak_dir_get_id (self);
if (!flatpak_dir_system_helper_call_ensure_repo (self, if (!flatpak_dir_system_helper_call_ensure_repo (self,
FLATPAK_HELPER_ENSURE _REPO_FLAGS_NONE, FLATPAK_HELPER_ENSURE _REPO_FLAGS_NONE,
installation ? instal lation : "", installation ? instal lation : "",
NULL, &local_error)) NULL, &local_error))
g_debug ("Failed to migrate system config: %s", local_error->message ); g_info ("Failed to migrate system config: %s", local_error->message) ;
} }
else else
{ {
if (!ostree_repo_write_config (self->repo, config, error)) if (!ostree_repo_write_config (self->repo, config, error))
return FALSE; return FALSE;
} }
if (changed != NULL) if (changed != NULL)
*changed = TRUE; *changed = TRUE;
} }
skipping to change at line 3904 skipping to change at line 3904
while (TRUE) while (TRUE)
{ {
GFileInfo *file_info; GFileInfo *file_info;
GFile *path; GFile *path;
const char *name; const char *name;
guint32 type; guint32 type;
if (!g_file_enumerator_iterate (dir_enum, &file_info, &path, if (!g_file_enumerator_iterate (dir_enum, &file_info, &path,
NULL, &my_error)) NULL, &my_error))
{ {
g_debug ("Unexpected error reading file in %s: %s", g_info ("Unexpected error reading file in %s: %s",
config_dir, my_error->message); config_dir, my_error->message);
break; break;
} }
if (file_info == NULL) if (file_info == NULL)
break; break;
name = g_file_info_get_name (file_info); name = g_file_info_get_name (file_info);
type = g_file_info_get_file_type (file_info); type = g_file_info_get_file_type (file_info);
if (type == G_FILE_TYPE_REGULAR && g_str_has_suffix (name, SYSCONF_REMOTES _FILE_EXT)) if (type == G_FILE_TYPE_REGULAR && g_str_has_suffix (name, SYSCONF_REMOTES _FILE_EXT))
skipping to change at line 3993 skipping to change at line 3993
if (gpg_data != NULL) if (gpg_data != NULL)
{ {
g_autoptr(GInputStream) input_stream = g_memory_input_stream_new_from_byte s (gpg_data); g_autoptr(GInputStream) input_stream = g_memory_input_stream_new_from_byte s (gpg_data);
guint imported = 0; guint imported = 0;
if (!ostree_repo_remote_gpg_import (repo, remote_name, input_stream, if (!ostree_repo_remote_gpg_import (repo, remote_name, input_stream,
NULL, &imported, NULL, error)) NULL, &imported, NULL, error))
return FALSE; return FALSE;
g_debug ("Imported %u GPG key%s to remote \"%s\"", imported, (imported == 1) ? "" : "s", remote_name); g_info ("Imported %u GPG key%s to remote \"%s\"", imported, (imported == 1 ) ? "" : "s", remote_name);
} }
return TRUE; return TRUE;
} }
static gboolean static gboolean
system_helper_maybe_ensure_repo (FlatpakDir *self, system_helper_maybe_ensure_repo (FlatpakDir *self,
FlatpakHelperEnsureRepoFlags flags, FlatpakHelperEnsureRepoFlags flags,
gboolean allow_empty, gboolean allow_empty,
GCancellable *cancellable, GCancellable *cancellable,
skipping to change at line 4545 skipping to change at line 4545
if (!glnx_fstatat (dir_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, NULL)) if (!glnx_fstatat (dir_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, NULL))
continue; continue;
if (stbuf.st_mtime >= now || if (stbuf.st_mtime >= now ||
now - stbuf.st_mtime < SECS_PER_DAY) now - stbuf.st_mtime < SECS_PER_DAY)
continue; continue;
tmp = g_file_get_child (dir, dent->d_name); tmp = g_file_get_child (dir, dent->d_name);
/* We ignore errors here, no need to worry anyone */ /* We ignore errors here, no need to worry anyone */
g_debug ("Deleting stale appstream deploy tmpdir %s", flatpak_file_get_pat h_cached (tmp)); g_info ("Deleting stale appstream deploy tmpdir %s", flatpak_file_get_path _cached (tmp));
(void)flatpak_rm_rf (tmp, NULL, NULL); (void)flatpak_rm_rf (tmp, NULL, NULL);
} }
} }
/* Like the function above, this looks for old temporary directories created by /* Like the function above, this looks for old temporary directories created by
* previous versions of flatpak_dir_deploy(). * previous versions of flatpak_dir_deploy().
* These are all directories starting with a dot. Such directories can be from a * These are all directories starting with a dot. Such directories can be from a
* concurrent deploy, so we only remove directories older than a day to avoid * concurrent deploy, so we only remove directories older than a day to avoid
* races. * races.
*/ */
skipping to change at line 4605 skipping to change at line 4605
if (!glnx_fstatat (dir_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, NULL)) if (!glnx_fstatat (dir_iter.fd, dent->d_name, &stbuf, AT_SYMLINK_NOFOLLOW, NULL))
continue; continue;
if (stbuf.st_mtime >= now || if (stbuf.st_mtime >= now ||
now - stbuf.st_mtime < SECS_PER_DAY) now - stbuf.st_mtime < SECS_PER_DAY)
continue; continue;
tmp = g_file_get_child (dir, dent->d_name); tmp = g_file_get_child (dir, dent->d_name);
/* We ignore errors here, no need to worry anyone */ /* We ignore errors here, no need to worry anyone */
g_debug ("Deleting stale deploy tmpdir %s", flatpak_file_get_path_cached ( tmp)); g_info ("Deleting stale deploy tmpdir %s", flatpak_file_get_path_cached (t mp));
(void)flatpak_rm_rf (tmp, NULL, NULL); (void)flatpak_rm_rf (tmp, NULL, NULL);
} }
} }
gboolean gboolean
flatpak_dir_deploy_appstream (FlatpakDir *self, flatpak_dir_deploy_appstream (FlatpakDir *self,
const char *remote, const char *remote,
const char *arch, const char *arch,
gboolean *out_changed, gboolean *out_changed,
GCancellable *cancellable, GCancellable *cancellable,
skipping to change at line 5451 skipping to change at line 5451
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
get_common_pull_options (&builder, state, ref_to_fetch, token, dirs_to_pull, c urrent_checksum, get_common_pull_options (&builder, state, ref_to_fetch, token, dirs_to_pull, c urrent_checksum,
force_disable_deltas, flags, progress); force_disable_deltas, flags, progress);
if (sideload_repo) if (sideload_repo)
{ {
GVariantBuilder colref_builder; GVariantBuilder colref_builder;
sideload_url = g_file_get_uri (sideload_repo); sideload_url = g_file_get_uri (sideload_repo);
g_debug ("Sideloading %s from %s in pull", ref_to_fetch, sideload_url); g_info ("Sideloading %s from %s in pull", ref_to_fetch, sideload_url);
g_assert (state->collection_id != NULL); g_assert (state->collection_id != NULL);
g_variant_builder_init (&colref_builder, G_VARIANT_TYPE ("a(sss)")); g_variant_builder_init (&colref_builder, G_VARIANT_TYPE ("a(sss)"));
g_variant_builder_add (&colref_builder, "(sss)", state->collection_id, ref _to_fetch, rev_to_fetch); g_variant_builder_add (&colref_builder, "(sss)", state->collection_id, ref _to_fetch, rev_to_fetch);
g_variant_builder_add (&builder, "{s@v}", "collection-refs", g_variant_builder_add (&builder, "{s@v}", "collection-refs",
g_variant_new_variant (g_variant_builder_end (&colr ef_builder))); g_variant_new_variant (g_variant_builder_end (&colr ef_builder)));
g_variant_builder_add (&builder, "{s@v}", "override-remote-name", g_variant_builder_add (&builder, "{s@v}", "override-remote-name",
g_variant_new_variant (g_variant_new_string (state- >remote_name))); g_variant_new_variant (g_variant_new_string (state- >remote_name)));
skipping to change at line 5721 skipping to change at line 5721
{ {
flatpak_progress_reset_extra_data (progress); flatpak_progress_reset_extra_data (progress);
return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Unsup ported extra data uri %s"), extra_data_uri); return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Unsup ported extra data uri %s"), extra_data_uri);
} }
/* TODO: Download to disk to support resumed downloads on error */ /* TODO: Download to disk to support resumed downloads on error */
extra_local_file = flatpak_build_file (base_dir, "extra-data", extra_data_ sha256, extra_data_name, NULL); extra_local_file = flatpak_build_file (base_dir, "extra-data", extra_data_ sha256, extra_data_name, NULL);
if (g_file_query_exists (extra_local_file, cancellable)) if (g_file_query_exists (extra_local_file, cancellable))
{ {
g_debug ("Loading extra-data from local file %s", flatpak_file_get_pat h_cached (extra_local_file)); g_info ("Loading extra-data from local file %s", flatpak_file_get_path _cached (extra_local_file));
gsize extra_local_size; gsize extra_local_size;
g_autofree char *extra_local_contents = NULL; g_autofree char *extra_local_contents = NULL;
g_autoptr(GError) my_error = NULL; g_autoptr(GError) my_error = NULL;
if (!g_file_load_contents (extra_local_file, cancellable, &extra_local _contents, &extra_local_size, NULL, &my_error)) if (!g_file_load_contents (extra_local_file, cancellable, &extra_local _contents, &extra_local_size, NULL, &my_error))
return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Fai led to load local extra-data %s: %s"), return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Fai led to load local extra-data %s: %s"),
flatpak_file_get_path_cached (extra_local _file), my_error->message); flatpak_file_get_path_cached (extra_local _file), my_error->message);
if (extra_local_size != download_size) if (extra_local_size != download_size)
return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Wro ng size for extra-data %s"), flatpak_file_get_path_cached (extra_local_file)); return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Wro ng size for extra-data %s"), flatpak_file_get_path_cached (extra_local_file));
skipping to change at line 5872 skipping to change at line 5872
delta_url = var_metadata_lookup_string (metadata, "xa.delta-url", NULL); delta_url = var_metadata_lookup_string (metadata, "xa.delta-url", NULL);
oci_digest = g_strconcat ("sha256:", rev, NULL); oci_digest = g_strconcat ("sha256:", rev, NULL);
registry = flatpak_remote_state_new_oci_registry (state, token, cancellable, e rror); registry = flatpak_remote_state_new_oci_registry (state, token, cancellable, e rror);
if (registry == NULL) if (registry == NULL)
return FALSE; return FALSE;
flatpak_progress_start_oci_pull (progress); flatpak_progress_start_oci_pull (progress);
g_debug ("Mirroring OCI image %s", oci_digest); g_info ("Mirroring OCI image %s", oci_digest);
res = flatpak_mirror_image_from_oci (dst_registry, registry, oci_repository, o ci_digest, state->remote_name, ref, delta_url, self->repo, oci_pull_progress_cb, res = flatpak_mirror_image_from_oci (dst_registry, registry, oci_repository, o ci_digest, state->remote_name, ref, delta_url, self->repo, oci_pull_progress_cb,
progress, cancellable, error); progress, cancellable, error);
if (!res) if (!res)
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
skipping to change at line 5953 skipping to change at line 5953
(const char **)FLATPAK_ OCI_MANIFEST (versioned)->config.urls, (const char **)FLATPAK_ OCI_MANIFEST (versioned)->config.urls,
NULL, cancellable, erro r); NULL, cancellable, erro r);
if (image_config == NULL) if (image_config == NULL)
return FALSE; return FALSE;
if (repo == NULL) if (repo == NULL)
repo = self->repo; repo = self->repo;
flatpak_progress_start_oci_pull (progress); flatpak_progress_start_oci_pull (progress);
g_debug ("Pulling OCI image %s", oci_digest); g_info ("Pulling OCI image %s", oci_digest);
checksum = flatpak_pull_from_oci (repo, registry, oci_repository, oci_digest, delta_url, FLATPAK_OCI_MANIFEST (versioned), image_config, checksum = flatpak_pull_from_oci (repo, registry, oci_repository, oci_digest, delta_url, FLATPAK_OCI_MANIFEST (versioned), image_config,
state->remote_name, ref, flatpak_flags, oci_ pull_progress_cb, progress, cancellable, error); state->remote_name, ref, flatpak_flags, oci_ pull_progress_cb, progress, cancellable, error);
if (checksum == NULL) if (checksum == NULL)
return FALSE; return FALSE;
g_debug ("Imported OCI image as checksum %s", checksum); g_info ("Imported OCI image as checksum %s", checksum);
if (repo == self->repo) if (repo == self->repo)
name = flatpak_dir_get_name (self); name = flatpak_dir_get_name (self);
else else
{ {
GFile *file = ostree_repo_get_path (repo); GFile *file = ostree_repo_get_path (repo);
name = g_file_get_path (file); name = g_file_get_path (file);
} }
(flatpak_dir_log) (self, __FILE__, __LINE__, __FUNCTION__, name, (flatpak_dir_log) (self, __FILE__, __LINE__, __FUNCTION__, name,
skipping to change at line 6041 skipping to change at line 6041
if (opt_rev != NULL) if (opt_rev != NULL)
{ {
rev = g_strdup (opt_rev); rev = g_strdup (opt_rev);
} }
else if (!flatpak_remote_state_lookup_ref (state, ref, &rev, NULL, NULL, NULL, error)) else if (!flatpak_remote_state_lookup_ref (state, ref, &rev, NULL, NULL, NULL, error))
{ {
g_assert (error == NULL || *error != NULL); g_assert (error == NULL || *error != NULL);
return FALSE; return FALSE;
} }
g_debug ("%s: Using commit %s for pull of ref %s from remote %s%s%s", g_info ("%s: Using commit %s for pull of ref %s from remote %s%s%s",
G_STRFUNC, rev, ref, state->remote_name, G_STRFUNC, rev, ref, state->remote_name,
sideload_repo ? "sideloaded from " : "", sideload_repo ? "sideloaded from " : "",
sideload_repo ? flatpak_file_get_path_cached (sideload_repo) : "" sideload_repo ? flatpak_file_get_path_cached (sideload_repo) : ""
); );
if (repo == NULL) if (repo == NULL)
repo = self->repo; repo = self->repo;
/* Past this we must use goto out, so we clean up console and /* Past this we must use goto out, so we clean up console and
abort the transaction on error */ abort the transaction on error */
if (subpaths != NULL && subpaths[0] != NULL) if (subpaths != NULL && subpaths[0] != NULL)
{ {
subdirs_arg = g_ptr_array_new_with_free_func (g_free); subdirs_arg = g_ptr_array_new_with_free_func (g_free);
skipping to change at line 7066 skipping to change at line 7066
error)) error))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
triggerspath = g_getenv ("FLATPAK_TRIGGERSDIR"); triggerspath = g_getenv ("FLATPAK_TRIGGERSDIR");
if (triggerspath == NULL) if (triggerspath == NULL)
triggerspath = FLATPAK_TRIGGERDIR; triggerspath = FLATPAK_TRIGGERDIR;
g_debug ("running triggers from %s", triggerspath); g_info ("running triggers from %s", triggerspath);
triggersdir = g_file_new_for_path (triggerspath); triggersdir = g_file_new_for_path (triggerspath);
dir_enum = g_file_enumerate_children (triggersdir, "standard::type,standard::n ame", dir_enum = g_file_enumerate_children (triggersdir, "standard::type,standard::n ame",
0, cancellable, error); 0, cancellable, error);
if (!dir_enum) if (!dir_enum)
goto out; goto out;
while ((child_info = g_file_enumerator_next_file (dir_enum, cancellable, &temp _error)) != NULL) while ((child_info = g_file_enumerator_next_file (dir_enum, cancellable, &temp _error)) != NULL)
{ {
skipping to change at line 7096 skipping to change at line 7096
g_str_has_suffix (name, ".trigger")) g_str_has_suffix (name, ".trigger"))
{ {
/* We need to canonicalize the basedir, because if has a symlink /* We need to canonicalize the basedir, because if has a symlink
somewhere the bind mount will be on the target of that, not somewhere the bind mount will be on the target of that, not
at that exact path. */ at that exact path. */
g_autofree char *basedir_orig = g_file_get_path (self->basedir); g_autofree char *basedir_orig = g_file_get_path (self->basedir);
g_autofree char *basedir = realpath (basedir_orig, NULL); g_autofree char *basedir = realpath (basedir_orig, NULL);
g_autoptr(FlatpakBwrap) bwrap = NULL; g_autoptr(FlatpakBwrap) bwrap = NULL;
g_autofree char *commandline = NULL; g_autofree char *commandline = NULL;
g_debug ("running trigger %s", name); g_info ("running trigger %s", name);
bwrap = flatpak_bwrap_new (NULL); bwrap = flatpak_bwrap_new (NULL);
#ifndef DISABLE_SANDBOXED_TRIGGERS #ifndef DISABLE_SANDBOXED_TRIGGERS
flatpak_bwrap_add_arg (bwrap, flatpak_get_bwrap ()); flatpak_bwrap_add_arg (bwrap, flatpak_get_bwrap ());
flatpak_bwrap_add_args (bwrap, flatpak_bwrap_add_args (bwrap,
"--unshare-ipc", "--unshare-ipc",
"--unshare-net", "--unshare-net",
"--unshare-pid", "--unshare-pid",
"--ro-bind", "/", "/", "--ro-bind", "/", "/",
skipping to change at line 7119 skipping to change at line 7119
"--bind", basedir, basedir, "--bind", basedir, basedir,
NULL); NULL);
#endif #endif
flatpak_bwrap_add_args (bwrap, flatpak_bwrap_add_args (bwrap,
flatpak_file_get_path_cached (child), flatpak_file_get_path_cached (child),
basedir, basedir,
NULL); NULL);
flatpak_bwrap_finish (bwrap); flatpak_bwrap_finish (bwrap);
commandline = flatpak_quote_argv ((const char **) bwrap->argv->pdata, -1); commandline = flatpak_quote_argv ((const char **) bwrap->argv->pdata, -1);
g_debug ("Running '%s'", commandline); g_info ("Running '%s'", commandline);
/* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak _close_fds_workaround */ /* We use LEAVE_DESCRIPTORS_OPEN to work around dead-lock, see flatpak _close_fds_workaround */
if (!g_spawn_sync ("/", if (!g_spawn_sync ("/",
(char **) bwrap->argv->pdata, (char **) bwrap->argv->pdata,
NULL, NULL,
G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPE N, G_SPAWN_SEARCH_PATH | G_SPAWN_LEAVE_DESCRIPTORS_OPE N,
flatpak_bwrap_child_setup_cb, bwrap->fds, flatpak_bwrap_child_setup_cb, bwrap->fds,
NULL, NULL, NULL, NULL,
NULL, &trigger_error)) NULL, &trigger_error))
{ {
skipping to change at line 8074 skipping to change at line 8074
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
n_extra_data_sources = g_variant_n_children (extra_data_sources); n_extra_data_sources = g_variant_n_children (extra_data_sources);
if (n_extra_data_sources == 0) if (n_extra_data_sources == 0)
return TRUE; return TRUE;
g_debug ("extracting extra data to %s", flatpak_file_get_path_cached (extradir )); g_info ("extracting extra data to %s", flatpak_file_get_path_cached (extradir) );
if (!ostree_repo_read_commit_detached_metadata (self->repo, checksum, &detache d_metadata, if (!ostree_repo_read_commit_detached_metadata (self->repo, checksum, &detache d_metadata,
cancellable, error)) cancellable, error))
{ {
g_prefix_error (error, _("While getting detached metadata: ")); g_prefix_error (error, _("While getting detached metadata: "));
return FALSE; return FALSE;
} }
if (detached_metadata == NULL) if (detached_metadata == NULL)
return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Extra data missing in detached metadata")); return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Extra data missing in detached metadata"));
skipping to change at line 8228 skipping to change at line 8228
g_autoptr(GFile) app_export_file = NULL; g_autoptr(GFile) app_export_file = NULL;
g_autoptr(GFile) extra_export_file = NULL; g_autoptr(GFile) extra_export_file = NULL;
g_autoptr(GFile) extra_files = NULL; g_autoptr(GFile) extra_files = NULL;
g_autoptr(GFile) runtime_files = NULL; g_autoptr(GFile) runtime_files = NULL;
g_autoptr(FlatpakContext) app_context = NULL; g_autoptr(FlatpakContext) app_context = NULL;
g_auto(GStrv) minimal_envp = NULL; g_auto(GStrv) minimal_envp = NULL;
g_autofree char *runtime_arch = NULL; g_autofree char *runtime_arch = NULL;
int exit_status; int exit_status;
const char *group = FLATPAK_METADATA_GROUP_APPLICATION; const char *group = FLATPAK_METADATA_GROUP_APPLICATION;
g_autoptr(GError) local_error = NULL; g_autoptr(GError) local_error = NULL;
FlatpakRunFlags run_flags;
apply_extra_file = g_file_resolve_relative_path (checkoutdir, "files/bin/apply _extra"); apply_extra_file = g_file_resolve_relative_path (checkoutdir, "files/bin/apply _extra");
if (!g_file_query_exists (apply_extra_file, cancellable)) if (!g_file_query_exists (apply_extra_file, cancellable))
return TRUE; return TRUE;
metadata = g_file_get_child (checkoutdir, "metadata"); metadata = g_file_get_child (checkoutdir, "metadata");
if (!g_file_load_contents (metadata, cancellable, &metadata_contents, &metadat a_size, NULL, error)) if (!g_file_load_contents (metadata, cancellable, &metadata_contents, &metadat a_size, NULL, error))
return FALSE; return FALSE;
skipping to change at line 8304 skipping to change at line 8305
NULL); NULL);
flatpak_bwrap_add_args (bwrap, flatpak_bwrap_add_args (bwrap,
"--ro-bind", flatpak_file_get_path_cached (app_files), "/app", "--ro-bind", flatpak_file_get_path_cached (app_files), "/app",
"--bind", flatpak_file_get_path_cached (extra_files), "/app/extra", "--bind", flatpak_file_get_path_cached (extra_files), "/app/extra",
"--chdir", "/app/extra", "--chdir", "/app/extra",
/* We run as root in the system-helper case, so drop a ll caps */ /* We run as root in the system-helper case, so drop a ll caps */
"--cap-drop", "ALL", "--cap-drop", "ALL",
NULL); NULL);
/* Might need multiarch in apply_extra (see e.g. #3742).
* Should be pretty safe in this limited context */
run_flags = (FLATPAK_RUN_FLAG_MULTIARCH |
FLATPAK_RUN_FLAG_NO_SESSION_HELPER |
FLATPAK_RUN_FLAG_NO_PROC |
FLATPAK_RUN_FLAG_NO_SESSION_BUS_PROXY |
FLATPAK_RUN_FLAG_NO_SYSTEM_BUS_PROXY |
FLATPAK_RUN_FLAG_NO_A11Y_BUS_PROXY);
if (!flatpak_run_setup_base_argv (bwrap, runtime_files, NULL, runtime_arch, if (!flatpak_run_setup_base_argv (bwrap, runtime_files, NULL, runtime_arch,
/* Might need multiarch in apply_extra (see run_flags, error))
e.g. #3742). Should be pretty safe in this limited context */
FLATPAK_RUN_FLAG_MULTIARCH |
FLATPAK_RUN_FLAG_NO_SESSION_HELPER | FLATPAK
_RUN_FLAG_NO_PROC,
error))
return FALSE; return FALSE;
app_context = flatpak_context_new (); app_context = flatpak_context_new ();
if (!flatpak_run_add_environment_args (bwrap, NULL, if (!flatpak_run_add_environment_args (bwrap, NULL, run_flags, id,
FLATPAK_RUN_FLAG_NO_SESSION_BUS_PROXY |
FLATPAK_RUN_FLAG_NO_SYSTEM_BUS_PROXY |
FLATPAK_RUN_FLAG_NO_A11Y_BUS_PROXY,
id,
app_context, NULL, NULL, -1, app_context, NULL, NULL, -1,
NULL, cancellable, error)) NULL, cancellable, error))
return FALSE; return FALSE;
flatpak_bwrap_populate_runtime_dir (bwrap, NULL); flatpak_bwrap_populate_runtime_dir (bwrap, NULL);
flatpak_bwrap_envp_to_args (bwrap); flatpak_bwrap_envp_to_args (bwrap);
flatpak_bwrap_add_arg (bwrap, "/app/bin/apply_extra"); flatpak_bwrap_add_arg (bwrap, "/app/bin/apply_extra");
flatpak_bwrap_finish (bwrap); flatpak_bwrap_finish (bwrap);
g_debug ("Running /app/bin/apply_extra "); g_info ("Running /app/bin/apply_extra ");
/* We run the sandbox without caps, but it can still create files owned by its elf with /* We run the sandbox without caps, but it can still create files owned by its elf with
* arbitrary permissions, including setuid myself. This is extra risky in the case where * arbitrary permissions, including setuid myself. This is extra risky in the case where
* this runs as root in the system helper case. We canonicalize the permission s at the * this runs as root in the system helper case. We canonicalize the permission s at the
* end, but to avoid non-canonical permissions leaking out before then we make the * end, but to avoid non-canonical permissions leaking out before then we make the
* toplevel dir only accessible to the user */ * toplevel dir only accessible to the user */
if (chmod (flatpak_file_get_path_cached (extra_files), 0700) != 0) if (chmod (flatpak_file_get_path_cached (extra_files), 0700) != 0)
{ {
glnx_set_error_from_errno (error); glnx_set_error_from_errno (error);
return FALSE; return FALSE;
skipping to change at line 8418 skipping to change at line 8421
PolkitCheckAuthorizationFlags polkit_flags; PolkitCheckAuthorizationFlags polkit_flags;
MctGetAppFilterFlags manager_flags; MctGetAppFilterFlags manager_flags;
/* Assume that root is allowed to install any ref and shouldn't have any /* Assume that root is allowed to install any ref and shouldn't have any
* parental controls restrictions applied to them. Note that this branch * parental controls restrictions applied to them. Note that this branch
* must not be taken if this code is running within the system-helper, as that * must not be taken if this code is running within the system-helper, as that
* runs as root but on behalf of another process. If running within the * runs as root but on behalf of another process. If running within the
* system-helper, self->source_pid is non-zero. */ * system-helper, self->source_pid is non-zero. */
if (self->source_pid == 0 && getuid () == 0) if (self->source_pid == 0 && getuid () == 0)
{ {
g_debug ("Skipping parental controls check for %s due to running as root", ref); g_info ("Skipping parental controls check for %s due to running as root", ref);
return TRUE; return TRUE;
} }
/* The ostree-metadata and appstream/ branches should not have any parental /* The ostree-metadata and appstream/ branches should not have any parental
* controls restrictions. Similarly, for the moment, there is no point in * controls restrictions. Similarly, for the moment, there is no point in
* restricting runtimes. */ * restricting runtimes. */
if (!g_str_has_prefix (ref, "app/")) if (!g_str_has_prefix (ref, "app/"))
return TRUE; return TRUE;
g_debug ("Getting parental controls details for %s from %s", g_info ("Getting parental controls details for %s from %s",
ref, flatpak_deploy_data_get_origin (deploy_data)); ref, flatpak_deploy_data_get_origin (deploy_data));
if (on_session != NULL) if (on_session != NULL)
{ {
/* FIXME: Instead of skipping the parental controls check in the test /* FIXME: Instead of skipping the parental controls check in the test
* environment, make a mock service for it. * environment, make a mock service for it.
* https://github.com/flatpak/flatpak/issues/2993 */ * https://github.com/flatpak/flatpak/issues/2993 */
g_debug ("Skipping parental controls check for %s since the " g_info ("Skipping parental controls check for %s since the "
"system bus is unavailable in the test environment", ref); "system bus is unavailable in the test environment", ref);
return TRUE; return TRUE;
} }
dbus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, cancellable, &local_error ); dbus_connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, cancellable, &local_error );
if (dbus_connection == NULL) if (dbus_connection == NULL)
{ {
g_propagate_error (error, g_steal_pointer (&local_error)); g_propagate_error (error, g_steal_pointer (&local_error));
return FALSE; return FALSE;
} }
skipping to change at line 8471 skipping to change at line 8474
manager = mct_manager_new (dbus_connection); manager = mct_manager_new (dbus_connection);
manager_flags = MCT_GET_APP_FILTER_FLAGS_NONE; manager_flags = MCT_GET_APP_FILTER_FLAGS_NONE;
if (!flatpak_dir_get_no_interaction (self)) if (!flatpak_dir_get_no_interaction (self))
manager_flags |= MCT_GET_APP_FILTER_FLAGS_INTERACTIVE; manager_flags |= MCT_GET_APP_FILTER_FLAGS_INTERACTIVE;
app_filter = mct_manager_get_app_filter (manager, subject_uid, app_filter = mct_manager_get_app_filter (manager, subject_uid,
manager_flags, manager_flags,
cancellable, &local_error); cancellable, &local_error);
if (g_error_matches (local_error, MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_D ISABLED)) if (g_error_matches (local_error, MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_D ISABLED))
{ {
g_debug ("Skipping parental controls check for %s since parental " g_info ("Skipping parental controls check for %s since parental "
"controls are disabled globally", ref); "controls are disabled globally", ref);
return TRUE; return TRUE;
} }
else if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKN OWN) || else if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKN OWN) ||
g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_ OWNER)) g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_NAME_HAS_NO_ OWNER))
{ {
g_debug ("Skipping parental controls check for %s since a required " g_info ("Skipping parental controls check for %s since a required "
"service was not found", ref); "service was not found", ref);
return TRUE; return TRUE;
} }
else if (local_error != NULL) else if (local_error != NULL)
{ {
g_propagate_error (error, g_steal_pointer (&local_error)); g_propagate_error (error, g_steal_pointer (&local_error));
return FALSE; return FALSE;
} }
/* Check the content rating against the parental controls. If the app is /* Check the content rating against the parental controls. If the app is
* allowed to be installed, return so immediately. */ * allowed to be installed, return so immediately. */
repo_installation_allowed = ((self->user && mct_app_filter_is_user_installatio n_allowed (app_filter)) || repo_installation_allowed = ((self->user && mct_app_filter_is_user_installatio n_allowed (app_filter)) ||
(!self->user && mct_app_filter_is_system_installa tion_allowed (app_filter))); (!self->user && mct_app_filter_is_system_installa tion_allowed (app_filter)));
content_rating_type = flatpak_deploy_data_get_appdata_content_rating_type (dep loy_data); content_rating_type = flatpak_deploy_data_get_appdata_content_rating_type (dep loy_data);
content_rating = flatpak_deploy_data_get_appdata_content_rating (deploy_data); content_rating = flatpak_deploy_data_get_appdata_content_rating (deploy_data);
app_is_appropriate = flatpak_oars_check_rating (content_rating, content_rating _type, app_is_appropriate = flatpak_oars_check_rating (content_rating, content_rating _type,
app_filter); app_filter);
if (repo_installation_allowed && app_is_appropriate) if (repo_installation_allowed && app_is_appropriate)
{ {
g_debug ("Parental controls policy satisfied for %s", ref); g_info ("Parental controls policy satisfied for %s", ref);
return TRUE; return TRUE;
} }
/* Otherwise, check polkit to see if the admin is going to allow the user to /* Otherwise, check polkit to see if the admin is going to allow the user to
* override their parental controls policy. We can’t pass any details to this * override their parental controls policy. We can’t pass any details to this
* polkit check, since it could be run by the user or by the system helper, * polkit check, since it could be run by the user or by the system helper,
* and non-root users can’t pass details to polkit checks. */ * and non-root users can’t pass details to polkit checks. */
authority = polkit_authority_get_sync (NULL, error); authority = polkit_authority_get_sync (NULL, error);
if (authority == NULL) if (authority == NULL)
return FALSE; return FALSE;
skipping to change at line 8531 skipping to change at line 8534
return FALSE; return FALSE;
authorized = polkit_authorization_result_get_is_authorized (result); authorized = polkit_authorization_result_get_is_authorized (result);
if (!authorized) if (!authorized)
return flatpak_fail_error (error, FLATPAK_ERROR_PERMISSION_DENIED, return flatpak_fail_error (error, FLATPAK_ERROR_PERMISSION_DENIED,
/* Translators: The placeholder is for an app ref . */ /* Translators: The placeholder is for an app ref . */
_("Installing %s is not allowed by the policy set by your administrator"), _("Installing %s is not allowed by the policy set by your administrator"),
ref); ref);
g_debug ("Parental controls policy overridden by polkit for %s", ref); g_info ("Parental controls policy overridden by polkit for %s", ref);
#endif /* USE_SYSTEM_HELPER */ #endif /* USE_SYSTEM_HELPER */
#endif /* HAVE_LIBMALCONTENT */ #endif /* HAVE_LIBMALCONTENT */
return TRUE; return TRUE;
} }
/* We create a deploy ref for the currently deployed version of all refs to avoi d /* We create a deploy ref for the currently deployed version of all refs to avoi d
deployed commits being pruned when e.g. we pull --no-deploy. */ deployed commits being pruned when e.g. we pull --no-deploy. */
static gboolean static gboolean
flatpak_dir_update_deploy_ref (FlatpakDir *self, flatpak_dir_update_deploy_ref (FlatpakDir *self,
skipping to change at line 8621 skipping to change at line 8624
return FALSE; return FALSE;
/* There used to be a bug here where temporary files beneath @deploy_base were not removed, /* There used to be a bug here where temporary files beneath @deploy_base were not removed,
* which could use quite a lot of space over time, so we check for these and r emove them. * which could use quite a lot of space over time, so we check for these and r emove them.
* We only do so for the current app to avoid every deploy operation iterating over * We only do so for the current app to avoid every deploy operation iterating over
* every app directory and all their immediate descendents. That would be a bi t much I/O. */ * every app directory and all their immediate descendents. That would be a bi t much I/O. */
remove_old_deploy_tmpdirs (deploy_base); remove_old_deploy_tmpdirs (deploy_base);
if (checksum_or_latest == NULL) if (checksum_or_latest == NULL)
{ {
g_debug ("No checksum specified, getting tip of %s from origin %s", flatpa k_decomposed_get_ref (ref), origin); g_info ("No checksum specified, getting tip of %s from origin %s", flatpak _decomposed_get_ref (ref), origin);
resolved_ref = flatpak_dir_read_latest (self, origin, flatpak_decomposed_g et_ref (ref), NULL, cancellable, error); resolved_ref = flatpak_dir_read_latest (self, origin, flatpak_decomposed_g et_ref (ref), NULL, cancellable, error);
if (resolved_ref == NULL) if (resolved_ref == NULL)
{ {
g_prefix_error (error, _("While trying to resolve ref %s: "), flatpak_ decomposed_get_ref (ref)); g_prefix_error (error, _("While trying to resolve ref %s: "), flatpak_ decomposed_get_ref (ref));
return FALSE; return FALSE;
} }
checksum = resolved_ref; checksum = resolved_ref;
g_debug ("tip resolved to: %s", checksum); g_info ("tip resolved to: %s", checksum);
} }
else else
{ {
checksum = checksum_or_latest; checksum = checksum_or_latest;
g_debug ("Looking for checksum %s in local repo", checksum); g_info ("Looking for checksum %s in local repo", checksum);
if (!ostree_repo_read_commit (self->repo, checksum, NULL, NULL, cancellabl e, NULL)) if (!ostree_repo_read_commit (self->repo, checksum, NULL, NULL, cancellabl e, NULL))
return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("%s is n ot available"), flatpak_decomposed_get_ref (ref)); return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("%s is n ot available"), flatpak_decomposed_get_ref (ref));
} }
if (!ostree_repo_load_commit (self->repo, checksum, &commit_data, NULL, error) ) if (!ostree_repo_load_commit (self->repo, checksum, &commit_data, NULL, error) )
return FALSE; return FALSE;
commit_metadata = g_variant_get_child_value (commit_data, 0); commit_metadata = g_variant_get_child_value (commit_data, 0);
checkout_basename = flatpak_dir_get_deploy_subdir (self, checksum, subpaths); checkout_basename = flatpak_dir_get_deploy_subdir (self, checksum, subpaths);
skipping to change at line 8721 skipping to change at line 8724
g_autofree char *subpath = g_build_filename ("files", subpaths[i], NUL L); g_autofree char *subpath = g_build_filename ("files", subpaths[i], NUL L);
g_autofree char *dstpath = g_build_filename (checkoutdirpath, "/files" , subpaths[i], NULL); g_autofree char *dstpath = g_build_filename (checkoutdirpath, "/files" , subpaths[i], NULL);
g_autofree char *dstpath_parent = g_path_get_dirname (dstpath); g_autofree char *dstpath_parent = g_path_get_dirname (dstpath);
g_autofree char *dstpath_relative_to_deploy_base = g_build_filename (c heckoutdir_basename, "/files", subpaths[i], NULL); g_autofree char *dstpath_relative_to_deploy_base = g_build_filename (c heckoutdir_basename, "/files", subpaths[i], NULL);
g_autoptr(GFile) child = NULL; g_autoptr(GFile) child = NULL;
child = g_file_resolve_relative_path (root, subpath); child = g_file_resolve_relative_path (root, subpath);
if (!g_file_query_exists (child, cancellable)) if (!g_file_query_exists (child, cancellable))
{ {
g_debug ("subpath %s not in tree", subpaths[i]); g_info ("subpath %s not in tree", subpaths[i]);
continue; continue;
} }
if (g_mkdir_with_parents (dstpath_parent, 0755)) if (g_mkdir_with_parents (dstpath_parent, 0755))
{ {
glnx_set_error_from_errno (error); glnx_set_error_from_errno (error);
return FALSE; return FALSE;
} }
options.subpath = subpath; options.subpath = subpath;
skipping to change at line 9047 skipping to change at line 9050
old_deploy = flatpak_load_deploy_data (old_deploy_dir, ref, self->repo , FLATPAK_DEPLOY_VERSION_ANY, cancellable, error); old_deploy = flatpak_load_deploy_data (old_deploy_dir, ref, self->repo , FLATPAK_DEPLOY_VERSION_ANY, cancellable, error);
if (old_deploy == NULL) if (old_deploy == NULL)
goto out; goto out;
/* If the old install was from a different remote, remove the ref */ /* If the old install was from a different remote, remove the ref */
old_origin = flatpak_deploy_data_get_origin (old_deploy); old_origin = flatpak_deploy_data_get_origin (old_deploy);
if (strcmp (old_origin, origin) != 0) if (strcmp (old_origin, origin) != 0)
remove_ref_from_remote = g_strdup (old_origin); remove_ref_from_remote = g_strdup (old_origin);
g_debug ("Removing old deployment for reinstall"); g_info ("Removing old deployment for reinstall");
if (!flatpak_dir_undeploy (self, ref, old_active, if (!flatpak_dir_undeploy (self, ref, old_active,
TRUE, FALSE, TRUE, FALSE,
cancellable, error)) cancellable, error))
goto out; goto out;
} }
else else
{ {
g_autofree char *id = flatpak_decomposed_dup_id (ref); g_autofree char *id = flatpak_decomposed_dup_id (ref);
g_autofree char *branch = flatpak_decomposed_dup_branch (ref); g_autofree char *branch = flatpak_decomposed_dup_branch (ref);
g_set_error (error, FLATPAK_ERROR, FLATPAK_ERROR_ALREADY_INSTALLED, g_set_error (error, FLATPAK_ERROR, FLATPAK_ERROR_ALREADY_INSTALLED,
skipping to change at line 9245 skipping to change at line 9248
old_key_file = g_key_file_new (); old_key_file = g_key_file_new ();
if (!g_key_file_load_from_file (old_key_file, desktop_path, if (!g_key_file_load_from_file (old_key_file, desktop_path,
G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRA NSLATIONS, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRA NSLATIONS,
&local_error)) &local_error))
{ {
g_warning ("Error encountered loading key file %s: %s", desktop_path, loca l_error->message); g_warning ("Error encountered loading key file %s: %s", desktop_path, loca l_error->message);
return; return;
} }
if (!g_key_file_has_key (old_key_file, G_KEY_FILE_DESKTOP_GROUP, "X-Flatpak", NULL)) if (!g_key_file_has_key (old_key_file, G_KEY_FILE_DESKTOP_GROUP, "X-Flatpak", NULL))
{ {
g_debug ("Ignoring non-Flatpak dynamic launcher: %s", desktop_path); g_info ("Ignoring non-Flatpak dynamic launcher: %s", desktop_path);
return; return;
} }
/* Fix paths in desktop file with a find-and-replace. The portal handled /* Fix paths in desktop file with a find-and-replace. The portal handled
* quoting the app ID in the Exec line for us. * quoting the app ID in the Exec line for us.
*/ */
old_data = g_key_file_to_data (old_key_file, NULL, NULL); old_data = g_key_file_to_data (old_key_file, NULL, NULL);
data_string = g_string_new ((const char *)old_data); data_string = g_string_new ((const char *)old_data);
g_string_replace (data_string, old_app_id, new_app_id, 0); g_string_replace (data_string, old_app_id, new_app_id, 0);
new_key_file = g_key_file_new (); new_key_file = g_key_file_new ();
skipping to change at line 9282 skipping to change at line 9285
desktop_path, new_desktop_path, local_error->message); desktop_path, new_desktop_path, local_error->message);
return; return;
} }
/* Fix symlink */ /* Fix symlink */
link_file = g_file_new_build_filename (g_get_user_data_dir (), "applications", desktop_name, NULL); link_file = g_file_new_build_filename (g_get_user_data_dir (), "applications", desktop_name, NULL);
relative_path = g_build_filename ("..", "xdg-desktop-portal", "applications", new_desktop, NULL); relative_path = g_build_filename ("..", "xdg-desktop-portal", "applications", new_desktop, NULL);
if (!g_file_delete (link_file, NULL, &local_error) && if (!g_file_delete (link_file, NULL, &local_error) &&
!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{ {
g_debug ("Unable to delete desktop file link %s: %s", desktop_name, local_ error->message); g_info ("Unable to delete desktop file link %s: %s", desktop_name, local_e rror->message);
g_clear_error (&local_error); g_clear_error (&local_error);
} }
new_link_file = g_file_new_build_filename (g_get_user_data_dir (), "applicatio ns", new_desktop, NULL); new_link_file = g_file_new_build_filename (g_get_user_data_dir (), "applicatio ns", new_desktop, NULL);
if (!g_file_make_symbolic_link (new_link_file, relative_path, NULL, &local_err or)) if (!g_file_make_symbolic_link (new_link_file, relative_path, NULL, &local_err or))
{ {
g_warning ("Unable to rename desktop file link %s -> %s: %s", g_warning ("Unable to rename desktop file link %s -> %s: %s",
desktop_name, new_desktop, local_error->message); desktop_name, new_desktop, local_error->message);
return; return;
} }
skipping to change at line 9630 skipping to change at line 9633
if (!flatpak_dir_system_helper_call_get_revokefs_fd (self, if (!flatpak_dir_system_helper_call_get_revokefs_fd (self,
FLATPAK_HELPER_GET_REVOKE FS_FD_FLAGS_NONE, FLATPAK_HELPER_GET_REVOKE FS_FD_FLAGS_NONE,
installation ? installati on : "", installation ? installati on : "",
&socket, &socket,
&src_dir_tmp, &src_dir_tmp,
cancellable, cancellable,
&local_error)) &local_error))
{ {
if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED )) if (g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED ))
g_debug ("revokefs-fuse not supported on your installation: %s", local_e rror->message); g_info ("revokefs-fuse not supported on your installation: %s", local_er ror->message);
else else
g_warning ("Failed to get revokefs-fuse socket from system-helper: %s", local_error->message); g_warning ("Failed to get revokefs-fuse socket from system-helper: %s", local_error->message);
goto out; goto out;
} }
else else
{ {
g_autoptr(GSubprocess) revokefs_fuse = NULL; g_autoptr(GSubprocess) revokefs_fuse = NULL;
g_autoptr(GSubprocessLauncher) launcher = NULL; g_autoptr(GSubprocessLauncher) launcher = NULL;
g_autofree gchar *client_uid = NULL; g_autofree gchar *client_uid = NULL;
skipping to change at line 10753 skipping to change at line 10756
g_string_append (joined, id); g_string_append (joined, id);
} }
return flatpak_fail_error (error, FLATPAK_ERROR_RUNTIME_USED, return flatpak_fail_error (error, FLATPAK_ERROR_RUNTIME_USED,
_("Can't remove %s, it is needed for: %s"), flatpak_decomposed_get_pref (ref), joined->str); _("Can't remove %s, it is needed for: %s"), flatpak_decomposed_get_pref (ref), joined->str);
} }
} }
old_active = g_strdup (flatpak_deploy_data_get_commit (deploy_data)); old_active = g_strdup (flatpak_deploy_data_get_commit (deploy_data));
g_debug ("dropping active ref"); g_info ("dropping active ref");
if (!flatpak_dir_set_active (self, ref, NULL, cancellable, error)) if (!flatpak_dir_set_active (self, ref, NULL, cancellable, error))
return FALSE; return FALSE;
if (flatpak_decomposed_is_app (ref)) if (flatpak_decomposed_is_app (ref))
{ {
current_ref = flatpak_dir_current_ref (self, name, cancellable); current_ref = flatpak_dir_current_ref (self, name, cancellable);
if (current_ref != NULL && if (current_ref != NULL &&
flatpak_decomposed_equal (ref, current_ref)) flatpak_decomposed_equal (ref, current_ref))
{ {
g_debug ("dropping current ref"); g_info ("dropping current ref");
if (!flatpak_dir_drop_current_ref (self, name, cancellable, error)) if (!flatpak_dir_drop_current_ref (self, name, cancellable, error))
return FALSE; return FALSE;
} }
} }
if (!flatpak_dir_update_deploy_ref (self, flatpak_decomposed_get_ref (ref), NU LL, error)) if (!flatpak_dir_update_deploy_ref (self, flatpak_decomposed_get_ref (ref), NU LL, error))
return FALSE; return FALSE;
if (!flatpak_dir_undeploy_all (self, ref, force_remove, &was_deployed, cancell able, error)) if (!flatpak_dir_undeploy_all (self, ref, force_remove, &was_deployed, cancell able, error))
return FALSE; return FALSE;
skipping to change at line 11179 skipping to change at line 11182
g_autoptr(GFile) top_dir = NULL; g_autoptr(GFile) top_dir = NULL;
GError *temp_error = NULL; GError *temp_error = NULL;
int i; int i;
gboolean was_deployed; gboolean was_deployed;
if (!flatpak_dir_list_deployed (self, ref, &deployed, cancellable, error)) if (!flatpak_dir_list_deployed (self, ref, &deployed, cancellable, error))
return FALSE; return FALSE;
for (i = 0; deployed[i] != NULL; i++) for (i = 0; deployed[i] != NULL; i++)
{ {
g_debug ("undeploying %s", deployed[i]); g_info ("undeploying %s", deployed[i]);
if (!flatpak_dir_undeploy (self, ref, deployed[i], FALSE, force_remove, ca ncellable, error)) if (!flatpak_dir_undeploy (self, ref, deployed[i], FALSE, force_remove, ca ncellable, error))
return FALSE; return FALSE;
} }
deploy_base = flatpak_dir_get_deploy_dir (self, ref); deploy_base = flatpak_dir_get_deploy_dir (self, ref);
was_deployed = g_file_query_exists (deploy_base, cancellable); was_deployed = g_file_query_exists (deploy_base, cancellable);
if (was_deployed) if (was_deployed)
{ {
g_debug ("removing deploy base"); g_info ("removing deploy base");
if (!flatpak_rm_rf (deploy_base, cancellable, error)) if (!flatpak_rm_rf (deploy_base, cancellable, error))
return FALSE; return FALSE;
} }
g_debug ("cleaning up empty directories"); g_info ("cleaning up empty directories");
arch_dir = g_file_get_parent (deploy_base); arch_dir = g_file_get_parent (deploy_base);
if (g_file_query_exists (arch_dir, cancellable) && if (g_file_query_exists (arch_dir, cancellable) &&
!g_file_delete (arch_dir, cancellable, &temp_error)) !g_file_delete (arch_dir, cancellable, &temp_error))
{ {
if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_EMPTY)) if (!g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_EMPTY))
{ {
g_propagate_error (error, temp_error); g_propagate_error (error, temp_error);
return FALSE; return FALSE;
} }
g_clear_error (&temp_error); g_clear_error (&temp_error);
skipping to change at line 11363 skipping to change at line 11366
if (!flatpak_dir_ensure_repo (self, cancellable, error)) if (!flatpak_dir_ensure_repo (self, cancellable, error))
goto out; goto out;
/* This could remove objects, so take an exclusive repo lock */ /* This could remove objects, so take an exclusive repo lock */
if (!flatpak_dir_repo_lock (self, &lock, LOCK_EX | LOCK_NB, cancellable, &lock _error)) if (!flatpak_dir_repo_lock (self, &lock, LOCK_EX | LOCK_NB, cancellable, &lock _error))
{ {
/* If we can't get an exclusive lock, don't block for a long time. Eventua lly /* If we can't get an exclusive lock, don't block for a long time. Eventua lly
the shared lock operation is released and we will do a prune then */ the shared lock operation is released and we will do a prune then */
if (g_error_matches (lock_error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK)) if (g_error_matches (lock_error, G_IO_ERROR, G_IO_ERROR_WOULD_BLOCK))
{ {
g_debug ("Skipping prune due to in progress operation"); g_info ("Skipping prune due to in progress operation");
return TRUE; return TRUE;
} }
g_propagate_error (error, g_steal_pointer (&lock_error)); g_propagate_error (error, g_steal_pointer (&lock_error));
return FALSE; return FALSE;
} }
g_debug ("Pruning repo"); g_info ("Pruning repo");
if (!ostree_repo_prune (self->repo, if (!ostree_repo_prune (self->repo,
OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY, OSTREE_REPO_PRUNE_FLAGS_REFS_ONLY,
0, 0,
&objects_total, &objects_total,
&objects_pruned, &objects_pruned,
&pruned_object_size_total, &pruned_object_size_total,
cancellable, error)) cancellable, error))
goto out; goto out;
formatted_freed_size = g_format_size_full (pruned_object_size_total, 0); formatted_freed_size = g_format_size_full (pruned_object_size_total, 0);
g_debug ("Pruned %d/%d objects, size %s", objects_total, objects_pruned, forma tted_freed_size); g_info ("Pruned %d/%d objects, size %s", objects_total, objects_pruned, format ted_freed_size);
ret = TRUE; ret = TRUE;
out: out:
/* There was an issue in ostree where for local pulls we don't get a .commitpa rtial (now fixed), /* There was an issue in ostree where for local pulls we don't get a .commitpa rtial (now fixed),
which caused errors when pruning. We print these here, but don't stop proce ssing. */ which caused errors when pruning. We print these here, but don't stop proce ssing. */
if (local_error != NULL) if (local_error != NULL)
g_print (_("Pruning repo failed: %s"), local_error->message); g_print (_("Pruning repo failed: %s"), local_error->message);
skipping to change at line 11422 skipping to change at line 11425
} }
if (!flatpak_dir_ensure_repo (self, cancellable, error)) if (!flatpak_dir_ensure_repo (self, cancellable, error))
return FALSE; return FALSE;
if (delete) if (delete)
{ {
g_autoptr(GError) local_error = NULL; g_autoptr(GError) local_error = NULL;
g_autoptr(GFile) summary_file = NULL; g_autoptr(GFile) summary_file = NULL;
g_debug ("Deleting summary"); g_info ("Deleting summary");
summary_file = g_file_get_child (ostree_repo_get_path (self->repo), "summa ry"); summary_file = g_file_get_child (ostree_repo_get_path (self->repo), "summa ry");
if (!g_file_delete (summary_file, cancellable, &local_error) && if (!g_file_delete (summary_file, cancellable, &local_error) &&
!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{ {
g_propagate_error (error, g_steal_pointer (&local_error)); g_propagate_error (error, g_steal_pointer (&local_error));
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
else else
{ {
g_auto(GLnxLockFile) lock = { 0, }; g_auto(GLnxLockFile) lock = { 0, };
g_debug ("Updating summary"); g_info ("Updating summary");
/* Keep a shared repo lock to avoid prunes removing objects we're relying on /* Keep a shared repo lock to avoid prunes removing objects we're relying on
* while generating the summary. */ * while generating the summary. */
if (!flatpak_dir_repo_lock (self, &lock, LOCK_SH, cancellable, error)) if (!flatpak_dir_repo_lock (self, &lock, LOCK_SH, cancellable, error))
return FALSE; return FALSE;
return ostree_repo_regenerate_summary (self->repo, NULL, cancellable, erro r); return ostree_repo_regenerate_summary (self->repo, NULL, cancellable, erro r);
} }
} }
skipping to change at line 11739 skipping to change at line 11742
if (self->summary_cache == NULL) if (self->summary_cache == NULL)
self->summary_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) cached_summary_free); self->summary_cache = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) cached_summary_free);
summary = g_hash_table_lookup (self->summary_cache, name); summary = g_hash_table_lookup (self->summary_cache, name);
if (summary) if (summary)
{ {
guint64 now = g_get_monotonic_time (); guint64 now = g_get_monotonic_time ();
if ((now - summary->time) / G_USEC_PER_SEC < SUMMARY_CACHE_TIMEOUT_SEC && if ((now - summary->time) / G_USEC_PER_SEC < SUMMARY_CACHE_TIMEOUT_SEC &&
strcmp (url, summary->url) == 0) strcmp (url, summary->url) == 0)
{ {
/* g_debug ("Using cached summary for remote %s", name); */ /* g_info ("Using cached summary for remote %s", name); */
*bytes_out = g_bytes_ref (summary->bytes); *bytes_out = g_bytes_ref (summary->bytes);
if (bytes_sig_out) if (bytes_sig_out)
{ {
if (summary->bytes_sig) if (summary->bytes_sig)
*bytes_sig_out = g_bytes_ref (summary->bytes_sig); *bytes_sig_out = g_bytes_ref (summary->bytes_sig);
else else
*bytes_sig_out = NULL; *bytes_sig_out = NULL;
} }
res = TRUE; res = TRUE;
skipping to change at line 12013 skipping to change at line 12016
return TRUE; return TRUE;
} }
static gboolean static gboolean
flatpak_dir_remote_clear_cached_summary (FlatpakDir *self, flatpak_dir_remote_clear_cached_summary (FlatpakDir *self,
const char *remote, const char *remote,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
g_debug ("Clearing cached summaries for remote %s", remote); g_info ("Clearing cached summaries for remote %s", remote);
if (!_flatpak_dir_remote_clear_cached_summary (self, remote, NULL, cancellable , error)) if (!_flatpak_dir_remote_clear_cached_summary (self, remote, NULL, cancellable , error))
return FALSE; return FALSE;
if (!_flatpak_dir_remote_clear_cached_summary (self, remote, ".sig", cancellab le, error)) if (!_flatpak_dir_remote_clear_cached_summary (self, remote, ".sig", cancellab le, error))
return FALSE; return FALSE;
if (!_flatpak_dir_remote_clear_cached_summary (self, remote, ".idx", cancellab le, error)) if (!_flatpak_dir_remote_clear_cached_summary (self, remote, ".idx", cancellab le, error))
return FALSE; return FALSE;
if (!_flatpak_dir_remote_clear_cached_summary (self, remote, ".idx.sig", cance llable, error)) if (!_flatpak_dir_remote_clear_cached_summary (self, remote, ".idx.sig", cance llable, error))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }
skipping to change at line 12120 skipping to change at line 12123
{ {
sha256 = g_compute_checksum_for_bytes (G_CHECKSUM_SHA256, mfile_bytes); sha256 = g_compute_checksum_for_bytes (G_CHECKSUM_SHA256, mfile_bytes);
if (strcmp (sha256, checksum) != 0) if (strcmp (sha256, checksum) != 0)
{ {
g_autoptr(GError) local_error = NULL; g_autoptr(GError) local_error = NULL;
if (!g_file_delete (main_cache_file, NULL, &local_error) && if (!g_file_delete (main_cache_file, NULL, &local_error) &&
!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{ {
g_autofree char *path = g_file_get_path (main_cache_file); g_autofree char *path = g_file_get_path (main_cache_file);
g_debug ("Unable to delete file %s: %s", path, local_error->messag e); g_info ("Unable to delete file %s: %s", path, local_error->message );
g_clear_error (&local_error); g_clear_error (&local_error);
} }
if (sig_ext) if (sig_ext)
{ {
if (!g_file_delete (sig_cache_file, NULL, &local_error) && if (!g_file_delete (sig_cache_file, NULL, &local_error) &&
!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUN D)) !g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUN D))
{ {
g_autofree char *path = g_file_get_path (sig_cache_file); g_autofree char *path = g_file_get_path (sig_cache_file);
g_debug ("Unable to delete file %s: %s", path, local_error->me ssage); g_info ("Unable to delete file %s: %s", path, local_error->mes sage);
g_clear_error (&local_error); g_clear_error (&local_error);
} }
} }
return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA,
_("Invalid checksum for indexed summary %s read from %s"), _("Invalid checksum for indexed summary %s read from %s"),
checksum, flatpak_file_get_path_cached (mai n_cache_file)); checksum, flatpak_file_get_path_cached (mai n_cache_file));
} }
} }
skipping to change at line 12195 skipping to change at line 12198
error)) error))
return FALSE; return FALSE;
} }
else else
{ {
if (only_cached) if (only_cached)
{ {
if (!flatpak_dir_remote_load_cached_summary (self, name_or_uri, NULL, NULL, ".sig", if (!flatpak_dir_remote_load_cached_summary (self, name_or_uri, NULL, NULL, ".sig",
&summary, &summary_sig, c ancellable, error)) &summary, &summary_sig, c ancellable, error))
return FALSE; return FALSE;
g_debug ("Loaded summary from cache for remote ‘%s’", name_or_uri); g_info ("Loaded summary from cache for remote ‘%s’", name_or_uri);
} }
else else
{ {
g_debug ("Fetching summary file for remote ‘%s’", name_or_uri); g_info ("Fetching summary file for remote ‘%s’", name_or_uri);
if (!ostree_repo_remote_fetch_summary (self->repo, name_or_uri, if (!ostree_repo_remote_fetch_summary (self->repo, name_or_uri,
&summary, &summary_sig, &summary, &summary_sig,
cancellable, cancellable,
error)) error))
return FALSE; return FALSE;
} }
} }
if (summary == NULL) if (summary == NULL)
return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Remote list ing for %s not available; server has no summary file. Check the URL passed to re mote-add was valid."), name_or_uri); return flatpak_fail_error (error, FLATPAK_ERROR_INVALID_DATA, _("Remote list ing for %s not available; server has no summary file. Check the URL passed to re mote-add was valid."), name_or_uri);
skipping to change at line 12359 skipping to change at line 12362
flatpak_dir_remote_load_cached_summary (self, name_or_uri, NULL, ".idx", ".idx .sig", flatpak_dir_remote_load_cached_summary (self, name_or_uri, NULL, ".idx", ".idx .sig",
&cached_index, &cached_index_sig, canc ellable, &cache_error); &cached_index, &cached_index_sig, canc ellable, &cache_error);
if (only_cached) if (only_cached)
{ {
if (cached_index == NULL) if (cached_index == NULL)
{ {
g_propagate_error (error, g_steal_pointer (&cache_error)); g_propagate_error (error, g_steal_pointer (&cache_error));
return FALSE; return FALSE;
} }
g_debug ("Loaded summary index from cache for remote ‘%s’", name_or_uri); g_info ("Loaded summary index from cache for remote ‘%s’", name_or_uri);
index = g_steal_pointer (&cached_index); index = g_steal_pointer (&cached_index);
if (gpg_verify_summary) if (gpg_verify_summary)
index_sig = g_steal_pointer (&cached_index_sig); index_sig = g_steal_pointer (&cached_index_sig);
} }
else else
{ {
g_autofree char *index_url = g_build_filename (url, "summary.idx", NULL); g_autofree char *index_url = g_build_filename (url, "summary.idx", NULL);
g_autoptr(GBytes) dl_index = NULL; g_autoptr(GBytes) dl_index = NULL;
gboolean used_download = FALSE; gboolean used_download = FALSE;
g_debug ("Fetching summary index file for remote ‘%s’", name_or_uri); g_info ("Fetching summary index file for remote ‘%s’", name_or_uri);
dl_index = flatpak_load_uri (self->http_session, index_url, 0, NULL, dl_index = flatpak_load_uri (self->http_session, index_url, 0, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
cancellable, error); cancellable, error);
if (dl_index == NULL) if (dl_index == NULL)
return FALSE; return FALSE;
/* If the downloaded index is the same as the cached one we need not re-do wnload or /* If the downloaded index is the same as the cached one we need not re-do wnload or
* re-verify, just use the cache (which we verified before) */ * re-verify, just use the cache (which we verified before) */
if (cached_index != NULL && g_bytes_equal (cached_index, dl_index)) if (cached_index != NULL && g_bytes_equal (cached_index, dl_index))
skipping to change at line 12542 skipping to change at line 12545
break; break;
} }
if (old_summary) if (old_summary)
{ {
g_autoptr(GError) delta_error = NULL; g_autoptr(GError) delta_error = NULL;
g_autofree char *delta_filename = g_strconcat (old_checksum, "-", chec ksum, ".delta", NULL); g_autofree char *delta_filename = g_strconcat (old_checksum, "-", chec ksum, ".delta", NULL);
g_autofree char *delta_url = g_build_filename (url, "summaries", delta _filename, NULL); g_autofree char *delta_url = g_build_filename (url, "summaries", delta _filename, NULL);
g_debug ("Fetching indexed summary delta %s for remote ‘%s’", delta_fi lename, name_or_uri); g_info ("Fetching indexed summary delta %s for remote ‘%s’", delta_fil ename, name_or_uri);
g_autoptr(GBytes) delta = flatpak_load_uri (self->http_session, delta_ url, 0, NULL, g_autoptr(GBytes) delta = flatpak_load_uri (self->http_session, delta_ url, 0, NULL,
NULL, NULL, NULL, NULL, NULL, NULL,
cancellable, &delta_error) ; cancellable, &delta_error) ;
if (delta == NULL) if (delta == NULL)
g_debug ("Failed to load delta, falling back: %s", delta_error->mess age); g_info ("Failed to load delta, falling back: %s", delta_error->messa ge);
else else
{ {
g_autoptr(GBytes) applied = flatpak_summary_apply_diff (old_summar y, delta, &delta_error); g_autoptr(GBytes) applied = flatpak_summary_apply_diff (old_summar y, delta, &delta_error);
if (applied == NULL) if (applied == NULL)
g_warning ("Failed to apply delta, falling back: %s", delta_erro r->message); g_warning ("Failed to apply delta, falling back: %s", delta_erro r->message);
else else
{ {
sha256 = g_compute_checksum_for_bytes (G_CHECKSUM_SHA256, appl ied); sha256 = g_compute_checksum_for_bytes (G_CHECKSUM_SHA256, appl ied);
if (strcmp (sha256, checksum) != 0) if (strcmp (sha256, checksum) != 0)
g_warning ("Applying delta gave wrong checksum, falling back "); g_warning ("Applying delta gave wrong checksum, falling back ");
else else
summary = g_steal_pointer (&applied); summary = g_steal_pointer (&applied);
} }
} }
} }
if (summary == NULL) if (summary == NULL)
{ {
g_autofree char *filename = g_strconcat (checksum, ".gz", NULL); g_autofree char *filename = g_strconcat (checksum, ".gz", NULL);
g_debug ("Fetching indexed summary file %s for remote ‘%s’", filename, name_or_uri); g_info ("Fetching indexed summary file %s for remote ‘%s’", filename, name_or_uri);
g_autofree char *subsummary_url = g_build_filename (url, "summaries", filename, NULL); g_autofree char *subsummary_url = g_build_filename (url, "summaries", filename, NULL);
summary_z = flatpak_load_uri (self->http_session, subsummary_url, 0, N ULL, summary_z = flatpak_load_uri (self->http_session, subsummary_url, 0, N ULL,
NULL, NULL, NULL, NULL, NULL, NULL,
cancellable, error); cancellable, error);
if (summary_z == NULL) if (summary_z == NULL)
return FALSE; return FALSE;
summary = flatpak_zlib_decompress_bytes (summary_z, error); summary = flatpak_zlib_decompress_bytes (summary_z, error);
if (summary == NULL) if (summary == NULL)
return FALSE; return FALSE;
skipping to change at line 12601 skipping to change at line 12604
summary, NULL, summary, NULL,
cancellable, error)) cancellable, error))
return FALSE; return FALSE;
if (!flatpak_dir_gc_cached_digested_summaries (self, name_or_uri, cach e_name, if (!flatpak_dir_gc_cached_digested_summaries (self, name_or_uri, cach e_name,
cancellable, error)) cancellable, error))
return FALSE; return FALSE;
} }
} }
else else
g_debug ("Loaded indexed summary file %s from cache for remote ‘%s’", checks um, name_or_uri); g_info ("Loaded indexed summary file %s from cache for remote ‘%s’", checksu m, name_or_uri);
/* Cache in memory */ /* Cache in memory */
if (!is_local && !only_cached) if (!is_local && !only_cached)
flatpak_dir_cache_summary (self, summary, NULL, checksum, url); flatpak_dir_cache_summary (self, summary, NULL, checksum, url);
*out_summary = g_steal_pointer (&summary); *out_summary = g_steal_pointer (&summary);
return TRUE; return TRUE;
} }
skipping to change at line 12737 skipping to change at line 12740
} }
else else
{ {
if (!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) & & if (!g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND) & &
!g_error_matches (local_error, FLATPAK_ERROR, FLATPAK_ERROR_NOT_CA CHED)) !g_error_matches (local_error, FLATPAK_ERROR, FLATPAK_ERROR_NOT_CA CHED))
{ {
/* We got an error other than not-found, assume we're indexed but there is some network error */ /* We got an error other than not-found, assume we're indexed but there is some network error */
got_summary = TRUE; got_summary = TRUE;
if (optional && !g_cancellable_is_cancelled (cancellable)) if (optional && !g_cancellable_is_cancelled (cancellable))
{ {
g_debug ("Failed to download optional summary index: %s", loca l_error->message); g_info ("Failed to download optional summary index: %s", local _error->message);
state->summary_fetch_error = g_steal_pointer (&local_error); state->summary_fetch_error = g_steal_pointer (&local_error);
} }
else else
{ {
g_propagate_error (error, g_steal_pointer (&local_error)); g_propagate_error (error, g_steal_pointer (&local_error));
return NULL; return NULL;
} }
} }
} }
} }
skipping to change at line 12763 skipping to change at line 12766
if (flatpak_dir_remote_fetch_summary (self, remote_or_uri, only_cached, &s ummary_bytes, &summary_sig_bytes, if (flatpak_dir_remote_fetch_summary (self, remote_or_uri, only_cached, &s ummary_bytes, &summary_sig_bytes,
cancellable, &local_error)) cancellable, &local_error))
{ {
got_summary = TRUE; got_summary = TRUE;
} }
else else
{ {
if (optional && !g_cancellable_is_cancelled (cancellable)) if (optional && !g_cancellable_is_cancelled (cancellable))
{ {
g_debug ("Failed to download optional summary: %s", local_error->m essage); g_info ("Failed to download optional summary: %s", local_error->me ssage);
state->summary_fetch_error = g_steal_pointer (&local_error); state->summary_fetch_error = g_steal_pointer (&local_error);
} }
else else
{ {
g_propagate_error (error, g_steal_pointer (&local_error)); g_propagate_error (error, g_steal_pointer (&local_error));
return NULL; return NULL;
} }
} }
} }
skipping to change at line 12828 skipping to change at line 12831
{ {
g_autofree char *subset = g_strndup (name, dash - name); g_autofree char *subset = g_strndup (name, dash - name);
if (strcmp (require_subset, subset) != 0) if (strcmp (require_subset, subset) != 0)
continue; continue;
} }
} }
var_subsummary_peek_checksum (subsummary, &checksum_bytes_len); var_subsummary_peek_checksum (subsummary, &checksum_bytes_len);
if (G_UNLIKELY (checksum_bytes_len != OSTREE_SHA256_DIGEST_LEN)) if (G_UNLIKELY (checksum_bytes_len != OSTREE_SHA256_DIGEST_LEN))
{ {
g_debug ("Invalid checksum for digested summary, not using cache") ; g_info ("Invalid checksum for digested summary, not using cache");
continue; continue;
} }
g_hash_table_insert (state->index_ht, g_strdup (subsummary_arch), var_ subsummary_to_owned_gvariant (subsummary, state->index)); g_hash_table_insert (state->index_ht, g_strdup (subsummary_arch), var_ subsummary_to_owned_gvariant (subsummary, state->index));
} }
/* Always load default (or specified) arch subsummary. Further arches can be manually loaded with flatpak_remote_state_ensure_subsummary. */ /* Always load default (or specified) arch subsummary. Further arches can be manually loaded with flatpak_remote_state_ensure_subsummary. */
if (opt_summary == NULL && if (opt_summary == NULL &&
!flatpak_remote_state_ensure_subsummary (state, self, arch, only_cache d, cancellable, error)) !flatpak_remote_state_ensure_subsummary (state, self, arch, only_cache d, cancellable, error))
return NULL; return NULL;
skipping to change at line 12977 skipping to change at line 12980
guint64 timestamp = get_timestamp_from_ref_info (info); guint64 timestamp = get_timestamp_from_ref_info (info);
gpointer value; gpointer value;
if (g_hash_table_lookup_extended (ref_timestamps, ref_name, NULL, &val ue)) if (g_hash_table_lookup_extended (ref_timestamps, ref_name, NULL, &val ue))
{ {
guint64 *old_timestamp = value; guint64 *old_timestamp = value;
if (*old_timestamp >= timestamp) if (*old_timestamp >= timestamp)
continue; /* New timestamp is older, skip this commit */ continue; /* New timestamp is older, skip this commit */
} }
new_timestamp = g_memdup (&timestamp, sizeof (guint64)); new_timestamp = g_memdup2 (&timestamp, sizeof (guint64));
} }
g_hash_table_replace (ret_all_refs, g_steal_pointer (&decomposed), ostree_ checksum_from_bytes (csum_bytes)); g_hash_table_replace (ret_all_refs, g_steal_pointer (&decomposed), ostree_ checksum_from_bytes (csum_bytes));
if (new_timestamp) if (new_timestamp)
g_hash_table_replace (ref_timestamps, g_strdup (ref_name), new_timestamp ); g_hash_table_replace (ref_timestamps, g_strdup (ref_name), new_timestamp );
} }
} }
/* This tries to list all available remote refs but also tries to keep /* This tries to list all available remote refs but also tries to keep
* working when offline, so it looks in sideloaded repos. Also it uses * working when offline, so it looks in sideloaded repos. Also it uses
skipping to change at line 14916 skipping to change at line 14919
if (gpg_data != NULL) if (gpg_data != NULL)
{ {
g_autoptr(GInputStream) input_stream = g_memory_input_stream_new_from_byte s (gpg_data); g_autoptr(GInputStream) input_stream = g_memory_input_stream_new_from_byte s (gpg_data);
guint imported = 0; guint imported = 0;
if (!ostree_repo_remote_gpg_import (self->repo, remote_name, input_stream, if (!ostree_repo_remote_gpg_import (self->repo, remote_name, input_stream,
NULL, &imported, cancellable, error)) NULL, &imported, cancellable, error))
return FALSE; return FALSE;
/* XXX If we ever add internationalization, use ngettext() here. */ /* XXX If we ever add internationalization, use ngettext() here. */
g_debug ("Imported %u GPG key%s to remote \"%s\"", g_info ("Imported %u GPG key%s to remote \"%s\"",
imported, (imported == 1) ? "" : "s", remote_name); imported, (imported == 1) ? "" : "s", remote_name);
} }
filter_path = g_key_file_get_value (new_config, group, "xa.filter", NULL); filter_path = g_key_file_get_value (new_config, group, "xa.filter", NULL);
if (filter_path && *filter_path && g_file_test (filter_path, G_FILE_TEST_EXIST S)) if (filter_path && *filter_path && g_file_test (filter_path, G_FILE_TEST_EXIST S))
{ {
/* Make a backup filter copy in case it goes away later */ /* Make a backup filter copy in case it goes away later */
g_autofree char *filter_name = g_strconcat (remote_name, ".filter", NULL); g_autofree char *filter_name = g_strconcat (remote_name, ".filter", NULL);
g_autoptr(GFile) filter_file = g_file_new_for_path (filter_path); g_autoptr(GFile) filter_file = g_file_new_for_path (filter_path);
g_autoptr(GFile) filter_copy = flatpak_build_file (self->basedir, "repo", filter_name, NULL); g_autoptr(GFile) filter_copy = flatpak_build_file (self->basedir, "repo", filter_name, NULL);
g_autoptr(GError) local_error = NULL; g_autoptr(GError) local_error = NULL;
g_autofree char *backup_data = NULL; g_autofree char *backup_data = NULL;
gsize backup_data_size; gsize backup_data_size;
if (g_file_load_contents (filter_file, cancellable, &backup_data, &backup_ data_size, NULL, &local_error)) if (g_file_load_contents (filter_file, cancellable, &backup_data, &backup_ data_size, NULL, &local_error))
{ {
g_autofree char *backup_data_copy = g_autofree char *backup_data_copy =
g_strdup_printf ("# backup copy of %s, do not edit!\n%s", filter_pat h, backup_data); g_strdup_printf ("# backup copy of %s, do not edit!\n%s", filter_pat h, backup_data);
if (!g_file_replace_contents (filter_copy, backup_data_copy, strlen (b ackup_data_copy), if (!g_file_replace_contents (filter_copy, backup_data_copy, strlen (b ackup_data_copy),
NULL, FALSE, G_FILE_CREATE_REPLACE_DESTI NATION, NULL, cancellable, &local_error)) NULL, FALSE, G_FILE_CREATE_REPLACE_DESTI NATION, NULL, cancellable, &local_error))
g_debug ("Failed to save backup copy of filter file %s: %s\n", filte r_path, local_error->message); g_info ("Failed to save backup copy of filter file %s: %s\n", filter _path, local_error->message);
} }
else else
{ {
g_debug ("Failed to read filter %s file while making a backup copy: %s \n", filter_path, local_error->message); g_info ("Failed to read filter %s file while making a backup copy: %s\ n", filter_path, local_error->message);
} }
} }
/* If we e.g. changed url or gpg config the cached summary may be invalid */ /* If we e.g. changed url or gpg config the cached summary may be invalid */
if (!flatpak_dir_remote_clear_cached_summary (self, remote_name, cancellable, error)) if (!flatpak_dir_remote_clear_cached_summary (self, remote_name, cancellable, error))
return FALSE; return FALSE;
if (!flatpak_dir_mark_changed (self, error)) if (!flatpak_dir_mark_changed (self, error))
return FALSE; return FALSE;
skipping to change at line 15265 skipping to change at line 15268
gboolean gpg_verify; gboolean gpg_verify;
if (!ostree_repo_remote_get_gpg_verify_summary (self->repo, remote, &gpg_v erify_summary, error)) if (!ostree_repo_remote_get_gpg_verify_summary (self->repo, remote, &gpg_v erify_summary, error))
return FALSE; return FALSE;
if (!ostree_repo_remote_get_gpg_verify (self->repo, remote, &gpg_verify, e rror)) if (!ostree_repo_remote_get_gpg_verify (self->repo, remote, &gpg_verify, e rror))
return FALSE; return FALSE;
if (!gpg_verify_summary || !gpg_verify) if (!gpg_verify_summary || !gpg_verify)
{ {
g_debug ("Ignoring automatic updates for system-helper remotes without gpg signatures"); g_info ("Ignoring automatic updates for system-helper remotes without gpg signatures");
return TRUE; return TRUE;
} }
if ((state->summary != NULL && state->summary_sig_bytes == NULL) || if ((state->summary != NULL && state->summary_sig_bytes == NULL) ||
(state->index != NULL && state->index_sig_bytes == NULL)) (state->index != NULL && state->index_sig_bytes == NULL))
{ {
g_debug ("Can't update remote configuration as user, no GPG signature" ); g_info ("Can't update remote configuration as user, no GPG signature") ;
return TRUE; return TRUE;
} }
if (!flatpak_dir_update_remote_configuration_for_state (self, state, TRUE, &has_changed, cancellable, error)) if (!flatpak_dir_update_remote_configuration_for_state (self, state, TRUE, &has_changed, cancellable, error))
return FALSE; return FALSE;
if (has_changed) if (has_changed)
{ {
g_autoptr(GBytes) bytes = g_variant_get_data_as_bytes (state->index ? state->index : state->summary); g_autoptr(GBytes) bytes = g_variant_get_data_as_bytes (state->index ? state->index : state->summary);
GBytes *sig_bytes = state->index ? state->index_sig_bytes : state->sum mary_sig_bytes; GBytes *sig_bytes = state->index ? state->index_sig_bytes : state->sum mary_sig_bytes;
skipping to change at line 15408 skipping to change at line 15411
deploy_data != NULL; deploy_data != NULL;
if (!flatpak_extension_matches_reason (id, autoprune_unless, TRUE)) if (!flatpak_extension_matches_reason (id, autoprune_unless, TRUE))
auto_prune = TRUE; auto_prune = TRUE;
/* Don't download if there is an unmaintained extension already installed */ /* Don't download if there is an unmaintained extension already installed */
unmaintained_path = unmaintained_path =
flatpak_find_unmaintained_extension_dir_if_exists (id, arch, branch, NULL); flatpak_find_unmaintained_extension_dir_if_exists (id, arch, branch, NULL);
if (unmaintained_path != NULL && deploy_data == NULL) if (unmaintained_path != NULL && deploy_data == NULL)
{ {
g_debug ("Skipping related extension ‘%s’ because it is already " g_info ("Skipping related extension ‘%s’ because it is already "
"installed as an unmaintained extension in ‘%s’.", "installed as an unmaintained extension in ‘%s’.",
id, flatpak_file_get_path_cached (unmaintained_path)); id, flatpak_file_get_path_cached (unmaintained_path));
download = FALSE; download = FALSE;
} }
if (g_str_has_suffix (extension, ".Debug")) if (g_str_has_suffix (extension, ".Debug"))
{ {
/* debug files only updated if already installed */ /* debug files only updated if already installed */
if (deploy_data == NULL) if (deploy_data == NULL)
download = FALSE; download = FALSE;
/* Always remove debug */ /* Always remove debug */
skipping to change at line 15723 skipping to change at line 15726
return NULL; return NULL;
} }
deploy_data = flatpak_load_deploy_data (deploy_dir, ref, self->repo, FLATP AK_DEPLOY_VERSION_ANY, cancellable, error); deploy_data = flatpak_load_deploy_data (deploy_dir, ref, self->repo, FLATP AK_DEPLOY_VERSION_ANY, cancellable, error);
if (deploy_data == NULL) if (deploy_data == NULL)
return NULL; return NULL;
metadata_file = g_file_get_child (deploy_dir, "metadata"); metadata_file = g_file_get_child (deploy_dir, "metadata");
if (!g_file_load_contents (metadata_file, cancellable, &metadata, NULL, NU LL, NULL)) if (!g_file_load_contents (metadata_file, cancellable, &metadata, NULL, NU LL, NULL))
{ {
g_debug ("No metadata in local deploy"); g_info ("No metadata in local deploy");
/* No metadata => no related, but no error */ /* No metadata => no related, but no error */
} }
} }
else else
flatpak_remote_state_load_data (state, flatpak_decomposed_get_ref (ref), flatpak_remote_state_load_data (state, flatpak_decomposed_get_ref (ref),
NULL, NULL, &metadata, NULL, NULL, &metadata,
NULL); NULL);
if (metadata != NULL && if (metadata != NULL &&
g_key_file_load_from_data (metakey, metadata, -1, 0, NULL)) g_key_file_load_from_data (metakey, metadata, -1, 0, NULL))
skipping to change at line 16014 skipping to change at line 16017
deploy_data = flatpak_load_deploy_data (deploy_dir, ref, self->repo, FLATP AK_DEPLOY_VERSION_ANY, cancellable, error); deploy_data = flatpak_load_deploy_data (deploy_dir, ref, self->repo, FLATP AK_DEPLOY_VERSION_ANY, cancellable, error);
if (deploy_data == NULL) if (deploy_data == NULL)
return NULL; return NULL;
if (flatpak_deploy_data_get_extension_of (deploy_data) == NULL) if (flatpak_deploy_data_get_extension_of (deploy_data) == NULL)
{ {
metadata = g_file_get_child (deploy_dir, "metadata"); metadata = g_file_get_child (deploy_dir, "metadata");
if (!g_file_load_contents (metadata, cancellable, &metadata_contents, NULL, NULL, NULL)) if (!g_file_load_contents (metadata, cancellable, &metadata_contents, NULL, NULL, NULL))
{ {
g_debug ("No metadata in local deploy"); g_info ("No metadata in local deploy");
/* No metadata => no related, but no error */ /* No metadata => no related, but no error */
} }
} }
} }
else else
{ {
g_autofree char *checksum = NULL; g_autofree char *checksum = NULL;
g_autoptr(GVariant) commit_data = flatpak_dir_read_latest_commit (self, re mote_name, ref, &checksum, NULL, NULL); g_autoptr(GVariant) commit_data = flatpak_dir_read_latest_commit (self, re mote_name, ref, &checksum, NULL, NULL);
if (commit_data) if (commit_data)
{ {
g_autoptr(GVariant) commit_metadata = g_variant_get_child_value (commi t_data, 0); g_autoptr(GVariant) commit_metadata = g_variant_get_child_value (commi t_data, 0);
g_variant_lookup (commit_metadata, "xa.metadata", "s", &metadata_conte nts); g_variant_lookup (commit_metadata, "xa.metadata", "s", &metadata_conte nts);
if (metadata_contents == NULL) if (metadata_contents == NULL)
g_debug ("No xa.metadata in local commit %s ref %s", checksum, flatp ak_decomposed_get_ref (ref)); g_info ("No xa.metadata in local commit %s ref %s", checksum, flatpa k_decomposed_get_ref (ref));
} }
} }
if (metadata_contents && if (metadata_contents &&
g_key_file_load_from_data (metakey, metadata_contents, -1, 0, NULL)) g_key_file_load_from_data (metakey, metadata_contents, -1, 0, NULL))
related = flatpak_dir_find_local_related_for_metadata (self, ref, remote_nam e, metakey, cancellable, error); related = flatpak_dir_find_local_related_for_metadata (self, ref, remote_nam e, metakey, cancellable, error);
else else
related = g_ptr_array_new_with_free_func ((GDestroyNotify) flatpak_related_f ree); related = g_ptr_array_new_with_free_func ((GDestroyNotify) flatpak_related_f ree);
return g_steal_pointer (&related); return g_steal_pointer (&related);
skipping to change at line 16054 skipping to change at line 16057
{ {
g_autofree char *authenticator_name = NULL; g_autofree char *authenticator_name = NULL;
g_autoptr(FlatpakDecomposed) ref = NULL; g_autoptr(FlatpakDecomposed) ref = NULL;
authenticator_name = flatpak_dir_get_remote_install_authenticator_name (self, remote_name); authenticator_name = flatpak_dir_get_remote_install_authenticator_name (self, remote_name);
if (authenticator_name != NULL) if (authenticator_name != NULL)
{ {
g_autoptr(GError) local_error = NULL; g_autoptr(GError) local_error = NULL;
ref = flatpak_decomposed_new_from_parts (FLATPAK_KINDS_APP, authenticator_ name, flatpak_get_arch (), "autoinstall", &local_error); ref = flatpak_decomposed_new_from_parts (FLATPAK_KINDS_APP, authenticator_ name, flatpak_get_arch (), "autoinstall", &local_error);
if (ref == NULL) if (ref == NULL)
g_debug ("Invalid authenticator ref: %s\n", local_error->message); g_info ("Invalid authenticator ref: %s\n", local_error->message);
} }
return g_steal_pointer (&ref); return g_steal_pointer (&ref);
} }
static GDBusProxy * static GDBusProxy *
get_localed_dbus_proxy (void) get_localed_dbus_proxy (void)
{ {
const char *localed_bus_name = "org.freedesktop.locale1"; const char *localed_bus_name = "org.freedesktop.locale1";
const char *localed_object_path = "/org/freedesktop/locale1"; const char *localed_object_path = "/org/freedesktop/locale1";
skipping to change at line 16476 skipping to change at line 16479
cancellable, error)) cancellable, error))
return FALSE; return FALSE;
/* Now delete any collection-refs which are in refs/mirrors/, were created by /* Now delete any collection-refs which are in refs/mirrors/, were created by
* Flatpak, and don't belong to a disabled remote. * Flatpak, and don't belong to a disabled remote.
*/ */
GLNX_HASH_TABLE_FOREACH (collection_refs, const OstreeCollectionRef *, c_r) GLNX_HASH_TABLE_FOREACH (collection_refs, const OstreeCollectionRef *, c_r)
{ {
if (g_strv_contains ((const char * const *)ignore_collections->pdata, c_r- >collection_id)) if (g_strv_contains ((const char * const *)ignore_collections->pdata, c_r- >collection_id))
{ {
g_debug ("Ignoring collection-ref (%s, %s) since its remote is disable g_info ("Ignoring collection-ref (%s, %s) since its remote is disabled
d or it matches the repo collection ID", or it matches the repo collection ID",
c_r->collection_id, c_r->ref_name); c_r->collection_id, c_r->ref_name);
continue; continue;
} }
/* Only delete refs which Flatpak created; the repo may have other /* Only delete refs which Flatpak created; the repo may have other
* users. We could check only for refs that come from configured * users. We could check only for refs that come from configured
* remotes, but that would not cover the case of if a remote was * remotes, but that would not cover the case of if a remote was
* deleted. * deleted.
*/ */
if (flatpak_is_app_runtime_or_appstream_ref (c_r->ref_name) || if (flatpak_is_app_runtime_or_appstream_ref (c_r->ref_name) ||
g_strcmp0 (c_r->ref_name, OSTREE_REPO_METADATA_REF) == 0) g_strcmp0 (c_r->ref_name, OSTREE_REPO_METADATA_REF) == 0)
 End of changes. 84 change blocks. 
108 lines changed or deleted 109 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)