/*----------------------------------------------------------------------- * File: MODINSTALL.C * * Copyright (c) 1995-2000 Intel Corporation. All rights reserved. *----------------------------------------------------------------------- */ #include #include #include "cssm.h" #include "cssmerr.h" #include "cssmport.h" #include "cssmlock.h" #include "maf_config.h" #include "maf_collectn.h" #include "maf_util.h" #include "guids.h" #include "mds.h" #include "mds_schema.h" #include "mds_util.h" #ifdef VMS #include "installdefs.h" #else #include "intel/installdefs.h" #endif /* Number of MDS update operations that will be remembered by mds_util for * error clean-up during installation. */ #define EMM_ADDIN_MDS_COMMIT_SIZE 150 static CSSM_RETURN __CleanMDS( MDSU_CONTEXT *pContext ) { CSSM_RETURN rv = CSSM_OK; MDSU_CDSA_COMMON_SCHEMA CommonTemplate; MDSU_CDSA_COMMON_SCHEMA CommonData; /* * Execute a search on every dummy EMM addin record type to * get a handle of all records and then delete them. */ /* Common Schema */ CommonTemplate.ModuleID = ADDIN_GUID; rv = MDSU_FindFirst( pContext, &IfiMdsuCdsadirCommonSchema, &CommonTemplate, MDSU_COM_MODULE_ID, &CommonData, NULL ); while ( rv == CSSM_OK ) { if ( CommonData.Manifest.Data ) { MDSU_free( pContext, CommonData.Manifest.Data ); } rv = MDSU_FindNext( pContext, &CommonData, NULL ); } if ( rv == CSSMERR_DL_ENDOFDATA ) { /* Flush everything from the MDS */ rv = MDSU_Revert( pContext ); } /* Make sure nothing gets removed if there is an error */ if ( ( rv != CSSMERR_DL_ENDOFDATA ) && ( rv != CSSM_OK ) ) { MDSU_Commit( pContext ); } return rv; } CSSM_RETURN CSSMAPI INSTALL_ENTRY_NAME( const char *szModuleName, const char *szSearchPath, CSSM_DATA *pCredential, INSTALL_ACTION Action, INSTALL_ERROR *pError ) { CSSM_RETURN rv = CSSM_OK; MDSU_CONTEXT MDSUContext; MDSU_CDSA_COMMON_SCHEMA Common; /* Initialize the MDS update */ if ( ( rv = MDSU_Init( &MDSUContext, &Addin_APIMemFuncs, &ADDIN_GUID, MDS_CDSA_DIRECTORY, ( CSSM_DB_ACCESS_READ | CSSM_DB_ACCESS_WRITE ), EMM_ADDIN_MDS_COMMIT_SIZE ) ) != CSSM_OK ) { sprintf( pError->ErrorString, "MDS Error (Init): %X\n", rv ); pError->ErrorCode = rv; return rv; } if ( ( rv = __CleanMDS( &MDSUContext ) ) != CSSM_OK ) { sprintf( pError->ErrorString, "MDS Error (Clean): %X\n", rv ); pError->ErrorCode = rv; MDSU_Term( &MDSUContext ); return rv; } if ( Action == INSTALL_ACTION_UNINSTALL ) { MDSU_Term( &MDSUContext ); return rv; } /* Fill in the common schema structure */ memcpy( &Common.ModuleID, &ADDIN_GUID, sizeof(ADDIN_GUID) ); Common.Manifest = *pCredential; strcpy( Common.ModuleName, szModuleName ); strcpy( Common.Path, szSearchPath ); Common.CDSAVersion.Major = CSSM_MAJOR; Common.CDSAVersion.Minor = CSSM_MINOR; strcpy( Common.Desc, ADDIN_NAME ); Common.DynamicFlag = CSSM_FALSE; Common.MultiThreadFlag = CSSM_FALSE; Common.ServiceMask = CSSM_SERVICE_EMM_DUMMY; /* Insert the common schema record into the MDS */ rv = MDSU_UpdateSchema( &MDSUContext, &IfiMdsuCdsadirCommonSchema, &Common, NULL ); if ( rv != CSSM_OK ) { sprintf( pError->ErrorString, "MDS Error (common-dummy EMM addin): %X\n", rv ); pError->ErrorCode = rv; MDSU_Term( &MDSUContext ); return rv; } /* Commit the records */ MDSU_Commit( &MDSUContext ); /* Shut down the MDS connection */ MDSU_Term( &MDSUContext ); return CSSM_OK; }