Changeset 1338
- Timestamp:
- 11/07/06 09:04:19
(2 years ago)
- Author:
- dsugar
- Message:
fix problem when deleting project - it was trying to build again during delete.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r1337 |
r1338 |
|
| 90 | 90 | if (currResource.getFileExtension ().equals (m_fpolExt)) |
|---|
| 91 | 91 | { |
|---|
| 92 | | BuildPolicy (GetSystemFromResource (currResource), |
|---|
| 93 | | (IFile) currResource); |
|---|
| | 92 | BuildPolicy (GetSystemFromResource (currResource), (IFile) currResource); |
|---|
| 94 | 93 | } |
|---|
| 95 | 94 | else if (currResource.getFileExtension ().equals (m_flnkExt)) |
|---|
| … | … | |
| 159 | 158 | { |
|---|
| 160 | 159 | if (currResource.getName ().equals (m_confDir) |
|---|
| 161 | | && currResource.getParent () == currResource |
|---|
| 162 | | .getProject ()) |
|---|
| | 160 | && currResource.getParent () == currResource.getProject ()) |
|---|
| 163 | 161 | { |
|---|
| 164 | 162 | supportFiles = new Vector (); |
|---|
| 165 | 163 | } |
|---|
| 166 | 164 | else if (!currResource.getName ().startsWith (".") |
|---|
| 167 | | && currResource.getParent ().getProjectRelativePath () |
|---|
| 168 | | .toString ().equals (m_srcDir)) |
|---|
| 169 | | { |
|---|
| 170 | | getNature (currResource.getProject ()).get_systems () |
|---|
| 171 | | .remove (GetSystemFromResource (currResource)); |
|---|
| | 165 | && currResource.getParent ().getProjectRelativePath ().toString ().equals (m_srcDir)) |
|---|
| | 166 | { |
|---|
| | 167 | getNature (currResource.getProject ()).get_systems ().remove (GetSystemFromResource (currResource)); |
|---|
| 172 | 168 | } |
|---|
| 173 | 169 | } |
|---|
| … | … | |
| 241 | 237 | if (m_projPrefs == null) |
|---|
| 242 | 238 | { |
|---|
| 243 | | Utility |
|---|
| 244 | | .SetProjectErrorHandler (new GUIProjectErrorHandler (project)); |
|---|
| | 239 | Utility.SetProjectErrorHandler (new GUIProjectErrorHandler (project)); |
|---|
| 245 | 240 | |
|---|
| 246 | 241 | IScopeContext currProjScope = new ProjectScope (project); |
|---|
| 247 | 242 | |
|---|
| 248 | 243 | m_projPrefs = currProjScope.getNode (SEFramework_Plugin.PLUGIN_ID); |
|---|
| 249 | | m_projPrefs.addPreferenceChangeListener (new IEclipsePreferences.IPreferenceChangeListener () { |
|---|
| 250 | | public void preferenceChange (PreferenceChangeEvent event) |
|---|
| 251 | | { |
|---|
| 252 | | // if the base dictionary is changed in the project |
|---|
| 253 | | // rebuild it. |
|---|
| 254 | | if (event.getKey ().equals ( |
|---|
| 255 | | SEFPreferencePage.BASE_DICT_PATH)) |
|---|
| | 244 | m_projPrefs.addPreferenceChangeListener (new IEclipsePreferences.IPreferenceChangeListener () |
|---|
| | 245 | { |
|---|
| | 246 | public void preferenceChange (PreferenceChangeEvent event) |
|---|
| | 247 | { |
|---|
| | 248 | // if the base dictionary is changed in the project |
|---|
| | 249 | // rebuild it. |
|---|
| | 250 | if (event.getNewValue() == null) |
|---|
| | 251 | return; |
|---|
| | 252 | |
|---|
| | 253 | if (event.getKey ().equals (SEFPreferencePage.BASE_DICT_PATH)) |
|---|
| | 254 | { |
|---|
| | 255 | try |
|---|
| 256 | 256 | { |
|---|
| 257 | | try |
|---|
| 258 | | { |
|---|
| 259 | | clean (null); |
|---|
| 260 | | } |
|---|
| 261 | | catch (CoreException ce) |
|---|
| 262 | | {} |
|---|
| 263 | | fullBuild (null); |
|---|
| | 257 | clean (null); |
|---|
| 264 | 258 | } |
|---|
| 265 | | } |
|---|
| 266 | | }); |
|---|
| | 259 | catch (CoreException ce) |
|---|
| | 260 | {} |
|---|
| | 261 | fullBuild (null); |
|---|
| | 262 | } |
|---|
| | 263 | } |
|---|
| | 264 | }); |
|---|
| 267 | 265 | } |
|---|
| 268 | 266 | |
|---|
| … | … | |
| 272 | 270 | |
|---|
| 273 | 271 | Enumeration eFlnks = SEFramework_Plugin.getDefault ().getBundle () |
|---|
| 274 | | .findEntries ("resources" + IPath.SEPARATOR + "link", "*." + m_flnkExt, |
|---|
| 275 | | true); |
|---|
| | 272 | .findEntries ("resources" + IPath.SEPARATOR + "link", "*." + m_flnkExt, true); |
|---|
| 276 | 273 | while (eFlnks.hasMoreElements ()) |
|---|
| 277 | 274 | { |
|---|
| … | … | |
| 290 | 287 | findAllSupportFiles ((IFolder) supportFolder); |
|---|
| 291 | 288 | |
|---|
| 292 | | Utility.SetDebug (SEFramework_Plugin.getDefault () |
|---|
| 293 | | .getPreferenceStore ().getBoolean (SEFPreferencePage.VERBOSE_COMPILE)); |
|---|
| | 289 | Utility.SetDebug (SEFramework_Plugin.getDefault ().getPreferenceStore ().getBoolean (SEFPreferencePage.VERBOSE_COMPILE)); |
|---|
| 294 | 290 | } |
|---|
| 295 | 291 | |
|---|
| … | … | |
| 435 | 431 | { |
|---|
| 436 | 432 | deleteMarkers (dictionaryFile); |
|---|
| 437 | | GUIErrorHandler currFileHandler = new GUIErrorHandler ( |
|---|
| 438 | | dictionaryFile); |
|---|
| 439 | | |
|---|
| 440 | | theDict.AddDictionaryReader (new InputStreamReader (dictionaryFile |
|---|
| 441 | | .getContents ()), currFileHandler); |
|---|
| | 433 | GUIErrorHandler currFileHandler = new GUIErrorHandler (dictionaryFile); |
|---|
| | 434 | |
|---|
| | 435 | theDict.AddDictionaryReader (new InputStreamReader (dictionaryFile.getContents ()), currFileHandler); |
|---|
| 442 | 436 | return currFileHandler.GetErrorCount (); |
|---|
| 443 | 437 | } |
|---|
| 444 | 438 | catch (CoreException e) |
|---|
| 445 | 439 | { |
|---|
| 446 | | Utility.ProjectError ("Error adding " + dictionaryFile.getName () |
|---|
| 447 | | + " to the dictionary"); |
|---|
| | 440 | Utility.ProjectError ("Error adding " + dictionaryFile.getName () + " to the dictionary"); |
|---|
| 448 | 441 | e.printStackTrace (); |
|---|
| 449 | 442 | return 1; |
|---|
| … | … | |
| 473 | 466 | flnkHandler = new GUIErrorHandler (currFile); |
|---|
| 474 | 467 | |
|---|
| 475 | | fileReader = new InputStreamReader (currFile |
|---|
| 476 | | .getContents ()); |
|---|
| | 468 | fileReader = new InputStreamReader (currFile.getContents ()); |
|---|
| 477 | 469 | } |
|---|
| 478 | 470 | else |
|---|
| 479 | 471 | { |
|---|
| 480 | 472 | File currFile = currPath.toFile (); |
|---|
| 481 | | flnkHandler = new CLIErrorHandler (currFile |
|---|
| 482 | | .getAbsolutePath ()); |
|---|
| | 473 | flnkHandler = new CLIErrorHandler (currFile.getAbsolutePath ()); |
|---|
| 483 | 474 | FileInputStream fstr = new FileInputStream (currFile); |
|---|
| 484 | 475 | fileReader = new InputStreamReader (fstr); |
|---|
| … | … | |
| 506 | 497 | for (int j = 0; j < getNature (currProj).get_systems ().size (); j++) |
|---|
| 507 | 498 | { |
|---|
| 508 | | SELinuxSystem system = (SELinuxSystem) getNature (currProj) |
|---|
| 509 | | .get_systems ().elementAt (j); |
|---|
| | 499 | SELinuxSystem system = (SELinuxSystem) getNature (currProj).get_systems ().elementAt (j); |
|---|
| 510 | 500 | if (system.getLinkage () != null) |
|---|
| 511 | 501 | { |
|---|
| … | … | |
| 529 | 519 | if (getNature (system.getProject ()).getDictionary () == null) |
|---|
| 530 | 520 | { |
|---|
| 531 | | Utility |
|---|
| 532 | | .ProjectError ("No Policies can be built until a valid dictionary is made"); |
|---|
| | 521 | Utility.ProjectError ("No Policies can be built until a valid dictionary is made"); |
|---|
| 533 | 522 | return; |
|---|
| 534 | 523 | } |
|---|
| 535 | | Policy thePolicy = new Policy (getNature (policyFile.getProject ()) |
|---|
| 536 | | .getDictionary (), system.getLinkage ()); |
|---|
| | 524 | Policy thePolicy = new Policy (getNature (policyFile.getProject ()).getDictionary (), system.getLinkage ()); |
|---|
| 537 | 525 | thePolicy.setValidInterfaces (system.getValidInterfaces ()); |
|---|
| 538 | 526 | thePolicy.setBasePolicyBooleans (system.getAllBooleans ()); |
|---|
| … | … | |
| 541 | 529 | { |
|---|
| 542 | 530 | GUIErrorHandler policyHandler = new GUIErrorHandler (policyFile); |
|---|
| 543 | | thePolicy.AddPolicyReader (new InputStreamReader (policyFile |
|---|
| 544 | | .getContents ()), policyHandler); |
|---|
| | 531 | thePolicy.AddPolicyReader (new InputStreamReader (policyFile.getContents ()), policyHandler); |
|---|
| 545 | 532 | } |
|---|
| 546 | 533 | catch (CoreException ce) |
|---|
| 547 | 534 | { |
|---|
| 548 | | Utility.ProjectError ("Error adding " + policyFile.getName () |
|---|
| 549 | | + " to the policy"); |
|---|
| | 535 | Utility.ProjectError ("Error adding " + policyFile.getName () + " to the policy"); |
|---|
| 550 | 536 | ce.printStackTrace (); |
|---|
| 551 | 537 | } |
|---|
| … | … | |
| 570 | 556 | GUIErrorHandler handler = new GUIErrorHandler (sysResFile); |
|---|
| 571 | 557 | |
|---|
| 572 | | sysRes.AddSystemResourcesReader (new InputStreamReader (sysResFile |
|---|
| 573 | | .getContents ()), handler); |
|---|
| | 558 | sysRes.AddSystemResourcesReader (new InputStreamReader (sysResFile.getContents ()), handler); |
|---|
| 574 | 559 | int numErrors = handler.GetErrorCount (); |
|---|
| 575 | | Utility.Debug (" Found " + numErrors + " errors while parsing " |
|---|
| 576 | | + sysResFile.getName ()); |
|---|
| | 560 | Utility.Debug (" Found " + numErrors + " errors while parsing " + sysResFile.getName ()); |
|---|
| 577 | 561 | system.setSystemResources (sysRes); |
|---|
| 578 | 562 | } |
|---|
| 579 | 563 | catch (CoreException ce) |
|---|
| 580 | 564 | { |
|---|
| 581 | | Utility.ProjectError ("Error adding " + sysResFile.getName () |
|---|
| 582 | | + " to the policy"); |
|---|
| | 565 | Utility.ProjectError ("Error adding " + sysResFile.getName () + " to the policy"); |
|---|
| 583 | 566 | ce.printStackTrace (); |
|---|
| 584 | 567 | } |
|---|
| … | … | |
| 592 | 575 | private void BuildLinkage (SELinuxSystem system) |
|---|
| 593 | 576 | { |
|---|
| 594 | | String flaskPath = system.getSystemPath () + File.separatorChar |
|---|
| 595 | | + "policy" + File.separatorChar + "flask"; |
|---|
| | 577 | String flaskPath = system.getSystemPath () + File.separatorChar + "policy" + File.separatorChar + "flask"; |
|---|
| 596 | 578 | String permWeightPath = null; |
|---|
| 597 | 579 | |
|---|
| … | … | |
| 599 | 581 | SEFPreferencePage.PERM_WEIGHT_PATH).equals ("")) |
|---|
| 600 | 582 | { |
|---|
| 601 | | permWeightPath = SEFramework_Plugin.getDefault () |
|---|
| 602 | | .getPreferenceStore ().getString ( |
|---|
| 603 | | SEFPreferencePage.PERM_WEIGHT_PATH); |
|---|
| | 583 | permWeightPath = SEFramework_Plugin.getDefault ().getPreferenceStore ().getString (SEFPreferencePage.PERM_WEIGHT_PATH); |
|---|
| 604 | 584 | } |
|---|
| 605 | 585 | |
|---|
| … | … | |
| 612 | 592 | } |
|---|
| 613 | 593 | |
|---|
| 614 | | theLinkage.LNFILESPATH = system.getProject ().getLocation () |
|---|
| 615 | | .toOSString (); |
|---|
| | 594 | theLinkage.LNFILESPATH = system.getProject ().getLocation ().toOSString (); |
|---|
| 616 | 595 | |
|---|
| 617 | 596 | if (allBaseDomains != null) |
|---|
| … | … | |
| 641 | 620 | try |
|---|
| 642 | 621 | { |
|---|
| 643 | | resource.deleteMarkers (GUIErrorHandler.MARKER_TYPE, false, |
|---|
| 644 | | IResource.DEPTH_ZERO); |
|---|
| | 622 | resource.deleteMarkers (GUIErrorHandler.MARKER_TYPE, false, IResource.DEPTH_ZERO); |
|---|
| 645 | 623 | } |
|---|
| 646 | 624 | catch (CoreException ce) |
|---|
| … | … | |
| 691 | 669 | * @throws CoreException |
|---|
| 692 | 670 | */ |
|---|
| 693 | | protected void incrementalBuild (IResourceDelta delta, |
|---|
| 694 | | IProgressMonitor monitor) |
|---|
| | 671 | protected void incrementalBuild (IResourceDelta delta, IProgressMonitor monitor) |
|---|
| 695 | 672 | throws CoreException |
|---|
| 696 | 673 | { |
|---|
| … | … | |
| 718 | 695 | for (int i = 0; i < nature.get_systems ().size (); i++) |
|---|
| 719 | 696 | { |
|---|
| 720 | | ((SELinuxSystem) nature.get_systems ().elementAt (i)) |
|---|
| 721 | | .setPolicy (null); |
|---|
| 722 | | ((SELinuxSystem) nature.get_systems ().elementAt (i)) |
|---|
| 723 | | .setLinkage (null); |
|---|
| 724 | | ((SELinuxSystem) nature.get_systems ().elementAt (i)) |
|---|
| 725 | | .setSystemResources (null); |
|---|
| | 697 | ((SELinuxSystem) nature.get_systems ().elementAt (i)).setPolicy (null); |
|---|
| | 698 | ((SELinuxSystem) nature.get_systems ().elementAt (i)).setLinkage (null); |
|---|
| | 699 | ((SELinuxSystem) nature.get_systems ().elementAt (i)).setSystemResources (null); |
|---|
| 726 | 700 | } |
|---|
| 727 | 701 | } |
|---|
| … | … | |
| 734 | 708 | if (currProject == null) |
|---|
| 735 | 709 | return null; |
|---|
| 736 | | return ((FrameworkNature) currProject |
|---|
| 737 | | .getNature (FrameworkNature.NATURE_ID)); |
|---|
| | 710 | return ((FrameworkNature) currProject.getNature (FrameworkNature.NATURE_ID)); |
|---|
| 738 | 711 | } |
|---|
| 739 | 712 | catch (CoreException ce) |
|---|
| … | … | |
| 745 | 718 | public static SELinuxSystem GetSystemFromResource (IResource res) |
|---|
| 746 | 719 | { |
|---|
| 747 | | Vector systems = FrameworkBuilder.getNature (res.getProject ()) |
|---|
| 748 | | .get_systems (); |
|---|
| | 720 | Vector systems = FrameworkBuilder.getNature (res.getProject ()).get_systems (); |
|---|
| 749 | 721 | if (systems == null) |
|---|
| 750 | 722 | return null; |
|---|
| … | … | |
| 753 | 725 | if (((SELinuxSystem) systems.elementAt (i)).getFolder () |
|---|
| 754 | 726 | .getFullPath ().isPrefixOf (res.getFullPath ())) |
|---|
| | 727 | { |
|---|
| 755 | 728 | return (SELinuxSystem) systems.elementAt (i); |
|---|
| | 729 | } |
|---|
| 756 | 730 | } |
|---|
| 757 | 731 | return null; |
|---|
| … | … | |
| 767 | 741 | thePolicy.setBasePolicyBooleans (system.getAllBooleans ()); |
|---|
| 768 | 742 | deleteMarkers (system.getFPolFile ()); |
|---|
| 769 | | QuickCompileGUIErrorHandler policyHandler = new QuickCompileGUIErrorHandler ( |
|---|
| 770 | | system.getFPolFile (), doc); |
|---|
| 771 | | thePolicy.AddPolicyReader (new StringReader (doc.get ()), |
|---|
| 772 | | policyHandler); |
|---|
| | 743 | QuickCompileGUIErrorHandler policyHandler = new QuickCompileGUIErrorHandler (system.getFPolFile (), doc); |
|---|
| | 744 | thePolicy.AddPolicyReader (new StringReader (doc.get ()), policyHandler); |
|---|
| 773 | 745 | // system.setPolicy (thePolicy); |
|---|
| 774 | 746 | } |
|---|
Download in other formats:
* Generating other formats may take time.