/**
 Old Test CaseID 		APPFWK-SUS-0008
 New Test CaseID 		DEVSRVS-SSMA-SUS-0013
 New Test CaseID 		DEVSRVS-SSMA-SUS-0014
 New Test CaseID 		DEVSRVS-SSMA-SUS-0015
 New Test CaseID 		DEVSRVS-SSMA-SUS-0016
 New Test CaseID 		DEVSRVS-SSMA-SUS-0017
*/
TVerdict CSusPlatsecTest::doTestStepL()
	{
	INFO_PRINTF1(_L("Test to make sure UtilityServer refuse connection for clients with incorrect capabilities"));
	
	__UHEAP_MARK;
	
	RProcess process;
	const TUint32 sid = process.SecureId();
	RThread thread;
	CleanupClosePushL(thread);
	TESTL(KErrNone == StartServer(thread, sid));
	
	//Test the RSession
	RSsmSusCliTest client;
	TInt connect = client.Connect(KTestServerName);
	TEST(KErrPermissionDenied == connect);	
	
	client.Close();
	thread.Kill(KErrNone);
	CleanupStack::PopAndDestroy(&thread);
	
	__UHEAP_MARKEND;
	
	return TestStepResult();
	}
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::StopProcessL
// ----------------------------------------------------------------------------------------
void CTerminalControlServer::StopProcessByUidL ( const TUid& aUID )
{
    RDEBUG("CTerminalControlServer::StopProcessByUidL");

    TInt rounds = 5;

    while( rounds-- )
    {
        TFullName    processName;
        TFindProcess findProcess;
        TInt ret = KErrNone;

        while( KErrNone == ( ret = findProcess.Next( processName ) ) )
        {
            RProcess process;

            if( KErrNone == ( ret = process.Open( findProcess ) ) )
            {
                if( aUID == process.SecureId() )
                {
                    RDEBUG("CTerminalControlServer::StopProcessByUidL Process with correct UID found => Kill(0) ");
                    process.Kill( 0 );
                }
            }
            else
            {
                RDEBUG_2("CTerminalControlServer::StopProcessByUidL process.Open returned %d", ret );
            }
        }
        if( KErrNone != ret )
        {
            RDEBUG_2("CTerminalControlServer::StopProcessByUidL findProcess.Next returned %d", ret );
        }
    }
}
Exemplo n.º 3
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CTraceContainer::IsServerOn()
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)KUidTraceServerUID.iUid)
	 	{
	 		TExitType Exxit =ph.ExitType();
	 		if(Exxit == EExitPending)
	 		{
		  		Ret = ETrue;
		  		break;
	 		}
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Exemplo n.º 4
0
// this is custom security check implemented just for example purposes
// check that client process has secure UID of our UI client application
CPolicyServer::TCustomResult CExPolicy_Server::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/)
{ 
	CPolicyServer::TCustomResult test;
	test=EFail;// by default we will fail the test
	
	RThread ClientThread;
	
	aMsg.Client(ClientThread);// get client thread 
	
	if(ClientThread.Handle())// has handle --> is valid
	{
		RProcess ClientProcess;
		ClientThread.Process(ClientProcess);// then get the process
		
		TSecureId ProsID = ClientProcess.SecureId();// and check secure UID
		
		if(ProsID.iId  == KUidPhoneManager.iUid
		|| ProsID.iId  == KUidLockScreen.iUid)// is it same as with client
		{	
			test=EPass;// pass check if it is, othervise it will fail
		}
	}
	
	return test;
} 
TBool IsBrowser()
    {
    RProcess process;
    TSecureId secId = process.SecureId();
    TUint32 secIdInt = secId;
    
    return ( secIdInt == KUIDBROWSERNG );
    }
/**
Processes the session initiator version info and set the same to session device data store.
*/
void CMTPSetDevicePropValue::CompleteServiceSessionInitiatorVersionInfoL()
	{
	OstTraceFunctionEntry0( CMTPSETDEVICEPROPVALUE_COMPLETESERVICESESSIONINITIATORVERSIONINFOL_ENTRY );
	RProcess process;
	RProperty::Set(process.SecureId(), EMTPConnStateKey, iString->StringChars());
	iDpSingletons.DeviceDataStore().SetSessionInitiatorVersionInfoL(iString->StringChars());
	SendResponseL(EMTPRespCodeOK);
	OstTraceFunctionExit0( CMTPSETDEVICEPROPVALUE_COMPLETESERVICESESSIONINITIATORVERSIONINFOL_EXIT );
	}
void CCryptoPluginsLoader::CreatePluginConfigPropertyL()
{
    RProcess thisProcess;
    // sanity check that feature property category in common header equals SID of this process
    ASSERT(KCryptoSpiPropertyCat == thisProcess.SecureId());
    TSecurityPolicy readPolicy(TSecurityPolicy::EAlwaysPass);
    TSecurityPolicy writePolicy(thisProcess.SecureId());

    TInt count=iPluginNames.Count();
    TInt publishResult=KErrNone;
    for (TInt i=0; i<count; i++)
    {
        publishResult = RProperty::Define(KPluginsConfigurationKey+i, RProperty::EByteArray, readPolicy, writePolicy);
        if ((publishResult == KErrNone) || (publishResult == KErrAlreadyExists))
        {
            TSizeStream ss;
            RWriteStream ws(&ss);
            ws<<iPluginNames[i];

            HBufC8* buf = HBufC8::NewLC(ss.Size());
            TPtr8 bufPtr(buf->Des());
            RDesWriteStream dws(bufPtr);
            dws<<iPluginNames[i];
            dws.CommitL();
            publishResult = RProperty::Set(KCryptoSpiPropertyCat, KPluginsConfigurationKey+i, bufPtr);
            CleanupStack::PopAndDestroy(buf);
        }
        else
        {
            User::Leave(publishResult);
        }
    }
    publishResult = RProperty::Define(KPluginsConfigurationKeyCount, RProperty::EInt, readPolicy, writePolicy);
    if ((publishResult == KErrNone) || (publishResult == KErrAlreadyExists))
    {
        publishResult = RProperty::Set(KCryptoSpiPropertyCat, KPluginsConfigurationKeyCount, count);
    }
    else
    {
        User::Leave(publishResult);
    }
}
void CCryptoPluginsLoader::DoCreateInterfacePropertyL(RWriteStream& aStream, TInt32 aInterface)
{
    RProcess thisProcess;
    // sanity check that feature property category in common header equals SID of this process
    ASSERT(KCryptoSpiPropertyCat == thisProcess.SecureId());
    TSecurityPolicy readPolicy(TSecurityPolicy::EAlwaysPass);
    TSecurityPolicy writePolicy(thisProcess.SecureId());

    TInt publishResult = RProperty::Define(aInterface, RProperty::ELargeByteArray, readPolicy, writePolicy);
    if ((publishResult == KErrNone) || (publishResult == KErrAlreadyExists))
    {
        CCharacteristicDllIndexList** charsListPtr=iInterfaceCharacteristicsMap.Find(aInterface);
        if (charsListPtr)
        {
            (*charsListPtr)->ExternalizeL(aStream);
        }
    }
    else
    {
        User::Leave(publishResult);
    }
}
void RNrhServer::StartLbsL()
	{
    RLbsSystemController systemController;
    RProcess process;
    CleanupClosePushL(process);
	systemController.OpenL(process.SecureId());
	CleanupClosePushL(systemController);
	
	TInt startErr = systemController.RequestSystemStartup();
	if (startErr != ELbsStartupSuccess)
		{
		User::Leave(KErrCouldNotConnect);
		}
	
	CleanupStack::PopAndDestroy(2, &process);
	}
Exemplo n.º 10
0
// -----------------------------------------------------------------------------
// RSatRefresh::Cancel
// Cancels both requests.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C void RSatRefresh::Cancel() const
    {
    LOG( SIMPLE, "SATCLIENT: RSatRefresh::Cancel calling" )
    
    #ifdef ENABLE_SAT_LOGGING
    RProcess test;
    LOG2( SIMPLE, 
    "SATCLIENT: RSatRefresh::Cancel UID of calling process: 0x%x",
    test.SecureId().iId )
    test.Close();
    #endif
    
    CancelNotifyAllowRefresh();
    CancelNotifyRefresh();

    LOG( SIMPLE, "SATCLIENT: RSatRefresh::Cancel exiting" )
    }
Exemplo n.º 11
0
// -----------------------------------------------------------------------------
// RSatRefresh::NotifyFileChangeL
// Starts monitoring refresh events.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C void RSatRefresh::NotifyFileChangeL(
    const TSatRefreshFiles& aObservedFiles )
    {
    LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL(1) calling" )
    
    #ifdef ENABLE_SAT_LOGGING
    RProcess test;
    LOG2( SIMPLE, 
    "SATCLIENT: RSatRefresh::NotifyFileChangeL(1) UID of calling process: 0x%x",
    test.SecureId().iId )
    test.Close();
    #endif
    
    if ( !iAllowMonitor )
        {
        LOG( SIMPLE, 
        "SATCLIENT: RSatRefresh::NotifyFileChangeL(1) iAllowMonitor false" )
        iAllowMonitor = CSatAllowRefreshMonitor::NewL( iObserver, *this );
        iAllowMonitor->ObserveFiles( aObservedFiles );
        iAllowMonitor->Start();
        }
    else
        {
        LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL(1), \
            re-start allowMonitor" )
        iAllowMonitor->ObserveFiles( aObservedFiles );
        iAllowMonitor->Start();
        }

    if ( !iRefreshMonitor )
        {
        LOG( SIMPLE, 
        "SATCLIENT: RSatRefresh::NotifyFileChangeL(1) iRefreshMonitor false" )
        iRefreshMonitor = CSatRefreshMonitor::NewL( *this, iObserver );
        iRefreshMonitor->Start();
        }
    else
        {
        LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL(1), \
            re-start RefreshMonitor" )
        iRefreshMonitor->Start();
        }

    LOG( SIMPLE, "SATCLIENT: RSatRefresh::NotifyFileChangeL(1) exiting" )
    }
Exemplo n.º 12
0
EXPORT_C void RKmsChannel::DeleteUsage(RProcess aDeletor, TKeyHandle aHandle, TInt aOperation, TRequestStatus& aStatus)
/**
	Delete a usage for the supplied key.

 	@param	aDeletor		This process is claiming ownership of the key, and therefore the
							right to delete a usage.
	@param	aHandle			Identifies key in hardware store.
	@param	aOperation		Numeric value identifies operation.
	@param	aStatus			This object is completed when the request has finished.
							On completion it will contain KErrNone on success, or any other
							error code on failure.
 */
	{
	TSecureId sid = aDeletor.SecureId();
	TUsageIdentifierArgs uia = {sid, aHandle, aOperation};
	TUsageIdentifierArgsPckg uiaPckg(uia);
	DoRequest(EDeleteUsage, aStatus, (TAny*) &uiaPckg);
	}
Exemplo n.º 13
0
// -----------------------------------------------------------------------------
// RSatRefresh::OpenL
// Connects a sub-session to SatServer.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C void RSatRefresh::OpenL( const RSatSession& aSession )
    {
    LOG( SIMPLE, "SATCLIENT: RSatRefresh::OpenL calling" )
    
    #ifdef ENABLE_SAT_LOGGING
    RProcess test;
    LOG2( SIMPLE, 
    "SATCLIENT: RSatRefresh::OpenL UID of calling process: 0x%x",
    test.SecureId().iId )
    test.Close();
    #endif

    TIpcArgs arguments( 0, 0, 0, 0 );
    User::LeaveIfError(
        CreateSubSession( aSession, ESatSOpenRefreshSubSession, arguments ) );

    LOG( SIMPLE, "SATCLIENT: RSatRefresh::OpenL exiting" )
    }
Exemplo n.º 14
0
EXPORT_C void RKmsChannel::DeleteKey(RProcess aClaimedOwner, TKeyHandle aHandle, TRequestStatus& aStatus)
/**
	Delete a key from the hardware store.  The key must have been
	created with GenerateKey or StoreKey.
	
	@param	aClaimedOwner	This process is claiming ownership of the key and attempting
							to delete it.
	@param	aHandle			Handle generated by GenerateKey or StoreKey.
	@param	aStatus			This object is completed when the request has finished.
							On completion it will contain KErrNone on success, or any other
							error code on failure.
	@see GenerateKey
	@see StoreKey
 */
	{
	TSecureId sid = aClaimedOwner.SecureId();
	TUint32 handleValue = aHandle.iValue;
	DoRequest(EDeleteKey, aStatus, (TAny*) sid.iId, (TAny*) handleValue);
	}
Exemplo n.º 15
0
// -----------------------------------------------------------------------------
// RSatRefresh::RefreshEFRead
// Indicates client's refresh actions complete.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C void RSatRefresh::RefreshEFRead( TBool aAdditionEFRead ) const
    {
    LOG( SIMPLE, "SATCLIENT: RSatRefresh::RefreshEFRead calling" )
    
    #ifdef ENABLE_SAT_LOGGING
    RProcess test;
    LOG2( SIMPLE, 
    "SATCLIENT: RSatRefresh::RefreshEFRead UID of calling process: 0x%x",
    test.SecureId().iId )
    test.Close();
    #endif
    
    TPckg<TBool> additionEFReadPckg( aAdditionEFRead );
    TIpcArgs arguments( &additionEFReadPckg );

    SendReceive( ESatSRefreshEFRead, arguments );

    LOG( SIMPLE, "SATCLIENT: RSatRefresh::RefreshEFRead exiting" )
    }
void CSleepModeListenerPrivate::RunL()
{
    sleepModeState.Subscribe(iStatus);
    SetActive();
    CHWRMLight::TLightStatus status(CHWRMLight::ELightStatusUnknown);
    RLightStatusArray currentStatus(KHWRMLightMaxTargets);
    TInt err = InitializeStatusArray(currentStatus);
    if (err == KErrNone) {
        TInt arraySize = sizeof(THWRMStatusInfo) * KHWRMLightMaxTargets;
        TPtr8 arrayPtr((TUint8 *)&currentStatus[0], arraySize, arraySize);
        err = sleepModeState.Get(arrayPtr);
        if (err == KErrNone) {
            TInt index = currentStatus.FindInOrder(KHWRMLightFirstTarget, FindByTarget);
            if (index >= 0 && index < KHWRMLightMaxTargets) {
                status = static_cast<CHWRMLight::TLightStatus>(currentStatus[index].iStatus);
                if (!lastStatusValid || lastStatus != status) {
                    lastStatusValid = true;
                    lastStatus = status;
                    RProcess process;
                    // If process is something else than themeserver
                    if (process.SecureId().iId != KHbPsHardwareCoarseOrientationCategoryUid.iUid) {
                        QList<HbMainWindow *> mainWindowList = hbInstance->allMainWindows();
                        for (int i = 0; i < mainWindowList.count(); ++i) {
                            if (status == CHWRMLight::ELightOff) {
                                mainWindowList[i]->broadcastEvent(HbEvent::SleepModeEnter);
                            } else {
                                mainWindowList[i]->broadcastEvent(HbEvent::SleepModeExit);
                            }
                        }
                    } else {
                        HbEvent event(status == CHWRMLight::ELightOff ? HbEvent::SleepModeEnter : HbEvent::SleepModeExit);
                        QCoreApplication::sendEvent(qApp, &event);
                    }
                }
            }
        }
    }

    // Clean up
    currentStatus.Close();
}
Exemplo n.º 17
0
void CPolicyTest::ConstructL(const TTestActionSpec& aTestActionSpec)
	{
	CTestAction::ConstructL(aTestActionSpec);
	iExpectedResult = KErrNone;

	User::LeaveIfError(iFs.Connect());

	RProcess thisProcess;
	User::LeaveIfError(thisProcess.Open(thisProcess.Id()));
	iProcessSecureId = thisProcess.SecureId();
	iProcessVendorId = thisProcess.VendorId();
	thisProcess.Close();
	
	SetTestExeL(Input::ParseElement(aTestActionSpec.iActionBody, KTestExeStart));
	Input::ParseCapabilitySetL(Input::ParseElement(aTestActionSpec.iActionBody, KExcludedCapsStart), iExcludedCaps);
	SetPolicyL(Input::ParseElement(aTestActionSpec.iActionBody, KPolicyStart));
	iPreActions = Input::ParseElement(aTestActionSpec.iActionBody, KPreActionsStart).AllocL();
	SetTestActionL(Input::ParseElement(aTestActionSpec.iActionBody, KPassAcionStart),
				   Input::ParseElement(aTestActionSpec.iActionBody, KFailAcionStart));
	iPostActions = Input::ParseElement(aTestActionSpec.iActionBody, KPostActionsStart).AllocL();
	}
Exemplo n.º 18
0
EXPORT_C void RKmsChannel::AddUsage(RProcess aClaimedOwner, TKeyHandle aHandle, TInt aOperation, const TSecurityPolicy& aSecPol, TRequestStatus& aStatus)
/**
	Add a usage operation and policy for the supplied key.
	
	@param	aClaimedOwner	This process is claiming ownership of the key, and therefore the
							right to add a usage.
	@param	aHandle			Identifies key in hardware store.
	@param	aOperation		Numeric value identifies operation.
	@param	aSecPol			Security policy which should be applied to clients wishing to use
							the supplied key for the supplied operation.
	@param	aStatus			This object is completed when the request has finished.
							On completion it will contain KErrNone on success, or any other
							error code on failure.
 */
	{
	TSecureId sid = aClaimedOwner.SecureId();
	TUsageIdentifierArgs aia = {sid, aHandle, aOperation};
	TUsageIdentifierArgsPckg aiaPckg(aia);
	TPckg<TSecurityPolicy> secPolPckg(aSecPol);
	DoRequest(EAddUsage, aStatus, (TAny*) &aiaPckg, (TAny*) &secPolPckg);
	}
Exemplo n.º 19
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CMgAppUi::IsDrawerOn(void)
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)(KUidServer.iUid))
	 	{
	  		Ret = ETrue;
	  		break;
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Exemplo n.º 20
0
EXPORT_C void RKmsChannel::StoreKey(const TDesC8& aData, RProcess aOwner, TKeyHandle& aHandle, TRequestStatus& aStatus)
/**
	Store a key in the hardware store.  This API is provided to transfer
	keys to hardware if required to use accelerator hardware.  The stored key
	is owned by the identified process, which must delete it when it is no
	longer in use.
	
	@param	aData			Key contents.
	@param	aOwner			Identifies process which will own this key.
	@param	aHandle			On success this is set to the newly-created key's handle.
							Its value is undefined on failure.
	@param	aStatus			This object is completed when the request has finished.
							On completion it will contain KErrNone on success, or any other
							error code on failure.  KErrArgument is returned if the store
							cannot support the supplied key length.
	@see DeleteKey
 */
	{
	TStoreKeyArgs ska = {aOwner.SecureId(), &aHandle};
	TStoreKeyArgsPckg skaPckg(ska);
	DoRequest(EStoreKey, aStatus, (TAny*) &aData, (TAny*) &skaPckg);
	}
Exemplo n.º 21
0
EXPORT_C void RKmsChannel::GenerateKey(
	TInt aLength, RProcess aOwner, TKeyHandle& aHandle, TRequestStatus& aStatus)
/**
	Generate a key and store it in the hardware.  The generated key is owned by
	the identified process, which must delete it when it is no longer in use.
	
	@param	aLength			Length of new key in bytes.
	@param	aOwner			Identifies process which will own this key.
	@param	aHandle			On success this is set to the newly-created key's handle.
							Its value is undefined on failure.
	@param	aStatus			This object is completed when the request has finished.
							On completion it will contain KErrNone on success, or any other
							error code on failure.  KErrArgument is returned if the store
							cannot support the supplied key length.
	@return					
	@see DeleteKey
 */
	{
	TGenKeyArgs gka = {aLength, aOwner.SecureId(), &aHandle};
	TGenKeyArgsPckg gkaPckg(gka);
	DoRequest(EGenerateKey, aStatus, (TAny*) &gkaPckg);
	}
Exemplo n.º 22
0
/*
-----------------------------------------------------------------------------
----------------------------------------------------------------------------
*/
TBool CCrashContainer::IsServerOn()
{
	TBool Ret(EFalse);
	
	TFileName res;
	TFindProcess find;
  	while(find.Next(res) == KErrNone)
    {
    	RProcess ph;
	  	ph.Open(res);
	  	  			
	  	if(ph.SecureId() == (TUint32)KUidCrashServerUID.iUid)
	 	{
	  		Ret = ETrue;
	  		break;
	  	}
	  	
	  	ph.Close();
    }
 
    return Ret;
}
Exemplo n.º 23
0
// -----------------------------------------------------------------------------
// RSatRefresh::Close
// Closes the sub-session
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C void RSatRefresh::Close()
    {
    LOG( SIMPLE, "SATCLIENT: RSatRefresh::Close calling" )
    
    #ifdef ENABLE_SAT_LOGGING
    RProcess test;
    LOG2( SIMPLE, 
    "SATCLIENT: RSatRefresh::Close UID of calling process: 0x%x",
    test.SecureId().iId )
    test.Close();
    #endif

    delete iRefreshMonitor;
    delete iAllowMonitor;

    iRefreshMonitor = NULL;
    iAllowMonitor = NULL;

    CloseSubSession( ESatSCloseRefreshSubSession );

    LOG( SIMPLE, "SATCLIENT: RSatRefresh::Close exiting" )
    }
Exemplo n.º 24
0
// ----------------------------------------------------------------------------
// Searches process id for target selector plugin.
// When the player has been opened in a mode, which is bound to the same engine
// than certain application's engine, then need to fetch its process id.
// (As a reference for parameter aMode see MMPXPlaybackUtility modes.)
// Otherwise target selector plugin is notified wrongly about registered client
// and key events are not propagated to correct application.
// ----------------------------------------------------------------------------
//
static void FindProcessIdForTsp( TInt aMode, TProcessId& aProcessId )
    {
    TBool processFound( EFalse );
    TFindProcess processFinder;
    TFullName processName;

    while ( processFinder.Next( processName ) == KErrNone && !processFound )
        {
        RProcess process;
        TInt err = process.Open( processFinder );
        if( err == KErrNone )
            {
            if( process.SecureId().iId == aMode && process.ExitType() == EExitPending )
                {
                MPX_DEBUG4("FindProcessIdForTsp(): pid changed from %d to %d (mode 0x%x)",
                           TUint(aProcessId), TUint(process.Id()), aMode);
                aProcessId = process.Id();
                processFound = ETrue;
                }
            process.Close();
            }
        }
    }
Exemplo n.º 25
0
// this is custom security check implemented just for example purposes
// check that client process has secure UID of our UI client application
CPolicyServer::TCustomResult CExPolicy_Server::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/)
{ 
	if(iFile.SubSessionHandle())
	{
		iFile.Write(_L8("Security test\n,"));
	}
	
	CPolicyServer::TCustomResult test;
	test=EFail;// by default we will fail the test
	
	RThread ClientThread;
	
	aMsg.Client(ClientThread);// get client thread 
	
	if(ClientThread.Handle())// has handle --> is valid
	{
		RProcess ClientProcess;
		ClientThread.Process(ClientProcess);// then get the process
		
		TSecureId ProsID = ClientProcess.SecureId();// and check secure UID
		
		if(ProsID.iId  == (TUint32)KMAINYTasksUid31.iUid
		|| ProsID.iId  == (TUint32)KMAINYTasksUid32.iUid
		|| ProsID.iId  == (TUint32)KMAINYTasksUid33.iUid
		|| ProsID.iId  == (TUint32)KMAINYTasksUid34.iUid)// is it same as with client
		{	
			if(iFile.SubSessionHandle())
			{
				iFile.Write(_L8("Passed\n,"));
			}
			test=EPass;// pass check if it is, othervise it will fail
		}
	}
	
	return test;
} 
Exemplo n.º 26
0
	void CABDataOwner::ConstructL()
		{
		RProcess process;
		iID = process.SecureId();
		process.Close();
		iABClient = NULL;
		
		iCallback = CABDataOwnerCallbackImplementation::NewL(iID);
		
		iProperty.Attach(TUid::Uid(KUidSystemCategoryValue), KUidBackupRestoreKey);
		TInt backupInfo = 0;
		iProperty.Get(backupInfo);
		if ((backupInfo & KBURPartTypeMask) != EBURNormal || (backupInfo & KBURPartTypeMask) != EBURUnset)
			{
			iABClient = CActiveBackupClient::NewL(iCallback);
			iCallback->SetABClient(iABClient);
				
			// Confirm that this data owner is ready for backup/restore operations
			iABClient->ConfirmReadyForBURL(KErrNone);
			// do nothing
			__LOG1("[0x%08x]: In Backup/Restore: ConfirmReadyForBUR", iID.iId);
			}
		__LOG1("[0x%08x]: ABTester ConstructL", iID.iId);
		}
// ----------------------------------------------------------------------------------------
// CTerminalControlServer::GetRunningProcessesL
// ----------------------------------------------------------------------------------------
CBufFlat* CTerminalControlServer::GetRunningProcessesL( )
{
    RDEBUG("CTerminalControlServer::GetRunningProcessesL");

    TFullName    processName;
    TFindProcess findProcess;
    CBufFlat *buffer = CBufFlat::NewL(128);
    iProcessInfoArray->Reset();

    while( KErrNone == findProcess.Next( processName ) )
    {
        TTcProcessInfo info;
        RProcess process;

        if( KErrNone == process.Open( findProcess ) )
        {
            //
            // Add process information to local array
            //
            info.iProcessName = processName;
            info.iFileName    = process.FileName();

            info.iHandle      = process.Handle();
            info.iId          = process.Id();
            info.iSecureId    = process.SecureId();

            info.iProtected   = EFalse;

            process.GetMemoryInfo( info.iMemoryInfo );

            User::IsRomAddress( info.iCodeInRom, (TAny*)(info.iMemoryInfo.iCodeBase) );
            if( !info.iCodeInRom )
            {
                User::IsRomAddress( info.iCodeInRom, (TAny*)(info.iMemoryInfo.iCodeBase) );
            }

            iProcessInfoArray->AppendL( info );

            //
            // Add process also to return buffer
            //
            /*
            TInt appendPosition = buffer->Size();
            if(iProcessInfoArray->Count() >= 2)
                {
                TBuf8<sizeof(info.iProcessName)> proName;
                proName.Copy(info.iProcessName);
                buffer->InsertL(appendPosition, _L8("/"));
                buffer->InsertL(appendPosition+1, proName);
                }
            else
                {
                TBuf8<sizeof(info.iProcessName)> proName;
                proName.Copy(info.iProcessName);
                buffer->InsertL(appendPosition, proName);
                }
            }

            */

            // Enumerate names from 1
            TInt appendPosition = buffer->Size();
            TBuf8<MAX_NUMBER_OF_DIGITS_IN_10BASE_INT64> numBuf;
            TBuf8<sizeof(KFormatProcessNamePrefix)+20> nameBuf;

            numBuf.Num(iProcessInfoArray->Count());
            nameBuf.Zero();
            nameBuf.Append(KFormatProcessNamePrefix);
            nameBuf.Append(numBuf);

            if(iProcessInfoArray->Count() >= 2)
            {
                buffer->InsertL(appendPosition, _L8("/"));
                buffer->InsertL(appendPosition+1, nameBuf);
            }
            else
            {
                buffer->InsertL(appendPosition, nameBuf);
            }
        }
    }
    /*
    	TUint32 flags = Exec::ProcessFlags(KCurrentProcessHandle);
    	if (flags & KProcessFlagSystemPermanent)
    		return ESystemPermanent;
    	if (flags & KProcessFlagSystemCritical)
    		return ESystemCritical;
    	if (flags & KThreadFlagProcessPermanent)
    		return EAllThreadsCritical;
    	return ENotCritical;
    */
    return buffer;
}
// ---------------------------------------------------------------------------
// CEmailInterfaceFactoryImpl::AppendOrRemoveUidL
// ---------------------------------------------------------------------------
void CEmailInterfaceFactoryImpl::AppendOrRemoveUidL(
        const TEmailUidAppendRemoveMode aMode )
    {
    // Read buffer length
    TInt bufLength( 0 );
    User::LeaveIfError( RProperty::Get( KEmailShutdownPsCategory,
                                        EEmailPsKeyPlatformApiAppsToCloseLength,
                                        bufLength ) );

    // Allocate buffer for reading and then read the list of UIDs from P&S.
    // Adding some extra buffer just in case the size key and actual list
    // are out of sync. This shouldn't happen, but you never know.
    HBufC8* readBuf = HBufC8::NewLC( bufLength + KEmailUidExtraBuffer );
    TPtr8 readPtr = readBuf->Des();
    
    User::LeaveIfError( RProperty::Get( KEmailShutdownPsCategory,
                                        EEmailPsKeyPlatformApiAppsToClose,
                                        readPtr ) );
    
    // For writing get the size of the original buffer + room for our own UID
    // if needed
    TInt writeBufSize = readPtr.Length();
    if( aMode == EEmailUidModeAppend )
        {
        writeBufSize += KEmailPlatformApiUidItemSize;
        }
    
    HBufC8* writeBuf = HBufC8::NewLC( writeBufSize );
    TPtr8 writePtr = writeBuf->Des();

    // Read and write streams used to read/write the UIDs from/to descriptors
    RDesReadStream readStream( readPtr );
    CleanupClosePushL( readStream );

    RDesWriteStream writeStream( writePtr );
    CleanupClosePushL( writeStream );

    // Get our own process UID
    RProcess ownProcess;
    TUid ownUid = ownProcess.SecureId();
    ownProcess.Close();

    TInt itemsCount = readPtr.Length() / KEmailPlatformApiUidItemSize;

    TBool ownUidFound = EFalse;
    TInt writeLength = 0;
    for ( TInt ii = 0;ii < itemsCount; ++ii )
        {
        // Read next UID from the stream
        TUid item = TUid::Uid( readStream.ReadInt32L() );
        
        // We can skip our own UID. If we are removing, then we don't want
        // our UID to be written. If we are adding, we don't need to set
        // the new values as our UID already exists in the list.
        if( item == ownUid )
            {
            ownUidFound = ETrue;
            if( aMode == EEmailUidModeAppend )
                {
                // Our own UID is already in the list, so no need to update
                // the list. Hence we can quit here.
                break;
                }
            }
        else
            {
            writeStream.WriteInt32L( item.iUid );
            writeLength += KEmailPlatformApiUidItemSize;
            }
        }

    // If we are appending our UID and it wasn't found from the list,
    // write it to the stream
    if( aMode == EEmailUidModeAppend && !ownUidFound )
        {
        writeStream.WriteInt32L( ownUid.iUid );
        writeLength += KEmailPlatformApiUidItemSize;
        }

    // Set correct length for the write ptr buffer as it might not be
    // updated correctly by the write stream
    writePtr.SetLength( writeLength );

    // Set new values to P&S only if something has changed, so either:
    // 1) We are appending our UID and it didn't exist before
    // 2) We are removing our UID and it did exist before
    if( ( aMode == EEmailUidModeAppend && !ownUidFound ) ||
        ( aMode == EEmailUidModeRemove && ownUidFound ) )
        {
        // Write first the UID list as it is more probable to fail, writing
        // plain integer value shouldn't fail in any case. This way these
        // values stay in sync also in case of error, as the list length
        // gets updated only if the list itself is updated succesfully.
        User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory,
                        EEmailPsKeyPlatformApiAppsToClose,
                        writePtr ) );

        User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory,
                        EEmailPsKeyPlatformApiAppsToCloseLength,
                        writeLength ) );
        }

    CleanupStack::PopAndDestroy( 4, readBuf );
    }
Exemplo n.º 29
0
LOCAL_C void mainL()
	{
	CCommandLineArguments* cmdLine = CCommandLineArguments::NewLC();
	TInt argTotal=cmdLine->Count();
	if (argTotal < 2 || argTotal > 3)
		{
		User::Leave(KErrArgument);
		}
	TUint sidRequested;
	TLex processLex(cmdLine->Arg(1));
	User::LeaveIfError(processLex.Val(sidRequested, EHex));
	if (sidRequested == 0)
		{
		User::Leave(KErrArgument);
		}
	
	if (argTotal == 3)
		{
		TUint timeout;
		TLex timeoutLex(cmdLine->Arg(2));
		User::LeaveIfError(timeoutLex.Val(timeout));
		if (timeout > 0)
			{
			User::After(timeout);
			}
		}

	TUid sid = {sidRequested};
	TBool needToScanFullList;
	TFullName fullName;

	do
		{
		needToScanFullList = EFalse;
		TFindProcess findProcess;

		while(findProcess.Next(fullName) == KErrNone)
			{
			RProcess process;
			TInt ret=KErrNone;
			TInt count=0;
			do
			{
			count++;
 			ret=process.Open(findProcess);
			if (ret!=KErrNone)
				{
				User::After(200000);
				}
			}while (ret!=KErrNone && count<=10);
			if (ret!=KErrNone)
				{
				User::Leave(ret);
				}

			TUid processSid(process.SecureId());
			if (processSid == sid && process.ExitType() == EExitPending)
				{
				process.Kill(KErrNone);
				needToScanFullList = ETrue;
				}
			process.Close();
			}
		} while (needToScanFullList);

	CleanupStack::PopAndDestroy(cmdLine);
	}
// -----------------------------------------------------------------------------
// CHttpCacheManager::CreateCacheHandlersL
//
// -----------------------------------------------------------------------------
//
void CHttpCacheManager::CreateCacheHandlersL()
    {
    // get our SID.
    RProcess process;
    TSecureId secId = process.SecureId();
    TUint32 secIdInt = secId;

    CRepository* repository = CRepository::NewLC(KCRUidCacheManager);
    CRepository* repositoryDiskLevel = CRepository::NewLC(KCRUidDiskLevel);

    // Get Cache Postpone Parameters.
    THttpCachePostponeParameters postpone;
    TBool newCentrepPresent;
    GetPostponeParamsL( newCentrepPresent, postpone, repository );

    // apply default cache configuration - no cache for anyone, sizes set to default.
    iCacheEnabled = EFalse;
    TInt cacheSize( KDefaultCacheSize );
    iCacheFolder.Copy( KDefaultCacheDir );
   
    TBool opCacheEnabled( EFalse );
    iOperatorCache = 0;
    TInt opCacheSize = KDefaultOperatorCacheSize;
    TFileName opCacheFolder( KDefaultOperatorCacheDir );
    
    iVSSCacheEnabled = EFalse;
    TInt vssCacheSize = KDefaultOperatorCacheSize;
    TFileName vssCacheFolder( KDefaultVssCacheDir );

    if(newCentrepPresent)
        {
        // if the new Centrep file is present, we trust it's configured properly.
        GetHttpCacheConfigL( *repository, iCacheEnabled, cacheSize, iCacheFolder );
        GetOperatorCacheConfigL( *repository, opCacheEnabled, opCacheSize, opCacheFolder );
        GetVSSCacheConfigL( *repository, iVSSCacheEnabled, vssCacheSize, vssCacheFolder );
        }
    
    // look for per-process overrides in central repository.  Do this before we get drive critical levels so we're on the right
    // drive.
    // This has a default string which applies the new per-client default configuration
    ApplyCacheOverridesL(*repository, secIdInt, iCacheEnabled, cacheSize, opCacheEnabled, iVSSCacheEnabled, iCacheFolder, KDefaultCacheDrive());

    TInt criticalLevel = 0;
    GetCriticalDriveLevelsL( *repositoryDiskLevel, iCacheFolder, criticalLevel );
    
    // Create any caches we should be using.
    if (iCacheEnabled)
        {
        CreateHttpCacheL( secIdInt, cacheSize, criticalLevel, postpone );

        if (opCacheEnabled)
            {
            CreateOperatorCacheL( *repository, opCacheFolder, opCacheSize, criticalLevel, postpone );
            }
        } //end if( iCacheEnabled )

    if ( iVSSCacheEnabled )
        {
        CreateVssCacheL( *repository, vssCacheFolder, vssCacheSize, criticalLevel, postpone );
        }

    CleanupStack::PopAndDestroy(2); // repository, repositoryDiskLevel
    CrashCheckL( secIdInt );
    }