Restore original umask after running keygen

This commit is contained in:
Andrew Ayer
2013-01-24 22:02:42 -08:00
parent 8b5c3d5c88
commit 3680884767

View File

@@ -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");