Repositories / jai.git

jai.git

Clone (read-only): git clone http://git.guha-anderson.com/git/jai.git

Branch

specify mode when opening files

Author
David Mazieres <dm@uun.org>
Date
2026-03-18 22:45:19 -0700
Commit
d19f8e4288646ea966714a4a4578adaf3aba97ad
fs.cc
index 3ca3f0e..9abcd0b 100644
--- a/fs.cc
+++ b/fs.cc
@@ -453,7 +453,8 @@ ensure_file(int dfd, path file, std::string_view contents, int mode)
     unlinkat(dfd, tmp.c_str(), 0);
     Defer cleanup{[dfd, &tmp] { unlinkat(dfd, tmp.c_str(), 0); }};
 
-    Fd fd = xopenat(dfd, tmp.c_str(), O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC);
+    Fd fd = xopenat(dfd, tmp.c_str(), O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC,
+                    mode);
     for (size_t i = 0; i < contents.size();) {
       if (auto n = write(*fd, contents.data() + i, contents.size() - i); n < 0)
         syserr(R"(write(O_TMPFILE for "{}"))", fdpath(dfd, file));
jai.cc
index 0429487..fc7ea49 100644
--- a/jai.cc
+++ b/jai.cc
@@ -1061,7 +1061,7 @@ The default is CMD.conf if it exists, otherwise default.conf)",
   }
 
   ensure_file(conf.home_jai(), ".defaults", jai_defaults, 0600);
-  ensure_file(conf.home_jai(), "default.conf", jai_defaults, 0600);
+  ensure_file(conf.home_jai(), "default.conf", default_conf, 0600);
 
   if (!opt_C.empty()) {
     if (!conf.parse_config_file(opt_C))