s3-module allow libreplace to provide dlopen replacement
[amitay/samba.git] / source3 / lib / module.c
index 76983387ffd03e172869edb374969e4d813ad024..9cd3884c517a6403b6659b75588dd9f7665f8fe3 100644 (file)
@@ -21,8 +21,6 @@
 
 #include "includes.h"
 
-#ifdef HAVE_DLOPEN
-
 /* Load a dynamic module.  Only log a level 0 error if we are not checking 
    for the existence of a module (probling). */
 
@@ -37,11 +35,11 @@ static NTSTATUS do_smb_load_module(const char *module_name, bool is_probe)
         * backwards compatibility, there might be symbols in the 
         * plugin referencing to old (removed) functions
         */
-       handle = sys_dlopen(module_name, RTLD_LAZY);
+       handle = dlopen(module_name, RTLD_LAZY);
 
        /* This call should reset any possible non-fatal errors that 
           occured since last call to dl* functions */
-       error = sys_dlerror();
+       error = dlerror();
 
        if(!handle) {
                int level = is_probe ? 3 : 0;
@@ -49,15 +47,15 @@ static NTSTATUS do_smb_load_module(const char *module_name, bool is_probe)
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       init = (init_module_function *)sys_dlsym(handle, "init_samba_module");
+       init = (init_module_function *)dlsym(handle, "init_samba_module");
 
-       /* we must check sys_dlerror() to determine if it worked, because
-           sys_dlsym() can validly return NULL */
-       error = sys_dlerror();
+       /* we must check dlerror() to determine if it worked, because
+           dlsym() can validly return NULL */
+       error = dlerror();
        if (error) {
                DEBUG(0, ("Error trying to resolve symbol 'init_samba_module' "
                          "in %s: %s\n", module_name, error));
-               sys_dlclose(handle);
+               dlclose(handle);
                return NT_STATUS_UNSUCCESSFUL;
        }
 
@@ -67,7 +65,7 @@ static NTSTATUS do_smb_load_module(const char *module_name, bool is_probe)
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0, ("Module '%s' initialization failed: %s\n",
                            module_name, get_friendly_nt_error_msg(status)));
-               sys_dlclose(handle);
+               dlclose(handle);
        }
 
        return status;
@@ -117,10 +115,10 @@ NTSTATUS smb_probe_module(const char *subsystem, const char *module)
        }
 
        full_path = talloc_asprintf(ctx,
-                       "%s/%s.%s",
-                       modules_path(subsystem),
-                       module,
-                       shlib_ext());
+                                   "%s/%s.%s",
+                                   modules_path(ctx, subsystem),
+                                   module,
+                                   shlib_ext());
        if (!full_path) {
                TALLOC_FREE(ctx);
                return NT_STATUS_NO_MEMORY;
@@ -135,28 +133,6 @@ NTSTATUS smb_probe_module(const char *subsystem, const char *module)
        return status;
 }
 
-#else /* HAVE_DLOPEN */
-
-NTSTATUS smb_load_module(const char *module_name)
-{
-       DEBUG(0,("This samba executable has not been built with plugin support\n"));
-       return NT_STATUS_NOT_SUPPORTED;
-}
-
-int smb_load_modules(const char **modules)
-{
-       DEBUG(0,("This samba executable has not been built with plugin support\n"));
-       return -1;
-}
-
-NTSTATUS smb_probe_module(const char *subsystem, const char *module)
-{
-       DEBUG(0,("This samba executable has not been built with plugin support, not probing\n")); 
-       return NT_STATUS_NOT_SUPPORTED;
-}
-
-#endif /* HAVE_DLOPEN */
-
 void init_modules(void)
 {
        /* FIXME: This can cause undefined symbol errors :