diff options
author | Forest <forestix@sonic.net> | 2023-01-13 18:29:04 -0800 |
---|---|---|
committer | Patrick <tingping@tingping.se> | 2023-01-22 19:21:36 -0600 |
commit | 01910ad12fd840a8667879f9a479a66e441cccdd (patch) | |
tree | 6e83aafcddf18a946d8949c710ae94f9bf4d5130 | |
parent | 16be436de3c946d321cddd6f921595194ef53405 (diff) | |
download | flatpak-01910ad12fd840a8667879f9a479a66e441cccdd.tar.gz |
utils: Unmap the old summary.idx file before trying to replace it
Exporting to an existing repo on a Samba filesystem failed with EACCES
when libglnx called renameat() to replace the old summary.idx file.
error: renameat: Permission denied
This occurred even when the user had appropriate permissions to the file
and its ancestor directories. The problem was that flatpak had mapped the
old file into memory for reading, and still held a reference to that mapping
when attempting to replace the underlying file. Apparently this works on some
filesystems, but not on cifs.
We therefore release the memory mapping before replacing the underlying file.
Fixes #5257
Co-authored-by: Patrick <tingping@tingping.se>
-rw-r--r-- | common/flatpak-utils.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/common/flatpak-utils.c b/common/flatpak-utils.c index 70adf239..53b73ff0 100644 --- a/common/flatpak-utils.c +++ b/common/flatpak-utils.c @@ -4980,6 +4980,10 @@ flatpak_repo_update (OstreeRepo *repo, g_variant_get_data (old_index), g_variant_get_size (old_index)); + /* Release the memory-mapped summary index file before replacing it, + to avoid failure on filesystems like cifs */ + g_clear_pointer (&old_index, g_variant_unref); + if (!flatpak_repo_save_summary_index (repo, summary_index, index_digest, index_sig, cancellable, error)) return FALSE; |