diff options
Diffstat (limited to 'source3/rpc_server/srv_pipe.c')
-rw-r--r-- | source3/rpc_server/srv_pipe.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c index f6deac68f8..588d6644b1 100644 --- a/source3/rpc_server/srv_pipe.c +++ b/source3/rpc_server/srv_pipe.c @@ -796,21 +796,40 @@ int rpc_pipe_register_commands(const char *clnt, const char *srv, const struct a *******************************************************************/ int rpc_load_module(const char *module) { +#ifdef HAVE_DLOPEN + void *handle; + int (*module_init)(void); pstring full_path; - int status; + const char *error; pstrcpy(full_path, lib_path("rpc")); pstrcat(full_path, "/librpc_"); pstrcat(full_path, module); pstrcat(full_path, "."); pstrcat(full_path, shlib_ext()); - - if (!(status = smb_load_module(full_path))) { + + handle = sys_dlopen(full_path, RTLD_LAZY); + if (!handle) { DEBUG(0, ("Could not load requested pipe %s as %s\n", module, full_path)); + DEBUG(0, (" Error: %s\n", dlerror())); + return 0; } - return status; + DEBUG(3, ("Module '%s' loaded\n", full_path)); + + module_init = sys_dlsym(handle, "rpc_pipe_init"); + if ((error = sys_dlerror()) != NULL) { + DEBUG(0, ("Error trying to resolve symbol 'rpc_pipe_init' in %s: %s\n", + full_path, error)); + return 0; + } + + return module_init(); +#else + DEBUG(0,("Attempting to load a dynamic RPC pipe when dlopen isn't available\n")); + return 0; +#endif } /******************************************************************* |