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