From 26fdf069f096c198cf044bf467100f98d1627561 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 11 Feb 2010 15:31:14 -0800 Subject: [PATCH] cauthtool: mode 0600 for keyrings --- src/cauthtool.cc | 2 +- src/common/buffer.cc | 4 ++-- src/include/buffer.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cauthtool.cc b/src/cauthtool.cc index 44c4d7586b9e6..6458e6c206418 100644 --- a/src/cauthtool.cc +++ b/src/cauthtool.cc @@ -197,7 +197,7 @@ int main(int argc, const char **argv) 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; } diff --git a/src/common/buffer.cc b/src/common/buffer.cc index da17022295478..bb47673b3a6b5 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -71,9 +71,9 @@ int buffer::list::read_file(const char *fn, bool silent) 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; diff --git a/src/include/buffer.h b/src/include/buffer.h index a1656e0c145a5..7ff6d85749ef2 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -1129,7 +1129,7 @@ public: 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::const_iterator it = _buffers.begin(); it != _buffers.end(); -- 2.39.5