Skip to content
Snippets Groups Projects
Commit 5f5a7bc0 authored by Brian Carrier's avatar Brian Carrier
Browse files

Merge branch 'master' of github.com:sleuthkit/sleuthkit

parents ed09999f 3d29d1c1
Branches
Tags
No related merge requests found
......@@ -61,10 +61,14 @@ ACLOCAL_AMFLAGS = -I m4
if CPPUNIT
UNIT_TESTS=unit_tests
endif
if X_JNI
JNI=bindings/java/jni
JAVA_BINDINGS=bindings/java/jni bindings/java
else
JAVA_BINDINGS=
endif
SUBDIRS = tsk tools tests samples man $(UNIT_TESTS) $(JNI)
SUBDIRS = tsk tools tests samples man $(UNIT_TESTS) $(JAVA_BINDINGS)
nobase_include_HEADERS = tsk/libtsk.h tsk/tsk_incs.h \
tsk/base/tsk_base.h tsk/base/tsk_os.h \
......
Z_PATH=@Z_PATH@
EWF_PATH=@EWF_PATH@
ANT_PROPS=
if X_ZLIB
ANT_PROPS+=-Dlib.z.path=$(Z_PATH)
endif
if X_LIBEWF
ANT_PROPS+=-Dlib.ewf.path=$(EWF_PATH)
endif
tsk_jar = $(top_builddir)/bindings/java/dist/Tsk_DataModel.jar
jardir = $(prefix)/share/java
jar_DATA = $(tsk_jar)
$(tsk_jar):
ant dist $(ANT_PROPS)
CLEANFILES = $(tsk_jar)
clean-local:
ant clean
......@@ -30,6 +30,9 @@
<available file="./jni/.libs/libtsk_jni.so" property="tsk_so.present"/>
<available file="./jni/.libs/libtsk_jni.a" property="present"/>
<fail unless="present" message="Run make install on The Sleuthkit."/>
<!-- Default location to find zlib and libewf. Overwritten by properties in makefile -->
<property name="lib.z.path" value="/usr/lib"/>
<property name="lib.ewf.path" value="/usr/local/lib"/>
</target>
<!-- OS X -->
......@@ -42,16 +45,16 @@
<property environment="env"/>
<property name="jni.dylib" location="${basedir}/jni/.libs/libtsk_jni.dylib" />
<property name="jni.jnilib" value="libtsk_jni.jnilib" />
<property name="zlib.jni" location="/usr/lib/libz.dylib"/>
<property name="libewf.jni" location="/usr/local/lib/libewf.dylib"/>
<property name="zlib.jni" location="${lib.z.path}/libz.dylib"/>
<property name="libewf.jni" location="${lib.ewf.path}/libewf.dylib"/>
<!-- x86_64 -->
<copy file="${jni.dylib}" tofile="${x86_64}/mac/${jni.jnilib}"/>
<copy file="${zlib.jni}" tofile="${x86_64}/mac/zlib.dylib"/>
<copy file="${libewf.jni}" tofile="${x86_64}/mac/libewf.dylib"/>
<!-- amd64 -->
<copy file="${jni.dylib}" tofile="${amd64}/mac/${jni.jnilib}"/>
<copy file="${zlib.jni}" tofile="${x86_64}/mac/zlib.dylib"/>
<copy file="${libewf.jni}" tofile="${x86_64}/mac/libewf.dylib"/>
<copy file="${zlib.jni}" tofile="${amd64}/mac/zlib.dylib"/>
<copy file="${libewf.jni}" tofile="${amd64}/mac/libewf.dylib"/>
</target>
<!-- Non-OS X -->
......@@ -63,18 +66,32 @@
<target name="copyLinuxLibs" depends="testTSKLibs" if="tsk_so.present">
<property environment="env"/>
<property name="jni.so" location="${basedir}/jni/.libs/libtsk_jni.so" />
<property name="zlib.so" location="${lib.z.path}/libz.so"/>
<property name="libewf.so" location="${lib.ewf.path}/libewf.so"/>
<!-- x86_64 -->
<copy file="${jni.so}" tofile="${x86_64}/linux/libtsk_jni.so"/>
<copy file="${zlib.so}" tofile="${x86_64}/linux/libz.so"/>
<copy file="${libewf.so}" tofile="${x86_64}/linux/libewf.so"/>
<!-- amd64 -->
<copy file="${jni.so}" tofile="${amd64}/linux/libtsk_jni.so"/>
<copy file="${zlib.so}" tofile="${amd64}/linux/libz.so"/>
<copy file="${libewf.so}" tofile="${amd64}/linux/libewf.so"/>
<!-- x86 -->
<copy file="${jni.so}" tofile="${x86}/linux/libtsk_jni.so"/>
<copy file="${zlib.so}" tofile="${x86}/linux/libz.so"/>
<copy file="${libewf.so}" tofile="${x86}/linux/libewf.so"/>
<!-- i386 -->
<copy file="${jni.so}" tofile="${i386}/linux/libtsk_jni.so"/>
<copy file="${zlib.so}" tofile="${i386}/linux/libz.so"/>
<copy file="${libewf.so}" tofile="${i386}/linux/libewf.so"/>
<!-- i586 -->
<copy file="${jni.so}" tofile="${i586}/linux/libtsk_jni.so"/>
<copy file="${zlib.so}" tofile="${i586}/linux/libz.so"/>
<copy file="${libewf.so}" tofile="${i586}/linux/libewf.so"/>
<!-- i686 -->
<copy file="${jni.so}" tofile="${i686}/linux/libtsk_jni.so"/>
<copy file="${zlib.so}" tofile="${i686}/linux/libz.so"/>
<copy file="${libewf.so}" tofile="${i686}/linux/libewf.so"/>
</target>
<target name="copyLibs" depends="copyLinuxLibs,copyMacLibs" />
......
......@@ -619,7 +619,7 @@ public String getMetaFlagsAsString() {
String str = "";
if (metaFlags.contains(TSK_FS_META_FLAG_ENUM.ALLOC)) {
str = TSK_FS_META_FLAG_ENUM.ALLOC.toString();
} else if (metaFlags.contains(TSK_FS_META_FLAG_ENUM.ALLOC)) {
} else if (metaFlags.contains(TSK_FS_META_FLAG_ENUM.UNALLOC)) {
str = TSK_FS_META_FLAG_ENUM.UNALLOC.toString();
}
return str;
......
......@@ -77,34 +77,40 @@ public static boolean loadAuxilliaryLibs() {
if (LibraryUtils.isWindows()) {
loaded = LibraryUtils.loadCRTLibs();
}
if (! LibraryUtils.isLinux()) {
for(LibraryUtils.Lib lib : LibraryUtils.getLibs()) {
loaded = LibraryUtils.loadLibFromJar(lib);
if (!loaded) {
System.out.println("SleuthkitJNI: failed to load " + lib.getLibName());
} else {
System.out.println("SleuthkitJNI: loaded " + lib.getLibName());
}
// Always try to load from jar first.
for(Lib lib : LibraryUtils.getLibs()) {
// Always try to load from jar first.
loaded = LibraryUtils.loadLibFromJar(lib);
if (!loaded) {
// if that fails, try to load from system
loaded = loadLibFromSystem(lib);
}
} else {
System.out.println("In unix path.");
// Unix platform
for (Lib lib : LibraryUtils.getLibs()) {
try {
System.out.println("Lib name: " + lib.getUnixName());
System.loadLibrary(lib.getUnixName());
System.out.println("SleuthkitJNI: loaded " + lib.getLibName());
} catch (UnsatisfiedLinkError e) {
loaded = false;
System.out.println("SleuthkitJNI: failed to load " + lib.getLibName());
}
if (!loaded) {
System.out.println("SleuthkitJNI: failed to load " + lib.getLibName());
} else {
System.out.println("SleuthkitJNI: loaded " + lib.getLibName());
}
}
return loaded;
}
/**
* Try to load the given Library from the System path.
*
* @param lib
* @return
*/
private static boolean loadLibFromSystem(Lib lib) {
String libName = (isWindows() ? lib.getLibName() : lib.getUnixName());
try {
System.loadLibrary(libName);
} catch (UnsatisfiedLinkError e) {
return false;
}
return true;
}
/**
* Load the Sleuthkit JNI.
*
......@@ -167,6 +173,8 @@ private static String getPlatform() {
os = "win";
} else if(LibraryUtils.isMac()) {
os = "mac";
} else if(LibraryUtils.isLinux()) {
os = "linux";
}
// os.arch represents the architecture of the JVM, not the os
String arch = System.getProperty("os.arch");
......@@ -232,7 +240,7 @@ private static boolean loadLibFromJar(Lib library) {
// copy library to temp folder and load it
try {
java.io.File libTemp = new java.io.File(System.getProperty("java.io.tmpdir") + libName + libExt);
java.io.File libTemp = new java.io.File(System.getProperty("java.io.tmpdir") + java.io.File.separator + libName + libExt);
if(libTemp.exists()) {
// Delete old file
......
......@@ -413,8 +413,8 @@ public enum TSK_FS_TYPE_ENUM {
TSK_FS_TYPE_HFS (0x00001000), ///< HFS file system
TSK_FS_TYPE_HFS_DETECT (0x00001000), ///< HFS auto detection
TSK_FS_TYPE_EXT4 (0x00002000), ///< Ext4 file system
TSK_FS_TYPE_YAFFS2(0x00003000), ///< YAFFS2 file system
TSK_FS_TYPE_YAFFS2_DETECT(0x00003000), ///< YAFFS2 auto detection
TSK_FS_TYPE_YAFFS2(0x00004000), ///< YAFFS2 file system
TSK_FS_TYPE_YAFFS2_DETECT(0x00004000), ///< YAFFS2 auto detection
TSK_FS_TYPE_UNSUPP (0xffffffff); ///< Unsupported file system
private int value;
......
......@@ -11,7 +11,8 @@ m4_include([m4/cppunit.m4])
m4_include([m4/ax_jni_include_dir.m4])
m4_include([m4/ac_prog_javac_works.m4])
m4_include([m4/ac_prog_javac.m4])
m4_include([m4/ac_prog_java_works.m4])
m4_include([m4/ac_prog_java.m4])
AC_CONFIG_SRCDIR([tsk/base/tsk_base.h])
AC_CONFIG_HEADERS([tsk/tsk_config.h])
......@@ -87,6 +88,10 @@ if test -d /usr/local/include; then
LDFLAGS="$LDFLAGS -L/usr/local/lib"
fi
dnl Add enable/disable option
AC_ARG_ENABLE([java],
[AS_HELP_STRING([--disable-java], [Do not build the java bindings or jar file])])
dnl Checks for libraries.
......@@ -173,6 +178,13 @@ AS_IF(
)
AS_IF([test "x$ac_cv_lib_z_inflate" = "xyes"], [ax_zlib=yes], [ax_zlib=no])
AM_CONDITIONAL([X_ZLIB],[test "x$with_zlib" != "xno" && test "x$with_zlib" != "xyes"])
AS_IF([test "x$with_zlib" != "xno"],
[Z_PATH="${with_zlib}/lib"],
[AC_MSG_NOTICE([failed to make Z_PATH])]
)
AC_SUBST(Z_PATH, $Z_PATH)
dnl needed for sqllite
AC_CHECK_LIB(dl, dlopen)
......@@ -198,25 +210,41 @@ AS_IF([test "x$with_libewf" != "xno"],
)]
dnl Check for the header file first to make sure they have the dev install
[AC_CHECK_HEADERS([libewf.h],
[AC_CHECK_LIB([ewf], [libewf_get_version])]
[AC_CHECK_LIB([ewf], [libewf_get_version], [], [NO_LIBEWF=true])]
)]
)
AS_IF([test "x$ac_cv_lib_ewf_libewf_get_version" = "xyes"], [ax_libewf=yes], [ax_libewf=no])
AM_CONDITIONAL([X_LIBEWF],[test "x$with_libewf" != "xno" && test "x$with_libewf" != "xyes"])
AS_IF([test "x$with_libewf" != "xno"],
[EWF_PATH="${with_libewf}/lib"],
)
AC_SUBST(EWF_PATH, $EWF_PATH)
dnl sqlite requires pthread libraries - this was copied from its configure.ac
dnl AC_SEARCH_LIBS(pthread_create, pthread)
AC_SEARCH_LIBS(dlopen, dl)
dnl Test for java/jni so that we can compile the java bindings
AC_PROG_JAVAC
if test "x$JAVAC" != x; then
AX_JNI_INCLUDE_DIR
for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS
do
JNI_CPPFLAGS="$JNI_CPPFLAGS -I$JNI_INCLUDE_DIR"
done
dnl Export the paths so that the makefile gets them
AC_SUBST(JNI_CPPFLAGS, $JNI_CPPFLAGS)
fi
AM_CONDITIONAL([X_JNI],[test "x$JNI_CPPFLAGS" != x])
AS_IF([test "x$enable_java" != "xno"], [
AC_PROG_JAVAC
if test "x$JAVAC" != x; then
AX_JNI_INCLUDE_DIR
for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS
do
JNI_CPPFLAGS="$JNI_CPPFLAGS -I$JNI_INCLUDE_DIR"
done
dnl Export the paths so that the makefile gets them
AC_SUBST(JNI_CPPFLAGS, $JNI_CPPFLAGS)
fi
AC_PROG_JAVA
]) dnl test enable_java
dnl Test is ant is available
AC_PATH_PROG([ANT_FOUND], [ant], [])
AM_CONDITIONAL([X_JNI],[test "x$JNI_CPPFLAGS" != x && test "x$ANT_FOUND" != x && test "x$JAVA" != x])
AS_IF([test "x$JNI_CPPFLAGS" != x], [ax_java_support=yes], [ax_java_support=no])
AS_IF([test "x$JNI_CPPFLAGS" != x && test "x$ANT_FOUND" != x && test "x$JAVA" != x], [ax_java_support=yes], [ax_java_support=no])
AC_CONFIG_COMMANDS([tsk/tsk_incs.h],
[echo "#ifndef _TSK_INCS_H" > tsk/tsk_incs.h
......@@ -274,6 +302,7 @@ AC_CONFIG_FILES([
tests/Makefile
samples/Makefile
man/Makefile
bindings/java/Makefile
bindings/java/jni/Makefile
unit_tests/Makefile
unit_tests/base/Makefile])
......
dnl @synopsis AC_PROG_JAVA
dnl
dnl Here is a summary of the main macros:
dnl
dnl AC_PROG_JAVAC: finds a Java compiler.
dnl
dnl AC_PROG_JAVA: finds a Java virtual machine.
dnl
dnl AC_CHECK_CLASS: finds if we have the given class (beware of
dnl CLASSPATH!).
dnl
dnl AC_CHECK_RQRD_CLASS: finds if we have the given class and stops
dnl otherwise.
dnl
dnl AC_TRY_COMPILE_JAVA: attempt to compile user given source.
dnl
dnl AC_TRY_RUN_JAVA: attempt to compile and run user given source.
dnl
dnl AC_JAVA_OPTIONS: adds Java configure options.
dnl
dnl AC_PROG_JAVA tests an existing Java virtual machine. It uses the
dnl environment variable JAVA then tests in sequence various common
dnl Java virtual machines. For political reasons, it starts with the
dnl free ones. You *must* call [AC_PROG_JAVAC] before.
dnl
dnl If you want to force a specific VM:
dnl
dnl - at the configure.in level, set JAVA=yourvm before calling
dnl AC_PROG_JAVA
dnl
dnl (but after AC_INIT)
dnl
dnl - at the configure level, setenv JAVA
dnl
dnl You can use the JAVA variable in your Makefile.in, with @JAVA@.
dnl
dnl *Warning*: its success or failure can depend on a proper setting of
dnl the CLASSPATH env. variable.
dnl
dnl TODO: allow to exclude virtual machines (rationale: most Java
dnl programs cannot run with some VM like kaffe).
dnl
dnl Note: This is part of the set of autoconf M4 macros for Java
dnl programs. It is VERY IMPORTANT that you download the whole set,
dnl some macros depend on other. Unfortunately, the autoconf archive
dnl does not support the concept of set of macros, so I had to break it
dnl for submission.
dnl
dnl A Web page, with a link to the latest CVS snapshot is at
dnl <http://www.internatif.org/bortzmeyer/autoconf-Java/>.
dnl
dnl This is a sample configure.in Process this file with autoconf to
dnl produce a configure script.
dnl
dnl AC_INIT(UnTag.java)
dnl
dnl dnl Checks for programs.
dnl AC_CHECK_CLASSPATH
dnl AC_PROG_JAVAC
dnl AC_PROG_JAVA
dnl
dnl dnl Checks for classes
dnl AC_CHECK_RQRD_CLASS(org.xml.sax.Parser)
dnl AC_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver)
dnl
dnl AC_OUTPUT(Makefile)
dnl
dnl @category Java
dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
dnl @version 2000-07-19
dnl @license GPLWithACException
AC_DEFUN([AC_PROG_JAVA],[
AC_REQUIRE([AC_EXEEXT])dnl
if test x$JAVAPREFIX = x; then
test x$JAVA = x && AC_CHECK_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT)
else
test x$JAVA = x && AC_CHECK_PROGS(JAVA, kaffe$EXEEXT java$EXEEXT, $JAVAPREFIX)
fi
test x$JAVA = x && AC_MSG_WARN([no acceptable Java virtual machine found in \$PATH])
AC_PROG_JAVA_WORKS
AC_PROVIDE([$0])dnl
])
dnl @synopsis AC_PROG_JAVA_WORKS
dnl
dnl Internal use ONLY.
dnl
dnl Note: This is part of the set of autoconf M4 macros for Java
dnl programs. It is VERY IMPORTANT that you download the whole set,
dnl some macros depend on other. Unfortunately, the autoconf archive
dnl does not support the concept of set of macros, so I had to break it
dnl for submission. The general documentation, as well as the sample
dnl configure.in, is included in the AC_PROG_JAVA macro.
dnl
dnl @category Java
dnl @author Stephane Bortzmeyer <bortzmeyer@pasteur.fr>
dnl @version 2000-07-19
dnl @license GPLWithACException
AC_DEFUN([AC_PROG_JAVA_WORKS], [
AC_CHECK_PROG(uudecode, uudecode$EXEEXT, yes)
if test x$JAVA != x; then
if test x$uudecode = xyes; then
AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [
dnl /**
dnl * Test.java: used to test if java compiler works.
dnl */
dnl public class Test
dnl {
dnl
dnl public static void
dnl main( String[] argv )
dnl {
dnl System.exit (0);
dnl }
dnl
dnl }
cat << \EOF > Test.uue
begin-base64 644 Test.class
yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE
bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51
bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s
YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG
aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB
AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB
AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ=
====
EOF
if uudecode$EXEEXT Test.uue; then
ac_cv_prog_uudecode_base64=yes
else
echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AC_FD_CC
echo "configure: failed file was:" >&AC_FD_CC
cat Test.uue >&AC_FD_CC
ac_cv_prog_uudecode_base64=no
fi
rm -f Test.uue])
fi
if test x$ac_cv_prog_uudecode_base64 != xyes; then
rm -f Test.class
AC_MSG_WARN([I have to compile Test.class from scratch])
if test x$ac_cv_prog_javac_works = xno; then
AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly])
fi
if test x$ac_cv_prog_javac_works = x; then
AC_PROG_JAVAC
fi
fi
AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [
JAVA_TEST=Test.java
CLASS_TEST=Test.class
TEST=Test
changequote(, )dnl
cat << \EOF > $JAVA_TEST
/* [#]line __oline__ "configure" */
public class
Test {
public static void main (String args[]) {
System.exit(0);
} }
EOF
changequote([, ])dnl
if test x$ac_cv_prog_uudecode_base64 != xyes; then
if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then
:
else
echo "configure: failed program was:" >&AC_FD_CC
cat $JAVA_TEST >&AC_FD_CC
AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?))
fi
fi
if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then
ac_cv_prog_java_works=yes
else
echo "configure: failed program was:" >&AC_FD_CC
cat $JAVA_TEST >&AC_FD_CC
AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?))
fi
rm -fr $JAVA_TEST $CLASS_TEST Test.uue])
AC_PROVIDE([$0])dnl
fi
]
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment