]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: preserve acls when rotating user journals with NOCOW attribute set
authorFranck Bui <fbui@suse.com>
Mon, 14 Mar 2022 17:03:02 +0000 (18:03 +0100)
committerFranck Bui <fbui@suse.com>
Mon, 14 Mar 2022 17:03:02 +0000 (18:03 +0100)
When restoring the COW flag for journals on BTRFS, the full journal contents
are copied into new files. But during these operations, the acls of the
previous files were lost and users were not able to access to their old
journal contents anymore.

src/journal/managed-journal-file.c

index 657cf5ebbf6ee8ef4b58313bf9e1050aa5fde073..03b1d8275e66e7fd458073866d0590194cd395e9 100644 (file)
@@ -210,7 +210,10 @@ static void managed_journal_file_set_offline_internal(ManagedJournalFile *f) {
 
                                 log_debug_errno(r, "Failed to re-enable copy-on-write for %s: %m, rewriting file", f->file->path);
 
-                                r = copy_file_atomic(FORMAT_PROC_FD_PATH(f->file->fd), f->file->path, f->file->mode, 0, FS_NOCOW_FL, COPY_REPLACE | COPY_FSYNC | COPY_HOLES);
+                                r = copy_file_atomic(FORMAT_PROC_FD_PATH(f->file->fd), f->file->path, f->file->mode,
+                                                     0,
+                                                     FS_NOCOW_FL,
+                                                     COPY_REPLACE | COPY_FSYNC | COPY_HOLES | COPY_ALL_XATTRS);
                                 if (r < 0) {
                                         log_debug_errno(r, "Failed to rewrite %s: %m", f->file->path);
                                         continue;