]> git.ozlabs.org Git - petitboot/commitdiff
lib/file: remove mkstemp umask in copy_file_secure_dest
authorBrett Grandbois <brett.grandbois@opengear.com>
Thu, 3 May 2018 06:02:04 +0000 (16:02 +1000)
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>
Fri, 4 May 2018 00:26:59 +0000 (10:26 +1000)
mkstemp will generate the temp file with permissions 0600 so the
umask(0644) is causing the file to have permissions of 0000, making
signature files unreadable

Signed-off-by: Brett Grandbois <brett.grandbois@opengear.com>
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
lib/file/file.c

index 57a251901a5afd1dbc1234313af2b1827d65f685..b575d343150ebbb246d8c0ccf5961a68fd434708 100644 (file)
@@ -44,7 +44,6 @@ int copy_file_secure_dest(void *ctx, const char *source_file,
        unsigned char *buffer;
        ssize_t r;
        size_t l1;
-       mode_t oldmask;
 
        source_handle = fopen(source_file, "r");
        if (!source_handle) {
@@ -53,9 +52,7 @@ int copy_file_secure_dest(void *ctx, const char *source_file,
                        return -1;
        }
 
-       oldmask = umask(0644);
        destination_fd = mkstemp(template);
-       umask(oldmask);
        if (destination_fd < 0) {
                pb_log("%s: unable to create temp file, %m\n", __func__);
                fclose(source_handle);