From 8c123a4c91dc1467906ce7456fa67d10504a5c93 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Sun, 21 Oct 2007 07:31:12 -0400 Subject: [PATCH] After saving the temporary file and renaming it to the original, restore the permissions of the original. --- src/commands.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/commands.c b/src/commands.c index 483b3198..6d96ff26 100644 --- a/src/commands.c +++ b/src/commands.c @@ -730,13 +730,22 @@ gpg_error_t do_xml_encrypt(struct client_s *client, gcry_cipher_hd_t gh, } if (filename) { + struct stat st; + mode_t mode = 0; + close(fd); + if (stat(filename, &st) == 0) + mode = st.st_mode & (S_IRWXU|S_IRWXG|S_IRWXO); + if (rename(tmp, filename) == -1) { len = errno; gcry_free(inbuf); return gpg_error_from_errno(len); } + + if (mode) + chmod(filename, mode); } gcry_free(inbuf); -- 2.11.4.GIT