Changeset 1956
- 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
| r1901 |
r1956 |
|
| 26 | 26 | import com.tresys.framework.compiler.linkage.flnkage.Ability; |
|---|
| 27 | 27 | import com.tresys.framework.compiler.linkage.flnkage.BaseAccessDefn; |
|---|
| 28 | | import com.tresys.framework.compiler.linkage.libselinuxjava.SWIGTYPE_p_p_char; |
|---|
| 29 | 28 | import com.tresys.framework.compiler.linkage.libselinuxjava.selinux; |
|---|
| 30 | 29 | import com.tresys.framework.compiler.linkage.libselinuxjava.selinuxConstants; |
|---|
| … | … | |
| 487 | 486 | } |
|---|
| 488 | 487 | |
|---|
| 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 | { |
|---|
| 492 | 492 | return null; |
|---|
| 493 | 493 | } |
|---|
| 494 | 494 | |
|---|
| 495 | 495 | if(strcontext != null) { |
|---|
| 496 | | String strcon = selinux.char_p_p_value(strcontext); |
|---|
| | 496 | // String strcon = selinux.char_p_p_value(strcontext); |
|---|
| 497 | 497 | |
|---|
| 498 | | String [] context = strcon.split (":"); |
|---|
| | 498 | String [] context = strcontext.split (":"); |
|---|
| 499 | 499 | if (context.length > 2) |
|---|
| 500 | 500 | { |
|---|
| r1901 |
r1956 |
|
| 59 | 59 | import com.tresys.framework.compiler.linkage.flnkage.Ability; |
|---|
| 60 | 60 | import com.tresys.framework.compiler.linkage.flnkage.BaseAccessDefn; |
|---|
| 61 | | import com.tresys.framework.compiler.linkage.libselinuxjava.SWIGTYPE_p_p_char; |
|---|
| 62 | 61 | import com.tresys.framework.compiler.linkage.libselinuxjava.selinux; |
|---|
| 63 | 62 | import com.tresys.framework.compiler.linkage.libselinuxjava.selinuxConstants; |
|---|
| … | … | |
| 125 | 124 | } |
|---|
| 126 | 125 | |
|---|
| | 126 | protected void finalize () |
|---|
| | 127 | throws Throwable |
|---|
| | 128 | { |
|---|
| | 129 | super.finalize (); |
|---|
| | 130 | selinux.matchpathcon_fini (); |
|---|
| | 131 | } |
|---|
| | 132 | |
|---|
| 127 | 133 | public boolean GetErrorState() |
|---|
| 128 | 134 | { |
|---|
| … | … | |
| 688 | 694 | } |
|---|
| 689 | 695 | |
|---|
| 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) |
|---|
| 693 | 700 | { |
|---|
| 694 | 701 | return null; |
|---|
| 695 | 702 | } |
|---|
| 696 | 703 | |
|---|
| 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 (":"); |
|---|
| 701 | 708 | |
|---|
| 702 | 709 | if (context.length > 2) |
|---|
| r1629 |
r1956 |
|
| 1 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
|---|
| 2 | 2 | <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:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet editPageId="org.eclipse.ui.resourceWorkingSetPage" factoryID="org.eclipse.ui.internal.WorkingSetFactory" label="working set" name="working set"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/libselinux.linux.x86/src/com/tresys/framework/compiler/linkage" type="2"/> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/libselinux.linux.x86/libselinuxjava" type="2"/> </launchConfigurationWorkingSet>}"/> |
|---|
| 3 | 7 | <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> |
|---|
| 4 | | <listEntry value="/CDSFramework/libselinuxjava/antbuild.xml"/> |
|---|
| | 8 | <listEntry value="/libselinuxjava/swig/antbuild.xml"/> |
|---|
| 5 | 9 | </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:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet editPageId="org.eclipse.ui.resourceWorkingSetPage" factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="working set"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/libselinux.linux.x86/libselinuxjava" type="2"/> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/libselinux.linux.x86/src/com/tresys/framework/compiler/linkage" type="2"/> </launchConfigurationWorkingSet>}"/> |
|---|
| 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:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet editPageId="org.eclipse.ui.resourceWorkingSetPage" factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="workingSet"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/CDSFramework/libselinuxjava/selinuxswig.i" type="1"/> </launchConfigurationWorkingSet>}"/> |
|---|
| 20 | 10 | <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES"> |
|---|
| 21 | 11 | <listEntry value="1"/> |
|---|
| 22 | 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:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet editPageId="org.eclipse.ui.resourceWorkingSetPage" factoryID="org.eclipse.ui.internal.WorkingSetFactory" label="workingSet" name="workingSet"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/CDSFramework/libselinuxjava/selinuxswig.i" type="1"/> </launchConfigurationWorkingSet>}"/> |
|---|
| | 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}"/> |
|---|
| 23 | 24 | </launchConfiguration> |
|---|
| r1629 |
r1956 |
|
| 1 | 1 | <?xml version="1.0" encoding="UTF-8" standalone="no"?> |
|---|
| 2 | 2 | <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:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet editPageId="org.eclipse.ui.resourceWorkingSetPage" factoryID="org.eclipse.ui.internal.WorkingSetFactory" label="working set" name="working set"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/libselinux.linux.x86_64/src/com/tresys/framework/compiler/linkage" type="2"/> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/libselinux.linux.x86_64/libselinuxjava" type="2"/> </launchConfigurationWorkingSet>}"/> |
|---|
| | 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:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet editPageId="org.eclipse.ui.resourceWorkingSetPage" factoryID="org.eclipse.ui.internal.WorkingSetFactory" label="workingSet" name="workingSet"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/CDSFramework/libselinuxjava/selinuxswig.i" type="1"/> </launchConfigurationWorkingSet>}"/> |
|---|
| | 19 | <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/libselinuxjava/swig/antbuild.xml}"/> |
|---|
| 3 | 20 | <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/"/> |
|---|
| 5 | 22 | <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:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet editPageId="org.eclipse.ui.resourceWorkingSetPage" factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="working set"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/libselinux.linux.x86_64/libselinuxjava" type="2"/> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/libselinux.linux.x86_64/src/com/tresys/framework/compiler/linkage" type="2"/> </launchConfigurationWorkingSet>}"/> |
|---|
| 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:<?xml version="1.0" encoding="UTF-8"?> <launchConfigurationWorkingSet editPageId="org.eclipse.ui.resourceWorkingSetPage" factoryID="org.eclipse.ui.internal.WorkingSetFactory" name="workingSet"> <item factoryID="org.eclipse.ui.internal.model.ResourceFactory" path="/CDSFramework/libselinuxjava/selinuxswig.i" type="1"/> </launchConfigurationWorkingSet>}"/> |
|---|
| | 23 | <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/libselinuxjava/swig}"/> |
|---|
| 17 | 24 | </launchConfiguration> |
|---|
| r1825 |
r1956 |
|
| 1 | 1 | %module selinux |
|---|
| 2 | 2 | %{ |
|---|
| 3 | | #include "selinux/selinux.h" |
|---|
| | 3 | #include <selinux/selinux.h> |
|---|
| | 4 | #include <string.h> |
|---|
| | 5 | #include <sys/stat.h> |
|---|
| 4 | 6 | %} |
|---|
| 5 | 7 | |
|---|
| 6 | 8 | |
|---|
| 7 | | %include "cpointer.i" |
|---|
| 8 | | %pointer_functions(char*, char_p_p); |
|---|
| 9 | 9 | |
|---|
| 10 | | typedef char* security_context_t; |
|---|
| 11 | | |
|---|
| 12 | | int matchpathcon(const char *name, int mode, security_context_t *con); |
|---|
| | 10 | int is_selinux_enabled (void); |
|---|
| | 11 | int is_selinux_mls_enabled (void); |
|---|
| 13 | 12 | int matchpathcon_init(const char *path); |
|---|
| | 13 | void matchpathcon_fini(); |
|---|
| 14 | 14 | int framework_ignore_invalid_con(); |
|---|
| 15 | 15 | |
|---|
| 16 | | //inline %{ |
|---|
| | 16 | |
|---|
| | 17 | %typemap(newfree) char * "free($1);"; |
|---|
| | 18 | %newobject matchpathconex; |
|---|
| | 19 | char *matchpathconex(const char *i_sName, int i_nMode); |
|---|
| | 20 | |
|---|
| | 21 | |
|---|
| 17 | 22 | %{ |
|---|
| 18 | 23 | |
|---|
| 19 | | int tmp_function(const char *path, unsigned lineno, char * context) { |
|---|
| | 24 | int tmp_function(const char *path, unsigned lineno, char * context) |
|---|
| | 25 | { |
|---|
| 20 | 26 | return 0; |
|---|
| 21 | 27 | } |
|---|
| 22 | 28 | |
|---|
| 23 | | int framework_ignore_invalid_con() { |
|---|
| | 29 | int framework_ignore_invalid_con() |
|---|
| | 30 | { |
|---|
| 24 | 31 | set_matchpathcon_invalidcon(&tmp_function); |
|---|
| 25 | 32 | return 0; |
|---|
| 26 | 33 | } |
|---|
| | 34 | |
|---|
| | 35 | char *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 | |
|---|
| 27 | 49 | %} |
|---|
| 28 | 50 | |
|---|
| 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; |
|---|
Download in other formats:
* Generating other formats may take time.