How Db2 loads security plug-ins
So that the Db2 database system has the necessary information to call security plug-in functions, a security plug-in must have a correctly set up initialization function.
- Server side authentication plug-in:
db2secServerAuthPluginInit()
- Client side authentication plug-in:
db2secClientAuthPluginInit()
- Group plug-in:
db2secGroupPluginInit()
- The highest version number of the function pointer structure that the Db2 instance invoking the plug-in can support
- A pointer to a structure containing pointers to all the APIs requiring implementation
- A pointer to a function that adds log messages to the db2diag log files
- A pointer to an error message string
- The length of the error message
SQL_API_RC SQL_API_FN db2secGroupPluginInit(
db2int32 version,
void *group_fns,
db2secLogMessage *logMessage_fn,
char **errormsg,
db2int32 *errormsglen);
extern
"C"
. Db2 relies on the underlying operating system dynamic loader to handle the C++ constructors and
destructors used inside of a C++ user-written plug-in library.- Cast the functions pointer to a pointer to an appropriate functions structure
- Specify the pointers to the other functions in the library
- Specify the version number of the function pointer structure being returned
Db2 can potentially call the plug-in initialization function more than once. This situation can occur when an application dynamically loads the Db2 client library, unloads it, and reloads it again, then performs authentication functions from a plug-in both before and after reloading. In this situation, the plug-in library might not be unloaded and then re-loaded; however, this behavior varies depending on the operating system.
Another example of Db2 issuing multiple calls to a plug-in initialization function occurs during the execution of stored procedures or federated system calls, where the database server can itself act as a client. If the client and server plug-ins on the database server are in the same file, Db2 could call the plug-in initialization function twice.
If the plug-in detects that db2secGroupPluginInit
is
called more than once, it should handle this event as if it was directed
to terminate and reinitialize the plug-in library. As such, the plug-in
initialization function should do the entire cleanup tasks that a
call to db2secPluginTerm
would do before returning
the set of function pointers again.
On a Db2 server running on a UNIX or Linux-based operating system, Db2 can potentially load and initialize plug-in libraries more than once in different processes.