Loading src/confhelper.cpp +15 −7 Changes for src/confhelper.cpp: 15 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -311,12 +311,7 @@ namespace fenrirds::confhelper { * config bind-mounted as a single file can't be renamed over * and is rewritten in place instead */ void save() { std::string dir = parentDir(_path); #ifndef _WIN32 struct stat dst; if (stat(dir.c_str(), &dst) != 0 && mkdir(dir.c_str(), 0755) != 0) throw std::runtime_error("mkdir " + dir + ": " + strerror(errno)); #endif ensureDir(); std::string tmp = _path + ".new"; _cfg->saveConfig(tmp.c_str()); try { Loading Loading @@ -350,9 +345,22 @@ namespace fenrirds::confhelper { } private: void ensureDir() { #ifndef _WIN32 std::string dir = parentDir(_path); struct stat dst; if (stat(dir.c_str(), &dst) != 0 && mkdir(dir.c_str(), 0755) != 0) throw std::runtime_error("mkdir " + dir + ": " + strerror(errno)); #endif } /* next to the config: that directory has to work anyway, and a * container need not have a /tmp */ void loadTemplate() { #ifndef _WIN32 char tmpl[] = "/tmp/fenrirds-config-XXXXXX"; ensureDir(); std::string name = parentDir(_path) + "/.config-XXXXXX"; char *tmpl = name.data(); int fd = mkstemp(tmpl); if (fd < 0) throw std::runtime_error(std::string("mkstemp: ") + strerror(errno)); Loading Loading
src/confhelper.cpp +15 −7 Changes for src/confhelper.cpp: 15 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -311,12 +311,7 @@ namespace fenrirds::confhelper { * config bind-mounted as a single file can't be renamed over * and is rewritten in place instead */ void save() { std::string dir = parentDir(_path); #ifndef _WIN32 struct stat dst; if (stat(dir.c_str(), &dst) != 0 && mkdir(dir.c_str(), 0755) != 0) throw std::runtime_error("mkdir " + dir + ": " + strerror(errno)); #endif ensureDir(); std::string tmp = _path + ".new"; _cfg->saveConfig(tmp.c_str()); try { Loading Loading @@ -350,9 +345,22 @@ namespace fenrirds::confhelper { } private: void ensureDir() { #ifndef _WIN32 std::string dir = parentDir(_path); struct stat dst; if (stat(dir.c_str(), &dst) != 0 && mkdir(dir.c_str(), 0755) != 0) throw std::runtime_error("mkdir " + dir + ": " + strerror(errno)); #endif } /* next to the config: that directory has to work anyway, and a * container need not have a /tmp */ void loadTemplate() { #ifndef _WIN32 char tmpl[] = "/tmp/fenrirds-config-XXXXXX"; ensureDir(); std::string name = parentDir(_path) + "/.config-XXXXXX"; char *tmpl = name.data(); int fd = mkstemp(tmpl); if (fd < 0) throw std::runtime_error(std::string("mkstemp: ") + strerror(errno)); Loading