|
1 /* |
|
2 * Copyright (c) 2004-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 the License "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 * CSisRegistryServer implementation |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @released |
|
23 @internalComponent |
|
24 */ |
|
25 #include <s32mem.h> |
|
26 #include <f32file.h> |
|
27 #include <s32file.h> |
|
28 |
|
29 #include "sisregistryserver.h" |
|
30 #include "sisregistryservershutdown.h" |
|
31 #include "sisregistryserversession.h" |
|
32 #include "log.h" |
|
33 #include "versionutil.h" |
|
34 #include "securitypolicy.h" |
|
35 |
|
36 using namespace Swi; |
|
37 |
|
38 const TInt CSisRegistryServer::iRanges[KPolicyRanges] = |
|
39 { |
|
40 0, // accessible by all clients |
|
41 EAddDrive, // Only Daemon should access these |
|
42 EControllers, // accessible by all clients |
|
43 EInitRecovery, // Only Daemon should access these |
|
44 EPackageExistsInRom, // accessible by all clients |
|
45 ESeparatorMinimumReadUserData, // accessible by ReadUserData clients only |
|
46 ESidToPackage, // accessible by all clients |
|
47 ESeparatorMinimumWriteUserData, // accessible by NetworkServices + WriteUserData clients only |
|
48 ESeparatorMinimumTCB, // accessible by TCB clients only |
|
49 ESeparatorMinimumReadUserData2, // accessible by ReadUserData clients only |
|
50 ESetComponentState, // requests coming from SIF |
|
51 ESeparatorEndAll, // not supported from there on |
|
52 }; |
|
53 |
|
54 const TUint8 CSisRegistryServer::iElementsIndex[iRangeCount] = |
|
55 { |
|
56 0, // all clients can have access |
|
57 3, // policed on SID only |
|
58 0, // all clients can have access |
|
59 3, // policed on SID only |
|
60 0, // all clients can have access |
|
61 1, // ReadUserData clients only |
|
62 0, // all clients can have access |
|
63 4, // WriteUserData clients only |
|
64 2, // Used by SWIS only, so TCB is needed - check on cap and SID. |
|
65 1, // ReadUserData clients only |
|
66 5, // requests coming from SIF |
|
67 CPolicyServer::ENotSupported, |
|
68 }; |
|
69 |
|
70 const CPolicyServer::TPolicyElement CSisRegistryServer::iPolicyElements[] = |
|
71 { |
|
72 {_INIT_SECURITY_POLICY_C1(ECapability_None), CPolicyServer::EFailClient}, |
|
73 {_INIT_SECURITY_POLICY_C1(ECapabilityReadUserData), CPolicyServer::EFailClient}, |
|
74 {_INIT_SECURITY_POLICY_S1(KSwisSecureId, ECapabilityTCB), CPolicyServer::EFailClient}, |
|
75 {_INIT_SECURITY_POLICY_S0(KDaemonSecureId), CPolicyServer::EFailClient}, |
|
76 {_INIT_SECURITY_POLICY_C2(ECapabilityWriteUserData, ECapabilityNetworkServices), CPolicyServer::EFailClient}, |
|
77 {_INIT_SECURITY_POLICY_S0(KSifServerSecureId), CPolicyServer::EFailClient}, |
|
78 }; |
|
79 |
|
80 const CPolicyServer::TPolicy CSisRegistryServer::iPolicy = |
|
81 { |
|
82 CPolicyServer::EAlwaysPass, // so that any client can connect |
|
83 iRangeCount, |
|
84 iRanges, |
|
85 iElementsIndex, |
|
86 iPolicyElements, |
|
87 }; |
|
88 |
|
89 inline CSisRegistryServer::CSisRegistryServer(CActive::TPriority aPriority) |
|
90 :CPolicyServer(aPriority, iPolicy, ESharableSessions) |
|
91 {} |
|
92 |
|
93 CSisRegistryServer* CSisRegistryServer::NewLC(CActive::TPriority aPriority) |
|
94 { |
|
95 CSisRegistryServer* self = new(ELeave) CSisRegistryServer(aPriority); |
|
96 CleanupStack::PushL(self); |
|
97 self->ConstructL(); |
|
98 return self; |
|
99 } |
|
100 |
|
101 void CSisRegistryServer::ConstructL() |
|
102 // |
|
103 // 2nd phase construction - ensure the timer and server objects are running |
|
104 // |
|
105 { |
|
106 DEBUG_PRINTF(_L8("SIS Registry Server - Starting Server")); |
|
107 StartL(KSisRegistryName); |
|
108 |
|
109 // create the shutdown |
|
110 iShutdown = new(ELeave) CShutdown; |
|
111 iShutdown->ConstructL(); |
|
112 // ensure that the server still exits even if the 1st client fails to connect |
|
113 iShutdown->Start(); |
|
114 } |
|
115 |
|
116 CSisRegistryServer::~CSisRegistryServer() |
|
117 { |
|
118 DEBUG_PRINTF(_L8("SIS Registry Server - Server Shutting Down")); |
|
119 CSecurityPolicy::ReleaseResource(); |
|
120 delete iShutdown; |
|
121 iShutdown = NULL; //required in case the server dies before the session |
|
122 } |
|
123 |
|
124 CSession2* CSisRegistryServer::NewSessionL(const TVersion& aClientVersion, const RMessage2&) const |
|
125 // |
|
126 // Create a new client session. This should really check the version number. |
|
127 // |
|
128 { |
|
129 if (aClientVersion == TVersion(1,0,0)) |
|
130 { |
|
131 return new(ELeave) CSisRegistrySession(); |
|
132 } |
|
133 else |
|
134 { |
|
135 User::Leave(KErrCouldNotConnect); |
|
136 return NULL; |
|
137 } |
|
138 } |
|
139 |
|
140 void CSisRegistryServer::AddSession() |
|
141 // |
|
142 // A new session is being created |
|
143 // Cancel the shutdown timer if it was running |
|
144 // |
|
145 { |
|
146 ++iSessionCount; |
|
147 DEBUG_PRINTF2(_L8("SIS Registry Server - New Session added (%d active)"), iSessionCount); |
|
148 iShutdown->Cancel(); |
|
149 } |
|
150 |
|
151 void CSisRegistryServer::DropSession() |
|
152 // |
|
153 // A session is being destroyed |
|
154 // Start the shutdown timer if it is the last session. |
|
155 // |
|
156 { |
|
157 if (--iSessionCount == 0 && iShutdown) |
|
158 { |
|
159 iShutdown->Start(); |
|
160 } |
|
161 DEBUG_PRINTF2(_L8("SIS Registry Server - Session close (%d active)"), iSessionCount); |
|
162 } |
|
163 |
|
164 |
|
165 |