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.
25
#define DBGC_CLASS DBGC_PASSDB
27
NTSTATUS pdb_init_plugin(struct pdb_methods **pdb_method, const char *location)
30
char *plugin_location, *plugin_name, *p;
31
pdb_init_function plugin_init;
32
int (*plugin_version)(void);
34
if (location == NULL) {
35
DEBUG(0, ("The plugin module needs an argument!\n"));
36
return NT_STATUS_UNSUCCESSFUL;
39
plugin_name = smb_xstrdup(location);
40
p = strchr(plugin_name, ':');
43
plugin_location = p+1;
44
trim_char(plugin_location, ' ', ' ');
46
plugin_location = NULL;
48
trim_char(plugin_name, ' ', ' ');
50
DEBUG(5, ("Trying to load sam plugin %s\n", plugin_name));
51
dl_handle = sys_dlopen(plugin_name, RTLD_NOW );
53
DEBUG(0, ("Failed to load sam plugin %s using sys_dlopen (%s)\n", plugin_name, sys_dlerror()));
54
return NT_STATUS_UNSUCCESSFUL;
57
plugin_version = sys_dlsym(dl_handle, "pdb_version");
58
if (!plugin_version) {
59
sys_dlclose(dl_handle);
60
DEBUG(0, ("Failed to find function 'pdb_version' using sys_dlsym in sam plugin %s (%s)\n", plugin_name, sys_dlerror()));
61
return NT_STATUS_UNSUCCESSFUL;
64
if (plugin_version() != PASSDB_INTERFACE_VERSION) {
65
sys_dlclose(dl_handle);
66
DEBUG(0, ("Wrong PASSDB_INTERFACE_VERSION! sam plugin has version %d and version %d is needed! Please update!\n",
67
plugin_version(),PASSDB_INTERFACE_VERSION));
68
return NT_STATUS_UNSUCCESSFUL;
71
plugin_init = sys_dlsym(dl_handle, "pdb_init");
73
sys_dlclose(dl_handle);
74
DEBUG(0, ("Failed to find function 'pdb_init' using sys_dlsym in sam plugin %s (%s)\n", plugin_name, sys_dlerror()));
75
return NT_STATUS_UNSUCCESSFUL;
78
DEBUG(5, ("Starting sam plugin %s with location %s\n", plugin_name, plugin_location));
79
return plugin_init(pdb_method, plugin_location);