diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-04-07 15:59:46 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-04-07 16:39:21 +0100 |
commit | 553d2c2f60bce6265868c147b59abb6fd4d65f65 (patch) | |
tree | 7fed9334cbe07bb2082fe36444494cacd8770c2e | |
parent | a7b387d9aab1503c6988ddf427b92a3b70c4c481 (diff) | |
download | rspamd-553d2c2f60bce6265868c147b59abb6fd4d65f65.tar.gz rspamd-553d2c2f60bce6265868c147b59abb6fd4d65f65.zip |
[Minor] Allow to save private key in output
-rw-r--r-- | src/lua/lua_rsa.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/lua/lua_rsa.c b/src/lua/lua_rsa.c index 85d5f8745..571f62646 100644 --- a/src/lua/lua_rsa.c +++ b/src/lua/lua_rsa.c @@ -177,7 +177,12 @@ lua_rsa_privkey_save (lua_State *L) } if (rsa != NULL && filename != NULL) { - f = fopen (filename, "wb"); + if (strcmp (filename, "-") == 0) { + f = stdout; + } + else { + f = fopen(filename, "wb"); + } if (f == NULL) { msg_err ("cannot save privkey to file: %s, %s", filename, @@ -185,8 +190,10 @@ lua_rsa_privkey_save (lua_State *L) lua_pushboolean (L, FALSE); } else { - /* Set secure permissions for the private key file */ - chmod (filename, S_IRUSR | S_IWUSR); + if (f != stdout) { + /* Set secure permissions for the private key file */ + chmod(filename, S_IRUSR | S_IWUSR); + } if (strcmp (type, "der") == 0) { ret = i2d_RSAPrivateKey_fp (f, rsa); |