Unverified Commit c227f5e7 authored by Salvatore Sanfilippo's avatar Salvatore Sanfilippo Committed by GitHub
Browse files

Merge pull request #6257 from JohnSully/ModuleSecurity

Modules must have execute permissions to load
parents c6fb9d09 2968d8e3
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "cluster.h" #include "cluster.h"
#include "rdb.h" #include "rdb.h"
#include <dlfcn.h> #include <dlfcn.h>
#include <sys/stat.h>
#include <sys/wait.h> #include <sys/wait.h>
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
...@@ -6984,6 +6985,15 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) { ...@@ -6984,6 +6985,15 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) {
int (*onload)(void *, void **, int); int (*onload)(void *, void **, int);
void *handle; void *handle;
RedisModuleCtx ctx = REDISMODULE_CTX_INIT; RedisModuleCtx ctx = REDISMODULE_CTX_INIT;
struct stat st;
if (stat(path, &st) == 0)
{ // this check is best effort
if (!(st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) {
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); handle = dlopen(path,RTLD_NOW|RTLD_LOCAL);
if (handle == NULL) { if (handle == NULL) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment