1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/rm_debug/t_trkdummyapp.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,532 @@
1.4 +// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Ensure that old insecure Trk debug agent cannot be installed
1.18 +// as it should be blocked from SWInstall'ing by a trkdummyapp.exe contained within
1.19 +// the base OS with the same SID as the insecure Trk.
1.20 +//
1.21 +//
1.22 +
1.23 +#include <e32base.h>
1.24 +#include <e32base_private.h>
1.25 +#include <e32cons.h>
1.26 +#include <e32test.h>
1.27 +#include <e32ldr.h>
1.28 +#include <e32cmn.h>
1.29 +#include <e32cmn_private.h>
1.30 +#include <f32dbg.h>
1.31 +#include <f32file.h>
1.32 +#include "t_trkdummyapp.h"
1.33 +
1.34 +LOCAL_D RTest test(_L("T_TRKDUMMYAPP"));
1.35 +
1.36 +CTrkDummyAppTest::CTrkDummyAppTest()
1.37 +//
1.38 +// CTrkDummyAppTest constructor
1.39 +//
1.40 + {
1.41 + // nothing to do
1.42 + }
1.43 +
1.44 +CTrkDummyAppTest* CTrkDummyAppTest::NewL()
1.45 +//
1.46 +// CRunModeAgent::NewL
1.47 +//
1.48 + {
1.49 + CTrkDummyAppTest* self = new(ELeave) CTrkDummyAppTest();
1.50 +
1.51 + self->ConstructL();
1.52 +
1.53 + return self;
1.54 + }
1.55 +
1.56 +CTrkDummyAppTest::~CTrkDummyAppTest()
1.57 +//
1.58 +// CTrkDummyAppTest destructor
1.59 +//
1.60 + {
1.61 + // Nothing to do
1.62 + }
1.63 +
1.64 +void CTrkDummyAppTest::ConstructL()
1.65 +//
1.66 +// CTrkDummyAppTest::ConstructL
1.67 +//
1.68 + {
1.69 + // nothing to do here
1.70 + }
1.71 +
1.72 +
1.73 +CTrkDummyAppTest *TrkDummyTest;
1.74 +
1.75 +//----------------------------------------------------------------------------------------------
1.76 +//! @SYMTestCaseID KBase-T-TRKDUMMYAPP-0792
1.77 +//! @SYMTestType
1.78 +//! @SYMPREQ PREQ1426
1.79 +//! @SYMTestCaseDesc Tests that a known insecure debug agent trkapp.sis cannot be installed
1.80 +//! by ensuring the existence of a Symbian OS common app called trkdummyapp.exe
1.81 +//! already exists with the same Secure ID as the insecure app.
1.82 +//! @SYMTestActions
1.83 +//!
1.84 +//! 1. Calls RProcess.Create() on z:\sys\bin\trkdummyapp.exe. Fail if unsuccessful.
1.85 +//!
1.86 +//! 2. Obtain the Secure ID of the process derived from z:\sys\bin\trkdummyapp.exe.
1.87 +//!
1.88 +//! 3. Close the process derived from z:\sys\bin\trkdummyapp.exe.
1.89 +//!
1.90 +//! @SYMTestExpectedResults
1.91 +//!
1.92 +//! 1. Fails if unable to create a process from z:\sys\bin\trkdummyapp.exe.
1.93 +//!
1.94 +//! 2. The Secure ID of trkdummyapp.exe has the Secure ID 0x101F7159. Fail otherwise.
1.95 +//!
1.96 +//! @SYMTestPriority High
1.97 +//! @SYMTestStatus Implemented
1.98 +//----------------------------------------------------------------------------------------------
1.99 +
1.100 +// Names of some test programs used for testing security
1.101 +_LIT(KRMDebugSecurityTrkDummyApp,"z:\\sys\\bin\\trkdummyapp.exe");
1.102 +
1.103 +void CTrkDummyAppTest::TestSecurityCheckPreventInsecureTrkDebugAgent(void)
1.104 + {
1.105 +
1.106 + test.Next(_L("TestSecurityCheckPreventInsecureTrkDebugAgent, SID 0x101F7159\n"));
1.107 +
1.108 + RProcess process;
1.109 + TInt err = process.Create(KRMDebugSecurityTrkDummyApp, KNullDesC, EOwnerProcess);
1.110 + test (err == KErrNone);
1.111 +
1.112 + // rendezvous with process
1.113 + TRequestStatus status;
1.114 + process.Rendezvous(status);
1.115 +
1.116 + // obtain the secure ID for the process
1.117 + TSecurityInfo secInfo(process);
1.118 +
1.119 + static const TSecureId KTrkDummyAppSID = 0x101F7159;
1.120 +
1.121 + test(secInfo.iSecureId.iId == KTrkDummyAppSID);
1.122 +
1.123 + // Kill the process, as we don't need it anymore
1.124 + process.Kill(KErrNone);
1.125 +
1.126 + process.Close();
1.127 + }
1.128 +
1.129 +//----------------------------------------------------------------------------------------------
1.130 +//! @SYMTestCaseID KBase-T-TRKDUMMYAPP-0793
1.131 +//! @SYMTestType
1.132 +//! @SYMPREQ PREQ1426
1.133 +//! @SYMTestCaseDesc Tests that a known insecure debug agent trkapp.sis cannot be installed
1.134 +//! by ensuring the existence of a Symbian OS common app called trkdummyapp.exe
1.135 +//! already exists with the same Secure ID as the insecure app.
1.136 +//! @SYMTestActions
1.137 +//!
1.138 +//! 1. Calls RProcess.Create() on z:\sys\bin\trkdummyapp2.exe. Fail if unsuccessful.
1.139 +//!
1.140 +//! 2. Obtain the Secure ID of the process derived from z:\sys\bin\trkdummyapp2.exe.
1.141 +//!
1.142 +//! 3. Close the process derived from z:\sys\bin\trkdummyapp2.exe.
1.143 +//!
1.144 +//! @SYMTestExpectedResults
1.145 +//!
1.146 +//! 1. Fails if unable to create a process from z:\sys\bin\trkdummyapp2.exe.
1.147 +//!
1.148 +//! 2. The Secure ID of trkdummyapp.exe has the Secure ID 0x2000a7dd. Fail otherwise.
1.149 +//!
1.150 +//! @SYMTestPriority High
1.151 +//! @SYMTestStatus Implemented
1.152 +//----------------------------------------------------------------------------------------------
1.153 +
1.154 +// Names of some test programs used for testing security
1.155 +_LIT(KRMDebugSecurityTrkDummyApp2,"z:\\sys\\bin\\trkdummyapp2.exe");
1.156 +
1.157 +void CTrkDummyAppTest::TestSecurityCheckPreventInsecureTrkDebugAgent2(void)
1.158 + {
1.159 +
1.160 + test.Next(_L("TestSecurityCheckPreventInsecureTrkDebugAgent2, SID 0x2000a7dd\n"));
1.161 +
1.162 + RProcess process;
1.163 + TInt err = process.Create(KRMDebugSecurityTrkDummyApp2, KNullDesC, EOwnerProcess);
1.164 + test (err == KErrNone);
1.165 +
1.166 + // rendezvous with process
1.167 + TRequestStatus status;
1.168 + process.Rendezvous(status);
1.169 +
1.170 + // obtain the secure ID for the process
1.171 + TSecurityInfo secInfo(process);
1.172 +
1.173 + static const TSecureId KTrkDummyAppSID2 = 0x2000a7dd;
1.174 +
1.175 + test(secInfo.iSecureId.iId == KTrkDummyAppSID2);
1.176 +
1.177 + // Kill the process, as we don't need it anymore
1.178 + process.Kill(KErrNone);
1.179 +
1.180 + process.Close();
1.181 + }
1.182 +
1.183 +//----------------------------------------------------------------------------------------------
1.184 +//! @SYMTestCaseID KBase-T-TRKDUMMYAPP-2396
1.185 +//! @SYMTestType
1.186 +//! @SYMPREQ PREQ1426
1.187 +//! @SYMTestCaseDesc Tests that a known insecure debug agent trkapp.sis cannot be installed
1.188 +//! by ensuring the existence of a Symbian OS common app called trkdummyapp200159D8.exe
1.189 +//! already exists with the same Secure ID as the insecure app.
1.190 +//! @SYMTestActions
1.191 +//!
1.192 +//! 1. Calls RProcess.Create() on z:\sys\bin\trkdummyapp200159D8.exe. Fail if unsuccessful.
1.193 +//!
1.194 +//! 2. Obtain the Secure ID of the process derived from z:\sys\bin\trkdummyapp200159D8.exe.
1.195 +//!
1.196 +//! 3. Close the process derived from z:\sys\bin\trkdummyapp200159D8.exe.
1.197 +//!
1.198 +//! @SYMTestExpectedResults
1.199 +//!
1.200 +//! 1. Fails if unable to create a process from z:\sys\bin\trkdummyapp200159D8.exe.
1.201 +//!
1.202 +//! 2. The Secure ID of trkdummyapp200159D8.exe has the Secure ID 0x200159D8. Fail otherwise.
1.203 +//!
1.204 +//! @SYMTestPriority High
1.205 +//! @SYMTestStatus Implemented
1.206 +//----------------------------------------------------------------------------------------------
1.207 +
1.208 +// Names of some test programs used for testing security
1.209 +_LIT(KRMDebugSecurityTrkDummyApp200159D8,"z:\\sys\\bin\\trkdummyapp200159D8.exe");
1.210 +
1.211 +void CTrkDummyAppTest::TestSecurityCheckPreventInsecureTrkDebugAgent200159D8(void)
1.212 + {
1.213 + test.Next(_L("TestSecurityCheckPreventInsecureTrkDebugAgent, SID 0x200159D8\n"));
1.214 +
1.215 + RProcess process;
1.216 + TInt err = process.Create(KRMDebugSecurityTrkDummyApp200159D8, KNullDesC, EOwnerProcess);
1.217 + test (err == KErrNone);
1.218 +
1.219 + // rendezvous with process
1.220 + TRequestStatus status;
1.221 + process.Rendezvous(status);
1.222 +
1.223 + // obtain the secure ID for the process
1.224 + TSecurityInfo secInfo(process);
1.225 +
1.226 + static const TSecureId KTrkDummyAppSID2 = 0x200159D8;
1.227 +
1.228 + test(secInfo.iSecureId.iId == KTrkDummyAppSID2);
1.229 +
1.230 + // Kill the process, as we don't need it anymore
1.231 + process.Kill(KErrNone);
1.232 +
1.233 + process.Close();
1.234 + }
1.235 +
1.236 +//----------------------------------------------------------------------------------------------
1.237 +//! @SYMTestCaseID KBase-T-TRKDUMMYAPP-2397
1.238 +//! @SYMTestType
1.239 +//! @SYMPREQ PREQ1426
1.240 +//! @SYMTestCaseDesc Tests that a known insecure debug agent trkapp.sis cannot be installed
1.241 +//! by ensuring the existence of a Symbian OS common app called trkdummyapp200170BC.exe
1.242 +//! already exists with the same Secure ID as the insecure app.
1.243 +//! @SYMTestActions
1.244 +//!
1.245 +//! 1. Calls RProcess.Create() on z:\sys\bin\trkdummyapp200170BC.exe. Fail if unsuccessful.
1.246 +//!
1.247 +//! 2. Obtain the Secure ID of the process derived from z:\sys\bin\trkdummyapp200170BC.exe.
1.248 +//!
1.249 +//! 3. Close the process derived from z:\sys\bin\trkdummyapp200170BC.exe.
1.250 +//!
1.251 +//! @SYMTestExpectedResults
1.252 +//!
1.253 +//! 1. Fails if unable to create a process from z:\sys\bin\trkdummyapp200170BC.exe.
1.254 +//!
1.255 +//! 2. The Secure ID of trkdummyapp.exe has the Secure ID 0x200170BC. Fail otherwise.
1.256 +//!
1.257 +//! @SYMTestPriority High
1.258 +//! @SYMTestStatus Implemented
1.259 +//----------------------------------------------------------------------------------------------
1.260 +
1.261 +// Names of some test programs used for testing security
1.262 +_LIT(KRMDebugSecurityTrkDummyApp200170BC,"z:\\sys\\bin\\trkdummyapp200170BC.exe");
1.263 +
1.264 +void CTrkDummyAppTest::TestSecurityCheckPreventInsecureTrkDebugAgent200170BC(void)
1.265 + {
1.266 +
1.267 + test.Next(_L("TestSecurityCheckPreventInsecureTrkDebugAgent, SID 0x200170BC\n"));
1.268 +
1.269 + RProcess process;
1.270 + TInt err = process.Create(KRMDebugSecurityTrkDummyApp200170BC, KNullDesC, EOwnerProcess);
1.271 + test (err == KErrNone);
1.272 +
1.273 + // rendezvous with process
1.274 + TRequestStatus status;
1.275 + process.Rendezvous(status);
1.276 +
1.277 + // obtain the secure ID for the process
1.278 + TSecurityInfo secInfo(process);
1.279 +
1.280 + static const TSecureId KTrkDummyAppSID2 = 0x200170BC;
1.281 +
1.282 + test(secInfo.iSecureId.iId == KTrkDummyAppSID2);
1.283 +
1.284 + // Kill the process, as we don't need it anymore
1.285 + process.Kill(KErrNone);
1.286 +
1.287 + process.Close();
1.288 + }
1.289 +
1.290 +void CTrkDummyAppTest::ClientAppL()
1.291 +//
1.292 +// Performs each test in turn
1.293 +//
1.294 + {
1.295 + test.Start(_L("ClientAppL"));
1.296 +
1.297 + TestSecurityCheckPreventInsecureTrkDebugAgent();
1.298 +
1.299 + TestSecurityCheckPreventInsecureTrkDebugAgent2();
1.300 +
1.301 + TestSecurityCheckPreventInsecureTrkDebugAgent200159D8();
1.302 +
1.303 + TestSecurityCheckPreventInsecureTrkDebugAgent200170BC();
1.304 +
1.305 + test.End();
1.306 + }
1.307 +
1.308 +
1.309 +
1.310 +GLDEF_C TInt E32Main()
1.311 +//
1.312 +// Entry point for run mode debug driver test
1.313 +//
1.314 + {
1.315 + TInt ret = KErrNone;
1.316 +
1.317 + // client
1.318 + CTrapCleanup* trap = CTrapCleanup::New();
1.319 + if (!trap)
1.320 + return KErrNoMemory;
1.321 +
1.322 + test.Title();
1.323 + TrkDummyTest = CTrkDummyAppTest::NewL();
1.324 + if (TrkDummyTest != NULL)
1.325 + {
1.326 + __UHEAP_MARK;
1.327 + TRAP(ret,TrkDummyTest->ClientAppL());
1.328 + __UHEAP_MARKEND;
1.329 +
1.330 + delete TrkDummyTest;
1.331 + }
1.332 +
1.333 + delete trap;
1.334 +
1.335 + return ret;
1.336 + }
1.337 +
1.338 +// End of file - t_trkdummyapp.cpp
1.339 +
1.340 +
1.341 +
1.342 +
1.343 +
1.344 +
1.345 +
1.346 +
1.347 +
1.348 +
1.349 +
1.350 +
1.351 +
1.352 +
1.353 +
1.354 +
1.355 +
1.356 +
1.357 +
1.358 +
1.359 +
1.360 +
1.361 +
1.362 +
1.363 +
1.364 +
1.365 +
1.366 +
1.367 +
1.368 +
1.369 +
1.370 +
1.371 +
1.372 +
1.373 +
1.374 +
1.375 +
1.376 +
1.377 +
1.378 +
1.379 +
1.380 +
1.381 +
1.382 +
1.383 +
1.384 +
1.385 +
1.386 +
1.387 +
1.388 +
1.389 +
1.390 +
1.391 +
1.392 +
1.393 +
1.394 +
1.395 +
1.396 +
1.397 +
1.398 +
1.399 +
1.400 +
1.401 +
1.402 +
1.403 +
1.404 +
1.405 +
1.406 +
1.407 +
1.408 +
1.409 +
1.410 +
1.411 +
1.412 +
1.413 +
1.414 +
1.415 +
1.416 +
1.417 +
1.418 +
1.419 +
1.420 +
1.421 +
1.422 +
1.423 +
1.424 +
1.425 +
1.426 +
1.427 +
1.428 +
1.429 +
1.430 +
1.431 +
1.432 +
1.433 +
1.434 +
1.435 +
1.436 +
1.437 +
1.438 +
1.439 +
1.440 +
1.441 +
1.442 +
1.443 +
1.444 +
1.445 +
1.446 +
1.447 +
1.448 +
1.449 +
1.450 +
1.451 +
1.452 +
1.453 +
1.454 +
1.455 +
1.456 +
1.457 +
1.458 +
1.459 +
1.460 +
1.461 +
1.462 +
1.463 +
1.464 +
1.465 +
1.466 +
1.467 +
1.468 +
1.469 +
1.470 +
1.471 +
1.472 +
1.473 +
1.474 +
1.475 +
1.476 +
1.477 +
1.478 +
1.479 +
1.480 +
1.481 +
1.482 +
1.483 +
1.484 +
1.485 +
1.486 +
1.487 +
1.488 +
1.489 +
1.490 +
1.491 +
1.492 +
1.493 +
1.494 +
1.495 +
1.496 +
1.497 +
1.498 +
1.499 +
1.500 +
1.501 +
1.502 +
1.503 +
1.504 +
1.505 +
1.506 +
1.507 +
1.508 +
1.509 +
1.510 +
1.511 +
1.512 +
1.513 +
1.514 +
1.515 +
1.516 +
1.517 +
1.518 +
1.519 +
1.520 +
1.521 +
1.522 +
1.523 +
1.524 +
1.525 +
1.526 +
1.527 +
1.528 +
1.529 +
1.530 +
1.531 +
1.532 +
1.533 +
1.534 +
1.535 +