Changeset 1841
- Timestamp:
- 01/18/08 12:41:16
(1 year ago)
- Author:
- gboyst
- Message:
Completion of Translator->TranslatorSELinux
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1838 |
r1841 |
|
| 358 | 358 | fcFile = new File(fcFilename); |
|---|
| 359 | 359 | |
|---|
| 360 | | translator = new TranslatorSELinux(policy, linkage, fcFile.getName()); |
|---|
| | 360 | int dot = polOutputFilename.lastIndexOf('.'); |
|---|
| | 361 | int slash = polOutputFilename.lastIndexOf('/'); |
|---|
| | 362 | String moduleName = polOutputFilename; |
|---|
| | 363 | |
|---|
| | 364 | if(dot != -1) |
|---|
| | 365 | moduleName = moduleName.substring(0, dot); |
|---|
| | 366 | if(slash != -1) |
|---|
| | 367 | moduleName = moduleName.substring(slash + 1); |
|---|
| | 368 | |
|---|
| | 369 | translator = new TranslatorSELinux(policy, linkage, moduleName, fcFile); |
|---|
| | 370 | |
|---|
| 361 | 371 | policy.Accept(translator); |
|---|
| 362 | 372 | |
|---|
| … | … | |
| 379 | 389 | } |
|---|
| 380 | 390 | |
|---|
| 381 | | int dot = polOutputFilename.lastIndexOf('.'); |
|---|
| 382 | | int slash = polOutputFilename.lastIndexOf('/'); |
|---|
| 383 | | String moduleName = polOutputFilename; |
|---|
| 384 | | |
|---|
| 385 | | if(dot != -1) |
|---|
| 386 | | moduleName = moduleName.substring(0, dot); |
|---|
| 387 | | if(slash != -1) |
|---|
| 388 | | moduleName = moduleName.substring(slash + 1); |
|---|
| 389 | | |
|---|
| 390 | 391 | streamPolicy.append(teData.toString ()); |
|---|
| 391 | 392 | |
|---|
| … | … | |
| 403 | 404 | streamInterface = System.out; |
|---|
| 404 | 405 | } |
|---|
| 405 | | streamPolicy.append (ifData.toString ()); |
|---|
| | 406 | streamInterface.append (ifData.toString ()); |
|---|
| 406 | 407 | |
|---|
| 407 | 408 | if(fcOutputFilename != null) { |
|---|
| r1838 |
r1841 |
|
| 105 | 105 | private TreeSet/*<String>*/dirPermSet = new TreeSet/*<String>*/(); |
|---|
| 106 | 106 | |
|---|
| 107 | | public TranslatorSELinux(Policy _policy, Linkage _linkage, String _moduleName) |
|---|
| | 107 | public TranslatorSELinux(Policy _policy, Linkage _linkage, String _moduleName, File fcFile) |
|---|
| 108 | 108 | { |
|---|
| 109 | 109 | super(); |
|---|
| … | … | |
| 115 | 115 | bufferInterfaces = new ByteArrayOutputStream (); |
|---|
| 116 | 116 | bufferSystemResources = new ByteArrayOutputStream (); |
|---|
| | 117 | |
|---|
| | 118 | if(fcFile != null && fcFile.exists()) |
|---|
| | 119 | { |
|---|
| | 120 | selinux.framework_ignore_invalid_con(); |
|---|
| | 121 | selinux.matchpathcon_init(fcFile.toString()); |
|---|
| | 122 | hasFileContext = true; |
|---|
| | 123 | } |
|---|
| 117 | 124 | } |
|---|
| 118 | 125 | |
|---|
| … | … | |
| 140 | 147 | { |
|---|
| 141 | 148 | PrintStream printStreamBufferPOL; |
|---|
| 142 | | printStreamBufferPOL = new PrintStream(bufferInterfaces); |
|---|
| | 149 | printStreamBufferPOL = new PrintStream(bufferPolicy); |
|---|
| 143 | 150 | |
|---|
| 144 | 151 | PrintStream printStreamBufferFC; |
|---|
| … | … | |
| 537 | 544 | "\t\ttype " + domain.getType() + ";\n" + |
|---|
| 538 | 545 | "\t\trole " + domain.GetRole() + ";\n" + |
|---|
| 539 | | "\t')\n"); |
|---|
| | 546 | "\t')\n" + "\n')\n"); |
|---|
| 540 | 547 | |
|---|
| 541 | 548 | printStreamBuffer.flush (); |
|---|
| … | … | |
| 642 | 649 | if(fileType == null) |
|---|
| 643 | 650 | { |
|---|
| 644 | | if(!hasFileContext) |
|---|
| | 651 | if(hasFileContext) |
|---|
| 645 | 652 | { |
|---|
| 646 | | Utility.ProjectError("ASDFASDFASDF#### Unable to determine file context for " |
|---|
| | 653 | Utility.ProjectError("Unable to determine file context for " |
|---|
| 647 | 654 | + file.toString() + ", try associating the parent directory with a CDSFramework component"); |
|---|
| 648 | 655 | errorEncountered = true; |
|---|
| … | … | |
| 686 | 693 | { |
|---|
| 687 | 694 | String strcon = selinux.char_p_p_value(strcontext); |
|---|
| 688 | | fileType = strcon.substring(strcon.lastIndexOf(":") + 1); |
|---|
| 689 | | fileConMap.put(path, fileType); |
|---|
| | 695 | String [] context = strcon.split (":"); |
|---|
| | 696 | |
|---|
| | 697 | if (context.length > 2) |
|---|
| | 698 | { |
|---|
| | 699 | fileType = context[2]; |
|---|
| | 700 | fileConMap.put(path, fileType); |
|---|
| | 701 | } |
|---|
| 690 | 702 | } |
|---|
| 691 | 703 | |
|---|
| … | … | |
| 1324 | 1336 | if(comp.getParent() != null) |
|---|
| 1325 | 1337 | { |
|---|
| 1326 | | if(sr instanceof DirResource) |
|---|
| | 1338 | if(sr instanceof DirResource) |
|---|
| 1327 | 1339 | { |
|---|
| 1328 | 1340 | dr = (DirResource) sr; |
|---|
| r1838 |
r1841 |
|
| 512 | 512 | |
|---|
| 513 | 513 | // only pass in file contexts if we were able to load libselinux |
|---|
| 514 | | final TranslatorSELinux translatorSELinux = new TranslatorSELinux(m_policy, getLinkage(), m_name); |
|---|
| | 514 | final TranslatorSELinux translatorSELinux = new TranslatorSELinux(m_policy, getLinkage(), m_name, fileContexts); |
|---|
| 515 | 515 | |
|---|
| 516 | 516 | m_policy.Accept(translatorSELinux); |
|---|
Download in other formats:
* Generating other formats may take time.