|
|
7d234d |
From d5dfd823c94045488aef8727c553f1e0f7666b90 Mon Sep 17 00:00:00 2001
|
|
|
7d234d |
From: Ondrej Holy <oholy@redhat.com>
|
|
|
7d234d |
Date: Fri, 24 May 2019 09:43:43 +0200
|
|
|
7d234d |
Subject: [PATCH] admin: Ensure correct ownership when moving to file:// uri
|
|
|
7d234d |
|
|
|
7d234d |
User and group is not restored properly when moving (or copying with
|
|
|
7d234d |
G_FILE_COPY_ALL_METADATA) from admin:// to file://, because it is handled
|
|
|
7d234d |
by GIO fallback code, which doesn't run with root permissions. Let's
|
|
|
7d234d |
handle this case with pull method to ensure correct ownership.
|
|
|
7d234d |
---
|
|
|
7d234d |
daemon/gvfsbackendadmin.c | 46 +++++++++++++++++++++++++++++++++++++++
|
|
|
7d234d |
1 file changed, 46 insertions(+)
|
|
|
7d234d |
|
|
|
7d234d |
diff --git a/daemon/gvfsbackendadmin.c b/daemon/gvfsbackendadmin.c
|
|
|
7d234d |
index 32b51b1a..9a7e8295 100644
|
|
|
7d234d |
--- a/daemon/gvfsbackendadmin.c
|
|
|
7d234d |
+++ b/daemon/gvfsbackendadmin.c
|
|
|
7d234d |
@@ -807,6 +807,51 @@ do_move (GVfsBackend *backend,
|
|
|
7d234d |
complete_job (job, error);
|
|
|
7d234d |
}
|
|
|
7d234d |
|
|
|
7d234d |
+static void
|
|
|
7d234d |
+do_pull (GVfsBackend *backend,
|
|
|
7d234d |
+ GVfsJobPull *pull_job,
|
|
|
7d234d |
+ const char *source,
|
|
|
7d234d |
+ const char *local_path,
|
|
|
7d234d |
+ GFileCopyFlags flags,
|
|
|
7d234d |
+ gboolean remove_source,
|
|
|
7d234d |
+ GFileProgressCallback progress_callback,
|
|
|
7d234d |
+ gpointer progress_callback_data)
|
|
|
7d234d |
+{
|
|
|
7d234d |
+ GVfsBackendAdmin *self = G_VFS_BACKEND_ADMIN (backend);
|
|
|
7d234d |
+ GVfsJob *job = G_VFS_JOB (pull_job);
|
|
|
7d234d |
+ GError *error = NULL;
|
|
|
7d234d |
+ GFile *src_file, *dst_file;
|
|
|
7d234d |
+
|
|
|
7d234d |
+ /* Pull method is necessary when user/group needs to be restored, return
|
|
|
7d234d |
+ * G_IO_ERROR_NOT_SUPPORTED in other cases to proceed with the fallback code.
|
|
|
7d234d |
+ */
|
|
|
7d234d |
+ if (!(flags & G_FILE_COPY_ALL_METADATA))
|
|
|
7d234d |
+ {
|
|
|
7d234d |
+ g_vfs_job_failed_literal (G_VFS_JOB (job), G_IO_ERROR,
|
|
|
7d234d |
+ G_IO_ERROR_NOT_SUPPORTED,
|
|
|
7d234d |
+ _("Operation not supported"));
|
|
|
7d234d |
+ return;
|
|
|
7d234d |
+ }
|
|
|
7d234d |
+
|
|
|
7d234d |
+ if (!check_permission (self, job))
|
|
|
7d234d |
+ return;
|
|
|
7d234d |
+
|
|
|
7d234d |
+ src_file = g_file_new_for_path (source);
|
|
|
7d234d |
+ dst_file = g_file_new_for_path (local_path);
|
|
|
7d234d |
+
|
|
|
7d234d |
+ if (remove_source)
|
|
|
7d234d |
+ g_file_move (src_file, dst_file, flags, job->cancellable,
|
|
|
7d234d |
+ progress_callback, progress_callback_data, &error);
|
|
|
7d234d |
+ else
|
|
|
7d234d |
+ g_file_copy (src_file, dst_file, flags, job->cancellable,
|
|
|
7d234d |
+ progress_callback, progress_callback_data, &error);
|
|
|
7d234d |
+
|
|
|
7d234d |
+ g_object_unref (src_file);
|
|
|
7d234d |
+ g_object_unref (dst_file);
|
|
|
7d234d |
+
|
|
|
7d234d |
+ complete_job (job, error);
|
|
|
7d234d |
+}
|
|
|
7d234d |
+
|
|
|
7d234d |
static void
|
|
|
7d234d |
do_query_settable_attributes (GVfsBackend *backend,
|
|
|
7d234d |
GVfsJobQueryAttributes *query_job,
|
|
|
7d234d |
@@ -927,6 +972,7 @@ g_vfs_backend_admin_class_init (GVfsBackendAdminClass * klass)
|
|
|
7d234d |
backend_class->set_attribute = do_set_attribute;
|
|
|
7d234d |
backend_class->delete = do_delete;
|
|
|
7d234d |
backend_class->move = do_move;
|
|
|
7d234d |
+ backend_class->pull = do_pull;
|
|
|
7d234d |
backend_class->query_settable_attributes = do_query_settable_attributes;
|
|
|
7d234d |
backend_class->query_writable_namespaces = do_query_writable_namespaces;
|
|
|
7d234d |
}
|
|
|
7d234d |
--
|
|
|
7d234d |
2.23.0
|
|
|
7d234d |
|