# HG changeset patch # User Kim Alvefur # Date 1348089998 -7200 # Node ID dfe6a70efaa2d571fa7872029f9c7fe80557df6d # Parent 81b49bb0ecc79c2a07ebd42d65bffb351d24670f prosodyctl: Set stricter umask while generating key (thanks darkrain) diff -r 81b49bb0ecc7 -r dfe6a70efaa2 prosodyctl --- a/prosodyctl Wed Sep 19 23:25:10 2012 +0200 +++ b/prosodyctl Wed Sep 19 23:26:38 2012 +0200 @@ -687,11 +687,13 @@ if ask_overwrite(key_filename) then return nil, key_filename; end - os.remove(key_filename); -- We chmod this file to not have write permissions + os.remove(key_filename); -- This file, if it exists is unlikely to have write permissions local key_size = tonumber(arg[2] or show_prompt("Choose key size (2048):") or 2048); + local old_umask = pposix.umask("0377"); if openssl.genrsa{out=key_filename, key_size} then os.execute(("chmod 400 '%s'"):format(key_filename)); show_message("Key written to ".. key_filename); + pposix.umask(old_umask); return nil, key_filename; end show_message("There was a problem, see OpenSSL output");