From: Tomas Mraz Date: Tue, 15 Nov 2016 15:04:24 +0000 (+0100) Subject: Keep the permissions of the original file when creating a backup. X-Git-Tag: 4.5~31^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4471e5419dd3c9456409390f9640e8504e84d157;p=shadow Keep the permissions of the original file when creating a backup. --- 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; }