Changeset 1956

Show
Ignore:
Timestamp:
02/26/08 09:38:27 (9 months ago)
Author:
dsugar
Message:

some cleanup and restructuring in preparation for additional functionality.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/mls/framework-plugin/src/com/tresys/framework/compiler/translator/Translator.java

    r1901 r1956  
    2626import com.tresys.framework.compiler.linkage.flnkage.Ability; 
    2727import com.tresys.framework.compiler.linkage.flnkage.BaseAccessDefn; 
    28 import com.tresys.framework.compiler.linkage.libselinuxjava.SWIGTYPE_p_p_char; 
    2928import com.tresys.framework.compiler.linkage.libselinuxjava.selinux; 
    3029import com.tresys.framework.compiler.linkage.libselinuxjava.selinuxConstants; 
     
    487486                } 
    488487                 
    489                 SWIGTYPE_p_p_char strcontext = selinux.new_char_p_p(); 
    490                 int returnCode = selinux.matchpathcon(path, selinuxConstants.S_IFDIR, strcontext); 
    491                 if(returnCode != 0) { 
     488//              SWIGTYPE_p_p_char strcontext = selinux.new_char_p_p(); 
     489                String strcontext = selinux.matchpathconex(path, selinuxConstants.S_IFDIR); 
     490                if(strcontext ==  null) 
     491                { 
    492492                        return null; 
    493493                } 
    494494                 
    495495                if(strcontext != null) { 
    496                       String strcon = selinux.char_p_p_value(strcontext); 
     496//                    String strcon = selinux.char_p_p_value(strcontext); 
    497497                         
    498                         String [] context = strcon.split (":"); 
     498                        String [] context = strcontext.split (":"); 
    499499                        if (context.length > 2) 
    500500                        { 
  • branches/mls/framework-plugin/src/com/tresys/framework/compiler/translator/TranslatorSELinux.java

    r1901 r1956  
    5959import com.tresys.framework.compiler.linkage.flnkage.Ability; 
    6060import com.tresys.framework.compiler.linkage.flnkage.BaseAccessDefn; 
    61 import com.tresys.framework.compiler.linkage.libselinuxjava.SWIGTYPE_p_p_char; 
    6261import com.tresys.framework.compiler.linkage.libselinuxjava.selinux; 
    6362import com.tresys.framework.compiler.linkage.libselinuxjava.selinuxConstants; 
     
    125124        } 
    126125         
     126        protected void finalize () 
     127                throws Throwable 
     128        { 
     129                super.finalize (); 
     130                selinux.matchpathcon_fini (); 
     131        } 
     132         
    127133        public boolean GetErrorState() 
    128134        { 
     
    688694                } 
    689695                 
    690                 SWIGTYPE_p_p_char strcontext = selinux.new_char_p_p(); 
    691                 int returnCode = selinux.matchpathcon(path, selinuxConstants.S_IFDIR, strcontext); 
    692                 if(returnCode != 0)  
     696//              SWIGTYPE_p_p_char strcontext = selinux.new_char_p_p(); 
     697//              int returnCode = selinux.matchpathcon(path, selinuxConstants.S_IFDIR, strcontext); 
     698                String strcontext = selinux.matchpathconex (path, selinuxConstants.S_IFDIR); 
     699                if (strcontext == null)  
    693700                { 
    694701                        return null; 
    695702                } 
    696703                 
    697               if(strcontext != null)  
    698                 { 
    699                       String strcon = selinux.char_p_p_value(strcontext); 
    700                         String [] context = strcon.split (":"); 
     704//            if(strcontext != null)  
     705                { 
     706//                    String strcon = selinux.char_p_p_value(strcontext); 
     707                        String [] context = strcontext.split (":"); 
    701708                         
    702709                        if (context.length > 2) 
  • branches/mls/libselinux.linux.x86/.externalToolBuilders/libSELinux x86.launch

    r1629 r1956  
    11<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
    22<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> 
     3<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/> 
     4<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> 
     5<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> 
     6<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/libselinux.linux.x86/src/com/tresys/framework/compiler/linkage&quot; type=&quot;2&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/libselinux.linux.x86/libselinuxjava&quot; type=&quot;2&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/> 
    37<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> 
    4 <listEntry value="/CDSFramework/libselinuxjava/antbuild.xml"/> 
     8<listEntry value="/libselinuxjava/swig/antbuild.xml"/> 
    59</listAttribute> 
    6 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean"/> 
    7 <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> 
    8 <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> 
    9 <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> 
    10 <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> 
    11 <stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/> 
    12 <stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;working set&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/libselinux.linux.x86/libselinuxjava&quot; type=&quot;2&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/libselinux.linux.x86/src/com/tresys/framework/compiler/linkage&quot; type=&quot;2&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/> 
    13 <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> 
    14 <booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> 
    15 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-Dtarget_arch=x86 -Dtarget_dir=${build_project}/libselinuxjava -Djava_target_dir=${build_project}/src/com/tresys/framework/compiler/linkage/libselinuxjava/"/> 
    16 <booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> 
    17 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/CDSFramework/libselinuxjava}"/> 
    18 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/CDSFramework/libselinuxjava/antbuild.xml}"/> 
    19 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;workingSet&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/CDSFramework/libselinuxjava/selinuxswig.i&quot; type=&quot;1&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/> 
    2010<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> 
    2111<listEntry value="1"/> 
    2212</listAttribute> 
     13<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> 
     14<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> 
     15<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> 
     16<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> 
     17<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="libselinuxjava"/> 
     18<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; label=&quot;workingSet&quot; name=&quot;workingSet&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/CDSFramework/libselinuxjava/selinuxswig.i&quot; type=&quot;1&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/> 
     19<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/libselinuxjava/swig/antbuild.xml}"/> 
     20<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean"/> 
     21<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-Dtarget_arch=x86 -Dtarget_dir=${build_project}/libselinuxjava -Djava_target_dir=${build_project}/src/com/tresys/framework/compiler/linkage/libselinuxjava/"/> 
     22<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> 
     23<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/libselinuxjava/swig}"/> 
    2324</launchConfiguration> 
  • branches/mls/libselinux.linux.x86_64/.externalToolBuilders/libSELinux x86_64.launch

    r1629 r1956  
    11<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
    22<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> 
     3<stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/> 
     4<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> 
     5<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> 
     6<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; label=&quot;working set&quot; name=&quot;working set&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/libselinux.linux.x86_64/src/com/tresys/framework/compiler/linkage&quot; type=&quot;2&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/libselinux.linux.x86_64/libselinuxjava&quot; type=&quot;2&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/> 
     7<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> 
     8<listEntry value="/libselinuxjava/swig/antbuild.xml"/> 
     9</listAttribute> 
     10<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> 
     11<listEntry value="1"/> 
     12</listAttribute> 
     13<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> 
     14<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> 
     15<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> 
     16<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> 
     17<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="libselinuxjava"/> 
     18<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; label=&quot;workingSet&quot; name=&quot;workingSet&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/CDSFramework/libselinuxjava/selinuxswig.i&quot; type=&quot;1&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/> 
     19<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/libselinuxjava/swig/antbuild.xml}"/> 
    320<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,auto,clean"/> 
    4 <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> 
     21<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-Dtarget_arch=x86_64 -Dtarget_dir=${build_project}/libselinuxjava -Djava_target_dir=${build_project}/src/com/tresys/framework/compiler/linkage/libselinuxjava/"/> 
    522<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> 
    6 <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> 
    7 <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> 
    8 <stringAttribute key="org.eclipse.ant.ui.ATTR_ANT_CLEAN_TARGETS" value="clean,"/> 
    9 <stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;working set&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/libselinux.linux.x86_64/libselinuxjava&quot; type=&quot;2&quot;/&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/libselinux.linux.x86_64/src/com/tresys/framework/compiler/linkage&quot; type=&quot;2&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/> 
    10 <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> 
    11 <booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> 
    12 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-Dtarget_arch=x86_64 -Dtarget_dir=${build_project}/libselinuxjava -Djava_target_dir=${build_project}/src/com/tresys/framework/compiler/linkage/libselinuxjava/"/> 
    13 <booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> 
    14 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/CDSFramework/libselinuxjava}"/> 
    15 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/CDSFramework/libselinuxjava/antbuild.xml}"/> 
    16 <stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&#10;&lt;launchConfigurationWorkingSet editPageId=&quot;org.eclipse.ui.resourceWorkingSetPage&quot; factoryID=&quot;org.eclipse.ui.internal.WorkingSetFactory&quot; name=&quot;workingSet&quot;&gt;&#10;&lt;item factoryID=&quot;org.eclipse.ui.internal.model.ResourceFactory&quot; path=&quot;/CDSFramework/libselinuxjava/selinuxswig.i&quot; type=&quot;1&quot;/&gt;&#10;&lt;/launchConfigurationWorkingSet&gt;}"/> 
     23<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/libselinuxjava/swig}"/> 
    1724</launchConfiguration> 
  • branches/mls/libselinuxjava-plugin/libselinuxjava/selinuxswig.i

    r1825 r1956  
    11%module selinux 
    22%{ 
    3 #include "selinux/selinux.h" 
     3#include <selinux/selinux.h> 
     4#include <string.h> 
     5#include <sys/stat.h> 
    46%} 
    57 
    68 
    7 %include "cpointer.i" 
    8 %pointer_functions(char*, char_p_p); 
    99 
    10 typedef char* security_context_t; 
    11  
    12 int matchpathcon(const char *name, int mode, security_context_t *con); 
     10int is_selinux_enabled (void); 
     11int is_selinux_mls_enabled (void); 
    1312int matchpathcon_init(const char *path); 
     13void matchpathcon_fini(); 
    1414int framework_ignore_invalid_con(); 
    1515 
    16 //inline %{ 
     16 
     17%typemap(newfree) char * "free($1);"; 
     18%newobject matchpathconex; 
     19char *matchpathconex(const char *i_sName, int i_nMode); 
     20 
     21 
    1722%{ 
    1823 
    19 int tmp_function(const char *path, unsigned lineno, char * context) { 
     24int tmp_function(const char *path, unsigned lineno, char * context)  
     25
    2026        return 0; 
    2127} 
    2228 
    23 int framework_ignore_invalid_con() { 
     29int framework_ignore_invalid_con()  
     30
    2431        set_matchpathcon_invalidcon(&tmp_function);  
    2532        return 0; 
    2633} 
     34 
     35char *matchpathconex(const char *i_sName, int i_nMode) 
     36{ 
     37        security_context_t oCon; 
     38        int rc = matchpathcon(i_sName, i_nMode, &oCon); 
     39        if (rc == 0) 
     40        { 
     41                 char * result = malloc (strlen (oCon) +1); 
     42                 strncpy (result, oCon, strlen (oCon) +1); 
     43                 freecon(oCon); 
     44                 return result; 
     45        } 
     46        return NULL; 
     47} 
     48 
    2749%} 
    2850 
    29 // These constants are pulled from bits/stat.h 
    30 // TODO: more portable way of doing this? 
    31 #define S_IFDIR       0040000 /* Directory.  */ 
     51// These constants are pulled from sys/stat.h 
     52%constant long S_IFDIR = S_IFDIR;