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