// modload_plugin - loader interface for dynamically loaded plugin modules
//
#include "modload_plugin.h"
+#include <security_cdsa_utilities/cssmerrors.h>
namespace Security {
//
LoadablePlugin::LoadablePlugin(const char *path) : LoadableBundle(path)
{
- secdebug("cssm", "LoadablePlugin(%s)", path);
+ secinfo("cssm", "LoadablePlugin(%s)", path);
+ if (!allowableModulePath(path)) {
+ secinfo("cssm", "LoadablePlugin(): not loaded; plugin in non-standard location: %s", path);
+ CssmError::throwMe(CSSMERR_CSSM_ADDIN_AUTHENTICATE_FAILED);
+ }
load();
}
//
void LoadablePlugin::load()
{
- secdebug("cssm", "LoadablePlugin::load() path %s", path().c_str());
+ secinfo("cssm", "LoadablePlugin::load() path %s", path().c_str());
LoadableBundle::load();
findFunction(mFunctions.load, "CSSM_SPI_ModuleLoad");
findFunction(mFunctions.attach, "CSSM_SPI_ModuleAttach");
void LoadablePlugin::unload()
{
- secdebug("cssm", "LoadablePlugin::unload() path %s", path().c_str());
+ secinfo("cssm", "LoadablePlugin::unload() path %s", path().c_str());
/* skipping for workaround for radar 3774226
LoadableBundle::unload(); */
}
CSSM_SPI_ModuleEventHandler CssmNotifyCallback,
void *CssmNotifyCallbackCtx)
{
- secdebug("cssm", "LoadablePlugin::load(guid,...) path %s", path().c_str());
+ secinfo("cssm", "LoadablePlugin::load(guid,...) path %s", path().c_str());
return mFunctions.load(CssmGuid, ModuleGuid,
CssmNotifyCallback, CssmNotifyCallbackCtx);
}
CSSM_SPI_ModuleEventHandler CssmNotifyCallback,
void *CssmNotifyCallbackCtx)
{
- secdebug("cssm", "LoadablePlugin::unload(guid,...) path %s", path().c_str());
+ secinfo("cssm", "LoadablePlugin::unload(guid,...) path %s", path().c_str());
return mFunctions.unload(CssmGuid, ModuleGuid,
CssmNotifyCallback, CssmNotifyCallbackCtx);
}
return mFunctions.detach(ModuleHandle);
}
+bool LoadablePlugin::allowableModulePath(const char *path) {
+ // True if module path is in default location
+ const char *loadablePrefix="/System/Library/Security/";
+ return (strncmp(loadablePrefix,path,strlen(loadablePrefix)) == 0);
+}
} // end namespace Security