From 64ea1d6c2c05f75f3618b12c6a429ccda7e0fe76 Mon Sep 17 00:00:00 2001 From: Bert Peters Date: Fri, 4 May 2018 16:19:22 +0200 Subject: [PATCH] Bugfix: properly set mode for created files. --- src/tools/deinplace.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/tools/deinplace.cpp b/src/tools/deinplace.cpp index cb05489..9573a64 100644 --- a/src/tools/deinplace.cpp +++ b/src/tools/deinplace.cpp @@ -37,7 +37,12 @@ void show_help(std::string_view name, int exit_code) int get_file_descriptor(std::string_view file_name, int mode) { - int fd = open(file_name.data(), mode); + int fd; + if ((mode & O_CREAT) || (mode & O_TMPFILE)) { + fd = open(file_name.data(), mode, 0666); + } else { + fd = open(file_name.data(), mode); + } if (fd < 0) { perror("get_file_descriptor"); exit(1); @@ -60,6 +65,7 @@ void read_options(int argc, char **argv) options.output_filename = optarg; break; case '?': + default: show_help(argv[0], 1); break; }