Fix local deploys using system helper

Resolves: #1982304
This commit is contained in:
Debarshi Ray 2021-08-28 13:04:41 +02:00
parent 868c09b903
commit d78fc751c2
2 changed files with 133 additions and 1 deletions

View File

@ -0,0 +1,126 @@
From 49e8bfcea516e96eb950109d0fa45811a352a517 Mon Sep 17 00:00:00 2001
From: Alexander Larsson <alexl@redhat.com>
Date: Wed, 17 Mar 2021 17:12:32 +0100
Subject: [PATCH] system-helper: Fix deploys of local remotes
For updates in remotes with a local (file:) uri we just do a deploy
with a LOCAL_PULL flag set and an empty arg_repo_path. However, our
arg_repo_path checking at some point seemed to stop properly handling
the case where it is empty. I got it to report "No such file" wich
broke the tests.
---
system-helper/flatpak-system-helper.c | 89 ++++++++++++++-------------
1 file changed, 46 insertions(+), 43 deletions(-)
diff --git a/system-helper/flatpak-system-helper.c b/system-helper/flatpak-system-helper.c
index b202c94105..adcfe61a86 100644
--- a/system-helper/flatpak-system-helper.c
+++ b/system-helper/flatpak-system-helper.c
@@ -410,61 +410,64 @@ handle_deploy (FlatpakSystemHelper *object,
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
- src_dir = g_path_get_dirname (arg_repo_path);
- ongoing_pull = take_ongoing_pull_by_dir (src_dir);
- if (ongoing_pull != NULL)
+ if ((arg_flags & ~FLATPAK_HELPER_DEPLOY_FLAGS_ALL) != 0)
{
- g_autoptr(GError) local_error = NULL;
- uid_t uid;
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
+ "Unsupported flags enabled: 0x%x", (arg_flags & ~FLATPAK_HELPER_DEPLOY_FLAGS_ALL));
+ return G_DBUS_METHOD_INVOCATION_HANDLED;
+ }
- /* Ensure that pull's uid is same as the caller's uid */
- if (!get_connection_uid (invocation, &uid, &local_error))
+ if (strlen (arg_repo_path) > 0)
+ {
+ if (!g_file_query_exists (repo_file, NULL))
{
- g_dbus_method_invocation_return_gerror (invocation, local_error);
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
+ "Path does not exist");
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
- else
+
+ src_dir = g_path_get_dirname (arg_repo_path);
+ ongoing_pull = take_ongoing_pull_by_dir (src_dir);
+ if (ongoing_pull != NULL)
{
- if (ongoing_pull->uid != uid)
+ g_autoptr(GError) local_error = NULL;
+ uid_t uid;
+
+ /* Ensure that pull's uid is same as the caller's uid */
+ if (!get_connection_uid (invocation, &uid, &local_error))
{
- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
- "Ongoing pull's uid(%d) does not match with peer uid(%d)",
- ongoing_pull->uid, uid);
+ g_dbus_method_invocation_return_gerror (invocation, local_error);
return G_DBUS_METHOD_INVOCATION_HANDLED;
}
- }
-
- terminate_revokefs_backend (ongoing_pull);
-
- if (!flatpak_canonicalize_permissions (AT_FDCWD,
- arg_repo_path,
- getuid() == 0 ? 0 : -1,
- getuid() == 0 ? 0 : -1,
- &local_error))
- {
- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
- "Failed to canonicalize permissions of repo %s: %s",
- arg_repo_path, local_error->message);
- return G_DBUS_METHOD_INVOCATION_HANDLED;
- }
+ else
+ {
+ if (ongoing_pull->uid != uid)
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
+ "Ongoing pull's uid(%d) does not match with peer uid(%d)",
+ ongoing_pull->uid, uid);
+ return G_DBUS_METHOD_INVOCATION_HANDLED;
+ }
+ }
- /* At this point, the cache-dir's repo is owned by root. Hence, any failure
- * from here on, should always cleanup the cache-dir and not preserve it to be re-used. */
- ongoing_pull->preserve_pull = FALSE;
- }
+ terminate_revokefs_backend (ongoing_pull);
- if ((arg_flags & ~FLATPAK_HELPER_DEPLOY_FLAGS_ALL) != 0)
- {
- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
- "Unsupported flags enabled: 0x%x", (arg_flags & ~FLATPAK_HELPER_DEPLOY_FLAGS_ALL));
- return G_DBUS_METHOD_INVOCATION_HANDLED;
- }
+ if (!flatpak_canonicalize_permissions (AT_FDCWD,
+ arg_repo_path,
+ getuid() == 0 ? 0 : -1,
+ getuid() == 0 ? 0 : -1,
+ &local_error))
+ {
+ g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_FAILED,
+ "Failed to canonicalize permissions of repo %s: %s",
+ arg_repo_path, local_error->message);
+ return G_DBUS_METHOD_INVOCATION_HANDLED;
+ }
- if (!g_file_query_exists (repo_file, NULL))
- {
- g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
- "Path does not exist");
- return G_DBUS_METHOD_INVOCATION_HANDLED;
+ /* At this point, the cache-dir's repo is owned by root. Hence, any failure
+ * from here on, should always cleanup the cache-dir and not preserve it to be re-used. */
+ ongoing_pull->preserve_pull = FALSE;
+ }
}
ref = flatpak_decomposed_new_from_ref (arg_ref, &error);

View File

@ -3,7 +3,7 @@
Name: flatpak
Version: 1.10.2
Release: 5%{?dist}
Release: 6%{?dist}
Summary: Application deployment framework for desktop apps
License: LGPLv2+
@ -15,6 +15,8 @@ Source1: flatpak-add-fedora-repos.service
# https://github.com/flatpak/flatpak/pull/4210
# https://pagure.io/fedora-infrastructure/issue/9840
Patch0: 0001-OCI-Switch-to-pax-format-for-tar-archives.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=1982304
Patch1: flatpak-1.10.2-system-helper-fix.patch
BuildRequires: pkgconfig(appstream-glib)
BuildRequires: pkgconfig(dconf)
@ -268,6 +270,10 @@ fi
%changelog
* Sat Aug 28 2021 Debarshi Ray <rishi@fedoraproject.org> - 1.10.2-6
- Fix local deploys using system helper
Resolves: #1982304
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 1.10.2-5
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688