|
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 # This module contains common helper functions for |
|
19 # handling excel sheets from perl. |
|
20 # Version 0.9 |
|
21 # - now checking that Int and Real values are really |
|
22 # numbers |
|
23 # - rfs, cust config and backup are must fields for variant row |
|
24 # - All rows, which have "Comment:" in the uid name are ignored. |
|
25 ################################################### |
|
26 ################################################### |
|
27 package cenrep_keys; |
|
28 |
|
29 ########################################## |
|
30 # Libraries used |
|
31 ########################################## |
|
32 use strict; |
|
33 use Win32::OLE qw(in with); |
|
34 use Win32::OLE::Const 'Microsoft Excel'; |
|
35 use Exporter (); # Needed to make constants available to caller. |
|
36 use excel_support; # opening/closing workbook, etc.. functions. |
|
37 |
|
38 ########################################## |
|
39 # Defining all the "global" variables, that we are using. |
|
40 ########################################## |
|
41 use vars qw( |
|
42 @ISA |
|
43 @EXPORT |
|
44 ); |
|
45 |
|
46 @ISA = qw(Exporter); # Inherit from Exporter module (import method needed). |
|
47 # Define all the functions defined by this module |
|
48 use subs qw( |
|
49 hasValue |
|
50 addHash |
|
51 readCol |
|
52 readCentrepKeyInfo |
|
53 checkCentrepKeyInfo |
|
54 checkCentrepKeySheetName |
|
55 ); |
|
56 |
|
57 ########################################## |
|
58 # Define the exports from this module that can be used |
|
59 # Outside |
|
60 ########################################## |
|
61 @EXPORT = qw( |
|
62 &addHash |
|
63 &readCol |
|
64 &readCentrepKeyInfo |
|
65 &checkCentrepKeyInfo |
|
66 &checkCentrepKeySheetName |
|
67 ); |
|
68 |
|
69 |
|
70 my $globalMaxColCount = 43; |
|
71 my $globalMaxEmptyRowCount = 10; |
|
72 |
|
73 ####################################### |
|
74 # Checks that the cell exists and has some value |
|
75 # |
|
76 # Params: refToWorkSheet,row,column |
|
77 # |
|
78 # Return: 1 if the cell had some value |
|
79 # 0 if the cell did not have a value |
|
80 ####################################### |
|
81 sub hasValue |
|
82 { |
|
83 my $refToWorksheet = shift; |
|
84 my $row = shift; |
|
85 my $col = shift; |
|
86 |
|
87 if($col < 1) |
|
88 { |
|
89 return 0; |
|
90 } |
|
91 if(defined($$refToWorksheet->Cells( $row, $col )->{ 'Value' })) |
|
92 { |
|
93 return 1; |
|
94 } |
|
95 if(!(defined($$refToWorksheet->Cells( $row, $col )) ||$$refToWorksheet->Cells( $row, $col )->{ 'Value' })) |
|
96 { |
|
97 print "$row $col\n"; |
|
98 print $$refToWorksheet->Name,"\n"; |
|
99 } |
|
100 if($$refToWorksheet->Cells( $row, $col )->{ 'Value' } !~ /^\s*$/) |
|
101 { |
|
102 return 1; |
|
103 } |
|
104 |
|
105 return 0; |
|
106 } |
|
107 |
|
108 ####################################### |
|
109 # Reads a cell value from given worksheet and given place. |
|
110 # If the value is empty then initializes teh return value to the |
|
111 # given default value |
|
112 # |
|
113 # Params: refToWorkSheet,row,column,defValue |
|
114 # |
|
115 # Return: the read value |
|
116 ####################################### |
|
117 sub readCol |
|
118 { |
|
119 my $refToWorksheet = shift; |
|
120 my $row = shift; |
|
121 my $col = shift; |
|
122 my $defValue = shift; |
|
123 |
|
124 my $retVal = undef; |
|
125 if($col > 0) |
|
126 { |
|
127 $retVal = $$refToWorksheet->Cells( $row, $col )->{ 'Value' }; |
|
128 } |
|
129 if(!defined($retVal) || $retVal =~ /^\s*$/) |
|
130 { |
|
131 $retVal = $defValue; |
|
132 } |
|
133 |
|
134 return $retVal; |
|
135 } |
|
136 ####################################### |
|
137 # If there is no given key defined in the given hash, then |
|
138 # adds a key to point to a new hash |
|
139 # |
|
140 # Params: newKey,refToHash,refToHash |
|
141 # |
|
142 # Return: ref to added hash, or existing hash |
|
143 ####################################### |
|
144 sub addHash |
|
145 { |
|
146 my $key = shift; |
|
147 my $refToHash = shift; |
|
148 |
|
149 if(! defined( $$refToHash{$key})) |
|
150 { |
|
151 my %newHash; |
|
152 $$refToHash{$key} = \%newHash; |
|
153 } |
|
154 |
|
155 return $$refToHash{$key}; |
|
156 } |
|
157 |
|
158 ########################################################################### |
|
159 # |
|
160 ########################################################################### |
|
161 sub addCapability |
|
162 { |
|
163 my $refToRList = shift; |
|
164 my $refToWList = shift; |
|
165 my $capaColumnValue = shift; |
|
166 my $capaName = shift; |
|
167 |
|
168 if($capaColumnValue =~ /R/i) |
|
169 { |
|
170 push(@$refToRList,$capaName); |
|
171 } |
|
172 if($capaColumnValue =~ /W/i) |
|
173 { |
|
174 push(@$refToWList,$capaName); |
|
175 } |
|
176 } |
|
177 |
|
178 ########################################################################### |
|
179 # |
|
180 ########################################################################### |
|
181 sub readIndexes |
|
182 { |
|
183 my $refToWorksheet = shift; |
|
184 |
|
185 my @retList; |
|
186 |
|
187 push(@retList,getIndexByColName($refToWorksheet,"Uid Name",$globalMaxColCount)); |
|
188 push(@retList,getIndexByColName($refToWorksheet,"Uid Value",$globalMaxColCount)); |
|
189 push(@retList,getIndexByColName($refToWorksheet,"Range From",$globalMaxColCount)); |
|
190 push(@retList,getIndexByColName($refToWorksheet,"Range To",$globalMaxColCount)); |
|
191 push(@retList,getIndexByColName($refToWorksheet,"Key Name",$globalMaxColCount)); |
|
192 push(@retList,getIndexByColName($refToWorksheet,"Key Int",$globalMaxColCount)); |
|
193 push(@retList,getIndexByColName($refToWorksheet,"Shared Data Name",$globalMaxColCount)); |
|
194 push(@retList,getIndexByColName($refToWorksheet,"Removed",$globalMaxColCount)); |
|
195 push(@retList,getIndexByColName($refToWorksheet,"Platform Release",$globalMaxColCount)); |
|
196 push(@retList,getIndexByColName($refToWorksheet,"Variant Name",$globalMaxColCount)); |
|
197 push(@retList,getIndexByColName($refToWorksheet,"Def Value",$globalMaxColCount)); |
|
198 my $index = getIndexByColName($refToWorksheet,"Read Only",$globalMaxColCount); |
|
199 if($index < 0) |
|
200 { |
|
201 $index = getIndexByColName($refToWorksheet,"Read Only",$globalMaxColCount); |
|
202 } |
|
203 push(@retList,$index); |
|
204 push(@retList,getIndexByColName($refToWorksheet,"Key Type",$globalMaxColCount)); |
|
205 push(@retList,getIndexByColName($refToWorksheet,"Backup",$globalMaxColCount)); |
|
206 push(@retList,getIndexByColName($refToWorksheet,"RFS",$globalMaxColCount)); |
|
207 push(@retList,getIndexByColName($refToWorksheet,"Cust Config",$globalMaxColCount)); |
|
208 push(@retList,getIndexByColName($refToWorksheet,"None",$globalMaxColCount)); |
|
209 push(@retList,getIndexByColName($refToWorksheet,"All",$globalMaxColCount)); |
|
210 push(@retList,getIndexByColName($refToWorksheet,"All - TCB",$globalMaxColCount)); |
|
211 push(@retList,getIndexByColName($refToWorksheet,"NetworkServices",$globalMaxColCount)); |
|
212 push(@retList,getIndexByColName($refToWorksheet,"LocalServices",$globalMaxColCount)); |
|
213 push(@retList,getIndexByColName($refToWorksheet,"ReadUserData",$globalMaxColCount)); |
|
214 push(@retList,getIndexByColName($refToWorksheet,"WriteUserData",$globalMaxColCount)); |
|
215 push(@retList,getIndexByColName($refToWorksheet,"Location",$globalMaxColCount)); |
|
216 push(@retList,getIndexByColName($refToWorksheet,"ReadDeviceData",$globalMaxColCount)); |
|
217 push(@retList,getIndexByColName($refToWorksheet,"WriteDeviceData",$globalMaxColCount)); |
|
218 push(@retList,getIndexByColName($refToWorksheet,"ProtServ",$globalMaxColCount)); |
|
219 push(@retList,getIndexByColName($refToWorksheet,"DRM",$globalMaxColCount)); |
|
220 push(@retList,getIndexByColName($refToWorksheet,"SwEvent",$globalMaxColCount)); |
|
221 push(@retList,getIndexByColName($refToWorksheet,"PowerMgmt",$globalMaxColCount)); |
|
222 push(@retList,getIndexByColName($refToWorksheet,"AllFiles",$globalMaxColCount)); |
|
223 push(@retList,getIndexByColName($refToWorksheet,"DiskAdmin",$globalMaxColCount)); |
|
224 push(@retList,getIndexByColName($refToWorksheet,"NetworkControl",$globalMaxColCount)); |
|
225 push(@retList,getIndexByColName($refToWorksheet,"MultiMediaDD",$globalMaxColCount)); |
|
226 push(@retList,getIndexByColName($refToWorksheet,"CommDD",$globalMaxColCount)); |
|
227 push(@retList,getIndexByColName($refToWorksheet,"TCB",$globalMaxColCount)); |
|
228 push(@retList,getIndexByColName($refToWorksheet,"TrustedUI",$globalMaxColCount)); |
|
229 |
|
230 push(@retList,getIndexByColName($refToWorksheet,"AlwaysPass",$globalMaxColCount)); |
|
231 push(@retList,getIndexByColName($refToWorksheet,"UserEnvironment",$globalMaxColCount)); |
|
232 push(@retList,getIndexByColName($refToWorksheet,"SurroundingsDD",$globalMaxColCount)); |
|
233 push(@retList,getIndexByColName($refToWorksheet,"SID Read",$globalMaxColCount)); |
|
234 push(@retList,getIndexByColName($refToWorksheet,"SID Write",$globalMaxColCount)); |
|
235 push(@retList,getIndexByColName($refToWorksheet,"Range From",$globalMaxColCount)); |
|
236 push(@retList,getIndexByColName($refToWorksheet,"Range To",$globalMaxColCount)); |
|
237 push(@retList,getIndexByColName($refToWorksheet,"Owner",$globalMaxColCount)); |
|
238 |
|
239 |
|
240 return @retList; |
|
241 } |
|
242 |
|
243 ########################################################################### |
|
244 # Function that reads all columns from the central repository sheet to the |
|
245 # given hash. |
|
246 # The format of the returned hash is: |
|
247 # { |
|
248 # <uid> => |
|
249 # { |
|
250 # "name" => <uidName> |
|
251 # "uid_specific" |
|
252 # = > { |
|
253 # <variant> |
|
254 # => { |
|
255 # <release> |
|
256 # => { |
|
257 # "R" => (<capa1ForReading>,<capa2ForReading>) |
|
258 # "W" => (<capa1ForWriting>,<capa2ForWriting>) |
|
259 # "RSid" => (<sidForReading>) |
|
260 # "WSid" => (<sidForWriting>) |
|
261 # "owner" => <ownerSid> |
|
262 # "rfs" => <0/1> |
|
263 # "backup" => <0/1> |
|
264 # } |
|
265 # } |
|
266 # } |
|
267 # "ranges" |
|
268 # => { |
|
269 # <rangeFrom> |
|
270 # => { |
|
271 # "common" => ( # == defined in range row |
|
272 # "removed" => <release> [optional, only if specified] |
|
273 # } |
|
274 # "to" => { |
|
275 # <rangeTo> |
|
276 # => { |
|
277 # <variant> |
|
278 # => { |
|
279 # <release> |
|
280 # => { |
|
281 # "R" => (<capa1ForReading>,<capa2ForReading>) |
|
282 # "W" => (<capa1ForWriting>,<capa2ForWriting>) |
|
283 # "RSid" => (<sidForReading>) |
|
284 # "WSid" => (<sidForWriting>) |
|
285 # "rfs" => <0/1> |
|
286 # "backup" => <0/1> |
|
287 # } |
|
288 # } |
|
289 # } |
|
290 # } |
|
291 # } |
|
292 # } |
|
293 # } # ranges end |
|
294 # "keys" => { |
|
295 # <keyInt> |
|
296 # => { |
|
297 # "common" => ( # == defined in key row |
|
298 # "name" => <keyName> |
|
299 # "sheetName" => <eexcelSheetName, from which this key was read> |
|
300 # "sd-name" => <sharedDataName> [optional, only if specified] |
|
301 # "read-only" => <0/1> |
|
302 # "key type" => <bin/int/str/bool> |
|
303 # "removed" => <release> [optional, only if specified] |
|
304 # "owner" => <ownerName> |
|
305 # "entity" => <ownerEntity> |
|
306 # } |
|
307 # "release" |
|
308 # => { |
|
309 # <variant> # "default" is special case |
|
310 # => { |
|
311 # <release> |
|
312 # => { |
|
313 # "R" => (<capa1ForReading>,<capa2ForReading>) |
|
314 # "W" => (<capa1ForWriting>,<capa2ForWriting>) |
|
315 # "RSid" => (<sidForReading>) |
|
316 # "WSid" => (<sidForWriting>) |
|
317 # "value" => <value> |
|
318 # "rfs" => <0/1> |
|
319 # "backup" => <0/1> |
|
320 # } |
|
321 # } |
|
322 # } |
|
323 # } |
|
324 # } # keys |
|
325 # |
|
326 # |
|
327 # |
|
328 # |
|
329 # Params: referenceToWorksheet,refToHash |
|
330 # |
|
331 # Return: 0 on successfull reading |
|
332 # 1 on case, where the worksheet was not OK (for isntance name is |
|
333 # not according to specification. |
|
334 ########################################################################### |
|
335 sub readCentrepKeyInfo |
|
336 { |
|
337 my $refToWorksheet = shift; |
|
338 my $refToHash = shift; |
|
339 my $owner = shift; |
|
340 my $entity = shift; |
|
341 my $sheetName = shift; |
|
342 |
|
343 # ---------------------------------------------------------------- |
|
344 # look to header information |
|
345 # ---------------------------------------------------------------- |
|
346 # Uid value |
|
347 # Key name value |
|
348 # Key value |
|
349 # |
|
350 # |
|
351 # |
|
352 # |
|
353 # |
|
354 |
|
355 my ($uidNameIndex,$uidValueIndex,$rangeFromIndex,$rangeToIndex,$keyNameValueIndex,$keyIntValueIndex,$sdNameIndex,$removedIndex,$releaseIndex,$variantNameIndex,$valueIndex,$readOnlyIndex, |
|
356 $keyTypeIndex,$backupIndex,$rfsIndex,$custConfigIndex,$capaNoneIndex,$capaAllIndex,$capaAllMinusTcbIndex,$capaNetworkServicesIndex, |
|
357 $capaLocalServicesIndex,$capaReadUserDataIndex,$capaWriteUserDataIndex,$capaLocationIndex,$capaReadDeviceDataIndex, |
|
358 $capaWriteDeviceDataIndex,$capaProtServIndex,$capaDrmIndex,$capaSwEventIndex,$capaPowerMgmtIndex,$capaAllFilesIndex, |
|
359 $capaDiskAdminIndex,$capaNetworkControlIndex,$capaMultiMediaDDIndex,$capaCommDDIndex, |
|
360 $capaTCBIndex,$capaTrustedUIIndex,$capaAlwaysPassIndex,$capaUserEnvIndex,$capaSurroundingsDDIndex, |
|
361 $capaSidReadIndex,$capaSidWriteIndex,$rangeFromIndex,$rangeToIndex,$ownerIndex) = readIndexes($refToWorksheet); |
|
362 |
|
363 if( $uidValueIndex < 0) |
|
364 { |
|
365 return; |
|
366 } |
|
367 |
|
368 my $row = 1; |
|
369 my $emptyRowCount = 0; |
|
370 |
|
371 ###################################################################### |
|
372 # Loop row by row until we have found $globalMaxEmptyRowCount of rows |
|
373 # empty one after each other. |
|
374 ###################################################################### |
|
375 my $currUid = ""; |
|
376 my $currUidKeysHash; |
|
377 my $currUidRangesHash; |
|
378 my $currUidSpecificHash; |
|
379 my $currRangeHash = undef; |
|
380 my $currKey = ""; |
|
381 my $currKeyReleaseHash; # the ref to has that is found from "release" |
|
382 my $lastActiveRowType = 0; # 0 = not defined, 1 = uid, 2 = range, 3 = key |
|
383 |
|
384 for( $row = 2;; $row++ ) |
|
385 { |
|
386 #------------------------------------------------------------ |
|
387 # We only allow $globalMaxEmptyRowCount empty rows, before we stop |
|
388 # handling the specific sheet |
|
389 #------------------------------------------------------------ |
|
390 if(! ( hasValue($refToWorksheet,$row, $uidValueIndex ) |
|
391 || hasValue($refToWorksheet,$row, $keyIntValueIndex ) |
|
392 || hasValue($refToWorksheet,$row, $valueIndex ) |
|
393 || hasValue($refToWorksheet,$row, $releaseIndex ) |
|
394 || hasValue($refToWorksheet,$row, $rangeFromIndex ) |
|
395 || hasValue($refToWorksheet,$row, $rangeToIndex ) |
|
396 )) |
|
397 { |
|
398 $emptyRowCount++; |
|
399 if($emptyRowCount > $globalMaxEmptyRowCount) |
|
400 { |
|
401 last; |
|
402 } |
|
403 next; |
|
404 } |
|
405 else |
|
406 { |
|
407 # Was not empty line, reset counter. |
|
408 $emptyRowCount = 0; |
|
409 } |
|
410 |
|
411 #------------------------------------------------------------ |
|
412 # Read the needed rows from the row |
|
413 #------------------------------------------------------------ |
|
414 my $uidName = readCol($refToWorksheet,$row,$uidNameIndex,""); |
|
415 my $uid = readCol($refToWorksheet,$row,$uidValueIndex,""); |
|
416 my $keyName = readCol($refToWorksheet,$row,$keyNameValueIndex,""); |
|
417 my $key = readCol($refToWorksheet,$row,$keyIntValueIndex,""); |
|
418 my $sdName = readCol($refToWorksheet,$row,$sdNameIndex,""); |
|
419 my $removed = readCol($refToWorksheet,$row,$removedIndex,""); |
|
420 my $release = readCol($refToWorksheet,$row,$releaseIndex,""); |
|
421 my $variant = readCol($refToWorksheet,$row,$variantNameIndex,""); |
|
422 my $value = readCol($refToWorksheet,$row,$valueIndex,""); |
|
423 my $ro = readCol($refToWorksheet,$row,$readOnlyIndex,""); |
|
424 my $keyType = readCol($refToWorksheet,$row,$keyTypeIndex,""); |
|
425 my $backup = readCol($refToWorksheet,$row,$backupIndex,""); |
|
426 my $rfs = readCol($refToWorksheet,$row,$rfsIndex,""); |
|
427 my $custConfig = readCol($refToWorksheet,$row,$custConfigIndex,""); |
|
428 my $capaNone = readCol($refToWorksheet,$row,$capaNoneIndex,""); |
|
429 my $capaAll = readCol($refToWorksheet,$row,$capaAllIndex,""); |
|
430 my $capaAllMinusTcb = readCol($refToWorksheet,$row,$capaAllMinusTcbIndex,""); |
|
431 my $capaNetworkServices = readCol($refToWorksheet,$row,$capaNetworkServicesIndex,""); |
|
432 my $capaLocalServices = readCol($refToWorksheet,$row,$capaLocalServicesIndex,""); |
|
433 my $capaReadUserData = readCol($refToWorksheet,$row,$capaReadUserDataIndex,""); |
|
434 my $capaWriteUserData = readCol($refToWorksheet,$row,$capaWriteUserDataIndex,""); |
|
435 my $capaLocation = readCol($refToWorksheet,$row,$capaLocationIndex,""); |
|
436 my $capaReadDeviceData = readCol($refToWorksheet,$row,$capaReadDeviceDataIndex,""); |
|
437 my $capaWriteDeviceData = readCol($refToWorksheet,$row,$capaWriteDeviceDataIndex,""); |
|
438 my $capaProtServ = readCol($refToWorksheet,$row,$capaProtServIndex,""); |
|
439 my $capaDrm = readCol($refToWorksheet,$row,$capaDrmIndex,""); |
|
440 my $capaSwEvent = readCol($refToWorksheet,$row,$capaSwEventIndex,""); |
|
441 my $capaPowerMgmt = readCol($refToWorksheet,$row,$capaPowerMgmtIndex,""); |
|
442 my $capaAllFiles = readCol($refToWorksheet,$row,$capaAllFilesIndex,""); |
|
443 my $capaDiskAdmin = readCol($refToWorksheet,$row,$capaDiskAdminIndex,""); |
|
444 my $capaNetworkControl = readCol($refToWorksheet,$row,$capaNetworkControlIndex,""); |
|
445 my $capaMultiMediaDD = readCol($refToWorksheet,$row,$capaMultiMediaDDIndex,""); |
|
446 my $capaCommDD = readCol($refToWorksheet,$row,$capaCommDDIndex,""); |
|
447 my $capaTCB = readCol($refToWorksheet,$row,$capaTCBIndex,""); |
|
448 my $capaTrustedUI = readCol($refToWorksheet,$row,$capaTrustedUIIndex,""); |
|
449 |
|
450 my $capaAlwaysPass = readCol($refToWorksheet,$row,$capaAlwaysPassIndex,""); |
|
451 my $capaUserEnv = readCol($refToWorksheet,$row,$capaUserEnvIndex,""); |
|
452 my $capaSurroundingsDD = readCol($refToWorksheet,$row,$capaSurroundingsDDIndex,""); |
|
453 my $capaSidRead = readCol($refToWorksheet,$row,$capaSidReadIndex,""); |
|
454 my $capaSidWrite = readCol($refToWorksheet,$row,$capaSidWriteIndex,""); |
|
455 my $rangeFrom = readCol($refToWorksheet,$row,$rangeFromIndex,""); |
|
456 my $rangeTo = readCol($refToWorksheet,$row,$rangeToIndex,""); |
|
457 my $uidOwner = readCol($refToWorksheet,$row,$ownerIndex,""); |
|
458 |
|
459 if($uidName =~ /^\s*Comment:/i) |
|
460 { |
|
461 # comment rows are ignored |
|
462 next; |
|
463 } |
|
464 |
|
465 #------------------------------------------------------------ |
|
466 # Handle UID row |
|
467 #------------------------------------------------------------ |
|
468 if($uid !~ /^\s*$/) |
|
469 { |
|
470 $currUid = $uid; |
|
471 $currKey = ""; |
|
472 $lastActiveRowType = 1; |
|
473 my $tmpRefToHash = addHash($uid,$refToHash); |
|
474 $currUidKeysHash = addHash("keys",$tmpRefToHash); |
|
475 $$tmpRefToHash{"name"} = $uidName; |
|
476 $currUidRangesHash = addHash("ranges",$tmpRefToHash); |
|
477 $currUidSpecificHash = addHash("uid_specific",$tmpRefToHash); |
|
478 } |
|
479 #------------------------------------------------------------ |
|
480 # Handle range row |
|
481 #------------------------------------------------------------ |
|
482 elsif($rangeFrom !~ /^\s*$/ || $rangeTo !~ /^\s*$/) |
|
483 { |
|
484 $currRangeHash = addHash($rangeFrom,$currUidRangesHash); |
|
485 my $commonHash = addHash("common",$currRangeHash); |
|
486 $currRangeHash = addHash("to",$currRangeHash); |
|
487 $currRangeHash = addHash($rangeTo,$currRangeHash); |
|
488 |
|
489 $$commonHash{"removed"} = $removed; |
|
490 $lastActiveRowType = 2; |
|
491 } |
|
492 #------------------------------------------------------------ |
|
493 # Handle key row |
|
494 #------------------------------------------------------------ |
|
495 elsif($key !~ /^\s*$/) |
|
496 { |
|
497 $currKey = $key; |
|
498 $lastActiveRowType = 3; |
|
499 my $keyHash = addHash($key,$currUidKeysHash); |
|
500 ###################################################### |
|
501 # "common" => ( |
|
502 # "name" => <someName> |
|
503 # "sheetName" => <someNameWithoutPath> |
|
504 # "sd-name" => <someName> [optional] |
|
505 # "read-only" => <0/1> |
|
506 # "key type" => <bin/int/str/bool> |
|
507 # "removed" => <release> |
|
508 # "owner" => <ownerName> |
|
509 # "entity" => <entity> |
|
510 # } |
|
511 ###################################################### |
|
512 my $commonHash = addHash("common",$keyHash); |
|
513 |
|
514 $$commonHash{"owner"} = $owner; |
|
515 $$commonHash{"entity"} = $entity; |
|
516 $$commonHash{"name"} = $keyName; |
|
517 $$commonHash{"sheetName"} = $sheetName; |
|
518 |
|
519 # read-only attribute is set always from the "key row". |
|
520 # It can't be overwritten |
|
521 $$commonHash{"read-only"} = 0; |
|
522 if($ro =~ /^\s*yes\s*$/i) |
|
523 { |
|
524 $$commonHash{"read-only"} = 1; |
|
525 } |
|
526 # key type attribute is set always from the "key row". It can't be overwritten |
|
527 $$commonHash{"key type"} = $keyType; |
|
528 |
|
529 # removed [ optional, we only defined, if specified] |
|
530 if($removed !~ /^\s*$/) |
|
531 { |
|
532 $$commonHash{"removed"} = $removed; |
|
533 } |
|
534 |
|
535 # shared data name [ optional, we only defined, if specified] |
|
536 if($sdName !~ /^\s*$/) |
|
537 { |
|
538 $$commonHash{"sd-name"} = $sdName; |
|
539 } |
|
540 |
|
541 ###################################################### |
|
542 # "release" => { |
|
543 # .... |
|
544 # } |
|
545 # information to this has in filled later on. |
|
546 ###################################################### |
|
547 $currKeyReleaseHash = addHash("release",$keyHash); |
|
548 } |
|
549 #------------------------------------------------------------ |
|
550 # Handle variant row |
|
551 #------------------------------------------------------------ |
|
552 elsif($release !~ /^\s*$/) |
|
553 { |
|
554 # harmonize the release syntax |
|
555 if($variant =~ /^\s*$/) |
|
556 { |
|
557 $variant = "default"; |
|
558 } |
|
559 my $relHashRef; |
|
560 if($lastActiveRowType == 3) |
|
561 { |
|
562 $relHashRef = addHash($variant,$currKeyReleaseHash); |
|
563 } |
|
564 elsif($lastActiveRowType == 2) |
|
565 { |
|
566 $relHashRef = addHash($variant,$currRangeHash); |
|
567 } |
|
568 elsif($lastActiveRowType == 1) |
|
569 { |
|
570 $relHashRef = addHash($variant,$currUidSpecificHash); |
|
571 } |
|
572 ###################################################### |
|
573 # <release> |
|
574 # => { |
|
575 # "R" => (<capa1ForReading>,<capa2ForReading>) |
|
576 # "W" => (<capa1ForWriting>,<capa2ForWriting>) |
|
577 # "RSid" => (<sidForReading>) |
|
578 # "WSid" => (<sidForWriting>) |
|
579 # "value" => <value> # only if this is for keys |
|
580 # "owner" => <uid> # only if this is for uid |
|
581 # "rfs" => <0/1> |
|
582 # "backup" => <0/1> |
|
583 # } |
|
584 ###################################################### |
|
585 $release =~ /s([0-9]+)\s+([0-9]+\.[0-9]+)/i; |
|
586 my $usedRel = "S$1 $2"; |
|
587 my $refToVarHash = addHash($usedRel,$relHashRef); |
|
588 # Value and owner are specific only to some variant row types. |
|
589 if($lastActiveRowType == 3) # This variant row is for a key |
|
590 { |
|
591 $$refToVarHash{"value"} = $value; |
|
592 } |
|
593 elsif($lastActiveRowType == 1) # This variant row is for the uid |
|
594 { |
|
595 $$refToVarHash{"owner"} = $uidOwner; |
|
596 } |
|
597 $$refToVarHash{"rfs"} = 0; |
|
598 if($rfs =~ /^\s*yes\s*$/i) |
|
599 { |
|
600 $$refToVarHash{"rfs"} = 1; |
|
601 } |
|
602 $$refToVarHash{"backup"} = 0; |
|
603 if($backup =~ /^\s*yes\s*$/i) |
|
604 { |
|
605 $$refToVarHash{"backup"} = 1; |
|
606 } |
|
607 if(!defined($$refToVarHash{"W"})) |
|
608 { |
|
609 my @list; |
|
610 $$refToVarHash{"W"} = \@list; |
|
611 } |
|
612 if(!defined($$refToVarHash{"R"})) |
|
613 { |
|
614 my @list; |
|
615 $$refToVarHash{"R"} = \@list; |
|
616 } |
|
617 |
|
618 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaNone,"AlwaysPass"); |
|
619 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaAlwaysPass,"AlwaysPass"); |
|
620 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaNetworkServices,"NetworkServices"); |
|
621 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaLocalServices,"Local Services"); |
|
622 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaReadUserData,"ReadUserData"); |
|
623 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaWriteUserData,"WriteUserData"); |
|
624 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaLocation,"Location"); |
|
625 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaReadDeviceData,"ReadDeviceData"); |
|
626 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaWriteDeviceData,"WriteDeviceData"); |
|
627 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaProtServ,"ProtServ"); |
|
628 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaDrm,"DRM"); |
|
629 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaSwEvent,"SwEvent"); |
|
630 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaPowerMgmt,"PowerMgmt"); |
|
631 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaAllFiles,"AllFiles"); |
|
632 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaDiskAdmin,"DiskAdmin"); |
|
633 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaNetworkControl,"NetworkControl"); |
|
634 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaMultiMediaDD,"MultiMediaDD"); |
|
635 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaCommDD,"CommDD"); |
|
636 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaTCB,"TCB"); |
|
637 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaTrustedUI,"TrustedUI"); |
|
638 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaUserEnv,"UserEnvironment"); |
|
639 addCapability($$refToVarHash{"R"},$$refToVarHash{"W"},$capaSurroundingsDD,"SurroundingsDD"); |
|
640 |
|
641 my @list1; |
|
642 $$refToVarHash{"RSid"} = \@list1; |
|
643 if($capaSidRead !~ /^\s*$/) |
|
644 { |
|
645 push(@list1,$capaSidRead); |
|
646 } |
|
647 my @list2; |
|
648 $$refToVarHash{"WSid"} = \@list2; |
|
649 if($capaSidWrite !~ /^\s*$/) |
|
650 { |
|
651 push(@list2,$capaSidWrite); |
|
652 } |
|
653 } |
|
654 } |
|
655 |
|
656 return $refToHash; |
|
657 } |
|
658 |
|
659 |
|
660 ########################################################################### |
|
661 # |
|
662 ########################################################################### |
|
663 sub checkRelease |
|
664 { |
|
665 my $row = shift; |
|
666 my $value = shift; |
|
667 my $columnName = shift; |
|
668 |
|
669 if($value !~ /^\s*S60\s+[1-9]+\.[0-9]+\s*$/ && $value !~ /^\s*$/) |
|
670 { |
|
671 print "Row $row: $columnName -column has wrong release syntax. (should be for instance \"S60 3.0\"\n"; |
|
672 return 1; |
|
673 } |
|
674 return 0; |
|
675 } |
|
676 |
|
677 ########################################################################### |
|
678 # |
|
679 ########################################################################### |
|
680 sub checkCapability |
|
681 { |
|
682 my $row = shift; |
|
683 my $value = shift; |
|
684 my $columnName = shift; |
|
685 |
|
686 if($value !~ /^\s*$/ && |
|
687 $value !~ /^R$/ && |
|
688 $value !~ /^W$/ && |
|
689 $value !~ /^RW$/ |
|
690 ) |
|
691 { |
|
692 print "Row $row: The $columnName -column has invalid value \"$value\".\n"; |
|
693 return 1; |
|
694 } |
|
695 return 0; |
|
696 } |
|
697 |
|
698 ########################################################################### |
|
699 # Makes syntax checks to the given worksheet |
|
700 # |
|
701 # |
|
702 # Params: referenceToWorksheet |
|
703 # |
|
704 ########################################################################### |
|
705 sub checkCentrepKeyInfo |
|
706 { |
|
707 my $refToWorksheet = shift; |
|
708 my $ignoreWarnings = shift; |
|
709 |
|
710 # ---------------------------------------------------------------- |
|
711 # look to header information |
|
712 # ---------------------------------------------------------------- |
|
713 my ($uidNameIndex,$uidValueIndex,$rangeFromIndex,$rangeToIndex, |
|
714 $keyNameValueIndex,$keyIntValueIndex,$sdNameIndex,$removedIndex,$releaseIndex,$variantNameIndex, |
|
715 $valueIndex,$readOnlyIndex, |
|
716 $keyTypeIndex,$backupIndex,$rfsIndex,$custConfigIndex,$capaNoneIndex,$capaAllIndex,$capaAllMinusTcbIndex,$capaNetworkServicesIndex, |
|
717 $capaLocalServicesIndex,$capaReadUserDataIndex,$capaWriteUserDataIndex,$capaLocationIndex,$capaReadDeviceDataIndex, |
|
718 $capaWriteDeviceDataIndex,$capaProtServIndex,$capaDrmIndex,$capaSwEventIndex,$capaPowerMgmtIndex,$capaAllFilesIndex, |
|
719 $capaDiskAdminIndex,$capaNetworkControlIndex,$capaMultiMediaDDIndex,$capaCommDDIndex, |
|
720 $capaTCBIndex,$capaTrustedUIIndex,$capaAlwaysPassIndex,$capaUserEnvIndex,$capaSurroundingsDDIndex, |
|
721 $capaSidReadIndex,$capaSidWriteIndex,$rangeFromIndex,$rangeToIndex,$ownerIndex) = readIndexes($refToWorksheet); |
|
722 if( $uidValueIndex < 0) |
|
723 { |
|
724 return; |
|
725 } |
|
726 |
|
727 my $row = 1; |
|
728 my $emptyRowCount = 0; |
|
729 |
|
730 ###################################################################### |
|
731 # Loop row by row until we have found $globalMaxEmptyRowCount of rows |
|
732 # empty one after each other. |
|
733 ###################################################################### |
|
734 my $currUid = ""; |
|
735 my $currRange = ""; |
|
736 my $lastActiveRowType = 0; # 0 = not defined, 1 = uid, 2 = range, 3 = key |
|
737 my $variantRowCount = 0; |
|
738 my $errorCount = 0; |
|
739 my $currentKeyType = ""; |
|
740 my $currentKeyReadOnly = ""; |
|
741 for( $row = 2;; $row++ ) |
|
742 { |
|
743 #------------------------------------------------------------ |
|
744 # We only allow $globalMaxEmptyRowCount empty rows, before we stop |
|
745 # handling the specific sheet |
|
746 #------------------------------------------------------------ |
|
747 if(! ( hasValue($refToWorksheet,$row, $uidValueIndex ) |
|
748 || hasValue($refToWorksheet,$row, $uidNameIndex ) |
|
749 || hasValue($refToWorksheet,$row, $keyNameValueIndex ) |
|
750 || hasValue($refToWorksheet,$row, $keyIntValueIndex ) |
|
751 || hasValue($refToWorksheet,$row, $releaseIndex ) |
|
752 || hasValue($refToWorksheet,$row, $rangeFromIndex ) |
|
753 || hasValue($refToWorksheet,$row, $rangeToIndex ) |
|
754 )) |
|
755 { |
|
756 $emptyRowCount++; |
|
757 if($emptyRowCount > $globalMaxEmptyRowCount) |
|
758 { |
|
759 if($variantRowCount == 0) |
|
760 { |
|
761 if($lastActiveRowType == 1) |
|
762 { |
|
763 print "Row $row: There were no variants defined for previous UID.\n"; |
|
764 print " This means among other things that default access is alwaysFail.\n"; |
|
765 $errorCount++; |
|
766 } |
|
767 elsif($lastActiveRowType == 2) |
|
768 { |
|
769 print "Row $row: There were no variants defined for previous range => range will not appear in ini-file.\n"; |
|
770 $errorCount++; |
|
771 } |
|
772 elsif($lastActiveRowType == 3) |
|
773 { |
|
774 print "Row $row: There were no variants defined for previous key => key will not appear in ini-file.\n"; |
|
775 $errorCount++; |
|
776 } |
|
777 } |
|
778 last; |
|
779 } |
|
780 next; |
|
781 } |
|
782 else |
|
783 { |
|
784 # Was not empty line, reset counter. |
|
785 $emptyRowCount = 0; |
|
786 } |
|
787 |
|
788 #------------------------------------------------------------ |
|
789 # Read the needed rows from the row |
|
790 #------------------------------------------------------------ |
|
791 my $uidName = readCol($refToWorksheet,$row,$uidNameIndex,""); |
|
792 my $uid = readCol($refToWorksheet,$row,$uidValueIndex,""); |
|
793 my $rangeFrom = readCol($refToWorksheet,$row,$rangeFromIndex,""); |
|
794 my $rangeTo = readCol($refToWorksheet,$row,$rangeToIndex,""); |
|
795 my $keyName = readCol($refToWorksheet,$row,$keyNameValueIndex,""); |
|
796 my $key = readCol($refToWorksheet,$row,$keyIntValueIndex,""); |
|
797 my $removed = readCol($refToWorksheet,$row,$removedIndex,""); |
|
798 my $release = readCol($refToWorksheet,$row,$releaseIndex,""); |
|
799 my $variant = readCol($refToWorksheet,$row,$variantNameIndex,""); |
|
800 my $value = readCol($refToWorksheet,$row,$valueIndex,""); |
|
801 my $ro = readCol($refToWorksheet,$row,$readOnlyIndex,""); |
|
802 my $keyType = readCol($refToWorksheet,$row,$keyTypeIndex,""); |
|
803 my $backup = readCol($refToWorksheet,$row,$backupIndex,""); |
|
804 my $rfs = readCol($refToWorksheet,$row,$rfsIndex,""); |
|
805 my $custConfig = readCol($refToWorksheet,$row,$custConfigIndex,""); |
|
806 my $capaNone = readCol($refToWorksheet,$row,$capaNoneIndex,""); |
|
807 my $capaAll = readCol($refToWorksheet,$row,$capaAllIndex,""); |
|
808 my $capaAllMinusTcb = readCol($refToWorksheet,$row,$capaAllMinusTcbIndex,""); |
|
809 my $capaNetworkServices = readCol($refToWorksheet,$row,$capaNetworkServicesIndex,""); |
|
810 my $capaLocalServices = readCol($refToWorksheet,$row,$capaLocalServicesIndex,""); |
|
811 my $capaReadUserData = readCol($refToWorksheet,$row,$capaReadUserDataIndex,""); |
|
812 my $capaWriteUserData = readCol($refToWorksheet,$row,$capaWriteUserDataIndex,""); |
|
813 my $capaLocation = readCol($refToWorksheet,$row,$capaLocationIndex,""); |
|
814 my $capaReadDeviceData = readCol($refToWorksheet,$row,$capaReadDeviceDataIndex,""); |
|
815 my $capaWriteDeviceData = readCol($refToWorksheet,$row,$capaWriteDeviceDataIndex,""); |
|
816 my $capaProtServ = readCol($refToWorksheet,$row,$capaProtServIndex,""); |
|
817 my $capaDrm = readCol($refToWorksheet,$row,$capaDrmIndex,""); |
|
818 my $capaSwEvent = readCol($refToWorksheet,$row,$capaSwEventIndex,""); |
|
819 my $capaPowerMgmt = readCol($refToWorksheet,$row,$capaPowerMgmtIndex,""); |
|
820 my $capaAllFiles = readCol($refToWorksheet,$row,$capaAllFilesIndex,""); |
|
821 my $capaDiskAdmin = readCol($refToWorksheet,$row,$capaDiskAdminIndex,""); |
|
822 my $capaNetworkControl = readCol($refToWorksheet,$row,$capaNetworkControlIndex,""); |
|
823 my $capaMultiMediaDD = readCol($refToWorksheet,$row,$capaMultiMediaDDIndex,""); |
|
824 my $capaCommDD = readCol($refToWorksheet,$row,$capaCommDDIndex,""); |
|
825 my $capaTCB = readCol($refToWorksheet,$row,$capaTCBIndex,""); |
|
826 my $capaTrustedUI = readCol($refToWorksheet,$row,$capaTrustedUIIndex,""); |
|
827 |
|
828 my $capaAlwaysPass = readCol($refToWorksheet,$row,$capaAlwaysPassIndex,""); |
|
829 my $capaUserEnv = readCol($refToWorksheet,$row,$capaUserEnvIndex,""); |
|
830 my $capaSurroundingsDD = readCol($refToWorksheet,$row,$capaSurroundingsDDIndex,""); |
|
831 my $capaSidRead = readCol($refToWorksheet,$row,$capaSidReadIndex,""); |
|
832 my $capaSidWrite = readCol($refToWorksheet,$row,$capaSidWriteIndex,""); |
|
833 my $rangeFrom = readCol($refToWorksheet,$row,$rangeFromIndex,""); |
|
834 my $rangeTo = readCol($refToWorksheet,$row,$rangeToIndex,""); |
|
835 my $uidOwner = readCol($refToWorksheet,$row,$ownerIndex,""); |
|
836 |
|
837 if($uidName =~ /^\s*Comment:/) |
|
838 { |
|
839 # comment rows are ignored |
|
840 print "Warning: Row $row ignored, since it is a comment row\n" if not $ignoreWarnings; |
|
841 next; |
|
842 } |
|
843 |
|
844 #------------------------------------------------------------ |
|
845 # Common checks |
|
846 #------------------------------------------------------------ |
|
847 if($uidName !~ /^\s*$/ && $uid =~ /^\s*$/) |
|
848 { |
|
849 # both uid and uidname have to be defined in the same row |
|
850 print "Row $row: Uid Name-column has value, but not the Uid Value-column\n"; |
|
851 $errorCount++; |
|
852 } |
|
853 if($keyName !~ /^\s*$/ && $key =~ /^\s*$/) |
|
854 { |
|
855 # both key int and keyname have to be defined in the same row |
|
856 print "Row $row: Key Name-column has value, but not the Key Int-column\n"; |
|
857 $errorCount++; |
|
858 } |
|
859 if($rangeTo !~ /^\s*$/ && $rangeFrom =~ /^\s*$/) |
|
860 { |
|
861 # if range to is defined, then also range from has to be defined. |
|
862 print "Row $row: Range To-column has value, but not the Range From-column\n"; |
|
863 $errorCount++; |
|
864 } |
|
865 if($rangeTo =~ /^\s*$/ && $rangeFrom !~ /^\s*$/) |
|
866 { |
|
867 # if range from is defined, then also range to has to be defined. |
|
868 print "Row $row: Range From-column has value, but not the Range To-column\n"; |
|
869 $errorCount++; |
|
870 } |
|
871 #------------------------------------------------------------ |
|
872 # Handle UID row |
|
873 #------------------------------------------------------------ |
|
874 if($uid !~ /^\s*$/) |
|
875 { |
|
876 $currUid = $uid; |
|
877 # Make sure that last uid/key/range had some variant rows |
|
878 if($variantRowCount == 0) |
|
879 { |
|
880 if($lastActiveRowType == 1) |
|
881 { |
|
882 print "Row $row: There were no variants defined for previous UID.\n"; |
|
883 print " This means among other things that default access is alwaysFail.\n"; |
|
884 $errorCount++; |
|
885 } |
|
886 elsif($lastActiveRowType == 2) |
|
887 { |
|
888 print "Row $row: There were no variants defined for previous range => range will not appear in ini-file.\n"; |
|
889 $errorCount++; |
|
890 } |
|
891 elsif($lastActiveRowType == 3) |
|
892 { |
|
893 print "Row $row: There were no variants defined for previous key => key will not appear in ini-file.\n"; |
|
894 $errorCount++; |
|
895 } |
|
896 } |
|
897 $lastActiveRowType = 1; |
|
898 $variantRowCount = 0; |
|
899 ####################################### |
|
900 # Check: In the uid row the only allowed |
|
901 # columns are "uid name", "uid value", "purpose" |
|
902 ####################################### |
|
903 if($rangeFrom !~ /^\s*$/) |
|
904 { |
|
905 print "Row $row: Range From-column is not allowed for uid row\n"; |
|
906 $errorCount++; |
|
907 } |
|
908 if($rangeTo !~ /^\s*$/) |
|
909 { |
|
910 print "Row $row: Range To-column is not allowed for uid row\n"; |
|
911 $errorCount++; |
|
912 } |
|
913 if($uidOwner !~ /^\s*$/) |
|
914 { |
|
915 print "Row $row: Owner-column is not allowed for uid row\n"; |
|
916 $errorCount++; |
|
917 } |
|
918 if($key !~ /^\s*$/) |
|
919 { |
|
920 print "Row $row: Key Int-column is not allowed for uid row\n"; |
|
921 $errorCount++; |
|
922 } |
|
923 if($value !~ /^\s*$/) |
|
924 { |
|
925 print "Row $row: Def value-column is not allowed for uid row\n"; |
|
926 $errorCount++; |
|
927 } |
|
928 if($rfs !~ /^\s*$/) |
|
929 { |
|
930 print "Row $row: RFS-column is not allowed for uid row\n"; |
|
931 $errorCount++; |
|
932 } |
|
933 if($ro !~ /^\s*$/) |
|
934 { |
|
935 print "Row $row: Read Only-column is not allowed for uid row\n"; |
|
936 $errorCount++; |
|
937 } |
|
938 if($keyType !~ /^\s*$/) |
|
939 { |
|
940 print "Row $row: Key Type-column is not allowed for uid row\n"; |
|
941 $errorCount++; |
|
942 } |
|
943 if($backup !~ /^\s*$/) |
|
944 { |
|
945 print "Row $row: Backup-column is not allowed for uid row\n"; |
|
946 $errorCount++; |
|
947 } |
|
948 if($custConfig !~ /^\s*$/) |
|
949 { |
|
950 print "Row $row: Cust Config-column is not allowed for uid row\n"; |
|
951 $errorCount++; |
|
952 } |
|
953 ####################################### |
|
954 # Check: Check that uid is in hex format |
|
955 ####################################### |
|
956 if($uid != /^\s*0x/) |
|
957 { |
|
958 print "Row $row: The Uid value has to be a hex value (starting with 0x)\n"; |
|
959 $errorCount++; |
|
960 } |
|
961 elsif(length($uid) != 10) |
|
962 { |
|
963 print "Row $row: The Uid length is not correct. Are you sure that the Uid is correct ?\n"; |
|
964 $errorCount++; |
|
965 } |
|
966 ####################################### |
|
967 # Check: Check that no capas defined |
|
968 ####################################### |
|
969 if( $capaNone !~ /^\s*$/ || |
|
970 $capaAll !~ /^\s*$/ || |
|
971 $capaAllMinusTcb !~ /^\s*$/ || |
|
972 $capaNetworkServices !~ /^\s*$/ || |
|
973 $capaLocalServices !~ /^\s*$/ || |
|
974 $capaReadUserData !~ /^\s*$/ || |
|
975 $capaWriteUserData !~ /^\s*$/ || |
|
976 $capaLocation !~ /^\s*$/ || |
|
977 $capaReadDeviceData !~ /^\s*$/ || |
|
978 $capaWriteDeviceData !~ /^\s*$/ || |
|
979 $capaProtServ !~ /^\s*$/ || |
|
980 $capaDrm !~ /^\s*$/ || |
|
981 $capaSwEvent !~ /^\s*$/ || |
|
982 $capaPowerMgmt !~ /^\s*$/ || |
|
983 $capaAllFiles !~ /^\s*$/ || |
|
984 $capaDiskAdmin !~ /^\s*$/ || |
|
985 $capaNetworkControl !~ /^\s*$/ || |
|
986 $capaMultiMediaDD !~ /^\s*$/ || |
|
987 $capaCommDD !~ /^\s*$/ || |
|
988 $capaTCB !~ /^\s*$/ || |
|
989 $capaTrustedUI !~ /^\s*$/ || |
|
990 $capaAlwaysPass !~ /^\s*$/ || |
|
991 $capaUserEnv !~ /^\s*$/ || |
|
992 $capaSurroundingsDD !~ /^\s*$/ || |
|
993 $capaSidRead !~ /^\s*$/ || |
|
994 $capaSidWrite !~ /^\s*$/ |
|
995 ) |
|
996 { |
|
997 print "Row $row: Capabilities are not allowed to be defined in UID row.\n"; |
|
998 $errorCount++; |
|
999 } |
|
1000 } |
|
1001 #------------------------------------------------------------ |
|
1002 # Handle range row |
|
1003 #------------------------------------------------------------ |
|
1004 elsif($rangeFrom !~ /^\s*$/) |
|
1005 { |
|
1006 # Make sure that last uid/key/range had some variant rows |
|
1007 if($variantRowCount == 0) |
|
1008 { |
|
1009 if($lastActiveRowType == 1) |
|
1010 { |
|
1011 print "Row $row: There were no variants defined for previous UID.\n"; |
|
1012 print " This means among other things that default access is alwaysFail.\n"; |
|
1013 $errorCount++; |
|
1014 } |
|
1015 elsif($lastActiveRowType == 2) |
|
1016 { |
|
1017 print "Row $row: There were no variants defined for previous range => range will not appear in ini-file.\n"; |
|
1018 $errorCount++; |
|
1019 } |
|
1020 elsif($lastActiveRowType == 3) |
|
1021 { |
|
1022 print "Row $row: There were no variants defined for previous key => key will not appear in ini-file.\n"; |
|
1023 $errorCount++; |
|
1024 } |
|
1025 } |
|
1026 $variantRowCount = 0; |
|
1027 $lastActiveRowType = 2; |
|
1028 |
|
1029 if($rangeTo =~ /^\s*$/) |
|
1030 { |
|
1031 print "Row $row: You have to specify both Range To and Range From in the range row.\n"; |
|
1032 $errorCount++; |
|
1033 } |
|
1034 ####################################### |
|
1035 # Check: There has to be uid defined before any ranges |
|
1036 ####################################### |
|
1037 if($currUid =~ /^\s*$/) |
|
1038 { |
|
1039 print "Row $row: Before any ranges are defined, an UID has to be defined\n"; |
|
1040 $errorCount++; |
|
1041 } |
|
1042 |
|
1043 ####################################### |
|
1044 # Check: In the range row the only allowed |
|
1045 # columns are "range from", "range to", "purpose", "removed" |
|
1046 ####################################### |
|
1047 if($uid !~ /^\s*$/) |
|
1048 { |
|
1049 print "Row $row: Uid-column is not allowed for range row\n"; |
|
1050 $errorCount++; |
|
1051 } |
|
1052 if($uidName !~ /^\s*$/) |
|
1053 { |
|
1054 print "Row $row: Uid Name-column is not allowed for uid row\n"; |
|
1055 $errorCount++; |
|
1056 } |
|
1057 if($uidOwner !~ /^\s*$/) |
|
1058 { |
|
1059 print "Row $row: Owner-column is not allowed for range row\n"; |
|
1060 $errorCount++; |
|
1061 } |
|
1062 if($key !~ /^\s*$/) |
|
1063 { |
|
1064 print "Row $row: Key Int-column is not allowed for range row\n"; |
|
1065 $errorCount++; |
|
1066 } |
|
1067 if($value !~ /^\s*$/) |
|
1068 { |
|
1069 print "Row $row: Def value-column is not allowed for range row\n"; |
|
1070 $errorCount++; |
|
1071 } |
|
1072 if($rfs !~ /^\s*$/) |
|
1073 { |
|
1074 print "Row $row: RFS-column is not allowed for range row\n"; |
|
1075 $errorCount++; |
|
1076 } |
|
1077 if($ro !~ /^\s*$/) |
|
1078 { |
|
1079 print "Row $row: Read Only-column is not allowed for range row\n"; |
|
1080 $errorCount++; |
|
1081 } |
|
1082 if($keyType !~ /^\s*$/) |
|
1083 { |
|
1084 print "Row $row: Key Type-column is not allowed for range row\n"; |
|
1085 $errorCount++; |
|
1086 } |
|
1087 if($backup !~ /^\s*$/) |
|
1088 { |
|
1089 print "Row $row: Backup-column is not allowed for range row\n"; |
|
1090 $errorCount++; |
|
1091 } |
|
1092 if($custConfig !~ /^\s*$/) |
|
1093 { |
|
1094 print "Row $row: Cust Config-column is not allowed for range row\n"; |
|
1095 $errorCount++; |
|
1096 } |
|
1097 ####################################### |
|
1098 # Check: Check that range from and range to are in hex format |
|
1099 ####################################### |
|
1100 if($rangeFrom != /^\s*0x/) |
|
1101 { |
|
1102 print "Row $row: The range from value has to be a hex value (starting with 0x)\n"; |
|
1103 $errorCount++; |
|
1104 } |
|
1105 elsif(length($rangeFrom) != 10) |
|
1106 { |
|
1107 print "Row $row: The range from-length is not correct. Are you sure that the range is correct ?\n"; |
|
1108 $errorCount++; |
|
1109 } |
|
1110 if($rangeTo != /^\s*0x/) |
|
1111 { |
|
1112 print "Row $row: The range to- value has to be a hex value (starting with 0x)\n"; |
|
1113 $errorCount++; |
|
1114 } |
|
1115 elsif(length($rangeTo) != 10) |
|
1116 { |
|
1117 print "Row $row: The range to-length is not correct. Are you sure that the range is correct ?\n"; |
|
1118 $errorCount++; |
|
1119 } |
|
1120 ####################################### |
|
1121 # Check: Check that no capas defined |
|
1122 ####################################### |
|
1123 if( $capaNone !~ /^\s*$/ || |
|
1124 $capaAll !~ /^\s*$/ || |
|
1125 $capaAllMinusTcb !~ /^\s*$/ || |
|
1126 $capaNetworkServices !~ /^\s*$/ || |
|
1127 $capaLocalServices !~ /^\s*$/ || |
|
1128 $capaReadUserData !~ /^\s*$/ || |
|
1129 $capaWriteUserData !~ /^\s*$/ || |
|
1130 $capaLocation !~ /^\s*$/ || |
|
1131 $capaReadDeviceData !~ /^\s*$/ || |
|
1132 $capaWriteDeviceData !~ /^\s*$/ || |
|
1133 $capaProtServ !~ /^\s*$/ || |
|
1134 $capaDrm !~ /^\s*$/ || |
|
1135 $capaSwEvent !~ /^\s*$/ || |
|
1136 $capaPowerMgmt !~ /^\s*$/ || |
|
1137 $capaAllFiles !~ /^\s*$/ || |
|
1138 $capaDiskAdmin !~ /^\s*$/ || |
|
1139 $capaNetworkControl !~ /^\s*$/ || |
|
1140 $capaMultiMediaDD !~ /^\s*$/ || |
|
1141 $capaCommDD !~ /^\s*$/ || |
|
1142 $capaTCB !~ /^\s*$/ || |
|
1143 $capaTrustedUI !~ /^\s*$/ || |
|
1144 $capaAlwaysPass !~ /^\s*$/ || |
|
1145 $capaUserEnv !~ /^\s*$/ || |
|
1146 $capaSurroundingsDD !~ /^\s*$/ || |
|
1147 $capaSidRead !~ /^\s*$/ || |
|
1148 $capaSidWrite !~ /^\s*$/ |
|
1149 ) |
|
1150 { |
|
1151 print "Row $row: Capabilities are not allowed to be defined in range row.\n"; |
|
1152 $errorCount++; |
|
1153 } |
|
1154 } |
|
1155 #------------------------------------------------------------ |
|
1156 # Handle key row |
|
1157 #------------------------------------------------------------ |
|
1158 elsif($key !~ /^\s*$/) |
|
1159 { |
|
1160 # Make sure that last uid/key/range had some variant rows |
|
1161 if($variantRowCount == 0) |
|
1162 { |
|
1163 if($lastActiveRowType == 1) |
|
1164 { |
|
1165 print "Row $row: There were no variants defined for previous UID.\n"; |
|
1166 print " This means among other things that default access is alwaysFail.\n"; |
|
1167 $errorCount++; |
|
1168 } |
|
1169 elsif($lastActiveRowType == 2) |
|
1170 { |
|
1171 print "Row $row: There were no variants defined for previous range => range will not appear in ini-file.\n"; |
|
1172 $errorCount++; |
|
1173 } |
|
1174 elsif($lastActiveRowType == 3) |
|
1175 { |
|
1176 print "Row $row: There were no variants defined for previous key => key will not appear in ini-file.\n"; |
|
1177 $errorCount++; |
|
1178 } |
|
1179 } |
|
1180 $variantRowCount = 0; |
|
1181 $lastActiveRowType = 3; |
|
1182 |
|
1183 $currentKeyType = $keyType; |
|
1184 # Store the ro value into the variable (we need this to handle the key variant rows |
|
1185 $currentKeyReadOnly = $ro; |
|
1186 |
|
1187 ####################################### |
|
1188 # Check: There has to be uid defined before any keys |
|
1189 ####################################### |
|
1190 if($currUid =~ /^\s*$/) |
|
1191 { |
|
1192 print "Row $row: Before any keys are defined an UID has to be defined\n"; |
|
1193 $errorCount++; |
|
1194 } |
|
1195 |
|
1196 ####################################### |
|
1197 # Check: Check that key int is in hex format |
|
1198 ####################################### |
|
1199 if($key !~ /^\s*0x/) |
|
1200 { |
|
1201 print "Row $row: The Key Int has to be a hex value (starting with 0x)\n"; |
|
1202 $errorCount++; |
|
1203 } |
|
1204 elsif(length($key) != 10) |
|
1205 { |
|
1206 print "Row $row: The Key int length is not correct. Are you sure that the hex value is correct ?\n"; |
|
1207 $errorCount++; |
|
1208 } |
|
1209 |
|
1210 ####################################### |
|
1211 # Check: Check that key type and read only are defined |
|
1212 ####################################### |
|
1213 if($keyType =~ /^\s*$/) |
|
1214 { |
|
1215 print "Row $row: The Key Type-column has to be defined in row, where key is defined.\n"; |
|
1216 $errorCount++; |
|
1217 } |
|
1218 if($ro =~ /^\s*$/) |
|
1219 { |
|
1220 print "Row $row: The Read Only-column has to be defined in row, where key is defined.\n"; |
|
1221 $errorCount++; |
|
1222 } |
|
1223 |
|
1224 ####################################### |
|
1225 # Check: key type column |
|
1226 ####################################### |
|
1227 if($keyType !~ /^Int$/ && |
|
1228 $keyType !~ /^Real$/ && |
|
1229 $keyType !~ /^Str$/ && |
|
1230 $keyType !~ /^Bin$/ |
|
1231 ) |
|
1232 { |
|
1233 print "Row $row: The Key type-column has invalid value.\n"; |
|
1234 $errorCount++; |
|
1235 } |
|
1236 |
|
1237 ####################################### |
|
1238 # Check: Removed column syntax |
|
1239 ####################################### |
|
1240 $errorCount += checkRelease($row,$removed,"Removed"); |
|
1241 |
|
1242 ####################################### |
|
1243 # Check: columns that should not be in key row |
|
1244 ####################################### |
|
1245 if($rangeFrom !~ /^\s*$/) |
|
1246 { |
|
1247 print "Row $row: Range From-column is not allowed for key row\n"; |
|
1248 $errorCount++; |
|
1249 } |
|
1250 if($rangeTo !~ /^\s*$/) |
|
1251 { |
|
1252 print "Row $row: Range To-column is not allowed for key row\n"; |
|
1253 $errorCount++; |
|
1254 } |
|
1255 if($uidOwner !~ /^\s*$/) |
|
1256 { |
|
1257 print "Row $row: Owner-column is not allowed for key row\n"; |
|
1258 $errorCount++; |
|
1259 } |
|
1260 if($release !~ /^\s*$/) |
|
1261 { |
|
1262 print "Row $row: Platform Release-column is not allowed for key row\n"; |
|
1263 $errorCount++; |
|
1264 } |
|
1265 if($value !~ /^\s*$/) |
|
1266 { |
|
1267 print "Row $row: Def value-column is not allowed for key row\n"; |
|
1268 $errorCount++; |
|
1269 } |
|
1270 if($rfs !~ /^\s*$/) |
|
1271 { |
|
1272 print "Row $row: RFS-column is not allowed for key row\n"; |
|
1273 $errorCount++; |
|
1274 } |
|
1275 if($backup !~ /^\s*$/) |
|
1276 { |
|
1277 print "Row $row: Backup-column is not allowed for key row\n"; |
|
1278 $errorCount++; |
|
1279 } |
|
1280 if($custConfig !~ /^\s*$/) |
|
1281 { |
|
1282 print "Row $row: Cust Config-column is not allowed for key row\n"; |
|
1283 $errorCount++; |
|
1284 } |
|
1285 ####################################### |
|
1286 # Check: Check that no capas defined |
|
1287 ####################################### |
|
1288 if( $capaNone !~ /^\s*$/ || |
|
1289 $capaAll !~ /^\s*$/ || |
|
1290 $capaAllMinusTcb !~ /^\s*$/ || |
|
1291 $capaNetworkServices !~ /^\s*$/ || |
|
1292 $capaLocalServices !~ /^\s*$/ || |
|
1293 $capaReadUserData !~ /^\s*$/ || |
|
1294 $capaWriteUserData !~ /^\s*$/ || |
|
1295 $capaLocation !~ /^\s*$/ || |
|
1296 $capaReadDeviceData !~ /^\s*$/ || |
|
1297 $capaWriteDeviceData !~ /^\s*$/ || |
|
1298 $capaProtServ !~ /^\s*$/ || |
|
1299 $capaDrm !~ /^\s*$/ || |
|
1300 $capaSwEvent !~ /^\s*$/ || |
|
1301 $capaPowerMgmt !~ /^\s*$/ || |
|
1302 $capaAllFiles !~ /^\s*$/ || |
|
1303 $capaDiskAdmin !~ /^\s*$/ || |
|
1304 $capaNetworkControl !~ /^\s*$/ || |
|
1305 $capaMultiMediaDD !~ /^\s*$/ || |
|
1306 $capaCommDD !~ /^\s*$/ || |
|
1307 $capaTCB !~ /^\s*$/ || |
|
1308 $capaTrustedUI !~ /^\s*$/ || |
|
1309 $capaAlwaysPass !~ /^\s*$/ || |
|
1310 $capaUserEnv !~ /^\s*$/ || |
|
1311 $capaSurroundingsDD !~ /^\s*$/ || |
|
1312 $capaSidRead !~ /^\s*$/ || |
|
1313 $capaSidWrite !~ /^\s*$/ |
|
1314 ) |
|
1315 { |
|
1316 print "Row $row: Capabilities are not allowed to be defined in Key row.\n"; |
|
1317 $errorCount++; |
|
1318 } |
|
1319 } |
|
1320 #------------------------------------------------------------ |
|
1321 # Handle variant row |
|
1322 #------------------------------------------------------------ |
|
1323 elsif($release !~ /^\s*$/) |
|
1324 { |
|
1325 $variantRowCount++; |
|
1326 ####################################### |
|
1327 # Check: Variant row should not contain removed, keyType or Read only column |
|
1328 ####################################### |
|
1329 if($keyType !~ /^\s*$/) |
|
1330 { |
|
1331 print "Row $row: The Key Type-column can't be defined in variant-row.\n"; |
|
1332 $errorCount++; |
|
1333 } |
|
1334 if($ro !~ /^\s*$/) |
|
1335 { |
|
1336 print "Row $row: The Read Only-column can't be defined in variant-row.\n"; |
|
1337 $errorCount++; |
|
1338 } |
|
1339 if($removed !~ /^\s*$/) |
|
1340 { |
|
1341 print "Row $row: The Removed-column can't be defined in variant-row.\n"; |
|
1342 $errorCount++; |
|
1343 } |
|
1344 |
|
1345 ####################################### |
|
1346 # Check: Platform release column syntax |
|
1347 ####################################### |
|
1348 $errorCount += checkRelease($row,$release,"Platform Release"); |
|
1349 |
|
1350 ####################################### |
|
1351 # Check: Owner value only allowed for uid variant row |
|
1352 ####################################### |
|
1353 if( $lastActiveRowType == 1) |
|
1354 { |
|
1355 if($uidOwner =~ /^\s*$/) |
|
1356 { |
|
1357 print "Row $row: No owner defined for the uid variant row.\n"; |
|
1358 $errorCount++; |
|
1359 } |
|
1360 } |
|
1361 elsif( $lastActiveRowType != 1) |
|
1362 { |
|
1363 if($uidOwner !~ /^\s*$/) |
|
1364 { |
|
1365 print "Row $row: Owner-column is only valid for the uid variant row.\n"; |
|
1366 $errorCount++; |
|
1367 } |
|
1368 } |
|
1369 ####################################### |
|
1370 # Check: Variant name column |
|
1371 ####################################### |
|
1372 if($variant !~ /^\s*$/ && |
|
1373 $variant !~ /^elaf$/ && |
|
1374 $variant !~ /^apac$/ && |
|
1375 $variant !~ /^thai$/ && |
|
1376 $variant !~ /^japan$/ && |
|
1377 $variant !~ /^gsm$/ && |
|
1378 $variant !~ /^low_cost$/ |
|
1379 ) |
|
1380 { |
|
1381 print "Row $row: The Variant name-column has invalid value.\n"; |
|
1382 $errorCount++; |
|
1383 } |
|
1384 |
|
1385 ####################################### |
|
1386 # Check: def value column |
|
1387 # (empty value only allowed in case of str and binary) |
|
1388 # Checks only valid, if the row is key's variant row. |
|
1389 # for other we check that the column is not filled. |
|
1390 ####################################### |
|
1391 if( $lastActiveRowType == 3) |
|
1392 { |
|
1393 if($currentKeyType !~ /^Str$/ && $currentKeyType !~ /^Bin$/ && $value =~ /^\s*$/) |
|
1394 { |
|
1395 print "Row $row: The Def value-column has to have some value.\n"; |
|
1396 $errorCount++; |
|
1397 } |
|
1398 if($currentKeyType =~ /^Int$/ && $value !~ /^\-*[0-9]+$/) |
|
1399 { |
|
1400 print "Row $row: The Def value-column has to be a number, since type is Int.\n"; |
|
1401 $errorCount++; |
|
1402 } |
|
1403 if($currentKeyType =~ /^Real$/ && $value !~ /^\-*[0-9\.]+$/) |
|
1404 { |
|
1405 print "Row $row: The Def value-column has to be a number, since type is Real.\n"; |
|
1406 $errorCount++; |
|
1407 } |
|
1408 } |
|
1409 elsif($value !~ /^\s*$/) |
|
1410 { |
|
1411 print "Row $row: The Def value-column should not be defined for "; |
|
1412 if($lastActiveRowType ==1) |
|
1413 { |
|
1414 print "Uid variant row\n"; |
|
1415 } |
|
1416 elsif($lastActiveRowType ==2) |
|
1417 { |
|
1418 print "range variant row\n"; |
|
1419 } |
|
1420 $errorCount++; |
|
1421 } |
|
1422 |
|
1423 ####################################### |
|
1424 # Check: backup and rfs columns |
|
1425 ####################################### |
|
1426 if($backup =~ /^\s*$/) |
|
1427 { |
|
1428 print "Row $row: The Backup-column has to be specified in variant row.\n"; |
|
1429 $errorCount++; |
|
1430 } |
|
1431 elsif($backup !~ /^Yes$/ && |
|
1432 $backup !~ /^No$/ |
|
1433 ) |
|
1434 { |
|
1435 print "Row $row: The Backup-column has invalid value.\n"; |
|
1436 $errorCount++; |
|
1437 } |
|
1438 if($release !~ /^\s*$/ && $lastActiveRowType == 3 && $currentKeyReadOnly =~ /yes/i && $backup =~ /^Yes$/) |
|
1439 { |
|
1440 print "Row $row: A readonly key should not be backed up.\n"; |
|
1441 $errorCount++; |
|
1442 } |
|
1443 |
|
1444 if($rfs =~ /^\s*$/) |
|
1445 { |
|
1446 print "Row $row: The RFS-column has to have value in the variant row.\n"; |
|
1447 $errorCount++; |
|
1448 } |
|
1449 elsif($rfs !~ /^Yes$/ && |
|
1450 $rfs !~ /^No$/ |
|
1451 ) |
|
1452 { |
|
1453 print "Row $row: The RFS-column has invalid value.\n"; |
|
1454 $errorCount++; |
|
1455 } |
|
1456 if($release !~ /^\s*$/ && $lastActiveRowType == 3 && $currentKeyReadOnly =~ /yes/i && $rfs =~ /^Yes$/) |
|
1457 { |
|
1458 print "Row $row: A readonly key should not have RFS as yes.\n"; |
|
1459 $errorCount++; |
|
1460 } |
|
1461 |
|
1462 ####################################### |
|
1463 # Check: customer config column |
|
1464 # Only allowed for key variant row |
|
1465 ####################################### |
|
1466 if( $lastActiveRowType == 3) |
|
1467 { |
|
1468 if($custConfig =~ /^\s*$/) |
|
1469 { |
|
1470 print "Row $row: The Cust Config-column has to have value in the variant row.\n"; |
|
1471 $errorCount++; |
|
1472 } |
|
1473 elsif($custConfig !~ /^Yes$/ && |
|
1474 $custConfig !~ /^No$/ && |
|
1475 $custConfig !~ /^Must$/ |
|
1476 ) |
|
1477 { |
|
1478 print "Row $row: The Cust config-column has invalid value.\n"; |
|
1479 $errorCount++; |
|
1480 } |
|
1481 } |
|
1482 elsif($custConfig !~ /^\s*$/) |
|
1483 { |
|
1484 print "Row $row: The Cust Config-column should not be defined in "; |
|
1485 if($lastActiveRowType ==1) |
|
1486 { |
|
1487 print "Uid variant row.\n"; |
|
1488 } |
|
1489 elsif($lastActiveRowType ==2) |
|
1490 { |
|
1491 print "range variant row.\n"; |
|
1492 } |
|
1493 $errorCount++; |
|
1494 } |
|
1495 ####################################### |
|
1496 # Check: at least one capability needs to be specified if release is specified |
|
1497 ####################################### |
|
1498 if($release !~ /^\s*$/) |
|
1499 { |
|
1500 if( $capaNone =~ /^\s*$/ && |
|
1501 $capaAll =~ /^\s*$/ && |
|
1502 $capaAllMinusTcb =~ /^\s*$/ && |
|
1503 $capaNetworkServices =~ /^\s*$/ && |
|
1504 $capaLocalServices =~ /^\s*$/ && |
|
1505 $capaReadUserData =~ /^\s*$/ && |
|
1506 $capaWriteUserData =~ /^\s*$/ && |
|
1507 $capaLocation =~ /^\s*$/ && |
|
1508 $capaReadDeviceData =~ /^\s*$/ && |
|
1509 $capaWriteDeviceData =~ /^\s*$/ && |
|
1510 $capaProtServ =~ /^\s*$/ && |
|
1511 $capaDrm =~ /^\s*$/ && |
|
1512 $capaSwEvent =~ /^\s*$/ && |
|
1513 $capaPowerMgmt =~ /^\s*$/ && |
|
1514 $capaAllFiles =~ /^\s*$/ && |
|
1515 $capaDiskAdmin =~ /^\s*$/ && |
|
1516 $capaNetworkControl =~ /^\s*$/ && |
|
1517 $capaMultiMediaDD =~ /^\s*$/ && |
|
1518 $capaCommDD =~ /^\s*$/ && |
|
1519 $capaTCB =~ /^\s*$/ && |
|
1520 $capaTrustedUI =~ /^\s*$/ && |
|
1521 $capaAlwaysPass =~ /^\s*$/ && |
|
1522 $capaUserEnv =~ /^\s*$/ && |
|
1523 $capaSurroundingsDD =~ /^\s*$/ && |
|
1524 $capaSidRead =~ /^\s*$/ && |
|
1525 $capaSidWrite =~ /^\s*$/ |
|
1526 ) |
|
1527 { |
|
1528 print "Row $row: At least some capability colums has to have some value, since Platform Release-column is defined.\n"; |
|
1529 $errorCount++; |
|
1530 } |
|
1531 } |
|
1532 |
|
1533 ####################################### |
|
1534 # Check: if this is variant row for key, then if the key is read-only key, then |
|
1535 # there should be no "W" defined |
|
1536 ####################################### |
|
1537 if($release !~ /^\s*$/ && $lastActiveRowType == 3 && $currentKeyReadOnly =~ /yes/i) |
|
1538 { |
|
1539 if( $capaNone =~ /W/i || |
|
1540 $capaAll =~ /W/i || |
|
1541 $capaAllMinusTcb =~ /W/i || |
|
1542 $capaNetworkServices =~ /W/i || |
|
1543 $capaLocalServices =~ /W/i || |
|
1544 $capaReadUserData =~ /W/i || |
|
1545 $capaWriteUserData =~ /W/i || |
|
1546 $capaLocation =~ /W/i || |
|
1547 $capaReadDeviceData =~ /W/i || |
|
1548 $capaWriteDeviceData =~ /W/i || |
|
1549 $capaProtServ =~ /W/i || |
|
1550 $capaDrm =~ /W/i || |
|
1551 $capaSwEvent =~ /W/i || |
|
1552 $capaPowerMgmt =~ /W/i || |
|
1553 $capaAllFiles =~ /W/i || |
|
1554 $capaDiskAdmin =~ /W/i || |
|
1555 $capaNetworkControl =~ /W/i || |
|
1556 $capaMultiMediaDD =~ /W/i || |
|
1557 $capaCommDD =~ /W/i || |
|
1558 $capaTCB =~ /W/i || |
|
1559 $capaTrustedUI =~ /W/i || |
|
1560 $capaAlwaysPass =~ /W/i || |
|
1561 $capaUserEnv =~ /W/i || |
|
1562 $capaSurroundingsDD =~ /W/i || |
|
1563 $capaSidRead =~ /W/i || |
|
1564 $capaSidWrite =~ /W/i |
|
1565 ) |
|
1566 { |
|
1567 print "Row $row: Since the key is read-only, there should be no W-capa defined.\n"; |
|
1568 $errorCount++; |
|
1569 } |
|
1570 } |
|
1571 ####################################### |
|
1572 # Check: checking the usage of the "R"-capa. |
|
1573 ####################################### |
|
1574 if($release !~ /^\s*$/ && $lastActiveRowType == 3) |
|
1575 { |
|
1576 # You should not use R-capa with the below capabilities |
|
1577 if( $capaWriteUserData =~ /R/i || |
|
1578 $capaWriteDeviceData =~ /R/i || |
|
1579 $capaSidWrite =~ /R/i |
|
1580 ) |
|
1581 { |
|
1582 print "Row $row: R-capa should not be used with association of Write-related capas.\n"; |
|
1583 $errorCount++; |
|
1584 } |
|
1585 |
|
1586 # In 99% cases you should allow R-to be always "alwayspass". Thus we report this as an error. |
|
1587 if( $capaNone =~ /R/i || |
|
1588 $capaAll =~ /R/i || |
|
1589 $capaAllMinusTcb =~ /R/i || |
|
1590 $capaNetworkServices =~ /R/i || |
|
1591 $capaLocalServices =~ /R/i || |
|
1592 $capaReadUserData =~ /R/i || |
|
1593 $capaWriteUserData =~ /R/i || |
|
1594 $capaLocation =~ /R/i || |
|
1595 $capaReadDeviceData =~ /R/i || |
|
1596 $capaWriteDeviceData =~ /R/i || |
|
1597 $capaProtServ =~ /R/i || |
|
1598 $capaDrm =~ /R/i || |
|
1599 $capaSwEvent =~ /R/i || |
|
1600 $capaPowerMgmt =~ /R/i || |
|
1601 $capaAllFiles =~ /R/i || |
|
1602 $capaDiskAdmin =~ /R/i || |
|
1603 $capaNetworkControl =~ /R/i || |
|
1604 $capaMultiMediaDD =~ /R/i || |
|
1605 $capaCommDD =~ /R/i || |
|
1606 $capaTCB =~ /R/i || |
|
1607 $capaTrustedUI =~ /R/i || |
|
1608 $capaUserEnv =~ /R/i || |
|
1609 $capaSurroundingsDD =~ /R/i || |
|
1610 $capaSidRead =~ /R/i || |
|
1611 $capaSidWrite =~ /R/i |
|
1612 ) |
|
1613 { |
|
1614 print "Row $row: NOTE: only sensitive data (passwords and alike) should be protected for reading.\n"; |
|
1615 print " In normal case read should be allowed for everyone (== AlwaysPass-capa).\n"; |
|
1616 print " Depending on the mening of key this is/is not an error (99% of cases this is an error).\n"; |
|
1617 $errorCount++; |
|
1618 } |
|
1619 } |
|
1620 ####################################### |
|
1621 # Check: capability colums |
|
1622 ####################################### |
|
1623 $errorCount += checkCapability($row,$capaNone,"None"); |
|
1624 $errorCount += checkCapability($row,$capaAll,"All"); |
|
1625 $errorCount += checkCapability($row,$capaAllMinusTcb,"All - TCB"); |
|
1626 $errorCount += checkCapability($row,$capaNetworkServices,"NetworkServices"); |
|
1627 $errorCount += checkCapability($row,$capaLocalServices,"Local Services"); |
|
1628 $errorCount += checkCapability($row,$capaReadUserData,"ReadUserData"); |
|
1629 $errorCount += checkCapability($row,$capaWriteUserData,"WriteUserData"); |
|
1630 $errorCount += checkCapability($row,$capaLocation,"Location"); |
|
1631 $errorCount += checkCapability($row,$capaReadDeviceData,"ReadDeviceData"); |
|
1632 $errorCount += checkCapability($row,$capaWriteDeviceData,"WriteDeviceData"); |
|
1633 $errorCount += checkCapability($row,$capaProtServ,"ProtServ"); |
|
1634 $errorCount += checkCapability($row,$capaDrm,"DRM"); |
|
1635 $errorCount += checkCapability($row,$capaSwEvent,"SwEvent"); |
|
1636 $errorCount += checkCapability($row,$capaPowerMgmt,"PowerMgmt"); |
|
1637 $errorCount += checkCapability($row,$capaAllFiles,"AllFiles"); |
|
1638 $errorCount += checkCapability($row,$capaDiskAdmin,"DiskAdmin"); |
|
1639 $errorCount += checkCapability($row,$capaNetworkControl,"NetworkControl"); |
|
1640 $errorCount += checkCapability($row,$capaMultiMediaDD,"MultiMediaDD"); |
|
1641 $errorCount += checkCapability($row,$capaCommDD,"CommDD"); |
|
1642 $errorCount += checkCapability($row,$capaTCB,"TCB"); |
|
1643 $errorCount += checkCapability($row,$capaAlwaysPass,"AlwaysPass"); |
|
1644 $errorCount += checkCapability($row,$capaUserEnv,"UserEnvironment"); |
|
1645 $errorCount += checkCapability($row,$capaSurroundingsDD,"SurroundingsDD"); |
|
1646 if($capaSidRead !~ /^\s*$/ && $capaSidRead !~ /^0x[0-9]{8}$/) |
|
1647 { |
|
1648 print "Row $row: the Sid Read-column has invalid value. Only 1 sid is allowed in hex format.\n"; |
|
1649 $errorCount++; |
|
1650 } |
|
1651 if($capaSidWrite !~ /^\s*$/ && $capaSidWrite !~ /^0x[0-9]{8}$/) |
|
1652 { |
|
1653 print "Row $row: the Sid Write-column has invalid value. Only 1 sid is allowed in hex format.\n"; |
|
1654 $errorCount++; |
|
1655 } |
|
1656 |
|
1657 ####################################### |
|
1658 # Check: capability colums limitations |
|
1659 # max capability checks are: |
|
1660 # 7 capabilities |
|
1661 # 1 sid and 3 capabilities |
|
1662 ####################################### |
|
1663 my @rList; |
|
1664 my @wList; |
|
1665 addCapability(\@rList,\@wList,$capaNone,"AlwaysPass"); |
|
1666 addCapability(\@rList,\@wList,$capaAlwaysPass,"AlwaysPass"); |
|
1667 addCapability(\@rList,\@wList,$capaNetworkServices,"NetworkServices"); |
|
1668 addCapability(\@rList,\@wList,$capaLocalServices,"Local Services"); |
|
1669 addCapability(\@rList,\@wList,$capaReadUserData,"ReadUserData"); |
|
1670 addCapability(\@rList,\@wList,$capaWriteUserData,"WriteUserData"); |
|
1671 addCapability(\@rList,\@wList,$capaLocation,"Location"); |
|
1672 addCapability(\@rList,\@wList,$capaReadDeviceData,"ReadDeviceData"); |
|
1673 addCapability(\@rList,\@wList,$capaWriteDeviceData,"WriteDeviceData"); |
|
1674 addCapability(\@rList,\@wList,$capaProtServ,"ProtServ"); |
|
1675 addCapability(\@rList,\@wList,$capaDrm,"DRM"); |
|
1676 addCapability(\@rList,\@wList,$capaSwEvent,"SwEvent"); |
|
1677 addCapability(\@rList,\@wList,$capaPowerMgmt,"PowerMgmt"); |
|
1678 addCapability(\@rList,\@wList,$capaAllFiles,"AllFiles"); |
|
1679 addCapability(\@rList,\@wList,$capaDiskAdmin,"DiskAdmin"); |
|
1680 addCapability(\@rList,\@wList,$capaNetworkControl,"NetworkControl"); |
|
1681 addCapability(\@rList,\@wList,$capaMultiMediaDD,"MultiMediaDD"); |
|
1682 addCapability(\@rList,\@wList,$capaCommDD,"CommDD"); |
|
1683 addCapability(\@rList,\@wList,$capaTCB,"TCB"); |
|
1684 addCapability(\@rList,\@wList,$capaTrustedUI,"TrustedUI"); |
|
1685 addCapability(\@rList,\@wList,$capaUserEnv,"UserEnvironment"); |
|
1686 addCapability(\@rList,\@wList,$capaSurroundingsDD,"SurroundingsDD"); |
|
1687 |
|
1688 my $rSidDefined = 0; |
|
1689 if($capaSidRead !~ /^\s*$/) |
|
1690 { |
|
1691 $rSidDefined = 4; |
|
1692 } |
|
1693 my $wSidDefined = 0; |
|
1694 if($capaSidWrite !~ /^\s*$/) |
|
1695 { |
|
1696 $wSidDefined = 4; |
|
1697 } |
|
1698 |
|
1699 if((scalar(@rList) + $rSidDefined) > 7) |
|
1700 { |
|
1701 print "Row $row: To many Read capability checks defined. Allowed max amounts are:\n"; |
|
1702 print " (7 capabilities) or (1 sid and 3 capabilities)\n"; |
|
1703 $errorCount++; |
|
1704 } |
|
1705 if((scalar(@wList) + $wSidDefined) > 7) |
|
1706 { |
|
1707 print "Row $row: To many Write capability checks defined. Allowed max amounts are:\n"; |
|
1708 print " (7 capabilities) or (1 sid and 3 capabilities)\n"; |
|
1709 $errorCount++; |
|
1710 |
|
1711 } |
|
1712 } |
|
1713 } |
|
1714 |
|
1715 if($errorCount < 1) |
|
1716 { |
|
1717 print "No content errors\n"; |
|
1718 } |
|
1719 } |
|
1720 |
|
1721 |
|
1722 ########################################################################### |
|
1723 # Makes syntax checks that the given name is according to specification |
|
1724 # |
|
1725 # |
|
1726 # Params: file name |
|
1727 # |
|
1728 ########################################################################### |
|
1729 sub checkCentrepKeySheetName |
|
1730 { |
|
1731 my $name = shift; |
|
1732 |
|
1733 # ---------------------------------------------------------------- |
|
1734 # check name syntax |
|
1735 # ---------------------------------------------------------------- |
|
1736 if($name =~ /[A-Z]/) |
|
1737 { |
|
1738 print "Sheet: $name, no capital letters allowed\n"; |
|
1739 } |
|
1740 if($name !~ /^[a-z0-9\_\.]+$/) |
|
1741 { |
|
1742 print "Sheet: $name, non valid characters in the name. (0-9 a-z _ and . are allowed\n"; |
|
1743 } |
|
1744 if($name !~ /^keys_[a-z0-9\_]+\.xls$/) |
|
1745 { |
|
1746 print "Sheet: \"$name\", syntax should be \"keys_<modulename>.xls\"\n"; |
|
1747 } |
|
1748 |
|
1749 } |
|
1750 |
|
1751 1; |
|
1752 |
|
1753 |
|
1754 |
|
1755 |