safmgr.c File Reference

ES ESF Manager Startup and Control. More...

Enumerations

enum  { SafUNINITIALIZED = 0, SafRUNNING = 1, SafTERMINATED = 2 }

Functions

BOOL APIENTRY DllMain (HANDLE Inst, DWORD Reason, LPVOID Reserved)
mf_uns32 safmgr (struct SafInit *Init)
 ESF Manager Initialization.
mf_uns32 safterm (mf_uns32 What, void *Reserved)
 ESF Manager Termination.
mf_uns32 safcfg (struct SafInit *Init, void *Reserved)
 ESF Manager Reconfiguration.
mf_uns32 safcfgesm (int Index, struct cas_esm_config_internal *Config, void *Reserved)
 ESM Reconfiguration.
int SafState (void)
 ESF Manager Run State.
SafRet SafQueryCfg (const char *Class, const char *Name, char **ValueP)
 Query ESF Manager Custom Configuration.
mf_uns32 SafNative32u (mf_uns32 NetValue)

Detailed Description

ES ESF Manager Startup and Control.

The ESF Manager API is used to control the ESF Manager; it includes an initialization function, configuration update notification support, and so forth.


Function Documentation

mf_uns32 safmgr ( struct SafInit Init  ) 

ESF Manager Initialization.

This function must be invoked before any other ESF Manager functions are used.

After successful initialization, a subsequent initialization has no effect. If initialization fails, it can be retried after the problem has been corrected.

Warning:
This function is not thread-safe. It must not be called by multiple threads until after initialization has completed successfully (at which point it will have no further effect).
Parameters:
Init A pointer to struct SafInit. On entry the following fields must be set:

  • Version Set to SafMGR_API_VER.
  • Environment Set to one of the predefined values.
  • Config Pointing to the ESF Manager configuration block.
  • ESMCnt Set to the number of configured ESM Modules.
  • ESMCfg Pointing to configuration blocks for ESM Modules.

On return, ESF Manager will have set Reason and Detail. They will be zero for success, non-zero for error. If a failure occurred in an ESM Module's initialization (see the description for SafInit::Detail), ESMCnt will be set to the index (from 0) of the ESM Module that reported the error.

Returns:
An integer value, zero for success and non-zero if initialization failed. See ESF Manager Initialization Return Codes.

References SafInit::Config, SafInit::Detail, SafInit::ESMCfg, SafInit::ESMCnt, SafInit::Reason, SafAllocStore(), SafCacheInit(), SafEnvInit(), SafESM_MAX, SafEsmInit(), SafINIT_BAD_CB, SafINIT_BADENV, SafINIT_CFG, SafINIT_CNT, SafINIT_ENVFUNC, SafINIT_ESMCFG, SafINIT_EXTERNAL, SafINIT_FAIL, SafINIT_NULL, SafINIT_OK, SafINIT_OTHER, SafINIT_RESRCE, SafINIT_VER, SafInitAuditing(), SafLog(), SafMGR_API_VER, SafMGR_FAIL_ENV, SafMGR_FAIL_RESOURCE, SafMsgCRIT, SafProcInit(), SafQueryCfg(), SafR_EXFAIL, SafR_INTERNAL, SafR_NOTFOUND, SafR_PARAM, SafR_RESOURCE, SafR_STATE, SafR_TRUNCATED, SafRaiseAuditEvent(), SafStoreAdd(), SafStoreLoad(), SafThrLock(), SafThrUnlock(), and SafInit::Version.

mf_uns32 safterm ( mf_uns32  What,
void *  Reserved 
)

ESF Manager Termination.

This function should be called when a thread or process that has used ESF is terminating. It will inform the ESM Modules (currently for process exit only), and will perform any necessary cleanup for the Manager itself, including environment-specific cleanup.

Parameters:
[in] What Indicates what is terminating; see "What" Codes for safterm()
Reserved Reserved for future use (pass a null pointer)
Returns:
An integer value, zero for success, non-zero for error. Currently no specific error codes are defined.

References SafCacheTerminate(), SafEsmExit(), SafEsmUnload(), SafR_PARAM, SafRaiseAuditEvent(), SafTERM_ESF, SafTERM_PROCESS, SafThrLock(), and SafThrUnlock().

mf_uns32 safcfg ( struct SafInit Init,
void *  Reserved 
)

ESF Manager Reconfiguration.

This function will be provided in the future to reconfigure ESF without stopping and restarting it. Reconfigurable aspects will probably include options such as auditing, configuration text, and so on.

Currently it's not implemented and will return SafR_NOTIMPL.

Parameters:
Init A pointer to struct SafInit. See safinit() for details.
Reserved Reserved for future use (pass a null pointer)
Returns:
An integer value, zero for success and non-zero if initialization failed. See ESF Manager API Return Codes.

References SafR_NOTIMPL, and SafR_PARAM.

mf_uns32 safcfgesm ( int  Index,
struct cas_esm_config_internal *  Config,
void *  Reserved 
)

ESM Reconfiguration.

This function lets the caller request that one of the ESMs that was configured in the call to safinit() be asked to update its configuration. If the module does not accept reconfiguration requests, or if it returns an error, safcfgesm will return SafR_ESM.

If the module does support reconfiguration, the aspects that can be updated depend on the module. The MLDAP ESM Module currently supports updating the tracing options that are controlled by the [Trace] section in its configuration text.

Note that the caller should pass the entire ESM configuration, including information that the module may not support updating, just as it was passed to safinit() except with the specific changes desired by the caller. That way, if a newer version of the module supports updating additional aspects, an update request won't unexpectedly change the ESM's behavior.

Parameters:
[in] Index Index of the ESM in the list originally passed to safinit(). The first ESM is 0.
[in] Config ESM module configuration block.
Reserved Reserved for future use (pass a null pointer)
Returns:
An integer value, zero for success and non-zero if reconfiguration failed. See ESF Manager API Return Codes.

References SafESM_RECONFIG, SafEsmCControl(), SafESMRC_EXTERNAL, SafESMRC_FAIL, SafESMRC_MGRFAIL, SafESMRC_NOTIMPL, SafESMRC_OK, SafESMRC_PARAM, SafESMRC_RESOURCE, SafR_ESM, SafR_EXFAIL, SafR_INTERNAL, SafR_NOTIMPL, SafR_OK, SafR_PARAM, and SafR_RESOURCE.

int SafState ( void   ) 

ESF Manager Run State.

Returns the run state of ESF Manager (uninitialized, running, terminated).

No parameters

Returns:
An integer value:
  • 0: ESF Manager has not been initialized
  • 1: ESF Manager is running
  • 2: ESF Manager has been terminated

Referenced by SafAdmin(), SafAuth(), SafUpdate(), SafVerify(), and SafXauth().

SafRet SafQueryCfg ( const char *  Class,
const char *  Name,
char **  ValueP 
)

Query ESF Manager Custom Configuration.

MFDS provides a "Configuration Information" text area in each Security Manager configuration object. This area can be used to set custom configuration attributes in "ini" format, with name=value pairs grouped under section headings in square brackets.

This function can be used to query the value associated with a name in a given section.

Parameters:
[in] Class Section heading (without the brackets)
[in] Name Item name
[out] ValueP Returned pointer to value, if any
Returns:
Zero for success or a SafRet value for failure.

References SafStoreFind().

Referenced by EsmSafQuery(), SafAdmin(), SafCacheInit(), SafEsmInit(), safmgr(), SafProcInit(), and SafVerify().