summaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-06-11 11:32:43 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-06-11 11:32:43 +0100
commit0e654a69f908ae3abe19663dc192f1dbc45d8ed0 (patch)
treee6802c0328f8a352dbfb1bd5986b66902a9294ba /src/lua
parenta028e5973813023f29c740a0b857fa32ce1c51fb (diff)
downloadrspamd-0e654a69f908ae3abe19663dc192f1dbc45d8ed0.tar.gz
rspamd-0e654a69f908ae3abe19663dc192f1dbc45d8ed0.zip
[Feature] Improve error reporting for DKIM key access issues
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_util.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index f99ae7d1f..063a7aab7 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -414,7 +414,7 @@ LUA_FUNCTION_DEF (util, readpassphrase);
/***
* @function util.file_exists(file)
* Checks if a specified file exists and is available for reading
- * @return {boolean} true if file exists
+ * @return {boolean,string} true if file exists + string error if not
*/
LUA_FUNCTION_DEF (util, file_exists);
@@ -2399,15 +2399,24 @@ static gint
lua_util_file_exists (lua_State *L)
{
const gchar *fname = luaL_checkstring (L, 1);
+ gint serrno;
if (fname) {
- lua_pushboolean (L, access (fname, R_OK) != -1);
+ if (access (fname, R_OK) == -1) {
+ serrno = errno;
+ lua_pushboolean (L, false);
+ lua_pushstring (L, strerror (serrno));
+ }
+ else {
+ lua_pushboolean (L, true);
+ lua_pushnil (L);
+ }
}
else {
return luaL_error (L, "invalid arguments");
}
- return 1;
+ return 2;
}
static gint