From 5404d6f6bb3be409a484835529de615e4eba128a Mon Sep 17 00:00:00 2001 From: John Sully Date: Fri, 19 Jul 2019 01:31:10 -0400 Subject: [PATCH] Modules must have execute permissions to load Former-commit-id: a4efcd35af52227a22daf7f882e8e14db3f8bf57 --- src/module.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/module.cpp b/src/module.cpp index 7d825df27..d71301cd6 100644 --- a/src/module.cpp +++ b/src/module.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #define REDISMODULE_CORE 1 #include "redismodule.h" @@ -5226,6 +5227,15 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) { int (*onload)(void *, void **, int); void *handle; RedisModuleCtx ctx = REDISMODULE_CTX_INIT; + + struct stat st; + if (stat(path, &st) == 0) + { // this check is best effort + if (!(st.st_mode & S_IEXEC)) { + serverLog(LL_WARNING, "Module %s failed to load: It does not have execute permissions.", path); + return C_ERR; + } + } handle = dlopen(path,RTLD_NOW|RTLD_LOCAL); if (handle == NULL) {