if (modified) {
bufferlist bl;
::encode(keyring, bl);
- r = bl.write_file(fn);
+ r = bl.write_file(fn, 0600);
if (r < 0) {
cerr << "could not write " << fn << std::endl;
}
return 0;
}
-int buffer::list::write_file(const char *fn)
+int buffer::list::write_file(const char *fn, int mode)
{
- int fd = ::open(fn, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ int fd = ::open(fn, O_WRONLY|O_CREAT|O_TRUNC, mode);
if (fd < 0) {
char buf[80];
cerr << "can't write " << fn << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
void hexdump(std::ostream &out) const;
int read_file(const char *fn, bool silent=false);
- int write_file(const char *fn);
+ int write_file(const char *fn, int mode=0644);
__u32 crc32c(__u32 crc) {
for (std::list<ptr>::const_iterator it = _buffers.begin();
it != _buffers.end();