]> granicus.if.org Git - shadow/commitdiff
Keep the permissions of the original file when creating a backup.
authorTomas Mraz <tmraz@fedoraproject.org>
Tue, 15 Nov 2016 15:04:24 +0000 (16:04 +0100)
committerTomas Mraz <tmraz@fedoraproject.org>
Tue, 15 Nov 2016 15:04:24 +0000 (16:04 +0100)
lib/commonio.c

index 2e2f7785e8c1e86f5e528fbdb659f6eca76edaec..b10da06a2e091b0780716b2c967757d02cc4a06a 100644 (file)
@@ -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;
        }