ucode: initialize module search path early
Ensure that the default module search path is initialized before compiling ucode handler scripts in order to support compile time import statements. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
parent
82904bd4f9
commit
0d02243086
1 changed files with 4 additions and 1 deletions
5
ucode.c
5
ucode.c
|
@ -929,7 +929,6 @@ rpc_ucode_script_execute(struct ubus_context *ctx, const char *path, uc_program_
|
||||||
|
|
||||||
script->path = strncpy(pptr, path, pathlen);
|
script->path = strncpy(pptr, path, pathlen);
|
||||||
|
|
||||||
uc_search_path_init(&config.module_search_path);
|
|
||||||
uc_vm_init(&script->vm, &config);
|
uc_vm_init(&script->vm, &config);
|
||||||
rpc_ucode_init_globals(script);
|
rpc_ucode_init_globals(script);
|
||||||
|
|
||||||
|
@ -1019,6 +1018,10 @@ rpc_ucode_api_init(const struct rpc_daemon_ops *ops, struct ubus_context *ctx)
|
||||||
fprintf(stderr, "Failed to dlopen() ucode.so: %s, dynamic ucode plugins may fail\n",
|
fprintf(stderr, "Failed to dlopen() ucode.so: %s, dynamic ucode plugins may fail\n",
|
||||||
dlerror());
|
dlerror());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* initialize default module search path */
|
||||||
|
uc_search_path_init(&config.module_search_path);
|
||||||
|
|
||||||
if ((d = opendir(RPC_UCSCRIPT_DIRECTORY)) != NULL) {
|
if ((d = opendir(RPC_UCSCRIPT_DIRECTORY)) != NULL) {
|
||||||
while ((e = readdir(d)) != NULL) {
|
while ((e = readdir(d)) != NULL) {
|
||||||
snprintf(path, sizeof(path), RPC_UCSCRIPT_DIRECTORY "/%s", e->d_name);
|
snprintf(path, sizeof(path), RPC_UCSCRIPT_DIRECTORY "/%s", e->d_name);
|
||||||
|
|
Loading…
Reference in a new issue