kerneltest/e32test/rm_debug/trk_blocking/t_trkdummyapp.cpp
branchRCL_3
changeset 21 e7d2d738d3c2
equal deleted inserted replaced
20:597aaf25e343 21:e7d2d738d3c2
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Ensure that old insecure Trk debug agent cannot be installed
       
    15 // as it should be blocked from SWInstall'ing by a trkdummyapp.exe contained within
       
    16 // the base OS with the same SID as the insecure Trk.
       
    17 // 
       
    18 //
       
    19 
       
    20 #include <e32base.h>
       
    21 #include <e32base_private.h>
       
    22 #include <e32cons.h>
       
    23 #include <e32test.h>
       
    24 #include <e32ldr.h>
       
    25 #include <e32cmn.h>
       
    26 #include <e32cmn_private.h>
       
    27 #include <f32dbg.h>
       
    28 #include <f32file.h>
       
    29 #include "t_trkdummyapp.h"
       
    30 
       
    31 LOCAL_D RTest test(_L("T_TRKDUMMYAPP"));
       
    32 
       
    33 CTrkDummyAppTest::CTrkDummyAppTest()
       
    34 //
       
    35 // CTrkDummyAppTest constructor
       
    36 //
       
    37 	{
       
    38 	// nothing to do
       
    39 	}
       
    40 
       
    41 CTrkDummyAppTest* CTrkDummyAppTest::NewL()
       
    42 //
       
    43 // CRunModeAgent::NewL
       
    44 //
       
    45 	{
       
    46 	CTrkDummyAppTest* self = new(ELeave) CTrkDummyAppTest();
       
    47 
       
    48   	self->ConstructL();
       
    49 
       
    50 	return self;
       
    51 	}
       
    52 
       
    53 CTrkDummyAppTest::~CTrkDummyAppTest()
       
    54 //
       
    55 // CTrkDummyAppTest destructor
       
    56 //
       
    57 	{
       
    58 	// Nothing to do
       
    59 	}
       
    60 
       
    61 void CTrkDummyAppTest::ConstructL()
       
    62 //
       
    63 // CTrkDummyAppTest::ConstructL
       
    64 //
       
    65 	{
       
    66 	// nothing to do here
       
    67 	}
       
    68 
       
    69 
       
    70 CTrkDummyAppTest *TrkDummyTest;
       
    71 
       
    72 //----------------------------------------------------------------------------------------------
       
    73 //! @SYMTestCaseID      KBase-T-TRKDUMMYAPP-0792
       
    74 //! @SYMTestType        
       
    75 //! @SYMPREQ            PREQ1426
       
    76 //! @SYMTestCaseDesc    Tests that a known insecure debug agent trkapp.sis cannot be installed
       
    77 //!                     by ensuring the existence of a Symbian OS common app called trkdummyapp.exe
       
    78 //!                     already exists with the same Secure ID as the insecure app.
       
    79 //! @SYMTestActions     
       
    80 //!    
       
    81 //!     1.              Calls RProcess.Create() on z:\sys\bin\trkdummyapp.exe. Fail if unsuccessful.
       
    82 //!     
       
    83 //!     2.              Obtain the Secure ID of the process derived from z:\sys\bin\trkdummyapp.exe.
       
    84 //!
       
    85 //!     3.              Close the process derived from z:\sys\bin\trkdummyapp.exe.
       
    86 //!
       
    87 //! @SYMTestExpectedResults 
       
    88 //!
       
    89 //!     1.              Fails if unable to create a process from z:\sys\bin\trkdummyapp.exe.
       
    90 //!
       
    91 //!     2.              The Secure ID of trkdummyapp.exe has the Secure ID 0x101F7159. Fail otherwise.
       
    92 //! 
       
    93 //! @SYMTestPriority        High
       
    94 //! @SYMTestStatus          Implemented
       
    95 //----------------------------------------------------------------------------------------------
       
    96 
       
    97 // Names of some test programs used for testing security
       
    98 _LIT(KRMDebugSecurityTrkDummyApp,"z:\\sys\\bin\\trkdummyapp.exe");
       
    99 
       
   100 void CTrkDummyAppTest::TestSecurityCheckPreventInsecureTrkDebugAgent(void)
       
   101 	{
       
   102 
       
   103 	test.Next(_L("TestSecurityCheckPreventInsecureTrkDebugAgent, SID 0x101F7159\n"));
       
   104 
       
   105 	RProcess process;
       
   106 	TInt err = process.Create(KRMDebugSecurityTrkDummyApp, KNullDesC, EOwnerProcess);
       
   107 	test (err == KErrNone);
       
   108 
       
   109 	// rendezvous with process
       
   110 	TRequestStatus status;
       
   111 	process.Rendezvous(status);
       
   112 
       
   113 	// obtain the secure ID for the process
       
   114 	TSecurityInfo secInfo(process);
       
   115 
       
   116 	static const TSecureId KTrkDummyAppSID = 0x101F7159;
       
   117 
       
   118 	test(secInfo.iSecureId.iId == KTrkDummyAppSID);
       
   119 
       
   120 	// Kill the process, as we don't need it anymore
       
   121 	process.Kill(KErrNone);
       
   122 
       
   123 	process.Close();
       
   124 	}
       
   125 
       
   126 //----------------------------------------------------------------------------------------------
       
   127 //! @SYMTestCaseID      KBase-T-TRKDUMMYAPP-0793
       
   128 //! @SYMTestType        
       
   129 //! @SYMPREQ            PREQ1426
       
   130 //! @SYMTestCaseDesc    Tests that a known insecure debug agent trkapp.sis cannot be installed
       
   131 //!                     by ensuring the existence of a Symbian OS common app called trkdummyapp.exe
       
   132 //!                     already exists with the same Secure ID as the insecure app.
       
   133 //! @SYMTestActions     
       
   134 //!    
       
   135 //!     1.              Calls RProcess.Create() on z:\sys\bin\trkdummyapp2.exe. Fail if unsuccessful.
       
   136 //!     
       
   137 //!     2.              Obtain the Secure ID of the process derived from z:\sys\bin\trkdummyapp2.exe.
       
   138 //!
       
   139 //!     3.              Close the process derived from z:\sys\bin\trkdummyapp2.exe.
       
   140 //!
       
   141 //! @SYMTestExpectedResults 
       
   142 //!
       
   143 //!     1.              Fails if unable to create a process from z:\sys\bin\trkdummyapp2.exe.
       
   144 //!
       
   145 //!     2.              The Secure ID of trkdummyapp.exe has the Secure ID 0x2000a7dd. Fail otherwise.
       
   146 //! 
       
   147 //! @SYMTestPriority        High
       
   148 //! @SYMTestStatus          Implemented
       
   149 //----------------------------------------------------------------------------------------------
       
   150 
       
   151 // Names of some test programs used for testing security
       
   152 _LIT(KRMDebugSecurityTrkDummyApp2,"z:\\sys\\bin\\trkdummyapp2.exe");
       
   153 
       
   154 void CTrkDummyAppTest::TestSecurityCheckPreventInsecureTrkDebugAgent2(void)
       
   155 	{
       
   156 
       
   157 	test.Next(_L("TestSecurityCheckPreventInsecureTrkDebugAgent2, SID 0x2000a7dd\n"));
       
   158 
       
   159 	RProcess process;
       
   160 	TInt err = process.Create(KRMDebugSecurityTrkDummyApp2, KNullDesC, EOwnerProcess);
       
   161 	test (err == KErrNone);
       
   162 
       
   163 	// rendezvous with process
       
   164 	TRequestStatus status;
       
   165 	process.Rendezvous(status);
       
   166 
       
   167 	// obtain the secure ID for the process
       
   168 	TSecurityInfo secInfo(process);
       
   169 
       
   170 	static const TSecureId KTrkDummyAppSID2 = 0x2000a7dd;
       
   171 
       
   172 	test(secInfo.iSecureId.iId == KTrkDummyAppSID2);
       
   173 
       
   174 	// Kill the process, as we don't need it anymore
       
   175 	process.Kill(KErrNone);
       
   176 
       
   177 	process.Close();
       
   178 	}
       
   179 
       
   180 //----------------------------------------------------------------------------------------------
       
   181 //! @SYMTestCaseID      KBase-T-TRKDUMMYAPP-2396
       
   182 //! @SYMTestType        
       
   183 //! @SYMPREQ            PREQ1426
       
   184 //! @SYMTestCaseDesc    Tests that a known insecure debug agent trkapp.sis cannot be installed
       
   185 //!                     by ensuring the existence of a Symbian OS common app called trkdummyapp200159D8.exe
       
   186 //!                     already exists with the same Secure ID as the insecure app.
       
   187 //! @SYMTestActions     
       
   188 //!    
       
   189 //!     1.              Calls RProcess.Create() on z:\sys\bin\trkdummyapp200159D8.exe. Fail if unsuccessful.
       
   190 //!     
       
   191 //!     2.              Obtain the Secure ID of the process derived from z:\sys\bin\trkdummyapp200159D8.exe.
       
   192 //!
       
   193 //!     3.              Close the process derived from z:\sys\bin\trkdummyapp200159D8.exe.
       
   194 //!
       
   195 //! @SYMTestExpectedResults 
       
   196 //!
       
   197 //!     1.              Fails if unable to create a process from z:\sys\bin\trkdummyapp200159D8.exe.
       
   198 //!
       
   199 //!     2.              The Secure ID of trkdummyapp200159D8.exe has the Secure ID 0x200159D8. Fail otherwise.
       
   200 //! 
       
   201 //! @SYMTestPriority        High
       
   202 //! @SYMTestStatus          Implemented
       
   203 //----------------------------------------------------------------------------------------------
       
   204 
       
   205 // Names of some test programs used for testing security
       
   206 _LIT(KRMDebugSecurityTrkDummyApp200159D8,"z:\\sys\\bin\\trkdummyapp200159D8.exe");
       
   207 
       
   208 void CTrkDummyAppTest::TestSecurityCheckPreventInsecureTrkDebugAgent200159D8(void)
       
   209 	{
       
   210 	test.Next(_L("TestSecurityCheckPreventInsecureTrkDebugAgent, SID 0x200159D8\n"));
       
   211 
       
   212 	RProcess process;
       
   213 	TInt err = process.Create(KRMDebugSecurityTrkDummyApp200159D8, KNullDesC, EOwnerProcess);
       
   214 	test (err == KErrNone);
       
   215 
       
   216 	// rendezvous with process
       
   217 	TRequestStatus status;
       
   218 	process.Rendezvous(status);
       
   219 
       
   220 	// obtain the secure ID for the process
       
   221 	TSecurityInfo secInfo(process);
       
   222 
       
   223 	static const TSecureId KTrkDummyAppSID2 = 0x200159D8;
       
   224 
       
   225 	test(secInfo.iSecureId.iId == KTrkDummyAppSID2);
       
   226 
       
   227 	// Kill the process, as we don't need it anymore
       
   228 	process.Kill(KErrNone);
       
   229 
       
   230 	process.Close();
       
   231 	}
       
   232 
       
   233 //----------------------------------------------------------------------------------------------
       
   234 //! @SYMTestCaseID      KBase-T-TRKDUMMYAPP-2397
       
   235 //! @SYMTestType        
       
   236 //! @SYMPREQ            PREQ1426
       
   237 //! @SYMTestCaseDesc    Tests that a known insecure debug agent trkapp.sis cannot be installed
       
   238 //!                     by ensuring the existence of a Symbian OS common app called trkdummyapp200170BC.exe
       
   239 //!                     already exists with the same Secure ID as the insecure app.
       
   240 //! @SYMTestActions     
       
   241 //!    
       
   242 //!     1.              Calls RProcess.Create() on z:\sys\bin\trkdummyapp200170BC.exe. Fail if unsuccessful.
       
   243 //!     
       
   244 //!     2.              Obtain the Secure ID of the process derived from z:\sys\bin\trkdummyapp200170BC.exe.
       
   245 //!
       
   246 //!     3.              Close the process derived from z:\sys\bin\trkdummyapp200170BC.exe.
       
   247 //!
       
   248 //! @SYMTestExpectedResults 
       
   249 //!
       
   250 //!     1.              Fails if unable to create a process from z:\sys\bin\trkdummyapp200170BC.exe.
       
   251 //!
       
   252 //!     2.              The Secure ID of trkdummyapp.exe has the Secure ID 0x200170BC. Fail otherwise.
       
   253 //! 
       
   254 //! @SYMTestPriority        High
       
   255 //! @SYMTestStatus          Implemented
       
   256 //----------------------------------------------------------------------------------------------
       
   257 
       
   258 // Names of some test programs used for testing security
       
   259 _LIT(KRMDebugSecurityTrkDummyApp200170BC,"z:\\sys\\bin\\trkdummyapp200170BC.exe");
       
   260 
       
   261 void CTrkDummyAppTest::TestSecurityCheckPreventInsecureTrkDebugAgent200170BC(void)
       
   262 	{
       
   263 
       
   264 	test.Next(_L("TestSecurityCheckPreventInsecureTrkDebugAgent, SID 0x200170BC\n"));
       
   265 
       
   266 	RProcess process;
       
   267 	TInt err = process.Create(KRMDebugSecurityTrkDummyApp200170BC, KNullDesC, EOwnerProcess);
       
   268 	test (err == KErrNone);
       
   269 
       
   270 	// rendezvous with process
       
   271 	TRequestStatus status;
       
   272 	process.Rendezvous(status);
       
   273 
       
   274 	// obtain the secure ID for the process
       
   275 	TSecurityInfo secInfo(process);
       
   276 
       
   277 	static const TSecureId KTrkDummyAppSID2 = 0x200170BC;
       
   278 
       
   279 	test(secInfo.iSecureId.iId == KTrkDummyAppSID2);
       
   280 
       
   281 	// Kill the process, as we don't need it anymore
       
   282 	process.Kill(KErrNone);
       
   283 
       
   284 	process.Close();
       
   285 	}
       
   286 
       
   287 void CTrkDummyAppTest::ClientAppL()
       
   288 //
       
   289 // Performs each test in turn
       
   290 //
       
   291 	{
       
   292 	test.Start(_L("ClientAppL"));
       
   293 
       
   294 	TestSecurityCheckPreventInsecureTrkDebugAgent();
       
   295 
       
   296 	TestSecurityCheckPreventInsecureTrkDebugAgent2();
       
   297 
       
   298 	TestSecurityCheckPreventInsecureTrkDebugAgent200159D8();
       
   299 
       
   300 	TestSecurityCheckPreventInsecureTrkDebugAgent200170BC();
       
   301 
       
   302 	test.End();
       
   303 	}
       
   304 
       
   305 
       
   306 
       
   307 GLDEF_C TInt E32Main()
       
   308 //
       
   309 // Entry point for run mode debug driver test
       
   310 //
       
   311 	{
       
   312    TInt ret = KErrNone;
       
   313 
       
   314 	// client
       
   315 	CTrapCleanup* trap = CTrapCleanup::New();
       
   316 	if (!trap)
       
   317 		return KErrNoMemory;
       
   318 
       
   319    	test.Title();
       
   320    TrkDummyTest = CTrkDummyAppTest::NewL();
       
   321    if (TrkDummyTest != NULL)
       
   322        {
       
   323         __UHEAP_MARK;
       
   324 	    TRAP(ret,TrkDummyTest->ClientAppL());
       
   325 	    __UHEAP_MARKEND;
       
   326 
       
   327 	    delete TrkDummyTest;
       
   328        }
       
   329        
       
   330 	delete trap;
       
   331 
       
   332 	return ret;
       
   333 	}
       
   334 
       
   335 // End of file - t_trkdummyapp.cpp
       
   336 
       
   337 
       
   338 
       
   339 
       
   340 
       
   341 
       
   342 
       
   343 
       
   344 
       
   345 
       
   346 
       
   347 
       
   348 
       
   349 
       
   350 
       
   351 
       
   352 
       
   353 
       
   354 
       
   355 
       
   356 
       
   357 
       
   358 
       
   359 
       
   360 
       
   361 
       
   362 
       
   363 
       
   364 
       
   365 
       
   366 
       
   367 
       
   368 
       
   369 
       
   370 
       
   371 
       
   372 
       
   373 
       
   374 
       
   375 
       
   376 
       
   377 
       
   378 
       
   379 
       
   380 
       
   381 
       
   382 
       
   383 
       
   384 
       
   385 
       
   386 
       
   387 
       
   388 
       
   389 
       
   390 
       
   391 
       
   392 
       
   393 
       
   394 
       
   395 
       
   396 
       
   397 
       
   398 
       
   399 
       
   400 
       
   401 
       
   402 
       
   403 
       
   404 
       
   405 
       
   406 
       
   407 
       
   408 
       
   409 
       
   410 
       
   411 
       
   412 
       
   413 
       
   414 
       
   415 
       
   416 
       
   417 
       
   418 
       
   419 
       
   420 
       
   421 
       
   422 
       
   423 
       
   424 
       
   425 
       
   426 
       
   427 
       
   428 
       
   429 
       
   430 
       
   431 
       
   432 
       
   433 
       
   434 
       
   435 
       
   436 
       
   437 
       
   438 
       
   439 
       
   440 
       
   441 
       
   442 
       
   443 
       
   444 
       
   445 
       
   446 
       
   447 
       
   448 
       
   449 
       
   450 
       
   451 
       
   452 
       
   453 
       
   454 
       
   455 
       
   456 
       
   457 
       
   458 
       
   459 
       
   460 
       
   461 
       
   462 
       
   463 
       
   464 
       
   465 
       
   466 
       
   467 
       
   468 
       
   469 
       
   470 
       
   471 
       
   472 
       
   473 
       
   474 
       
   475 
       
   476 
       
   477 
       
   478 
       
   479 
       
   480 
       
   481 
       
   482 
       
   483 
       
   484 
       
   485 
       
   486 
       
   487 
       
   488 
       
   489 
       
   490 
       
   491 
       
   492 
       
   493 
       
   494 
       
   495 
       
   496 
       
   497 
       
   498 
       
   499 
       
   500 
       
   501 
       
   502 
       
   503 
       
   504 
       
   505 
       
   506 
       
   507 
       
   508 
       
   509 
       
   510 
       
   511 
       
   512 
       
   513 
       
   514 
       
   515 
       
   516 
       
   517 
       
   518 
       
   519 
       
   520 
       
   521 
       
   522 
       
   523 
       
   524 
       
   525 
       
   526 
       
   527 
       
   528 
       
   529 
       
   530 
       
   531 
       
   532