Changeset 1841

Show
Ignore:
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
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/Compiler.java

    r1838 r1841  
    358358                        fcFile = new File(fcFilename); 
    359359 
    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                 
    361371                policy.Accept(translator); 
    362372                 
     
    379389                } 
    380390 
    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  
    390391                streamPolicy.append(teData.toString ()); 
    391392 
     
    403404                        streamInterface = System.out; 
    404405                } 
    405                 streamPolicy.append (ifData.toString ()); 
     406                streamInterface.append (ifData.toString ()); 
    406407 
    407408                if(fcOutputFilename != null) { 
  • branches/transwork/framework-plugin/src/com/tresys/framework/compiler/translator/TranslatorSELinux.java

    r1838 r1841  
    105105        private TreeSet/*<String>*/dirPermSet = new TreeSet/*<String>*/(); 
    106106         
    107         public TranslatorSELinux(Policy _policy, Linkage _linkage, String _moduleName)  
     107        public TranslatorSELinux(Policy _policy, Linkage _linkage, String _moduleName, File fcFile)  
    108108        { 
    109109                super(); 
     
    115115                bufferInterfaces = new ByteArrayOutputStream (); 
    116116                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                } 
    117124        } 
    118125         
     
    140147        { 
    141148                PrintStream printStreamBufferPOL; 
    142                 printStreamBufferPOL = new PrintStream(bufferInterfaces); 
     149                printStreamBufferPOL = new PrintStream(bufferPolicy); 
    143150                 
    144151                PrintStream printStreamBufferFC; 
     
    537544                        "\t\ttype " + domain.getType() + ";\n" +  
    538545                        "\t\trole " + domain.GetRole() + ";\n" +  
    539                         "\t')\n"); 
     546                        "\t')\n" + "\n')\n"); 
    540547                 
    541548                printStreamBuffer.flush (); 
     
    642649                                        if(fileType == null)  
    643650                                        { 
    644                                                 if(!hasFileContext)  
     651                                                if(hasFileContext)  
    645652                                                { 
    646                                                         Utility.ProjectError("ASDFASDFASDF#### Unable to determine file context for " 
     653                                                        Utility.ProjectError("Unable to determine file context for " 
    647654                                                                + file.toString() + ", try associating the parent directory with a CDSFramework component"); 
    648655                                                        errorEncountered = true; 
     
    686693                { 
    687694                        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                        } 
    690702                } 
    691703 
     
    13241336                        if(comp.getParent() != null)  
    13251337                        { 
    1326                                 if(sr instanceof DirResource)  
     1338                                if(sr instanceof DirResource) 
    13271339                                { 
    13281340                                        dr = (DirResource) sr; 
  • branches/transwork/framework-plugin/src/com/tresys/framework/plugin/builder/SELinuxSystem.java

    r1838 r1841  
    512512 
    513513                        // 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);  
    515515 
    516516                        m_policy.Accept(translatorSELinux);