mirror of
https://github.com/fluencelabs/redis
synced 2025-05-08 17:02:13 +00:00
Merge pull request #6257 from JohnSully/ModuleSecurity
Modules must have execute permissions to load
This commit is contained in:
commit
c227f5e7bd
10
src/module.c
10
src/module.c
@ -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>
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------
|
||||||
@ -6985,6 +6986,15 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) {
|
|||||||
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) {
|
||||||
serverLog(LL_WARNING, "Module %s failed to load: %s", path, dlerror());
|
serverLog(LL_WARNING, "Module %s failed to load: %s", path, dlerror());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user