From 4471e5419dd3c9456409390f9640e8504e84d157 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Tue, 15 Nov 2016 16:04:24 +0100 Subject: [PATCH] Keep the permissions of the original file when creating a backup. --- lib/commonio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/commonio.c b/lib/commonio.c index 2e2f7785..b10da06a 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -301,15 +301,12 @@ static int create_backup (const char *backup, FILE * fp) struct utimbuf ub; FILE *bkfp; int c; - mode_t mask; if (fstat (fileno (fp), &sb) != 0) { return -1; } - mask = umask (077); - bkfp = fopen (backup, "w"); - (void) umask (mask); + bkfp = fopen_set_perms (backup, "w", &sb); if (NULL == bkfp) { return -1; }