From 9f682a9fe3c2541f91268ba3b0f0e8982f50ebe5 Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Wed, 25 Dec 2024 21:16:52 +0900 Subject: [PATCH] Fix case when archiving from read-only directory A temporary file is usually created to store compressed archive chunks/files which is located where the files are. This commit falls-back to using `tmpfile()` if the first attempt to create a temporary file fails. --- src/archiver.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/archiver.c b/src/archiver.c index 4534ca6..c0c9aaf 100644 --- a/src/archiver.c +++ b/src/archiver.c @@ -3602,7 +3602,10 @@ int simple_archiver_write_v2(FILE *out_f, SDArchiverState *state, } if (!temp_fd) { - return SDAS_INTERNAL_ERROR; + temp_fd = tmpfile(); + if (!temp_fd) { + return SDAS_INTERNAL_ERROR; + } } // Handle SIGPIPE. -- 2.49.0