From f17055f5933d3b4e8c14bc4c71aa603ccabb1b35 Mon Sep 17 00:00:00 2001 From: Ondrej Holy Date: Thu, 6 Jun 2019 16:55:25 +0200 Subject: [PATCH] gfile: Do not follow symlinks when moving It is expected that `g_file_move()` moves symlink file itself, not its target. Unfortunately, copy and delete fallback passes `GFileCopyFlags` and don't explicitly use `G_FILE_COPY_NOFOLLOW_SYMLINKS`. This may cause that symlink target is copied and symlink itself is removed. Let's explicitly pass `G_FILE_COPY_NOFOLLOW_SYMLINKS` to the copy operation to prevent this unexpected behavior. https://gitlab.gnome.org/GNOME/glib/issues/986 --- gio/gfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gio/gfile.c b/gio/gfile.c index 19f5d105f..c9274cd9b 100644 --- a/gio/gfile.c +++ b/gio/gfile.c @@ -3736,7 +3736,7 @@ g_file_move (GFile *source, return FALSE; } - flags |= G_FILE_COPY_ALL_METADATA; + flags |= G_FILE_COPY_ALL_METADATA | G_FILE_COPY_NOFOLLOW_SYMLINKS; if (!g_file_copy (source, destination, flags, cancellable, progress_callback, progress_callback_data, error))