2 Unix SMB/CIFS implementation.
3 Loadable passdb module interface.
4 Copyright (C) Jelmer Vernooij 2002
5 Copyright (C) Andrew Bartlett 2002
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 NTSTATUS pdb_init_plugin(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_method, const char *location)
27 char *plugin_location, *plugin_name, *p;
28 pdb_init_function plugin_init;
30 if (location == NULL) {
31 DEBUG(0, ("The plugin module needs an argument!\n"));
32 return NT_STATUS_UNSUCCESSFUL;
35 plugin_name = smb_xstrdup(location);
36 p = strchr(plugin_name, ':');
39 plugin_location = p+1;
40 trim_string(plugin_location, " ", " ");
41 } else plugin_location = NULL;
42 trim_string(plugin_name, " ", " ");
44 DEBUG(5, ("Trying to load sam plugin %s\n", plugin_name));
45 dl_handle = sys_dlopen(plugin_name, RTLD_NOW | RTLD_GLOBAL );
47 DEBUG(0, ("Failed to load sam plugin %s using sys_dlopen (%s)\n", plugin_name, sys_dlerror()));
48 return NT_STATUS_UNSUCCESSFUL;
51 plugin_init = sys_dlsym(dl_handle, "pdb_init");
53 DEBUG(0, ("Failed to find function 'pdb_init' using sys_dlsym in sam plugin %s (%s)\n", plugin_name, sys_dlerror()));
54 return NT_STATUS_UNSUCCESSFUL;
57 DEBUG(5, ("Starting sam plugin %s with location %s\n", plugin_name, plugin_location));
58 return plugin_init(pdb_context, pdb_method, plugin_location);