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(PDB_CONTEXT
*pdb_context
, 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_string(plugin_location
, " ", " ");
45 } else plugin_location
= NULL
;
46 trim_string(plugin_name
, " ", " ");
48 DEBUG(5, ("Trying to load sam plugin %s\n", plugin_name
));
49 dl_handle
= sys_dlopen(plugin_name
, RTLD_NOW
);
51 DEBUG(0, ("Failed to load sam plugin %s using sys_dlopen (%s)\n", plugin_name
, sys_dlerror()));
52 return NT_STATUS_UNSUCCESSFUL
;
55 plugin_version
= sys_dlsym(dl_handle
, "pdb_version");
56 if (!plugin_version
) {
57 sys_dlclose(dl_handle
);
58 DEBUG(0, ("Failed to find function 'pdb_version' using sys_dlsym in sam plugin %s (%s)\n", plugin_name
, sys_dlerror()));
59 return NT_STATUS_UNSUCCESSFUL
;
62 if (plugin_version() != PASSDB_INTERFACE_VERSION
) {
63 sys_dlclose(dl_handle
);
64 DEBUG(0, ("Wrong PASSDB_INTERFACE_VERSION! sam plugin has version %d and version %d is needed! Please update!\n",
65 plugin_version(),PASSDB_INTERFACE_VERSION
));
66 return NT_STATUS_UNSUCCESSFUL
;
69 plugin_init
= sys_dlsym(dl_handle
, "pdb_init");
71 sys_dlclose(dl_handle
);
72 DEBUG(0, ("Failed to find function 'pdb_init' using sys_dlsym in sam plugin %s (%s)\n", plugin_name
, sys_dlerror()));
73 return NT_STATUS_UNSUCCESSFUL
;
76 DEBUG(5, ("Starting sam plugin %s with location %s\n", plugin_name
, plugin_location
));
77 return plugin_init(pdb_context
, pdb_method
, plugin_location
);