|
0
|
1 |
/*
|
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
3 |
* All rights reserved.
|
|
|
4 |
* This component and the accompanying materials are made available
|
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
|
6 |
* which accompanies this distribution, and is available
|
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
|
8 |
*
|
|
|
9 |
* Initial Contributors:
|
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
|
11 |
*
|
|
|
12 |
* Contributors:
|
|
|
13 |
*
|
|
|
14 |
* Description:
|
|
|
15 |
*
|
|
|
16 |
*/
|
|
|
17 |
|
|
|
18 |
#include "TrkTcbSrvServer.h"
|
|
|
19 |
|
|
|
20 |
// System includes
|
|
|
21 |
#include <e32base.h>
|
|
|
22 |
#include <e32debug.h>
|
|
|
23 |
|
|
|
24 |
// User includes
|
|
|
25 |
#include "TrkTcbSrvSession.h"
|
|
|
26 |
//#include "TrkTcbSrvStaticUtils.h"
|
|
|
27 |
|
|
|
28 |
|
|
|
29 |
// Type definitions
|
|
|
30 |
|
|
|
31 |
// Constants
|
|
|
32 |
#define TRK_SID 0x200170BB
|
|
|
33 |
// Enumerations
|
|
|
34 |
|
|
|
35 |
// Classes referenced
|
|
|
36 |
|
|
|
37 |
#ifdef EKA2
|
|
|
38 |
//Only include these in the secured platform
|
|
|
39 |
#include "TrkTcbCmdCodes.h"
|
|
|
40 |
|
|
|
41 |
const TUint KRangeCount = 2;
|
|
|
42 |
|
|
|
43 |
const TInt KOpCodeRanges[KRangeCount] =
|
|
|
44 |
{
|
|
|
45 |
KCapabilityCustomCheck,
|
|
|
46 |
ETrkTcbCmdCodeLast,
|
|
|
47 |
};
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
const TUint8 KElementsIndex[KRangeCount] =
|
|
|
51 |
{
|
|
|
52 |
CPolicyServer::ECustomCheck, //Custom check for the Trk SID 0 - ETrkTcbCmdCodeLast
|
|
|
53 |
CPolicyServer::ENotSupported, //Not Supported ETrkTcbCmdCodeLast-End
|
|
|
54 |
};
|
|
|
55 |
|
|
|
56 |
const CPolicyServer::TPolicy KTrkTcbServerPolicy =
|
|
|
57 |
{
|
|
|
58 |
CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
|
|
|
59 |
KRangeCount,
|
|
|
60 |
KOpCodeRanges,
|
|
|
61 |
KElementsIndex, // what each range is compared to
|
|
|
62 |
NULL, //KPolicyElements // what policies range is compared to
|
|
|
63 |
};
|
|
|
64 |
|
|
|
65 |
#endif
|
|
|
66 |
|
|
|
67 |
|
|
|
68 |
//
|
|
|
69 |
// CTrkTcbSrvServer (source)
|
|
|
70 |
//
|
|
|
71 |
|
|
|
72 |
//
|
|
|
73 |
// CTrkTcbSrvServer::CTrkTcbSrvServer()
|
|
|
74 |
//
|
|
|
75 |
// Constructor
|
|
|
76 |
//
|
|
|
77 |
CTrkTcbSrvServer::CTrkTcbSrvServer()
|
|
|
78 |
#ifdef EKA2
|
|
|
79 |
:CPolicyServer(CActive::EPriorityHigh, KTrkTcbServerPolicy)
|
|
|
80 |
#else
|
|
|
81 |
:CServer2(CActive::EPriorityHigh)
|
|
|
82 |
#endif
|
|
|
83 |
{
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
//
|
|
|
87 |
// CTrkTcbSrvServer::~CTrkTcbSrvServer()
|
|
|
88 |
//
|
|
|
89 |
// Destructor
|
|
|
90 |
//
|
|
|
91 |
CTrkTcbSrvServer::~CTrkTcbSrvServer()
|
|
|
92 |
{
|
|
|
93 |
// In order to prevent access violations as the server
|
|
|
94 |
// shuts down, we inform all sessions that the server is
|
|
|
95 |
// about to be destroyed
|
|
|
96 |
iSessionIter.SetToFirst();
|
|
|
97 |
//
|
|
|
98 |
CTrkTcbSrvSession* session = static_cast<CTrkTcbSrvSession*>(iSessionIter++);
|
|
|
99 |
while (session)
|
|
|
100 |
{
|
|
|
101 |
session->HandleServerDestruction();
|
|
|
102 |
session = static_cast<CTrkTcbSrvSession*>(iSessionIter++);
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
}
|
|
|
106 |
|
|
|
107 |
//
|
|
|
108 |
// CTrkTcbSrvServer::ConstructL()
|
|
|
109 |
//
|
|
|
110 |
// Second level construction
|
|
|
111 |
//
|
|
|
112 |
void CTrkTcbSrvServer::ConstructL()
|
|
|
113 |
{
|
|
|
114 |
// Calling StartL here won't actually allow any connections
|
|
|
115 |
// to be created until the active scheduler has a chance to run. However, the
|
|
|
116 |
// call below will leave should there already be a started TrkTcb server instance.
|
|
|
117 |
//
|
|
|
118 |
StartL(KTrkTcbServerName);
|
|
|
119 |
}
|
|
|
120 |
|
|
|
121 |
//
|
|
|
122 |
// CTrkTcbSrvServer::NewLC()
|
|
|
123 |
//
|
|
|
124 |
// Creates an instance of CTrkTcbSrvServer.
|
|
|
125 |
//
|
|
|
126 |
CTrkTcbSrvServer* CTrkTcbSrvServer::NewLC()
|
|
|
127 |
{
|
|
|
128 |
CTrkTcbSrvServer* self = new(ELeave) CTrkTcbSrvServer();
|
|
|
129 |
CleanupStack::PushL(self);
|
|
|
130 |
self->ConstructL();
|
|
|
131 |
return self;
|
|
|
132 |
}
|
|
|
133 |
|
|
|
134 |
//
|
|
|
135 |
// CTrkTcbSrvServer::NewSessionL()
|
|
|
136 |
//
|
|
|
137 |
// Creates a new session.
|
|
|
138 |
// Called by the IPC framework everytime a client creates a new session.
|
|
|
139 |
// Returns a CTrkTcbSrvSession object.
|
|
|
140 |
//
|
|
|
141 |
CSession2* CTrkTcbSrvServer::NewSessionL(const TVersion& aVersion,const RMessage2& /*aMessage*/) const
|
|
|
142 |
{
|
|
|
143 |
// Check client version is correct
|
|
|
144 |
const TVersion trkTcbServerVersion(KTrkTcbServerMajorVN, KTrkTcbServerMinorVN, KTrkTcbServerBuildVN);
|
|
|
145 |
if (!User::QueryVersionSupported(trkTcbServerVersion, aVersion))
|
|
|
146 |
User::Leave(KErrNotSupported);
|
|
|
147 |
|
|
|
148 |
// Create new session
|
|
|
149 |
CTrkTcbSrvSession* session = CTrkTcbSrvSession::NewL();
|
|
|
150 |
return session;
|
|
|
151 |
}
|
|
|
152 |
|
|
|
153 |
//
|
|
|
154 |
// CTrkTcbSrvServer::RunError()
|
|
|
155 |
//
|
|
|
156 |
// Handles all the errors when handling a client request.
|
|
|
157 |
// Called by the IPC framework whenever a leave occurs when handling a client request.
|
|
|
158 |
// Returns KErrNone to complete the error handling.
|
|
|
159 |
//
|
|
|
160 |
TInt CTrkTcbSrvServer::RunError(TInt aError)
|
|
|
161 |
{
|
|
|
162 |
// A bad descriptor error implies a badly programmed client, so panic it;
|
|
|
163 |
// otherwise report the error to the client
|
|
|
164 |
if (aError == KErrBadDescriptor)
|
|
|
165 |
{
|
|
|
166 |
Message().Panic(KServerIntiatedSessionPanic, ETrkTcbServerInitiatedClientPanicBadDescriptor);
|
|
|
167 |
}
|
|
|
168 |
else
|
|
|
169 |
{
|
|
|
170 |
Message().Complete(aError);
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
// The leave will result in an early return from CServer2::RunL(), skipping
|
|
|
174 |
// the call to request another message. So do that now in order to keep the
|
|
|
175 |
// server running.
|
|
|
176 |
ReStart();
|
|
|
177 |
|
|
|
178 |
// Indicate that we've handled the error fully
|
|
|
179 |
return KErrNone;
|
|
|
180 |
}
|
|
|
181 |
|
|
|
182 |
#ifdef EKA2
|
|
|
183 |
//
|
|
|
184 |
// CTrkTcbSrvServer::CustomSecurityCheckL()
|
|
|
185 |
//
|
|
|
186 |
// The only security check that is done is to check for the cleint securid
|
|
|
187 |
// Returns EFail or EPass
|
|
|
188 |
//
|
|
|
189 |
CPolicyServer::TCustomResult CTrkTcbSrvServer::CustomSecurityCheckL(const RMessage2& aMsg, TInt& /*aAction*/, TSecurityInfo& /*aMissing*/)
|
|
|
190 |
{
|
|
|
191 |
CPolicyServer::TCustomResult returnValue = CPolicyServer::EFail;
|
|
|
192 |
|
|
|
193 |
TSecureId ClientSID = aMsg.SecureId();
|
|
|
194 |
// We only permit Trk to use this server. So we check
|
|
|
195 |
// for Trk's SIDs. If its not Trk's SIDs, then the security check fails.
|
|
|
196 |
if ((KTrkSrvUid == ClientSID) || (KTrkAppUid == ClientSID) || (KTrkExeUid == ClientSID))
|
|
|
197 |
{
|
|
|
198 |
returnValue = CPolicyServer::EPass;
|
|
|
199 |
}
|
|
|
200 |
return(returnValue);
|
|
|
201 |
}
|
|
|
202 |
#endif
|