Open files with permissions 0666 and let umask(2) do its job.
authorPhilippe Troin <phil+github-commits@fifi.org>
Sun, 19 May 2019 05:08:11 +0000 (22:08 -0700)
committerPhilippe Troin <phil+github-commits@fifi.org>
Sun, 19 May 2019 05:08:11 +0000 (22:08 -0700)
When creating files, zchunk did not obey the users's umask(2) setting.

src/unzck.c
src/zck.c
src/zck_dl.c
src/zck_gen_zdict.c
test/copy_chunks.c

index d46a4d542682167d78dfe8eaee830dc529981f29..8d6c62a5935373ed4f419e2632772a018d84df24 100644 (file)
@@ -139,7 +139,7 @@ int main (int argc, char *argv[]) {
 
     int dst_fd = STDOUT_FILENO;
     if(!arguments.stdout) {
-        dst_fd = open(out_name, O_TRUNC | O_WRONLY | O_CREAT, 0644);
+        dst_fd = open(out_name, O_TRUNC | O_WRONLY | O_CREAT, 0666);
         if(dst_fd < 0) {
             dprintf(STDERR_FILENO, "Unable to open %s", out_name);
             perror("");
index 252ae55fa9be1778d451f4f4b9e06f68f086f012..84231b17beefce9d18fd4fa5e2d8e53940c62b0e 100644 (file)
--- a/src/zck.c
+++ b/src/zck.c
@@ -179,7 +179,7 @@ int main (int argc, char *argv[]) {
         close(dict_fd);
     }
 
-    int dst_fd = open(out_name, O_TRUNC | O_WRONLY | O_CREAT, 0644);
+    int dst_fd = open(out_name, O_TRUNC | O_WRONLY | O_CREAT, 0666);
     if(dst_fd < 0) {
         dprintf(STDERR_FILENO, "Unable to open %s", out_name);
         perror("");
index 206213812db09af9725eacf1a237732480b88de6..045f08fc506d007a0d0dccde477da9f0885fe150 100644 (file)
@@ -314,7 +314,7 @@ int main (int argc, char *argv[]) {
     }
 
     char *outname = basename(arguments.args[0]);
-    int dst_fd = open(outname, O_RDWR | O_CREAT, 0644);
+    int dst_fd = open(outname, O_RDWR | O_CREAT, 0666);
     if(dst_fd < 0) {
         dprintf(STDERR_FILENO, "Unable to open %s: %s\n", outname,
                 strerror(errno));
index ab96bff8a6967b3052f91f1b8afa5397348c6414..030f09a63b4a430106f377986c4ac5f596df3e2d 100644 (file)
@@ -224,7 +224,7 @@ int main (int argc, char *argv[]) {
         assert(dict_block);
         snprintf(dict_block, strlen(dir) + strlen(out_name) + 12, "%s/%s.%li",
                  dir, out_name, zck_get_chunk_number(idx));
-        int dst_fd = open(dict_block, O_TRUNC | O_WRONLY | O_CREAT, 0644);
+        int dst_fd = open(dict_block, O_TRUNC | O_WRONLY | O_CREAT, 0666);
         if(dst_fd < 0) {
             dprintf(STDERR_FILENO, "Unable to open %s", dict_block);
             perror("");
index b8d5b9fe5087ff273b102e98c0ffa9ddeac5ad21..ad8f2fb7a07e1dbac0b1a3541eea4f50a49b438e 100644 (file)
@@ -49,7 +49,7 @@ int main (int argc, char *argv[]) {
         perror("Unable to open LICENSE.header.new.nodict.fodt.zck for reading");
         exit(1);
     }
-    int tgt = open(base_name, O_RDWR | O_CREAT, 0644);
+    int tgt = open(base_name, O_RDWR | O_CREAT, 0666);
     if(tgt < 0) {
         perror("Unable to open LICENSE.header.new.nodict.fodt.zck for writing");
         exit(1);