From 3680884767375be9d2c193f5bd49975970e7b83f Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Thu, 24 Jan 2013 22:02:42 -0800 Subject: [PATCH] Restore original umask after running keygen --- commands.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands.cpp b/commands.cpp index 69d6f10..9d782d6 100644 --- a/commands.cpp +++ b/commands.cpp @@ -247,12 +247,13 @@ void init (const char* argv0, const char* keyfile) void keygen (const char* keyfile) { - umask(0077); // make sure key file is protected + mode_t old_umask = umask(0077); // make sure key file is protected std::ofstream keyout(keyfile); if (!keyout) { perror(keyfile); std::exit(1); } + umask(old_umask); std::ifstream randin("/dev/random"); if (!randin) { perror("/dev/random");