diff --git a/.gitignore b/.gitignore index 9e8c92b..ee3da06 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ config.h config.h.in~ config.log config.status -compile autom4te.cache/ bin/ lib/ @@ -21,6 +20,9 @@ src/test-harness/twtest **/*.dll **/*.exe **/*~ +**/*# **/*.bak **/.DS_Store +**/*.gcno +**/*.gcda releases/ diff --git a/ChangeLog b/ChangeLog index e5ac5c3..e49ca47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2017-10-01 Brian Cox + * Update version to 2.4.3.6 + * Fix & expand tests in Perl acceptance test framework + * Fix & expand twtest unit tests, & rework unit test mini-framework so they’re referenced by name, not some numeric ID, and list tests as “skipped" if they don’t make any test assertions. + * Add configure options to enable coverage, profiling, & use /dev/urandom as RNG (all off by default) + * Add a ‘list’ make target to list all make targets + * Remove dead code & add test coverage per gcov+lcov results + * Fix various memory issues pointed out by valgrind + * In examine-encryption mode, better reporting (& nonzero exit) if we can't find a keyfile for the examined file. + * More exception handling around individual objects & init/IC as a whole, since there have been occasional reports of uncaught exceptions during init or check, and so far haven’t been able to repro or figure out what circumstances it occurs under. (e.g. Github issue #25) + * Tweak install.sh so it can be run directly, not just thru 'make install' if you want. (Github issue #26) + * Improve native (non-Posixy) path handling on platforms that need it (DOS, AROS, RISC OS, Redox) + * New platforms: MirOS BSD, Bitrig, LibertyBSD, RISC OS, Redox + * Add default policies for HP-UX & various BSDs + 2017-03-30 Brian Cox * Bump version to 2.4.3.5 * Fix ‘install-strip’, ‘check’, ‘uninstall’, and ‘distcheck’ make targets. @@ -35,7 +50,8 @@ * AROS: Correctly hide passphrases & delete temp files. * Remove dead code & unused files. * Optional RESOLVE_IDS_TO_NAMES option to disable uid/gid to name resolution, if needed. - * New --key-size option to twadmin --generate-keys, to generate 1024 (default) or 2048 bit El Gamal keys. + * New --key-size option to twadmin --generate-keys, to generate 1024 (default) or 2048 bit El Gamal keys. + 2016-04-20 Brian Cox * Bump version to 2.4.3.1 * Revive old 'twtest' unit test suite (such as it is); move _t.cpp files into twtest dir. diff --git a/Makefile.am b/Makefile.am index bfcd93a..e353377 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,5 +14,12 @@ uninstall-hook: check: rm -Rf $(top_srcdir)/src/test-harness/twtest + rm -Rf $(top_srcdir)/bin/TWTestData cd $(top_srcdir)/src/test-harness && perl ./twtest.pl - $(top_srcdir)/bin/twtest all + cd $(top_srcdir)/bin && ./twtest all + +test: check + +.PHONY: targets +targets: + @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs diff --git a/Makefile.in b/Makefile.in index 3bb6176..faf90c5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -307,7 +307,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -547,7 +546,7 @@ distdir: $(DISTFILES) ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir - tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir @@ -573,7 +572,7 @@ dist-shar: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 - shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir @@ -591,7 +590,7 @@ dist dist-all: distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ @@ -601,7 +600,7 @@ distcheck: dist *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ - GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ + eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac @@ -810,8 +809,15 @@ uninstall-hook: check: rm -Rf $(top_srcdir)/src/test-harness/twtest + rm -Rf $(top_srcdir)/bin/TWTestData cd $(top_srcdir)/src/test-harness && perl ./twtest.pl - $(top_srcdir)/bin/twtest all + cd $(top_srcdir)/bin && ./twtest all + +test: check + +.PHONY: targets +targets: + @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff --git a/TRADEMARK b/TRADEMARK index e06b19a..9d26cf5 100644 --- a/TRADEMARK +++ b/TRADEMARK @@ -2,7 +2,7 @@ TRIPWIRE COPYRIGHT & TRADEMARK NOTICE COPYRIGHT The developer of the original code and/or files is Tripwire, Inc. Portions -created by Tripwire, Inc. are copyright 2000 Tripwire, Inc. +created by Tripwire, Inc. are copyright 2000-2017 Tripwire, Inc. TRADEMARK Tripwire is a registered trademark (the "Trademark") of Tripwire, Inc. All diff --git a/aclocal.m4 b/aclocal.m4 index 322b108..1995959 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.15 -*- Autoconf -*- +# generated automatically by aclocal 1.15.1 -*- Autoconf -*- -# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2014 Free Software Foundation, Inc. +# Copyright (C) 2002-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.15' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.15], [], +m4_if([$1], [1.15.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.15])dnl +[AM_AUTOMAKE_VERSION([1.15.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -110,7 +110,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2014 Free Software Foundation, Inc. +# Copyright (C) 1997-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -141,7 +141,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -332,7 +332,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -408,7 +408,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -605,7 +605,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -626,7 +626,7 @@ if test x"${install_sh+set}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2014 Free Software Foundation, Inc. +# Copyright (C) 2003-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -647,7 +647,7 @@ AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -697,7 +697,7 @@ rm -f confinc confmf # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2014 Free Software Foundation, Inc. +# Copyright (C) 1997-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -738,7 +738,7 @@ fi # Obsolete and "removed" macros, that must however still report explicit # error messages when used, to smooth transition. # -# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -765,7 +765,7 @@ AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES]) # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -794,7 +794,7 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -841,7 +841,7 @@ AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -860,7 +860,7 @@ AC_DEFUN([AM_RUN_LOG], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Copyright (C) 1996-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -941,7 +941,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2014 Free Software Foundation, Inc. +# Copyright (C) 2009-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1001,7 +1001,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2014 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1029,7 +1029,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2014 Free Software Foundation, Inc. +# Copyright (C) 2006-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1048,7 +1048,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2014 Free Software Foundation, Inc. +# Copyright (C) 2004-2017 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/compile b/compile new file mode 100755 index 0000000..2ab71e4 --- /dev/null +++ b/compile @@ -0,0 +1,348 @@ +#! /bin/sh +# Wrapper for compilers which do not understand '-c -o'. + +scriptversion=2016-01-11.22; # UTC + +# Copyright (C) 1999-2017 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file 'INSTALL'. + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no '-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # '.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` + +# Create the lock directory. +# Note: use '[/\\:.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC0" +# time-stamp-end: "; # UTC" +# End: diff --git a/config.guess b/config.guess index 471f5a5..a05ca70 100644 --- a/config.guess +++ b/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2016 Free Software Foundation, Inc. +# Copyright 1992-2017 Free Software Foundation, Inc. -timestamp='2016-02-11' +timestamp='2017-09-16' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2016-02-11' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -27,7 +27,7 @@ timestamp='2016-02-11' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess # # Please send patches to . @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2016 Free Software Foundation, Inc. +Copyright 1992-2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -186,9 +186,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. + # to ELF recently (or will in the future) and ABI. case "${UNAME_MACHINE_ARCH}" in - arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ @@ -256,6 +259,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:Sortix:*:*) echo ${UNAME_MACHINE}-unknown-sortix exit ;; + *:Redox:*:*) + echo ${UNAME_MACHINE}-unknown-redox + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) @@ -312,15 +318,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in exitcode=$? trap '' 0 exit $exitcode ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; @@ -386,7 +383,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # This test works for both compilers. if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 @@ -684,7 +681,7 @@ EOF exit (0); } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac @@ -701,7 +698,7 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH=hppa2.0w @@ -834,10 +831,11 @@ EOF UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:MidnightBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` @@ -860,10 +858,6 @@ EOF *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 - exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; @@ -879,27 +873,12 @@ EOF echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; @@ -909,7 +888,7 @@ EOF exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix @@ -1006,6 +985,9 @@ EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; + mips64el:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; openrisc*:Linux:*:*) echo or1k-unknown-linux-${LIBC} exit ;; @@ -1038,6 +1020,9 @@ EOF ppcle:Linux:*:*) echo powerpcle-unknown-linux-${LIBC} exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; @@ -1285,6 +1270,9 @@ EOF SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux${UNAME_RELEASE} + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; @@ -1300,14 +1288,21 @@ EOF if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then if [ "$CC_FOR_BUILD" != no_compiler_found ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi fi elif test "$UNAME_PROCESSOR" = i386 ; then # Avoid executing cc on OS X 10.9, as it ships with a stub @@ -1331,15 +1326,18 @@ EOF *:QNX:*:4*) echo i386-pc-qnx exit ;; - NEO-?:NONSTOP_KERNEL:*:*) + NEO-*:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; - NSR-?:NONSTOP_KERNEL:*:*) + NSR-*:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk${UNAME_RELEASE} + exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; @@ -1395,7 +1393,7 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos @@ -1414,18 +1412,17 @@ esac cat >&2 < in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp diff --git a/config.h.in b/config.h.in index 387a1cd..f3f1b37 100644 --- a/config.h.in +++ b/config.h.in @@ -6,6 +6,9 @@ /* Compile with debug code */ #undef DEBUG +/* Enable use of /dev/urandom */ +#undef ENABLE_DEV_URANDOM + /* this is the prefix for STL exception functions */ #undef EXCEPTION_NAMESPACE @@ -15,6 +18,21 @@ /* Define to 1 if you have the header file. */ #undef HAVE_COMMONCRYPTO_COMMONDIGEST_H +/* Has /dev/arandom */ +#undef HAVE_DEV_ARANDOM + +/* Has /dev/random */ +#undef HAVE_DEV_RANDOM + +/* Has /dev/urandom */ +#undef HAVE_DEV_URANDOM + +/* Define to 1 if you have the `door_create' function. */ +#undef HAVE_DOOR_CREATE + +/* Define to 1 if you have the header file. */ +#undef HAVE_DOOR_H + /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H @@ -54,6 +72,12 @@ /* Define to 1 if you have the header file. */ #undef HAVE_OPENSSL_SHA_H +/* Define to 1 if you have the `port_create' function. */ +#undef HAVE_PORT_CREATE + +/* Define to 1 if you have the header file. */ +#undef HAVE_PORT_H + /* Define to 1 if you have the `posix_fadvise' function. */ #undef HAVE_POSIX_FADVISE @@ -78,6 +102,15 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_BLOCKS + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#undef HAVE_STRUCT_STAT_ST_RDEV + +/* Define to 1 if you have the `swab' function. */ +#undef HAVE_SWAB + /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H @@ -111,6 +144,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_UNISTD_H + /* Define to 1 if you have the header file. */ #undef HAVE_SYS_USTAT_H @@ -165,6 +201,9 @@ /* The size of `long long', as computed by sizeof. */ #undef SIZEOF_LONG_LONG +/* The size of `time_t', as computed by sizeof. */ +#undef SIZEOF_TIME_T + /* Don't use gethostbyname() on Solaris */ #undef SOLARIS_NO_GETHOSTBYNAME diff --git a/config.sub b/config.sub index 6f126a0..ec385cc 100644 --- a/config.sub +++ b/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2016 Free Software Foundation, Inc. +# Copyright 1992-2017 Free Software Foundation, Inc. -timestamp='2016-01-01' +timestamp='2017-09-22' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ timestamp='2016-01-01' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, see . +# along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -33,7 +33,7 @@ timestamp='2016-01-01' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -67,7 +67,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright 1992-2016 Free Software Foundation, Inc. +Copyright 1992-2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -117,7 +117,7 @@ case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -229,9 +229,6 @@ case $os in -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` - ;; -psos*) os=-psos ;; @@ -263,7 +260,7 @@ case $basic_machine in | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ - | i370 | i860 | i960 | ia64 \ + | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ | k1om \ | le32 | le64 \ @@ -301,6 +298,7 @@ case $basic_machine in | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ | riscv32 | riscv64 \ | rl78 | rx \ @@ -314,6 +312,7 @@ case $basic_machine in | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | visium \ + | wasm32 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) @@ -387,7 +386,7 @@ case $basic_machine in | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ - | i*86-* | i860-* | i960-* | ia64-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ | k1om-* \ | le32-* | le64-* \ @@ -428,6 +427,7 @@ case $basic_machine in | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ | riscv32-* | riscv64-* \ | rl78-* | romp-* | rs6000-* | rx-* \ @@ -444,6 +444,7 @@ case $basic_machine in | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | visium-* \ + | wasm32-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ @@ -643,6 +644,14 @@ case $basic_machine in basic_machine=m68k-bull os=-sysv3 ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + os=$os"spe" + ;; ebmon29k) basic_machine=a29k-amd os=-ebmon @@ -938,6 +947,9 @@ case $basic_machine in nsr-tandem) basic_machine=nsr-tandem ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf @@ -1022,7 +1034,7 @@ case $basic_machine in ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) @@ -1032,7 +1044,7 @@ case $basic_machine in ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) @@ -1233,6 +1245,9 @@ case $basic_machine in basic_machine=a29k-wrs os=-vxworks ;; + wasm32) + basic_machine=wasm32-unknown + ;; w65*) basic_machine=w65-wdc os=-none @@ -1241,6 +1256,9 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; + x64) + basic_machine=x86_64-pc + ;; xbox) basic_machine=i686-pc os=-mingw32 @@ -1348,8 +1366,8 @@ esac if [ x"$os" != x"" ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. + # First match some system type aliases that might get confused + # with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux @@ -1369,9 +1387,9 @@ case $os in -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # First accept the basic system types. + # Now accept the basic system types. # The portable systems comes first. - # Each alternative MUST END IN A *, to match a version number. + # Each alternative MUST end in a * to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ @@ -1387,9 +1405,9 @@ case $os in | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ @@ -1399,7 +1417,7 @@ case $os in | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ - | -onefs* | -tirtos*) + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1531,6 +1549,8 @@ case $os in ;; -nacl*) ;; + -ios) + ;; -none) ;; *) @@ -1626,6 +1646,9 @@ case $basic_machine in sparc-* | *-sun) os=-sunos4.1.1 ;; + pru-*) + os=-elf + ;; *-be) os=-beos ;; diff --git a/configure b/configure index 00df1a1..6a9c917 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.ac Revision: 2.4.3.5 . +# From configure.ac Revision: 2.4.3.6 . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for tripwire 2.4.3.5. +# Generated by GNU Autoconf 2.69 for tripwire 2.4.3.6. # # Report bugs to . # @@ -584,8 +584,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='tripwire' PACKAGE_TARNAME='tripwire' -PACKAGE_VERSION='2.4.3.5' -PACKAGE_STRING='tripwire 2.4.3.5' +PACKAGE_VERSION='2.4.3.6' +PACKAGE_STRING='tripwire 2.4.3.6' PACKAGE_BUGREPORT='https://github.com/Tripwire/tripwire-open-source/issues' PACKAGE_URL='https://github.com/Tripwire/tripwire-open-source' @@ -724,7 +724,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -751,6 +750,9 @@ enable_silent_rules enable_extrawarnings enable_static enable_debug +enable_coverage +enable_profiling +enable_urandom enable_dependency_tracking enable_commoncrypto enable_iconv @@ -810,7 +812,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1063,15 +1064,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1209,7 +1201,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1322,7 +1314,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures tripwire 2.4.3.5 to adapt to many kinds of systems. +\`configure' configures tripwire 2.4.3.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1362,7 +1354,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -1394,7 +1385,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of tripwire 2.4.3.5:";; + short | recursive ) echo "Configuration of tripwire 2.4.3.6:";; esac cat <<\_ACEOF @@ -1407,6 +1398,9 @@ Optional Features: —-disable-extrawarnings do not compile with -Wextra warnings enabled --enable-static compile static binaries --enable-debug compile with debuging enabled + --enable-coverage enable code coverage + --enable-profiling enable profiling + --enable-urandom use /dev/urandom --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking @@ -1506,7 +1500,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -tripwire configure 2.4.3.5 +tripwire configure 2.4.3.6 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2036,6 +2030,63 @@ rm -f conftest.val } # ac_fn_c_compute_int +# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES +# ---------------------------------------------------- +# Tries to find if the field MEMBER exists in type AGGR, after including +# INCLUDES, setting cache variable VAR accordingly. +ac_fn_c_check_member () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 +$as_echo_n "checking for $2.$3... " >&6; } +if eval \${$4+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$5 +int +main () +{ +static $2 ac_aggr; +if (sizeof ac_aggr.$3) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$4=yes" +else + eval "$4=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$4 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_member + # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. @@ -2393,7 +2444,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by tripwire $as_me 2.4.3.5, which was +It was created by tripwire $as_me 2.4.3.6, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3367,7 +3418,7 @@ fi # Define the identity of the package. PACKAGE='tripwire' - VERSION='2.4.3.5' + VERSION='2.4.3.6' cat >>confdefs.h <<_ACEOF @@ -3462,6 +3513,10 @@ fi ac_config_headers="$ac_config_headers config.h" + + + + CFLAGS=${CFLAGS:-"-O -pipe -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"} CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"} @@ -3499,6 +3554,46 @@ then $as_echo "#define DEBUG 1" >>confdefs.h +else + +$as_echo "#define NDEBUG 1" >>confdefs.h + +fi + +# Check whether --enable-coverage was given. +if test "${enable_coverage+set}" = set; then : + enableval=$enable_coverage; +fi + +if test "x$enable_coverage" = xyes +then + CFLAGS="${CFLAGS} --coverage" + CXXFLAGS="${CXXFLAGS} --coverage" + LDFLAGS="${LDFLAGS} --coverage" +fi + +# Check whether --enable-profiling was given. +if test "${enable_profiling+set}" = set; then : + enableval=$enable_profiling; +fi + +if test "x$enable_profiling" = xyes +then + CFLAGS="${CFLAGS} -pg" + CXXFLAGS="${CXXFLAGS} -pg" + LDFLAGS="${LDFLAGS} -pg" +fi + +# Check whether --enable-urandom was given. +if test "${enable_urandom+set}" = set; then : + enableval=$enable_urandom; +fi + +if test "x$enable_urandom" = xyes +then + +$as_echo "#define ENABLE_DEV_URANDOM 1" >>confdefs.h + fi ac_ext=c @@ -5531,7 +5626,20 @@ fi done -for ac_header in unistd.h syslog.h langinfo.h sys/statfs.h sys/select.h +for ac_header in unistd.h sys/unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +for ac_header in syslog.h langinfo.h sys/statfs.h sys/select.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -6062,6 +6170,39 @@ cat >>confdefs.h <<_ACEOF _ACEOF +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5 +$as_echo_n "checking size of time_t... " >&6; } +if ${ac_cv_sizeof_time_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_time_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (time_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_time_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_time_t" >&5 +$as_echo "$ac_cv_sizeof_time_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_TIME_T $ac_cv_sizeof_time_t +_ACEOF + + $as_echo "#define USES_1S_COMPLEMENT 0" >>confdefs.h @@ -6087,6 +6228,26 @@ $as_echo "#define IS_UNIX 1" >>confdefs.h $as_echo "#define NDEBUG 1" >>confdefs.h +ac_fn_c_check_member "$LINENO" "struct stat" "st_rdev" "ac_cv_member_struct_stat_st_rdev" "$ac_includes_default" +if test "x$ac_cv_member_struct_stat_st_rdev" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_RDEV 1 +_ACEOF + + +fi +ac_fn_c_check_member "$LINENO" "struct stat" "st_blocks" "ac_cv_member_struct_stat_st_blocks" "$ac_includes_default" +if test "x$ac_cv_member_struct_stat_st_blocks" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 +_ACEOF + + +fi + + for ac_func in strftime gethostname gethostid do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` @@ -6111,6 +6272,17 @@ _ACEOF fi done +for ac_func in swab +do : + ac_fn_c_check_func "$LINENO" "swab" "ac_cv_func_swab" +if test "x$ac_cv_func_swab" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SWAB 1 +_ACEOF + +fi +done + for ac_header in fcntl.h do : @@ -6157,6 +6329,78 @@ done fi +for ac_header in door.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "door.h" "ac_cv_header_door_h" "$ac_includes_default" +if test "x$ac_cv_header_door_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DOOR_H 1 +_ACEOF + for ac_func in door_create +do : + ac_fn_c_check_func "$LINENO" "door_create" "ac_cv_func_door_create" +if test "x$ac_cv_func_door_create" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_DOOR_CREATE 1 +_ACEOF + +fi +done + +fi + +done + + +for ac_header in port.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "port.h" "ac_cv_header_port_h" "$ac_includes_default" +if test "x$ac_cv_header_port_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PORT_H 1 +_ACEOF + for ac_func in port_create +do : + ac_fn_c_check_func "$LINENO" "port_create" "ac_cv_func_port_create" +if test "x$ac_cv_func_port_create" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_PORT_CREATE 1 +_ACEOF + +fi +done + +fi + +done + + + +UNAME=`uname` + + +if [ $UNAME != "AROS" ]; then + + if test -c "/dev/random"; then + +$as_echo "#define HAVE_DEV_RANDOM 1" >>confdefs.h + + fi + + if test -c "/dev/urandom"; then + +$as_echo "#define HAVE_DEV_URANDOM 1" >>confdefs.h + + fi + + if test -c "/dev/arandom"; then + +$as_echo "#define HAVE_DEV_ARANDOM 1" >>confdefs.h + + fi + +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for socket in -lc" >&5 $as_echo_n "checking for socket in -lc... " >&6; } @@ -6859,6 +7103,9 @@ case $target in ;; *-*-netbsd*) ;; + *-*-libertybsd*) + CXXFLAGS="${CXXFLAGS} -DTW_LibertyBSD" + ;; i[0-9]86-pc-linux*) ;; sparc-*-linux*) @@ -7642,7 +7889,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by tripwire $as_me 2.4.3.5, which was +This file was extended by tripwire $as_me 2.4.3.6, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7709,7 +7956,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -tripwire config.status 2.4.3.5 +tripwire config.status 2.4.3.6 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 2e72058..3876be6 100644 --- a/configure.ac +++ b/configure.ac @@ -2,14 +2,14 @@ dnl Process this file with autoconf to produce a configure script. dnl dnl -AC_INIT([tripwire], [2.4.3.5], [https://github.com/Tripwire/tripwire-open-source/issues], [tripwire], [https://github.com/Tripwire/tripwire-open-source]) +AC_INIT([tripwire], [2.4.3.6], [https://github.com/Tripwire/tripwire-open-source/issues], [tripwire], [https://github.com/Tripwire/tripwire-open-source]) AC_CONFIG_SRCDIR([src/tw/tw.cpp]) AC_CANONICAL_TARGET([]) AM_INIT_AUTOMAKE AM_CONFIG_HEADER(config.h) AC_COPYRIGHT([The developer of the original code and/or files is Tripwire, Inc. Portions created by Tripwire, Inc. are copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights reserved.]) -AC_REVISION([$Revision: 2.4.3.5 $]) +AC_REVISION([$Revision: 2.4.3.6 $]) dnl ############### dnl Setup defaults @@ -40,6 +40,30 @@ then CFLAGS="${CFLAGS} -g" CXXFLAGS="${CXXFLAGS} -g" AC_DEFINE(DEBUG, 1, [Compile with debug code]) +else + AC_DEFINE(NDEBUG, 1, [Compile without debug code]) +fi + +AC_ARG_ENABLE(coverage, [ --enable-coverage enable code coverage]) +if test "x$enable_coverage" = xyes +then + CFLAGS="${CFLAGS} --coverage" + CXXFLAGS="${CXXFLAGS} --coverage" + LDFLAGS="${LDFLAGS} --coverage" +fi + +AC_ARG_ENABLE(profiling, [ --enable-profiling enable profiling]) +if test "x$enable_profiling" = xyes +then + CFLAGS="${CFLAGS} -pg" + CXXFLAGS="${CXXFLAGS} -pg" + LDFLAGS="${LDFLAGS} -pg" +fi + +AC_ARG_ENABLE(urandom, [ --enable-urandom use /dev/urandom]) +if test "x$enable_urandom" = xyes +then + AC_DEFINE(ENABLE_DEV_URANDOM, 1, [Enable use of /dev/urandom]) fi dnl ################### @@ -75,7 +99,8 @@ AC_CHECK_HEADERS(sys/mount.h,,, #endif ]]) AC_CHECK_HEADERS(sys/ustat.h sys/sysmacros.h sys/syslog.h sys/socket.h) -AC_CHECK_HEADERS(unistd.h syslog.h langinfo.h sys/statfs.h sys/select.h) +AC_CHECK_HEADERS(unistd.h sys/unistd.h) +AC_CHECK_HEADERS(syslog.h langinfo.h sys/statfs.h sys/select.h) AC_CHECK_HEADERS(signum.h bits/signum.h, break ) AC_CHECK_HEADERS(stdarg.h varargs.h, break ) AC_CHECK_HEADERS(sys/utsname.h memory.h) @@ -97,6 +122,7 @@ AC_C_BIGENDIAN AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) +AC_CHECK_SIZEOF(time_t) dnl All platforms we support use 2's complement, are byte aligned, etc... AC_DEFINE(USES_1S_COMPLEMENT, 0, [Uses one's complement]) @@ -113,11 +139,15 @@ AC_DEFINE(IS_UNIX, 1, [Is a unix type platform]) dnl whether or not to generate debuging code? AC_DEFINE(NDEBUG, 1, [don't generate debuging code]) +dnl look for struct stat members that aren't always there +AC_CHECK_MEMBERS([struct stat.st_rdev, struct stat.st_blocks]) + dnl ############################# dnl Checks for standard functions dnl ############################# AC_CHECK_FUNCS(strftime gethostname gethostid) AC_CHECK_FUNCS(mkstemp mktemp, break) +AC_CHECK_FUNCS(swab) dnl check for posix_fadvise AC_CHECK_HEADERS(fcntl.h, [AC_CHECK_FUNCS(posix_fadvise)]) @@ -131,6 +161,40 @@ then AC_CHECK_HEADERS(CommonCrypto/CommonDigest.h) fi +dnl check for door support (Solaris) +AC_CHECK_HEADERS(door.h, [AC_CHECK_FUNCS(door_create)]) + +dnl check for event port support (Solaris) +AC_CHECK_HEADERS(port.h, [AC_CHECK_FUNCS(port_create)]) + +dnl ############################################## +dnl check for various RNG/PRNG devices +dnl ############################################## + +UNAME=`uname` + +dnl ############################################## +dnl AROS pops up a "Please insert disk" dialog for /dev +dnl if script looks for devices (which don't exist) +dnl so don't even try looking. +dnl ############################################## + +if [[ $UNAME != "AROS" ]]; then + + if test -c "/dev/random"; then + AC_DEFINE(HAVE_DEV_RANDOM, [1], [Has /dev/random]) + fi + + if test -c "/dev/urandom"; then + AC_DEFINE(HAVE_DEV_URANDOM, [1], [Has /dev/urandom]) + fi + + if test -c "/dev/arandom"; then + AC_DEFINE(HAVE_DEV_ARANDOM, [1], [Has /dev/arandom]) + fi + +fi + dnl ############################################## dnl Checks for various platform specific libraries dnl ############################################## @@ -285,6 +349,9 @@ case $target in ;; *-*-netbsd*) ;; + *-*-libertybsd*) + CXXFLAGS="${CXXFLAGS} -DTW_LibertyBSD" + ;; i[[0-9]]86-pc-linux*) ;; sparc-*-linux*) diff --git a/installer/install.sh b/installer/install.sh index 3492ccd..178731c 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -28,7 +28,7 @@ fi ## The usage message. ##------------------------------------------------------- -USAGE="install.sh [] [-n] [-f] [-s ] [-l ]" +USAGE="install.sh [] [-n] [-f] [-s ] [-l ] [-d ]" ##------------------------------------------------------- ## Figure out how to do an echo without newline. @@ -104,8 +104,10 @@ fi ## Miscellaneous configuration parameters. ##------------------------------------------------------- -# prefix -prefix="${prefix:=/usr}" +# set a few location variables if caller didn't pass them to us +prefix="${prefix:=/usr/local}" +sysconfdir="${sysconfdir:=/usr/local/etc}" +path_to_vi="${path_to_vi:=/usr/bin/vi}" # License File name TWLICENSEFILE="COPYING" @@ -178,6 +180,13 @@ while [ "x$1" != "x" ] ; do exit 1 ;; *) TW_LOCAL_PASS="$2"; shift ;; esac ;; + -d) case "$2" in + "" | -*) + echo "Error: missing install dir with -d option." 1>&2 + echo "$USAGE" + exit 1 ;; + *) prefix="$2"; sysconfdir="$2/bin"; shift ;; + esac ;; -*) echo "Error: unknown argument $1" 1>&2 echo "$USAGE" exit 1 ;; diff --git a/lcov.sh b/lcov.sh new file mode 100755 index 0000000..b8f85c5 --- /dev/null +++ b/lcov.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +if [ -d ./lcov ]; then + rm -Rf ./lcov +fi + +if [ -e ./lcov.dat ]; then + rm ./lcov.dat +fi + +if [ -e ./lcov.tgz ]; then + rm ./lcov.tgz +fi + +lcov --capture --directory src --output-file ./lcov.dat +genhtml ./lcov.dat --output-directory lcov +tar -zcvf lcov.tgz lcov + diff --git a/man/Makefile.in b/man/Makefile.in index 9cf2615..2218a28 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -284,7 +284,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/man/man4/Makefile.in b/man/man4/Makefile.in index 01437ef..dbd0c2d 100644 --- a/man/man4/Makefile.in +++ b/man/man4/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -256,7 +256,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/man/man5/Makefile.in b/man/man5/Makefile.in index 9bb9a4d..2d8dd98 100644 --- a/man/man5/Makefile.in +++ b/man/man5/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -256,7 +256,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/man/man8/Makefile.in b/man/man8/Makefile.in index 9341d22..d6e21b4 100644 --- a/man/man8/Makefile.in +++ b/man/man8/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -256,7 +256,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/policy/policyguide.txt b/policy/policyguide.txt index 09bf2e9..526ddaa 100644 --- a/policy/policyguide.txt +++ b/policy/policyguide.txt @@ -191,7 +191,7 @@ $(DIR1) -> $(param1); # It is also possible to do a #============================================================================= # -# Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, +# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, # Inc. All rights reserved. # # Linux is a registered trademark of Linus Torvalds. diff --git a/policy/twpol-Bitrig.txt b/policy/twpol-Bitrig.txt new file mode 100644 index 0000000..7130be2 --- /dev/null +++ b/policy/twpol-Bitrig.txt @@ -0,0 +1,292 @@ + ############################################################################## + # ## +############################################################################## # +# # # +# Policy file for Bitrig 1.x # # +# (adapted from OpenBSD policy) # # +# ## +############################################################################## + + ############################################################################## + # ## +############################################################################## # +# # # +# Global Variable Definitions # # +# # # +# These are defined at install time by the installation script. You may # # +# manually edit these if you are using this file directly and not from the # # +# installation script itself. # # +# ## +############################################################################## + +@@section GLOBAL +TWROOT=; +TWBIN=; +TWPOL=; +TWDB=; +TWSKEY=; +TWLKEY=; +TWREPORT=; +HOSTNAME=; + + ############################################################################## + # Predefined Variables # +############################################################################## +# +# Property Masks +# +# - ignore the following properties +# + check the following properties +# +# a access timestamp (mutually exclusive with +CMSH) +# b number of blocks allocated +# c inode creation/modification timestamp +# d ID of device on which inode resides +# g group id of owner +# i inode number +# l growing files (logfiles for example) +# m modification timestamp +# n number of links +# p permission and file mode bits +# r ID of device pointed to by inode (valid only for device objects) +# s file size +# t file type +# u user id of owner +# +# C CRC-32 hash +# H HAVAL hash +# M MD5 hash +# S SHA hash +# +############################################################################## + +Device = +pugsdr-intlbamcCMSH ; +Dynamic = +pinugtd-srlbamcCMSH ; +Growing = +pinugtdl-srbamcCMSH ; +IgnoreAll = -pinugtsdrlbamcCMSH ; +IgnoreNone = +pinugtsdrbamcCMSH-l ; +ReadOnly = +pinugtsdbmCM-rlacSH ; +Temporary = +pugt ; + +@@section FS + + ######################################## + # ## +######################################## # +# # # +# Tripwire Binaries and Data Files # # +# ## +######################################## + +# Tripwire Binaries +( + rulename = "Tripwire Binaries", +) +{ + $(TWBIN)/siggen -> $(ReadOnly) ; + $(TWBIN)/tripwire -> $(ReadOnly) ; + $(TWBIN)/twadmin -> $(ReadOnly) ; + $(TWBIN)/twprint -> $(ReadOnly) ; +} + +# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases +( + rulename = "Tripwire Data Files", +) +{ + # NOTE: We remove the inode attribute because when Tripwire creates a backup, + # it does so by renaming the old file and creating a new one (which will + # have a new inode number). Inode is left turned on for keys, which shouldn't + # ever change. + + # NOTE: The first integrity check triggers this rule and each integrity check + # afterward triggers this rule until a database update is run, since the + # database file does not exist before that point. + + $(TWDB) -> $(Dynamic) -i ; + $(TWPOL)/tw.pol -> $(ReadOnly) -i ; + $(TWPOL)/tw.cfg -> $(ReadOnly) -i ; + $(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ; + $(TWSKEY)/site.key -> $(ReadOnly) ; + + # don't scan the individual reports + $(TWREPORT) -> $(Dynamic) (recurse=0) ; + + # In this configuration /usr/local is a symbolic link to /home/local. + # We want to ignore the following directories since they are already + # scanned using the real directory or mount point. Otherwise we see + # duplicates in the reports. + + !/home/local ; +} + + ################################################ + # ## +################################################ # +# # # +# OS Boot and Configuration Files # # +# ## +################################################ +( + rulename = "OS Boot and Configuration Files", +) +{ + /boot -> $(ReadOnly) ; + /bsd -> $(ReadOnly) ; + /etc -> $(IgnoreNone) -SHa ; +} + + ################################################### + # ## +################################################### # +# # # +# Mount Points # # +# ## +################################################### +( + rulename = "Mount Points", +) +{ + / -> $(ReadOnly) ; + /cdrom -> $(Dynamic) ; + /floppy -> $(Dynamic) ; + /home -> $(ReadOnly) ; # Modify as needed + /mnt -> $(Dynamic) ; + /usr -> $(ReadOnly) ; + /var -> $(ReadOnly) ; +} + + ################################################### + # ## +################################################### # +# # # +# Misc Top-Level Directories # # +# ## +################################################### +( + rulename = "Misc Top-Level Directories", +) +{ + /altroot -> $(Dynamic) ; + /stand -> $(Dynamic) ; +} + + ################################################ + # ## +################################################ # +# # # +# System Devices # # +# ## +################################################ +( + rulename = "System Devices", +) +{ + /dev -> $(Device) ; + /dev/fd -> $(Device) ; + /var/cron/tabs/.sock -> $(Device) ; + /var/empty/dev/log -> $(Device) ; +} + + ################################################ + # ## +################################################ # +# # # +# OS Binaries and Libraries # # +# ## +################################################ +( + rulename = "OS Binaries and Libraries", +) +{ + /bin -> $(ReadOnly) ; + /sbin -> $(ReadOnly) ; + /usr/bin -> $(ReadOnly) ; + /usr/lib -> $(ReadOnly) ; + /usr/libexec -> $(ReadOnly) ; + /usr/sbin -> $(ReadOnly) ; + /usr/X11R6/bin -> $(ReadOnly) ; + /usr/X11R6/lib -> $(ReadOnly) ; +} + ################################################ + # ## +################################################ # +# # # +# Usr Local Files # # +# ## +################################################ +#OK( + #OKrulename = "Usr Local Files", +#OK) +#OK{ + #OK/usr/local -> $(ReadOnly) ; + #OK/usr/local/bin -> $(ReadOnly) ; + #OK/usr/local/doc -> $(ReadOnly) ; + #OK/usr/local/etc -> $(ReadOnly) ; + #OK/usr/local/include -> $(ReadOnly) ; + #OK/usr/local/info -> $(ReadOnly) ; + #OK/usr/local/lib -> $(ReadOnly) ; + #OK/usr/local/libdata -> $(ReadOnly) ; + #OK/usr/local/libexec -> $(ReadOnly) ; + #OK/usr/local/man -> $(ReadOnly) ; + #OK/usr/local/sbin -> $(ReadOnly) ; + #OK/usr/local/share -> $(ReadOnly) ; + #OK/usr/local/src -> $(ReadOnly) ; +#OK} + + ################################################ + # ## +################################################ # +# # # +# Root Directory and Files # # +# ## +################################################ +( + rulename = "Root Directory and Files", +) +{ + /root -> $(IgnoreNone) -SHa ; + /root/.cshrc -> $(Dynamic) ; + /root/.profile -> $(Dynamic) ; +} + + ################################################ + # ## +################################################ # +# # # +# Temporary Directories # # +# ## +################################################ +( + rulename = "Temporary Directories", +) +{ + /tmp -> $(Temporary) ; + /var/tmp -> $(Temporary) ; +} + + ################################################ + # ## +################################################ # +# # # +# System and Boot Changes # # +# ## +################################################ +( + rulename = "System and Boot Changes", +) +{ + /var/backups -> $(Dynamic) -i ; + /var/db/host.random -> $(ReadOnly) -mCM ; + /var/cron -> $(Growing) -i ; + /var/log -> $(Growing) -i ; + /var/run -> $(Dynamic) -i ; + /var/mail -> $(Growing) ; + /var/msgs/bounds -> $(ReadOnly) -smbCM ; + /var/spool/clientmqueue -> $(Temporary) ; + /var/spool/mqueue -> $(Temporary) ; +} + +# +# $Id: twpol-OpenBSD.txt,v 1.2 2004/05/14 21:56:21 pherman Exp $ +# diff --git a/policy/twpol-DragonFly.txt b/policy/twpol-DragonFly.txt new file mode 100644 index 0000000..1c3f184 --- /dev/null +++ b/policy/twpol-DragonFly.txt @@ -0,0 +1,656 @@ +# +# Policy file for DragonFly BSD +# (adapted from FreeBSD policy) +# +# $FreeBSD: ports/security/tripwire/files/twpol.txt,v 1.2 2002/03/04 16:55:21 cy Exp $ +# $Id: twpol-FreeBSD.txt,v 1.1 2003/06/08 02:00:06 pherman Exp $ + +# +# This is the example Tripwire Policy file. It is intended as a place to +# start creating your own custom Tripwire Policy file. Referring to it as +# well as the Tripwire Policy Guide should give you enough information to +# make a good custom Tripwire Policy file that better covers your +# configuration and security needs. A text version of this policy file is +# called twpol.txt. +# +# Note that this file is tuned to an install of FreeBSD using +# buildworld. If run unmodified, this file should create no errors on +# database creation, or violations on a subsiquent integrity check. +# However it is impossible for there to be one policy file for all machines, +# so this existing one errs on the side of security. Your FreeBSD +# configuration will most likey differ from the one our policy file was +# tuned to, and will therefore require some editing of the default +# Tripwire Policy file. +# +# The example policy file is best run with 'Loose Directory Checking' +# enabled. Set LOOSEDIRECTORYCHECKING=TRUE in the Tripwire Configuration +# file. +# +# Email support is not included and must be added to this file. +# Add the 'emailto=' to the rule directive section of each rule (add a comma +# after the 'severity=' line and add an 'emailto=' and include the email +# addresses you want the violation reports to go to). Addresses are +# semi-colon delimited. +# + + + +# +# Global Variable Definitions +# +# These are defined at install time by the installation script. You may +# Manually edit these if you are using this file directly and not from the +# installation script itself. +# + +@@section GLOBAL +TWROOT=; +TWBIN=; +TWPOL=; +TWDB=; +TWSKEY=; +TWLKEY=; +TWREPORT=; +HOSTNAME=; + +@@section FS +SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change +SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set +SEC_BIN = $(ReadOnly) ; # Binaries that should not change +SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often +SEC_TTY = $(Dynamic)-ugp ; # Tty files that change ownership at login +SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership +SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership +SIG_LOW = 33 ; # Non-critical files that are of minimal security impact +SIG_MED = 66 ; # Non-critical files that are of significant security impact +SIG_HI = 100 ; # Critical files that are significant points of vulnerability + + +# Tripwire Binaries +( + rulename = "Tripwire Binaries", + severity = $(SIG_HI) +) +{ + $(TWBIN)/siggen -> $(SEC_BIN) ; + $(TWBIN)/tripwire -> $(SEC_BIN) ; + $(TWBIN)/twadmin -> $(SEC_BIN) ; + $(TWBIN)/twprint -> $(SEC_BIN) ; +} + +# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases +( + rulename = "Tripwire Data Files", + severity = $(SIG_HI) +) +{ + # NOTE: We remove the inode attribute because when Tripwire creates a backup, + # it does so by renaming the old file and creating a new one (which will + # have a new inode number). Inode is left turned on for keys, which shouldn't + # ever change. + + # NOTE: The first integrity check triggers this rule and each integrity check + # afterward triggers this rule until a database update is run, since the + # database file does not exist before that point. + + $(TWDB) -> $(SEC_CONFIG) -i ; + $(TWPOL)/tw.pol -> $(SEC_BIN) -i ; + $(TWPOL)/tw.cfg -> $(SEC_BIN) -i ; + $(TWPOL)/twcfg.txt -> $(SEC_BIN) ; + $(TWPOL)/twpol.txt -> $(SEC_BIN) ; + $(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_BIN) ; + $(TWSKEY)/site.key -> $(SEC_BIN) ; + + #don't scan the individual reports + $(TWREPORT) -> $(SEC_CONFIG) (recurse=0) ; +} + + +# Tripwire HQ Connector Binaries +#( +# rulename = "Tripwire HQ Connector Binaries", +# severity = $(SIG_HI) +#) +#{ +# $(TWBIN)/hqagent -> $(SEC_BIN) ; +#} +# +# Tripwire HQ Connector - Configuration Files, Keys, and Logs + +# +# Note: File locations here are different than in a stock HQ Connector +# installation. This is because Tripwire 2.3 uses a different path +# structure than Tripwire 2.2.1. +# +# You may need to update your HQ Agent configuation file (or this policy +# file) to correct the paths. We have attempted to support the FHS standard +# here by placing the HQ Agent files similarly to the way Tripwire 2.3 +# places them. +# + +#( +# rulename = "Tripwire HQ Connector Data Files", +# severity = $(SIG_HI) +#) +#{ +# +# # NOTE: Removing the inode attribute because when Tripwire creates a backup +# # it does so by renaming the old file and creating a new one (which will +# # have a new inode number). Leaving inode turned on for keys, which +# # shouldn't ever change. +# +# +# $(TWBIN)/agent.cfg -> $(SEC_BIN) -i ; +# $(TWLKEY)/authentication.key -> $(SEC_BIN) ; +# $(TWDB)/tasks.dat -> $(SEC_CONFIG) ; +# $(TWDB)/schedule.dat -> $(SEC_CONFIG) ; +# +# # Uncomment if you have agent logging enabled. +# #/var/log/tripwire/agent.log -> $(SEC_LOG) ; +#} + + + +# Commonly accessed directories that should remain static with regards to owner and group +( + rulename = "Invariant Directories", + severity = $(SIG_MED) +) +{ + / -> $(SEC_INVARIANT) (recurse = false) ; + /home -> $(SEC_INVARIANT) (recurse = false) ; +} + +# +# First, root's "home" +# + +( + rulename = "Root's home", + severity = $(SIG_HI) +) +{ + # /.rhosts -> $(SEC_CRIT) ; + /.profile -> $(SEC_CRIT) ; + /.cshrc -> $(SEC_CRIT) ; + /.login -> $(SEC_CRIT) ; + # /.exrc -> $(SEC_CRIT) ; + # /.logout -> $(SEC_CRIT) ; + # /.forward -> $(SEC_CRIT) ; + /root -> $(SEC_CRIT) (recurse = true) ; + !/root/.history ; + !/root/.bash_history ; + # !/root/.lsof_SYSTEM_NAME ; # Uncomment if lsof is installed +} + + +# +# FreeBSD Kernel +# + +( + rulename = "FreeBSD Kernel", + severity = $(SIG_HI) +) +{ + /kernel -> $(SEC_CRIT) ; + /kernel.old -> $(SEC_CRIT) ; + /kernel.GENERIC -> $(SEC_CRIT) ; +} + + +# +# FreeBSD Modules +# + +( + rulename = "FreeBSD Modules", + severity = $(SIG_HI) +) +{ + /modules -> $(SEC_CRIT) (recurse = true) ; + /modules.old -> $(SEC_CRIT) (recurse = true) ; + # /lkm -> $(SEC_CRIT) (recurse = true) ; # uncomment if using lkm kld +} + + +# +# System Administration Programs +# + +( + rulename = "System Administration Programs", + severity = $(SIG_HI) +) +{ + /sbin -> $(SEC_CRIT) (recurse = true) ; + /usr/sbin -> $(SEC_CRIT) (recurse = true) ; +} + + +# +# User Utilities +# + +( + rulename = "User Utilities", + severity = $(SIG_HI) +) +{ + /bin -> $(SEC_CRIT) (recurse = true) ; + /usr/bin -> $(SEC_CRIT) (recurse = true) ; +} + + +# +# /dev +# + +( + rulename = "/dev", + severity = $(SIG_HI) +) +{ + /dev -> $(Device) (recurse = true) ; + !/dev/vga ; + !/dev/dri ; + /dev/console -> $(SEC_TTY) ; + /dev/ttyv0 -> $(SEC_TTY) ; + /dev/ttyv1 -> $(SEC_TTY) ; + /dev/ttyv2 -> $(SEC_TTY) ; + /dev/ttyv3 -> $(SEC_TTY) ; + /dev/ttyv4 -> $(SEC_TTY) ; + /dev/ttyv5 -> $(SEC_TTY) ; + /dev/ttyv6 -> $(SEC_TTY) ; + /dev/ttyv7 -> $(SEC_TTY) ; + /dev/ttyp0 -> $(SEC_TTY) ; + /dev/ttyp1 -> $(SEC_TTY) ; + /dev/ttyp2 -> $(SEC_TTY) ; + /dev/ttyp3 -> $(SEC_TTY) ; + /dev/ttyp4 -> $(SEC_TTY) ; + /dev/ttyp5 -> $(SEC_TTY) ; + /dev/ttyp6 -> $(SEC_TTY) ; + /dev/ttyp7 -> $(SEC_TTY) ; + /dev/ttyp8 -> $(SEC_TTY) ; + /dev/ttyp9 -> $(SEC_TTY) ; + /dev/ttypa -> $(SEC_TTY) ; + /dev/ttypb -> $(SEC_TTY) ; + /dev/ttypc -> $(SEC_TTY) ; + /dev/ttypd -> $(SEC_TTY) ; + /dev/ttype -> $(SEC_TTY) ; + /dev/ttypf -> $(SEC_TTY) ; + /dev/ttypg -> $(SEC_TTY) ; + /dev/ttyph -> $(SEC_TTY) ; + /dev/ttypi -> $(SEC_TTY) ; + /dev/ttypj -> $(SEC_TTY) ; + /dev/ttypl -> $(SEC_TTY) ; + /dev/ttypm -> $(SEC_TTY) ; + /dev/ttypn -> $(SEC_TTY) ; + /dev/ttypo -> $(SEC_TTY) ; + /dev/ttypp -> $(SEC_TTY) ; + /dev/ttypq -> $(SEC_TTY) ; + /dev/ttypr -> $(SEC_TTY) ; + /dev/ttyps -> $(SEC_TTY) ; + /dev/ttypt -> $(SEC_TTY) ; + /dev/ttypu -> $(SEC_TTY) ; + /dev/ttypv -> $(SEC_TTY) ; + /dev/cuaa0 -> $(SEC_TTY) ; # modem +} + + +# +# /etc +# + +( + rulename = "/etc", + severity = $(SIG_HI) +) +{ + /etc -> $(SEC_CRIT) (recurse = true) ; + # /etc/mail/aliases -> $(SEC_CONFIG) ; + /etc/dumpdates -> $(SEC_CONFIG) ; + /etc/motd -> $(SEC_CONFIG) ; + !/etc/ppp/connect-errors ; + /etc/skeykeys -> $(SEC_CONFIG) ; + # Uncomment the following 4 lines if your password file does not change + # /etc/passwd -> $(SEC_CONFIG) ; + # /etc/master.passwd -> $(SEC_CONFIG) ; + # /etc/pwd.db -> $(SEC_CONFIG) ; + # /etc/spwd.db -> $(SEC_CONFIG) ; +} + + +# +# Copatibility (Linux) +# + +( + rulename = "Linux Compatibility", + severity = $(SIG_HI) +) +{ + /compat -> $(SEC_CRIT) (recurse = true) ; +# +# Uncomment the following if Linux compatibility is used. Replace +# HOSTNAME1 and HOSTNAME2 with the hosts that have Linux emulation port +# installed. +# +#@@ifhost HOSTNAME1 || HOSTNAME2 +# /compat/linux/etc -> $(SEC_INVARIANT) (recurse = false) ; +# /compat/linux/etc/X11 -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/pam.d -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/profile.d -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/real -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/bashrc -> $(SEC_CONFIG) ; +# /compat/linux/etc/csh.login -> $(SEC_CONFIG) ; +# /compat/linux/etc/host.conf -> $(SEC_CONFIG) ; +# /compat/linux/etc/hosts.allow -> $(SEC_CONFIG) ; +# /compat/linux/etc/hosts.deny -> $(SEC_CONFIG) ; +# /compat/linux/etc/info-dir -> $(SEC_CONFIG) ; +# /compat/linux/etc/inputrc -> $(SEC_CONFIG) ; +# /compat/linux/etc/ld.so.conf -> $(SEC_CONFIG) ; +# /compat/linux/etc/nsswitch.conf -> $(SEC_CONFIG) ; +# /compat/linux/etc/profile -> $(SEC_CONFIG) ; +# /compat/linux/etc/redhat-release -> $(SEC_CONFIG) ; +# /compat/linux/etc/rpc -> $(SEC_CONFIG) ; +# /compat/linux/etc/securetty -> $(SEC_CONFIG) ; +# /compat/linux/etc/shells -> $(SEC_CONFIG) ; +# /compat/linux/etc/termcap -> $(SEC_CONFIG) ; +# /compat/linux/etc/yp.conf -> $(SEC_CONFIG) ; +# !/compat/linux/etc/ld.so.cache ; +# !/compat/linux/var/spool/mail ; +#@@endif +} + + +# +# Libraries, include files, and other system files +# + +( + rulename = "Libraries, include files, and other system files", + severity = $(SIG_HI) +) +{ + /usr/include -> $(SEC_CRIT) (recurse = true) ; + /usr/lib -> $(SEC_CRIT) (recurse = true) ; + /usr/libdata -> $(SEC_CRIT) (recurse = true) ; + /usr/libexec -> $(SEC_CRIT) (recurse = true) ; + /usr/share -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man -> $(SEC_CONFIG) ; + !/usr/share/man/whatis ; + !/usr/share/man/.glimpse_filenames ; + !/usr/share/man/.glimpse_filenames_index ; + !/usr/share/man/.glimpse_filetimes ; + !/usr/share/man/.glimpse_filters ; + !/usr/share/man/.glimpse_index ; + !/usr/share/man/.glimpse_messages ; + !/usr/share/man/.glimpse_partitions ; + !/usr/share/man/.glimpse_statistics ; + !/usr/share/man/.glimpse_turbo ; + /usr/share/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/share/man/cat1 ; + ! /usr/share/man/cat2 ; + ! /usr/share/man/cat3 ; + ! /usr/share/man/cat4 ; + ! /usr/share/man/cat5 ; + ! /usr/share/man/cat6 ; + ! /usr/share/man/cat7 ; + ! /usr/share/man/cat8 ; + ! /usr/share/man/cat9 ; + ! /usr/share/man/catl ; + ! /usr/share/man/catn ; + /usr/share/perl/man -> $(SEC_CONFIG) ; + !/usr/share/perl/man/whatis ; + !/usr/share/perl/man/.glimpse_filenames ; + !/usr/share/perl/man/.glimpse_filenames_index ; + !/usr/share/perl/man/.glimpse_filetimes ; + !/usr/share/perl/man/.glimpse_filters ; + !/usr/share/perl/man/.glimpse_index ; + !/usr/share/perl/man/.glimpse_messages ; + !/usr/share/perl/man/.glimpse_partitions ; + !/usr/share/perl/man/.glimpse_statistics ; + !/usr/share/perl/man/.glimpse_turbo ; + /usr/share/perl/man/man3 -> $(SEC_CRIT) (recurse = true) ; + ! /usr/share/perl/man/cat3 ; + /usr/local/lib/perl5/5.00503/man -> $(SEC_CONFIG) ; + ! /usr/local/lib/perl5/5.00503/man/whatis ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filters ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filetimes ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_messages ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_statistics ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_index ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_turbo ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_partitions ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filenames ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filenames_index ; + /usr/local/lib/perl5/5.00503/man/man3 -> $(SEC_CRIT) (recurse = true) ; + ! /usr/local/lib/perl5/5.00503/man/cat3 ; +} + + +# +# X11R6 +# + +( + rulename = "X11R6", + severity = $(SIG_HI) +) +{ + /usr/X11R6 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/lib/X11/xdm -> $(SEC_CONFIG) (recurse = true) ; + !/usr/X11R6/lib/X11/xdm/xdm-errors ; + !/usr/X11R6/lib/X11/xdm/authdir/authfiles ; + !/usr/X11R6/lib/X11/xdm/xdm-pid ; + /usr/X11R6/lib/X11/xkb/compiled -> $(SEC_CONFIG) (recurse = true) ; + /usr/X11R6/man -> $(SEC_CONFIG) ; + !/usr/X11R6/man/whatis ; + !/usr/X11R6/man/.glimpse_filenames ; + !/usr/X11R6/man/.glimpse_filenames_index ; + !/usr/X11R6/man/.glimpse_filetimes ; + !/usr/X11R6/man/.glimpse_filters ; + !/usr/X11R6/man/.glimpse_index ; + !/usr/X11R6/man/.glimpse_messages ; + !/usr/X11R6/man/.glimpse_partitions ; + !/usr/X11R6/man/.glimpse_statistics ; + !/usr/X11R6/man/.glimpse_turbo ; + /usr/X11R6/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/manl -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/X11R6/man/cat1 ; + ! /usr/X11R6/man/cat2 ; + ! /usr/X11R6/man/cat3 ; + ! /usr/X11R6/man/cat4 ; + ! /usr/X11R6/man/cat5 ; + ! /usr/X11R6/man/cat6 ; + ! /usr/X11R6/man/cat7 ; + ! /usr/X11R6/man/cat8 ; + ! /usr/X11R6/man/cat9 ; + ! /usr/X11R6/man/catl ; + ! /usr/X11R6/man/catn ; +} + + +# +# sources +# + +( + rulename = "Sources", + severity = $(SIG_HI) +) +{ + /usr/src -> $(SEC_CRIT) (recurse = true) ; + /usr/src/sys/compile -> $(SEC_CONFIG) (recurse = false) ; +} + + +# +# NIS +# + +( + rulename = "NIS", + severity = $(SIG_HI) +) +{ + /var/yp -> $(SEC_CRIT) (recurse = true) ; + !/var/yp/binding ; +} + + +# +# Temporary directories +# +( + rulename = "Temporary directories", + recurse = false, + severity = $(SIG_LOW) +) +{ + /usr/tmp -> $(SEC_INVARIANT) ; + /var/tmp -> $(SEC_INVARIANT) ; + /var/preserve -> $(SEC_INVARIANT) ; + /tmp -> $(SEC_INVARIANT) ; +} + +# +# Local files +# + +( + rulename = "Local files", + severity = $(SIG_MED) +) +{ + /usr/local/bin -> $(SEC_BIN) (recurse = true) ; + /usr/local/sbin -> $(SEC_BIN) (recurse = true) ; + /usr/local/etc -> $(SEC_BIN) (recurse = true) ; + /usr/local/lib -> $(SEC_BIN) (recurse = true ) ; + /usr/local/libexec -> $(SEC_BIN) (recurse = true ) ; + /usr/local/share -> $(SEC_BIN) (recurse = true ) ; + /usr/local/man -> $(SEC_CONFIG) ; + !/usr/local/man/whatis ; + !/usr/local/man/.glimpse_filenames ; + !/usr/local/man/.glimpse_filenames_index ; + !/usr/local/man/.glimpse_filetimes ; + !/usr/local/man/.glimpse_filters ; + !/usr/local/man/.glimpse_index ; + !/usr/local/man/.glimpse_messages ; + !/usr/local/man/.glimpse_partitions ; + !/usr/local/man/.glimpse_statistics ; + !/usr/local/man/.glimpse_turbo ; + /usr/local/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/manl -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/local/man/cat1 ; + ! /usr/local/man/cat2 ; + ! /usr/local/man/cat3 ; + ! /usr/local/man/cat4 ; + ! /usr/local/man/cat5 ; + ! /usr/local/man/cat6 ; + ! /usr/local/man/cat7 ; + ! /usr/local/man/cat8 ; + ! /usr/local/man/cat9 ; + ! /usr/local/man/catl ; + ! /usr/local/man/catn ; + /usr/local/krb5 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man -> $(SEC_CONFIG) ; + !/usr/local/krb5/man/whatis ; + !/usr/local/krb5/man/.glimpse_filenames ; + !/usr/local/krb5/man/.glimpse_filenames_index ; + !/usr/local/krb5/man/.glimpse_filetimes ; + !/usr/local/krb5/man/.glimpse_filters ; + !/usr/local/krb5/man/.glimpse_index ; + !/usr/local/krb5/man/.glimpse_messages ; + !/usr/local/krb5/man/.glimpse_partitions ; + !/usr/local/krb5/man/.glimpse_statistics ; + !/usr/local/krb5/man/.glimpse_turbo ; + /usr/local/krb5/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/manl -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/local/krb5/man/cat1 ; + ! /usr/local/krb5/man/cat2 ; + ! /usr/local/krb5/man/cat3 ; + ! /usr/local/krb5/man/cat4 ; + ! /usr/local/krb5/man/cat5 ; + ! /usr/local/krb5/man/cat6 ; + ! /usr/local/krb5/man/cat7 ; + ! /usr/local/krb5/man/cat8 ; + ! /usr/local/krb5/man/cat9 ; + ! /usr/local/krb5/man/catl ; + ! /usr/local/krb5/man/catn ; + /usr/local/www -> $(SEC_CONFIG) (recurse = true) ; +} + + +( + rulename = "Security Control", + severity = $(SIG_HI) +) +{ + /etc/group -> $(SEC_CRIT) ; + /etc/crontab -> $(SEC_CRIT) ; +} + +#============================================================================= +# +# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, +# Inc. in the United States and other countries. All rights reserved. +# +# FreeBSD is a registered trademark of the FreeBSD Project Inc. +# +# UNIX is a registered trademark of The Open Group. +# +#============================================================================= +# +# Permission is granted to make and distribute verbatim copies of this document +# provided the copyright notice and this permission notice are preserved on all +# copies. +# +# Permission is granted to copy and distribute modified versions of this +# document under the conditions for verbatim copying, provided that the entire +# resulting derived work is distributed under the terms of a permission notice +# identical to this one. +# +# Permission is granted to copy and distribute translations of this document +# into another language, under the above conditions for modified versions, +# except that this permission notice may be stated in a translation approved by +# Tripwire, Inc. +# +# DCM diff --git a/policy/twpol-FreeBSD.txt b/policy/twpol-FreeBSD.txt index 351a320..bae94fb 100644 --- a/policy/twpol-FreeBSD.txt +++ b/policy/twpol-FreeBSD.txt @@ -629,7 +629,7 @@ SIG_HI = 100 ; # Critical files that are significant point #============================================================================= # -# Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, +# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, # Inc. in the United States and other countries. All rights reserved. # # FreeBSD is a registered trademark of the FreeBSD Project Inc. diff --git a/policy/twpol-GENERIC.txt b/policy/twpol-GENERIC.txt index e30ae4c..114028e 100644 --- a/policy/twpol-GENERIC.txt +++ b/policy/twpol-GENERIC.txt @@ -1078,7 +1078,7 @@ SIG_HI = 100 ; # Critical files that are significant point #============================================================================= # -# Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, +# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, # Inc. in the United States and other countries. All rights reserved. # # Linux is a registered trademark of Linus Torvalds. diff --git a/policy/twpol-HP-UX.txt b/policy/twpol-HP-UX.txt new file mode 100644 index 0000000..176aa5d --- /dev/null +++ b/policy/twpol-HP-UX.txt @@ -0,0 +1,1106 @@ + ############################################################################## + # ## +############################################################################## # +# # # +# Policy file for HP-UX # # +# (adapted from OST generic policy) # # +# ## +############################################################################## + + + ############################################################################## + # ## +############################################################################## # +# # # +# This is the example Tripwire Policy file. It is intended as a place to # # +# start creating your own custom Tripwire Policy file. Referring to it as # # +# well as the Tripwire Policy Guide should give you enough information to # # +# make a good custom Tripwire Policy file that better covers your # # +# configuration and security needs. A text version of this policy file is # # +# called twpol.txt. # # +# # # +# Note that this file is tuned to an 'everything' install of Red Hat Linux. # # +# If run unmodified, this file should create no errors on database # # +# creation, or violations on a subsiquent integrity check. However, it is # # +# impossible for there to be one policy file for all machines, so this # # +# existing one errs on the side of security. Your Linux configuration will # # +# most likey differ from the one our policy file was tuned to, and will # # +# therefore require some editing of the default Tripwire Policy file. # # +# # # +# The example policy file is best run with 'Loose Directory Checking' # # +# enabled. Set LOOSEDIRECTORYCHECKING=TRUE in the Tripwire Configuration # # +# file. # # +# # # +# Email support is not included and must be added to this file. # # +# Add the 'emailto=' to the rule directive section of each rule (add a comma # # +# after the 'severity=' line and add an 'emailto=' and include the email # # +# addresses you want the violation reports to go to). Addresses are # # +# semi-colon delimited. # # +# ## +############################################################################## + + + + ############################################################################## + # ## +############################################################################## # +# # # +# Global Variable Definitions # # +# # # +# These are defined at install time by the installation script. You may # # +# Manually edit these if you are using this file directly and not from the # # +# installation script itself. # # +# ## +############################################################################## + +@@section GLOBAL +TWROOT=; +TWBIN=; +TWPOL=; +TWDB=; +TWSKEY=; +TWLKEY=; +TWREPORT=; +HOSTNAME=; + +@@section FS +SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change +SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set +SEC_BIN = $(ReadOnly) ; # Binaries that should not change +SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often +SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership +SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership +SIG_LOW = 33 ; # Non-critical files that are of minimal security impact +SIG_MED = 66 ; # Non-critical files that are of significant security impact +SIG_HI = 100 ; # Critical files that are significant points of vulnerability + + +# Tripwire Binaries +( + rulename = "Tripwire Binaries", + severity = $(SIG_HI) +) +{ + $(TWBIN)/siggen -> $(SEC_BIN) ; + $(TWBIN)/tripwire -> $(SEC_BIN) ; + $(TWBIN)/twadmin -> $(SEC_BIN) ; + $(TWBIN)/twprint -> $(SEC_BIN) ; +} + +# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases +( + rulename = "Tripwire Data Files", + severity = $(SIG_HI) +) +{ + # NOTE: We remove the inode attribute because when Tripwire creates a backup, + # it does so by renaming the old file and creating a new one (which will + # have a new inode number). Inode is left turned on for keys, which shouldn't + # ever change. + + # NOTE: The first integrity check triggers this rule and each integrity check + # afterward triggers this rule until a database update is run, since the + # database file does not exist before that point. + + $(TWDB) -> $(SEC_CONFIG) -i ; + $(TWPOL)/tw.pol -> $(SEC_BIN) -i ; + $(TWPOL)/tw.cfg -> $(SEC_BIN) -i ; + $(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_BIN) ; + $(TWSKEY)/site.key -> $(SEC_BIN) ; + + #don't scan the individual reports + $(TWREPORT) -> $(SEC_CONFIG) (recurse=0) ; +} + + +# Tripwire HQ Connector Binaries +#( +# rulename = "Tripwire HQ Connector Binaries", +# severity = $(SIG_HI) +#) +#{ +# $(TWBIN)/hqagent -> $(SEC_BIN) ; +#} +# +# Tripwire HQ Connector - Configuration Files, Keys, and Logs + + ############################################################################## + # ## +############################################################################## # +# # # +# Note: File locations here are different than in a stock HQ Connector # # +# installation. This is because Tripwire 2.3 uses a different path # # +# structure than Tripwire 2.2.1. # # +# # # +# You may need to update your HQ Agent configuation file (or this policy # # +# file) to correct the paths. We have attempted to support the FHS standard # # +# here by placing the HQ Agent files similarly to the way Tripwire 2.3 # # +# places them. # # +# ## +############################################################################## + +#( +# rulename = "Tripwire HQ Connector Data Files", +# severity = $(SIG_HI) +#) +#{ +# ############################################################################# +# ############################################################################## +# # NOTE: Removing the inode attribute because when Tripwire creates a backup ## +# # it does so by renaming the old file and creating a new one (which will ## +# # have a new inode number). Leaving inode turned on for keys, which ## +# # shouldn't ever change. ## +# ############################################################################# +# +# $(TWBIN)/agent.cfg -> $(SEC_BIN) -i ; +# $(TWLKEY)/authentication.key -> $(SEC_BIN) ; +# $(TWDB)/tasks.dat -> $(SEC_CONFIG) ; +# $(TWDB)/schedule.dat -> $(SEC_CONFIG) ; +# +# # Uncomment if you have agent logging enabled. +# #/var/log/tripwire/agent.log -> $(SEC_LOG) ; +#} + + + +# Commonly accessed directories that should remain static with regards to owner and group +( + rulename = "Invariant Directories", + severity = $(SIG_MED) +) +{ + / -> $(SEC_INVARIANT) (recurse = 0) ; + /home -> $(SEC_INVARIANT) (recurse = 0) ; + /etc -> $(SEC_INVARIANT) (recurse = 0) ; +} + ################################################ + # ## +################################################ # +# # # +# File System and Disk Administration Programs # # +# ## +################################################ + +( + rulename = "File System and Disk Administraton Programs", + severity = $(SIG_HI) +) +{ + /sbin/accton -> $(SEC_CRIT) ; + /sbin/badblocks -> $(SEC_CRIT) ; + /sbin/busybox -> $(SEC_CRIT) ; + /sbin/busybox.anaconda -> $(SEC_CRIT) ; + /sbin/convertquota -> $(SEC_CRIT) ; + /sbin/dosfsck -> $(SEC_CRIT) ; + /sbin/debugfs -> $(SEC_CRIT) ; + /sbin/debugreiserfs -> $(SEC_CRIT) ; + /sbin/dumpe2fs -> $(SEC_CRIT) ; + /sbin/dump -> $(SEC_CRIT) ; + /sbin/dump.static -> $(SEC_CRIT) ; + # /sbin/e2fsadm -> $(SEC_CRIT) ; tune2fs? + /sbin/e2fsck -> $(SEC_CRIT) ; + /sbin/e2label -> $(SEC_CRIT) ; + /sbin/fdisk -> $(SEC_CRIT) ; + /sbin/fsck -> $(SEC_CRIT) ; + /sbin/fsck.ext2 -> $(SEC_CRIT) ; + /sbin/fsck.ext3 -> $(SEC_CRIT) ; + /sbin/fsck.minix -> $(SEC_CRIT) ; + /sbin/fsck.msdos -> $(SEC_CRIT) ; + /sbin/fsck.vfat -> $(SEC_CRIT) ; + /sbin/ftl_check -> $(SEC_CRIT) ; + /sbin/ftl_format -> $(SEC_CRIT) ; + /sbin/hdparm -> $(SEC_CRIT) ; + #/sbin/lvchange -> $(SEC_CRIT) ; + #/sbin/lvcreate -> $(SEC_CRIT) ; + #/sbin/lvdisplay -> $(SEC_CRIT) ; + #/sbin/lvextend -> $(SEC_CRIT) ; + #/sbin/lvmchange -> $(SEC_CRIT) ; + #/sbin/lvmcreate_initrd -> $(SEC_CRIT) ; + #/sbin/lvmdiskscan -> $(SEC_CRIT) ; + #/sbin/lvmsadc -> $(SEC_CRIT) ; + #/sbin/lvmsar -> $(SEC_CRIT) ; + #/sbin/lvreduce -> $(SEC_CRIT) ; + #/sbin/lvremove -> $(SEC_CRIT) ; + #/sbin/lvrename -> $(SEC_CRIT) ; + #/sbin/lvscan -> $(SEC_CRIT) ; + /sbin/mkbootdisk -> $(SEC_CRIT) ; + /sbin/mkdosfs -> $(SEC_CRIT) ; + /sbin/mke2fs -> $(SEC_CRIT) ; + /sbin/mkfs -> $(SEC_CRIT) ; + /sbin/mkfs.bfs -> $(SEC_CRIT) ; + /sbin/mkfs.ext2 -> $(SEC_CRIT) ; + /sbin/mkfs.minix -> $(SEC_CRIT) ; + /sbin/mkfs.msdos -> $(SEC_CRIT) ; + /sbin/mkfs.vfat -> $(SEC_CRIT) ; + /sbin/mkinitrd -> $(SEC_CRIT) ; + #/sbin/mkpv -> $(SEC_CRIT) ; + /sbin/mkraid -> $(SEC_CRIT) ; + /sbin/mkreiserfs -> $(SEC_CRIT) ; + /sbin/mkswap -> $(SEC_CRIT) ; + #/sbin/mtx -> $(SEC_CRIT) ; + /sbin/pam_console_apply -> $(SEC_CRIT) ; + /sbin/parted -> $(SEC_CRIT) ; + /sbin/pcinitrd -> $(SEC_CRIT) ; + #/sbin/pvchange -> $(SEC_CRIT) ; + #/sbin/pvcreate -> $(SEC_CRIT) ; + #/sbin/pvdata -> $(SEC_CRIT) ; + #/sbin/pvdisplay -> $(SEC_CRIT) ; + #/sbin/pvmove -> $(SEC_CRIT) ; + #/sbin/pvscan -> $(SEC_CRIT) ; + /sbin/quotacheck -> $(SEC_CRIT) ; + /sbin/quotaon -> $(SEC_CRIT) ; + /sbin/raidstart -> $(SEC_CRIT) ; + /sbin/reiserfsck -> $(SEC_CRIT) ; + /sbin/resize2fs -> $(SEC_CRIT) ; + /sbin/resize_reiserfs -> $(SEC_CRIT) ; + /sbin/restore -> $(SEC_CRIT) ; + /sbin/restore.static -> $(SEC_CRIT) ; + /sbin/scsi_info -> $(SEC_CRIT) ; + /sbin/sfdisk -> $(SEC_CRIT) ; + /sbin/stinit -> $(SEC_CRIT) ; + #/sbin/tapeinfo -> $(SEC_CRIT) ; + /sbin/tune2fs -> $(SEC_CRIT) ; + /sbin/unpack -> $(SEC_CRIT) ; + /sbin/update -> $(SEC_CRIT) ; + #/sbin/vgcfgbackup -> $(SEC_CRIT) ; + #/sbin/vgcfgrestore -> $(SEC_CRIT) ; + #/sbin/vgchange -> $(SEC_CRIT) ; + #/sbin/vgck -> $(SEC_CRIT) ; + #/sbin/vgcreate -> $(SEC_CRIT) ; + #/sbin/vgdisplay -> $(SEC_CRIT) ; + #/sbin/vgexport -> $(SEC_CRIT) ; + #/sbin/vgextend -> $(SEC_CRIT) ; + #/sbin/vgimport -> $(SEC_CRIT) ; + #/sbin/vgmerge -> $(SEC_CRIT) ; + #/sbin/vgmknodes -> $(SEC_CRIT) ; + #/sbin/vgreduce -> $(SEC_CRIT) ; + #/sbin/vgremove -> $(SEC_CRIT) ; + #/sbin/vgrename -> $(SEC_CRIT) ; + #/sbin/vgscan -> $(SEC_CRIT) ; + #/sbin/vgsplit -> $(SEC_CRIT) ; + /bin/chgrp -> $(SEC_CRIT) ; + /bin/chmod -> $(SEC_CRIT) ; + /bin/chown -> $(SEC_CRIT) ; + /bin/cp -> $(SEC_CRIT) ; + /bin/cpio -> $(SEC_CRIT) ; + /bin/mount -> $(SEC_CRIT) ; + /bin/umount -> $(SEC_CRIT) ; + /bin/mkdir -> $(SEC_CRIT) ; + /bin/mknod -> $(SEC_CRIT) ; + /bin/mktemp -> $(SEC_CRIT) ; + /bin/rm -> $(SEC_CRIT) ; + /bin/rmdir -> $(SEC_CRIT) ; + /bin/touch -> $(SEC_CRIT) ; +} + + ################################## + # ## +################################## # +# # # +# Kernel Administration Programs # # +# ## +################################## + +( + rulename = "Kernel Administration Programs", + severity = $(SIG_HI) +) +{ + /sbin/adjtimex -> $(SEC_CRIT) ; + /sbin/ctrlaltdel -> $(SEC_CRIT) ; + /sbin/depmod -> $(SEC_CRIT) ; + /sbin/insmod -> $(SEC_CRIT) ; + /sbin/insmod.static -> $(SEC_CRIT) ; + /sbin/insmod_ksymoops_clean -> $(SEC_CRIT) ; + /sbin/klogd -> $(SEC_CRIT) ; + /sbin/ldconfig -> $(SEC_CRIT) ; + /sbin/minilogd -> $(SEC_CRIT) ; + /sbin/modinfo -> $(SEC_CRIT) ; + #/sbin/nuactlun -> $(SEC_CRIT) ; + #/sbin/nuscsitcpd -> $(SEC_CRIT) ; + /sbin/pivot_root -> $(SEC_CRIT) ; + /sbin/sndconfig -> $(SEC_CRIT) ; + /sbin/sysctl -> $(SEC_CRIT) ; +} + + ####################### + # ## +####################### # +# # # +# Networking Programs # # +# ## +####################### + +( + rulename = "Networking Programs", + severity = $(SIG_HI) +) +{ + /etc/sysconfig/network-scripts/ifdown -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifdown-cipcb -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifdown-ippp -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifdown-ipv6 -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifdown-isdn -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifdown-post -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifdown-ppp -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifdown-sit -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifdown-sl -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-aliases -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-cipcb -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-ippp -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-ipv6 -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-isdn -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-plip -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-plusb -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-post -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-ppp -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-routes -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-sit -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-sl -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/ifup-wireless -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/network-functions -> $(SEC_CRIT) ; + /etc/sysconfig/network-scripts/network-functions-ipv6 -> $(SEC_CRIT) ; + /bin/ping -> $(SEC_CRIT) ; + /sbin/agetty -> $(SEC_CRIT) ; + /sbin/arp -> $(SEC_CRIT) ; + /sbin/arping -> $(SEC_CRIT) ; + /sbin/dhcpcd -> $(SEC_CRIT) ; + /sbin/ether-wake -> $(SEC_CRIT) ; + #/sbin/getty -> $(SEC_CRIT) ; + /sbin/ifcfg -> $(SEC_CRIT) ; + /sbin/ifconfig -> $(SEC_CRIT) ; + /sbin/ifdown -> $(SEC_CRIT) ; + /sbin/ifenslave -> $(SEC_CRIT) ; + /sbin/ifport -> $(SEC_CRIT) ; + /sbin/ifup -> $(SEC_CRIT) ; + /sbin/ifuser -> $(SEC_CRIT) ; + /sbin/ip -> $(SEC_CRIT) ; + /sbin/ip6tables -> $(SEC_CRIT) ; + /sbin/ipchains -> $(SEC_CRIT) ; + /sbin/ipchains-restore -> $(SEC_CRIT) ; + /sbin/ipchains-save -> $(SEC_CRIT) ; + /sbin/ipfwadm -> $(SEC_CRIT) ; + /sbin/ipmaddr -> $(SEC_CRIT) ; + /sbin/iptables -> $(SEC_CRIT) ; + /sbin/iptables-restore -> $(SEC_CRIT) ; + /sbin/iptables-save -> $(SEC_CRIT) ; + /sbin/iptunnel -> $(SEC_CRIT) ; + #/sbin/ipvsadm -> $(SEC_CRIT) ; + #/sbin/ipvsadm-restore -> $(SEC_CRIT) ; + #/sbin/ipvsadm-save -> $(SEC_CRIT) ; + /sbin/ipx_configure -> $(SEC_CRIT) ; + /sbin/ipx_interface -> $(SEC_CRIT) ; + /sbin/ipx_internal_net -> $(SEC_CRIT) ; + /sbin/iwconfig -> $(SEC_CRIT) ; + /sbin/iwgetid -> $(SEC_CRIT) ; + /sbin/iwlist -> $(SEC_CRIT) ; + /sbin/iwpriv -> $(SEC_CRIT) ; + /sbin/iwspy -> $(SEC_CRIT) ; + /sbin/mgetty -> $(SEC_CRIT) ; + /sbin/mingetty -> $(SEC_CRIT) ; + /sbin/nameif -> $(SEC_CRIT) ; + /sbin/netreport -> $(SEC_CRIT) ; + /sbin/plipconfig -> $(SEC_CRIT) ; + /sbin/portmap -> $(SEC_CRIT) ; + /sbin/ppp-watch -> $(SEC_CRIT) ; + #/sbin/rarp -> $(SEC_CRIT) ; + /sbin/route -> $(SEC_CRIT) ; + /sbin/slattach -> $(SEC_CRIT) ; + /sbin/tc -> $(SEC_CRIT) ; + #/sbin/uugetty -> $(SEC_CRIT) ; + /sbin/vgetty -> $(SEC_CRIT) ; + /sbin/ypbind -> $(SEC_CRIT) ; +} + + ################################## + # ## +################################## # +# # # +# System Administration Programs # # +# ## +################################## + +( + rulename = "System Administration Programs", + severity = $(SIG_HI) +) +{ + /sbin/chkconfig -> $(SEC_CRIT) ; + /sbin/fuser -> $(SEC_CRIT) ; + /sbin/halt -> $(SEC_CRIT) ; + /sbin/init -> $(SEC_CRIT) ; + /sbin/initlog -> $(SEC_CRIT) ; + /sbin/install-info -> $(SEC_CRIT) ; + /sbin/killall5 -> $(SEC_CRIT) ; + #/sbin/linuxconf -> $(SEC_CRIT) ; + #/sbin/linuxconf-auth -> $(SEC_CRIT) ; + /sbin/pam_tally -> $(SEC_CRIT) ; + /sbin/pwdb_chkpwd -> $(SEC_CRIT) ; + #/sbin/remadmin -> $(SEC_CRIT) ; + /sbin/rescuept -> $(SEC_CRIT) ; + /sbin/rmt -> $(SEC_CRIT) ; + /sbin/rpc.lockd -> $(SEC_CRIT) ; + /sbin/rpc.statd -> $(SEC_CRIT) ; + /sbin/rpcdebug -> $(SEC_CRIT) ; + /sbin/service -> $(SEC_CRIT) ; + /sbin/setsysfont -> $(SEC_CRIT) ; + /sbin/shutdown -> $(SEC_CRIT) ; + /sbin/sulogin -> $(SEC_CRIT) ; + /sbin/swapon -> $(SEC_CRIT) ; + /sbin/syslogd -> $(SEC_CRIT) ; + /sbin/unix_chkpwd -> $(SEC_CRIT) ; + /bin/pwd -> $(SEC_CRIT) ; + /bin/uname -> $(SEC_CRIT) ; +} + + ######################################## + # ## +######################################## # +# # # +# Hardware and Device Control Programs # # +# ## +######################################## +( + rulename = "Hardware and Device Control Programs", + severity = $(SIG_HI) +) +{ + /bin/setserial -> $(SEC_CRIT) ; + /bin/sfxload -> $(SEC_CRIT) ; + /sbin/blockdev -> $(SEC_CRIT) ; + /sbin/cardctl -> $(SEC_CRIT) ; + /sbin/cardmgr -> $(SEC_CRIT) ; + /sbin/cbq -> $(SEC_CRIT) ; + /sbin/dump_cis -> $(SEC_CRIT) ; + /sbin/elvtune -> $(SEC_CRIT) ; + /sbin/hotplug -> $(SEC_CRIT) ; + /sbin/hwclock -> $(SEC_CRIT) ; + /sbin/ide_info -> $(SEC_CRIT) ; + #/sbin/isapnp -> $(SEC_CRIT) ; + /sbin/kbdrate -> $(SEC_CRIT) ; + /sbin/losetup -> $(SEC_CRIT) ; + /sbin/lspci -> $(SEC_CRIT) ; + /sbin/lspnp -> $(SEC_CRIT) ; + /sbin/mii-tool -> $(SEC_CRIT) ; + /sbin/pack_cis -> $(SEC_CRIT) ; + #/sbin/pnpdump -> $(SEC_CRIT) ; + /sbin/probe -> $(SEC_CRIT) ; + /sbin/pump -> $(SEC_CRIT) ; + /sbin/setpci -> $(SEC_CRIT) ; + /sbin/shapecfg -> $(SEC_CRIT) ; +} + + ############################### + # ## +############################### # +# # # +# System Information Programs # # +# ## +############################### +( + rulename = "System Information Programs", + severity = $(SIG_HI) +) +{ + /sbin/consoletype -> $(SEC_CRIT) ; + /sbin/kernelversion -> $(SEC_CRIT) ; + /sbin/runlevel -> $(SEC_CRIT) ; +} + + #################################### + # ## +#################################### # +# # # +# Application Information Programs # # +# ## +#################################### + +( + rulename = "Application Information Programs", + severity = $(SIG_HI) +) +{ + /sbin/genksyms -> $(SEC_CRIT) ; + #/sbin/genksyms.old -> $(SEC_CRIT) ; + /sbin/rtmon -> $(SEC_CRIT) ; +} + + ########################## + # ## +########################## # +# # # +# Shell Related Programs # # +# ## +########################## +( + rulename = "Shell Related Programs", + severity = $(SIG_HI) +) +{ + /sbin/getkey -> $(SEC_CRIT) ; + /sbin/nash -> $(SEC_CRIT) ; + /sbin/sash -> $(SEC_CRIT) ; +} + + + ################ + # ## +################ # +# # # +# OS Utilities # # +# ## +################ +( + rulename = "Operating System Utilities", + severity = $(SIG_HI) +) +{ + /bin/arch -> $(SEC_CRIT) ; + /bin/ash -> $(SEC_CRIT) ; + /bin/ash.static -> $(SEC_CRIT) ; + /bin/aumix-minimal -> $(SEC_CRIT) ; + /bin/basename -> $(SEC_CRIT) ; + /bin/cat -> $(SEC_CRIT) ; + /bin/consolechars -> $(SEC_CRIT) ; + /bin/cut -> $(SEC_CRIT) ; + /bin/date -> $(SEC_CRIT) ; + /bin/dd -> $(SEC_CRIT) ; + /bin/df -> $(SEC_CRIT) ; + /bin/dmesg -> $(SEC_CRIT) ; + /bin/doexec -> $(SEC_CRIT) ; + /bin/echo -> $(SEC_CRIT) ; + /bin/ed -> $(SEC_CRIT) ; + /bin/egrep -> $(SEC_CRIT) ; + /bin/false -> $(SEC_CRIT) ; + /bin/fgrep -> $(SEC_CRIT) ; + /bin/gawk -> $(SEC_CRIT) ; + /bin/gawk-3.1.0 -> $(SEC_CRIT) ; + /bin/gettext -> $(SEC_CRIT) ; + /bin/grep -> $(SEC_CRIT) ; + /bin/gunzip -> $(SEC_CRIT) ; + /bin/gzip -> $(SEC_CRIT) ; + /bin/hostname -> $(SEC_CRIT) ; + /bin/igawk -> $(SEC_CRIT) ; + /bin/ipcalc -> $(SEC_CRIT) ; + /bin/kill -> $(SEC_CRIT) ; + /bin/ln -> $(SEC_CRIT) ; + /bin/loadkeys -> $(SEC_CRIT) ; + /bin/login -> $(SEC_CRIT) ; + /bin/ls -> $(SEC_CRIT) ; + /bin/mail -> $(SEC_CRIT) ; + /bin/more -> $(SEC_CRIT) ; + /bin/mt -> $(SEC_CRIT) ; + /bin/mv -> $(SEC_CRIT) ; + /bin/netstat -> $(SEC_CRIT) ; + /bin/nice -> $(SEC_CRIT) ; + /bin/pgawk -> $(SEC_CRIT) ; + /bin/ps -> $(SEC_CRIT) ; + /bin/rpm -> $(SEC_CRIT) ; + /bin/sed -> $(SEC_CRIT) ; + /bin/sleep -> $(SEC_CRIT) ; + /bin/sort -> $(SEC_CRIT) ; + /bin/stty -> $(SEC_CRIT) ; + /bin/su -> $(SEC_CRIT) ; + /bin/sync -> $(SEC_CRIT) ; + /bin/tar -> $(SEC_CRIT) ; + /bin/true -> $(SEC_CRIT) ; + /bin/usleep -> $(SEC_CRIT) ; + /bin/vi -> $(SEC_CRIT) ; + /bin/zcat -> $(SEC_CRIT) ; + /bin/zsh -> $(SEC_CRIT) ; + #/bin/zsh-4.0.2 -> $(SEC_CRIT) ; + /sbin/sln -> $(SEC_CRIT) ; + /usr/bin/vimtutor -> $(SEC_CRIT) ; +} + + ############################## + # ## +############################## # +# # # +# Critical Utility Sym-Links # # +# ## +############################## +( + rulename = "Critical Utility Sym-Links", + severity = $(SIG_HI) +) +{ + #/sbin/askrunlevel -> $(SEC_CRIT) ; + /sbin/clock -> $(SEC_CRIT) ; + #/sbin/fixperm -> $(SEC_CRIT) ; + /sbin/fsck.reiserfs -> $(SEC_CRIT) ; + #/sbin/fsconf -> $(SEC_CRIT) ; + /sbin/ipfwadm-wrapper -> $(SEC_CRIT) ; + /sbin/kallsyms -> $(SEC_CRIT) ; + /sbin/ksyms -> $(SEC_CRIT) ; + /sbin/lsmod -> $(SEC_CRIT) ; + #/sbin/mailconf -> $(SEC_CRIT) ; + /sbin/mkfs.reiserfs -> $(SEC_CRIT) ; + #/sbin/modemconf -> $(SEC_CRIT) ; + /sbin/modprobe -> $(SEC_CRIT) ; + /sbin/mount.ncp -> $(SEC_CRIT) ; + /sbin/mount.ncpfs -> $(SEC_CRIT) ; + /sbin/mount.smb -> $(SEC_CRIT) ; + /sbin/mount.smbfs -> $(SEC_CRIT) ; + #/sbin/netconf -> $(SEC_CRIT) ; + /sbin/pidof -> $(SEC_CRIT) ; + /sbin/poweroff -> $(SEC_CRIT) ; + /sbin/quotaoff -> $(SEC_CRIT) ; + /sbin/raid0run -> $(SEC_CRIT) ; + /sbin/raidhotadd -> $(SEC_CRIT) ; + /sbin/raidhotgenerateerror -> $(SEC_CRIT) ; + /sbin/raidhotremove -> $(SEC_CRIT) ; + /sbin/raidstop -> $(SEC_CRIT) ; + /sbin/rdump -> $(SEC_CRIT) ; + /sbin/rdump.static -> $(SEC_CRIT) ; + /sbin/reboot -> $(SEC_CRIT) ; + /sbin/rmmod -> $(SEC_CRIT) ; + /sbin/rrestore -> $(SEC_CRIT) ; + /sbin/rrestore.static -> $(SEC_CRIT) ; + /sbin/swapoff -> $(SEC_CRIT) ; + /sbin/telinit -> $(SEC_CRIT) ; + #/sbin/userconf -> $(SEC_CRIT) ; + #/sbin/uucpconf -> $(SEC_CRIT) ; + #/sbin/vregistry -> $(SEC_CRIT) ; + /bin/awk -> $(SEC_CRIT) ; + /bin/bash2 -> $(SEC_CRIT) ; + /bin/bsh -> $(SEC_CRIT) ; + /bin/csh -> $(SEC_CRIT) ; + /bin/dnsdomainname -> $(SEC_CRIT) ; + /bin/domainname -> $(SEC_CRIT) ; + /bin/ex -> $(SEC_CRIT) ; + /bin/gtar -> $(SEC_CRIT) ; + /bin/nisdomainname -> $(SEC_CRIT) ; + /bin/red -> $(SEC_CRIT) ; + /bin/rvi -> $(SEC_CRIT) ; + /bin/rview -> $(SEC_CRIT) ; + /bin/view -> $(SEC_CRIT) ; + /bin/ypdomainname -> $(SEC_CRIT) ; +} + + + ######################### + # ## +######################### # +# # # +# Temporary directories # # +# ## +######################### +( + rulename = "Temporary directories", + recurse = false, + severity = $(SIG_LOW) +) +{ + /usr/tmp -> $(SEC_INVARIANT) ; + /var/tmp -> $(SEC_INVARIANT) ; + /tmp -> $(SEC_INVARIANT) ; +} + + ############### + # ## +############### # +# # # +# Local files # # +# ## +############### +( + rulename = "User binaries", + severity = $(SIG_MED) +) +{ + /sbin -> $(SEC_BIN) (recurse = 1) ; + /usr/bin -> $(SEC_BIN) (recurse = 1) ; + /usr/sbin -> $(SEC_BIN) (recurse = 1) ; + /usr/local/bin -> $(SEC_BIN) (recurse = 1) ; +} + +( + rulename = "Shell Binaries", + severity = $(SIG_HI) +) +{ + /bin/bash -> $(SEC_BIN) ; + /bin/ksh -> $(SEC_BIN) ; + # /bin/psh -> $(SEC_BIN) ; # No longer used? + # /bin/Rsh -> $(SEC_BIN) ; # No longer used? + /bin/sh -> $(SEC_BIN) ; + # /bin/shell -> $(SEC_SUID) ; # No longer used? + # /bin/tsh -> $(SEC_BIN) ; # No longer used? + /bin/tcsh -> $(SEC_BIN) ; + /sbin/nologin -> $(SEC_BIN) ; +} + +( + rulename = "Security Control", + severity = $(SIG_HI) +) +{ + /etc/group -> $(SEC_CRIT) ; + /etc/security -> $(SEC_CRIT) ; + #/var/spool/cron/crontabs -> $(SEC_CRIT) ; # Uncomment when this file exists +} + +#( +# rulename = "Boot Scripts", +# severity = $(SIG_HI) +#) +#{ +# /etc/rc -> $(SEC_CONFIG) ; +# /etc/rc.bsdnet -> $(SEC_CONFIG) ; +# /etc/rc.dt -> $(SEC_CONFIG) ; +# /etc/rc.net -> $(SEC_CONFIG) ; +# /etc/rc.net.serial -> $(SEC_CONFIG) ; +# /etc/rc.nfs -> $(SEC_CONFIG) ; +# /etc/rc.powerfail -> $(SEC_CONFIG) ; +# /etc/rc.tcpip -> $(SEC_CONFIG) ; +# /etc/trcfmt.Z -> $(SEC_CONFIG) ; +#} + +( + rulename = "Login Scripts", + severity = $(SIG_HI) +) +{ + /etc/bashrc -> $(SEC_CONFIG) ; + /etc/csh.cshrc -> $(SEC_CONFIG) ; + /etc/csh.login -> $(SEC_CONFIG) ; + /etc/inputrc -> $(SEC_CONFIG) ; + # /etc/tsh_profile -> $(SEC_CONFIG) ; #Uncomment when this file exists + /etc/profile -> $(SEC_CONFIG) ; +} + +# Libraries +( + rulename = "Libraries", + severity = $(SIG_MED) +) +{ + /usr/lib -> $(SEC_BIN) ; + /usr/local/lib -> $(SEC_BIN) ; +} + + + ###################################################### + # ## +###################################################### # +# # # +# Critical System Boot Files # # +# These files are critical to a correct system boot. # # +# ## +###################################################### + +( + rulename = "Critical system boot files", + severity = $(SIG_HI) +) +{ + /boot -> $(SEC_CRIT) ; + #/sbin/devfsd -> $(SEC_CRIT) ; + /sbin/grub -> $(SEC_CRIT) ; + /sbin/grub-install -> $(SEC_CRIT) ; + /sbin/grub-md5-crypt -> $(SEC_CRIT) ; + /sbin/installkernel -> $(SEC_CRIT) ; + /sbin/lilo -> $(SEC_CRIT) ; + /sbin/mkkerneldoth -> $(SEC_CRIT) ; + !/boot/System.map ; + !/boot/module-info ; + /usr/share/grub/i386-redhat/e2fs_stage1_5 -> $(SEC_CRIT) ; + /usr/share/grub/i386-redhat/fat_stage1_5 -> $(SEC_CRIT) ; + /usr/share/grub/i386-redhat/ffs_stage1_5 -> $(SEC_CRIT) ; + /usr/share/grub/i386-redhat/minix_stage1_5 -> $(SEC_CRIT) ; + /usr/share/grub/i386-redhat/reiserfs_stage1_5 -> $(SEC_CRIT) ; + /usr/share/grub/i386-redhat/stage1 -> $(SEC_CRIT) ; + /usr/share/grub/i386-redhat/stage2 -> $(SEC_CRIT) ; + /usr/share/grub/i386-redhat/vstafs_stage1_5 -> $(SEC_CRIT) ; + # other boot files may exist. Look for: + #/ufsboot -> $(SEC_CRIT) ; +} + ################################################## + ################################################### + # These files change every time the system boots ## + ################################################## +( + rulename = "System boot changes", + severity = $(SIG_HI) +) +{ + !/var/run/ftp.pids-all ; # Comes and goes on reboot. + !/root/.enlightenment ; + /dev/log -> $(SEC_CONFIG) ; + /dev/cua0 -> $(SEC_CONFIG) ; + # /dev/printer -> $(SEC_CONFIG) ; # Uncomment if you have a printer device + /dev/console -> $(SEC_CONFIG) -u ; # User ID may change on console login/logout. + /dev/tty1 -> $(SEC_CONFIG) ; # tty devices + /dev/tty2 -> $(SEC_CONFIG) ; # tty devices + /dev/tty3 -> $(SEC_CONFIG) ; # are extremely + /dev/tty4 -> $(SEC_CONFIG) ; # variable + /dev/tty5 -> $(SEC_CONFIG) ; + /dev/tty6 -> $(SEC_CONFIG) ; + /dev/urandom -> $(SEC_CONFIG) ; + /dev/initctl -> $(SEC_CONFIG) ; + /var/lock/subsys -> $(SEC_CONFIG) ; + #/var/lock/subsys/amd -> $(SEC_CONFIG) ; + /var/lock/subsys/anacron -> $(SEC_CONFIG) ; + /var/lock/subsys/apmd -> $(SEC_CONFIG) ; + #/var/lock/subsys/arpwatch -> $(SEC_CONFIG) ; + /var/lock/subsys/atd -> $(SEC_CONFIG) ; + /var/lock/subsys/autofs -> $(SEC_CONFIG) ; + #/var/lock/subsys/bcm5820 -> $(SEC_CONFIG) ; + #/var/lock/subsys/bgpd -> $(SEC_CONFIG) ; + #/var/lock/subsys/bootparamd -> $(SEC_CONFIG) ; + #/var/lock/subsys/canna -> $(SEC_CONFIG) ; + /var/lock/subsys/crond -> $(SEC_CONFIG) ; + #/var/lock/subsys/cWnn -> $(SEC_CONFIG) ; + #/var/lock/subsys/dhcpd -> $(SEC_CONFIG) ; + #/var/lock/subsys/firewall -> $(SEC_CONFIG) ; + #/var/lock/subsys/freeWnn -> $(SEC_CONFIG) ; + #/var/lock/subsys/gated -> $(SEC_CONFIG) ; + /var/lock/subsys/gpm -> $(SEC_CONFIG) ; + #/var/lock/subsys/httpd -> $(SEC_CONFIG) ; + #/var/lock/subsys/identd -> $(SEC_CONFIG) ; + #/var/lock/subsys/innd -> $(SEC_CONFIG) ; + /var/lock/subsys/ipchains -> $(SEC_CONFIG) ; + #/var/lock/subsys/iptables -> $(SEC_CONFIG) ; + #/var/lock/subsys/ipvsadm -> $(SEC_CONFIG) ; + #/var/lock/subsys/irda -> $(SEC_CONFIG) ; + #/var/lock/subsys/iscsi -> $(SEC_CONFIG) ; + #/var/lock/subsys/isdn -> $(SEC_CONFIG) ; + #/var/lock/subsys/junkbuster -> $(SEC_CONFIG) ; + #/var/lock/subsys/kadmin -> $(SEC_CONFIG) ; + /var/lock/subsys/keytable -> $(SEC_CONFIG) ; + #/var/lock/subsys/kprop -> $(SEC_CONFIG) ; + #/var/lock/subsys/krb524 -> $(SEC_CONFIG) ; + #/var/lock/subsys/krb5kdc -> $(SEC_CONFIG) ; + /var/lock/subsys/kudzu -> $(SEC_CONFIG) ; + #/var/lock/subsys/kWnn -> $(SEC_CONFIG) ; + #/var/lock/subsys/ldap -> $(SEC_CONFIG) ; + #/var/lock/subsys/linuxconf -> $(SEC_CONFIG) ; + #/var/lock/subsys/lpd -> $(SEC_CONFIG) ; + #/var/lock/subsys/mars_nwe -> $(SEC_CONFIG) ; + #/var/lock/subsys/mcserv -> $(SEC_CONFIG) ; + #/var/lock/subsys/mysqld -> $(SEC_CONFIG) ; + #/var/lock/subsys/named -> $(SEC_CONFIG) ; + /var/lock/subsys/netfs -> $(SEC_CONFIG) ; + /var/lock/subsys/network -> $(SEC_CONFIG) ; + #/var/lock/subsys/nfs -> $(SEC_CONFIG) ; + /var/lock/subsys/nfslock -> $(SEC_CONFIG) ; + #/var/lock/subsys/nscd -> $(SEC_CONFIG) ; + #/var/lock/subsys/ntpd -> $(SEC_CONFIG) ; + #/var/lock/subsys/ospf6d -> $(SEC_CONFIG) ; + #/var/lock/subsys/ospfd -> $(SEC_CONFIG) ; + /var/lock/subsys/pcmcia -> $(SEC_CONFIG) ; + /var/lock/subsys/portmap -> $(SEC_CONFIG) ; + #/var/lock/subsys/postgresql -> $(SEC_CONFIG) ; + #/var/lock/subsys/pxe -> $(SEC_CONFIG) ; + #/var/lock/subsys/radvd -> $(SEC_CONFIG) ; + /var/lock/subsys/random -> $(SEC_CONFIG) ; + #/var/lock/subsys/rarpd -> $(SEC_CONFIG) ; + /var/lock/subsys/reconfig -> $(SEC_CONFIG) ; + /var/lock/subsys/rhnsd -> $(SEC_CONFIG) ; + #/var/lock/subsys/ripd -> $(SEC_CONFIG) ; + #/var/lock/subsys/ripngd -> $(SEC_CONFIG) ; + #/var/lock/subsys/routed -> $(SEC_CONFIG) ; + #/var/lock/subsys/rstatd -> $(SEC_CONFIG) ; + #/var/lock/subsys/rusersd -> $(SEC_CONFIG) ; + #/var/lock/subsys/rwalld -> $(SEC_CONFIG) ; + #/var/lock/subsys/rwhod -> $(SEC_CONFIG) ; + /var/lock/subsys/sendmail -> $(SEC_CONFIG) ; + #/var/lock/subsys/smb -> $(SEC_CONFIG) ; + #/var/lock/subsys/snmpd -> $(SEC_CONFIG) ; + #/var/lock/subsys/squid -> $(SEC_CONFIG) ; + /var/lock/subsys/sshd -> $(SEC_CONFIG) ; + /var/lock/subsys/syslog -> $(SEC_CONFIG) ; + #/var/lock/subsys/tux -> $(SEC_CONFIG) ; + #/var/lock/subsys/tWnn -> $(SEC_CONFIG) ; + #/var/lock/subsys/ups -> $(SEC_CONFIG) ; + #/var/lock/subsys/vncserver -> $(SEC_CONFIG) ; + #/var/lock/subsys/wine -> $(SEC_CONFIG) ; + /var/lock/subsys/xfs -> $(SEC_CONFIG) ; + /var/lock/subsys/xinetd -> $(SEC_CONFIG) ; + /var/lock/subsys/ypbind -> $(SEC_CONFIG) ; + #/var/lock/subsys/yppasswdd -> $(SEC_CONFIG) ; + #/var/lock/subsys/ypserv -> $(SEC_CONFIG) ; + #/var/lock/subsys/ypxfrd -> $(SEC_CONFIG) ; + #/var/lock/subsys/zebra -> $(SEC_CONFIG) ; + /var/run -> $(SEC_CONFIG) ; + /var/log -> $(SEC_CONFIG) ; + /etc/ioctl.save -> $(SEC_CONFIG) ; + /etc/issue.net -> $(SEC_CONFIG) -i ; # Inode number changes + /etc/issue -> $(SEC_CONFIG) ; + /etc/mtab -> $(SEC_CONFIG) -i ; # Inode number changes on any mount/unmount + /lib/modules -> $(SEC_CONFIG) ; + /etc/.pwd.lock -> $(SEC_CONFIG) ; + # /lib/modules/preferred -> $(SEC_CONFIG) ; #Uncomment when this file exists +} + +# These files change the behavior of the root account +( + rulename = "Root config files", + severity = 100 +) +{ + /root -> $(SEC_CRIT) ; # Catch all additions to /root + #/root/.Xresources -> $(SEC_CONFIG) ; + /root/.bashrc -> $(SEC_CONFIG) ; + /root/.bash_profile -> $(SEC_CONFIG) ; + /root/.bash_logout -> $(SEC_CONFIG) ; + /root/.cshrc -> $(SEC_CONFIG) ; + /root/.tcshrc -> $(SEC_CONFIG) ; + /root/Mail -> $(SEC_CONFIG) ; + #/root/mail -> $(SEC_CONFIG) ; + #/root/.amandahosts -> $(SEC_CONFIG) ; + #/root/.addressbook.lu -> $(SEC_CONFIG) ; + #/root/.addressbook -> $(SEC_CONFIG) ; + /root/.bash_history -> $(SEC_CONFIG) ; + /root/.elm -> $(SEC_CONFIG) ; + #/root/.esd_auth -> $(SEC_CONFIG) ; + /root/.gnome_private -> $(SEC_CONFIG) ; + /root/.gnome-desktop -> $(SEC_CONFIG) ; + /root/.gnome -> $(SEC_CONFIG) ; + /root/.ICEauthority -> $(SEC_CONFIG) ; + #/root/.mc -> $(SEC_CONFIG) ; + #/root/.pinerc -> $(SEC_CONFIG) ; + /root/.sawfish -> $(SEC_CONFIG) ; + /root/.Xauthority -> $(SEC_CONFIG) -i ; # Changes Inode number on login + #/root/.xauth -> $(SEC_CONFIG) ; + /root/.xsession-errors -> $(SEC_CONFIG) ; +} + + ################################ + # ## +################################ # +# # # +# Critical configuration files # # +# ## +################################ +( + rulename = "Critical configuration files", + severity = $(SIG_HI) +) +{ + #/etc/conf.linuxconf -> $(SEC_BIN) ; + /etc/crontab -> $(SEC_BIN) ; + /etc/cron.hourly -> $(SEC_BIN) ; + /etc/cron.daily -> $(SEC_BIN) ; + /etc/cron.weekly -> $(SEC_BIN) ; + /etc/cron.monthly -> $(SEC_BIN) ; + /etc/default -> $(SEC_BIN) ; + /etc/fstab -> $(SEC_BIN) ; + /etc/exports -> $(SEC_BIN) ; + /etc/group- -> $(SEC_BIN) ; # changes should be infrequent + /etc/host.conf -> $(SEC_BIN) ; + /etc/hosts.allow -> $(SEC_BIN) ; + /etc/hosts.deny -> $(SEC_BIN) ; + /etc/httpd/conf -> $(SEC_BIN) ; # changes should be infrequent + /etc/protocols -> $(SEC_BIN) ; + /etc/services -> $(SEC_BIN) ; + /etc/rc.d/init.d -> $(SEC_BIN) ; + /etc/rc.d -> $(SEC_BIN) ; + /etc/mail.rc -> $(SEC_BIN) ; + /etc/modules.conf -> $(SEC_BIN) ; + /etc/motd -> $(SEC_BIN) ; + /etc/named.conf -> $(SEC_BIN) ; + /etc/passwd -> $(SEC_CONFIG) ; + /etc/passwd- -> $(SEC_CONFIG) ; + /etc/profile.d -> $(SEC_BIN) ; + /var/lib/nfs/rmtab -> $(SEC_BIN) ; + /usr/sbin/fixrmtab -> $(SEC_BIN) ; + /etc/rpc -> $(SEC_BIN) ; + /etc/sysconfig -> $(SEC_BIN) ; + /etc/samba/smb.conf -> $(SEC_CONFIG) ; + #/etc/gettydefs -> $(SEC_BIN) ; + /etc/nsswitch.conf -> $(SEC_BIN) ; + /etc/yp.conf -> $(SEC_BIN) ; + /etc/hosts -> $(SEC_CONFIG) ; + /etc/xinetd.conf -> $(SEC_CONFIG) ; + /etc/inittab -> $(SEC_CONFIG) ; + /etc/resolv.conf -> $(SEC_CONFIG) ; + /etc/syslog.conf -> $(SEC_CONFIG) ; +} + + #################### + # ## +#################### # +# # # +# Critical devices # # +# ## +#################### +( + rulename = "Critical devices", + severity = $(SIG_HI), + recurse = false +) +{ + /dev/kmem -> $(Device) ; + /dev/mem -> $(Device) ; + /dev/null -> $(Device) ; + /dev/zero -> $(Device) ; + /proc/devices -> $(Device) ; + /proc/net -> $(Device) ; + /proc/sys -> $(Device) ; + /proc/cpuinfo -> $(Device) ; + /proc/modules -> $(Device) ; + /proc/mounts -> $(Device) ; + /proc/dma -> $(Device) ; + /proc/filesystems -> $(Device) ; + /proc/pci -> $(Device) ; + /proc/interrupts -> $(Device) ; + /proc/driver/rtc -> $(Device) ; + /proc/ioports -> $(Device) ; + #/proc/scsi -> $(Device) ; + /proc/kcore -> $(Device) ; + /proc/self -> $(Device) ; + /proc/kmsg -> $(Device) ; + /proc/stat -> $(Device) ; + /proc/ksyms -> $(Device) ; + /proc/loadavg -> $(Device) ; + /proc/uptime -> $(Device) ; + /proc/locks -> $(Device) ; + /proc/version -> $(Device) ; + /proc/mdstat -> $(Device) ; + /proc/meminfo -> $(Device) ; + /proc/cmdline -> $(Device) ; + /proc/misc -> $(Device) ; +} + +# Rest of critical system binaries +( + rulename = "OS executables and libraries", + severity = $(SIG_HI) +) +{ + /bin -> $(SEC_BIN) ; + /lib -> $(SEC_BIN) ; +} + +#============================================================================= +# +# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, +# Inc. in the United States and other countries. All rights reserved. +# +# Linux is a registered trademark of Linus Torvalds. +# +# UNIX is a registered trademark of The Open Group. +# +#============================================================================= +# +# Permission is granted to make and distribute verbatim copies of this document +# provided the copyright notice and this permission notice are preserved on all +# copies. +# +# Permission is granted to copy and distribute modified versions of this +# document under the conditions for verbatim copying, provided that the entire +# resulting derived work is distributed under the terms of a permission notice +# identical to this one. +# +# Permission is granted to copy and distribute translations of this document +# into another language, under the above conditions for modified versions, +# except that this permission notice may be stated in a translation approved by +# Tripwire, Inc. +# +# DCM +# +# $Id: twpol-GENERIC.txt,v 1.1 2003/06/08 02:00:06 pherman Exp $ +# diff --git a/policy/twpol-MidnightBSD.txt b/policy/twpol-MidnightBSD.txt new file mode 100644 index 0000000..b9c55a3 --- /dev/null +++ b/policy/twpol-MidnightBSD.txt @@ -0,0 +1,656 @@ +# +# Policy file for MidnightBSD +# (adapted from FreeBSD policy) +# +# $FreeBSD: ports/security/tripwire/files/twpol.txt,v 1.2 2002/03/04 16:55:21 cy Exp $ +# $Id: twpol-FreeBSD.txt,v 1.1 2003/06/08 02:00:06 pherman Exp $ + +# +# This is the example Tripwire Policy file. It is intended as a place to +# start creating your own custom Tripwire Policy file. Referring to it as +# well as the Tripwire Policy Guide should give you enough information to +# make a good custom Tripwire Policy file that better covers your +# configuration and security needs. A text version of this policy file is +# called twpol.txt. +# +# Note that this file is tuned to an install of FreeBSD using +# buildworld. If run unmodified, this file should create no errors on +# database creation, or violations on a subsiquent integrity check. +# However it is impossible for there to be one policy file for all machines, +# so this existing one errs on the side of security. Your FreeBSD +# configuration will most likey differ from the one our policy file was +# tuned to, and will therefore require some editing of the default +# Tripwire Policy file. +# +# The example policy file is best run with 'Loose Directory Checking' +# enabled. Set LOOSEDIRECTORYCHECKING=TRUE in the Tripwire Configuration +# file. +# +# Email support is not included and must be added to this file. +# Add the 'emailto=' to the rule directive section of each rule (add a comma +# after the 'severity=' line and add an 'emailto=' and include the email +# addresses you want the violation reports to go to). Addresses are +# semi-colon delimited. +# + + + +# +# Global Variable Definitions +# +# These are defined at install time by the installation script. You may +# Manually edit these if you are using this file directly and not from the +# installation script itself. +# + +@@section GLOBAL +TWROOT=; +TWBIN=; +TWPOL=; +TWDB=; +TWSKEY=; +TWLKEY=; +TWREPORT=; +HOSTNAME=; + +@@section FS +SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change +SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set +SEC_BIN = $(ReadOnly) ; # Binaries that should not change +SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often +SEC_TTY = $(Dynamic)-ugp ; # Tty files that change ownership at login +SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership +SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership +SIG_LOW = 33 ; # Non-critical files that are of minimal security impact +SIG_MED = 66 ; # Non-critical files that are of significant security impact +SIG_HI = 100 ; # Critical files that are significant points of vulnerability + + +# Tripwire Binaries +( + rulename = "Tripwire Binaries", + severity = $(SIG_HI) +) +{ + $(TWBIN)/siggen -> $(SEC_BIN) ; + $(TWBIN)/tripwire -> $(SEC_BIN) ; + $(TWBIN)/twadmin -> $(SEC_BIN) ; + $(TWBIN)/twprint -> $(SEC_BIN) ; +} + +# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases +( + rulename = "Tripwire Data Files", + severity = $(SIG_HI) +) +{ + # NOTE: We remove the inode attribute because when Tripwire creates a backup, + # it does so by renaming the old file and creating a new one (which will + # have a new inode number). Inode is left turned on for keys, which shouldn't + # ever change. + + # NOTE: The first integrity check triggers this rule and each integrity check + # afterward triggers this rule until a database update is run, since the + # database file does not exist before that point. + + $(TWDB) -> $(SEC_CONFIG) -i ; + $(TWPOL)/tw.pol -> $(SEC_BIN) -i ; + $(TWPOL)/tw.cfg -> $(SEC_BIN) -i ; + $(TWPOL)/twcfg.txt -> $(SEC_BIN) ; + $(TWPOL)/twpol.txt -> $(SEC_BIN) ; + $(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_BIN) ; + $(TWSKEY)/site.key -> $(SEC_BIN) ; + + #don't scan the individual reports + $(TWREPORT) -> $(SEC_CONFIG) (recurse=0) ; +} + + +# Tripwire HQ Connector Binaries +#( +# rulename = "Tripwire HQ Connector Binaries", +# severity = $(SIG_HI) +#) +#{ +# $(TWBIN)/hqagent -> $(SEC_BIN) ; +#} +# +# Tripwire HQ Connector - Configuration Files, Keys, and Logs + +# +# Note: File locations here are different than in a stock HQ Connector +# installation. This is because Tripwire 2.3 uses a different path +# structure than Tripwire 2.2.1. +# +# You may need to update your HQ Agent configuation file (or this policy +# file) to correct the paths. We have attempted to support the FHS standard +# here by placing the HQ Agent files similarly to the way Tripwire 2.3 +# places them. +# + +#( +# rulename = "Tripwire HQ Connector Data Files", +# severity = $(SIG_HI) +#) +#{ +# +# # NOTE: Removing the inode attribute because when Tripwire creates a backup +# # it does so by renaming the old file and creating a new one (which will +# # have a new inode number). Leaving inode turned on for keys, which +# # shouldn't ever change. +# +# +# $(TWBIN)/agent.cfg -> $(SEC_BIN) -i ; +# $(TWLKEY)/authentication.key -> $(SEC_BIN) ; +# $(TWDB)/tasks.dat -> $(SEC_CONFIG) ; +# $(TWDB)/schedule.dat -> $(SEC_CONFIG) ; +# +# # Uncomment if you have agent logging enabled. +# #/var/log/tripwire/agent.log -> $(SEC_LOG) ; +#} + + + +# Commonly accessed directories that should remain static with regards to owner and group +( + rulename = "Invariant Directories", + severity = $(SIG_MED) +) +{ + / -> $(SEC_INVARIANT) (recurse = false) ; + /home -> $(SEC_INVARIANT) (recurse = false) ; +} + +# +# First, root's "home" +# + +( + rulename = "Root's home", + severity = $(SIG_HI) +) +{ + # /.rhosts -> $(SEC_CRIT) ; + /.profile -> $(SEC_CRIT) ; + /.cshrc -> $(SEC_CRIT) ; + /.login -> $(SEC_CRIT) ; + # /.exrc -> $(SEC_CRIT) ; + # /.logout -> $(SEC_CRIT) ; + # /.forward -> $(SEC_CRIT) ; + /root -> $(SEC_CRIT) (recurse = true) ; + !/root/.history ; + !/root/.bash_history ; + # !/root/.lsof_SYSTEM_NAME ; # Uncomment if lsof is installed +} + + +# +# FreeBSD Kernel +# + +( + rulename = "FreeBSD Kernel", + severity = $(SIG_HI) +) +{ + /kernel -> $(SEC_CRIT) ; + /kernel.old -> $(SEC_CRIT) ; + /kernel.GENERIC -> $(SEC_CRIT) ; +} + + +# +# FreeBSD Modules +# + +( + rulename = "FreeBSD Modules", + severity = $(SIG_HI) +) +{ + /modules -> $(SEC_CRIT) (recurse = true) ; + /modules.old -> $(SEC_CRIT) (recurse = true) ; + # /lkm -> $(SEC_CRIT) (recurse = true) ; # uncomment if using lkm kld +} + + +# +# System Administration Programs +# + +( + rulename = "System Administration Programs", + severity = $(SIG_HI) +) +{ + /sbin -> $(SEC_CRIT) (recurse = true) ; + /usr/sbin -> $(SEC_CRIT) (recurse = true) ; +} + + +# +# User Utilities +# + +( + rulename = "User Utilities", + severity = $(SIG_HI) +) +{ + /bin -> $(SEC_CRIT) (recurse = true) ; + /usr/bin -> $(SEC_CRIT) (recurse = true) ; +} + + +# +# /dev +# + +( + rulename = "/dev", + severity = $(SIG_HI) +) +{ + /dev -> $(Device) (recurse = true) ; + !/dev/vga ; + !/dev/dri ; + /dev/console -> $(SEC_TTY) ; + /dev/ttyv0 -> $(SEC_TTY) ; + /dev/ttyv1 -> $(SEC_TTY) ; + /dev/ttyv2 -> $(SEC_TTY) ; + /dev/ttyv3 -> $(SEC_TTY) ; + /dev/ttyv4 -> $(SEC_TTY) ; + /dev/ttyv5 -> $(SEC_TTY) ; + /dev/ttyv6 -> $(SEC_TTY) ; + /dev/ttyv7 -> $(SEC_TTY) ; + /dev/ttyp0 -> $(SEC_TTY) ; + /dev/ttyp1 -> $(SEC_TTY) ; + /dev/ttyp2 -> $(SEC_TTY) ; + /dev/ttyp3 -> $(SEC_TTY) ; + /dev/ttyp4 -> $(SEC_TTY) ; + /dev/ttyp5 -> $(SEC_TTY) ; + /dev/ttyp6 -> $(SEC_TTY) ; + /dev/ttyp7 -> $(SEC_TTY) ; + /dev/ttyp8 -> $(SEC_TTY) ; + /dev/ttyp9 -> $(SEC_TTY) ; + /dev/ttypa -> $(SEC_TTY) ; + /dev/ttypb -> $(SEC_TTY) ; + /dev/ttypc -> $(SEC_TTY) ; + /dev/ttypd -> $(SEC_TTY) ; + /dev/ttype -> $(SEC_TTY) ; + /dev/ttypf -> $(SEC_TTY) ; + /dev/ttypg -> $(SEC_TTY) ; + /dev/ttyph -> $(SEC_TTY) ; + /dev/ttypi -> $(SEC_TTY) ; + /dev/ttypj -> $(SEC_TTY) ; + /dev/ttypl -> $(SEC_TTY) ; + /dev/ttypm -> $(SEC_TTY) ; + /dev/ttypn -> $(SEC_TTY) ; + /dev/ttypo -> $(SEC_TTY) ; + /dev/ttypp -> $(SEC_TTY) ; + /dev/ttypq -> $(SEC_TTY) ; + /dev/ttypr -> $(SEC_TTY) ; + /dev/ttyps -> $(SEC_TTY) ; + /dev/ttypt -> $(SEC_TTY) ; + /dev/ttypu -> $(SEC_TTY) ; + /dev/ttypv -> $(SEC_TTY) ; + /dev/cuaa0 -> $(SEC_TTY) ; # modem +} + + +# +# /etc +# + +( + rulename = "/etc", + severity = $(SIG_HI) +) +{ + /etc -> $(SEC_CRIT) (recurse = true) ; + # /etc/mail/aliases -> $(SEC_CONFIG) ; + /etc/dumpdates -> $(SEC_CONFIG) ; + /etc/motd -> $(SEC_CONFIG) ; + !/etc/ppp/connect-errors ; + /etc/skeykeys -> $(SEC_CONFIG) ; + # Uncomment the following 4 lines if your password file does not change + # /etc/passwd -> $(SEC_CONFIG) ; + # /etc/master.passwd -> $(SEC_CONFIG) ; + # /etc/pwd.db -> $(SEC_CONFIG) ; + # /etc/spwd.db -> $(SEC_CONFIG) ; +} + + +# +# Copatibility (Linux) +# + +( + rulename = "Linux Compatibility", + severity = $(SIG_HI) +) +{ + /compat -> $(SEC_CRIT) (recurse = true) ; +# +# Uncomment the following if Linux compatibility is used. Replace +# HOSTNAME1 and HOSTNAME2 with the hosts that have Linux emulation port +# installed. +# +#@@ifhost HOSTNAME1 || HOSTNAME2 +# /compat/linux/etc -> $(SEC_INVARIANT) (recurse = false) ; +# /compat/linux/etc/X11 -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/pam.d -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/profile.d -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/real -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/bashrc -> $(SEC_CONFIG) ; +# /compat/linux/etc/csh.login -> $(SEC_CONFIG) ; +# /compat/linux/etc/host.conf -> $(SEC_CONFIG) ; +# /compat/linux/etc/hosts.allow -> $(SEC_CONFIG) ; +# /compat/linux/etc/hosts.deny -> $(SEC_CONFIG) ; +# /compat/linux/etc/info-dir -> $(SEC_CONFIG) ; +# /compat/linux/etc/inputrc -> $(SEC_CONFIG) ; +# /compat/linux/etc/ld.so.conf -> $(SEC_CONFIG) ; +# /compat/linux/etc/nsswitch.conf -> $(SEC_CONFIG) ; +# /compat/linux/etc/profile -> $(SEC_CONFIG) ; +# /compat/linux/etc/redhat-release -> $(SEC_CONFIG) ; +# /compat/linux/etc/rpc -> $(SEC_CONFIG) ; +# /compat/linux/etc/securetty -> $(SEC_CONFIG) ; +# /compat/linux/etc/shells -> $(SEC_CONFIG) ; +# /compat/linux/etc/termcap -> $(SEC_CONFIG) ; +# /compat/linux/etc/yp.conf -> $(SEC_CONFIG) ; +# !/compat/linux/etc/ld.so.cache ; +# !/compat/linux/var/spool/mail ; +#@@endif +} + + +# +# Libraries, include files, and other system files +# + +( + rulename = "Libraries, include files, and other system files", + severity = $(SIG_HI) +) +{ + /usr/include -> $(SEC_CRIT) (recurse = true) ; + /usr/lib -> $(SEC_CRIT) (recurse = true) ; + /usr/libdata -> $(SEC_CRIT) (recurse = true) ; + /usr/libexec -> $(SEC_CRIT) (recurse = true) ; + /usr/share -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man -> $(SEC_CONFIG) ; + !/usr/share/man/whatis ; + !/usr/share/man/.glimpse_filenames ; + !/usr/share/man/.glimpse_filenames_index ; + !/usr/share/man/.glimpse_filetimes ; + !/usr/share/man/.glimpse_filters ; + !/usr/share/man/.glimpse_index ; + !/usr/share/man/.glimpse_messages ; + !/usr/share/man/.glimpse_partitions ; + !/usr/share/man/.glimpse_statistics ; + !/usr/share/man/.glimpse_turbo ; + /usr/share/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/share/man/cat1 ; + ! /usr/share/man/cat2 ; + ! /usr/share/man/cat3 ; + ! /usr/share/man/cat4 ; + ! /usr/share/man/cat5 ; + ! /usr/share/man/cat6 ; + ! /usr/share/man/cat7 ; + ! /usr/share/man/cat8 ; + ! /usr/share/man/cat9 ; + ! /usr/share/man/catl ; + ! /usr/share/man/catn ; + /usr/share/perl/man -> $(SEC_CONFIG) ; + !/usr/share/perl/man/whatis ; + !/usr/share/perl/man/.glimpse_filenames ; + !/usr/share/perl/man/.glimpse_filenames_index ; + !/usr/share/perl/man/.glimpse_filetimes ; + !/usr/share/perl/man/.glimpse_filters ; + !/usr/share/perl/man/.glimpse_index ; + !/usr/share/perl/man/.glimpse_messages ; + !/usr/share/perl/man/.glimpse_partitions ; + !/usr/share/perl/man/.glimpse_statistics ; + !/usr/share/perl/man/.glimpse_turbo ; + /usr/share/perl/man/man3 -> $(SEC_CRIT) (recurse = true) ; + ! /usr/share/perl/man/cat3 ; + /usr/local/lib/perl5/5.00503/man -> $(SEC_CONFIG) ; + ! /usr/local/lib/perl5/5.00503/man/whatis ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filters ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filetimes ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_messages ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_statistics ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_index ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_turbo ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_partitions ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filenames ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filenames_index ; + /usr/local/lib/perl5/5.00503/man/man3 -> $(SEC_CRIT) (recurse = true) ; + ! /usr/local/lib/perl5/5.00503/man/cat3 ; +} + + +# +# X11R6 +# + +( + rulename = "X11R6", + severity = $(SIG_HI) +) +{ + /usr/X11R6 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/lib/X11/xdm -> $(SEC_CONFIG) (recurse = true) ; + !/usr/X11R6/lib/X11/xdm/xdm-errors ; + !/usr/X11R6/lib/X11/xdm/authdir/authfiles ; + !/usr/X11R6/lib/X11/xdm/xdm-pid ; + /usr/X11R6/lib/X11/xkb/compiled -> $(SEC_CONFIG) (recurse = true) ; + /usr/X11R6/man -> $(SEC_CONFIG) ; + !/usr/X11R6/man/whatis ; + !/usr/X11R6/man/.glimpse_filenames ; + !/usr/X11R6/man/.glimpse_filenames_index ; + !/usr/X11R6/man/.glimpse_filetimes ; + !/usr/X11R6/man/.glimpse_filters ; + !/usr/X11R6/man/.glimpse_index ; + !/usr/X11R6/man/.glimpse_messages ; + !/usr/X11R6/man/.glimpse_partitions ; + !/usr/X11R6/man/.glimpse_statistics ; + !/usr/X11R6/man/.glimpse_turbo ; + /usr/X11R6/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/manl -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/X11R6/man/cat1 ; + ! /usr/X11R6/man/cat2 ; + ! /usr/X11R6/man/cat3 ; + ! /usr/X11R6/man/cat4 ; + ! /usr/X11R6/man/cat5 ; + ! /usr/X11R6/man/cat6 ; + ! /usr/X11R6/man/cat7 ; + ! /usr/X11R6/man/cat8 ; + ! /usr/X11R6/man/cat9 ; + ! /usr/X11R6/man/catl ; + ! /usr/X11R6/man/catn ; +} + + +# +# sources +# + +( + rulename = "Sources", + severity = $(SIG_HI) +) +{ + /usr/src -> $(SEC_CRIT) (recurse = true) ; + /usr/src/sys/compile -> $(SEC_CONFIG) (recurse = false) ; +} + + +# +# NIS +# + +( + rulename = "NIS", + severity = $(SIG_HI) +) +{ + /var/yp -> $(SEC_CRIT) (recurse = true) ; + !/var/yp/binding ; +} + + +# +# Temporary directories +# +( + rulename = "Temporary directories", + recurse = false, + severity = $(SIG_LOW) +) +{ + /usr/tmp -> $(SEC_INVARIANT) ; + /var/tmp -> $(SEC_INVARIANT) ; + /var/preserve -> $(SEC_INVARIANT) ; + /tmp -> $(SEC_INVARIANT) ; +} + +# +# Local files +# + +( + rulename = "Local files", + severity = $(SIG_MED) +) +{ + /usr/local/bin -> $(SEC_BIN) (recurse = true) ; + /usr/local/sbin -> $(SEC_BIN) (recurse = true) ; + /usr/local/etc -> $(SEC_BIN) (recurse = true) ; + /usr/local/lib -> $(SEC_BIN) (recurse = true ) ; + /usr/local/libexec -> $(SEC_BIN) (recurse = true ) ; + /usr/local/share -> $(SEC_BIN) (recurse = true ) ; + /usr/local/man -> $(SEC_CONFIG) ; + !/usr/local/man/whatis ; + !/usr/local/man/.glimpse_filenames ; + !/usr/local/man/.glimpse_filenames_index ; + !/usr/local/man/.glimpse_filetimes ; + !/usr/local/man/.glimpse_filters ; + !/usr/local/man/.glimpse_index ; + !/usr/local/man/.glimpse_messages ; + !/usr/local/man/.glimpse_partitions ; + !/usr/local/man/.glimpse_statistics ; + !/usr/local/man/.glimpse_turbo ; + /usr/local/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/manl -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/local/man/cat1 ; + ! /usr/local/man/cat2 ; + ! /usr/local/man/cat3 ; + ! /usr/local/man/cat4 ; + ! /usr/local/man/cat5 ; + ! /usr/local/man/cat6 ; + ! /usr/local/man/cat7 ; + ! /usr/local/man/cat8 ; + ! /usr/local/man/cat9 ; + ! /usr/local/man/catl ; + ! /usr/local/man/catn ; + /usr/local/krb5 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man -> $(SEC_CONFIG) ; + !/usr/local/krb5/man/whatis ; + !/usr/local/krb5/man/.glimpse_filenames ; + !/usr/local/krb5/man/.glimpse_filenames_index ; + !/usr/local/krb5/man/.glimpse_filetimes ; + !/usr/local/krb5/man/.glimpse_filters ; + !/usr/local/krb5/man/.glimpse_index ; + !/usr/local/krb5/man/.glimpse_messages ; + !/usr/local/krb5/man/.glimpse_partitions ; + !/usr/local/krb5/man/.glimpse_statistics ; + !/usr/local/krb5/man/.glimpse_turbo ; + /usr/local/krb5/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/manl -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/local/krb5/man/cat1 ; + ! /usr/local/krb5/man/cat2 ; + ! /usr/local/krb5/man/cat3 ; + ! /usr/local/krb5/man/cat4 ; + ! /usr/local/krb5/man/cat5 ; + ! /usr/local/krb5/man/cat6 ; + ! /usr/local/krb5/man/cat7 ; + ! /usr/local/krb5/man/cat8 ; + ! /usr/local/krb5/man/cat9 ; + ! /usr/local/krb5/man/catl ; + ! /usr/local/krb5/man/catn ; + /usr/local/www -> $(SEC_CONFIG) (recurse = true) ; +} + + +( + rulename = "Security Control", + severity = $(SIG_HI) +) +{ + /etc/group -> $(SEC_CRIT) ; + /etc/crontab -> $(SEC_CRIT) ; +} + +#============================================================================= +# +# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, +# Inc. in the United States and other countries. All rights reserved. +# +# FreeBSD is a registered trademark of the FreeBSD Project Inc. +# +# UNIX is a registered trademark of The Open Group. +# +#============================================================================= +# +# Permission is granted to make and distribute verbatim copies of this document +# provided the copyright notice and this permission notice are preserved on all +# copies. +# +# Permission is granted to copy and distribute modified versions of this +# document under the conditions for verbatim copying, provided that the entire +# resulting derived work is distributed under the terms of a permission notice +# identical to this one. +# +# Permission is granted to copy and distribute translations of this document +# into another language, under the above conditions for modified versions, +# except that this permission notice may be stated in a translation approved by +# Tripwire, Inc. +# +# DCM diff --git a/policy/twpol-MirBSD.txt b/policy/twpol-MirBSD.txt new file mode 100644 index 0000000..a74fb67 --- /dev/null +++ b/policy/twpol-MirBSD.txt @@ -0,0 +1,292 @@ + ############################################################################## + # ## +############################################################################## # +# # # +# Policy file for MirOS BSD # # +# (adapted from OpenBSD policy) # # +# ## +############################################################################## + + ############################################################################## + # ## +############################################################################## # +# # # +# Global Variable Definitions # # +# # # +# These are defined at install time by the installation script. You may # # +# manually edit these if you are using this file directly and not from the # # +# installation script itself. # # +# ## +############################################################################## + +@@section GLOBAL +TWROOT=; +TWBIN=; +TWPOL=; +TWDB=; +TWSKEY=; +TWLKEY=; +TWREPORT=; +HOSTNAME=; + + ############################################################################## + # Predefined Variables # +############################################################################## +# +# Property Masks +# +# - ignore the following properties +# + check the following properties +# +# a access timestamp (mutually exclusive with +CMSH) +# b number of blocks allocated +# c inode creation/modification timestamp +# d ID of device on which inode resides +# g group id of owner +# i inode number +# l growing files (logfiles for example) +# m modification timestamp +# n number of links +# p permission and file mode bits +# r ID of device pointed to by inode (valid only for device objects) +# s file size +# t file type +# u user id of owner +# +# C CRC-32 hash +# H HAVAL hash +# M MD5 hash +# S SHA hash +# +############################################################################## + +Device = +pugsdr-intlbamcCMSH ; +Dynamic = +pinugtd-srlbamcCMSH ; +Growing = +pinugtdl-srbamcCMSH ; +IgnoreAll = -pinugtsdrlbamcCMSH ; +IgnoreNone = +pinugtsdrbamcCMSH-l ; +ReadOnly = +pinugtsdbmCM-rlacSH ; +Temporary = +pugt ; + +@@section FS + + ######################################## + # ## +######################################## # +# # # +# Tripwire Binaries and Data Files # # +# ## +######################################## + +# Tripwire Binaries +( + rulename = "Tripwire Binaries", +) +{ + $(TWBIN)/siggen -> $(ReadOnly) ; + $(TWBIN)/tripwire -> $(ReadOnly) ; + $(TWBIN)/twadmin -> $(ReadOnly) ; + $(TWBIN)/twprint -> $(ReadOnly) ; +} + +# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases +( + rulename = "Tripwire Data Files", +) +{ + # NOTE: We remove the inode attribute because when Tripwire creates a backup, + # it does so by renaming the old file and creating a new one (which will + # have a new inode number). Inode is left turned on for keys, which shouldn't + # ever change. + + # NOTE: The first integrity check triggers this rule and each integrity check + # afterward triggers this rule until a database update is run, since the + # database file does not exist before that point. + + $(TWDB) -> $(Dynamic) -i ; + $(TWPOL)/tw.pol -> $(ReadOnly) -i ; + $(TWPOL)/tw.cfg -> $(ReadOnly) -i ; + $(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ; + $(TWSKEY)/site.key -> $(ReadOnly) ; + + # don't scan the individual reports + $(TWREPORT) -> $(Dynamic) (recurse=0) ; + + # In this configuration /usr/local is a symbolic link to /home/local. + # We want to ignore the following directories since they are already + # scanned using the real directory or mount point. Otherwise we see + # duplicates in the reports. + + !/home/local ; +} + + ################################################ + # ## +################################################ # +# # # +# OS Boot and Configuration Files # # +# ## +################################################ +( + rulename = "OS Boot and Configuration Files", +) +{ + /boot -> $(ReadOnly) ; + /bsd -> $(ReadOnly) ; + /etc -> $(IgnoreNone) -SHa ; +} + + ################################################### + # ## +################################################### # +# # # +# Mount Points # # +# ## +################################################### +( + rulename = "Mount Points", +) +{ + / -> $(ReadOnly) ; + /cdrom -> $(Dynamic) ; + /floppy -> $(Dynamic) ; + /home -> $(ReadOnly) ; # Modify as needed + /mnt -> $(Dynamic) ; + /usr -> $(ReadOnly) ; + /var -> $(ReadOnly) ; +} + + ################################################### + # ## +################################################### # +# # # +# Misc Top-Level Directories # # +# ## +################################################### +( + rulename = "Misc Top-Level Directories", +) +{ + /altroot -> $(Dynamic) ; + /stand -> $(Dynamic) ; +} + + ################################################ + # ## +################################################ # +# # # +# System Devices # # +# ## +################################################ +( + rulename = "System Devices", +) +{ + /dev -> $(Device) ; + /dev/fd -> $(Device) ; + /var/cron/tabs/.sock -> $(Device) ; + /var/empty/dev/log -> $(Device) ; +} + + ################################################ + # ## +################################################ # +# # # +# OS Binaries and Libraries # # +# ## +################################################ +( + rulename = "OS Binaries and Libraries", +) +{ + /bin -> $(ReadOnly) ; + /sbin -> $(ReadOnly) ; + /usr/bin -> $(ReadOnly) ; + /usr/lib -> $(ReadOnly) ; + /usr/libexec -> $(ReadOnly) ; + /usr/sbin -> $(ReadOnly) ; + /usr/X11R6/bin -> $(ReadOnly) ; + /usr/X11R6/lib -> $(ReadOnly) ; +} + ################################################ + # ## +################################################ # +# # # +# Usr Local Files # # +# ## +################################################ +#OK( + #OKrulename = "Usr Local Files", +#OK) +#OK{ + #OK/usr/local -> $(ReadOnly) ; + #OK/usr/local/bin -> $(ReadOnly) ; + #OK/usr/local/doc -> $(ReadOnly) ; + #OK/usr/local/etc -> $(ReadOnly) ; + #OK/usr/local/include -> $(ReadOnly) ; + #OK/usr/local/info -> $(ReadOnly) ; + #OK/usr/local/lib -> $(ReadOnly) ; + #OK/usr/local/libdata -> $(ReadOnly) ; + #OK/usr/local/libexec -> $(ReadOnly) ; + #OK/usr/local/man -> $(ReadOnly) ; + #OK/usr/local/sbin -> $(ReadOnly) ; + #OK/usr/local/share -> $(ReadOnly) ; + #OK/usr/local/src -> $(ReadOnly) ; +#OK} + + ################################################ + # ## +################################################ # +# # # +# Root Directory and Files # # +# ## +################################################ +( + rulename = "Root Directory and Files", +) +{ + /root -> $(IgnoreNone) -SHa ; + /root/.cshrc -> $(Dynamic) ; + /root/.profile -> $(Dynamic) ; +} + + ################################################ + # ## +################################################ # +# # # +# Temporary Directories # # +# ## +################################################ +( + rulename = "Temporary Directories", +) +{ + /tmp -> $(Temporary) ; + /var/tmp -> $(Temporary) ; +} + + ################################################ + # ## +################################################ # +# # # +# System and Boot Changes # # +# ## +################################################ +( + rulename = "System and Boot Changes", +) +{ + /var/backups -> $(Dynamic) -i ; + /var/db/host.random -> $(ReadOnly) -mCM ; + /var/cron -> $(Growing) -i ; + /var/log -> $(Growing) -i ; + /var/run -> $(Dynamic) -i ; + /var/mail -> $(Growing) ; + /var/msgs/bounds -> $(ReadOnly) -smbCM ; + /var/spool/clientmqueue -> $(Temporary) ; + /var/spool/mqueue -> $(Temporary) ; +} + +# +# $Id: twpol-OpenBSD.txt,v 1.2 2004/05/14 21:56:21 pherman Exp $ +# diff --git a/policy/twpol-NetBSD.txt b/policy/twpol-NetBSD.txt new file mode 100644 index 0000000..79e742e --- /dev/null +++ b/policy/twpol-NetBSD.txt @@ -0,0 +1,656 @@ +# +# Policy file for NetBSD +# (adapted from FreeBSD policy) +# +# $FreeBSD: ports/security/tripwire/files/twpol.txt,v 1.2 2002/03/04 16:55:21 cy Exp $ +# $Id: twpol-FreeBSD.txt,v 1.1 2003/06/08 02:00:06 pherman Exp $ + +# +# This is the example Tripwire Policy file. It is intended as a place to +# start creating your own custom Tripwire Policy file. Referring to it as +# well as the Tripwire Policy Guide should give you enough information to +# make a good custom Tripwire Policy file that better covers your +# configuration and security needs. A text version of this policy file is +# called twpol.txt. +# +# Note that this file is tuned to an install of FreeBSD using +# buildworld. If run unmodified, this file should create no errors on +# database creation, or violations on a subsiquent integrity check. +# However it is impossible for there to be one policy file for all machines, +# so this existing one errs on the side of security. Your FreeBSD +# configuration will most likey differ from the one our policy file was +# tuned to, and will therefore require some editing of the default +# Tripwire Policy file. +# +# The example policy file is best run with 'Loose Directory Checking' +# enabled. Set LOOSEDIRECTORYCHECKING=TRUE in the Tripwire Configuration +# file. +# +# Email support is not included and must be added to this file. +# Add the 'emailto=' to the rule directive section of each rule (add a comma +# after the 'severity=' line and add an 'emailto=' and include the email +# addresses you want the violation reports to go to). Addresses are +# semi-colon delimited. +# + + + +# +# Global Variable Definitions +# +# These are defined at install time by the installation script. You may +# Manually edit these if you are using this file directly and not from the +# installation script itself. +# + +@@section GLOBAL +TWROOT=; +TWBIN=; +TWPOL=; +TWDB=; +TWSKEY=; +TWLKEY=; +TWREPORT=; +HOSTNAME=; + +@@section FS +SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change +SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set +SEC_BIN = $(ReadOnly) ; # Binaries that should not change +SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often +SEC_TTY = $(Dynamic)-ugp ; # Tty files that change ownership at login +SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership +SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership +SIG_LOW = 33 ; # Non-critical files that are of minimal security impact +SIG_MED = 66 ; # Non-critical files that are of significant security impact +SIG_HI = 100 ; # Critical files that are significant points of vulnerability + + +# Tripwire Binaries +( + rulename = "Tripwire Binaries", + severity = $(SIG_HI) +) +{ + $(TWBIN)/siggen -> $(SEC_BIN) ; + $(TWBIN)/tripwire -> $(SEC_BIN) ; + $(TWBIN)/twadmin -> $(SEC_BIN) ; + $(TWBIN)/twprint -> $(SEC_BIN) ; +} + +# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases +( + rulename = "Tripwire Data Files", + severity = $(SIG_HI) +) +{ + # NOTE: We remove the inode attribute because when Tripwire creates a backup, + # it does so by renaming the old file and creating a new one (which will + # have a new inode number). Inode is left turned on for keys, which shouldn't + # ever change. + + # NOTE: The first integrity check triggers this rule and each integrity check + # afterward triggers this rule until a database update is run, since the + # database file does not exist before that point. + + $(TWDB) -> $(SEC_CONFIG) -i ; + $(TWPOL)/tw.pol -> $(SEC_BIN) -i ; + $(TWPOL)/tw.cfg -> $(SEC_BIN) -i ; + $(TWPOL)/twcfg.txt -> $(SEC_BIN) ; + $(TWPOL)/twpol.txt -> $(SEC_BIN) ; + $(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_BIN) ; + $(TWSKEY)/site.key -> $(SEC_BIN) ; + + #don't scan the individual reports + $(TWREPORT) -> $(SEC_CONFIG) (recurse=0) ; +} + + +# Tripwire HQ Connector Binaries +#( +# rulename = "Tripwire HQ Connector Binaries", +# severity = $(SIG_HI) +#) +#{ +# $(TWBIN)/hqagent -> $(SEC_BIN) ; +#} +# +# Tripwire HQ Connector - Configuration Files, Keys, and Logs + +# +# Note: File locations here are different than in a stock HQ Connector +# installation. This is because Tripwire 2.3 uses a different path +# structure than Tripwire 2.2.1. +# +# You may need to update your HQ Agent configuation file (or this policy +# file) to correct the paths. We have attempted to support the FHS standard +# here by placing the HQ Agent files similarly to the way Tripwire 2.3 +# places them. +# + +#( +# rulename = "Tripwire HQ Connector Data Files", +# severity = $(SIG_HI) +#) +#{ +# +# # NOTE: Removing the inode attribute because when Tripwire creates a backup +# # it does so by renaming the old file and creating a new one (which will +# # have a new inode number). Leaving inode turned on for keys, which +# # shouldn't ever change. +# +# +# $(TWBIN)/agent.cfg -> $(SEC_BIN) -i ; +# $(TWLKEY)/authentication.key -> $(SEC_BIN) ; +# $(TWDB)/tasks.dat -> $(SEC_CONFIG) ; +# $(TWDB)/schedule.dat -> $(SEC_CONFIG) ; +# +# # Uncomment if you have agent logging enabled. +# #/var/log/tripwire/agent.log -> $(SEC_LOG) ; +#} + + + +# Commonly accessed directories that should remain static with regards to owner and group +( + rulename = "Invariant Directories", + severity = $(SIG_MED) +) +{ + / -> $(SEC_INVARIANT) (recurse = false) ; + /home -> $(SEC_INVARIANT) (recurse = false) ; +} + +# +# First, root's "home" +# + +( + rulename = "Root's home", + severity = $(SIG_HI) +) +{ + # /.rhosts -> $(SEC_CRIT) ; + /.profile -> $(SEC_CRIT) ; + /.cshrc -> $(SEC_CRIT) ; + /.login -> $(SEC_CRIT) ; + # /.exrc -> $(SEC_CRIT) ; + # /.logout -> $(SEC_CRIT) ; + # /.forward -> $(SEC_CRIT) ; + /root -> $(SEC_CRIT) (recurse = true) ; + !/root/.history ; + !/root/.bash_history ; + # !/root/.lsof_SYSTEM_NAME ; # Uncomment if lsof is installed +} + + +# +# FreeBSD Kernel +# + +( + rulename = "FreeBSD Kernel", + severity = $(SIG_HI) +) +{ + /kernel -> $(SEC_CRIT) ; + /kernel.old -> $(SEC_CRIT) ; + /kernel.GENERIC -> $(SEC_CRIT) ; +} + + +# +# FreeBSD Modules +# + +( + rulename = "FreeBSD Modules", + severity = $(SIG_HI) +) +{ + /modules -> $(SEC_CRIT) (recurse = true) ; + /modules.old -> $(SEC_CRIT) (recurse = true) ; + # /lkm -> $(SEC_CRIT) (recurse = true) ; # uncomment if using lkm kld +} + + +# +# System Administration Programs +# + +( + rulename = "System Administration Programs", + severity = $(SIG_HI) +) +{ + /sbin -> $(SEC_CRIT) (recurse = true) ; + /usr/sbin -> $(SEC_CRIT) (recurse = true) ; +} + + +# +# User Utilities +# + +( + rulename = "User Utilities", + severity = $(SIG_HI) +) +{ + /bin -> $(SEC_CRIT) (recurse = true) ; + /usr/bin -> $(SEC_CRIT) (recurse = true) ; +} + + +# +# /dev +# + +( + rulename = "/dev", + severity = $(SIG_HI) +) +{ + /dev -> $(Device) (recurse = true) ; + !/dev/vga ; + !/dev/dri ; + /dev/console -> $(SEC_TTY) ; + /dev/ttyv0 -> $(SEC_TTY) ; + /dev/ttyv1 -> $(SEC_TTY) ; + /dev/ttyv2 -> $(SEC_TTY) ; + /dev/ttyv3 -> $(SEC_TTY) ; + /dev/ttyv4 -> $(SEC_TTY) ; + /dev/ttyv5 -> $(SEC_TTY) ; + /dev/ttyv6 -> $(SEC_TTY) ; + /dev/ttyv7 -> $(SEC_TTY) ; + /dev/ttyp0 -> $(SEC_TTY) ; + /dev/ttyp1 -> $(SEC_TTY) ; + /dev/ttyp2 -> $(SEC_TTY) ; + /dev/ttyp3 -> $(SEC_TTY) ; + /dev/ttyp4 -> $(SEC_TTY) ; + /dev/ttyp5 -> $(SEC_TTY) ; + /dev/ttyp6 -> $(SEC_TTY) ; + /dev/ttyp7 -> $(SEC_TTY) ; + /dev/ttyp8 -> $(SEC_TTY) ; + /dev/ttyp9 -> $(SEC_TTY) ; + /dev/ttypa -> $(SEC_TTY) ; + /dev/ttypb -> $(SEC_TTY) ; + /dev/ttypc -> $(SEC_TTY) ; + /dev/ttypd -> $(SEC_TTY) ; + /dev/ttype -> $(SEC_TTY) ; + /dev/ttypf -> $(SEC_TTY) ; + /dev/ttypg -> $(SEC_TTY) ; + /dev/ttyph -> $(SEC_TTY) ; + /dev/ttypi -> $(SEC_TTY) ; + /dev/ttypj -> $(SEC_TTY) ; + /dev/ttypl -> $(SEC_TTY) ; + /dev/ttypm -> $(SEC_TTY) ; + /dev/ttypn -> $(SEC_TTY) ; + /dev/ttypo -> $(SEC_TTY) ; + /dev/ttypp -> $(SEC_TTY) ; + /dev/ttypq -> $(SEC_TTY) ; + /dev/ttypr -> $(SEC_TTY) ; + /dev/ttyps -> $(SEC_TTY) ; + /dev/ttypt -> $(SEC_TTY) ; + /dev/ttypu -> $(SEC_TTY) ; + /dev/ttypv -> $(SEC_TTY) ; + /dev/cuaa0 -> $(SEC_TTY) ; # modem +} + + +# +# /etc +# + +( + rulename = "/etc", + severity = $(SIG_HI) +) +{ + /etc -> $(SEC_CRIT) (recurse = true) ; + # /etc/mail/aliases -> $(SEC_CONFIG) ; + /etc/dumpdates -> $(SEC_CONFIG) ; + /etc/motd -> $(SEC_CONFIG) ; + !/etc/ppp/connect-errors ; + /etc/skeykeys -> $(SEC_CONFIG) ; + # Uncomment the following 4 lines if your password file does not change + # /etc/passwd -> $(SEC_CONFIG) ; + # /etc/master.passwd -> $(SEC_CONFIG) ; + # /etc/pwd.db -> $(SEC_CONFIG) ; + # /etc/spwd.db -> $(SEC_CONFIG) ; +} + + +# +# Copatibility (Linux) +# + +( + rulename = "Linux Compatibility", + severity = $(SIG_HI) +) +{ + /compat -> $(SEC_CRIT) (recurse = true) ; +# +# Uncomment the following if Linux compatibility is used. Replace +# HOSTNAME1 and HOSTNAME2 with the hosts that have Linux emulation port +# installed. +# +#@@ifhost HOSTNAME1 || HOSTNAME2 +# /compat/linux/etc -> $(SEC_INVARIANT) (recurse = false) ; +# /compat/linux/etc/X11 -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/pam.d -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/profile.d -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/real -> $(SEC_CONFIG) (recurse = true) ; +# /compat/linux/etc/bashrc -> $(SEC_CONFIG) ; +# /compat/linux/etc/csh.login -> $(SEC_CONFIG) ; +# /compat/linux/etc/host.conf -> $(SEC_CONFIG) ; +# /compat/linux/etc/hosts.allow -> $(SEC_CONFIG) ; +# /compat/linux/etc/hosts.deny -> $(SEC_CONFIG) ; +# /compat/linux/etc/info-dir -> $(SEC_CONFIG) ; +# /compat/linux/etc/inputrc -> $(SEC_CONFIG) ; +# /compat/linux/etc/ld.so.conf -> $(SEC_CONFIG) ; +# /compat/linux/etc/nsswitch.conf -> $(SEC_CONFIG) ; +# /compat/linux/etc/profile -> $(SEC_CONFIG) ; +# /compat/linux/etc/redhat-release -> $(SEC_CONFIG) ; +# /compat/linux/etc/rpc -> $(SEC_CONFIG) ; +# /compat/linux/etc/securetty -> $(SEC_CONFIG) ; +# /compat/linux/etc/shells -> $(SEC_CONFIG) ; +# /compat/linux/etc/termcap -> $(SEC_CONFIG) ; +# /compat/linux/etc/yp.conf -> $(SEC_CONFIG) ; +# !/compat/linux/etc/ld.so.cache ; +# !/compat/linux/var/spool/mail ; +#@@endif +} + + +# +# Libraries, include files, and other system files +# + +( + rulename = "Libraries, include files, and other system files", + severity = $(SIG_HI) +) +{ + /usr/include -> $(SEC_CRIT) (recurse = true) ; + /usr/lib -> $(SEC_CRIT) (recurse = true) ; + /usr/libdata -> $(SEC_CRIT) (recurse = true) ; + /usr/libexec -> $(SEC_CRIT) (recurse = true) ; + /usr/share -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man -> $(SEC_CONFIG) ; + !/usr/share/man/whatis ; + !/usr/share/man/.glimpse_filenames ; + !/usr/share/man/.glimpse_filenames_index ; + !/usr/share/man/.glimpse_filetimes ; + !/usr/share/man/.glimpse_filters ; + !/usr/share/man/.glimpse_index ; + !/usr/share/man/.glimpse_messages ; + !/usr/share/man/.glimpse_partitions ; + !/usr/share/man/.glimpse_statistics ; + !/usr/share/man/.glimpse_turbo ; + /usr/share/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/share/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/share/man/cat1 ; + ! /usr/share/man/cat2 ; + ! /usr/share/man/cat3 ; + ! /usr/share/man/cat4 ; + ! /usr/share/man/cat5 ; + ! /usr/share/man/cat6 ; + ! /usr/share/man/cat7 ; + ! /usr/share/man/cat8 ; + ! /usr/share/man/cat9 ; + ! /usr/share/man/catl ; + ! /usr/share/man/catn ; + /usr/share/perl/man -> $(SEC_CONFIG) ; + !/usr/share/perl/man/whatis ; + !/usr/share/perl/man/.glimpse_filenames ; + !/usr/share/perl/man/.glimpse_filenames_index ; + !/usr/share/perl/man/.glimpse_filetimes ; + !/usr/share/perl/man/.glimpse_filters ; + !/usr/share/perl/man/.glimpse_index ; + !/usr/share/perl/man/.glimpse_messages ; + !/usr/share/perl/man/.glimpse_partitions ; + !/usr/share/perl/man/.glimpse_statistics ; + !/usr/share/perl/man/.glimpse_turbo ; + /usr/share/perl/man/man3 -> $(SEC_CRIT) (recurse = true) ; + ! /usr/share/perl/man/cat3 ; + /usr/local/lib/perl5/5.00503/man -> $(SEC_CONFIG) ; + ! /usr/local/lib/perl5/5.00503/man/whatis ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filters ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filetimes ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_messages ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_statistics ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_index ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_turbo ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_partitions ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filenames ; + ! /usr/local/lib/perl5/5.00503/man/.glimpse_filenames_index ; + /usr/local/lib/perl5/5.00503/man/man3 -> $(SEC_CRIT) (recurse = true) ; + ! /usr/local/lib/perl5/5.00503/man/cat3 ; +} + + +# +# X11R6 +# + +( + rulename = "X11R6", + severity = $(SIG_HI) +) +{ + /usr/X11R6 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/lib/X11/xdm -> $(SEC_CONFIG) (recurse = true) ; + !/usr/X11R6/lib/X11/xdm/xdm-errors ; + !/usr/X11R6/lib/X11/xdm/authdir/authfiles ; + !/usr/X11R6/lib/X11/xdm/xdm-pid ; + /usr/X11R6/lib/X11/xkb/compiled -> $(SEC_CONFIG) (recurse = true) ; + /usr/X11R6/man -> $(SEC_CONFIG) ; + !/usr/X11R6/man/whatis ; + !/usr/X11R6/man/.glimpse_filenames ; + !/usr/X11R6/man/.glimpse_filenames_index ; + !/usr/X11R6/man/.glimpse_filetimes ; + !/usr/X11R6/man/.glimpse_filters ; + !/usr/X11R6/man/.glimpse_index ; + !/usr/X11R6/man/.glimpse_messages ; + !/usr/X11R6/man/.glimpse_partitions ; + !/usr/X11R6/man/.glimpse_statistics ; + !/usr/X11R6/man/.glimpse_turbo ; + /usr/X11R6/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/manl -> $(SEC_CRIT) (recurse = true) ; + /usr/X11R6/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/X11R6/man/cat1 ; + ! /usr/X11R6/man/cat2 ; + ! /usr/X11R6/man/cat3 ; + ! /usr/X11R6/man/cat4 ; + ! /usr/X11R6/man/cat5 ; + ! /usr/X11R6/man/cat6 ; + ! /usr/X11R6/man/cat7 ; + ! /usr/X11R6/man/cat8 ; + ! /usr/X11R6/man/cat9 ; + ! /usr/X11R6/man/catl ; + ! /usr/X11R6/man/catn ; +} + + +# +# sources +# + +( + rulename = "Sources", + severity = $(SIG_HI) +) +{ + /usr/src -> $(SEC_CRIT) (recurse = true) ; + /usr/src/sys/compile -> $(SEC_CONFIG) (recurse = false) ; +} + + +# +# NIS +# + +( + rulename = "NIS", + severity = $(SIG_HI) +) +{ + /var/yp -> $(SEC_CRIT) (recurse = true) ; + !/var/yp/binding ; +} + + +# +# Temporary directories +# +( + rulename = "Temporary directories", + recurse = false, + severity = $(SIG_LOW) +) +{ + /usr/tmp -> $(SEC_INVARIANT) ; + /var/tmp -> $(SEC_INVARIANT) ; + /var/preserve -> $(SEC_INVARIANT) ; + /tmp -> $(SEC_INVARIANT) ; +} + +# +# Local files +# + +( + rulename = "Local files", + severity = $(SIG_MED) +) +{ + /usr/local/bin -> $(SEC_BIN) (recurse = true) ; + /usr/local/sbin -> $(SEC_BIN) (recurse = true) ; + /usr/local/etc -> $(SEC_BIN) (recurse = true) ; + /usr/local/lib -> $(SEC_BIN) (recurse = true ) ; + /usr/local/libexec -> $(SEC_BIN) (recurse = true ) ; + /usr/local/share -> $(SEC_BIN) (recurse = true ) ; + /usr/local/man -> $(SEC_CONFIG) ; + !/usr/local/man/whatis ; + !/usr/local/man/.glimpse_filenames ; + !/usr/local/man/.glimpse_filenames_index ; + !/usr/local/man/.glimpse_filetimes ; + !/usr/local/man/.glimpse_filters ; + !/usr/local/man/.glimpse_index ; + !/usr/local/man/.glimpse_messages ; + !/usr/local/man/.glimpse_partitions ; + !/usr/local/man/.glimpse_statistics ; + !/usr/local/man/.glimpse_turbo ; + /usr/local/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/manl -> $(SEC_CRIT) (recurse = true) ; + /usr/local/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/local/man/cat1 ; + ! /usr/local/man/cat2 ; + ! /usr/local/man/cat3 ; + ! /usr/local/man/cat4 ; + ! /usr/local/man/cat5 ; + ! /usr/local/man/cat6 ; + ! /usr/local/man/cat7 ; + ! /usr/local/man/cat8 ; + ! /usr/local/man/cat9 ; + ! /usr/local/man/catl ; + ! /usr/local/man/catn ; + /usr/local/krb5 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man -> $(SEC_CONFIG) ; + !/usr/local/krb5/man/whatis ; + !/usr/local/krb5/man/.glimpse_filenames ; + !/usr/local/krb5/man/.glimpse_filenames_index ; + !/usr/local/krb5/man/.glimpse_filetimes ; + !/usr/local/krb5/man/.glimpse_filters ; + !/usr/local/krb5/man/.glimpse_index ; + !/usr/local/krb5/man/.glimpse_messages ; + !/usr/local/krb5/man/.glimpse_partitions ; + !/usr/local/krb5/man/.glimpse_statistics ; + !/usr/local/krb5/man/.glimpse_turbo ; + /usr/local/krb5/man/man1 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man2 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man3 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man4 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man5 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man6 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man7 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man8 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/man9 -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/manl -> $(SEC_CRIT) (recurse = true) ; + /usr/local/krb5/man/mann -> $(SEC_CRIT) (recurse = true) ; + ! /usr/local/krb5/man/cat1 ; + ! /usr/local/krb5/man/cat2 ; + ! /usr/local/krb5/man/cat3 ; + ! /usr/local/krb5/man/cat4 ; + ! /usr/local/krb5/man/cat5 ; + ! /usr/local/krb5/man/cat6 ; + ! /usr/local/krb5/man/cat7 ; + ! /usr/local/krb5/man/cat8 ; + ! /usr/local/krb5/man/cat9 ; + ! /usr/local/krb5/man/catl ; + ! /usr/local/krb5/man/catn ; + /usr/local/www -> $(SEC_CONFIG) (recurse = true) ; +} + + +( + rulename = "Security Control", + severity = $(SIG_HI) +) +{ + /etc/group -> $(SEC_CRIT) ; + /etc/crontab -> $(SEC_CRIT) ; +} + +#============================================================================= +# +# Copyright 2000-2017 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, +# Inc. in the United States and other countries. All rights reserved. +# +# FreeBSD is a registered trademark of the FreeBSD Project Inc. +# +# UNIX is a registered trademark of The Open Group. +# +#============================================================================= +# +# Permission is granted to make and distribute verbatim copies of this document +# provided the copyright notice and this permission notice are preserved on all +# copies. +# +# Permission is granted to copy and distribute modified versions of this +# document under the conditions for verbatim copying, provided that the entire +# resulting derived work is distributed under the terms of a permission notice +# identical to this one. +# +# Permission is granted to copy and distribute translations of this document +# into another language, under the above conditions for modified versions, +# except that this permission notice may be stated in a translation approved by +# Tripwire, Inc. +# +# DCM diff --git a/src/Makefile.am b/src/Makefile.am index 6b8084e..7e6ffd8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,3 +8,7 @@ install: uninstall: true +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + -rm -rf test-harness/twtest \ No newline at end of file diff --git a/src/Makefile.in b/src/Makefile.in index 7769907..be0d740 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -282,7 +282,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -520,7 +519,7 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive -clean-am: clean-generic mostlyclean-am +clean-am: clean-generic clean-local mostlyclean-am distclean: distclean-recursive -rm -f Makefile @@ -587,16 +586,17 @@ uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \ - check-am clean clean-generic cscopelist-am ctags ctags-am \ - distclean distclean-generic distclean-tags distdir dvi dvi-am \ - html html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ - pdf-am ps ps-am tags tags-am uninstall uninstall-am + check-am clean clean-generic clean-local cscopelist-am ctags \ + ctags-am distclean distclean-generic distclean-tags distdir \ + dvi dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am .PRECIOUS: Makefile @@ -607,6 +607,11 @@ install: uninstall: true +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + -rm -rf test-harness/twtest + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 484e642..2b48224 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -9,25 +9,25 @@ libcore_a_SOURCES = \ archive.cpp charutil.cpp \ cmdlineparser.cpp codeconvert.cpp core.cpp coreerrors.cpp \ corestrings.cpp crc32.cpp debug.cpp displayencoder.cpp \ - displayutil.cpp error.cpp errorbucketimpl.cpp errortable.cpp \ + displayutil.cpp epoch.cpp error.cpp errorbucketimpl.cpp errortable.cpp \ errorutil.cpp fileerror.cpp fileheader.cpp fsservices.cpp \ growheap.cpp hashtable.cpp haval.cpp msystem.cpp ntmbs.cpp \ refcountobj.cpp serializable.cpp serializer.cpp \ serializerimpl.cpp serializerutil.cpp serstring.cpp \ srefcountobj.cpp srefcounttbl.cpp stdcore.cpp stringutil.cpp \ - timebomb.cpp timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \ + timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \ unixexcept.cpp usernotify.cpp usernotifystdout.cpp \ wchar16.cpp libcore_a_HEADERS = archive.h charutil.h cmdlineparser.h codeconvert.h \ core.h coreerrors.h corestrings.h crc32.h debug.h displayencoder.h \ - displayutil.h error.h errorbucket.h errorbucketimpl.h errorgeneral.h \ + displayutil.h epoch.h error.h errorbucket.h errorbucketimpl.h errorgeneral.h \ errortable.h errorutil.h file.h fileerror.h fileheader.h fixedfilebuf.h \ fsservices.h growheap.h hashtable.h haval.h md5.h msystem.h ntdbs.h \ - ntmbs.h package.h platform.h refcountobj.h resources.h \ + ntmbs.h package.h platform.h refcountobj.h resources.h \ serializable.h serializer.h serializerimpl.h serializerutil.h serstring.h \ sha.h srefcountobj.h srefcounttbl.h stdcore.h stringutil.h tasktimer.h \ - tchar.h timebomb.h timeconvert.h tw_signal.h twlimits.h twlocale.h \ + tchar.h timeconvert.h tw_signal.h twlimits.h twlocale.h \ twstringslang.h typed.h types.h unixexcept.h unixfsservices.h upperbound.h \ usernotify.h usernotifystdout.h wchar16.h @@ -35,6 +35,7 @@ libcore_a_LIBADD = @CORE_CRYPT_O@ libcore_a_DEPENDENCIES = @CORE_CRYPT_O@ DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit +CLEANFILES = *.gcno *.gcda all: $(noinst_LIBRARIES) $(AR) ru ../../lib/libtripwire.a $(libcore_a_OBJECTS) $(libcore_a_LIBADD) diff --git a/src/core/Makefile.in b/src/core/Makefile.in index c013c55..5ee6d53 100644 --- a/src/core/Makefile.in +++ b/src/core/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -113,8 +113,8 @@ am_libcore_a_OBJECTS = file_unix.$(OBJEXT) unixfsservices.$(OBJEXT) \ archive.$(OBJEXT) charutil.$(OBJEXT) cmdlineparser.$(OBJEXT) \ codeconvert.$(OBJEXT) core.$(OBJEXT) coreerrors.$(OBJEXT) \ corestrings.$(OBJEXT) crc32.$(OBJEXT) debug.$(OBJEXT) \ - displayencoder.$(OBJEXT) displayutil.$(OBJEXT) error.$(OBJEXT) \ - errorbucketimpl.$(OBJEXT) errortable.$(OBJEXT) \ + displayencoder.$(OBJEXT) displayutil.$(OBJEXT) epoch.$(OBJEXT) \ + error.$(OBJEXT) errorbucketimpl.$(OBJEXT) errortable.$(OBJEXT) \ errorutil.$(OBJEXT) fileerror.$(OBJEXT) fileheader.$(OBJEXT) \ fsservices.$(OBJEXT) growheap.$(OBJEXT) hashtable.$(OBJEXT) \ haval.$(OBJEXT) msystem.$(OBJEXT) ntmbs.$(OBJEXT) \ @@ -122,9 +122,9 @@ am_libcore_a_OBJECTS = file_unix.$(OBJEXT) unixfsservices.$(OBJEXT) \ serializer.$(OBJEXT) serializerimpl.$(OBJEXT) \ serializerutil.$(OBJEXT) serstring.$(OBJEXT) \ srefcountobj.$(OBJEXT) srefcounttbl.$(OBJEXT) \ - stdcore.$(OBJEXT) stringutil.$(OBJEXT) timebomb.$(OBJEXT) \ - timeconvert.$(OBJEXT) tw_signal.$(OBJEXT) twlimits.$(OBJEXT) \ - twlocale.$(OBJEXT) unixexcept.$(OBJEXT) usernotify.$(OBJEXT) \ + stdcore.$(OBJEXT) stringutil.$(OBJEXT) timeconvert.$(OBJEXT) \ + tw_signal.$(OBJEXT) twlimits.$(OBJEXT) twlocale.$(OBJEXT) \ + unixexcept.$(OBJEXT) usernotify.$(OBJEXT) \ usernotifystdout.$(OBJEXT) wchar16.$(OBJEXT) libcore_a_OBJECTS = $(am_libcore_a_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) @@ -313,7 +313,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -335,30 +334,31 @@ libcore_a_SOURCES = \ archive.cpp charutil.cpp \ cmdlineparser.cpp codeconvert.cpp core.cpp coreerrors.cpp \ corestrings.cpp crc32.cpp debug.cpp displayencoder.cpp \ - displayutil.cpp error.cpp errorbucketimpl.cpp errortable.cpp \ + displayutil.cpp epoch.cpp error.cpp errorbucketimpl.cpp errortable.cpp \ errorutil.cpp fileerror.cpp fileheader.cpp fsservices.cpp \ growheap.cpp hashtable.cpp haval.cpp msystem.cpp ntmbs.cpp \ refcountobj.cpp serializable.cpp serializer.cpp \ serializerimpl.cpp serializerutil.cpp serstring.cpp \ srefcountobj.cpp srefcounttbl.cpp stdcore.cpp stringutil.cpp \ - timebomb.cpp timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \ + timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \ unixexcept.cpp usernotify.cpp usernotifystdout.cpp \ wchar16.cpp libcore_a_HEADERS = archive.h charutil.h cmdlineparser.h codeconvert.h \ core.h coreerrors.h corestrings.h crc32.h debug.h displayencoder.h \ - displayutil.h error.h errorbucket.h errorbucketimpl.h errorgeneral.h \ + displayutil.h epoch.h error.h errorbucket.h errorbucketimpl.h errorgeneral.h \ errortable.h errorutil.h file.h fileerror.h fileheader.h fixedfilebuf.h \ fsservices.h growheap.h hashtable.h haval.h md5.h msystem.h ntdbs.h \ - ntmbs.h package.h platform.h refcountobj.h resources.h \ + ntmbs.h package.h platform.h refcountobj.h resources.h \ serializable.h serializer.h serializerimpl.h serializerutil.h serstring.h \ sha.h srefcountobj.h srefcounttbl.h stdcore.h stringutil.h tasktimer.h \ - tchar.h timebomb.h timeconvert.h tw_signal.h twlimits.h twlocale.h \ + tchar.h timeconvert.h tw_signal.h twlimits.h twlocale.h \ twstringslang.h typed.h types.h unixexcept.h unixfsservices.h upperbound.h \ usernotify.h usernotifystdout.h wchar16.h libcore_a_LIBADD = @CORE_CRYPT_O@ libcore_a_DEPENDENCIES = @CORE_CRYPT_O@ +CLEANFILES = *.gcno *.gcda all: all-am .SUFFIXES: @@ -545,6 +545,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) diff --git a/src/core/archive.cpp b/src/core/archive.cpp index ab4e7cf..45e388e 100644 --- a/src/core/archive.cpp +++ b/src/core/archive.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -51,28 +51,6 @@ #include "corestrings.h" // for: STR_ERR2_ARCH_CRYPTO_ERR -//============================================================================= -// Utility Functions -//============================================================================= - -/////////////////////////////////////////////////////////////////////////////// -// util_IsDir -- returns true if a given file is a directory -/////////////////////////////////////////////////////////////////////////////// -bool util_IsDir( const TSTRING& fileName ) -{ - cFSStatArgs s; - try - { - iFSServices::GetInstance()->Stat( fileName, s ); - } - catch( eFSServices ) - { - return false; - } - - return( s.mFileType == cFSStatArgs::TY_DIR ); -} - //============================================================================= // eArchiveCrypto //============================================================================= @@ -421,7 +399,7 @@ void cMemoryArchive::AllocateMemory(int len) // throw(eArchive) { // grow the buffer // only error if we are in debug mode -#ifdef _DEBUG +#ifdef DEBUG if (len > mMaxAllocatedLen) ThrowAndAssert(eArchiveOutOfMem()); #endif diff --git a/src/core/archive.h b/src/core/archive.h index 7c25092..e3e483a 100644 --- a/src/core/archive.h +++ b/src/core/archive.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/charutil.cpp b/src/core/charutil.cpp index 48326b8..42ff607 100644 --- a/src/core/charutil.cpp +++ b/src/core/charutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -150,4 +150,4 @@ bool cCharUtil::PopNextChar( TSTRING::const_iterator& cur, return f; } -// eof: charutil.cpp + diff --git a/src/core/charutil.h b/src/core/charutil.h index 6d0c2ff..5717cc9 100644 --- a/src/core/charutil.h +++ b/src/core/charutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/cmdlineparser.cpp b/src/core/cmdlineparser.cpp index 7da836b..4ddc30d 100644 --- a/src/core/cmdlineparser.cpp +++ b/src/core/cmdlineparser.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -78,14 +78,14 @@ void cCmdLineParser::AddArg(int argId, const TSTRING& arg, const TSTRING& alias, /////////////////////////////////////////////////////////////////////////////// // Clear /////////////////////////////////////////////////////////////////////////////// -void cCmdLineParser::Clear() +/*void cCmdLineParser::Clear() { mLastArgInfo.mId = -1; mLastArgInfo.mNumParams = PARAM_INVALID; mArgTable.Clear(); mArgData.clear(); mMutExList.clear(); -} +}*/ /////////////////////////////////////////////////////////////////////////////// // Parse @@ -378,7 +378,7 @@ void cCmdLineParser::AddDependency(int argId1, int argId2, bool mutual ) /////////////////////////////////////////////////////////////////////////////// // TraceContents /////////////////////////////////////////////////////////////////////////////// -#ifdef _DEBUG +#ifdef DEBUG void cCmdLineParser::TraceContents(int dl) { cDebug d("cCmdLineParser::TraceContents"); diff --git a/src/core/cmdlineparser.h b/src/core/cmdlineparser.h index ed78009..b9d0a40 100644 --- a/src/core/cmdlineparser.h +++ b/src/core/cmdlineparser.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -132,14 +132,14 @@ public: // the input was invalid in some way; the actual error can be determined by calling // GetErrorInfo() below. - void Clear(); +// void Clear(); // clear out all information that this class contains bool LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) const; // given an argId, fill out the strings with the argument and alias strings. Returns false // if the argId cannot be found. This method is not very fast, so don't use it often. - #ifdef _DEBUG + #ifdef DEBUG void TraceContents(int dl = -1) ; #endif private: diff --git a/src/core/codeconvert.cpp b/src/core/codeconvert.cpp index 9142da1..7978278 100644 --- a/src/core/codeconvert.cpp +++ b/src/core/codeconvert.cpp @@ -1,6 +1,6 @@ // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -111,6 +111,12 @@ iCodeConverter* iCodeConverter::GetInstance() return m_pInst; } +void iCodeConverter::Finit() +{ + delete m_pInst; + m_pInst = 0; +} + iCodeConverter* iCodeConverter::CreateConverter() { cDebug d("iCodeConverter::CreateConverter()"); @@ -496,7 +502,7 @@ namespace /*Unique*/ d.TraceDebug( "Converted to: %s\n", util_output_bytes( (void*)pConvertedTo, nTo ).c_str() ); char aBuffer[ MB_LEN_MAX ]; -#ifdef _DEBUG +#ifdef DEBUG for( size_t foo = 0; foo < sizeof( aBuffer ); foo++ ) aBuffer[ foo ] = 0xCD; #endif @@ -651,7 +657,7 @@ namespace /*Unique*/ { cDebug d( "tss_Converter< BufferT, SourceT >()" ); -#ifdef _DEBUG +#ifdef DEBUG for( size_t s = nBufferItems; s; s-- ) pBuffer[s] = 0xCD; d.TraceDebug( "sizeof buffer: %d, sizeof source: %d\n", sizeof( BufferT ), sizeof( SourceT ) ); diff --git a/src/core/codeconvert.h b/src/core/codeconvert.h index 543d17a..1539a72 100644 --- a/src/core/codeconvert.h +++ b/src/core/codeconvert.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -93,6 +93,8 @@ class iCodeConverter public: static iCodeConverter* GetInstance(); // Singleton + static void Finit(); + /// Subclass Responsibilities diff --git a/src/core/core.cpp b/src/core/core.cpp index 453b509..039400a 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -60,5 +60,8 @@ cCore::cCore() iCodeConverter::GetInstance(); } +cCore::~cCore() +{ + iCodeConverter::Finit(); +} -// eof: core.cpp diff --git a/src/core/core.h b/src/core/core.h index ce629da..3e17c6b 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -54,6 +54,7 @@ TSS_BeginPackage( cCore ) public: cCore(); + ~cCore(); TSS_EndPackage( cCore ) diff --git a/src/core/coreerrors.cpp b/src/core/coreerrors.cpp index 2c249d0..0a7ca64 100644 --- a/src/core/coreerrors.cpp +++ b/src/core/coreerrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/coreerrors.h b/src/core/coreerrors.h index 19dd721..1b9a17c 100644 --- a/src/core/coreerrors.h +++ b/src/core/coreerrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/corestrings.cpp b/src/core/corestrings.cpp index 18d7648..65f1747 100644 --- a/src/core/corestrings.cpp +++ b/src/core/corestrings.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -70,4 +70,4 @@ TSS_BeginStringtable( cCore ) TSS_EndStringtable( cCore ) -// eof: corestrings.cpp + diff --git a/src/core/corestrings.h b/src/core/corestrings.h index 3071203..3566333 100644 --- a/src/core/corestrings.h +++ b/src/core/corestrings.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/crc32.cpp b/src/core/crc32.cpp index 4c357c9..888a2e7 100644 --- a/src/core/crc32.cpp +++ b/src/core/crc32.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/crc32.h b/src/core/crc32.h index 4b3bf67..2ae013f 100644 --- a/src/core/crc32.h +++ b/src/core/crc32.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/debug.cpp b/src/core/debug.cpp index 7c285bb..229dae1 100644 --- a/src/core/debug.cpp +++ b/src/core/debug.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -307,7 +307,7 @@ void cDebug::DebugOut( const char* lpOutputString, ... ) vsnprintf(buf, 2048, lpOutputString, args); va_end(args); - #ifdef _DEBUG + #ifdef DEBUG TCERR << buf; #endif //_DEBUG diff --git a/src/core/debug.h b/src/core/debug.h index 499fcf7..1210767 100644 --- a/src/core/debug.h +++ b/src/core/debug.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -156,11 +156,11 @@ private: #endif }; -#ifdef _DEBUG +#ifdef DEBUG #define TRACE cDebug::DebugOut #else #define TRACE 1 ? (void)0 : cDebug::DebugOut -#endif // _DEBUG +#endif // DEBUG ////////////////////////////////////////////////////////////////////////////////// // inline implementation diff --git a/src/core/displayencoder.cpp b/src/core/displayencoder.cpp index 3b3536d..1b48e29 100644 --- a/src/core/displayencoder.cpp +++ b/src/core/displayencoder.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -653,6 +653,9 @@ cEncoder::cEncoder( int e, int f ) cEncoder::~cEncoder() { + sack_type::iterator itr; + for( itr = m_encodings.begin(); itr != m_encodings.end(); ++itr) + delete *itr; } bool cEncoder::RoundTrip() const diff --git a/src/core/displayencoder.h b/src/core/displayencoder.h index fb8a775..534830f 100644 --- a/src/core/displayencoder.h +++ b/src/core/displayencoder.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/displayutil.cpp b/src/core/displayutil.cpp index aa45571..42ce9eb 100644 --- a/src/core/displayutil.cpp +++ b/src/core/displayutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -97,4 +97,4 @@ TSTRING cDisplayUtil::FormatMultiLineString( const TSTRING& str, int nOffset, in return( sstr.str() ); } -// eof: displayutil.cpp + diff --git a/src/core/displayutil.h b/src/core/displayutil.h index e9ab6a6..35ee90d 100644 --- a/src/core/displayutil.h +++ b/src/core/displayutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/timebomb.cpp b/src/core/epoch.cpp similarity index 72% rename from src/core/timebomb.cpp rename to src/core/epoch.cpp index 5d023eb..0c0e5ad 100644 --- a/src/core/timebomb.cpp +++ b/src/core/epoch.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -30,44 +30,21 @@ // info@tripwire.org or www.tripwire.org. // /////////////////////////////////////////////////////////////////////////////// -// timebomb.h +// epoch.h #include "stdcore.h" -#include "timebomb.h" +#include "epoch.h" #include #include #include "timeconvert.h" #include "corestrings.h" /////////////////////////////////////////////////////////////////////////////// -// TimeBombExploded() -- Call from main(). Prints out timebomb message and -// returns true if main() should exit. -// -bool TimeBombExploded() +bool CheckEpoch() { +#if SIZEOF_TIME_T == 4 + struct tm time_struct; - /* - memset(&time_struct, 0, sizeof(time_struct)); - time_struct.tm_mday = 25; - time_struct.tm_mon = 0; - time_struct.tm_year = 99; - int64 begin = cTimeUtil::DateToTime( &time_struct ); - - memset(&time_struct, 0, sizeof(time_struct)); - time_struct.tm_mday = 1; - time_struct.tm_mon = 4; - time_struct.tm_year = 99; - int64 end = cTimeUtil::DateToTime( &time_struct ); - - int64 now = time(0); - - if (now < begin || now > end) - { - std::cerr << "This beta version of Tripwire(R) has expired.\n"; - return true; - } - */ - // Many functions will fail as we approach the end of the epoch // Rather than crashing, we will exit with a nice message memset(&time_struct, 0, sizeof(time_struct)); @@ -83,5 +60,8 @@ bool TimeBombExploded() } return false; +#else + return false; +#endif } diff --git a/src/core/timebomb.h b/src/core/epoch.h similarity index 87% rename from src/core/timebomb.h rename to src/core/epoch.h index b9030bc..53cfd6d 100644 --- a/src/core/timebomb.h +++ b/src/core/epoch.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -30,16 +30,16 @@ // info@tripwire.org or www.tripwire.org. // /////////////////////////////////////////////////////////////////////////////// -// timebomb.h +// epoch.h -#ifndef __TIMEBOMB_H -#define __TIMEBOMB_H +#ifndef __EPOCH_H +#define __EPOCH_H /////////////////////////////////////////////////////////////////////////////// -// TimeBombExploded() -- Call from main(). Prints out timebomb message and +// CheckEpoch() -- Call from main(). Prints out timebomb message and // returns true if main() should exit. // -bool TimeBombExploded(); +bool CheckEpoch(); #endif diff --git a/src/core/error.cpp b/src/core/error.cpp index 5c20c23..c58c5e0 100644 --- a/src/core/error.cpp +++ b/src/core/error.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/error.h b/src/core/error.h index bb73cbd..3cafb32 100644 --- a/src/core/error.h +++ b/src/core/error.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/errorbucket.h b/src/core/errorbucket.h index d9f5ac6..e0896ee 100644 --- a/src/core/errorbucket.h +++ b/src/core/errorbucket.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/errorbucketimpl.cpp b/src/core/errorbucketimpl.cpp index 523720d..3b00bd1 100644 --- a/src/core/errorbucketimpl.cpp +++ b/src/core/errorbucketimpl.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/errorbucketimpl.h b/src/core/errorbucketimpl.h index f714e46..5944458 100644 --- a/src/core/errorbucketimpl.h +++ b/src/core/errorbucketimpl.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/errorgeneral.h b/src/core/errorgeneral.h index c78b285..5159df5 100644 --- a/src/core/errorgeneral.h +++ b/src/core/errorgeneral.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/errortable.cpp b/src/core/errortable.cpp index 6c7a24c..8005389 100644 --- a/src/core/errortable.cpp +++ b/src/core/errortable.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -35,7 +35,7 @@ #include "stdcore.h" #include "errortable.h" -#ifdef _DEBUG +#ifdef DEBUG #include "package.h" #include "corestrings.h" #endif @@ -52,7 +52,7 @@ cErrorTable* cErrorTable::GetInstance() /////////////////////////////////////////////////////////////////////////////// // AssertMsgValidity /////////////////////////////////////////////////////////////////////////////// -#ifdef _DEBUG +#ifdef DEBUG void cErrorTable::AssertMsgValidity(const TCHAR* msg) { // Check to see that the first part of this error message is not too long. diff --git a/src/core/errortable.h b/src/core/errortable.h index dbd0632..3fca130 100644 --- a/src/core/errortable.h +++ b/src/core/errortable.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -66,14 +66,14 @@ public: static cErrorTable* GetInstance(); private: - #ifdef _DEBUG + #ifdef DEBUG static void AssertMsgValidity(const TCHAR* msg); #endif }; inline void cErrorTable::Put( const eError& e, const TCHAR* msg ) { - #ifdef _DEBUG + #ifdef DEBUG AssertMsgValidity(msg); #endif diff --git a/src/core/errorutil.cpp b/src/core/errorutil.cpp index e4f7af5..b08d06d 100644 --- a/src/core/errorutil.cpp +++ b/src/core/errorutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/errorutil.h b/src/core/errorutil.h index 4b95b6f..1a40b3d 100644 --- a/src/core/errorutil.h +++ b/src/core/errorutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/file.h b/src/core/file.h index b261da2..6b50a87 100644 --- a/src/core/file.h +++ b/src/core/file.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -138,13 +138,47 @@ public: }; -#if USES_DEVICE_PATH -class cDevicePath +class cDosPath { public: static TSTRING AsPosix(const TSTRING& in); static TSTRING AsNative(const TSTRING& in); + static bool IsAbsolutePath(const TSTRING& in); + static TSTRING BackupName(const TSTRING& in); }; + +class cArosPath +{ +public: + static TSTRING AsPosix(const TSTRING& in); + static TSTRING AsNative(const TSTRING& in); + static bool IsAbsolutePath(const TSTRING& in); +}; + +class cRiscosPath +{ +public: + static TSTRING AsPosix(const TSTRING& in); + static TSTRING AsNative(const TSTRING& in); + static bool IsAbsolutePath(const TSTRING& in); +}; + +class cRedoxPath +{ +public: + static TSTRING AsPosix(const TSTRING& in); + static TSTRING AsNative(const TSTRING& in); + static bool IsAbsolutePath(const TSTRING& in); +}; + +#if IS_DOS_DJGPP +#define cDevicePath cDosPath +#elif IS_AROS +#define cDevicePath cArosPath +#elif IS_RISCOS +#define cDevicePath cRiscosPath +#elif IS_REDOX +#define cDevicePath cRedoxPath #endif diff --git a/src/core/file_unix.cpp b/src/core/file_unix.cpp index d896cac..8144aa0 100644 --- a/src/core/file_unix.cpp +++ b/src/core/file_unix.cpp @@ -1,6 +1,6 @@ // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -62,6 +62,10 @@ #include "core/fsservices.h" #include "core/errorutil.h" +#if IS_RISCOS +#include +#endif + /////////////////////////////////////////////////////////////////////////// // cFile_i : Insulated implementation for cFile objects. /////////////////////////////////////////////////////////////////////////// @@ -79,28 +83,28 @@ struct cFile_i //Ctor cFile_i::cFile_i() : - mpCurrStream(NULL) + m_fd(-1), mpCurrStream(NULL), mFlags(0) {} //Dtor cFile_i::~cFile_i() { if (mpCurrStream != NULL) - fclose( mpCurrStream ); - mpCurrStream = NULL; - -#if IS_AROS - if( mFlags & cFile::OPEN_LOCKED_TEMP ) { - // unlink this file - if( 0 != unlink(mFileName.c_str())) - { - throw( eFileOpen( mFileName, iFSServices::GetInstance()->GetErrString() ) ); - } - } -#endif + fclose( mpCurrStream ); + mpCurrStream = NULL; - mFileName.empty(); +#if !CAN_UNLINK_WHILE_OPEN // so unlink after close instead + if( mFlags & cFile::OPEN_LOCKED_TEMP ) + { + // unlink this file + if( 0 != unlink(mFileName.c_str())) + { + throw( eFileOpen( mFileName, iFSServices::GetInstance()->GetErrString() ) ); + } + } +#endif + } } /////////////////////////////////////////////////////////////////////////// @@ -205,7 +209,7 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags ) } mpData->m_fd = fh; -#if !IS_AROS +#if CAN_UNLINK_WHILE_OPEN if( flags & OPEN_LOCKED_TEMP ) { // unlink this file @@ -322,7 +326,7 @@ cFile::File_t cFile::Seek( File_t offset, SeekFrom From) const //throw(eFile) if (fseeko( mpData->mpCurrStream, offset, apiFrom ) != 0) { - #ifdef _DEBUG + #ifdef DEBUG cDebug d("cFile::Seek"); d.TraceDebug("Seek failed!\n"); #endif @@ -449,31 +453,46 @@ void cFile::Truncate( File_t offset ) // throw(eFile) } -#if USES_DEVICE_PATH -// For paths of type DH0:/dir/file -TSTRING cDevicePath::AsPosix( const TSTRING& in ) +///////////////////////////////////////////////////////////////////////// +// Platform path conversion methods +///////////////////////////////////////////////////////////////////////// + +bool cDosPath::IsAbsolutePath(const TSTRING& in) +{ + if (in.empty()) + return false; + + if (in[0] == '/') + return true; + + if (in.length() >= 2 && in[1] == ':') + return true; + + return false; +} + +// For paths of type C:\DOS +TSTRING cDosPath::AsPosix( const TSTRING& in ) { if (in[0] == '/') + { return in; + } -#if IS_DOS_DJGPP - TSTRING out = "/dev/" + in; + TSTRING out = (cDosPath::IsAbsolutePath(in)) ? ("/dev/" + in) : in; std::replace(out.begin(), out.end(), '\\', '/'); -#else - TSTRING out = '/' + in; -#endif - - std::replace(out.begin(), out.end(), ':', '/'); + out.erase( std::remove(out.begin(), out.end(), ':'), out.end()); return out; } -TSTRING cDevicePath::AsNative( const TSTRING& in ) +TSTRING cDosPath::AsNative( const TSTRING& in ) { if (in[0] != '/') + { return in; + } -#if IS_DOS_DJGPP if (in.find("/dev") != 0 || in.length() < 6) return in; @@ -482,18 +501,181 @@ TSTRING cDevicePath::AsNative( const TSTRING& in ) if (in.length() >= 8) out.append(in.substr(7)); - - return out; - -#elif IS_AROS - int x = 1; - for ( x; in[x] == '/' && x buf(buf_size); + __riscosify(in.c_str(), 0,0, &buf[0], buf_size, 0); + if(buf[0]) + { + out.assign(&buf[0]); + return out; + } + return in; +#else + return in; #endif +} + + +///////////////////////////////////////////////////////////////////////// +bool cRedoxPath::IsAbsolutePath(const TSTRING& in) +{ + if (in.empty()) + return false; + + if (in[0] == '/') + return true; + + if (in.find(":") != std::string::npos) + return true; + + return false; +} + +// For paths of type file:/dir/file +TSTRING cRedoxPath::AsPosix( const TSTRING& in ) +{ + if (in[0] == '/') + { + return in; + } + + TSTRING out = IsAbsolutePath(in) ? '/' + in : in; + std::string::size_type colon = out.find_first_of(":"); + if( colon != std::string::npos ) + out.erase(colon, 1); + return out; +} + +TSTRING cRedoxPath::AsNative( const TSTRING& in ) +{ + if (in[0] != '/') + { + return in; + } + + std::string::size_type drive = in.find_first_not_of("/"); + TSTRING out = (drive != std::string::npos) ? in.substr(drive) : in; + TSTRING::size_type slash = out.find_first_of('/'); + if(slash != std::string::npos) + out.insert(slash, ":"); + else + out.append(":/"); + + return out; +} diff --git a/src/core/fileerror.cpp b/src/core/fileerror.cpp index e925e13..5c153b4 100644 --- a/src/core/fileerror.cpp +++ b/src/core/fileerror.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/fileerror.h b/src/core/fileerror.h index 48b54b6..0789d0f 100644 --- a/src/core/fileerror.h +++ b/src/core/fileerror.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/fileheader.cpp b/src/core/fileheader.cpp index cf0fca3..a6cc83e 100644 --- a/src/core/fileheader.cpp +++ b/src/core/fileheader.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -111,7 +111,7 @@ void cFileHeaderID::Write(iSerializer* pSerializer) const // throw (eSerializer, cFileHeader::cFileHeader() : mVersion(0) { -#ifdef _DEBUG +#ifdef DEBUG mEncoding = LAST_ENCODING; // set to invalid value so we can assert on write #else mEncoding = NO_ENCODING; @@ -213,7 +213,7 @@ void cFileHeader::Read(iSerializer* pSerializer, int32 /*version*/) // throw (eS void cFileHeader::Write(iSerializer* pSerializer) const // throw (eSerializer, eArchive) { -#ifdef _DEBUG +#ifdef DEBUG // check that we set some values cFileHeaderID id; ASSERT(mID != id); diff --git a/src/core/fileheader.h b/src/core/fileheader.h index cb5806c..3aa3214 100644 --- a/src/core/fileheader.h +++ b/src/core/fileheader.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/fixedfilebuf.h b/src/core/fixedfilebuf.h index 8ce2d6e..37a9352 100644 --- a/src/core/fixedfilebuf.h +++ b/src/core/fixedfilebuf.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/fsservices.cpp b/src/core/fsservices.cpp index 7f68d62..f4e1861 100644 --- a/src/core/fsservices.cpp +++ b/src/core/fsservices.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/fsservices.h b/src/core/fsservices.h index f2f4249..aa93ba1 100644 --- a/src/core/fsservices.h +++ b/src/core/fsservices.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -133,7 +133,8 @@ struct cFSStatArgs { TY_FIFO, TY_SOCK, TY_DOOR, - TY_PORT + TY_PORT, + TY_NAMED }; // attr is fs dependent? @@ -290,8 +291,6 @@ class iFSServices virtual bool Rename( const TSTRING& strOldName, const TSTRING& strNewName, bool fOverWrite = true ) const = 0; // rename a file - virtual bool GetOwnerForFile( const TSTRING& tstrFilename, TSTRING& tstrUser ) const = 0; - virtual bool GetGroupForFile( const TSTRING& tstrFilename, TSTRING& tstrGroup ) const = 0; virtual bool GetUserName( uid_t user_id, TSTRING& tstrUser ) const = 0; virtual bool GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const = 0; diff --git a/src/core/growheap.cpp b/src/core/growheap.cpp index e1142ff..5cb10c1 100644 --- a/src/core/growheap.cpp +++ b/src/core/growheap.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/growheap.h b/src/core/growheap.h index d255480..fd2e31e 100644 --- a/src/core/growheap.h +++ b/src/core/growheap.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/hashtable.cpp b/src/core/hashtable.cpp index dfe3ad6..69445f7 100644 --- a/src/core/hashtable.cpp +++ b/src/core/hashtable.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/hashtable.h b/src/core/hashtable.h index 658905e..2944ea3 100644 --- a/src/core/hashtable.h +++ b/src/core/hashtable.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -172,7 +172,7 @@ public: int32 GetNumValues() const { return mValuesInTable; }; // returns number of table entries filled -#ifdef _DEBUG +#ifdef DEBUG void TraceDiagnostics() const; // traces hash table statistics #endif @@ -254,10 +254,14 @@ inline void cHashTableIter::SeekNextV { if(mpCurNode) mpCurNode = mpCurNode->next; - //mCurIndex++; - while((! mpCurNode) && (mCurIndex < mHashTable.mTableSize)) + + // if we're out of range, bail out w/o incrementing index + if(mCurIndex >= mHashTable.mTableSize) + return; + + while((! mpCurNode) && (++mCurIndex < mHashTable.mTableSize)) { - mpCurNode = mHashTable.mTable[++mCurIndex]; + mpCurNode = mHashTable.mTable[mCurIndex]; } } @@ -316,6 +320,7 @@ cHashTable::~cHashTable() } } } + delete [] mTable; } //////////////////////////////////////////////////////////////////////////////// @@ -503,7 +508,7 @@ uint32 cHashTable::Hash( const KEY_TY return hindex; } -#ifdef _DEBUG +#ifdef DEBUG template void cHashTable::TraceDiagnostics() const @@ -537,7 +542,7 @@ void cHashTable::TraceDiagnostics() c d.TraceDebug("-- Slots with >1 item: %d (%lf %%)\n",numMultiSlot, ((double)numMultiSlot / (double)slotsFilled) * 100.0); d.TraceDebug("--------------------------------------------------\n"); } -#endif // _DEBUG +#endif // DEBUG #endif //__HASHTABLE_H diff --git a/src/core/haval.cpp b/src/core/haval.cpp index cffc303..a17fbb1 100644 --- a/src/core/haval.cpp +++ b/src/core/haval.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -275,6 +275,7 @@ static uint8 padding[128] = { /* constants for padding */ } \ } +#if 0 //unused in OST /* hash a string */ void haval_string (char *string, uint8 fingerprint[FPTLEN >> 3]) @@ -330,6 +331,7 @@ void haval_stdin () putchar(fingerprint[i]); } } +#endif /* initialization */ void haval_start (haval_state *state) diff --git a/src/core/haval.h b/src/core/haval.h index e9489dd..975614d 100644 --- a/src/core/haval.h +++ b/src/core/haval.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -117,10 +117,12 @@ typedef struct { #define P_(s) s //Old prototyping stuff... I will ignore it for now. - +#if 0 //unused in OST void haval_string P_((char *, uint8 *)); /* hash a string */ int haval_file P_((char *, uint8 *)); /* hash a file */ void haval_stdin P_((void)); /* filter -- hash input from stdin */ +#endif + void haval_start P_((haval_state *)); /* initialization */ void haval_hash P_((haval_state* state, uint8* str, int str_len)); void haval_end P_((haval_state *, uint8 *)); /* finalization */ diff --git a/src/core/md5.cpp b/src/core/md5.cpp index 1a265b7..9e0e313 100644 --- a/src/core/md5.cpp +++ b/src/core/md5.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/md5.h b/src/core/md5.h index d82b54b..4686182 100644 --- a/src/core/md5.h +++ b/src/core/md5.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/msystem.cpp b/src/core/msystem.cpp index a4a120a..e122fd1 100644 --- a/src/core/msystem.cpp +++ b/src/core/msystem.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -78,7 +78,7 @@ #include #include #include -#if defined(HAVE_MALLOC_H) +#if HAVE_MALLOC_H && !IS_AROS #include #endif #include @@ -94,6 +94,13 @@ #include #include "msystem.h" +#if IS_REDOX +#define setuid(x) sleep(0) +#define setgid(x) sleep(0) +#endif + + + /* * signal type */ diff --git a/src/core/msystem.h b/src/core/msystem.h index 9f0a13e..b5a8431 100644 --- a/src/core/msystem.h +++ b/src/core/msystem.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/ntdbs.h b/src/core/ntdbs.h index 81ae8f2..07c29ea 100644 --- a/src/core/ntdbs.h +++ b/src/core/ntdbs.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/ntmbs.cpp b/src/core/ntmbs.cpp index 94de08c..f0ba58a 100644 --- a/src/core/ntmbs.cpp +++ b/src/core/ntmbs.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -46,7 +46,7 @@ // Module-wide Helpers //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#ifndef TSS_Raise // Should add file and line info in _DEBUG mode!!!! +#ifndef TSS_Raise // Should add file and line info in DEBUG mode!!!! #define TSS_Raise( Xcpt, pkg, ids ) \ throw Xcpt( TSS_GetString( pkg, ids ) ) @@ -244,5 +244,5 @@ tss::mbscount( const_ntmbs_t psz ) return nCount; } -// eof: ntmbs.cpp + diff --git a/src/core/ntmbs.h b/src/core/ntmbs.h index 4b792f0..094f646 100644 --- a/src/core/ntmbs.h +++ b/src/core/ntmbs.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/package.h b/src/core/package.h index ac5e6a8..d8459e5 100644 --- a/src/core/package.h +++ b/src/core/package.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -142,17 +142,17 @@ Messages m_messages // Decare a Stringtable -#ifdef _DEBUG +#ifdef DEBUG #define TSS_BeginStringtable( pkg ) \ void pkg::LoadStrings() \ { cDebug d( #pkg "::LoadStrings()" ); \ d.TraceDebug("Loading strings for " #pkg " package.\n"); \ Messages::Pair astr[] = { // Define a Stringtable -#else // _DEBUG +#else // DEBUG #define TSS_BeginStringtable( pkg ) \ void pkg::LoadStrings() \ { Messages::Pair astr[] = { // Define a Stringtable -#endif // _DEBUG +#endif // DEBUG #define TSS_EndStringtable( pkg ) \ }; m_messages.Put( \ diff --git a/src/core/platform.h b/src/core/platform.h index 7e2bc47..1c2a849 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -64,6 +64,9 @@ #define OS_DARWIN 0x0304 #define OS_DRAGONFLYBSD 0x0305 #define OS_MIDNIGHTBSD 0x0306 +#define OS_MIRBSD 0x0307 +#define OS_BITRIG 0x0308 +#define OS_LIBERTYBSD 0x0309 #define OS_SOLARIS 0x0400 #define OS_AIX 0x0401 @@ -80,6 +83,9 @@ #define OS_MINT 0x0507 #define OS_AROS 0x0508 #define OS_RTEMS 0x0509 +#define OS_RISCOS 0x050A +#define OS_REDOX 0x050B +#define OS_QNX 0x050C #define COMP_UNKNOWN 0 #define COMP_GCC 0x0001 @@ -130,8 +136,18 @@ #elif defined(__linux__) #define OS OS_LINUX #define IS_LINUX 1 - - + + +// A herd of BSDs. Have to detect MidnightBSD before FreeBSD, and MirOS & Bitrig before OpenBSD +// because they also define symbols for their ancestor BSDs. +#elif defined(__DragonFly__) + #define OS OS_DRAGONFLYBSD + #define IS_DRAGONFLYBSD 1 + +#elif defined(__MidnightBSD__) + #define OS OS_MIDNIGHTBSD + #define IS_MIDNIGHTBSD 1 + #elif defined(__FreeBSD__) #define OS OS_FREEBSD #define IS_FREEBSD 1 @@ -140,6 +156,18 @@ #define OS OS_NETBSD #define IS_NETBSD 1 +#elif defined(__MirBSD__) + #define OS OS_MIRBSD + #define IS_MIRBSD 1 + +#elif defined(__Bitrig__) + #define OS OS_BITRIG + #define IS_BITRIG 1 + +#elif defined(TW_LibertyBSD) + #define OS OS_LIBERTYBSD + #define IS_LIBERTYBSD 1 + #elif defined(__OpenBSD__) #define OS OS_OPENBSD #define IS_OPENBSD 1 @@ -148,14 +176,6 @@ #define OS OS_DARWIN #define IS_DARWIN 1 -#elif defined(__DragonFly__) - #define OS OS_DRAGONFLYBSD - #define IS_DRAGONFLYBSD 1 - -#elif defined(__MidnightBSD__) - #define OS OS_MIDNIGHTBSD - #define IS_MIDNIGHTBSD 1 - #elif defined(__sun) #define OS OS_SOLARIS @@ -209,14 +229,23 @@ #elif defined(__AROS__) #define OS OS_AROS #define IS_AROS 1 - + #elif defined(__rtems__) #define OS OS_RTEMS #define IS_RTEMS 1 -#else -// OK for OS not to resolve, it's being phased out. -// #error Unknown OS +#elif defined(__riscos__) + #define OS OS_RISCOS + #define IS_RISCOS 1 + +#elif defined(__redox__) + #define OS OS_REDOX + #define IS_REDOX 1 + +#elif defined(__QNX__) + #define OS OS_QNX + #define IS_QNX 1 + #endif @@ -297,19 +326,21 @@ #define SUPPORTS_MEMBER_TEMPLATES ( ! IS_SUNPRO ) #define SUPPORTS_EXPLICIT_TEMPLATE_FUNC_INST ( ! IS_SUNPRO ) -#define SUPPORTS_ST_BLOCKS (!IS_DOS_DJGPP) #define SUPPORTS_POSIX_SIGNALS (!IS_DOS_DJGPP) -#define SUPPORTS_NETWORKING (!IS_SORTIX && !IS_DOS_DJGPP) -#define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS) -#define NEEDS_SWAB_IMPL (IS_SYLLABLE || IS_ANDROID || IS_SORTIX) +#define SUPPORTS_NETWORKING (!IS_SORTIX && !IS_DOS_DJGPP && !IS_REDOX) +#define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS && !IS_RISCOS) +#define NEEDS_SWAB_IMPL (IS_CYGWIN || IS_SYLLABLE || IS_ANDROID || IS_SORTIX) #define USES_MBLEN (!IS_ANDROID && !IS_AROS) -#define USES_DEVICE_PATH (IS_AROS || IS_DOS_DJGPP) +#define USES_DEVICE_PATH (IS_AROS || IS_DOS_DJGPP || IS_RISCOS || IS_REDOX) #define ICONV_CONST_SOURCE (IS_MINIX) #define SUPPORTS_DIRECT_IO (IS_LINUX) // Linux is the only platform where direct i/o hashing has been tested & works properly so far. -#define SUPPORTS_TERMIOS (!IS_RTEMS) +#define SUPPORTS_TERMIOS (!IS_RTEMS && !IS_REDOX) // RTEMS errors are probably just a buildsys issue & this will change or go away. +// Redox will probably implement this in the future. + +#define CAN_UNLINK_WHILE_OPEN (!IS_AROS && !IS_RISCOS && !IS_REDOX && !IS_DOS_DJGPP) #define SUPPORTS_DOUBLE_SLASH_PATH (IS_CYGWIN) // POSIX standard says paths beginning with 2 slashes are "implementation defined" @@ -318,6 +349,8 @@ // which uses this syntax for UNC paths. So we'll allow leading double slashes there, but // continue removing them on all other platforms +#define USE_DEV_URANDOM (HAVE_DEV_URANDOM && ENABLE_DEV_URANDOM) + //============================================================================= // Miscellaneous // diff --git a/src/core/refcountobj.cpp b/src/core/refcountobj.cpp index f8df324..5ed4d08 100644 --- a/src/core/refcountobj.cpp +++ b/src/core/refcountobj.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -41,7 +41,7 @@ #include "errorutil.h" -#ifdef _DEBUG +#ifdef DEBUG int cRefCountObj::objectCounter = 0; int cRefCountObj::referenceCounter = 0; @@ -68,7 +68,7 @@ struct cRefCountObj_Debug } } gRefCountObj_Debug; -#endif // _DEBUG +#endif // DEBUG cRefCountObj::cRefCountObj() { @@ -76,7 +76,7 @@ cRefCountObj::cRefCountObj() //std::cout << "Allocated RefObj(" << std::hex << (int)this << ")\n"; -#ifdef _DEBUG +#ifdef DEBUG ++objectCounter; ++referenceCounter; @@ -95,7 +95,7 @@ cRefCountObj::~cRefCountObj() //std::cout << "Deleted RefObj(" << std::hex << (int)this << ")\n"; -#ifdef _DEBUG +#ifdef DEBUG --objectCounter; cDebug d("cRefCountObj::~cRefCountObj"); d.TraceNever("Object Destroyed[%p] %s Objects Left = %d\n", this, typeid(*this).name(), objectCounter); @@ -128,7 +128,7 @@ void cRefCountObj::AddRef() const ++mRefCount; - #ifdef _DEBUG + #ifdef DEBUG ++referenceCounter; #endif } @@ -140,7 +140,7 @@ void cRefCountObj::Release() const Delete(); } - #ifdef _DEBUG + #ifdef DEBUG --referenceCounter; #endif } diff --git a/src/core/refcountobj.h b/src/core/refcountobj.h index 68f39f7..96b669c 100644 --- a/src/core/refcountobj.h +++ b/src/core/refcountobj.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -77,7 +77,7 @@ protected: private: mutable int mRefCount; -#ifdef _DEBUG +#ifdef DEBUG private: static int objectCounter; static int referenceCounter; diff --git a/src/core/resources.h b/src/core/resources.h index 6ef4161..5a64818 100644 --- a/src/core/resources.h +++ b/src/core/resources.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -241,7 +241,7 @@ Resource_Class::Get( ConstKeyRef id ) const if ( at == m_table.end() ) { - #ifdef _DEBUG + #ifdef DEBUG std::cerr << "*** Error Resource_Class::Get() [" __FILE__ ":" << __LINE__ << "]: Resource not found\n"; #endif diff --git a/src/core/serializable.cpp b/src/core/serializable.cpp index 7c559df..6543021 100644 --- a/src/core/serializable.cpp +++ b/src/core/serializable.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/serializable.h b/src/core/serializable.h index f5a5325..3fd3cd1 100644 --- a/src/core/serializable.h +++ b/src/core/serializable.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/serializer.cpp b/src/core/serializer.cpp index f80ae8c..0d45030 100644 --- a/src/core/serializer.cpp +++ b/src/core/serializer.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/serializer.h b/src/core/serializer.h index 036a24e..92d2cf1 100644 --- a/src/core/serializer.h +++ b/src/core/serializer.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/serializerimpl.cpp b/src/core/serializerimpl.cpp index 8c9aaa0..e9bd5a8 100644 --- a/src/core/serializerimpl.cpp +++ b/src/core/serializerimpl.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -274,7 +274,7 @@ iTypedSerializable* cSerializerImpl::ReadObjectDynCreate() // unable to find the creation function... d.TraceError("Unable to find creation function for non-ref counted object %d\n", crc); TOSTRINGSTREAM str; - #ifdef _DEBUG + #ifdef DEBUG // Let's only report the actual crc in debug mode str << (int32)crc << std::ends; #endif diff --git a/src/core/serializerimpl.h b/src/core/serializerimpl.h index 273672c..f054bc9 100644 --- a/src/core/serializerimpl.h +++ b/src/core/serializerimpl.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/serializerutil.cpp b/src/core/serializerutil.cpp index 3dd021d..7bbc33e 100644 --- a/src/core/serializerutil.cpp +++ b/src/core/serializerutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/serializerutil.h b/src/core/serializerutil.h index 1aeb75c..9954dee 100644 --- a/src/core/serializerutil.h +++ b/src/core/serializerutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/serstring.cpp b/src/core/serstring.cpp index 84b8084..073c919 100644 --- a/src/core/serstring.cpp +++ b/src/core/serstring.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/serstring.h b/src/core/serstring.h index 7037413..f5ce84f 100644 --- a/src/core/serstring.h +++ b/src/core/serstring.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/sha.cpp b/src/core/sha.cpp index b58a4a0..4ab1b02 100644 --- a/src/core/sha.cpp +++ b/src/core/sha.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/sha.h b/src/core/sha.h index ea1880f..d0a57b9 100644 --- a/src/core/sha.h +++ b/src/core/sha.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/srefcountobj.cpp b/src/core/srefcountobj.cpp index da2a5c2..8bbb404 100644 --- a/src/core/srefcountobj.cpp +++ b/src/core/srefcountobj.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/srefcountobj.h b/src/core/srefcountobj.h index 61080aa..4046943 100644 --- a/src/core/srefcountobj.h +++ b/src/core/srefcountobj.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/srefcounttbl.cpp b/src/core/srefcounttbl.cpp index 3e88c88..06324a5 100644 --- a/src/core/srefcounttbl.cpp +++ b/src/core/srefcounttbl.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -119,7 +119,7 @@ int cSerRefCountTable::Add(const iSerRefCountObj* pObj, int id) // creates a new cSerRefCountTable void cSerRefCountTableMap::AddSerializer(const cSerializer* pSerializer) { - #ifdef _DEBUG + #ifdef DEBUG // make sure we don't have this serialzier in here yet { std::map::iterator itr; diff --git a/src/core/srefcounttbl.h b/src/core/srefcounttbl.h index cab73db..d7dd536 100644 --- a/src/core/srefcounttbl.h +++ b/src/core/srefcounttbl.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/stdcore.cpp b/src/core/stdcore.cpp index 1798c5b..4d139a9 100644 --- a/src/core/stdcore.cpp +++ b/src/core/stdcore.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,4 +37,4 @@ #include "stdcore.h" -// eof: stdcore.cpp + diff --git a/src/core/stdcore.h b/src/core/stdcore.h index fc5848b..7db5630 100644 --- a/src/core/stdcore.h +++ b/src/core/stdcore.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -62,7 +62,7 @@ #pragma warning( disable: 4100 ) // Formal argument not used #pragma warning( disable: 4710 ) // Compiler did not inline function -#ifndef _DEBUG // ASSERT's are disabled give a lot of these +#ifndef DEBUG // ASSERT's are disabled give a lot of these #pragma warning( disable: 4702 ) // ---Unreachable Code #endif diff --git a/src/core/stringutil.cpp b/src/core/stringutil.cpp index bb3fecc..4662ca4 100644 --- a/src/core/stringutil.cpp +++ b/src/core/stringutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -361,151 +361,3 @@ wc16_string cStringUtil::TstrToWstr( const TSTRING& rhs ) cStringUtil::Convert( lhs, rhs ); return lhs; } - -/////////////////////////////////////////////////////////////////////////////// -// StringIsInteger -- returns true if the string is a length of at least one -// and contains nothing other than [0-9]. -// Used to verify a string is acceptable to pass to atoi() -/////////////////////////////////////////////////////////////////////////////// -#ifdef OLDCODE -bool cStringUtil::StringIsInteger(TCHAR* pStr) -{ - int len = _tcslen(pStr); - - if (len <= 0) - return false; - - for (int i = 0; i < len; ++i) - { - if (pStr[i] < _T('0') || pStr[i] > _T('9')) - return false; - } - - return true; -} -#endif//OLDCODE - -// eof: stringutil.cpp - -/* - - -typedef wchar_t dbchar_t; -typedef char mbchar_t; - -class cMBUCS2Cache -{ -public: - cMBUCS2Cache(); - ~cMBUCS2Cache(); - - bool Convert(dbchar_t& ret, mbchar_t* pMBChar); - // returns false if conversion could not be done - void Add(mbchar_t* pMBchar, int mblen); - // add a mb char def to the chache - -protected: - struct Element - { - union - { - Element* mpNext; // points to another Element[256] - dbchar_t mUCS2; - }; - - enum ElementDefinition { UNDEFINED, UCS2, CONTINUES }; - short mElementDefinition; - - Element() { mElementDefinition = UNDEFINED; } - ~Element() { if (mElementDefinition == CONTINUES) delete mpNext; } - }; - - Element mTop[256]; -}; - - -cMBUCS2Cache::cMBUCS2Cache() -{ -} - -cMBUCS2Cache::~cMBUCS2Cache() -{ -} - -// returns false if conversion could not be done -bool cMBUCS2Cache::Convert(dbchar_t& ret, mbchar_t* pMBChar) -{ - Element* pNode = mTop; - while (pNode[*pMBChar].mElementDefinition == Element::CONTINUES) - { - pNode = pNode[*pMBChar].mpNext; - ++pMBChar; - } - - if (pNode[*pMBChar].mElementDefinition == Element::UCS2) - { - ret = pNode[*pMBChar].mUCS2; - return true; - } - - return false; -} - -// add a mb char def to the chache -void cMBUCS2Cache::Add(mbchar_t* pMBchar, int mblen, dbchar_t ucs2) -{ - ASSERT(mblen > 0); - - Element* pNode = mTop; - while (mblen > 1); - { - // this ASSERT fails if there is a UCS2 definition for a mbchar - // whose first few bytes are identical to this char - ASSERT(pNode[*pMBchar].mElementDefinition == Element::UNDEFINED || - pNode[*pMBchar].mElementDefinition == Element::CONTINUES) - - if (pNode[*pMBchar].mElementDefinition == Element::UNDEFINED) - { - pNode[*pMBchar].mElementDefinition = Element::CONINUES; - pNode = pNode[*pMBchar].mpNext = new Element[256]; - } - else - { - pNode = pNode[*pMBchar].mpNext; - } - - --mblen; - ++pMBChar; - } - - // this assert makes sure everything is sane - ASSERT(pNode[*pMBchar].mElementDefinition == Element::UNDEFINED || - (pNode[*pMBchar].mElementDefinition == Element::UCS2 && pNode[*pMBchar].mUCS2 == ucs2)); - - // this assert fails if we attempt to add the same mbchar twice - ASSERT(pNode[*pMBchar].mElementDefinition == Element::UNDEFINED) - - pNode[*pMBchar].mElementDefinition = Element::UCS2; - pNode[*pMBchar].mUCS2 = ucs2; -} -*/ -/* -static inline const byte* tss_hash_key_convert()( const TCHAR* psz, int* const pcbKeyLen ) -{ - *pcbKeyLen = sizeof(TCHAR) * _tcslen( psz ); - return (byte*)psz; -} - -static inline bool tss_hash_key_compare()( const TCHAR* lhs, const TCHAR* rhs ) -{ - return ( _tcscmp( lhs, rhs ) == 0 ); -} - -cHashTable< dbchar_t*, - mbchar_t*, - tss_hash_key_convert, - tss_hash_key_compare > ha; - */ - - - diff --git a/src/core/stringutil.h b/src/core/stringutil.h index c4540ba..003e035 100644 --- a/src/core/stringutil.h +++ b/src/core/stringutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -114,6 +114,7 @@ namespace cStringUtil wc16_string TstrToWstr( const TSTRING& tstr ); // convert a TSTRING to a wc16_string + template void splitstring(IterT& iter, const TSTRING& str, @@ -146,7 +147,7 @@ namespace cStringUtil }//cStringUtil:: - +/* //----------------------------------------------------------------------------- // push_back_string // @@ -199,7 +200,7 @@ namespace std } }; } - +*/ #endif//__STRINGUTIL_H diff --git a/src/core/tasktimer.h b/src/core/tasktimer.h index d65fbe6..59135dd 100644 --- a/src/core/tasktimer.h +++ b/src/core/tasktimer.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -46,105 +46,60 @@ #endif #include +#include + /////////////////////////////////////////////////////////////////////////////// // cTaskTimer -- /////////////////////////////////////////////////////////////////////////////// -template class cTaskTimer { + + public: cTaskTimer(const TSTRING& name) : mName(name), mTotalTime(0), mStartTime(0), mNumStarts(0) {} - ~cTaskTimer(); - void Start(); - void Stop(); + inline ~cTaskTimer() + { + // stop the timer if it is currently running + if(IsRunning()) + Stop(); + + // trace out the time contents... + cDebug d("cTaskTimer"); + d.TraceDebug("----- Time to execute %s: %d (started %d times)\n", mName.c_str(), mTotalTime, mNumStarts); + } + + inline void Start() + { + ASSERT(! IsRunning()); + time_t dummy; + mStartTime = time(&dummy); + mNumStarts++; + } + + void Stop() + { + ASSERT(IsRunning()); + time_t dummy; + mTotalTime += ( time(&dummy) - mStartTime ); + mStartTime = 0; + } + bool IsRunning() { return (mStartTime != 0); } - void Reset() { mNumStarts = mStartTime = mTotalTime = 0 } - int32 GetTotalTime() const; - int32 GetNumTimesStarted() const; // returns the number of times start() was called - const std::string& GetName() const; + void Reset() { mNumStarts = mStartTime = mTotalTime = 0; } + uint32 GetTotalTime() const { return mTotalTime; } + uint32 GetNumTimesStarted() const { return mNumStarts; } + const std::string& GetName() const { return mName; } private: TSTRING mName; - int32 mTotalTime; - TIME_TYPE mStartTime; - int32 mNumStarts; + uint32 mTotalTime; + uint32 mStartTime; + uint32 mNumStarts; + }; -/////////////////////////////////////////////////////////////////////////////// -// cUnixTimeFn -- Unix version, inserts proper function call and overloads -// operator() -/////////////////////////////////////////////////////////////////////////////// -#include -class cUnixTimeFn -{ -public: - typedef uint32 DataType; - - uint32 operator()() - { - return time( &dummy_var ); - } -private: - time_t dummy_var; -}; - -/////////////////////////////////////////////////////////////////////////////// -// cUnixTaskTimer -- the Unix typedef... -/////////////////////////////////////////////////////////////////////////////// -typedef cTaskTimer cUnixTaskTimer; -typedef cUnixTaskTimer cGenericTaskTimer; - - - -//----------------------------------------------------------------------------- -// inline implementation -//----------------------------------------------------------------------------- - -template -inline void cTaskTimer::Start() -{ - ASSERT(! IsRunning()); - TIME_FN GetTime; - mStartTime = GetTime(); - mNumStarts++; -} - -template -inline void cTaskTimer::Stop() -{ - ASSERT(IsRunning()); - TIME_FN GetTime; - mTotalTime += ( GetTime() - mStartTime ); - mStartTime = 0; -} - -template -inline int32 cTaskTimer::GetTotalTime() const -{ - return mTotalTime; -} - -template -inline const std::string& cTaskTimer::GetName() const -{ - return mName -} - -template -inline cTaskTimer::~cTaskTimer() -{ - // stop the timer if it is currently running - if(IsRunning()) - Stop(); - - // trace out the time contents... - cDebug d("cTaskTimer"); - d.TraceDebug("----- Time to execute %s: %d (started %d times)\n", mName.c_str(), mTotalTime, mNumStarts); -} - - #endif diff --git a/src/core/tchar.h b/src/core/tchar.h index 2871a16..c0ac100 100644 --- a/src/core/tchar.h +++ b/src/core/tchar.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/timeconvert.cpp b/src/core/timeconvert.cpp index e7b73da..a0c0b04 100644 --- a/src/core/timeconvert.cpp +++ b/src/core/timeconvert.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/timeconvert.h b/src/core/timeconvert.h index c8cb1a1..aa9210f 100644 --- a/src/core/timeconvert.h +++ b/src/core/timeconvert.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/tw_signal.cpp b/src/core/tw_signal.cpp index e13feb8..9274895 100644 --- a/src/core/tw_signal.cpp +++ b/src/core/tw_signal.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/tw_signal.h b/src/core/tw_signal.h index 573a256..31b0edc 100644 --- a/src/core/tw_signal.h +++ b/src/core/tw_signal.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/twlimits.cpp b/src/core/twlimits.cpp index 9da1234..b43139d 100644 --- a/src/core/twlimits.cpp +++ b/src/core/twlimits.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/twlimits.h b/src/core/twlimits.h index 5625b59..ccf8008 100644 --- a/src/core/twlimits.h +++ b/src/core/twlimits.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/twlocale.cpp b/src/core/twlocale.cpp index bf85ea9..c671dc6 100644 --- a/src/core/twlocale.cpp +++ b/src/core/twlocale.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -104,6 +104,7 @@ void cTWLocale::InitGlobalLocale() } +/* TSTRING cTWLocale::FormatNumberAsHex( int32 i ) { // @@ -125,6 +126,7 @@ TSTRING cTWLocale::FormatNumberAsHex( int32 i ) // return( sstr.str() ); } +*/ template< class numT, class CharT > class cFormatNumberUtil @@ -190,6 +192,7 @@ public: } }; +/* TSTRING cTWLocale::FormatNumberClassic( int32 i ) { TSTRING s; @@ -200,7 +203,7 @@ int32 cTWLocale::FormatNumberClassic( const TSTRING& s ) { return cFormatNumberUtil< long, TCHAR >::Format( s, true ); } - +*/ TSTRING& cTWLocale::FormatNumber( uint64 ui, TSTRING& strBuf ) { diff --git a/src/core/twlocale.h b/src/core/twlocale.h index 18300a7..052a49f 100644 --- a/src/core/twlocale.h +++ b/src/core/twlocale.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -79,12 +79,13 @@ public: static TSTRING& FormatNumber( uint64 ui, TSTRING& strBuf ); static TSTRING& FormatNumber( double d, TSTRING& strBuf ); // returns the locale-specific representation of the given cardinal number - +/* static TSTRING FormatNumberClassic( int32 i ); static int32 FormatNumberClassic( const TSTRING& s ); // returns the C-locale representation of the given cardinal number - - static TSTRING FormatNumberAsHex( int32 x ); +*/ +// disabled this since nobody's using it +// static TSTRING FormatNumberAsHex( int32 x ); // locale-independant static TSTRING& FormatTime( int64 t, TSTRING& strBuf ); diff --git a/src/core/twstringslang.h b/src/core/twstringslang.h index 9734312..82a7adb 100644 --- a/src/core/twstringslang.h +++ b/src/core/twstringslang.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/typed.h b/src/core/typed.h index dbef30f..6515180 100644 --- a/src/core/typed.h +++ b/src/core/typed.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/types.h b/src/core/types.h index 170681a..644b482 100644 --- a/src/core/types.h +++ b/src/core/types.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -36,35 +36,49 @@ #include "platform.h" +#if HAVE_STDINT_H +#include +#endif + + + //----------------------------------------------------------------------------- // standard TSS types //----------------------------------------------------------------------------- -typedef unsigned char byte ; // platform-independent +typedef unsigned char byte ; // platform-independent typedef signed char int8 ; typedef short int16 ; typedef float float32 ; typedef double float64 ; -typedef unsigned char uint8 ; -typedef unsigned short uint16 ; +typedef unsigned char uint8 ; +typedef unsigned short uint16 ; + +#if HAVE_STDINT_H +typedef int32_t int32 ; +typedef uint32_t uint32 ; + +#elif SIZEOF_INT == 4 +typedef int int32 ; +typedef unsigned int uint32 ; -#if SIZEOF_INT == 4 -typedef int int32 ; -typedef unsigned int uint32 ; #elif SIZEOF_LONG == 4 -typedef long int32 ; -typedef unsigned long uint32 ; +typedef long int32 ; +typedef unsigned long uint32 ; #else # error "I don't seem to have a 32-bit integer type on this system." #endif -#if SIZEOF_LONG == 8 +#if HAVE_STDINT_H +typedef int64_t int64 ; +typedef uint64_t uint64 ; +#elif SIZEOF_LONG == 8 typedef long int64 ; -typedef unsigned long uint64 ; +typedef unsigned long uint64 ; #elif SIZEOF_LONG_LONG == 8 typedef long long int64 ; -typedef unsigned long long uint64 ; +typedef unsigned long long uint64 ; #else # error "I don't seem to have a 64-bit integer type on this system." #endif diff --git a/src/core/unixexcept.cpp b/src/core/unixexcept.cpp index 0ab1c19..64eef25 100644 --- a/src/core/unixexcept.cpp +++ b/src/core/unixexcept.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/unixexcept.h b/src/core/unixexcept.h index d9f9f50..460f6ae 100644 --- a/src/core/unixexcept.h +++ b/src/core/unixexcept.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/unixfsservices.cpp b/src/core/unixfsservices.cpp index 54595e4..d1ea0c0 100644 --- a/src/core/unixfsservices.cpp +++ b/src/core/unixfsservices.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -77,6 +77,10 @@ #include +#if IS_REDOX +#define restrict __restrict__ +#endif + #if HAVE_SYS_SOCKET_H # include # include @@ -326,6 +330,7 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const if( ret < 0 ) throw eFSServicesGeneric( strName, iFSServices::GetInstance()->GetErrString() ); +#if HAVE_STRUCT_STAT_ST_RDEV // new stuff 7/17/99 - BAM // if the file is not a device set rdev to zero by hand (most OSs will // do this for us, but some don't) @@ -335,6 +340,7 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const // actual type of the object -- could be a struct (requiring '= {0}' ) util_ZeroMemory( statbuf.st_rdev ); } +#endif //copy information returned by lstat call into the structure passed in stat.gid = statbuf.st_gid; @@ -342,14 +348,21 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const stat.ctime = statbuf.st_ctime; stat.mtime = statbuf.st_mtime; stat.dev = statbuf.st_dev; + +#if HAVE_STRUCT_STAT_ST_RDEV stat.rdev = statbuf.st_rdev; +#else + stat.rdev = 0; +#endif + stat.ino = statbuf.st_ino; stat.mode = statbuf.st_mode; stat.nlink = statbuf.st_nlink; stat.size = statbuf.st_size; stat.uid = statbuf.st_uid; stat.blksize = statbuf.st_blksize; -#if SUPPORTS_ST_BLOCKS + +#if HAVE_STRUCT_STAT_ST_BLOCKS stat.blocks = statbuf.st_blocks; #else stat.blocks = 0; @@ -365,13 +378,19 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const #ifdef S_ISSOCK else if(S_ISSOCK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_SOCK; #endif -#ifdef S_IFDOOR + +#if HAVE_DOOR_CREATE else if(S_ISDOOR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_DOOR; #endif -#ifdef S_IFPORT + +#if HAVE_PORT_CREATE else if(S_ISPORT(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_PORT; #endif - + +#ifdef S_ISNAM + else if(S_ISNAM(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_NAMED; +#endif + else stat.mFileType = cFSStatArgs::TY_INVALID; } @@ -497,43 +516,6 @@ void cUnixFSServices::SetResolveNames(bool resolve) mResolveNames=resolve; } -bool cUnixFSServices::GetOwnerForFile( const TSTRING& tstrFilename, TSTRING& tstrUser ) const -{ - bool fSuccess = true; - - struct stat statbuf; - int ret = lstat(tstrFilename.c_str(), &statbuf); - if(ret < 0) - { - fSuccess = false; - } - else - { - fSuccess = GetUserName(statbuf.st_uid, tstrUser); - } - - return( fSuccess ); -} - - -bool cUnixFSServices::GetGroupForFile( const TSTRING& tstrFilename, TSTRING& tstrGroup ) const -{ - bool fSuccess = true; - struct stat statbuf; - - int ret = lstat(tstrFilename.c_str(), &statbuf); - if(ret < 0) - { - fSuccess = false; - } - else - { - fSuccess = GetGroupName(statbuf.st_gid, tstrGroup); - } - - return( fSuccess ); -} - bool cUnixFSServices::GetUserName( uid_t user_id, TSTRING& tstrUser ) const { @@ -564,7 +546,8 @@ bool cUnixFSServices::GetUserName( uid_t user_id, TSTRING& tstrUser ) const bool cUnixFSServices::GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const { bool fSuccess = true; - + +#if !IS_REDOX if( mResolveNames ) { struct group* pg = getgrgid( group_id ); @@ -578,10 +561,13 @@ bool cUnixFSServices::GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const } else { +#endif std::stringstream sstr; sstr << group_id; tstrGroup = sstr.str(); +#if !IS_REDOX } +#endif return( fSuccess ); } @@ -631,16 +617,24 @@ void cUnixFSServices::ConvertModeToString( uint64 perm, TSTRING& tstrPerm ) cons case S_IFLNK: szPerm[0] = _T('l'); break; -#ifdef S_IFDOOR + +#if HAVE_DOOR_CREATE // Solaris doors case S_IFDOOR: szPerm[0] = _T('D'); break; #endif -#ifdef S_IFPORT + +#if HAVE_PORT_CREATE // Solaris event ports case S_IFPORT: szPerm[0] = _T('P'); break; #endif + +#ifdef S_IFNAM + case S_IFNAM: + szPerm[0] = _T('n'); + break; +#endif break; } @@ -763,12 +757,18 @@ bool cUnixFSServices::GetExecutableFilename( TSTRING& strFullPath, const TSTRING /////////////////////////////////////////////////////////////////////////////// bool cUnixFSServices::FullPath( TSTRING& strFullPath, const TSTRING& strRelPathC, const TSTRING& pathRelFromC ) const { + cDebug d("cUnixFSServices::FullPath"); + d.TraceDebug("strRelPathC = %s, pathRelFromC = %s\n", strRelPathC.c_str(), pathRelFromC.c_str()); + // don't do anything with an empty path if( strRelPathC.empty() ) return false; +#if USES_DEVICE_PATH + TSTRING strRelPath = cDevicePath::AsPosix(strRelPathC); // make non-const temp var +#else TSTRING strRelPath = strRelPathC; // make non-const temp var - +#endif // // get base name (where strRelPath will be relative to), which will either be; // 1. the root directory if strRelPath is an absolute path @@ -781,6 +781,7 @@ bool cUnixFSServices::FullPath( TSTRING& strFullPath, const TSTRING& strRelPathC if( IsRoot( strRelPath ) ) // if it's root, don't monkey with it, just return it. { strFullPath = strRelPath; + d.TraceDebug("Is root; returning %s\n", strFullPath.c_str()); return true; } else @@ -799,18 +800,30 @@ bool cUnixFSServices::FullPath( TSTRING& strFullPath, const TSTRING& strRelPathC try { GetCurrentDir( strFullPath ); +#if USES_DEVICE_PATH + strFullPath = cDevicePath::AsPosix(strFullPath); +#endif util_TrailingSep( strFullPath, false ); } catch( eFSServices& ) { return false; } + + d.TraceDebug("Creating prefix relative to CWD: %s\n", strFullPath.c_str()); } else // we're relative to a given dir { + +#if USES_DEVICE_PATH + strFullPath = cDevicePath::AsPosix(pathRelFromC); +#else strFullPath = pathRelFromC; +#endif util_RemoveDuplicateSeps( strFullPath ); util_TrailingSep( strFullPath, false ); + + d.TraceDebug("Creating prefix from supplied path: %s\n", strFullPath.c_str()); } } @@ -823,6 +836,7 @@ bool cUnixFSServices::FullPath( TSTRING& strFullPath, const TSTRING& strRelPathC int index = 0; while( util_GetNextPathElement( strRelPath, strElem, index++ ) ) { + d.TraceDebug("Path element = %s\n", strElem.c_str()); if( 0 == strElem.compare( _T(".") ) ) { // ignore it @@ -838,8 +852,15 @@ bool cUnixFSServices::FullPath( TSTRING& strFullPath, const TSTRING& strRelPathC strFullPath += TW_SLASH; strFullPath += strElem; } + + d.TraceDebug("FullPath is now %s\n", strFullPath.c_str()); } +#if IS_AROS || IS_REDOX + strFullPath = cDevicePath::AsNative(strFullPath); +#endif + + d.TraceDebug("Done, returning %s\n", strFullPath.c_str()); return true; } diff --git a/src/core/unixfsservices.h b/src/core/unixfsservices.h index 51e6c51..c008dc0 100644 --- a/src/core/unixfsservices.h +++ b/src/core/unixfsservices.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -132,8 +132,6 @@ class cUnixFSServices : public iFSServices virtual bool Rename( const TSTRING& strOldName, const TSTRING& strNewName, bool fOverWrite = true ) const; // rename a file - virtual bool GetOwnerForFile( const TSTRING& tstrFilename, TSTRING& tstrUser ) const; - virtual bool GetGroupForFile( const TSTRING& tstrFilename, TSTRING& tstrGroup ) const; virtual bool GetUserName( uid_t user_id, TSTRING& tstrUser ) const; virtual bool GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const; diff --git a/src/core/upperbound.h b/src/core/upperbound.h index 6fecc17..8dd29dc 100644 --- a/src/core/upperbound.h +++ b/src/core/upperbound.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/usernotify.cpp b/src/core/usernotify.cpp index ba45a0c..c66f549 100644 --- a/src/core/usernotify.cpp +++ b/src/core/usernotify.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/usernotify.h b/src/core/usernotify.h index 4796491..8c61e97 100644 --- a/src/core/usernotify.h +++ b/src/core/usernotify.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/usernotifystdout.cpp b/src/core/usernotifystdout.cpp index d41b0f9..c2bf1a5 100644 --- a/src/core/usernotifystdout.cpp +++ b/src/core/usernotifystdout.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/usernotifystdout.h b/src/core/usernotifystdout.h index e48af7b..92b757b 100644 --- a/src/core/usernotifystdout.h +++ b/src/core/usernotifystdout.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/userstringmem.cpp b/src/core/userstringmem.cpp index ffa84e4..1a20cd2 100644 --- a/src/core/userstringmem.cpp +++ b/src/core/userstringmem.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/userstringmem.h b/src/core/userstringmem.h index 84fcf2a..10f1272 100644 --- a/src/core/userstringmem.h +++ b/src/core/userstringmem.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/wchar16.cpp b/src/core/wchar16.cpp index f7e465d..d2c097b 100644 --- a/src/core/wchar16.cpp +++ b/src/core/wchar16.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/core/wchar16.h b/src/core/wchar16.h index 74abe7f..d4adfad 100644 --- a/src/core/wchar16.h +++ b/src/core/wchar16.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/cryptlib/Makefile.am b/src/cryptlib/Makefile.am index 6ec973b..156082d 100644 --- a/src/cryptlib/Makefile.am +++ b/src/cryptlib/Makefile.am @@ -20,7 +20,7 @@ libcryptlib_a_HEADERS = \ ztrees.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit -CLEANFILES = ../../lib/libcryptlib.a +CLEANFILES = ../../lib/libcryptlib.a *.gcno *.gcda all: $(noinst_LIBRARIES) $(LN) -f $(noinst_LIBRARIES) ../../lib/libcryptlib.a diff --git a/src/cryptlib/Makefile.in b/src/cryptlib/Makefile.in index 84de4fb..4f6d772 100644 --- a/src/cryptlib/Makefile.in +++ b/src/cryptlib/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -303,7 +303,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -334,7 +333,7 @@ libcryptlib_a_HEADERS = \ queue.h rng.h sha.h smartptr.h words.h zbits.h zdeflate.h zinflate.h \ ztrees.h -CLEANFILES = ../../lib/libcryptlib.a +CLEANFILES = ../../lib/libcryptlib.a *.gcno *.gcda all: all-am .SUFFIXES: diff --git a/src/db/Makefile.am b/src/db/Makefile.am index 3488413..68a57ed 100644 --- a/src/db/Makefile.am +++ b/src/db/Makefile.am @@ -13,6 +13,7 @@ libdb_a_HEADERS = \ db.h dberrors.h hierdatabase.h hierdbnode.h hierdbpath.h stddb.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit +CLEANFILES = *.gcno *.gcda all: $(noinst_LIBRARIES) $(AR) ru ../../lib/libtripwire.a $(libdb_a_OBJECTS) diff --git a/src/db/Makefile.in b/src/db/Makefile.in index f80ab34..c875d47 100644 --- a/src/db/Makefile.in +++ b/src/db/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -300,7 +300,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -325,6 +324,7 @@ libdb_a_HEADERS = \ block.h blockfile.h blockrecordarray.h blockrecordfile.h \ db.h dberrors.h hierdatabase.h hierdbnode.h hierdbpath.h stddb.h +CLEANFILES = *.gcno *.gcda all: all-am .SUFFIXES: @@ -511,6 +511,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) diff --git a/src/db/block.h b/src/db/block.h index fca863f..2c948b3 100644 --- a/src/db/block.h +++ b/src/db/block.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/blockfile.cpp b/src/db/blockfile.cpp index d87f3d4..5ff3770 100644 --- a/src/db/blockfile.cpp +++ b/src/db/blockfile.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -326,7 +326,7 @@ void cBlockFile::AssertValid() const // // make sure the archive length and block count match up // - #ifdef _DEBUG + #ifdef DEBUG if (mpArchive->Length() != (GetBlockSize() * GetNumBlocks())) { cDebug d("cBlockFile::AssertValid"); diff --git a/src/db/blockfile.h b/src/db/blockfile.h index 884bb8f..06003f4 100644 --- a/src/db/blockfile.h +++ b/src/db/blockfile.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -46,7 +46,7 @@ #include "block.h" #endif -#ifdef _DEBUG +#ifdef DEBUG #undef _BLOCKFILE_DEBUG // If we dont do this, test does not compile on unix #define _BLOCKFILE_DEBUG // If we dont do this, test does not compile on unix #endif diff --git a/src/db/blockrecordarray.cpp b/src/db/blockrecordarray.cpp index 51b6642..f18ebc3 100644 --- a/src/db/blockrecordarray.cpp +++ b/src/db/blockrecordarray.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/blockrecordarray.h b/src/db/blockrecordarray.h index d973f69..6f0cb42 100644 --- a/src/db/blockrecordarray.h +++ b/src/db/blockrecordarray.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/blockrecordfile.cpp b/src/db/blockrecordfile.cpp index 194a5db..123c714 100644 --- a/src/db/blockrecordfile.cpp +++ b/src/db/blockrecordfile.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -266,11 +266,14 @@ int cBlockRecordFile::FindRoomForData( int32 dataSize ) //throw (eArchive) // first, try the last added to block... // d.TraceDetail( "Looking for room for %d bytes; first trying mLastAddedTo (%d)\n", dataSize, mLastAddedTo ); - util_InitBlockArray( mvBlocks[mLastAddedTo] ); - if( mvBlocks[mLastAddedTo].GetAvailableSpace() >= dataSize ) + if( mLastAddedTo >= 0 ) { - d.TraceDetail( "---Found room in block %d\n", mLastAddedTo ); - return mLastAddedTo; + util_InitBlockArray( mvBlocks[mLastAddedTo] ); + if( mvBlocks[mLastAddedTo].GetAvailableSpace() >= dataSize ) + { + d.TraceDetail( "---Found room in block %d\n", mLastAddedTo ); + return mLastAddedTo; + } } // // ok, I guess we will have to iterate through all the blocks... diff --git a/src/db/blockrecordfile.h b/src/db/blockrecordfile.h index 5a664af..a3ff540 100644 --- a/src/db/blockrecordfile.h +++ b/src/db/blockrecordfile.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/db.cpp b/src/db/db.cpp index 6493d78..16918ca 100644 --- a/src/db/db.cpp +++ b/src/db/db.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -47,5 +47,4 @@ cDb::cDb() } -// eof: db.cpp diff --git a/src/db/db.h b/src/db/db.h index 2102ca9..d1d1df2 100644 --- a/src/db/db.h +++ b/src/db/db.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/dberrors.cpp b/src/db/dberrors.cpp index 4b2d2ed..15c484d 100644 --- a/src/db/dberrors.cpp +++ b/src/db/dberrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/dberrors.h b/src/db/dberrors.h index b4c876d..4f4e6ca 100644 --- a/src/db/dberrors.h +++ b/src/db/dberrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/hierdatabase.cpp b/src/db/hierdatabase.cpp index e90e28a..b94531a 100644 --- a/src/db/hierdatabase.cpp +++ b/src/db/hierdatabase.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/hierdatabase.h b/src/db/hierdatabase.h index 1e3c173..957dbea 100644 --- a/src/db/hierdatabase.h +++ b/src/db/hierdatabase.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/hierdbnode.h b/src/db/hierdbnode.h index 148df88..929c340 100644 --- a/src/db/hierdbnode.h +++ b/src/db/hierdbnode.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/hierdbpath.cpp b/src/db/hierdbpath.cpp index 42c99c4..9da1dc3 100644 --- a/src/db/hierdbpath.cpp +++ b/src/db/hierdbpath.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/hierdbpath.h b/src/db/hierdbpath.h index ab0aea3..fb9c868 100644 --- a/src/db/hierdbpath.h +++ b/src/db/hierdbpath.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/db/stddb.cpp b/src/db/stddb.cpp index 22bd5cc..967418d 100644 --- a/src/db/stddb.cpp +++ b/src/db/stddb.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -38,4 +38,4 @@ #include "stddb.h" -// eof: stddb.cpp + diff --git a/src/db/stddb.h b/src/db/stddb.h index 301ed7a..28b9c51 100644 --- a/src/db/stddb.h +++ b/src/db/stddb.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/Makefile.am b/src/fco/Makefile.am index 10f756d..cb5f50f 100644 --- a/src/fco/Makefile.am +++ b/src/fco/Makefile.am @@ -27,6 +27,7 @@ libfco_a_HEADERS = \ DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit +CLEANFILES = *.gcno *.gcda all: $(noinst_LIBRARIES) $(AR) ru ../../lib/libtripwire.a $(libfco_a_OBJECTS) diff --git a/src/fco/Makefile.in b/src/fco/Makefile.in index cb15522..0300072 100644 --- a/src/fco/Makefile.in +++ b/src/fco/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -308,7 +308,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -346,6 +345,7 @@ libfco_a_HEADERS = \ iterproxy.h parsergenreutil.h propset.h signature.h \ stdfco.h twfactory.h +CLEANFILES = *.gcno *.gcda all: all-am .SUFFIXES: @@ -532,6 +532,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) diff --git a/src/fco/fco.cpp b/src/fco/fco.cpp index 85a88ed..83123ae 100644 --- a/src/fco/fco.cpp +++ b/src/fco/fco.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -57,4 +57,4 @@ iFCO::~iFCO() { } -// eof: fco.cpp + diff --git a/src/fco/fco.h b/src/fco/fco.h index b6db14e..70104fb 100644 --- a/src/fco/fco.h +++ b/src/fco/fco.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcocompare.cpp b/src/fco/fcocompare.cpp index 52465ef..439c7ea 100644 --- a/src/fco/fcocompare.cpp +++ b/src/fco/fcocompare.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcocompare.h b/src/fco/fcocompare.h index 2343286..473213f 100644 --- a/src/fco/fcocompare.h +++ b/src/fco/fcocompare.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcodatasource.h b/src/fco/fcodatasource.h index f103189..6710ed9 100644 --- a/src/fco/fcodatasource.h +++ b/src/fco/fcodatasource.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcodatasourceiter.cpp b/src/fco/fcodatasourceiter.cpp index ce9d68f..b70341b 100644 --- a/src/fco/fcodatasourceiter.cpp +++ b/src/fco/fcodatasourceiter.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcodatasourceiter.h b/src/fco/fcodatasourceiter.h index a8658b7..c5f840c 100644 --- a/src/fco/fcodatasourceiter.h +++ b/src/fco/fcodatasourceiter.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcodatasourceiterimpl.cpp b/src/fco/fcodatasourceiterimpl.cpp index 8ed612b..12a8181 100644 --- a/src/fco/fcodatasourceiterimpl.cpp +++ b/src/fco/fcodatasourceiterimpl.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcodatasourceiterimpl.h b/src/fco/fcodatasourceiterimpl.h index 83ac1c8..39fd047 100644 --- a/src/fco/fcodatasourceiterimpl.h +++ b/src/fco/fcodatasourceiterimpl.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcoerrors.cpp b/src/fco/fcoerrors.cpp index 2117a5d..7e593a7 100644 --- a/src/fco/fcoerrors.cpp +++ b/src/fco/fcoerrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcoerrors.h b/src/fco/fcoerrors.h index 89b4978..56be119 100644 --- a/src/fco/fcoerrors.h +++ b/src/fco/fcoerrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcogenre.h b/src/fco/fcogenre.h index 704a0f1..f6103de 100644 --- a/src/fco/fcogenre.h +++ b/src/fco/fcogenre.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fconame.cpp b/src/fco/fconame.cpp index e73e8ac..2d24c8c 100644 --- a/src/fco/fconame.cpp +++ b/src/fco/fconame.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -97,7 +97,7 @@ cFCOName::cFCOName(iFCONameInfo* pNI) : { SetNameInfo(pNI); mpPathName = new cFCOName_i; -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); cDebug d("cFCOName::cFCOName(iFCONameInfo*)"); d.TraceNever(_T("constructing %X:%X %s (refcount=%d)\n"), this, mpPathName, mDebugStrName.c_str(), mpPathName->GetRefCount()); @@ -111,7 +111,7 @@ cFCOName::cFCOName(const cFCOName& rhs) : mbCaseSensitive(rhs.mbCaseSensitive) { mpPathName->AddRef(); -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); cDebug d("cFCOName::cFCOName(cFCOName&)"); d.TraceNever(_T("constructing %X:%X %s (refcount=%d)\n"), this, mpPathName, mDebugStrName.c_str(), mpPathName->GetRefCount()); @@ -125,7 +125,7 @@ cFCOName::cFCOName(const TSTRING& rhs, iFCONameInfo* pNI) : mpPathName = new cFCOName_i; ParseString(rhs.c_str()); -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); cDebug d("cFCOName::cFCOName(cFCOName&,iFCONameInfo*)"); d.TraceNever(_T("constructing %X:%X %s (refcount=%d)\n"), this, mpPathName, mDebugStrName.c_str(), mpPathName->GetRefCount()); @@ -139,7 +139,7 @@ cFCOName::cFCOName(const TCHAR* rhs, iFCONameInfo* pNI) : mpPathName = new cFCOName_i; ParseString(rhs); -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); cDebug d("cFCOName::cFCOName(cFCOName&,iFCONameInfo*)"); d.TraceNever(_T("constructing %X:%X %s (refcount=%d)\n"), this, mpPathName, mDebugStrName.c_str(), mpPathName->GetRefCount()); @@ -148,7 +148,7 @@ cFCOName::cFCOName(const TCHAR* rhs, iFCONameInfo* pNI) : cFCOName::~cFCOName() { -#ifdef _DEBUG +#ifdef DEBUG cDebug d("cFCOName::~cFCOName()"); d.TraceNever(_T("destructing %X:%X %s (refcount=%d)\n"), this, mpPathName, mDebugStrName.c_str(), mpPathName->GetRefCount()); #endif @@ -168,7 +168,7 @@ void cFCOName::SetNameInfo(iFCONameInfo* pNI) mbCaseSensitive = iTWFactory::GetInstance()->GetNameInfo()->IsCaseSensitive(); mDelimiter = iTWFactory::GetInstance()->GetNameInfo()->GetDelimitingChar(); } -#ifdef _DEBUG +#ifdef DEBUG if( mpPathName != NULL ) // this could be called from the constructor before this is initialized. mDebugStrName = AsString(); #endif @@ -185,7 +185,7 @@ cFCOName& cFCOName::operator = (const cFCOName& rhs) mpPathName->AddRef(); mDelimiter = rhs.mDelimiter; mbCaseSensitive = rhs.mbCaseSensitive; -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); #endif return *this; @@ -194,7 +194,7 @@ cFCOName& cFCOName::operator = (const cFCOName& rhs) cFCOName& cFCOName::operator = (const TSTRING& rhs) { *this = rhs.c_str(); -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); #endif return *this; @@ -210,7 +210,7 @@ cFCOName& cFCOName::operator = (const TCHAR* rhs) mpPathName = new cFCOName_i; } ParseString(rhs); -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); #endif return *this; @@ -320,7 +320,7 @@ void cFCOName::Clear() { Pop(); } -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); #endif } @@ -392,7 +392,7 @@ void cFCOName::Read(iSerializer* pSerializer, int32 version) mbCaseSensitive = true; ParseString(str.c_str()); -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); #endif } @@ -443,7 +443,7 @@ void cFCOName::Push(const TSTRING& str) cFCONameTblNode* pNode = cFCOName_i::msNameTbl.CreateNode(str); mpPathName->mNames.push_back(pNode); -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); #endif } @@ -465,7 +465,7 @@ const TCHAR* cFCOName::Pop() ASSERT(pNode->GetRefCount() > 1); const TCHAR* ret = pNode->GetString(); pNode->Release(); -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); #endif return ret; @@ -489,7 +489,7 @@ const TCHAR* cFCOName::PopFront() ASSERT(pNode->GetRefCount() > 1); const TCHAR* ret = pNode->GetString(); pNode->Release(); -#ifdef _DEBUG +#ifdef DEBUG mDebugStrName = AsString(); #endif return ret; diff --git a/src/fco/fconame.h b/src/fco/fconame.h index daccab0..c3557db 100644 --- a/src/fco/fconame.h +++ b/src/fco/fconame.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -153,7 +153,7 @@ protected: // typedef std::vector ListType; -#ifdef _DEBUG +#ifdef DEBUG TSTRING mDebugStrName; // so we can see this guy's value in the debug window #endif }; diff --git a/src/fco/fconameinfo.h b/src/fco/fconameinfo.h index a277764..3c1b57e 100644 --- a/src/fco/fconameinfo.h +++ b/src/fco/fconameinfo.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fconametbl.cpp b/src/fco/fconametbl.cpp index a331533..002b636 100644 --- a/src/fco/fconametbl.cpp +++ b/src/fco/fconametbl.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -156,7 +156,7 @@ cFCONameTbl::cFCONameTbl(int defSize) : cFCONameTbl::~cFCONameTbl() { -#ifdef _DEBUG +#ifdef DEBUG cDebug d("cFCONameTbl::~cFCONameTbl()"); d.TraceDebug("Tracing cFCONameTblNode hash table statistics:\n"); mTable.TraceDiagnostics(); diff --git a/src/fco/fconametbl.h b/src/fco/fconametbl.h index 16e2301..d21d2c2 100644 --- a/src/fco/fconametbl.h +++ b/src/fco/fconametbl.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fconametranslator.h b/src/fco/fconametranslator.h index 0c6e0f1..57e2bd5 100644 --- a/src/fco/fconametranslator.h +++ b/src/fco/fconametranslator.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcoprop.h b/src/fco/fcoprop.h index df74f7d..f73c634 100644 --- a/src/fco/fcoprop.h +++ b/src/fco/fcoprop.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcopropcalc.h b/src/fco/fcopropcalc.h index f39d30d..0b6454c 100644 --- a/src/fco/fcopropcalc.h +++ b/src/fco/fcopropcalc.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcopropdisplayer.h b/src/fco/fcopropdisplayer.h index 496429b..96d7efd 100644 --- a/src/fco/fcopropdisplayer.h +++ b/src/fco/fcopropdisplayer.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcopropimpl.cpp b/src/fco/fcopropimpl.cpp index 157d071..18a15a9 100644 --- a/src/fco/fcopropimpl.cpp +++ b/src/fco/fcopropimpl.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcopropimpl.h b/src/fco/fcopropimpl.h index 87cdfa9..bc0b2ff 100644 --- a/src/fco/fcopropimpl.h +++ b/src/fco/fcopropimpl.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcopropset.h b/src/fco/fcopropset.h index 8932045..fa21d04 100644 --- a/src/fco/fcopropset.h +++ b/src/fco/fcopropset.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcopropvector.cpp b/src/fco/fcopropvector.cpp index 54c1bde..62564a3 100644 --- a/src/fco/fcopropvector.cpp +++ b/src/fco/fcopropvector.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -366,10 +366,10 @@ bool cFCOPropVector::isExtended(void) const return false; else { - int sum = 0; - for (int i=(*mpBuf).size(); i >= 2; i--) + uint32 sum = 0; + for (uint32 i=(*mpBuf).size()-1; i >= 2; i--) sum += ((*mpBuf)[i]); - return (sum == 0); + return (sum != 0); } } } diff --git a/src/fco/fcopropvector.h b/src/fco/fcopropvector.h index 7e2dc51..e15f331 100644 --- a/src/fco/fcopropvector.h +++ b/src/fco/fcopropvector.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcosetimpl.cpp b/src/fco/fcosetimpl.cpp index 2f271e4..2bc3e1a 100644 --- a/src/fco/fcosetimpl.cpp +++ b/src/fco/fcosetimpl.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcosetimpl.h b/src/fco/fcosetimpl.h index b7d3bef..ae9f98d 100644 --- a/src/fco/fcosetimpl.h +++ b/src/fco/fcosetimpl.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcosetws.h b/src/fco/fcosetws.h index 8f3f8be..5b46e87 100644 --- a/src/fco/fcosetws.h +++ b/src/fco/fcosetws.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -112,7 +112,7 @@ inline void cFCOSetWS::SetSpec(const iFCOSpec* pSpec) inline void cFCOSetWS::Insert(iFCO* pFCO) { // here is the only real work this class does! -#ifdef _DEBUG +#ifdef DEBUG // TODO -- note that this doesn't do any checking if the spec is NULL. I // am not sure if this is the right thing to do or not. if(mpSpec) @@ -127,7 +127,7 @@ inline void cFCOSetWS::Insert(iFCO* pFCO) mpSpec->TraceContents(cDebug::D_ERROR); } } -#endif // _DEBUG +#endif // DEBUG cFCOSetImpl::Insert(pFCO); } diff --git a/src/fco/fcospec.cpp b/src/fco/fcospec.cpp index e281c77..8aeb80a 100644 --- a/src/fco/fcospec.cpp +++ b/src/fco/fcospec.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcospec.h b/src/fco/fcospec.h index 6b7b9f2..f23c1ff 100644 --- a/src/fco/fcospec.h +++ b/src/fco/fcospec.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcospecattr.cpp b/src/fco/fcospecattr.cpp index 341c671..9394c80 100644 --- a/src/fco/fcospecattr.cpp +++ b/src/fco/fcospecattr.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -92,4 +92,10 @@ void cFCOSpecAttr::TraceContents(int dl) const } } +bool cFCOSpecAttr::operator==(const cFCOSpecAttr& rhs) const +{ + return ( (mEmailAddrs == rhs.mEmailAddrs) + && (mName == rhs.mName) + && (mSeverity == rhs.mSeverity)); +} diff --git a/src/fco/fcospecattr.h b/src/fco/fcospecattr.h index c212673..746e9dc 100644 --- a/src/fco/fcospecattr.h +++ b/src/fco/fcospecattr.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -76,6 +76,8 @@ public: void TraceContents(int dl = -1) const; + bool operator==(const cFCOSpecAttr& rhs) const; + DECLARE_SERREFCOUNT() private: cFCOSpecAttr (const cFCOSpecAttr& rhs); // not impl diff --git a/src/fco/fcospechelper.cpp b/src/fco/fcospechelper.cpp index 24909ee..921b8d4 100644 --- a/src/fco/fcospechelper.cpp +++ b/src/fco/fcospechelper.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcospechelper.h b/src/fco/fcospechelper.h index f0ae60f..f9b74d7 100644 --- a/src/fco/fcospechelper.h +++ b/src/fco/fcospechelper.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcospecimpl.cpp b/src/fco/fcospecimpl.cpp index 839e282..e15d0fd 100644 --- a/src/fco/fcospecimpl.cpp +++ b/src/fco/fcospecimpl.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -41,7 +41,7 @@ #include "fcospechelper.h" #include "core/errorutil.h" -#ifdef _DEBUG +#ifdef DEBUG int gFCOSpecImplCreated = 0; int gFCOSpecImplDestroyed = 0; #endif @@ -53,7 +53,7 @@ cFCOSpecImpl::cFCOSpecImpl(const TSTRING& name, void* pSrc, iFCOSpecHelper* pHel mName(name), mpHelper(pHelper) { -#ifdef _DEBUG +#ifdef DEBUG ++gFCOSpecImplCreated; cDebug d("cFCOSpecImpl::cFCOSpecImpl()"); d.TraceDetail("Allocated cFCOSpecImpl(%p) creat=%d dest=%d\n", this, gFCOSpecImplCreated, gFCOSpecImplDestroyed); @@ -65,7 +65,7 @@ cFCOSpecImpl::cFCOSpecImpl() : mName(_T("Unnamed_FCOSpecImpl")), mpHelper(0) { -#ifdef _DEBUG +#ifdef DEBUG ++gFCOSpecImplCreated; cDebug d("cFCOSpecImpl::cFCOSpecImpl()"); d.TraceDetail("Allocated cFCOSpecImpl(%p) creat=%d dest=%d\n", this, gFCOSpecImplCreated, gFCOSpecImplDestroyed); @@ -77,7 +77,7 @@ cFCOSpecImpl::cFCOSpecImpl(const cFCOSpecImpl& rhs) : mpHelper(0) { *this = rhs; -#ifdef _DEBUG +#ifdef DEBUG ++gFCOSpecImplCreated; cDebug d("cFCOSpecImpl::cFCOSpecImpl()"); d.TraceDetail("Allocated cFCOSpecImpl(%p) creat=%d dest=%d\n", this, gFCOSpecImplCreated, gFCOSpecImplDestroyed); @@ -86,7 +86,7 @@ cFCOSpecImpl::cFCOSpecImpl(const cFCOSpecImpl& rhs) : cFCOSpecImpl::~cFCOSpecImpl() { -#ifdef _DEBUG +#ifdef DEBUG ++gFCOSpecImplDestroyed; cDebug d("cFCOSpecImpl::cFCOSpecImpl()"); d.TraceDetail("Deleted cFCOSpecImpl(%p) creat=%d dest=%d\n", this, gFCOSpecImplCreated, gFCOSpecImplDestroyed); diff --git a/src/fco/fcospecimpl.h b/src/fco/fcospecimpl.h index 0bfa028..794b0ba 100644 --- a/src/fco/fcospecimpl.h +++ b/src/fco/fcospecimpl.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcospeclist.cpp b/src/fco/fcospeclist.cpp index 735d73b..8dfdb96 100644 --- a/src/fco/fcospeclist.cpp +++ b/src/fco/fcospeclist.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcospeclist.h b/src/fco/fcospeclist.h index d149c13..05ffc9c 100644 --- a/src/fco/fcospeclist.h +++ b/src/fco/fcospeclist.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcospecutil.cpp b/src/fco/fcospecutil.cpp index 293e721..e6b13c0 100644 --- a/src/fco/fcospecutil.cpp +++ b/src/fco/fcospecutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcospecutil.h b/src/fco/fcospecutil.h index 0f2f236..912cd80 100644 --- a/src/fco/fcospecutil.h +++ b/src/fco/fcospecutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcostrings.cpp b/src/fco/fcostrings.cpp index 369f528..872665d 100644 --- a/src/fco/fcostrings.cpp +++ b/src/fco/fcostrings.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -53,4 +53,4 @@ TSS_BeginStringtable( cFCO ) TSS_EndStringtable( cFCO ) -// eof: fcostrings.cpp + diff --git a/src/fco/fcostrings.h b/src/fco/fcostrings.h index 30683c0..f06de30 100644 --- a/src/fco/fcostrings.h +++ b/src/fco/fcostrings.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcoundefprop.cpp b/src/fco/fcoundefprop.cpp index 2de785f..e00444c 100644 --- a/src/fco/fcoundefprop.cpp +++ b/src/fco/fcoundefprop.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -138,4 +138,4 @@ void cFCOUndefinedProp::Copy(const iFCOProp* rhs) ThrowAndAssert( INTERNAL_ERROR("fcoundefprop.cpp") ); } -// eof: fcoundefprop.cpp + diff --git a/src/fco/fcoundefprop.h b/src/fco/fcoundefprop.h index 1c94f28..f00b19a 100644 --- a/src/fco/fcoundefprop.h +++ b/src/fco/fcoundefprop.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/fcovisitor.h b/src/fco/fcovisitor.h index 3977e50..c4a134a 100644 --- a/src/fco/fcovisitor.h +++ b/src/fco/fcovisitor.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/genreinfo.cpp b/src/fco/genreinfo.cpp index 10594d5..af31296 100644 --- a/src/fco/genreinfo.cpp +++ b/src/fco/genreinfo.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/genreinfo.h b/src/fco/genreinfo.h index a2024e7..f1b85ee 100644 --- a/src/fco/genreinfo.h +++ b/src/fco/genreinfo.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/genrespeclist.cpp b/src/fco/genrespeclist.cpp index 17f2b49..ee9970c 100644 --- a/src/fco/genrespeclist.cpp +++ b/src/fco/genrespeclist.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/genrespeclist.h b/src/fco/genrespeclist.h index da1e646..a341f14 100644 --- a/src/fco/genrespeclist.h +++ b/src/fco/genrespeclist.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/genreswitcher.cpp b/src/fco/genreswitcher.cpp index 98f04a5..37f7a3b 100644 --- a/src/fco/genreswitcher.cpp +++ b/src/fco/genreswitcher.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/genreswitcher.h b/src/fco/genreswitcher.h index 121b56c..f3261e4 100644 --- a/src/fco/genreswitcher.h +++ b/src/fco/genreswitcher.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/iterproxy.h b/src/fco/iterproxy.h index 21fdfca..78d4af8 100644 --- a/src/fco/iterproxy.h +++ b/src/fco/iterproxy.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/parsergenreutil.h b/src/fco/parsergenreutil.h index 6b6edfd..9db8e56 100644 --- a/src/fco/parsergenreutil.h +++ b/src/fco/parsergenreutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/propset.h b/src/fco/propset.h index be6ef67..b6aae9d 100644 --- a/src/fco/propset.h +++ b/src/fco/propset.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/signature.cpp b/src/fco/signature.cpp index 4278ed1..c7129d1 100644 --- a/src/fco/signature.cpp +++ b/src/fco/signature.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -267,7 +267,7 @@ void cNullSignature::Read(iSerializer* pSerializer, int32 version) if (version > Version()) ThrowAndAssert(eSerializerVersionMismatch(_T("Null Signature Read"))); -#ifdef _DEBUG +#ifdef DEBUG int16 ret; pSerializer->ReadInt16(ret); ASSERT(ret == 123); @@ -276,7 +276,7 @@ void cNullSignature::Read(iSerializer* pSerializer, int32 version) void cNullSignature::Write(iSerializer* pSerializer) const { -#ifdef _DEBUG +#ifdef DEBUG pSerializer->WriteInt16(123); #endif } diff --git a/src/fco/signature.h b/src/fco/signature.h index c7d775c..ba6de3d 100644 --- a/src/fco/signature.h +++ b/src/fco/signature.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/stdfco.cpp b/src/fco/stdfco.cpp index 6d6acbc..dffd92f 100644 --- a/src/fco/stdfco.cpp +++ b/src/fco/stdfco.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,4 +37,4 @@ #include "stdfco.h" -// eof: stdfco.cpp + diff --git a/src/fco/stdfco.h b/src/fco/stdfco.h index f897a01..0f7c96e 100644 --- a/src/fco/stdfco.h +++ b/src/fco/stdfco.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/twfactory.cpp b/src/fco/twfactory.cpp index cb0a229..59c8671 100644 --- a/src/fco/twfactory.cpp +++ b/src/fco/twfactory.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fco/twfactory.h b/src/fco/twfactory.h index fe87b8c..9e6d221 100644 --- a/src/fco/twfactory.h +++ b/src/fco/twfactory.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index 55fbd36..d7b7ae5 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am @@ -17,6 +17,7 @@ libfs_a_HEADERS = \ fsvisitor.h stdfs.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit +CLEANFILES = *.gcno *.gcda all: $(noinst_LIBRARIES) $(AR) ru ../../lib/libtripwire.a $(libfs_a_OBJECTS) diff --git a/src/fs/Makefile.in b/src/fs/Makefile.in index 2734d23..21c6d25 100644 --- a/src/fs/Makefile.in +++ b/src/fs/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -303,7 +303,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -332,6 +331,7 @@ libfs_a_HEADERS = \ fspropcalc.h fspropdisplayer.h fspropset.h fsstrings.h \ fsvisitor.h stdfs.h +CLEANFILES = *.gcno *.gcda all: all-am .SUFFIXES: @@ -518,6 +518,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) diff --git a/src/fs/fs.cpp b/src/fs/fs.cpp index 76d64c0..d7889a1 100644 --- a/src/fs/fs.cpp +++ b/src/fs/fs.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fs/fs.h b/src/fs/fs.h index 6231810..250e78b 100644 --- a/src/fs/fs.h +++ b/src/fs/fs.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fs/fsdatasourceiter.cpp b/src/fs/fsdatasourceiter.cpp index 7308621..8ebaebf 100644 --- a/src/fs/fsdatasourceiter.cpp +++ b/src/fs/fsdatasourceiter.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -42,7 +42,6 @@ #include "fsdatasourceiter.h" #include "fco/fcodatasourceiter.h" #include "fsobject.h" -#include "core/fsservices.h" #include "core/errorbucket.h" #include "core/corestrings.h" #include "core/usernotify.h" @@ -99,6 +98,12 @@ static bool gCrossFileSystems = false; gCrossFileSystems = crossFS; } +void cFSDataSourceIter::AddIterationError(const eError& e) +{ + if(mpErrorBucket) + mpErrorBucket->AddError(e); +} + /////////////////////////////////////////////////////////////////////////////// // CreateCopy /////////////////////////////////////////////////////////////////////////////// @@ -151,15 +156,42 @@ void cFSDataSourceIter::GetChildrenNames( const TSTRING& strParentName, std::vec } catch( eError& e ) { - cDebug d("cFSDataSourceIter::GeneratePeers"); - d.TraceError("**** ReadDir failed for %s\n", strParentName.c_str() ); - - if( mpErrorBucket ) - { - eFSDataSourceIterReadDir eReadDir(e.GetMsg(), eError::NON_FATAL); - mpErrorBucket->AddError( eReadDir ); - } + AddIterationError( eFSDataSourceIterReadDir( strParentName, e.GetMsg(), eError::NON_FATAL) ); } + catch( std::exception& e ) + { + AddIterationError( eFSDataSourceIterReadDir( strParentName, e.what(), eError::NON_FATAL) ); + } + catch(...) + { + AddIterationError( eFSDataSourceIterReadDir( strParentName, "unknown", eError::NON_FATAL) ); + } +} + +bool cFSDataSourceIter::DoStat( const TSTRING& name, cFSStatArgs& statArgs ) +{ + try + { + iFSServices::GetInstance()->Stat( name, statArgs); + } + catch(eError& e) + { + e.SetFatality(false); + AddIterationError(e); + return false; + } + catch(std::exception& e) + { + AddIterationError( eFSDataSourceIter( name, e.what(), eError::NON_FATAL) ); + return false; + } + catch(...) + { + AddIterationError( eFSDataSourceIter( name, "unknown", eError::NON_FATAL) ); + return false; + } + + return true; } /////////////////////////////////////////////////////////////////////////////// @@ -173,30 +205,15 @@ bool cFSDataSourceIter::InitializeTypeInfo(iFCO* pFCO) if( pObj->GetFSPropSet().GetValidVector().ContainsItem( cFSPropSet::PROP_FILETYPE) ) return true; - // // assume invalid by default... // cFSPropSet& propSet = pObj->GetFSPropSet(); propSet.SetFileType(cFSPropSet::FT_INVALID); cFSStatArgs statArgs; - try - { - iFSServices::GetInstance()->Stat( pTrans->ToStringAPI( pObj->GetName() ), statArgs); - } - catch(eError& e) - { - cDebug d("CreateObject"); - d.TraceError( "*** Stat of %s failed!!!\n", pObj->GetName().AsString().c_str() ); - if( mpErrorBucket ) - { - e.SetFatality( false ); - mpErrorBucket->AddError( e ); - } + if( !DoStat( pObj->GetName().AsString(), statArgs )) return false; - } - // // don't create the object if it is on a different file system... // if( gCrossFileSystems == false && (mDev != 0) && (statArgs.dev != mDev) ) @@ -254,6 +271,9 @@ bool cFSDataSourceIter::InitializeTypeInfo(iFCO* pFCO) case cFSStatArgs::TY_PORT: propSet.SetFileType(cFSPropSet::FT_PORT); break; + case cFSStatArgs::TY_NAMED: + propSet.SetFileType(cFSPropSet::FT_NAMED); + break; default: // set it to invalid propSet.SetFileType(cFSPropSet::FT_INVALID); diff --git a/src/fs/fsdatasourceiter.h b/src/fs/fsdatasourceiter.h index b4f0eee..fa20f01 100644 --- a/src/fs/fsdatasourceiter.h +++ b/src/fs/fsdatasourceiter.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -39,9 +39,11 @@ // INCLUDES //========================================================================= #include "fco/fcodatasourceiterimpl.h" +#include "core/fileerror.h" +#include "core/fsservices.h" -TSS_EXCEPTION( eFSDataSourceIter, eError ) -TSS_EXCEPTION( eFSDataSourceIterReadDir, eFSDataSourceIter ) +TSS_FILE_EXCEPTION( eFSDataSourceIter, eFileError ) +TSS_FILE_EXCEPTION( eFSDataSourceIterReadDir, eFSDataSourceIter ) //========================================================================= @@ -83,6 +85,9 @@ private: virtual iFCO* CreateObject(const cFCOName& name, bool bCreatingPeers ); virtual bool InitializeTypeInfo(iFCO* pFCO) ; + + void AddIterationError(const eError& e); + bool DoStat(const TSTRING& name, cFSStatArgs& statArgs); }; #endif //__FSDATASOURCEITER_H diff --git a/src/fs/fserrors.cpp b/src/fs/fserrors.cpp index e494057..131f6b1 100644 --- a/src/fs/fserrors.cpp +++ b/src/fs/fserrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -43,7 +43,7 @@ TSS_BEGIN_ERROR_REGISTRATION( fs ) -TSS_REGISTER_ERROR( eFSPropCalc(), _T("NTFS property calculation error.") ) +TSS_REGISTER_ERROR( eFSPropCalc(), _T("Property calculation error.") ) //TSS_REGISTER_ERROR( eFSPropCalcResetAccessTime(), _T("Could not reset access time for file.") ) TSS_REGISTER_ERROR( eFSDataSourceIter(), _T("Data source iterator error.") ) TSS_REGISTER_ERROR( eFSDataSourceIterReadDir(), _T("Could not access directory contents.") ) diff --git a/src/fs/fserrors.h b/src/fs/fserrors.h index 2369419..38ff091 100644 --- a/src/fs/fserrors.h +++ b/src/fs/fserrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fs/fsfactory.cpp b/src/fs/fsfactory.cpp index 1874aeb..36f40e4 100644 --- a/src/fs/fsfactory.cpp +++ b/src/fs/fsfactory.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -76,7 +76,12 @@ iFCOSpec* cFSFactory::CreateSpec(const TSTRING& name, iFCOSpecHelper* pHelper) c iFCOPropDisplayer* cFSFactory::CreatePropDisplayer() const { - return new cFSPropDisplayer(); + static iFCOPropDisplayer* gPropDisplayer = 0; + + if (!gPropDisplayer) + gPropDisplayer = new cFSPropDisplayer(); + + return gPropDisplayer; } iSerRefCountObj::CreateFunc cFSFactory::GetCreateFunc() const diff --git a/src/fs/fsfactory.h b/src/fs/fsfactory.h index 980dda7..5d14691 100644 --- a/src/fs/fsfactory.h +++ b/src/fs/fsfactory.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fs/fsnametranslator.cpp b/src/fs/fsnametranslator.cpp index ebb24bd..cf1bea9 100644 --- a/src/fs/fsnametranslator.cpp +++ b/src/fs/fsnametranslator.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fs/fsnametranslator.h b/src/fs/fsnametranslator.h index 4daf9f4..3f5e4a0 100644 --- a/src/fs/fsnametranslator.h +++ b/src/fs/fsnametranslator.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fs/fsobject.cpp b/src/fs/fsobject.cpp index c811d77..87522b5 100644 --- a/src/fs/fsobject.cpp +++ b/src/fs/fsobject.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -45,7 +45,7 @@ IMPLEMENT_SERREFCOUNT(cFSObject, _T("FSObject"), 0, 1) // Debug stuff -#ifdef _DEBUG +#ifdef DEBUG static int gNumFSObjectCreate = 0; static int gNumFSObjectDestroy = 0; @@ -75,7 +75,7 @@ public: cFSObject::cFSObject(const cFCOName& name) : mName(name) { -#ifdef _DEBUG +#ifdef DEBUG gNumFSObjectCreate++; #endif } @@ -83,14 +83,14 @@ cFSObject::cFSObject(const cFCOName& name) : cFSObject::cFSObject() : mName(_T("undefined")) { -#ifdef _DEBUG +#ifdef DEBUG gNumFSObjectCreate++; #endif } cFSObject::~cFSObject() { -#ifdef _DEBUG +#ifdef DEBUG gNumFSObjectDestroy++; #endif } diff --git a/src/fs/fsobject.h b/src/fs/fsobject.h index 9121137..12d6592 100644 --- a/src/fs/fsobject.h +++ b/src/fs/fsobject.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -82,7 +82,7 @@ public: virtual void TraceContents(int dl = -1) const; -#ifdef _DEBUG +#ifdef DEBUG static void TraceStats() ; // this TRACEs statistics on FSObject usage that is pertinent to performance or mem leakage // concerns. diff --git a/src/fs/fsparserutil.cpp b/src/fs/fsparserutil.cpp index 7de1b0a..28843d0 100644 --- a/src/fs/fsparserutil.cpp +++ b/src/fs/fsparserutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -83,6 +83,11 @@ bool cFSParserUtil::MapStringToProperty( const TSTRING& str, int& propIndex ) co default: fMappedChar = false; break; } } + else + fMappedChar = false; + +/* Leaving this here in case we ever want to implement long property names + else { if( 0 == str.compare( TSS_GetString( cFS, fs::STR_PARSER_PROP_MODE ) ) ) @@ -122,6 +127,7 @@ bool cFSParserUtil::MapStringToProperty( const TSTRING& str, int& propIndex ) co else fMappedChar = false; } +*/ return( fMappedChar ); } @@ -206,6 +212,10 @@ bool cFSParserUtil::EnumPredefinedVariables( int index, TSTRING& sName, TSTRING& bool cFSParserUtil::IsAbsolutePath( const TSTRING& strPath ) const { - // IF there's a first character AND it is ( '/' OR '\\' ), THEN it's absolute - return( strPath.size() > 0 && ( _T('/') == strPath[0] || _T('\\') == strPath[0] ) ); +#if USES_DEVICE_PATH + return cDevicePath::IsAbsolutePath(strPath); +#else + // IF there's a first character AND it's a '/', it's absolute. + return( strPath.size() > 0 && ( _T('/') == strPath[0] ) ); +#endif } diff --git a/src/fs/fsparserutil.h b/src/fs/fsparserutil.h index b0e1b7c..c5b3dea 100644 --- a/src/fs/fsparserutil.h +++ b/src/fs/fsparserutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fs/fspropcalc.cpp b/src/fs/fspropcalc.cpp index f575bfd..afc1f67 100644 --- a/src/fs/fspropcalc.cpp +++ b/src/fs/fspropcalc.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -35,18 +35,15 @@ #include "stdfs.h" #include "core/debug.h" #include "core/errorbucket.h" -#include "core/fsservices.h" #include "core/errorbucket.h" #include "fco/fconame.h" #include "fco/fconametranslator.h" #include "fco/twfactory.h" -#include "core/archive.h" - #include "fspropcalc.h" #include "fsobject.h" #include - +#include cFSPropCalc::cFSPropCalc() : mCollAction(iFCOPropCalc::PROP_LEAVE), mCalcFlags(0), mpErrorBucket(0) @@ -88,149 +85,198 @@ static bool NeedsStat(const cFCOPropVector& v) /////////////////////////////////////////////////////////////////////////////// -static bool GetSymLinkStr(const cFCOName& fileName, cArchive& arch) +bool cFSPropCalc::GetSymLinkStr(const TSTRING& strName, cArchive& arch, size_t size) { - char buf[1024]; -#if defined(O_PATH) - int fd = open(iTWFactory::GetInstance()->GetNameTranslator()->ToStringAPI( fileName ).c_str(), - (O_PATH | O_NOFOLLOW | O_NOATIME)); - int rtn = readlinkat(fd, 0, buf, 1024); + std::vector data(size+1); + char* buf = &data[0]; + +#if defined(O_PATH) // A Linuxism that lets us read symlinks w/o bumping the access time. + int fd = open(strName.c_str(), (O_PATH | O_NOFOLLOW | O_NOATIME)); + int rtn = readlinkat(fd, 0, buf, size); close(fd); #else - int rtn = readlink( iTWFactory::GetInstance()->GetNameTranslator()->ToStringAPI( fileName ).c_str(), - buf, 1024 ); + int rtn = readlink( strName.c_str(), buf, size ); #endif - if(rtn == -1) - return false; + if(rtn < 0) + { + // Some OSes (like HP-UX) return ERANGE if buffer is too small. + // This is nonstandard but better than the usual truncate-and-say-you-succeeded + // + if(ERANGE == errno) + return GetSymLinkStr(strName, arch, size*2); - // the return value is the number of characters written. + return false; + } + + //Sadly if buf isn't big enough readlink 'succeeds' by truncating the string, so the only + // clue your buffer might be too small is if you maxed it out. So we try again, within reason. +#if IS_SKYOS + if((size_t)rtn >= size-1) //SkyOS wants space to null terminate the string it hands back, which is nice, I guess. +#else + if((size_t)rtn == size) +#endif + { + if(size < 128*TW_PATH_SIZE) + return GetSymLinkStr(strName, arch, size*2); + + return false; + } + + // the return value is the number of characters written. arch.WriteBlob(buf, rtn); return true; } - -/////////////////////////////////////////////////////////////////////////////// -// VisitFSObject -- this is the workhorse method that actually fills out the -// passed in FSObject' properties -/////////////////////////////////////////////////////////////////////////////// -void cFSPropCalc::VisitFSObject(cFSObject& obj) +void cFSPropCalc::AddPropCalcError(const eError& e) { - cDebug d("cFSPropCalc::VisitFSObject"); - d.TraceDetail(_T("Visiting %s\n"), obj.GetName().AsString().c_str()); + if(mpErrorBucket) + mpErrorBucket->AddError(e); +} - // if we are not in overwrite mode, we need to alter the - // properties we are calculating... - cFCOPropVector propsToCheck(mPropVector); - if(mCollAction == iFCOPropCalc::PROP_LEAVE) - { - cFCOPropVector inBoth = propsToCheck; - inBoth &= obj.GetPropSet()->GetValidVector(); - propsToCheck ^= inBoth; - } - -#ifdef _DEBUG - d.TraceDetail("----->Collision Action = %s\n", mCollAction == iFCOPropCalc::PROP_LEAVE ? "Leave" : "Replace"); - d.TraceDetail("----->Object's valid properties (a):\n"); - obj.GetPropSet()->GetValidVector().TraceContents(cDebug::D_DETAIL); - d.TraceDetail("----->Properties to calculate: (b)\n"); - mPropVector.TraceContents(cDebug::D_DETAIL); - d.TraceDetail("----->Properties to change in object ((a&b)^b for Leave or b for Replace):\n"); - propsToCheck.TraceContents(cDebug::D_DETAIL); -#endif //_DEBUG - - // only do the stat() if it is necessary - iFSServices* pFSServices = iFSServices::GetInstance(); - cFSStatArgs ss; - bool bDidStat = false; - TSTRING strName = iTWFactory::GetInstance()->GetNameTranslator()->ToStringAPI( obj.GetName() ); - - // get a reference to the fco's property set - cFSPropSet& propSet = obj.GetFSPropSet(); +bool cFSPropCalc::DoStat( const TSTRING& strName, cFSStatArgs& statArgs ) +{ + cDebug d("cFSPropCalc::DoStat"); - // - // just return if this object is invalid - // - if( propSet.GetFileType() == cFSPropSet::FT_INVALID ) - return; - try { - if( NeedsStat(propsToCheck) ) - { - d.TraceDetail("---Performing Stat()\n"); - pFSServices->Stat(strName, ss); - bDidStat = true; - } + d.TraceDetail("---Performing Stat()\n"); + iFSServices::GetInstance()->Stat(strName, statArgs); } catch(eError& e) { d.TraceError("Error getting stat info for %s : %s\n", strName.c_str(), e.GetMsg().c_str()); - - // add this fco to the error set... - // it is assumed that the file name that the error is associated with is in the exception's - // GetMsg() - e.SetFatality( false ); - if(mpErrorBucket) - mpErrorBucket->AddError( e ); - return; + e.SetFatality(false); + AddPropCalcError(e); + return false; + } + catch(std::exception& e) + { + d.TraceError("Error getting stat info for %s : %s\n", strName.c_str(), e.what()); + AddPropCalcError( eFSPropCalc( strName, e.what(), eError::NON_FATAL ) ); + return false; + } + catch(...) + { + d.TraceError("Unknown error getting stat info for %s\n", strName.c_str()); + AddPropCalcError( eFSPropCalc( strName, "unknown", eError::NON_FATAL ) ); + return false; } - // for now, I will only fill out the stat info indicated in the property vector, - // but in reality, there is no reason not to fill out everything, since we have the - // extra information for free! - if(bDidStat) + return true; +} + +bool cFSPropCalc::DoOpen( const TSTRING& strName, cFileArchive& arch ) +{ + try { - if(propsToCheck.ContainsItem(cFSPropSet::PROP_DEV)) - propSet.SetDev(ss.dev); - - if(propsToCheck.ContainsItem(cFSPropSet::PROP_RDEV)) - propSet.SetRDev(ss.rdev); + arch.OpenRead(strName.c_str(), ((mCalcFlags & iFCOPropCalc::DIRECT_IO) ? + cFileArchive::FA_SCANNING | cFileArchive::FA_DIRECT : + cFileArchive::FA_SCANNING) ); + } + catch (eError&) + { + AddPropCalcError( eArchiveOpen( strName, iFSServices::GetInstance()->GetErrString(), eError::NON_FATAL)); + return false; + } + catch (std::exception& e) + { + AddPropCalcError( eArchiveOpen( strName, e.what(), eError::NON_FATAL ) ); + return false; + } + catch (...) + { + AddPropCalcError( eArchiveOpen( strName, "unknown", eError::NON_FATAL ) ); + return false; + } - if(propsToCheck.ContainsItem(cFSPropSet::PROP_INODE)) - propSet.SetInode(ss.ino); - - if(propsToCheck.ContainsItem(cFSPropSet::PROP_MODE)) - propSet.SetMode(ss.mode); - - if(propsToCheck.ContainsItem(cFSPropSet::PROP_NLINK)) - propSet.SetNLink(ss.nlink); - - if(propsToCheck.ContainsItem(cFSPropSet::PROP_UID)) - propSet.SetUID(ss.uid); - - if(propsToCheck.ContainsItem(cFSPropSet::PROP_GID)) - propSet.SetGID(ss.gid); - - if(propsToCheck.ContainsItem(cFSPropSet::PROP_SIZE)) - propSet.SetSize(ss.size); - - if(propsToCheck.ContainsItem(cFSPropSet::PROP_ATIME)) - propSet.SetAccessTime(ss.atime); - - if(propsToCheck.ContainsItem(cFSPropSet::PROP_MTIME)) - propSet.SetModifyTime(ss.mtime); - - if(propsToCheck.ContainsItem(cFSPropSet::PROP_CTIME)) - propSet.SetCreateTime(ss.ctime); + return true; +} - if(propsToCheck.ContainsItem(cFSPropSet::PROP_BLOCK_SIZE)) - propSet.SetBlockSize(ss.blksize); - - if(propsToCheck.ContainsItem(cFSPropSet::PROP_BLOCKS)) - propSet.SetBlocks(ss.blocks); +bool cFSPropCalc::DoHash( const TSTRING& strName, cBidirArchive* pTheArch, cArchiveSigGen& asg, cFileArchive& arch ) +{ + cDebug d("cFSPropCalc::DoHash"); + try + { + pTheArch->Seek( 0, cBidirArchive::BEGINNING ); + asg.CalculateSignatures( *pTheArch ); + arch.Close(); + } + catch (eError& e) + { + d.TraceError("Error generating hashes for %s : %s\n", strName.c_str(), e.GetMsg().c_str()); + e.SetFatality(false); + AddPropCalcError(e); + return false; + } + catch (std::exception& e) + { + d.TraceError("Error generating hashes for %s : %s\n", strName.c_str(), e.what()); + AddPropCalcError( eArchiveRead( strName, e.what(), eError::NON_FATAL ) ); + return false; + } + catch (...) + { + d.TraceError("Unknown error generating hashes for %s\n", strName.c_str()); + AddPropCalcError( eArchiveRead( strName, "unknown", eError::NON_FATAL ) ); + return false; + } + + return true; +} - if(propsToCheck.ContainsItem(cFSPropSet::PROP_GROWING_FILE)) - propSet.SetGrowingFile(ss.size); +void cFSPropCalc::HandleStatProperties( const cFCOPropVector& propsToCheck, const cFSStatArgs& ss, cFSPropSet& propSet) +{ + if(propsToCheck.ContainsItem(cFSPropSet::PROP_DEV)) + propSet.SetDev(ss.dev); - if(propsToCheck.ContainsItem(cFSPropSet::PROP_FILETYPE)) + if(propsToCheck.ContainsItem(cFSPropSet::PROP_RDEV)) + propSet.SetRDev(ss.rdev); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_INODE)) + propSet.SetInode(ss.ino); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_MODE)) + propSet.SetMode(ss.mode); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_NLINK)) + propSet.SetNLink(ss.nlink); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_UID)) + propSet.SetUID(ss.uid); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_GID)) + propSet.SetGID(ss.gid); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_SIZE)) + propSet.SetSize(ss.size); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_ATIME)) + propSet.SetAccessTime(ss.atime); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_MTIME)) + propSet.SetModifyTime(ss.mtime); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_CTIME)) + propSet.SetCreateTime(ss.ctime); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_BLOCK_SIZE)) + propSet.SetBlockSize(ss.blksize); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_BLOCKS)) + propSet.SetBlocks(ss.blocks); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_GROWING_FILE)) + propSet.SetGrowingFile(ss.size); + + if(propsToCheck.ContainsItem(cFSPropSet::PROP_FILETYPE)) + { + // TODO -- It _really_ bites duplicating code here and in fsdatasource.cpp + // *** This _has_ to be remedied somehow! + // set the file type + switch(ss.mFileType) { - // TODO -- It _really_ bites duplicating code here and in fsdatasource.cpp - // *** This _has_ to be remedied somehow! - // set the file type - switch(ss.mFileType) - { case cFSStatArgs::TY_FILE: propSet.SetFileType(cFSPropSet::FT_FILE); break; @@ -258,13 +304,18 @@ void cFSPropCalc::VisitFSObject(cFSObject& obj) case cFSStatArgs::TY_PORT: propSet.SetFileType(cFSPropSet::FT_PORT); break; + case cFSStatArgs::TY_NAMED: + propSet.SetFileType(cFSPropSet::FT_NAMED); + break; default: // set it to invalid propSet.SetFileType(cFSPropSet::FT_INVALID); - } - } + } } +} +void cFSPropCalc::HandleHashes( const cFCOPropVector& propsToCheck, const TSTRING& strName, cFSPropSet& propSet) +{ bool hash_success = false; // if the file type is not a regular file, we will @@ -273,45 +324,31 @@ void cFSPropCalc::VisitFSObject(cFSObject& obj) if( propSet.GetFileType() == cFSPropSet::FT_FILE || propSet.GetFileType() == cFSPropSet::FT_SYMLINK ) { if( // if we need to open the file - propsToCheck.ContainsItem(cFSPropSet::PROP_CRC32) || - propsToCheck.ContainsItem(cFSPropSet::PROP_MD5) || - propsToCheck.ContainsItem(cFSPropSet::PROP_SHA) || - propsToCheck.ContainsItem(cFSPropSet::PROP_HAVAL) - ) + propsToCheck.ContainsItem(cFSPropSet::PROP_CRC32) || + propsToCheck.ContainsItem(cFSPropSet::PROP_MD5) || + propsToCheck.ContainsItem(cFSPropSet::PROP_SHA) || + propsToCheck.ContainsItem(cFSPropSet::PROP_HAVAL) + ) { cFileArchive arch; cMemoryArchive memArch; - cBidirArchive* pTheArch; + cBidirArchive* pTheArch; hash_success = true; if(propSet.GetFileType() == cFSPropSet::FT_SYMLINK) { pTheArch = &memArch; - if(! GetSymLinkStr(obj.GetName(), memArch)) + if(! GetSymLinkStr(strName, memArch)) { // add it to the bucket... - if(mpErrorBucket) - mpErrorBucket->AddError( eArchiveOpen( strName, iFSServices::GetInstance()->GetErrString(), eError::NON_FATAL ) ); + AddPropCalcError( eArchiveOpen( strName, iFSServices::GetInstance()->GetErrString(), eError::NON_FATAL ) ); hash_success = false; } - } else { pTheArch = &arch; - try - { - arch.OpenRead(strName.c_str(), ((mCalcFlags & iFCOPropCalc::DIRECT_IO) ? - cFileArchive::FA_SCANNING | cFileArchive::FA_DIRECT : - cFileArchive::FA_SCANNING) ); - } - catch (eError&) - { - // add it to the bucket... - if(mpErrorBucket) - mpErrorBucket->AddError( eArchiveOpen( strName, iFSServices::GetInstance()->GetErrString(), eError::NON_FATAL ) ); - hash_success = false; - } + hash_success = DoOpen(strName, arch); } // @@ -326,43 +363,29 @@ void cFSPropCalc::VisitFSObject(cFSObject& obj) propSet.SetDefinedCRC32(true); asg.AddSig( propSet.GetCRC32() ); } - + if(propsToCheck.ContainsItem(cFSPropSet::PROP_MD5)) { propSet.SetDefinedMD5(true); asg.AddSig( propSet.GetMD5() ); } - + if(propsToCheck.ContainsItem(cFSPropSet::PROP_SHA)) { propSet.SetDefinedSHA(true); asg.AddSig( propSet.GetSHA() ); } - + if(propsToCheck.ContainsItem(cFSPropSet::PROP_HAVAL)) { propSet.SetDefinedHAVAL(true); asg.AddSig( propSet.GetHAVAL() ); } - + // // calculate the signatures // - try - { - pTheArch->Seek( 0, cBidirArchive::BEGINNING ); - asg.CalculateSignatures( *pTheArch ); - arch.Close(); - } - catch (eError& e) - { - d.TraceError("Error generating hashes for %s : %s\n", strName.c_str(), e.GetMsg().c_str()); - - e.SetFatality(false); - if(mpErrorBucket) - mpErrorBucket->AddError(e); - hash_success = false; - } + hash_success = DoHash(strName, pTheArch, asg, arch); } } } @@ -384,6 +407,59 @@ void cFSPropCalc::VisitFSObject(cFSObject& obj) } } +/////////////////////////////////////////////////////////////////////////////// +// VisitFSObject -- this is the workhorse method that actually fills out the +// passed in FSObject' properties +/////////////////////////////////////////////////////////////////////////////// +void cFSPropCalc::VisitFSObject(cFSObject& obj) +{ + cDebug d("cFSPropCalc::VisitFSObject"); + d.TraceDetail(_T("Visiting %s\n"), obj.GetName().AsString().c_str()); + + // if we are not in overwrite mode, we need to alter the + // properties we are calculating... + cFCOPropVector propsToCheck(mPropVector); + if(mCollAction == iFCOPropCalc::PROP_LEAVE) + { + cFCOPropVector inBoth = propsToCheck; + inBoth &= obj.GetPropSet()->GetValidVector(); + propsToCheck ^= inBoth; + } + +#ifdef DEBUG + d.TraceDetail("----->Collision Action = %s\n", mCollAction == iFCOPropCalc::PROP_LEAVE ? "Leave" : "Replace"); + d.TraceDetail("----->Object's valid properties (a):\n"); + obj.GetPropSet()->GetValidVector().TraceContents(cDebug::D_DETAIL); + d.TraceDetail("----->Properties to calculate: (b)\n"); + mPropVector.TraceContents(cDebug::D_DETAIL); + d.TraceDetail("----->Properties to change in object ((a&b)^b for Leave or b for Replace):\n"); + propsToCheck.TraceContents(cDebug::D_DETAIL); +#endif //_DEBUG + + // only do the stat() if it is necessary + cFSStatArgs ss; + TSTRING strName = iTWFactory::GetInstance()->GetNameTranslator()->ToStringAPI( obj.GetName() ); + + // get a reference to the fco's property set + cFSPropSet& propSet = obj.GetFSPropSet(); + + // + // just return if this object is invalid + // + if( propSet.GetFileType() == cFSPropSet::FT_INVALID ) + return; + + if( NeedsStat(propsToCheck) ) + { + if (!DoStat(strName, ss)) + return; + + HandleStatProperties(propsToCheck, ss, propSet); + } + + HandleHashes(propsToCheck, strName, propSet); +} + void cFSPropCalc::SetPropVector(const cFCOPropVector& pv) { mPropVector = pv; diff --git a/src/fs/fspropcalc.h b/src/fs/fspropcalc.h index 53a1eae..d476b13 100644 --- a/src/fs/fspropcalc.h +++ b/src/fs/fspropcalc.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -47,7 +47,19 @@ #include "fco/fcopropvector.h" #endif -TSS_EXCEPTION( eFSPropCalc, eError ) +#include "fco/signature.h" +#include "core/fileerror.h" +#include "core/fsservices.h" +#include "core/archive.h" +#include "fspropset.h" + +#ifdef PATH_MAX +# define TW_PATH_SIZE PATH_MAX +#else +# define TW_PATH_SIZE 1024 +#endif + +TSS_FILE_EXCEPTION( eFSPropCalc, eFileError ) //TSS_EXCEPTION( eFSPropCalcResetAccessTime, eFSPropCalc ) // this was never used class cFSPropCalc : public iFCOPropCalc, public iFSVisitor @@ -73,11 +85,21 @@ public: virtual int GetCalcFlags() const; virtual void SetCalcFlags( int i ); - + + static bool GetSymLinkStr(const TSTRING& strName, cArchive& arch, size_t size = TW_PATH_SIZE); + private: cFSPropCalc( const cFSPropCalc& ); void operator =( const cFSPropCalc& ); + void AddPropCalcError(const eError& e); + + bool DoStat(const TSTRING& name, cFSStatArgs& statArgs); + bool DoOpen(const TSTRING& name, cFileArchive& arch); + bool DoHash( const TSTRING& name, cBidirArchive* pTheArch, cArchiveSigGen& asg, cFileArchive& arch ); + void HandleStatProperties( const cFCOPropVector& propsToCheck, const cFSStatArgs& ss, cFSPropSet& propSet); + void HandleHashes( const cFCOPropVector& propsToCheck, const TSTRING& strName, cFSPropSet& propSet); + cFCOPropVector mPropVector; iFCOPropCalc::CollisionAction mCollAction; int mCalcFlags; diff --git a/src/fs/fspropdisplayer.cpp b/src/fs/fspropdisplayer.cpp index 6e465f3..28e733f 100644 --- a/src/fs/fspropdisplayer.cpp +++ b/src/fs/fspropdisplayer.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -509,4 +509,9 @@ bool cFSPropDisplayer::AddGroupnameMapping( const int64& i64gid, const TSTRING& return( ret.second = false ); // returns true if key didn't exist before } - +bool cFSPropDisplayer::operator==(const cFSPropDisplayer& rhs) const +{ + return (mpvPropsWeDisplay == rhs.mpvPropsWeDisplay + && uidToUsername == rhs.uidToUsername + && gidToGroupname == rhs.gidToGroupname); +} diff --git a/src/fs/fspropdisplayer.h b/src/fs/fspropdisplayer.h index 03bc8e2..780bfe4 100644 --- a/src/fs/fspropdisplayer.h +++ b/src/fs/fspropdisplayer.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -114,6 +114,9 @@ public: virtual bool GetLazy() const; virtual void Read (iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive) virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive) + + bool operator==(const cFSPropDisplayer& rhs) const; // for testing + private: void AddMapping( const iFCOProp* const pProp, const TSTRING& tstrValue, const int propTypeEnum ); // pass in a property value and its string representation. for instance: ( FS::PROP_UID --> username ) diff --git a/src/fs/fspropset.cpp b/src/fs/fspropset.cpp index f734611..d03d629 100644 --- a/src/fs/fspropset.cpp +++ b/src/fs/fspropset.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -60,7 +60,8 @@ TSTRING cFCOPropFileType::AsString() const fs::STR_FT_FIFO, fs::STR_FT_SOCK, fs::STR_FT_DOOR, - fs::STR_FT_PORT + fs::STR_FT_PORT, + fs::STR_FT_NAMED }; int32 fileType = GetValue(); diff --git a/src/fs/fspropset.h b/src/fs/fspropset.h index 423e5cc..57f7dc4 100644 --- a/src/fs/fspropset.h +++ b/src/fs/fspropset.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -111,6 +111,7 @@ public: FT_SOCK, FT_DOOR, FT_PORT, + FT_NAMED, FT_NUMITEMS }; diff --git a/src/fs/fsstrings.cpp b/src/fs/fsstrings.cpp index 3eee809..97a08bf 100644 --- a/src/fs/fsstrings.cpp +++ b/src/fs/fsstrings.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -51,6 +51,7 @@ TSS_BeginStringtable( cFS ) TSS_StringEntry( fs::STR_FT_SOCK, _T("Socket") ), TSS_StringEntry( fs::STR_FT_DOOR, _T("Door") ), TSS_StringEntry( fs::STR_FT_PORT, _T("Event Port") ), + TSS_StringEntry( fs::STR_FT_NAMED, _T("Named Special File") ), // property names TSS_StringEntry( fs::STR_PROP_DEV, _T("Device Number") ), @@ -73,8 +74,9 @@ TSS_BeginStringtable( cFS ) TSS_StringEntry( fs::STR_PROP_SHA, _T("SHA") ), TSS_StringEntry( fs::STR_PROP_HAVAL, _T("HAVAL") ), TSS_StringEntry( fs::STR_PROP_ACL, _T("ACL Placeholder -- Not Implemented") ), - - // TODO: get actual strings + +/* Leaving these here in case we ever implement long property names + TSS_StringEntry( fs::STR_PARSER_PROP_DEV, _T("unimplemented") ), TSS_StringEntry( fs::STR_PARSER_PROP_RDEV, _T("unimplemented") ), TSS_StringEntry( fs::STR_PARSER_PROP_INODE, _T("unimplemented") ), @@ -94,7 +96,7 @@ TSS_BeginStringtable( cFS ) TSS_StringEntry( fs::STR_PARSER_PROP_MD5, _T("unimplemented") ), TSS_StringEntry( fs::STR_PARSER_PROP_SHA, _T("unimplemented") ), TSS_StringEntry( fs::STR_PARSER_PROP_HAVAL, _T("unimplemented") ), - +*/ TSS_StringEntry( fs::STR_PARSER_READONLY, _T("ReadOnly")), TSS_StringEntry( fs::STR_PARSER_DYNAMIC, _T("Dynamic")), TSS_StringEntry( fs::STR_PARSER_GROWING, _T("Growing")), diff --git a/src/fs/fsstrings.h b/src/fs/fsstrings.h index c61fe70..6607e08 100644 --- a/src/fs/fsstrings.h +++ b/src/fs/fsstrings.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -55,6 +55,7 @@ TSS_BeginStringIds( fs ) STR_FT_SOCK, STR_FT_DOOR, STR_FT_PORT, + STR_FT_NAMED, // property names STR_PROP_DEV, @@ -77,7 +78,8 @@ TSS_BeginStringIds( fs ) STR_PROP_SHA, STR_PROP_HAVAL, STR_PROP_ACL, - + +/* Leaving these here in case we ever implement long property names STR_PARSER_PROP_DEV, STR_PARSER_PROP_RDEV, STR_PARSER_PROP_INODE, @@ -97,7 +99,7 @@ TSS_BeginStringIds( fs ) STR_PARSER_PROP_MD5, STR_PARSER_PROP_SHA, STR_PARSER_PROP_HAVAL, - +*/ STR_PARSER_READONLY, STR_PARSER_DYNAMIC, STR_PARSER_GROWING, diff --git a/src/fs/fsvisitor.cpp b/src/fs/fsvisitor.cpp index b9a669c..bac8ebd 100644 --- a/src/fs/fsvisitor.cpp +++ b/src/fs/fsvisitor.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fs/fsvisitor.h b/src/fs/fsvisitor.h index ac9c042..8d7eb7c 100644 --- a/src/fs/fsvisitor.h +++ b/src/fs/fsvisitor.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/fs/stdfs.cpp b/src/fs/stdfs.cpp index 4a7c176..8715dc4 100644 --- a/src/fs/stdfs.cpp +++ b/src/fs/stdfs.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,4 +37,4 @@ #include "stdfs.h" -// eof: stdfs.cpp + diff --git a/src/fs/stdfs.h b/src/fs/stdfs.h index 58712e0..07912e9 100644 --- a/src/fs/stdfs.h +++ b/src/fs/stdfs.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/parser/lexyacc_header.h b/src/parser/lexyacc_header.h index d2b67ae..3611f4c 100644 --- a/src/parser/lexyacc_header.h +++ b/src/parser/lexyacc_header.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/parser/policy.y b/src/parser/policy.y index 910c79f..7398508 100644 --- a/src/parser/policy.y +++ b/src/parser/policy.y @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/parser/testfiles.bad/arrow.txt b/src/parser/testfiles.bad/arrow.txt new file mode 100644 index 0000000..e4400a5 --- /dev/null +++ b/src/parser/testfiles.bad/arrow.txt @@ -0,0 +1 @@ +-> diff --git a/src/parser/testfiles.bad/asdf.txt b/src/parser/testfiles.bad/asdf.txt new file mode 100644 index 0000000..e08928b --- /dev/null +++ b/src/parser/testfiles.bad/asdf.txt @@ -0,0 +1,4 @@ +(asdf=fjfj) +{ +/foo -> $(IgnoreNone); +} diff --git a/src/parser/testfiles.bad/atat.txt b/src/parser/testfiles.bad/atat.txt new file mode 100644 index 0000000..0282815 --- /dev/null +++ b/src/parser/testfiles.bad/atat.txt @@ -0,0 +1 @@ +@@ diff --git a/src/parser/testfiles.bad/bad-directive.txt b/src/parser/testfiles.bad/bad-directive.txt new file mode 100644 index 0000000..87e2747 --- /dev/null +++ b/src/parser/testfiles.bad/bad-directive.txt @@ -0,0 +1 @@ +@@unknown fjfjfj diff --git a/src/parser/testfiles.bad/bad-ifhost.txt b/src/parser/testfiles.bad/bad-ifhost.txt new file mode 100644 index 0000000..6672764 --- /dev/null +++ b/src/parser/testfiles.bad/bad-ifhost.txt @@ -0,0 +1 @@ +@@ifhost diff --git a/src/parser/testfiles.bad/error.txt b/src/parser/testfiles.bad/error.txt new file mode 100644 index 0000000..179b4a5 --- /dev/null +++ b/src/parser/testfiles.bad/error.txt @@ -0,0 +1 @@ +@@error This should fail diff --git a/src/parser/testfiles.bad/global-foo.txt b/src/parser/testfiles.bad/global-foo.txt new file mode 100644 index 0000000..81cfcd6 --- /dev/null +++ b/src/parser/testfiles.bad/global-foo.txt @@ -0,0 +1,2 @@ +@@section GLOBAL +/foo -> $(IgnoreNone); diff --git a/src/parser/testfiles.bad/ignore-some.txt b/src/parser/testfiles.bad/ignore-some.txt new file mode 100644 index 0000000..70f3d29 --- /dev/null +++ b/src/parser/testfiles.bad/ignore-some.txt @@ -0,0 +1 @@ +/foo -> $(IgnoreSome); diff --git a/src/parser/testfiles.bad/incomplete-1.txt b/src/parser/testfiles.bad/incomplete-1.txt new file mode 100644 index 0000000..0661686 --- /dev/null +++ b/src/parser/testfiles.bad/incomplete-1.txt @@ -0,0 +1 @@ +/foo diff --git a/src/parser/testfiles.bad/incomplete-2.txt b/src/parser/testfiles.bad/incomplete-2.txt new file mode 100644 index 0000000..cdceccf --- /dev/null +++ b/src/parser/testfiles.bad/incomplete-2.txt @@ -0,0 +1 @@ +/foo -> diff --git a/src/parser/testfiles.bad/incomplete-3.txt b/src/parser/testfiles.bad/incomplete-3.txt new file mode 100644 index 0000000..5b7d008 --- /dev/null +++ b/src/parser/testfiles.bad/incomplete-3.txt @@ -0,0 +1 @@ +/foo -> $(IgnoreNone) diff --git a/src/parser/testfiles.bad/incomplete-4.txt b/src/parser/testfiles.bad/incomplete-4.txt new file mode 100644 index 0000000..7073e76 --- /dev/null +++ b/src/parser/testfiles.bad/incomplete-4.txt @@ -0,0 +1,2 @@ +{ +/foo -> $(IgnoreNone); diff --git a/src/parser/testfiles.bad/incomplete-5.txt b/src/parser/testfiles.bad/incomplete-5.txt new file mode 100644 index 0000000..533ee7f --- /dev/null +++ b/src/parser/testfiles.bad/incomplete-5.txt @@ -0,0 +1,2 @@ +/foo -> $(IgnoreNone); +} diff --git a/src/parser/testfiles.bad/incomplete-6.txt b/src/parser/testfiles.bad/incomplete-6.txt new file mode 100644 index 0000000..ff668ee --- /dev/null +++ b/src/parser/testfiles.bad/incomplete-6.txt @@ -0,0 +1,4 @@ +(emailto="foo@bar +{ +/foo -> $(IgnoreNone); +} diff --git a/src/parser/testfiles.bad/incomplete-7.txt b/src/parser/testfiles.bad/incomplete-7.txt new file mode 100644 index 0000000..82df1f7 --- /dev/null +++ b/src/parser/testfiles.bad/incomplete-7.txt @@ -0,0 +1,4 @@ +(emailto="foo@bar" +{ +/foo -> $(IgnoreNone); +} diff --git a/src/parser/testfiles.bad/relpath.txt b/src/parser/testfiles.bad/relpath.txt new file mode 100644 index 0000000..ac86154 --- /dev/null +++ b/src/parser/testfiles.bad/relpath.txt @@ -0,0 +1 @@ +foo -> $(IgnoreNone); diff --git a/src/parser/testfiles/basic.txt b/src/parser/testfiles/basic.txt new file mode 100644 index 0000000..86c70fe --- /dev/null +++ b/src/parser/testfiles/basic.txt @@ -0,0 +1,3 @@ +/foo -> +S; +/bar -> $(IgnoreNone); +!/baz; diff --git a/src/parser/testfiles/directives.txt b/src/parser/testfiles/directives.txt index 47255b0..7e9446a 100644 --- a/src/parser/testfiles/directives.txt +++ b/src/parser/testfiles/directives.txt @@ -1,4 +1,4 @@ -# replace your_host with the name of your host. +# Exercises the ifhost conditional, assuming your host answers to 'localhost'. # parser will echo YES1 through YES9 # there's a problem with the parser if it echoes NO @@ -8,12 +8,12 @@ @@print +YES1 @@endif -@@ifhost bar || your_host||baz +@@ifhost bar || localhost||baz @@ifhost foo - @@ifhost your_host + @@ifhost localhost @@error +NO2; @@else @@error +NO3; @@ -35,9 +35,9 @@ - @@ifhost your_host + @@ifhost localhost - @@ifhost your_host + @@ifhost localhost @@print +YES4; @@else @@error +NO6; @@ -47,7 +47,7 @@ @@else - @@ifhost your_host + @@ifhost localhost @@error +NO7; @@else @@error +NO8; @@ -57,7 +57,7 @@ @@endif - @@ifhost your_host + @@ifhost localhost @@print +YES6; @@else @@error +NO10; @@ -70,11 +70,11 @@ @@endif - @@ifhost your_host || baz + @@ifhost localhost || baz @@print +YES8; @@endif - @@ifhost baz || your_host + @@ifhost baz || localhost @@print +YES9; @@endif @@ -87,7 +87,7 @@ @@ifhost foo - @@ifhost your_host + @@ifhost localhost @@error +NO13; @@else @@error +NO14; @@ -113,7 +113,7 @@ @@error +NO20; @@endif - @@ifhost your_host + @@ifhost localhost @@error +NO21; @@else @@error +NO22; diff --git a/src/parser/testfiles/empty.txt b/src/parser/testfiles/empty.txt new file mode 100644 index 0000000..e69de29 diff --git a/src/parser/testfiles/ifhost.txt b/src/parser/testfiles/ifhost.txt new file mode 100644 index 0000000..4117d1c --- /dev/null +++ b/src/parser/testfiles/ifhost.txt @@ -0,0 +1,6 @@ +@@ifhost localhost + @@print Hello World + /foo -> $(IgnoreNone); +@@else + @@error Failed +@@endif diff --git a/src/parser/testfiles/variable.txt b/src/parser/testfiles/variable.txt new file mode 100644 index 0000000..f651b03 --- /dev/null +++ b/src/parser/testfiles/variable.txt @@ -0,0 +1,7 @@ +@@section GLOBAL +FOO =/foo ; +BAR = +pinug ; + +@@section FS +$(FOO) -> $(BAR); + diff --git a/src/parser/tokens.l b/src/parser/tokens.l index 94bc773..d6a45cd 100644 --- a/src/parser/tokens.l +++ b/src/parser/tokens.l @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -311,12 +311,12 @@ END {WS}*{DIRECTIVE}{WS}*end *mpstring = strW; -#ifdef _DEBUG +#ifdef DEBUG TSTRING strDisplay = *mpstring; cDisplayEncoder e; e.Encode( strDisplay ); d.TraceDetail("interpreted as --> <%s>\n", strDisplay.c_str()); -#endif // _DEBUG +#endif // DEBUG // attach to lval yylval.mpString = mpstring; diff --git a/src/siggen/Makefile.am b/src/siggen/Makefile.am index b56566e..f400881 100644 --- a/src/siggen/Makefile.am +++ b/src/siggen/Makefile.am @@ -16,7 +16,7 @@ siggen_HEADERS = \ siggen.h siggencmdline.h siggenstrings.h stdsiggen.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit -CLEANFILES = ../../bin/siggen +CLEANFILES = ../../bin/siggen *.gcno *.gcda all: $(sbin_PROGRAMS) @test -d ../../bin && $(LN) -f $(sbin_PROGRAMS) ../../bin diff --git a/src/siggen/Makefile.in b/src/siggen/Makefile.in index 05165fb..8db2435 100644 --- a/src/siggen/Makefile.in +++ b/src/siggen/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -295,7 +295,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -319,7 +318,7 @@ siggen_SOURCES = \ siggen_HEADERS = \ siggen.h siggencmdline.h siggenstrings.h stdsiggen.h -CLEANFILES = ../../bin/siggen +CLEANFILES = ../../bin/siggen *.gcno *.gcda all: all-am .SUFFIXES: diff --git a/src/siggen/siggen.cpp b/src/siggen/siggen.cpp index 06b63a8..338f897 100644 --- a/src/siggen/siggen.cpp +++ b/src/siggen/siggen.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -67,5 +67,5 @@ cSiggen::cSiggen() TSS_Dependency( cTWCrypto ); } -// eof: siggen.cpp + diff --git a/src/siggen/siggen.h b/src/siggen/siggen.h index 666bec9..2e79351 100644 --- a/src/siggen/siggen.h +++ b/src/siggen/siggen.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/siggen/siggencmdline.cpp b/src/siggen/siggencmdline.cpp index 514fcc5..24f2d45 100644 --- a/src/siggen/siggencmdline.cpp +++ b/src/siggen/siggencmdline.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/siggen/siggencmdline.h b/src/siggen/siggencmdline.h index 585eb25..b31d49a 100644 --- a/src/siggen/siggencmdline.h +++ b/src/siggen/siggencmdline.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/siggen/siggenmain.cpp b/src/siggen/siggenmain.cpp index 0427b71..94ca8a4 100644 --- a/src/siggen/siggenmain.cpp +++ b/src/siggen/siggenmain.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -43,7 +43,7 @@ #include "core/cmdlineparser.h" #include "core/errorbucketimpl.h" #include "core/usernotifystdout.h" -#include "core/timebomb.h" +#include "core/epoch.h" #include "fs/fsstrings.h" #include "tw/twstrings.h" #include "tw/twutil.h" // for cTWUtil::PrintErrorMsg @@ -104,7 +104,7 @@ int __cdecl _tmain(int argc, const TCHAR** argv) { int ret = 0; - if (TimeBombExploded()) + if (CheckEpoch()) return 1; try diff --git a/src/siggen/siggenstrings.cpp b/src/siggen/siggenstrings.cpp index fb8a8c2..5257d96 100644 --- a/src/siggen/siggenstrings.cpp +++ b/src/siggen/siggenstrings.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -75,5 +75,5 @@ TSS_BeginStringtable( cSiggen ) TSS_EndStringtable( cSiggen ) -// eof: siggenstrings.cpp + diff --git a/src/siggen/siggenstrings.h b/src/siggen/siggenstrings.h index e026f10..badc831 100644 --- a/src/siggen/siggenstrings.h +++ b/src/siggen/siggenstrings.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/siggen/stdsiggen.cpp b/src/siggen/stdsiggen.cpp index 54e47e1..1bf9da2 100644 --- a/src/siggen/stdsiggen.cpp +++ b/src/siggen/stdsiggen.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,4 +37,4 @@ // #include "stdsiggen.h" -// eof: stdsiggen.cpp + diff --git a/src/siggen/stdsiggen.h b/src/siggen/stdsiggen.h index 874dc91..fae8afe 100644 --- a/src/siggen/stdsiggen.h +++ b/src/siggen/stdsiggen.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/test-harness/tests/chpass.pm b/src/test-harness/tests/chpass.pm new file mode 100644 index 0000000..3e201f2 --- /dev/null +++ b/src/test-harness/tests/chpass.pm @@ -0,0 +1,84 @@ + +use twtools; + +package chpass; + +###################################################################### +# One time module initialization goes in here... +# +BEGIN { + $description = "change passphrases test"; +} + +###################################################################### +# +# Initialize, get ready to run this test... +# +sub initialize() { + +} + + +###################################################################### +# +# Run the test. +# +sub run() { + + my $twpassed = 1; + my $newpass = "password"; + + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); + + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --change-passphrases -S $twtools::twrootdir/$twtools::twsitekeyloc --site-passphrase $newpass --site-passphrase-old $twtools::twsitepass`); + if ( $? != 0 ) { + twtools::logStatus("first change site passphrase failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --change-passphrases -S $twtools::twrootdir/$twtools::twsitekeyloc --site-passphrase $twtools::twsitepass --site-passphrase-old $newpass`); + if ( $? != 0 ) { + twtools::logStatus("second change site passphrase failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --change-passphrases -L $twtools::twrootdir/$twtools::twlocalkeyloc --local-passphrase $newpass --local-passphrase-old $twtools::twlocalpass`); + if ( $? != 0 ) { + twtools::logStatus("first change local passphrase failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --change-passphrases -L $twtools::twrootdir/$twtools::twlocalkeyloc --local-passphrase $twtools::twlocalpass --local-passphrase-old $newpass`); + if ( $? != 0 ) { + twtools::logStatus("second change local passphrase failed\n"); + $twpassed = 0; + } + + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; + print "PASSED\n"; + return 1; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + return 0; + } +} + + + +###################################################################### +# One time module cleanup goes in here... +# +END { +} + +1; diff --git a/src/test-harness/tests/complex.pm b/src/test-harness/tests/complex.pm index 201f9f0..15ad9b9 100644 --- a/src/test-harness/tests/complex.pm +++ b/src/test-harness/tests/complex.pm @@ -119,8 +119,8 @@ EOT # sub initialize() { - my $twstr = getPolicyFileString(); - twtools::GeneratePolicyFile($twstr); + my $twstr = getPolicyFileString(); + twtools::GeneratePolicyFile($twstr); } @@ -131,29 +131,36 @@ sub initialize() { # sub run() { - my $twpassed = 1; + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); - twtools::logStatus("*** Beginning $description\n"); - printf("%-30s", "-- $description"); + if ($^O eq "skyos" || $^O eq "gnu") { + ++$twtools::twskippedtests; + print "SKIPPED; TODO: OS has fewer expected changes here; refactor so we can test for correct values\n"; + return; + } - ######################################################### - # - # Run the tests describe above in the %TESTS structure. - # - $twpassed = twtools::RunIntegrityTests(%TESTS); + my $twpassed = 1; + + ######################################################### + # + # Run the tests describe above in the %TESTS structure. + # + $twpassed = twtools::RunIntegrityTests(%TESTS); - ######################################################### - # - # See if the tests all succeeded... - # - if ($twpassed) { + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { print "PASSED\n"; - } - else { + ++$twtools::twpassedtests; + } + else { ++$twtools::twfailedtests; print "*FAILED*\n"; - } + } } diff --git a/src/test-harness/tests/crc32.pm b/src/test-harness/tests/crc32.pm index 28a071a..764eccf 100644 --- a/src/test-harness/tests/crc32.pm +++ b/src/test-harness/tests/crc32.pm @@ -28,39 +28,48 @@ sub initialize() { # sub run() { - my $twpassed = 1; + my $twpassed = 1; - twtools::logStatus("*** Beginning $description\n"); - printf("%-30s", "-- $description"); + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); + # lets see if the system 'cksum' agree's with siggen's crc32 value + # Doing split with ' ' instead of / / because some flavors of cksum + # like to separate fields with tabs, as seen on Solaris 10. + # + my ($crc32, undef) = split(' ', `cksum $twtools::twrootdir/test`); - # lets see if the system 'cksum' agree's with siggen's md5 hash - # - my ($crc32, undef) = split(/ /, `cksum $twtools::twrootdir/test`); - my $siggen = `$twtools::twrootdir/bin/siggen -h -t -C $twtools::twrootdir/test`; + if ($crc32 eq "") { + ++$twtools::twskippedtests; + print "SKIPPED\n"; + return; + } - chomp $md5sum; - chomp $siggen; + my $siggen = `$twtools::twrootdir/bin/siggen -h -t -C $twtools::twrootdir/test`; - # cksum issues results in decimal, so get siggen's result in base10. - $siggen = hex($siggen); + chomp $crc32; + chomp $siggen; - twtools::logStatus(" cksum reports: $crc32\n"); - twtools::logStatus("siggen reports: $siggen\n"); + # cksum issues results in decimal, so get siggen's result in base10. + $siggen = hex($siggen); - $twpassed = $crc32 == $siggen; + twtools::logStatus(" cksum reports: $crc32\n"); + twtools::logStatus("siggen reports: $siggen\n"); - ######################################################### - # - # See if the tests all succeeded... - # - if ($twpassed) { + $twpassed = ($crc32 eq $siggen); + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { print "PASSED\n"; - } - else { + ++$twtools::twpassedtests; + } + else { ++$twtools::twfailedtests; print "*FAILED*\n"; - } + } } diff --git a/src/test-harness/tests/createpolicy.pm b/src/test-harness/tests/createpolicy.pm new file mode 100644 index 0000000..ecf63d5 --- /dev/null +++ b/src/test-harness/tests/createpolicy.pm @@ -0,0 +1,121 @@ + +use twtools; + +package createpolicy; + + +###################################################################### +# One time module initialization goes in here... +# +BEGIN +{ + $description = "policy creation test"; + $testpolicydir = "$twtools::twrootdir/../../parser/testfiles"; + $badpolicydir = "$twtools::twrootdir/../../parser/testfiles.bad"; + $twpassed = 1; +} + + +###################################################################### +# Try all policy files in specified directory, & verify each returns expected value +# +sub test_policy_dir +{ + my ($policydir, $expected) = @_; + # my $twpassed = 1; + + opendir my $dir, $policydir or return 0; + my @files = readdir $dir; + closedir $dir; + + foreach my $current_file (@files) { + + if ($current_file eq "." || $current_file eq ".." ) { + next; + } + + twtools::logStatus "Trying policy text $policydir/$current_file\n"; + + twtools::CreatePolicy({policy-text => "$policydir/$current_file"}); + if ( $? != $expected ) { + twtools::logStatus ("*** create-polfile with $policydir/$current_file failed, error = $?\n"); + $twpassed = 0; + } + } + + twtools::logStatus("Done with policy dir $policydir, result = $twpassed\n"); + return $twpassed; +} + + +###################################################################### +# +# Run the test. +# +sub run +{ + my $out = 1; + + + # First try a bunch of policies that are supposed to succeed + # + twtools::logStatus("*** Beginning policy creation test\n"); + printf("%-30s", "-- policy creation test"); + + test_policy_dir( "$testpolicydir", 0 ); + if ($twpassed) { + ++$twtools::twpassedtests; + print "PASSED\n"; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + $out = 0; + } + + + # Now try some bad policies + # + twtools::logStatus("*** Beginning bad policy rejection test\n"); + printf("%-30s", "-- bad policy rejection test"); + + $twpassed = 1; + ++$twtools::twtotaltests; + + test_policy_dir( "$badpolicydir", 256 ); + if ($twpassed) { + ++$twtools::twpassedtests; + print "PASSED\n"; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + $out = 0; + } + + + return $out; +} + + + +###################################################################### +# +# Initialize the test +# + +sub initialize +{ + return 1; +} + + +###################################################################### +# One time module cleanup goes in here... +# +END +{ +} + +1; + diff --git a/src/test-harness/tests/crypto.pm b/src/test-harness/tests/crypto.pm new file mode 100644 index 0000000..795f078 --- /dev/null +++ b/src/test-harness/tests/crypto.pm @@ -0,0 +1,108 @@ + +use twtools; + +package crypto; + +###################################################################### +# One time module initialization goes in here... +# +BEGIN { + $description = "file crypto test"; +} + + +###################################################################### +# PolicyFileString -- return the policy text as a string +# +sub PolicyFileString +{ + return < +M; #read only plus MD5 + +POLICY_END + +} + + +###################################################################### +# +# Initialize, get ready to run this test... +# +sub initialize() { + + my $twstr = PolicyFileString(); + twtools::GeneratePolicyFile($twstr); + +} + + +###################################################################### +# +# Run the test. +# +sub run() { + + my $twpassed = 1; + my $testpath = "$twtools::twrootdir/$twtools::twpolfileloc"; + + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); + + if ( ! twtools::ExamineEncryption("$testpath")) + { + twtools::logStatus("first examine encryption failed\n"); + $twpassed = 0; + } + + twtools::logStatus("testing file crypto removal...\n"); + if ( !twtools::RemoveEncryption("$testpath")) + { + twtools::logStatus("remove encryption failed\n"); + $twpassed = 0; + } + + if ( ! twtools::ExamineEncryption("$testpath")) + { + twtools::logStatus("second examine encryption failed\n"); + $twpassed = 0; + } + + twtools::logStatus("testing file crypto...\n"); + if ( ! twtools::AddEncryption("$testpath")) + { + twtools::logStatus("add encryption failed\n"); + $twpassed = 0; + } + + if ( ! twtools::ExamineEncryption("$testpath")) + { + twtools::logStatus("third examine encryption failed\n"); + $twpassed = 0; + } + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; + print "PASSED\n"; + return 1; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + return 0; + } +} + + + +###################################################################### +# One time module cleanup goes in here... +# +END { +} + +1; diff --git a/src/test-harness/tests/dbupdate.pm b/src/test-harness/tests/dbupdate.pm index 9b0c448..d9c5875 100644 --- a/src/test-harness/tests/dbupdate.pm +++ b/src/test-harness/tests/dbupdate.pm @@ -9,7 +9,6 @@ package dbupdate; # BEGIN { - # This is the root directory we will be integrity checking # $root = "$twtools::twcwd/$twtools::twrootdir/dbupdate-test"; @@ -135,7 +134,7 @@ sub PrepareForTest # Initialize the database # - twtools::initializeDatabase(); + twtools::InitializeDatabase(); } ###################################################################### @@ -143,49 +142,56 @@ sub PrepareForTest # sub RunBasicTest { - PrepareForTest(); - - printf("%-30s", "-- dbupdate.basic test"); + twtools::logStatus("*** Beginning dbupdate.basic test\n"); + printf("%-30s", "-- dbupdate.basic test"); - # make some violations... - # - MoveFile ( "meow.txt", "cat.txt" ); - CreateFile( "dog/bark.txt", "bark bark bark" ); - - # run the integrity check... - # - twtools::runIntegrityCheck(); + PrepareForTest(); - # Make sure we got 4 violations: 2 mod, 1 add, 1 rm. - # - my ($n, $a, $r, $c) = - twtools::analyzeReport( twtools::runReport() ); - - if( ($n != 4) || ($a != 1) || ($r != 1) || ($c != 2) ) - { - print "FAILED -- initial integrity check was wack!"; - return 0; - } + # make some violations... + # + MoveFile ( "meow.txt", "cat.txt" ); + CreateFile( "dog/bark.txt", "bark bark bark" ); - # do the database update... - # - twtools::updateDatabase(); + # run the integrity check... + # + twtools::RunIntegrityCheck(); - # do another IC and make sure there are no violations - # - twtools::runIntegrityCheck(); + # Make sure we got 4 violations: 2 mod, 1 add, 1 rm. + # + my $dir_mods = (($^O eq "skyos") || ($^O eq "dragonfly")) ? 0 : 1; + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + my $n_expected = $dir_mods ? 4 : 3; + my $c_expected = $dir_mods ? 2 : 1; - ($n, $a, $r, $c) = - twtools::analyzeReport( twtools::runReport() ); - - if( $n != 0 ) - { - print "FAILED -- violations after update!"; - return 0; - } - - print "PASSED!!!\n"; - return 1; + if( ($n != $n_expected) || ($a != 1) || ($r != 1) || ($c != $c_expected) ) { + + twtools::logStatus("FAILED -- initial integrity check had unexpected results\n"); + return 0; + } + + # do the database update... + # + if (0 != twtools::UpdateDatabase()) + { + twtools::logStatus("FAILED -- db update did not succeed\n"); + return 0; + } + + # do another IC and make sure there are no violations + # + twtools::RunIntegrityCheck(); + + ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + + if( $n != 0 ) + { + twtools::logStatus("FAILED -- violations after update\n"); + return 0; + } + + ++$twtools::twpassedtests; + print "PASSED\n"; + return 1; } ###################################################################### @@ -193,78 +199,87 @@ sub RunBasicTest # sub RunSecureModeTest { - PrepareForTest(); - - printf("%-30s", "-- dbupdate.secure-mode test"); + twtools::logStatus("*** Beginning dbupdate.secure-mode test\n"); + printf("%-30s", "-- dbupdate.secure-mode test"); - # make a violation and generate a report - # - CreateFile( "dog/bark.txt", "bark bark bark" ); - twtools::runIntegrityCheck( { report => $report1 } ); + PrepareForTest(); - # change the same file in a slightly different way and generate - # another report - # - CreateFile( "dog/bark.txt", "bark bark bark woof" ); - twtools::runIntegrityCheck( { report => $report2 } ); + # make a violation and generate a report + # + CreateFile( "dog/bark.txt", "bark bark bark" ); + twtools::RunIntegrityCheck( { report => $report1 } ); - # Remove a file and generate a third report - # - RemoveFile( "dog/bark.txt" ); - twtools::runIntegrityCheck( { report => $report3 } ); - - # Add a file and generate the fourth report - # - CreateFile( "dog/cow.txt", "moo moo" ); - twtools::runIntegrityCheck( { report => $report4 } ); - + # change the same file in a slightly different way and generate + # another report + # + CreateFile( "dog/bark.txt", "bark bark bark woof" ); + twtools::RunIntegrityCheck( { report => $report2 } ); - # Update the database with report 1. - # - twtools::updateDatabase( { report => $report1 } ); + # Remove a file and generate a third report + # + RemoveFile( "dog/bark.txt" ); + twtools::RunIntegrityCheck( { report => $report3 } ); - # Try to update the database with report 2 ... this should fail - # in secure-mode == high because the "old" values don't match. - # - if( twtools::updateDatabase( - { report => $report2, secure-mode => "high" } ) ) - { - print "FAILED ... Secure-mode high didn't catch a bad update!"; - return 0; - } + # Add a file and generate the fourth report + # + CreateFile( "dog/cow.txt", "moo moo" ); + twtools::RunIntegrityCheck( { report => $report4 } ); - # do a high severity update with report3 -- this should - # succeed - # - if( ! twtools::updateDatabase( - { report => $report3, secure-mode => "high" } ) ) - { - print "FAILED ... Update with report 3 failed!"; - return 0; - } - - # Try 2 again ... now we are trying to update an object that - # doesn't exist in the database at all. This should - # succeed in low but fail in high. - # - if( twtools::updateDatabase( - { report => $report2, secure-mode => "high" } ) ) - { - print "FAILED ... Update with report 2 after 3 succeeded in high mode!"; - return 0; - } + # Update the database with report 1. + # + twtools::UpdateDatabase( { report => $report1 } ); - if( ! twtools::updateDatabase( - { report => $report2, secure-mode => "low" } ) ) - { - print "FAILED ... Update with report 2 after 3 failed in low mode!"; - return 0; - } - - - - print "PASSED!!!\n"; - return 1; + # Try to update the database with report 1 again ... this should fail + # in secure-mode == high because the db can't accept same changes again. + # + if( 0 == twtools::UpdateDatabase( + { report => $report1, secure-mode => "high" } ) ) + { + twtools::logStatus("FAILED ... Secure-mode high didn't catch a bad update\n"); + return 0; + } + + # Try to update the database with report 2 ... this should fail + # in secure-mode == high because the "old" values don't match. + # + if( 0 == twtools::UpdateDatabase( + { report => $report2, secure-mode => "high" } ) ) + { + twtools::logStatus("FAILED ... Secure-mode high didn't catch a bad update\n"); + return 0; + } + + # do a high severity update with report3 -- this should + # succeed + # + if( 0 != twtools::UpdateDatabase( + { report => $report3, secure-mode => "high" } ) ) + { + twtools::logStatus("FAILED ... Update with report 3 failed\n"); + return 0; + } + + # Try 2 again ... now we are trying to update an object that + # doesn't exist in the database at all. This should + # succeed in low but fail in high. + # + if( 0 == twtools::UpdateDatabase( + { report => $report2, secure-mode => "high" } ) ) + { + twtools::logStatus("FAILED ... Update with report 2 after 3 succeeded in high mode\n"); + return 0; + } + + if( 0 != twtools::UpdateDatabase( + { report => $report2, secure-mode => "low" } ) ) + { + twtools::logStatus("FAILED ... Update with report 2 after 3 failed in low mode\n"); + return 0; + } + + ++$twtools::twpassedtests; + print "PASSED\n"; + return 1; } @@ -275,9 +290,10 @@ sub RunSecureModeTest sub initialize { - # Make the policy file - # - twtools::generatePolicyFile( PolicyFileString() ); + # Make the policy file + # + twtools::GeneratePolicyFile( PolicyFileString() ); + return 1; } @@ -287,8 +303,26 @@ sub initialize # sub run { - RunBasicTest() || return; - RunSecureModeTest() || return; + eval { + RunBasicTest(); + } or do { + my $e = $@; + twtools::logStatus("Exception in DBUpdate RunBasicTest: $e\n"); + ++$twtools::twfailedtests; + print "*FAILED*\n"; + }; + + # bump the total test count since this file's a twofer + ++$twtools::twtotaltests; + + eval { + RunSecureModeTest(); + } or do { + my $e = $@; + twtools::logStatus("Exception in DBUpdate RunSecureModeTest: $e\n"); + ++$twtools::twfailedtests; + print "*FAILED*\n"; + }; } sub cleanup diff --git a/src/test-harness/tests/dirs.pm b/src/test-harness/tests/dirs.pm index b714b7d..dfbb37a 100644 --- a/src/test-harness/tests/dirs.pm +++ b/src/test-harness/tests/dirs.pm @@ -105,12 +105,12 @@ EOT # sub initialize() { - my $twstr = getPolicyFileString(); - twtools::GeneratePolicyFile($twstr); + my $twstr = getPolicyFileString(); + twtools::GeneratePolicyFile($twstr); - # this test requires a clean start of it's tree - # - system("rm -rf $twtools::twrootdir/" . $TESTS{"0-createTempDir"}{dir}); + # this test requires a clean start of it's tree + # + system("rm -rf $twtools::twrootdir/" . $TESTS{"0-createTempDir"}{dir}); } @@ -120,29 +120,37 @@ sub initialize() { # sub run() { - my $twpassed = 1; + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); - twtools::logStatus("*** Beginning $description\n"); - printf("%-30s", "-- $description"); + if (($^O eq "skyos") || ($^O eq "dragonfly")) { + ++$twtools::twskippedtests; + print "SKIPPED; TODO: OS has fewer expected changes here; refactor so we can test for correct values\n"; + return; + } - ######################################################### - # - # Run the tests describe above in the %TESTS structure. - # - $twpassed = twtools::RunIntegrityTests(%TESTS); + my $twpassed = 1; - ######################################################### - # - # See if the tests all succeeded... - # - if ($twpassed) { + ######################################################### + # + # Run the tests describe above in the %TESTS structure. + # + $twpassed = twtools::RunIntegrityTests(%TESTS); + + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; print "PASSED\n"; - } - else { + } + else { ++$twtools::twfailedtests; print "*FAILED*\n"; - } + } } diff --git a/src/test-harness/tests/email.pm b/src/test-harness/tests/email.pm new file mode 100644 index 0000000..f03eb09 --- /dev/null +++ b/src/test-harness/tests/email.pm @@ -0,0 +1,85 @@ + +use twtools; + +package email; + +###################################################################### +# One time module initialization goes in here... +# +BEGIN { + $description = "email test"; +} + + +###################################################################### +# +# Initialize, get ready to run this test... +# +sub initialize() { +} + + +###################################################################### +# +# Run the test. +# +sub run() { + + my $twpassed = 1; + + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); + + my($sending, undef, undef, $mailfrom, $mailto, $subject, undef, undef, undef, $body) = twtools::RunEmailTest(); + + # Verify that various lines in the test email output look right, + # including the RFC 2822-required CRLFs that should be in everything + # except $sending, which isn't part of the actual email. + # + if ( !($sending =~ "Sending a test message to: elvis\@mars")) { + twtools::logStatus("Unexpected sending line: $sending\n"); + $twpassed = 0; + } + + if ( !($mailfrom =~ "taz\@cat")) { + twtools::logStatus("Unexpected From: field: $mailfrom\n"); + $twpassed = 0; + } + + if ( !($mailto =~ "To: elvis\@mars\r")) { + twtools::logStatus("Unexpected To: field: $mailto\n"); + $twpassed = 0; + } + + if ( !($subject =~ "Subject: Test email message from Tripwire\r")) { + twtools::logStatus("Unexpected Subject field: $subject\n"); + $twpassed = 0; + } + + if ( !($body =~ "If you receive this message, email notification from tripwire is working correctly.\r")) { + twtools::logStatus("Unexpected message body: $body\n"); + $twpassed = 0; + } + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + print "PASSED\n"; + ++$twtools::twpassedtests; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + } +} + + +###################################################################### +# One time module cleanup goes in here... +# +END { +} + +1; diff --git a/src/test-harness/tests/hashes.pm b/src/test-harness/tests/hashes.pm index e9741bc..0cab2f7 100644 --- a/src/test-harness/tests/hashes.pm +++ b/src/test-harness/tests/hashes.pm @@ -125,6 +125,7 @@ sub run() { # See if the tests all succeeded... # if ($twpassed) { + ++$twtools::twpassedtests; print "PASSED\n"; } else { diff --git a/src/test-harness/tests/inoderef.pm b/src/test-harness/tests/inoderef.pm index 8711179..50117d1 100644 --- a/src/test-harness/tests/inoderef.pm +++ b/src/test-harness/tests/inoderef.pm @@ -77,8 +77,8 @@ EOT # sub initialize() { - my $twstr = getPolicyFileString(); - twtools::GeneratePolicyFile($twstr); + my $twstr = getPolicyFileString(); + twtools::GeneratePolicyFile($twstr); } @@ -89,29 +89,36 @@ sub initialize() { # sub run() { - my $twpassed = 1; + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); - twtools::logStatus("*** Beginning $description\n"); - printf("%-30s", "-- $description"); + if ($^O eq "skyos" || $^O eq "haiku" || $^O eq "syllable") { + ++$twtools::twskippedtests; + print "SKIPPED; OS doesn't support hardlinks.\n"; + return; + } - ######################################################### - # - # Run the tests describe above in the %TESTS structure. - # - $twpassed = twtools::RunIntegrityTests(%TESTS); + my $twpassed = 1; + + ######################################################### + # + # Run the tests describe above in the %TESTS structure. + # + $twpassed = twtools::RunIntegrityTests(%TESTS); - ######################################################### - # - # See if the tests all succeeded... - # - if ($twpassed) { + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; print "PASSED\n"; - } - else { + } + else { ++$twtools::twfailedtests; print "*FAILED*\n"; - } + } } diff --git a/src/test-harness/tests/integritycheck.pm b/src/test-harness/tests/integritycheck.pm new file mode 100644 index 0000000..b72383b --- /dev/null +++ b/src/test-harness/tests/integritycheck.pm @@ -0,0 +1,439 @@ + +use twtools; + +package integritycheck; + + +###################################################################### +# One time module initialization goes in here... +# +BEGIN +{ + $description = "integrity check test"; + + # This is the root directory we will be integrity checking + # + $root = "$twtools::twcwd/$twtools::twrootdir/ic-test-a"; + $root2 = "$twtools::twcwd/$twtools::twrootdir/ic-test-b"; + + # Here are the names of the report files this test will create + # + $report1 = "$twtools::twcwd/$twtools::twrootdir/report/ic-1.twr"; + + $report2 = "$twtools::twcwd/$twtools::twrootdir/report/dbupdate-2.twr"; + $report3 = "$twtools::twcwd/$twtools::twrootdir/report/dbupdate-3.twr"; + $report4 = "$twtools::twcwd/$twtools::twrootdir/report/dbupdate-4.twr"; +} + +###################################################################### +# PolicyFileString -- return the policy text as a string +# +sub PolicyFileString +{ + return < \$(ReadOnly) +S -ab; #read only plus SHA-1 minus atime & blocks + } + + (rulename="RuleB", severity=200, emailto="elvis@mars") + { + $root2 -> \$(ReadOnly) +S -ab; #read only plus SHA-1 minus atime & blocks + } + +POLICY_END + +} + +###################################################################### +# CreateFile -- create a file with the specified contents +# +# input: path -- path to the file; relative to $root +# contents -- string to put in the file +# +sub CreateFile +{ + my ($path, $contents) = @_; + + system( "echo $contents > $path" ); + + $? && die "Create file failed for $path\n"; +} + +###################################################################### +# RemoveFile -- removes the named file +# +sub RemoveFile +{ + my ($path) = @_; + + if( -e "$path" ) + { + system( "rm -f $path" ); + } + + $? && die "Remove file failed for $root/$path\n"; +} + + +###################################################################### +# CreateDir -- create a directory +# +sub CreateDir +{ + my($dir) = @_; + + # NOTE: mkdir fails if it is already a directory! + # + if( ! -d "$dir" ) + { + system( "rm -f $dir" ); + system( "mkdir -p $dir" ); + + $? && die "Mkdir failed for $root/$dir\n"; + } +} + +###################################################################### +# MoveFile -- move a file from one place to another +# NOTE: file names are relative to $root +# +# input: old_name -- name of file to move +# new_name -- where it should be moved to +# +sub MoveFile +{ + my($old, $new) = @_; + + system( "mv $old $new" ); + $? && die "mv $old $new failed!\n"; +} + +###################################################################### +# PrintDatabase +# +sub PrintDatabase +{ + system( "$twtools::twrootdir/bin/twprint -m d -c $twtools::twrootdir/tw.cfg" ); +} + +###################################################################### +# PrintReport +# +sub PrintReport +{ + my ($report) = @_; + system( "$twtools::twrootdir/bin/twprint -m r -c $twtools::twrootdir/tw.cfg -r $report" ); +} + +###################################################################### +# PrepareForTest -- creates the files that each test will be +# integrity checking and initializes the database. +# +sub PrepareForTest +{ + # make sure we are cleaned up... + # + cleanup(); + + # Make the files we will be using... + # + CreateDir ( "$root"); + CreateDir ( "$root/subdir" ); + CreateFile( "$root/subdir/modify.txt", "hello world" ); + CreateFile( "$root/copy-src.txt", "asdf" ); + + CreateDir ( "$root2"); + CreateFile( "$root2/deleteme.txt", "goodbye cruel world" ); + + # Initialize the database + # + twtools::InitializeDatabase(); +} + + +###################################################################### +# +# Run the test. +# +sub run +{ + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); + + if ($^O eq "dragonfly") { + ++$twtools::twskippedtests; + print "SKIPPED; TODO: DragonflyBSD has fewer expected changes here; refactor so we can test for correct values\n"; + return; + } + + my $twpassed = 1; + my $dir_mods = ($^O eq "skyos") ? 0 : 1; + + PrepareForTest(); + + # make some violations... + # + MoveFile ( "$root/copy-src.txt", "$root/copy-dest.txt" ); + CreateFile( "$root/subdir/modify.txt", "bark bark bark" ); + RemoveFile( "$root2/deleteme.txt"); + + ####################################################### + # First run a full IC + # + twtools::RunIntegrityCheck(); + + # Make sure we got 6 violations: 3 mod, 1 add, 2 rm. + # + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + my $n_expected = $dir_mods ? 6 : 4; + my $c_expected = $dir_mods ? 3 : 1; + + if( ($n != $n_expected) || ($a != 1) || ($r != 2) || ($c != $c_expected) ) + { + twtools::logStatus("Full IC failed: $n $a $r $c\n"); + $twpassed = 0; + } + + # TODO: Make RunReport+AnalyzeReport play nice with signed report files + ####################################################### + # Do it again, but sign it this time. + # + #twtools::RunIntegrityCheck({trailing-opts => "-E -P $twtools::twlocalpass"}); + + # Make sure we got 6 violations: 3 mod, 1 add, 2 rm. + # + #my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + + #if( ($n != 6) || ($a != 1) || ($r != 2) || ($c != 3) ) + #{ + # twtools::logStatus("Full IC with signing failed: $n $a $r $c\n"); + # $twpassed = 0; + #} + + ####################################################### + # Now run 'just' the FS section, aka the whole policy + # + RemoveFile("$reportloc"); + twtools::RunIntegrityCheck(trailing-opts => "-x FS"); + + # Make sure we got 6 violations: 3 mod, 1 add, 2 rm. + # + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + my $n_expected = $dir_mods ? 6 : 4; + my $c_expected = $dir_mods ? 3 : 1; + + if( ($n != $n_expected) || ($a != 1) || ($r != 2) || ($c != $c_expected) ) + { + twtools::logStatus("IC with FS section failed: $n $a $r $c\n"); + $twpassed = 0; + } + + ####################################################### + # Now run a check ignoring the SHA attribute, should still return same changes + # + RemoveFile("$reportloc"); + twtools::RunIntegrityCheck(trailing-opts => "-i S"); + + # Make sure we got 6 violations: 3 mod, 1 add, 2 rm. + # + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + my $n_expected = $dir_mods ? 6 : 4; + my $c_expected = $dir_mods ? 3 : 1; + + if( ($n != $n_expected) || ($a != 1) || ($r != 2) || ($c != $c_expected) ) + { + twtools::logStatus("IC with FS section failed: $n $a $r $c\n"); + $twpassed = 0; + } + + ####################################################### + # Now just run RuleA + # + RemoveFile("$reportloc"); + twtools::RunIntegrityCheck({trailing-opts => "-R RuleA"}); + + # Make sure we got 4 violations this time: 2 mod, 1 add, 1 rm. + # + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + my $n_expected = $dir_mods ? 4 : 3; + my $c_expected = $dir_mods ? 2 : 1; + + if( ($n != $n_expected) || ($a != 1) || ($r != 1) || ($c != $c_expected) ) + { + twtools::logStatus("IC of Rule A failed: $n $a $r $c\n"); + $twpassed = 0; + } + + ####################################################### + # Now run severity level 200, meaning RuleB + # + RemoveFile("$reportloc"); + twtools::RunIntegrityCheck({trailing-opts => "-l 200"}); + + # Make sure we got 2 violations this time: 1 mod, 0 add, 1 rm. + # + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + my $n_expected = $dir_mods ? 2 : 1; + my $c_expected = $dir_mods ? 1 : 0; + + if( ($n != $n_expected) || ($a != 0) || ($r != 1) || ($c != $c_expected) ) + { + twtools::logStatus("IC of severity 200+ failed: $n $a $r $c\n"); + $twpassed = 0; + } + + ####################################################### + # Now run severity level "high", also meaning RuleB + # + RemoveFile("$reportloc"); + twtools::RunIntegrityCheck({trailing-opts => "-l high"}); + + # Make sure we got 2 violations this time: 1 mod, 0 add, 1 rm. + # + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + my $n_expected = $dir_mods ? 2 : 1; + my $c_expected = $dir_mods ? 1 : 0; + + if( ($n != $n_expected) || ($a != 0) || ($r != 1) || ($c != $c_expected) ) + { + twtools::logStatus("IC of severity 'high' failed: $n $a $r $c\n"); + $twpassed = 0; + } + + ####################################################### + # Now run against one object, modify.txt + # + RemoveFile("$reportloc"); + twtools::RunIntegrityCheck({trailing-opts => "$root/subdir/modify.txt"}); + + # Make sure we got 1 violation this time: 1 mod, 0 add, 0 rm. + # + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + + if( ($n != 1) || ($a != 0) || ($r != 0) || ($c != 1) ) + { + twtools::logStatus("IC of single object modify.txt failed: $n $a $r $c\n"); + $twpassed = 0; + } + + ####################################################### + # Run a few full check w/ email reporting, all the valid levels + # (we're configured to pipe to cat as a fake mailprogram) + # + RemoveFile("$reportloc"); + twtools::RunIntegrityCheck({trailing-opts => "-M -t 0"}); + twtools::RunIntegrityCheck({trailing-opts => "-M -t 1"}); + twtools::RunIntegrityCheck({trailing-opts => "-M -t 2"}); + twtools::RunIntegrityCheck({trailing-opts => "-M -t 3"}); + twtools::RunIntegrityCheck({trailing-opts => "-M -t 4"}); + + # Make sure we got 6 violations: 3 mod, 1 add, 2 rm. + # + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + my $n_expected = $dir_mods ? 6 : 4; + my $c_expected = $dir_mods ? 3 : 1; + + if( ($n != $n_expected) || ($a != 1) || ($r != 2) || ($c != $c_expected) ) + { + twtools::logStatus("Full IC failed: $n $a $r $c\n"); + $twpassed = 0; + } + + + ####################################################### + # Now run an interactive IC with cat as a fake editor, so DB gets auto updated. + # + RemoveFile("$reportloc"); + twtools::RunIntegrityCheck({trailing-opts => "-I -V cat -P $twtools::twlocalpass"}); + + # Make sure we got 6 violations: 3 mod, 1 add, 2 rm. + # + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + my $n_expected = $dir_mods ? 6 : 4; + my $c_expected = $dir_mods ? 3 : 1; + + if( ($n != $n_expected) || ($a != 1) || ($r != 2) || ($c != $c_expected) ) + { + twtools::logStatus("Interactive IC failed: $n $a $r $c\n"); + $twpassed = 0; + } + + ####################################################### + # Finally run another full IC to verify db was updated + # + also exercise the verbose & hex output options since we don't elsewhere. + # + RemoveFile("$reportloc"); + twtools::RunIntegrityCheck({trailing-opts => "-v -h"}); + + # Make sure we got no violations this time + # + my ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + + if( ($n != 0) || ($a != 0) || ($r != 0) || ($c != 0) ) + { + twtools::logStatus("IC after interactive IC failed: $n $a $r $c\n"); + $twpassed = 0; + } + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; + print "PASSED\n"; + return 1; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + return 0; + } +} + + + +###################################################################### +# +# Initialize the test +# + +sub initialize +{ + # Make the policy file + # + twtools::GeneratePolicyFile( PolicyFileString() ); + return 1; +} + + +sub cleanup +{ + # remove all of the files we were integrity checking... + # + system( "rm -rf $root/*" ); + system( "rm -rf $root2/*" ); + $? && print "WARNING: IC cleanup failed.\n"; + + # remove the report files we created... + # + system( "rm -f $report1" ) if (-e $report1); + system( "rm -r $report2" ) if (-e $report2); + system( "rm -r $report3" ) if (-e $report3); + system( "rm -r $report4" ) if (-e $report4); + +} + + +###################################################################### +# One time module cleanup goes in here... +# +END +{ +} + +1; + diff --git a/src/test-harness/tests/md5sum.pm b/src/test-harness/tests/md5sum.pm index 0a37a00..09e612f 100644 --- a/src/test-harness/tests/md5sum.pm +++ b/src/test-harness/tests/md5sum.pm @@ -37,21 +37,34 @@ sub run() { # lets see if the system 'md5sum' agree's with siggen's md5 hash # my ($md5sum, undef) = split(/ /, `md5sum $twtools::twrootdir/test`); + if ($mf5sum eq "") { + twtools::logStatus("md5sum not found, trying openssl instead\n"); + (undef, $md5sum) = split(/=/, `openssl md5 $twtools::twrootdir/test`); + } + if ($md5sum eq "") { + ++$twtools::twskippedtests; + print "SKIPPED\n"; + return; + } + my $siggen = `$twtools::twrootdir/bin/siggen -h -t -M $twtools::twrootdir/test`; chomp $md5sum; chomp $siggen; + $md5sum =~ s/^\s+|\s+$//g; + $siggen =~ s/^\s+|\s+$//g; twtools::logStatus("md5sum reports: $md5sum\n"); twtools::logStatus("siggen reports: $siggen\n"); - $twpassed = $md5sum == $siggen; + $twpassed = ($md5sum eq $siggen); ######################################################### # # See if the tests all succeeded... # if ($twpassed) { + ++$twtools::twpassedtests; print "PASSED\n"; } else { diff --git a/src/test-harness/tests/polupdate.pm b/src/test-harness/tests/polupdate.pm new file mode 100644 index 0000000..a554a1b --- /dev/null +++ b/src/test-harness/tests/polupdate.pm @@ -0,0 +1,301 @@ + +use twtools; + +package polupdate; + + +###################################################################### +# One time module initialization goes in here... +# +BEGIN +{ + # This is the root directory we will be integrity checking + # + $root1 = "$twtools::twcwd/$twtools::twrootdir/polupdate-test-1"; + $root2 = "$twtools::twcwd/$twtools::twrootdir/polupdate-test-2"; + $root3 = "$twtools::twcwd/$twtools::twrootdir/polupdate-test-3"; + + # Here are the names of the report files this test will create + # + $report1 = "$twtools::twcwd/$twtools::twrootdir/report/polupdate-1.twr"; + $report2 = "$twtools::twcwd/$twtools::twrootdir/report/polupdate-2.twr"; + $report3 = "$twtools::twcwd/$twtools::twrootdir/report/polupdate-3.twr"; + $report4 = "$twtools::twcwd/$twtools::twrootdir/report/polupdate-4.twr"; +} + +###################################################################### +# PolicyFileString -- return the policy text as a string +# +sub PolicyFileString +{ + return < \$(ReadOnly) +M -ab; #read only plus MD5 minus atime & blocks + $root2 -> \$(ReadOnly) +M -ab; #read only plus MD5 minus atime & blocks + +POLICY_END + +} + +###################################################################### +# PolicyFileStringNew -- return the policy text as a string +# +sub PolicyFileStringNew +{ + return < \$(ReadOnly) +S -ab; #read only plus SHA1 minus atime & blocks + $root3 -> \$(ReadOnly) +S -ab; #read only plus SHA1 minus atime & blocks + +POLICY_END + +} + +###################################################################### +# CreateFile -- create a file with the specified contents +# +# input: path -- *absolute* path to the file +# contents -- string to put in the file +# +sub CreateFile +{ + my ($path, $contents) = @_; + + system( "echo $contents > $path" ); + + $? && die "Create file failed for $path\n"; +} + +###################################################################### +# RemoveFile -- removes the named file by absolute path +# +sub RemoveFile +{ + my ($path) = @_; + + if( -e $path ) + { + system( "rm -f $path" ); + } + + $? && die "Remove file failed for $path\n"; +} + + +###################################################################### +# CreateDir -- create a directory +# +sub CreateDir +{ + my($dir) = @_; + + # NOTE: mkdir fails if it is already a directory! + # + if( ! -d "$dir" ) + { + system( "rm -f $dir" ); + system( "mkdir -p $dir" ); + + $? && die "Mkdir failed for $dir\n"; + } +} + +###################################################################### +# MoveFile -- move a file from one place to another +# NOTE: file names are relative to $root +# +# input: old_name -- name of file to move +# new_name -- where it should be moved to +# +sub MoveFile +{ + my($old, $new) = @_; + + system( "mv $old $new" ); + $? && die "mv $old $new failed!\n"; +} + +###################################################################### +# PrintDatabase +# +sub PrintDatabase +{ + system( "$twtools::twrootdir/bin/twprint -m d -c $twtools::twrootdir/tw.cfg" ); +} + +###################################################################### +# PrintReport +# +sub PrintReport +{ + my ($report) = @_; + system( "$twtools::twrootdir/bin/twprint -m r -c $twtools::twrootdir/tw.cfg -r $report" ); +} + +###################################################################### +# PrepareForTest -- creates the files that each test will be +# integrity checking and initializes the database. +# +sub PrepareForTest +{ + # make sure we are cleaned up... + # + cleanup(); + + # Make the files we will be using... + # + CreateDir ( "$root1/sub" ); + CreateFile( "$root1/sub/hello.txt", "hello world one" ); + + CreateDir ( "$root2/sub" ); + CreateFile( "$root2/sub/hello.txt", "hello world two" ); + + CreateDir ( "$root3/sub" ); + CreateFile( "$root3/sub/hello.txt", "hello world three" ); + + # Initialize the database + # + twtools::InitializeDatabase(); +} + +###################################################################### +# RunBasicTest -- performs a rudimentary UpdateDatabase test +# +sub RunBasicTest +{ + twtools::logStatus("*** Beginning polupdate.basic test\n"); + printf("%-30s", "-- polupdate.basic test"); + + PrepareForTest(); + + twtools::WritePolicyFile( PolicyFileStringNew() ); + if( ! twtools::UpdatePolicy() ) + { + twtools::logStatus("FAILED -- update policy returned nonzero\n"); + return 0; + } + + # do another IC and make sure there are no violations + # + twtools::RunIntegrityCheck(); + + ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + + if( $n != 0 ) + { + twtools::logStatus("FAILED -- violations after update\n"); + return 0; + } + + ++$twtools::twpassedtests; + print "PASSED\n"; + return 1; +} + +###################################################################### +# RunSecureModeTest -- performs a rudimentary UpdateDatabase test +# +sub RunSecureModeTest +{ + twtools::logStatus("*** Beginning polupdate.secure-mode test\n"); + printf("%-30s", "-- polupdate.secure-mode test"); + + PrepareForTest(); + + twtools::WritePolicyFile( PolicyFileStringNew() ); + if( ! twtools::UpdatePolicy({ secure-mode => "high" } )) + { + twtools::logStatus("FAILED -- update policy returned nonzero\n"); + return 0; + } + + # do another IC and make sure there are no violations + # + twtools::RunIntegrityCheck(); + + ($n, $a, $r, $c) = twtools::AnalyzeReport( twtools::RunReport() ); + + if( $n != 0 ) + { + twtools::logStatus("FAILED -- violations after update\n"); + return 0; + } + + ++$twtools::twpassedtests; + print "PASSED\n"; + return 1; +} + + +###################################################################### +# +# Initialize the test +# + +sub initialize +{ + # Make the policy file + # + twtools::GeneratePolicyFile( PolicyFileString() ); + return 1; +} + + +###################################################################### +# +# Run the test. +# +sub run +{ + eval { + RunBasicTest(); + } or do { + my $e = $@; + twtools::logStatus("Exception in Polupdate RunBasicTest: $e\n"); + ++$twtools::twfailedtests; + print "*FAILED*\n"; + }; + + # bump the total test count since this file's a twofer + ++$twtools::twtotaltests; + + eval { + RunSecureModeTest(); + } or do { + my $e = $@; + twtools::logStatus("Exception in Polupdate RunSecureModeTest: $e\n"); + ++$twtools::twfailedtests; + print "*FAILED*\n"; + }; +} + +sub cleanup +{ + # remove all of the files we were integrity checking... + # + system( "rm -rf $root1/*" ); + system( "rm -rf $root2/*" ); + system( "rm -rf $root3/*" ); + $? && print "WARNING: polupdate cleanup failed.\n"; + + # remove the report files we created... + # + system( "rm -f $report1" ) if (-e $report1); + system( "rm -r $report2" ) if (-e $report2); + system( "rm -r $report3" ) if (-e $report3); + system( "rm -r $report4" ) if (-e $report4); + +} + + +###################################################################### +# One time module cleanup goes in here... +# +END +{ +} + +1; + diff --git a/src/test-harness/tests/readonly.pm b/src/test-harness/tests/readonly.pm index 230e462..811b293 100644 --- a/src/test-harness/tests/readonly.pm +++ b/src/test-harness/tests/readonly.pm @@ -55,9 +55,9 @@ sub getPolicyFileString { return < \$(ReadOnly); -$twtools::twcwd/$twtools::twrootdir/$TESTS{"1-accessed"}{file} -> \$(ReadOnly); -$twtools::twcwd/$twtools::twrootdir/$TESTS{"2-removed"}{file} -> \$(ReadOnly); +$twtools::twcwd/$twtools::twrootdir/$TESTS{"0-permsChange"}{file} -> \$(ReadOnly) -a; +$twtools::twcwd/$twtools::twrootdir/$TESTS{"1-accessed"}{file} -> \$(ReadOnly) -a; +$twtools::twcwd/$twtools::twrootdir/$TESTS{"2-removed"}{file} -> \$(ReadOnly) -a; EOT @@ -71,8 +71,8 @@ EOT sub initialize() { - my $twstr = getPolicyFileString(); - twtools::GeneratePolicyFile($twstr); + my $twstr = getPolicyFileString(); + twtools::GeneratePolicyFile($twstr); } @@ -83,31 +83,42 @@ sub initialize() { # sub run() { - my $twpassed = 1; + twtools::logStatus("\n\n*** Beginning $description\n"); + printf("%-30s", "-- $description"); - twtools::logStatus("\n\n*** Beginning $description\n"); - - printf("%-30s", "-- $description"); - - ######################################################### - # - # Run the tests describe above in the %TESTS structure. - # - $twpassed = twtools::RunIntegrityTests(%TESTS); + if ($^O eq "skyos") { + ++$twtools::twskippedtests; + print "SKIPPED; SkyOS doesn't support readonly files.\n"; + return; + } elsif ($^O eq "gnu") { + ++$twtools::twskippedtests; + print "SKIPPED; TODO: Hurd has fewer expected changes here; refactor so we can test for correct values\n"; + return; + } - ######################################################### - # - # See if the tests all succeeded... - # - if ($twpassed) { + my $twpassed = 1; + + ######################################################### + # + # Run the tests describe above in the %TESTS structure. + # + $twpassed = twtools::RunIntegrityTests(%TESTS); + + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; print "PASSED\n"; return 0; - } - else { + } + else { print "*FAILED*\n"; ++$twtools::twfailedtests; - } + } } diff --git a/src/test-harness/tests/sha1sum.pm b/src/test-harness/tests/sha1sum.pm new file mode 100644 index 0000000..145a6a5 --- /dev/null +++ b/src/test-harness/tests/sha1sum.pm @@ -0,0 +1,83 @@ + +use twtools; + +package sha1sum; + +###################################################################### +# One time module initialization goes in here... +# +BEGIN { + + $description = "sha1 hash check"; +} + + +###################################################################### +# +# Initialize, get ready to run this test... +# +sub initialize() { + + twtools::CreateFile( { file => "test", contents => "deadbeef"x5000} ); +} + + +###################################################################### +# +# Run the test. +# +sub run() { + + my $twpassed = 1; + + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); + + + # lets see if the system 'sha1sum' agree's with siggen's sha1 hash + # + my ($sha1sum, undef) = split(/ /, `sha1sum $twtools::twrootdir/test`); + if ($sha1sum eq "") { + twtools::logStatus("sha1sum not found, trying openssl instead\n"); + (undef, $sha1sum) = split(/=/, `openssl sha1 $twtools::twrootdir/test`); + } + if ($sha1sum eq "") { + ++$twtools::twskippedtests; + print "SKIPPED\n"; + return; + } + + my $siggen = `$twtools::twrootdir/bin/siggen -h -t -S $twtools::twrootdir/test`; + + chomp $sha1sum; + chomp $siggen; + $sha1sum =~ s/^\s+|\s+$//g; + $siggen =~ s/^\s+|\s+$//g; + + twtools::logStatus("sha1sum reports: $sha1sum\n"); + twtools::logStatus("siggen reports: $siggen\n"); + + $twpassed = ($sha1sum eq $siggen); + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; + print "PASSED\n"; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + } +} + + +###################################################################### +# One time module cleanup goes in here... +# +END { +} + +1; diff --git a/src/test-harness/tests/siggen.pm b/src/test-harness/tests/siggen.pm new file mode 100644 index 0000000..f73ae90 --- /dev/null +++ b/src/test-harness/tests/siggen.pm @@ -0,0 +1,146 @@ + +use twtools; + +package siggen; + +###################################################################### +# One time module initialization goes in here... +# +BEGIN { + $description = "siggen test"; +} + +###################################################################### +# +# Initialize, get ready to run this test... +# +sub initialize() { + +} + + +###################################################################### +# +# Run the test. +# +sub run() { + + my $twpassed = 1; + + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); + + + twtools::logStatus(`ps > $twtools::twrootdir/hashme.txt`); + if ( $? != 0 ) { + twtools::logStatus("test file creation failed\n"); + $twpassed = 0; + } + + # SkyOS doesn't have FIFOs, so this won't work + if ( $^O ne "skyos") { + twtools::logStatus(`mkfifo $twtools::twrootdir/donthashme.fifo`); + if ( $? != 0 ) { + twtools::logStatus("test fifo creation failed\n"); + $twpassed = 0; + } + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen`); + if ( $? != 256 ) { + twtools::logStatus("no-args siggen failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen -h -t -a`); + if ( $? != 256 ) { + twtools::logStatus("no-args siggen failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen --help`); + if ( $? != 256 ) { + twtools::logStatus("siggen --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen --version`); + if ( $? != 0 ) { + twtools::logStatus("siggen --version failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("siggen --asdf failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen $twtools::twrootdir/hashme.txt`); + if ( $? != 0 ) { + twtools::logStatus("siggen hashme.txt failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen -a $twtools::twrootdir/hashme.txt`); + if ( $? != 0 ) { + twtools::logStatus("siggen -a hashme.txt failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen -h -t -a $twtools::twrootdir/hashme.txt`); + if ( $? != 0 ) { + twtools::logStatus("siggen -h -t -a hashme.txt failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen -a $twtools::twrootdir/donthashme.fifo`); + if ( $? != 256 ) { + twtools::logStatus("siggen -a donthashme.fifo failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen -h -t -a $twtools::twrootdir/donthashme.fifo`); + if ( $? != 256 ) { + twtools::logStatus("siggen -h -t -a donthashme.fifo failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen -a $twtools::twrootdir/no-existe.txt`); + if ( $? != 256 ) { + twtools::logStatus("siggen -a no-existe.txt failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/siggen -h -t -a $twtools::twrootdir/no-existe.txt`); + if ( $? != 256 ) { + twtools::logStatus("siggen -h -t -a no-existe.txt failed\n"); + $twpassed = 0; + } + + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; + print "PASSED\n"; + return 1; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + return 0; + } +} + + + +###################################################################### +# One time module cleanup goes in here... +# +END { +} + +1; diff --git a/src/test-harness/tests/sizes.pm b/src/test-harness/tests/sizes.pm index dac2594..b880bfe 100644 --- a/src/test-harness/tests/sizes.pm +++ b/src/test-harness/tests/sizes.pm @@ -97,6 +97,7 @@ sub run() { # See if the tests all succeeded... # if ($twpassed) { + ++$twtools::twpassedtests; print "PASSED\n"; } else { diff --git a/src/test-harness/tests/tripwire.pm b/src/test-harness/tests/tripwire.pm new file mode 100644 index 0000000..af7810c --- /dev/null +++ b/src/test-harness/tests/tripwire.pm @@ -0,0 +1,124 @@ + +use twtools; + +package tripwire; + +###################################################################### +# One time module initialization goes in here... +# +BEGIN { + $description = "tripwire options test"; +} + +###################################################################### +# +# Initialize, get ready to run this test... +# +sub initialize() { + +} + + +###################################################################### +# +# Run the test. +# +sub run() { + + my $twpassed = 1; + + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); + + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire`); + if ( $? != 2048 ) { + twtools::logStatus("no-args tripwire failed, error = $?\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire --version`); + if ( $? != 0 ) { + twtools::logStatus("tripwire --version failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire --help`); + if ( $? != 2048 ) { + twtools::logStatus("tripwire --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire --help all`); + if ( $? != 2048 ) { + twtools::logStatus("tripwire --help all failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire --help i c`); + if ( $? != 2048 ) { + twtools::logStatus("tripwire --help i c failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire --asdf 2>&1`); + if ( $? != 2048 ) { + twtools::logStatus("tripwire --asdf failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire --asdf --help 2>&1`); + if ( $? != 2048 ) { + twtools::logStatus("tripwire --asdf --help\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire -m 2>&1`); + if ( $? != 2048 ) { + twtools::logStatus("tripwire -m\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire -m Z 2>&1`); + if ( $? != 2048 ) { + twtools::logStatus("tripwire -m Z failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire -m -m 2>&1`); + if ( $? != 2048 ) { + twtools::logStatus("tripwire -m -m failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/tripwire -m i -c nope.cfg 2>&1`); + if ( $? != 2048 ) { + twtools::logStatus("tripwire -m -i -c nope.cfg\n"); + $twpassed = 0; + } + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; + print "PASSED\n"; + return 1; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + return 0; + } +} + + + +###################################################################### +# One time module cleanup goes in here... +# +END { +} + +1; diff --git a/src/test-harness/tests/twadmin.pm b/src/test-harness/tests/twadmin.pm new file mode 100644 index 0000000..6fe6050 --- /dev/null +++ b/src/test-harness/tests/twadmin.pm @@ -0,0 +1,413 @@ + +use twtools; + +package twadmin; + +###################################################################### +# One time module initialization goes in here... +# +BEGIN { + $description = "twadmin test"; +} + + +###################################################################### +# Return the policy file text for this test... +# +sub getPolicyFileString { + + return < +S; + + +EOT + +} + +###################################################################### +# +# Initialize, get ready to run this test... +# +sub initialize() { + + my $twstr = getPolicyFileString(); + twtools::GeneratePolicyFile($twstr); + +} + +sub runTests() { + + +} + +###################################################################### +# +# Run the test. +# +sub run() { + + my $twpassed = 1; + + + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); + + + ######################################################### + # + # print-policy & print-config variants + # + + twtools::PrintConfig(); + if ( $? != 0 ) { + twtools::logStatus("base print-cfgfile failed, error = $?\n"); + $twpassed = 0; + } + + twtools::PrintConfig(opts => "--verbose"); + if ( $? != 0 ) { + twtools::logStatus("print-cfgfile --verbose failed, error = $?\n"); + $twpassed = 0; + } + + twtools::PrintConfig(opts => "--silent"); + if ( $? != 0 ) { + twtools::logStatus("print-cfgfile --silent failed\, error = $?n"); + $twpassed = 0; + } + + twtools::PrintPolicy(); + if ( $? != 0 ) { + twtools::logStatus("base print-polfile failed, error = $?\n"); + $twpassed = 0; + } + + twtools::PrintPolicy(opts => "--verbose"); + if ( $? != 0 ) { + twtools::logStatus("print-polfile --verbose failed, error = $?\n"); + $twpassed = 0; + } + + twtools::PrintPolicy(opts => "--silent"); + if ( $? != 0 ) { + twtools::logStatus("print-polfile --silent failed, error = $?\n"); + $twpassed = 0; + } + + ######################################################### + # + # Now try misc help & version options + # + twtools::logStatus(`$twtools::twrootdir/bin/twadmin 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin, no args failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --asdf failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --help`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin -?`); + if ( $? != 256 ) { + twtools::logStatus("twadmin -? failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --help all`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --help all failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --help f p`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --help d r failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --help asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --help asdf failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --asdf --help 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --help --asdf failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin -m 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin -m failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin -m Z 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin -m Z failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin -m -m 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin -m -m failed\n"); + $twpassed = 0; + } + + ######################################################### + # + # Various missing files + # + twtools::logStatus(`$twtools::twrootdir/bin/twadmin -m P 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --create-polfile --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin -m P nope.txt 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --create-polfile --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin -m P -c nope.cfg nope.txt 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --create-polfile --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin -m P -S site.nope nope.txt 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --create-polfile --help failed\n"); + $twpassed = 0; + } + + + ######################################################### + # + # Per-mode help & errors + # + + # create-polfile + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --create-polfile --help`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --create-polfile --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --create-polfile --verbose --silent 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --help --create-polfile --verbose --silent failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --create-polfile --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --create-polfile --asdf failed\n"); + $twpassed = 0; + } + + + # create-cfgfile + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --create-cfgfile --help`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --create-cfgfile --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --create-cfgfile --verbose --silent 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --create-cfgfile --verbose --silent failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --create-cfgfile --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --create-cfgfile --asdf failed\n"); + $twpassed = 0; + } + + + # print-polfile + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --print-polfile --help`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --print-polfile --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --print-polfile --verbose --silent 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --print-polfile --verbose --silent failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --print-polfile --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --print-polfile --asdf failed\n"); + $twpassed = 0; + } + + + # print-cfgfile + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --print-cfgfile --help`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --print-cfgfile --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --print-cfgfile --verbose --silent 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --print-cfgfile --verbose --silent failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --print-cfgfile --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --print-cfgfile --asdf failed\n"); + $twpassed = 0; + } + + + # encrypt + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --encrypt --help`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --encrypt --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --encrypt --verbose --silent 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --encrypt --verbose --silent failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --encrypt --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --encrypt --asdf failed\n"); + $twpassed = 0; + } + + + # remove-encryption + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --remove-encryption --help`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --remove-encryption --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --remove-encryption --verbose --silent 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --remove-encryption --verbose --silent failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --remove-encryption --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --remove-encryption --asdf failed\n"); + $twpassed = 0; + } + + + # examine + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --examine --help`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --examine --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --examine --verbose --silent 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --examine --verbose --silent failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --examine --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --examine --asdf failed\n"); + $twpassed = 0; + } + + + # generate-keys + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --generate-keys --help`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --generate-keys --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --generate-keys --verbose --silent 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --generate-keys --verbose --silent failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --generate-keys--asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --generate-keys--asdf failed\n"); + $twpassed = 0; + } + + # change-passphrases + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --change-passphrases --help`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --change-passphrases --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --change-passphrases --verbose --silent 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --change-passphrases --verbose --silent` failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --change-passphrases --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twadmin --change-passphrases --asdf failed\n"); + $twpassed = 0; + } + + + ######################################################### + # + # Version + # + twtools::logStatus(`$twtools::twrootdir/bin/twadmin --version`); + if ( $? != 0 ) { + twtools::logStatus("twadmin --version failed\n"); + $twpassed = 0; + } + + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; + print "PASSED\n"; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + } +} + + +###################################################################### +# One time module cleanup goes in here... +# +END { +} + +1; diff --git a/src/test-harness/tests/twprint.pm b/src/test-harness/tests/twprint.pm new file mode 100644 index 0000000..7c7fda0 --- /dev/null +++ b/src/test-harness/tests/twprint.pm @@ -0,0 +1,282 @@ + +use twtools; + +package twprint; + +###################################################################### +# One time module initialization goes in here... +# +BEGIN { + + %TESTS = ( + + "twprintInit" => { + + changeFunc => \&twtools::MakeBigger, + createFunc => \&twtools::CreateFile, + file => "printme.txt", + perms => "a+w", + contents => "testing", + violations => "V:1 S:0 A:0 R:0 C:1" + }, + ); + + + $description = "twprint test"; +} + + +###################################################################### +# Return the policy file text for this test... +# +sub getPolicyFileString { + + return < +S; + + +EOT + +} + +###################################################################### +# +# Initialize, get ready to run this test... +# +sub initialize() { + + my $twstr = getPolicyFileString(); + twtools::GeneratePolicyFile($twstr); + +} + + +###################################################################### +# +# Run the test. +# +sub run() { + + my $twpassed = 1; + + twtools::logStatus("*** Beginning $description\n"); + printf("%-30s", "-- $description"); + + ######################################################### + # + # Run a check first, to set up for twprint exercises + # + $twpassed = twtools::RunIntegrityTests(%TESTS); + + + + ######################################################### + # + # Now run thru the valid report levels & verify return codes + # TODO: look for expected result in various report levels + + twtools::RunReport({ report-level => 0 }); + if ( $? != 0 ) { + twtools::logStatus("level 0 report failed\n"); + $twpassed = 0; + } + + twtools::RunReport({ report-level => 1 }); + if ( $? != 0 ) { + twtools::logStatus("level 1 report failed\n"); + $twpassed = 0; + } + + twtools::RunReport({ report-level => 2 }); + if ( $? != 0 ) { + twtools::logStatus("level 2 report failed\n"); + $twpassed = 0; + } + + twtools::RunReport({ report-level => 3 }); + if ( $? != 0 ) { + twtools::logStatus("level 3 report failed\n"); + $twpassed = 0; + } + + twtools::RunReport({ report-level => 4 }); + if ( $? != 0 ) { + twtools::logStatus("level 4 report failed\n"); + $twpassed = 0; + } + + twtools::RunReport({ report-level => "4 --verbose --hexadecimal" }); + if ( $? != 0 ) { + twtools::logStatus("level 4 report (verbose, hex) failed\n"); + $twpassed = 0; + } + + twtools::RunReport({ report-level => "4 --silent" }); + if ( $? != 0 ) { + twtools::logStatus("level 4 report (silent) failed\n"); + $twpassed = 0; + } + + ######################################################### + # + # Now some failure cases, to verify they fail + # + twtools::RunReport({ report-level => 5 }); + if ( $? != 256 ) { + twtools::logStatus("nonexistent level 5 report failed, result = $?\n"); + $twpassed = 0; + } + + twtools::RunReport({ report-level => "asdf" }); + if ( $? != 256 ) { + twtools::logStatus("nonexistent level 'asdf' report failed, result = $?\n"); + $twpassed = 0; + } + + twtools::RunReport({ report-level => "0 --help" }); + if ( $? != 256 ) { + twtools::logStatus("print-report help mode failed, result = $?\n"); + $twpassed = 0; + } + + twtools::RunReport({ report-level => "4 --verbose --silent" }); + if ( $? != 256 ) { + twtools::logStatus("print-report verbose vs silent failed, result = $?\n"); + $twpassed = 0; + } + + ######################################################### + # + # Now try db printing + # + twtools::RunDbPrint(); + if ( $? != 0 ) { + twtools::logStatus("db print failed\n"); + $twpassed = 0; + } + + twtools::RunDbPrint({ db-object-list => "$twtools::twrootdir/printme.txt" }); + if ( $? != 0 ) { + twtools::logStatus("db print failed\n"); + $twpassed = 0; + } + + twtools::RunDbPrint({ db-object-list => "$twtools::twrootdir/nonexistent.vbs" }); + if ( $? != 0 ) { + twtools::logStatus("db print failed\n"); + $twpassed = 0; + } + + ######################################################### + # + # Now try misc help & version options + # + twtools::logStatus(`$twtools::twrootdir/bin/twprint 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twprint, no args failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint --asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twprint --asdf failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint --help`); + if ( $? != 256 ) { + twtools::logStatus("twprint --help failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint -?`); + if ( $? != 256 ) { + twtools::logStatus("twprint -? failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint --help all`); + if ( $? != 256 ) { + twtools::logStatus("twprint --help all failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint --help d r`); + if ( $? != 256 ) { + twtools::logStatus("twprint --help d r failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint --help asdf 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twprint --help asdf failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint --asdf --help 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twprint --help --asdf failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint --print-dbfile --help`); + if ( $? != 256 ) { + twtools::logStatus("twprint --help --print-dbfile failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint --print-report --help `); + if ( $? != 256 ) { + twtools::logStatus("twprint --help --print-reportfile failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint -m Z 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twprint -m Z failed\n"); + $twpassed = 0; + } + + + twtools::logStatus(`$twtools::twrootdir/bin/twprint -m 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twprint -m failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint -m -m 2>&1`); + if ( $? != 256 ) { + twtools::logStatus("twprint -m -m failed\n"); + $twpassed = 0; + } + + twtools::logStatus(`$twtools::twrootdir/bin/twprint --version`); + if ( $? != 0 ) { + twtools::logStatus("twprint --version failed\n"); + $twpassed = 0; + } + + + ######################################################### + # + # See if the tests all succeeded... + # + if ($twpassed) { + ++$twtools::twpassedtests; + print "PASSED\n"; + } + else { + ++$twtools::twfailedtests; + print "*FAILED*\n"; + } +} + + +###################################################################### +# One time module cleanup goes in here... +# +END { +} + +1; diff --git a/src/test-harness/twtest.pl b/src/test-harness/twtest.pl index 1f7ea53..1611811 100755 --- a/src/test-harness/twtest.pl +++ b/src/test-harness/twtest.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; - +use lib '.'; use twtools; my @twtests = (); @@ -94,6 +94,8 @@ sub runTests { for $module (@twtests) { + ++$twtools::twtotaltests; + # use the module # eval qq{use tests::$module}; @@ -135,8 +137,9 @@ processCommandLine(); prepareListOfTests() if scalar(@twtests) == 0; # only if none were on the cmdline print "\n"; -print "initializing for tests...\n\n"; +print "initializing for tests on $^O...\n\n"; +print "logging to $ENV{'PWD'}/$twtools::twrootdir/status.log\n\n"; # all tests can assume a base configuration, i.e. default tw.cfg, site and local keys # @@ -151,7 +154,13 @@ print "=============\n\n"; # runTests(); -print "\n\n$twtools::twfailedtests test(s) failed...\n\n"; +# Any test that didn't report a status gets counted as skipped. +$twtools::twskippedtests += ($twtools::twtotaltests - ($twtools::twpassedtests + $twtools::twfailedtests + $twtools::twskippedtests)); + +print "\n\n$twtools::twtotaltests test(s) run\n"; +print "$twtools::twpassedtests test(s) passed\n"; +print "$twtools::twfailedtests test(s) failed\n"; +print "$twtools::twskippedtests test(s) skipped\n\n"; exit($twtools::twfailedtests); diff --git a/src/test-harness/twtools.pm b/src/test-harness/twtools.pm index 894a161..218511d 100644 --- a/src/test-harness/twtools.pm +++ b/src/test-harness/twtools.pm @@ -17,13 +17,18 @@ BEGIN { $twsitekeyloc = "key/site.key"; $twlocalkeyloc = "key/local.key"; $twpolicyloc = "policy/twpol.txt"; + $twpolfileloc = "policy/tw.pol"; $twcfgloc = "tw.cfg"; + $twsitepass = "testing"; $twlocalpass = "testing"; $twbinaries = "../../../../bin"; + $twtotaltests = 0; $twfailedtests = 0; + $twpassedtests = 0; + $twskippedtests = 0; # get's setup in twtest... # @@ -32,7 +37,7 @@ BEGIN { %twcfgdirs = ( ROOT => '', - POLFILE => 'policy/tw.pol', + POLFILE => $twpolfileloc, DBFILE => 'db/$(HOSTNAME).twd', REPORTFILE => 'report/$(HOSTNAME)-$(DATE).twr', SITEKEYFILE => $twsitekeyloc, @@ -49,9 +54,9 @@ BEGIN { EMAILREPORTLEVEL => '3', REPORTLEVEL => '3', MAILMETHOD => 'SENDMAIL', - SYSLOGREPORTING => 'false', - MAILPROGRAM => '/usr/lib/sendmail -oi -t' - + SYSLOGREPORTING => 'true', + MAILPROGRAM => 'cat', + MAILFROMADDRESS => 'taz@cat' ); } @@ -155,15 +160,107 @@ sub GenerateKeys { # sub SignConfigFile { - if (!-e "$twrootdir/tw.cfg") { + if (!-e "$twrootdir/$twcfgloc") { print "signing configuration file...\n" if $verbose; - logStatus(`$twrootdir/bin/twadmin -m F -Q $twsitepass -c $twrootdir/tw.cfg -S $twrootdir/$twsitekeyloc $twrootdir/twcfg.txt`); + logStatus(`$twrootdir/bin/twadmin -m F -Q $twsitepass -c $twrootdir/$twcfgloc -S $twrootdir/$twsitekeyloc $twrootdir/twcfg.txt`); } return ($? == 0); } +###################################################################### +# Examine encryption +# +sub ExamineEncryption { + + my ($filename) = @_; + + logStatus(`$twrootdir/bin/twadmin -m e -c $twrootdir/$twcfgloc $filename`); + + return ($? == 0); +} + + +###################################################################### +# Add encryption +# +sub AddEncryption { + + my ($filename) = @_; + logStatus "addding crypt to file...\n"; + logStatus(`$twrootdir/bin/twadmin -m E -c $twrootdir/$twcfgloc -P $twlocalpass -Q $twsitepass $filename 2>&1`); + + return ($? == 0); +} + + +###################################################################### +# Remove encryption +# + +sub RemoveEncryption { + + my ($filename) = @_; + + logStatus "removing crypto from file...\n"; + logStatus(`$twrootdir/bin/twadmin -m R -c $twrootdir/$twcfgloc -P $twlocalpass -Q $twsitepass $filename 2>&1`); + + return ($? == 0); +} + + +###################################################################### +# Print polfile +# + +sub PrintPolicy { + + my (%params) = %{$_[0]}; + logStatus "printing policy file...\n"; + + my (@out) = `$twrootdir/bin/twadmin -m p -c $twrootdir/$twcfgloc -p $twrootdir/$twpolfileloc -S $twrootdir/$twsitekeyloc $params{opts} 2>&1`; + + my ($result) = $?; + + logStatus(@out); + + return $result; +} + +###################################################################### +# Print polfile +# + +sub PrintConfig { + + my (%params) = %{$_[0]}; + + logStatus "printing config file...\n"; + my (@out) = `$twrootdir/bin/twadmin -m f -c $twrootdir/$twcfgloc $params{opts} 2>&1`; + + my ($result) = $?; + + logStatus(@out); + + return $result; +} + + +###################################################################### +# Write policy text to disk... Note the contents +# of the policy file are passed in as '$twstr'. +# +sub WritePolicyFile { + + my ($twstr) = @_; + + open(FH, ">$twrootdir/$twpolicyloc") || warn $!; + print FH $twstr; + close(FH); +} + + ###################################################################### # Generate and sign the policy file... Note the contents # of the policy file are passed in as '$twstr'. @@ -172,15 +269,39 @@ sub GeneratePolicyFile { my ($twstr) = @_; - open(FH, ">$twrootdir/$twpolicyloc") || warn $!; - print FH $twstr; - close(FH); + WritePolicyFile($twstr); print "generating policy file...\n" if $verbose; - logStatus(`$twrootdir/bin/twadmin -m P -c $twrootdir/tw.cfg -Q $twsitepass -p $twrootdir/policy/tw.pol $twrootdir/policy/twpol.txt`); + my (@out) = `$twrootdir/bin/twadmin -m P -c $twrootdir/$twcfgloc -Q $twsitepass -p $twrootdir/$twpolfileloc $twrootdir/$twpolicyloc 2>&1`; - return ($? == 0); + my ($result) = $?; + + logStatus(@out); + + return $result; +} + + +###################################################################### +# Generate and sign the policy file... Note the contents +# of the policy file are passed in as '$twstr'. +# +sub CreatePolicy { + + my (%params) = %{$_[0]}; + + $params{policy-text} = "$twrootdir/$twpolicyloc" if( ! defined($params{policy-text}) ); + + print "generating policy file...\n" if $verbose; + + my (@out) = `$twrootdir/bin/twadmin -m P -c $twrootdir/$twcfgloc -Q $twsitepass -p $twrootdir/$twpolfileloc $params{policy-text} 2>&1`; + + my ($result) = $?; + + logStatus(@out); + + return $result; } @@ -192,43 +313,96 @@ sub InitializeDatabase { my ($twmsg) = @_; print "initializing database for '$twmsg' test...\n" if $verbose; - logStatus(`$twrootdir/bin/tripwire -m i -P $twsitepass -p $twrootdir/policy/tw.pol -c $twrootdir/tw.cfg`); + my (@out) = `$twrootdir/bin/tripwire -m i -P $twsitepass -p $twrootdir/$twpolfileloc -c $twrootdir/$twcfgloc 2>&1`; - return ($? == 0); + my ($result) = $?; + + logStatus(@out); + + return $result; } ###################################################################### -# Run tripwire to initialize the database... +# Run tripwire to update the database... # sub UpdateDatabase { my (%params) = %{$_[0]}; - $params{'report'} = $reportloc if( ! defined($params{'report'}) ); - $params{'secure-mode'} = "low" if( ! defined($params{'secure-mode'}) ); + $params{report} = $reportloc if( ! defined($params{report}) ); + $params{secure-mode} = "low" if( ! defined($params{secure-mode}) ); print "updating database for '$twmsg' test...\n" if $verbose; - logStatus(`$twrootdir/bin/tripwire -m u -a -P $twsitepass -Z $params{'secure-mode'} -p $twrootdir/policy/tw.pol -c $twrootdir/tw.cfg -r $params{'report'}`); - + my (@out) = `$twrootdir/bin/tripwire -m u -a -P $twsitepass -Z $params{secure-mode} -p $twrootdir/$twpolfileloc -c $twrootdir/$twcfgloc -r $params{report} 2>&1`; + + my ($result) = $?; + + logStatus(@out); + + return $result; +} + +###################################################################### +# Run tripwire to update the policy... +# +sub UpdatePolicy { + + my (%params) = %{$_[0]}; + $params{secure-mode} = "low" if( ! defined($params{secure-mode}) ); + + print "updating policy for '$twmsg' test...\n" if $verbose; + logStatus(`$twrootdir/bin/tripwire -m p -P $twsitepass -Q $twlocalpass -Z $params{secure-mode} -p $twrootdir/$twpolfileloc -c $twrootdir/$twcfgloc $twrootdir/$twpolicyloc 2>&1`); + return ($? == 0); } +###################################################################### +# Use twprint to get a report of specified level (default 0) and return +# that. +# +sub RunReport { + + my (%params) = %{$_[0]}; + + $params{report} = $reportloc if( ! defined($params{report}) ); + $params{report-level} = 0 if( ! defined($params{report-level}) ); + + my (@out) = `$twrootdir/bin/twprint -m r -c $twrootdir/$twcfgloc -t $params{report-level} -r $params{report} 2>&1`; + + logStatus(@out); + + return @out; + +} + ###################################################################### # Use twprint to get a report level 0 report and return # that. # -sub RunReport(%) { +sub RunDbPrint { - my (%params) = %{$_[0]}; - $params{report} = $reportloc if( ! defined($params{report}) ); + my (%params) = %{$_[0]}; + $params{db-object-list} = "" if( ! defined($params{db-object-list}) ); - my (@out) = `$twrootdir/bin/twprint -m r -c $twrootdir/tw.cfg -t 0 -r $params{report}`; + my (@out) = `$twrootdir/bin/twprint -m d -c $twrootdir/$twcfgloc $params{db-object-list} 2>&1`; - logStatus(@out); + logStatus(@out); - return @out; + return @out; +} + +###################################################################### +# Run an email test (configured with mailmethod=sendmail) & capture output +# +sub RunEmailTest { + + my (@out) = `$twrootdir/bin/tripwire --test -c $twrootdir/$twcfgloc --email elvis\@mars`; + + logStatus(@out); + + return @out; } @@ -240,9 +414,10 @@ sub RunIntegrityCheck { my (%params) = %{$_[0]}; $params{report} = $reportloc if( ! defined($params{report}) ); + $params{trailing-opts} = "" if( ! defined($params{trailing-opts}) ); print("running integrity check for test '$twmsg'...\n") if $verbose; - logStatus(`$twrootdir/bin/tripwire -m c -r $params{report} -p $twrootdir/policy/tw.pol -c $twrootdir/tw.cfg 2>&1`); + logStatus(`$twrootdir/bin/tripwire -m c -r $params{report} -p $twrootdir/$twpolfileloc -c $twrootdir/$twcfgloc $params{trailing-opts} 2>&1`); return ($? & 8); } @@ -260,14 +435,11 @@ sub AnalyzeReport { # my (undef, $twstatus) = @_; -# print "*** $twstatus\n"; - # split the report summary line into it's fields # my (undef, undef, undef, $violations, $severity, $added, $removed, $changed) = split(/ /, $twstatus); - # Split out the count for each type of # violation. # diff --git a/src/tripwire/Makefile.am b/src/tripwire/Makefile.am index 4abba88..2ec808a 100644 --- a/src/tripwire/Makefile.am +++ b/src/tripwire/Makefile.am @@ -20,7 +20,7 @@ tripwire_HEADERS = \ tripwirestrings.h tripwireutil.h twcmdline.h twcmdlineutil.h updatedb.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit -CLEANFILES = ../../bin/tripwire ../../lib/libtripwire.a +CLEANFILES = ../../bin/tripwire ../../lib/libtripwire.a *.gcno *.gcda all: $(sbin_PROGRAMS) @test -d ../../bin && $(LN) -f $(sbin_PROGRAMS) ../../bin diff --git a/src/tripwire/Makefile.in b/src/tripwire/Makefile.in index 24a68bf..df8e69c 100644 --- a/src/tripwire/Makefile.in +++ b/src/tripwire/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -299,7 +299,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -327,7 +326,7 @@ tripwire_HEADERS = \ stdtripwire.h syslog_trip.h tripwire.h tripwireerrors.h tripwiremsg.h \ tripwirestrings.h tripwireutil.h twcmdline.h twcmdlineutil.h updatedb.h -CLEANFILES = ../../bin/tripwire ../../lib/libtripwire.a +CLEANFILES = ../../bin/tripwire ../../lib/libtripwire.a *.gcno *.gcda all: all-am .SUFFIXES: diff --git a/src/tripwire/generatedb.cpp b/src/tripwire/generatedb.cpp index 7bf59b2..8c3a6d5 100644 --- a/src/tripwire/generatedb.cpp +++ b/src/tripwire/generatedb.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/generatedb.h b/src/tripwire/generatedb.h index 22fe8fb..2f1665c 100644 --- a/src/tripwire/generatedb.h +++ b/src/tripwire/generatedb.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/generatedb_t.cpp b/src/tripwire/generatedb_t.cpp index 7de5c82..4c7bbfa 100644 --- a/src/tripwire/generatedb_t.cpp +++ b/src/tripwire/generatedb_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/integritycheck.cpp b/src/tripwire/integritycheck.cpp index 224c14c..bbbf51c 100644 --- a/src/tripwire/integritycheck.cpp +++ b/src/tripwire/integritycheck.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -324,7 +324,7 @@ void cIntegrityCheck::ProcessDir( cDbDataSourceIter dbIter, iFCODataSourceIter* return; } -#ifdef _DEBUG +#ifdef DEBUG if( dbIter.Done() ) { d.TraceDebug( "Processing directory %s\n", pIter->GetParentName().AsString().c_str() ); diff --git a/src/tripwire/integritycheck.h b/src/tripwire/integritycheck.h index f5a61ca..5143c4e 100644 --- a/src/tripwire/integritycheck.h +++ b/src/tripwire/integritycheck.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/integritycheck_t.cpp b/src/tripwire/integritycheck_t.cpp index ed133b4..aacedf1 100644 --- a/src/tripwire/integritycheck_t.cpp +++ b/src/tripwire/integritycheck_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/mailmessage.cpp b/src/tripwire/mailmessage.cpp index 975fe50..59963e1 100644 --- a/src/tripwire/mailmessage.cpp +++ b/src/tripwire/mailmessage.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/mailmessage.h b/src/tripwire/mailmessage.h index 19b0617..5e86aac 100644 --- a/src/tripwire/mailmessage.h +++ b/src/tripwire/mailmessage.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -36,7 +36,11 @@ #include "core/error.h" #endif -#if HAVE_SYS_SOCKET_H +#if IS_REDOX +#define restrict __restrict__ +#endif + +#if SUPPORTS_NETWORKING && HAVE_SYS_SOCKET_H # include #endif #define SOCKET int @@ -207,7 +211,7 @@ public: }; - +#if SUPPORTS_NETWORKING /////////////////////////////////////////////////////////////////////////////// // // This class implements sending a message via SMTP @@ -245,7 +249,7 @@ private: TSTRING mstrServerName; unsigned short mPortNumber; }; - +#endif /////////////////////////////////////////////////////////////////////////////// // diff --git a/src/tripwire/pipedmailmessage.cpp b/src/tripwire/pipedmailmessage.cpp index ea81f9f..84bffab 100644 --- a/src/tripwire/pipedmailmessage.cpp +++ b/src/tripwire/pipedmailmessage.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/policyupdate.cpp b/src/tripwire/policyupdate.cpp index e559e7f..27fe59f 100644 --- a/src/tripwire/policyupdate.cpp +++ b/src/tripwire/policyupdate.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/policyupdate.h b/src/tripwire/policyupdate.h index 210cf8a..c7169ca 100644 --- a/src/tripwire/policyupdate.h +++ b/src/tripwire/policyupdate.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/resource.h b/src/tripwire/resource.h index fbe9e46..33bb438 100644 --- a/src/tripwire/resource.h +++ b/src/tripwire/resource.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/smtpmailmessage.cpp b/src/tripwire/smtpmailmessage.cpp index 9e63bc7..1d04fe5 100644 --- a/src/tripwire/smtpmailmessage.cpp +++ b/src/tripwire/smtpmailmessage.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -42,6 +42,8 @@ #include +#if SUPPORTS_NETWORKING + //All the spleck that it takes to run sockets in Unix... #include #if HAVE_SYS_SOCKET_H @@ -564,3 +566,5 @@ void cSMTPMailMessage::DecodeError() #endif // defined(_DEBUG) } +#endif // SUPPORTS_NETWORKING + diff --git a/src/tripwire/stdtripwire.cpp b/src/tripwire/stdtripwire.cpp index 76e5c8c..d3fc63d 100644 --- a/src/tripwire/stdtripwire.cpp +++ b/src/tripwire/stdtripwire.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,4 +37,4 @@ // #include "stdtripwire.h" -// eof: stdtripwire.cpp + diff --git a/src/tripwire/stdtripwire.h b/src/tripwire/stdtripwire.h index e62786d..1a72e9e 100644 --- a/src/tripwire/stdtripwire.h +++ b/src/tripwire/stdtripwire.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/syslog_trip.cpp b/src/tripwire/syslog_trip.cpp index 66da277..9680b6c 100644 --- a/src/tripwire/syslog_trip.cpp +++ b/src/tripwire/syslog_trip.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/syslog_trip.h b/src/tripwire/syslog_trip.h index 9c8de99..c7b3341 100644 --- a/src/tripwire/syslog_trip.h +++ b/src/tripwire/syslog_trip.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/tripwire.cpp b/src/tripwire/tripwire.cpp index bcdfd30..0ac986f 100644 --- a/src/tripwire/tripwire.cpp +++ b/src/tripwire/tripwire.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -69,5 +69,5 @@ cTripwire::cTripwire() TSS_REGISTER_PKG_ERRORS( tripwire ) } -// eof: tripwire.cpp + diff --git a/src/tripwire/tripwire.h b/src/tripwire/tripwire.h index b725e76..faefee7 100644 --- a/src/tripwire/tripwire.h +++ b/src/tripwire/tripwire.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/tripwireerrors.cpp b/src/tripwire/tripwireerrors.cpp index aa56c45..3a2f54c 100644 --- a/src/tripwire/tripwireerrors.cpp +++ b/src/tripwire/tripwireerrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/tripwireerrors.h b/src/tripwire/tripwireerrors.h index d3be484..778e98a 100644 --- a/src/tripwire/tripwireerrors.h +++ b/src/tripwire/tripwireerrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/tripwiremain.cpp b/src/tripwire/tripwiremain.cpp index 266199d..b9d68ba 100644 --- a/src/tripwire/tripwiremain.cpp +++ b/src/tripwire/tripwiremain.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -43,7 +43,7 @@ #include "tw/configfile.h" #include "core/errorbucketimpl.h" #include "core/usernotifystdout.h" -#include "core/timebomb.h" +#include "core/epoch.h" #include // for auto_ptr / unique_ptr #include #include @@ -64,7 +64,7 @@ static TSTRING util_GetWholeCmdLine( int argc, const TCHAR *argv[] ); // global new() and delete() overrides -- this is done to do performance testing /////////////////////////////////////////////////////////////////////////////// /* -#ifdef _DEBUG +#ifdef DEBUG #if defined(HAVE_MALLOC_H) #include #endif @@ -107,7 +107,7 @@ void tw_unexpected_handler() int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] ) { - if (TimeBombExploded()) + if (CheckEpoch()) return 8; int ret = 0; @@ -254,22 +254,19 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] ) TCERR << _T("*** Exiting...\n"); ret = 8; } - - /* catch (...) { TCERR << _T("*** Fatal exception occurred.\n"); TCERR << _T("*** Exiting...\n"); ret = 8; } - */ exit: // print out the max memory usage... /* -#ifdef _DEBUG +#ifdef DEBUG TCOUT << _T("Maximum memory footprint = ") << gMaxAlloc << std::endl; #endif */ diff --git a/src/tripwire/tripwiremsg.h b/src/tripwire/tripwiremsg.h index f6dbb95..1fcb824 100644 --- a/src/tripwire/tripwiremsg.h +++ b/src/tripwire/tripwiremsg.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/tripwirestrings.cpp b/src/tripwire/tripwirestrings.cpp index b254d18..0494f8c 100644 --- a/src/tripwire/tripwirestrings.cpp +++ b/src/tripwire/tripwirestrings.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/tripwirestrings.h b/src/tripwire/tripwirestrings.h index db805c6..e2a07e9 100644 --- a/src/tripwire/tripwirestrings.h +++ b/src/tripwire/tripwirestrings.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/tripwireutil.cpp b/src/tripwire/tripwireutil.cpp index 69a5e32..e97726f 100644 --- a/src/tripwire/tripwireutil.cpp +++ b/src/tripwire/tripwireutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/tripwireutil.h b/src/tripwire/tripwireutil.h index 51d4857..0eac927 100644 --- a/src/tripwire/tripwireutil.h +++ b/src/tripwire/tripwireutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/twcmdline.cpp b/src/tripwire/twcmdline.cpp index 5666533..9a971f5 100644 --- a/src/tripwire/twcmdline.cpp +++ b/src/tripwire/twcmdline.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -158,7 +158,7 @@ iTWMode* cTWCmdLine::GetMode(int argc, const TCHAR *const * argv) else if (_tcscmp(argv[1], _T("--test")) == 0) mode = MODE_TEST; -#ifdef _DEBUG_DB +#ifdef DEBUG if (_tcscmp(argv[1], _T("--explore")) == 0) mode = MODE_EXPLORE; if (_tcscmp(argv[1], _T("--verifydb")) == 0) @@ -172,7 +172,7 @@ iTWMode* cTWCmdLine::GetMode(int argc, const TCHAR *const * argv) // unknown mode switch cDebug d("cTWCmdLine::GetMode"); d.TraceError(_T("Error: Bad mode switch: %s\n"), pcMode); - TCERR << TSS_GetString( cTW, tw::STR_UNKOWN_MODE_SPECIFIED) + TCERR << TSS_GetString( cTW, tw::STR_UNKNOWN_MODE_SPECIFIED) << pcMode << std::endl << TSS_GetString( cTW, tw::STR_GET_HELP) << std::endl; return NULL; @@ -204,8 +204,8 @@ iTWMode* cTWCmdLine::GetMode(int argc, const TCHAR *const * argv) pRtn = new cTWModeVersion; break; -//Explore and Debug modes are invisible unless _DEBUG_DB is defined. -#ifdef _DEBUG_DB +//Explore and Debug modes are invisible unless DEBUG is defined. +#ifdef DEBUG case cTWCmdLine::MODE_EXPLORE: pRtn = new cTWModeExploreDb; break; @@ -249,186 +249,261 @@ static void InitCmdLineCommon(cCmdLineParser& parser) } + /////////////////////////////////////////////////////////////////////////////// -// FillOutConfigInfo -- fills out all the common info with config file information +// Set up temp directory /////////////////////////////////////////////////////////////////////////////// -static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf) +static void util_InitTempDirectory(const cConfigFile& cf) { - TSTRING str; - if(cf.Lookup(TSTRING(_T("POLFILE")), str)) - pModeInfo->mPolFile = str; - if(cf.Lookup(TSTRING(_T("DBFILE")), str)) - pModeInfo->mDbFile = str; - if(cf.Lookup(TSTRING(_T("SITEKEYFILE")), str)) - pModeInfo->mSiteKeyFile = str; - if(cf.Lookup(TSTRING(_T("LOCALKEYFILE")), str)) - pModeInfo->mLocalKeyFile = str; - if(cf.Lookup(TSTRING(_T("REPORTFILE")), str)) - pModeInfo->mReportFile = str; - if(cf.Lookup(TSTRING(_T("EDITOR")), str)) - pModeInfo->mEditor = str; - if(cf.Lookup(TSTRING(_T("LATEPROMPTING")), str)) - { - if (_tcsicmp(str.c_str(), _T("true")) == 0) - pModeInfo->mbLatePassphrase = true; - } - if(cf.Lookup(TSTRING(_T("RESETACCESSTIME")), str)) - { - // We do not support reset access time on Unix, so we issue a warning. - // This used to be a fatal error, however this prevents - // cross platform config files. - cTWUtil::PrintErrorMsg(eTWInvalidConfigFileKey(_T("RESETACCESSTIME"), eError::NON_FATAL)); - } - if(cf.Lookup(TSTRING(_T("LOOSEDIRECTORYCHECKING")), str)) - { - if (_tcsicmp(str.c_str(), _T("true")) == 0) - pModeInfo->mfLooseDirs = true; - } + TSTRING temp_directory; + cf.Lookup(TSTRING(_T("TEMPDIRECTORY")), temp_directory); - TSTRING temp_directory; - cf.Lookup(TSTRING(_T("TEMPDIRECTORY")), temp_directory); - - if (temp_directory.length() == 0) { + if (temp_directory.empty()) + { #if IS_AROS - temp_directory = "T:"; + temp_directory = "T:"; +#elif IS_DOS_DJGPP + temp_directory = "/dev/c/temp/"; +#elif IS_RISCOS + temp_directory = "/!BOOT/Resources/!Scrap/ScrapDirs/ScrapDir"; +#elif IS_REDOX + temp_directory = "/file/tmp/"; #else - temp_directory = "/tmp/"; + temp_directory = "/tmp/"; #endif } +#if !IS_RISCOS // make sure we have a trailing slash -- thanks Jarno... // - if (temp_directory[_tcslen(str.c_str())-1] != '/') { - temp_directory += '/'; + if (*temp_directory.rbegin() != '/') + { + temp_directory.push_back('/'); } +#endif + // make sure it exists... // -#if USES_DEVICE_PATH +#if IS_AROS || IS_RISCOS temp_directory = cDevicePath::AsNative(temp_directory); +#elif IS_DOS_DJGPP + temp_directory = cDevicePath::AsPosix(temp_directory); #endif - if (access(temp_directory.c_str(), F_OK) != 0) { - TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY ); - TSTRING tmpStr = _T("Directory: "); - tmpStr += (temp_directory + _T("\n")); - tmpStr += errStr; - throw eTWInvalidTempDirectory(tmpStr); - } - else { - iFSServices::GetInstance()->SetTempDirName(temp_directory); - } - - - if (cf.Lookup(TSTRING(_T("GLOBALEMAIL")), str)) { - - if (str.length() != 0) - pModeInfo->mGlobalEmail = str; - } - - // - // Set the report-viewing level if one has been specified, use - // default level otherwise. - // - if(cf.Lookup(TSTRING(_T("EMAILREPORTLEVEL")), str)) + if (access(temp_directory.c_str(), F_OK) != 0) { - if (_tcsicmp(str.c_str(), _T("0")) == 0) - pModeInfo->mEmailReportLevel = cTextReportViewer::SINGLE_LINE; - else if (_tcsicmp(str.c_str(), _T("1")) == 0) - pModeInfo->mEmailReportLevel = cTextReportViewer::PARSEABLE; - else if (_tcsicmp(str.c_str(), _T("2")) == 0) - pModeInfo->mEmailReportLevel = cTextReportViewer::SUMMARY_ONLY; - else if (_tcsicmp(str.c_str(), _T("3")) == 0) - pModeInfo->mEmailReportLevel = cTextReportViewer::CONCISE_REPORT; - else if (_tcsicmp(str.c_str(), _T("4")) == 0) - pModeInfo->mEmailReportLevel = cTextReportViewer::FULL_REPORT; - else + TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY ); + TSTRING tmpStr = _T("Directory: "); + tmpStr += (temp_directory + _T("\n")); + tmpStr += errStr; + throw eTWInvalidTempDirectory(tmpStr); + } + else + { +#if IS_RISCOS + if (*temp_directory.rbegin() != '.') { - // They specified an illegal level, error. - TSTRING errStr = _T("Invalid Level: "); - errStr += str; - throw eTWInvalidReportLevelCfg( errStr ); + temp_directory.push_back('.'); + } +#endif + + iFSServices::GetInstance()->SetTempDirName(temp_directory); + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// Set up various email reporting options +/////////////////////////////////////////////////////////////////////////////// +static void util_InitEmailOptions(cTWModeCommon* pModeInfo, const cConfigFile& cf) +{ + TSTRING str; + if (cf.Lookup(TSTRING(_T("GLOBALEMAIL")), str)) + { + if (str.length() != 0) + pModeInfo->mGlobalEmail = str; + } + + // + // Set the report-viewing level if one has been specified, use + // default level otherwise. + // + if(cf.Lookup(TSTRING(_T("EMAILREPORTLEVEL")), str)) + { + if (_tcsicmp(str.c_str(), _T("0")) == 0) + pModeInfo->mEmailReportLevel = cTextReportViewer::SINGLE_LINE; + else if (_tcsicmp(str.c_str(), _T("1")) == 0) + pModeInfo->mEmailReportLevel = cTextReportViewer::PARSEABLE; + else if (_tcsicmp(str.c_str(), _T("2")) == 0) + pModeInfo->mEmailReportLevel = cTextReportViewer::SUMMARY_ONLY; + else if (_tcsicmp(str.c_str(), _T("3")) == 0) + pModeInfo->mEmailReportLevel = cTextReportViewer::CONCISE_REPORT; + else if (_tcsicmp(str.c_str(), _T("4")) == 0) + pModeInfo->mEmailReportLevel = cTextReportViewer::FULL_REPORT; + else + { + // They specified an illegal level, error. + TSTRING errStr = _T("Invalid Level: "); + errStr += str; + throw eTWInvalidReportLevelCfg( errStr ); } } - else - // no level was specified in the configuration file, use default. - pModeInfo->mEmailReportLevel = cTextReportViewer::CONCISE_REPORT; - - - // Decide what mail method should be used to email reports - if(cf.Lookup(TSTRING(_T("MAILMETHOD")), str)) + else { - if (_tcsicmp(str.c_str(), _T("SENDMAIL")) == 0) - pModeInfo->mMailMethod = cMailMessage::MAIL_BY_PIPE; - else if( _tcsicmp( str.c_str(), _T("SMTP") ) == 0 ) - pModeInfo->mMailMethod = cMailMessage::MAIL_BY_SMTP; - else - pModeInfo->mMailMethod = cMailMessage::INVALID_METHOD; + // no level was specified in the configuration file, use default. + pModeInfo->mEmailReportLevel = cTextReportViewer::CONCISE_REPORT; } - else + + // Decide what mail method should be used to email reports + if(cf.Lookup(TSTRING(_T("MAILMETHOD")), str)) { - pModeInfo->mMailMethod = cMailMessage::NO_METHOD; + if (_tcsicmp(str.c_str(), _T("SENDMAIL")) == 0) + pModeInfo->mMailMethod = cMailMessage::MAIL_BY_PIPE; + else if( _tcsicmp( str.c_str(), _T("SMTP") ) == 0 ) + pModeInfo->mMailMethod = cMailMessage::MAIL_BY_SMTP; + else + pModeInfo->mMailMethod = cMailMessage::INVALID_METHOD; + } + else + { + pModeInfo->mMailMethod = cMailMessage::NO_METHOD; } #if !SUPPORTS_NETWORKING if (pModeInfo->mMailMethod == cMailMessage::MAIL_BY_SMTP) throw eMailSMTPNotSupported(); #endif - - // Get the SMTP server - if(cf.Lookup(TSTRING(_T("SMTPHOST")), str)) - pModeInfo->mSmtpHost = str; - else - pModeInfo->mSmtpHost = _T("127.0.0.1"); // this is the default - // Get the SMTP port number - if(cf.Lookup(TSTRING(_T("SMTPPORT")), str)) + // Get the SMTP server + if(cf.Lookup(TSTRING(_T("SMTPHOST")), str)) { - int i = _ttoi( str.c_str() ); - if( i < 0 || i > SHRT_MAX ) - throw eTWInvalidPortNumber( str ); - pModeInfo->mSmtpPort = static_cast( i ); + pModeInfo->mSmtpHost = str; } - else - pModeInfo->mSmtpPort = 25; // this is the default - - // Get the mail program to use if we're piping our email - if(cf.Lookup(TSTRING(_T("MAILPROGRAM")), str)) - pModeInfo->mMailProgram = str; - else - pModeInfo->mMailProgram.erase(); // MAILPROGRAM is not required to be specified - - // Get the mail program to use if we're piping our email - if(cf.Lookup(TSTRING(_T("MAILNOVIOLATIONS")), str)) + else { - if (_tcsicmp(str.c_str(), _T("true")) == 0) - pModeInfo->mMailNoViolations = true; - else - pModeInfo->mMailNoViolations = false; + pModeInfo->mSmtpHost = _T("127.0.0.1"); // this is the default } - else - pModeInfo->mMailNoViolations = true; // MAILPROGRAM is not required to be specified - if(cf.Lookup(TSTRING(_T("MAILFROMADDRESS")), str)) - pModeInfo->mMailFrom = str; + // Get the SMTP port number + if(cf.Lookup(TSTRING(_T("SMTPPORT")), str)) + { + int i = _ttoi( str.c_str() ); + if( i < 0 || i > SHRT_MAX ) + throw eTWInvalidPortNumber( str ); + pModeInfo->mSmtpPort = static_cast( i ); + } + else + { + pModeInfo->mSmtpPort = 25; // this is the default + } + + // Get the mail program to use if we're piping our email + if(cf.Lookup(TSTRING(_T("MAILPROGRAM")), str)) + { + pModeInfo->mMailProgram = str; + } + else + { + pModeInfo->mMailProgram.erase(); // MAILPROGRAM is not required to be specified + } + + // Get the mail program to use if we're piping our email + if(cf.Lookup(TSTRING(_T("MAILNOVIOLATIONS")), str)) + { + if (_tcsicmp(str.c_str(), _T("true")) == 0) + pModeInfo->mMailNoViolations = true; + else + pModeInfo->mMailNoViolations = false; + } + else + { + pModeInfo->mMailNoViolations = true; // MAILPROGRAM is not required to be specified + } + + if(cf.Lookup(TSTRING(_T("MAILFROMADDRESS")), str)) + { + pModeInfo->mMailFrom = str; + } +} + + +/////////////////////////////////////////////////////////////////////////////// +// FillOutConfigInfo -- fills out all the common info with config file information +/////////////////////////////////////////////////////////////////////////////// +static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf) +{ + TSTRING str; + if(cf.Lookup(TSTRING(_T("POLFILE")), str)) + { + pModeInfo->mPolFile = str; + } + if(cf.Lookup(TSTRING(_T("DBFILE")), str)) + { + pModeInfo->mDbFile = str; + } + if(cf.Lookup(TSTRING(_T("SITEKEYFILE")), str)) + { + pModeInfo->mSiteKeyFile = str; + } + if(cf.Lookup(TSTRING(_T("LOCALKEYFILE")), str)) + { + pModeInfo->mLocalKeyFile = str; + } + if(cf.Lookup(TSTRING(_T("REPORTFILE")), str)) + { + pModeInfo->mReportFile = str; + } + if(cf.Lookup(TSTRING(_T("EDITOR")), str)) + { + pModeInfo->mEditor = str; + } + if(cf.Lookup(TSTRING(_T("LATEPROMPTING")), str)) + { + if (_tcsicmp(str.c_str(), _T("true")) == 0) + pModeInfo->mbLatePassphrase = true; + } + if(cf.Lookup(TSTRING(_T("RESETACCESSTIME")), str)) + { + // We do not support reset access time on Unix, so we issue a warning. + // This used to be a fatal error, however this prevents + // cross platform config files. + cTWUtil::PrintErrorMsg(eTWInvalidConfigFileKey(_T("RESETACCESSTIME"), eError::NON_FATAL)); + } + if(cf.Lookup(TSTRING(_T("LOOSEDIRECTORYCHECKING")), str)) + { + if (_tcsicmp(str.c_str(), _T("true")) == 0) + pModeInfo->mfLooseDirs = true; + } + + util_InitTempDirectory(cf); + + util_InitEmailOptions(pModeInfo, cf); // SYSLOG reporting - if(cf.Lookup(TSTRING(_T("SYSLOGREPORTING")), str)) + if(cf.Lookup(TSTRING(_T("SYSLOGREPORTING")), str)) { + if (_tcsicmp(str.c_str(), _T("true")) == 0) + { #if SUPPORTS_SYSLOG - if (_tcsicmp(str.c_str(), _T("true")) == 0) - pModeInfo->mbLogToSyslog = true; - else - pModeInfo->mbLogToSyslog = false; + pModeInfo->mbLogToSyslog = true; #else - throw eTWSyslogNotSupported(); + eTWSyslogNotSupported e; + e.SetFatality(false); + cErrorReporter::PrintErrorMsg(e); + pModeInfo->mbLogToSyslog = false; #endif + } + else + pModeInfo->mbLogToSyslog = false; } - else - pModeInfo->mbLogToSyslog = false; - + else + { + pModeInfo->mbLogToSyslog = false; + } + // Crossing file systems - if(cf.Lookup(TSTRING(_T("CROSSFILESYSTEMS")), str)) + if(cf.Lookup(TSTRING(_T("CROSSFILESYSTEMS")), str)) { if (_tcsicmp(str.c_str(), _T("true")) == 0) pModeInfo->mbCrossFileSystems = true; @@ -457,20 +532,20 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf) iFSServices::GetInstance()->SetResolveNames(false); } - // - // turn all of the file names into full paths (they're relative to the exe dir) - // - TSTRING fullPath; - if(iFSServices::GetInstance()->FullPath( fullPath, pModeInfo->mPolFile, cSystemInfo::GetExeDir() )) - pModeInfo->mPolFile = fullPath; - if(iFSServices::GetInstance()->FullPath( fullPath, pModeInfo->mDbFile, cSystemInfo::GetExeDir() )) - pModeInfo->mDbFile = fullPath; - if(iFSServices::GetInstance()->FullPath( fullPath, pModeInfo->mSiteKeyFile, cSystemInfo::GetExeDir() )) - pModeInfo->mSiteKeyFile = fullPath; - if(iFSServices::GetInstance()->FullPath( fullPath, pModeInfo->mLocalKeyFile, cSystemInfo::GetExeDir() )) - pModeInfo->mLocalKeyFile = fullPath; - if(iFSServices::GetInstance()->FullPath( fullPath, pModeInfo->mReportFile, cSystemInfo::GetExeDir() )) - pModeInfo->mReportFile = fullPath; + // + // turn all of the file names into full paths (they're relative to the exe dir) + // + TSTRING fullPath; + if(iFSServices::GetInstance()->FullPath( fullPath, pModeInfo->mPolFile, cSystemInfo::GetExeDir() )) + pModeInfo->mPolFile = fullPath; + if(iFSServices::GetInstance()->FullPath( fullPath, pModeInfo->mDbFile, cSystemInfo::GetExeDir() )) + pModeInfo->mDbFile = fullPath; + if(iFSServices::GetInstance()->FullPath( fullPath, pModeInfo->mSiteKeyFile, cSystemInfo::GetExeDir() )) + pModeInfo->mSiteKeyFile = fullPath; + if(iFSServices::GetInstance()->FullPath( fullPath, pModeInfo->mLocalKeyFile, cSystemInfo::GetExeDir() )) + pModeInfo->mLocalKeyFile = fullPath; + if(iFSServices::GetInstance()->FullPath( fullPath, pModeInfo->mReportFile, cSystemInfo::GetExeDir() )) + pModeInfo->mReportFile = fullPath; } /////////////////////////////////////////////////////////////////////////////// @@ -676,7 +751,7 @@ int cTWModeDbInit::Execute(cErrorQueue* pQueue) cTWCmdLineUtil::ParsePolicyFile(genreSpecList, mpData->mPolFile, mpData->mSiteKeyFile, pQueue); #ifdef TW_PROFILE - cWin32TaskTimer timer("cTripwire::GenerateDatabase"); + cTaskTimer timer("cTripwire::GenerateDatabase"); timer.Start(); #endif @@ -709,9 +784,10 @@ int cTWModeDbInit::Execute(cErrorQueue* pQueue) // generate the database... // TODO -- turn pQueue into an error bucket cGenerateDb::Execute( dbIter.GetSpecList(), dbIter.GetDb(), dbIter.GetGenreHeader().GetPropDisplayer(), pQueue, gdbFlags ); + } - - cFCODatabaseUtil::CalculateHeader( + + cFCODatabaseUtil::CalculateHeader( dbFile.GetHeader(), mpData->mPolFile, mstrConfigFile, @@ -1150,15 +1226,35 @@ int cTWModeIC::Execute(cErrorQueue* pQueue) } } // TODO -- emit "processing XXX" + cIntegrityCheck ic( (cGenre::Genre)genreIter->first, dbIter.GetSpecList(), dbIter.GetDb(), report, pQueue ); - + + //If any sort of exception escapes the IC, make sure it goes in the report. + try + { uint32 icFlags = 0; icFlags |= ( mpData->mfLooseDirs ? cIntegrityCheck::FLAG_LOOSE_DIR : 0 ); icFlags |= ( mpData->mbResetAccessTime ? cIntegrityCheck::FLAG_ERASE_FOOTPRINTS_IC : 0 ); icFlags |= ( mpData->mbDirectIO ? cIntegrityCheck::FLAG_DIRECT_IO : 0 ); - - ic.ExecuteOnObjectList( fcoNames, icFlags ); - + + ic.ExecuteOnObjectList( fcoNames, icFlags ); + } + catch( eError& e ) + { + if( pQueue ) + pQueue->AddError(e); + } + catch( std::exception& e ) + { + if (pQueue ) + pQueue->AddError(eIC(e.what())); + } + catch(...) + { + if (pQueue ) + pQueue->AddError(eIC("Unknown")); + + } // put all info into report cFCOReportGenreIter rgi( report ); rgi.SeekToGenre( (cGenre::Genre) genreIter->first ); @@ -1279,18 +1375,37 @@ int cTWModeIC::Execute(cErrorQueue* pQueue) iUserNotify::GetInstance()->Notify(1, TSS_GetString( cTripwire, tripwire::STR_INTEGRITY_CHECK).c_str()); #ifdef TW_PROFILE - cWin32TaskTimer timer("cTripwire::IntegrityCheck"); + cTaskTimer timer("cTripwire::IntegrityCheck"); timer.Start(); #endif cIntegrityCheck ic( (cGenre::Genre)dbIter.GetGenre(), specList, dbIter.GetDb(), report, pQueue ); + //If any sort of exception escapes the IC, make sure it goes in the report. + try + { uint32 icFlags = 0; icFlags |= ( mpData->mfLooseDirs ? cIntegrityCheck::FLAG_LOOSE_DIR : 0 ); icFlags |= ( mpData->mbResetAccessTime ? cIntegrityCheck::FLAG_ERASE_FOOTPRINTS_IC : 0 ); icFlags |= ( mpData->mbDirectIO ? cIntegrityCheck::FLAG_DIRECT_IO : 0 ); - - ic.Execute( icFlags ); - + + ic.Execute( icFlags ); + } + catch( eError& e ) + { + if( pQueue ) + pQueue->AddError(e); + } + catch( std::exception& e ) + { + if (pQueue ) + pQueue->AddError(eIC(e.what())); + } + catch(...) + { + if (pQueue ) + pQueue->AddError(eIC("Unknown")); + } + // put all display info into report cFCOReportGenreIter rgi( report ); rgi.SeekToGenre( (cGenre::Genre) dbIter.GetGenre() ); @@ -2441,7 +2556,7 @@ int cTWModeHelp::Execute(cErrorQueue* pQueue) TCOUT<< TSS_GetString( cTripwire, tripwire::STR_TRIPWIRE_HELP_UPDATE ); TCOUT<< TSS_GetString( cTripwire, tripwire::STR_TRIPWIRE_HELP_UPDATE_POLICY ); TCOUT<< TSS_GetString( cTripwire, tripwire::STR_TRIPWIRE_HELP_TEST ); -#ifdef _DEBUG_DB +#ifdef DEBUG // TODO: Do we need help messages for these modes? DRA #endif //We're done, return @@ -2539,7 +2654,7 @@ bool util_GetEditor( TSTRING& strEd ) //Encase the explore and debug modes in this ifdef, since they are for internal //use only. -#ifdef _DEBUG_DB +#ifdef DEBUG //############################################################################# // cTWModeExploreDb @@ -2724,6 +2839,6 @@ int cTWModeDebugDb::Execute(cErrorQueue* pQueue) } -#endif //_DEBUG_DB +#endif //DEBUG diff --git a/src/tripwire/twcmdline.h b/src/tripwire/twcmdline.h index 1dd1c45..67fd217 100644 --- a/src/tripwire/twcmdline.h +++ b/src/tripwire/twcmdline.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -361,8 +361,8 @@ private: cTWModeHelp_i* mpData; }; -//These two modes are invisible if _DEBUG_DB is not defined. -#ifdef _DEBUG_DB +//These two modes are invisible if DEBUG is not defined. +#ifdef DEBUG /////////////////////////////////////////////////////////////////////////////// // Explore Db @@ -404,7 +404,7 @@ private: cTWModeDebugDb_i* mpData; }; -#endif //_DEBUG_DB +#endif //DEBUG /////////////////////////////////////////////////////////////////////////////// // Version Mode diff --git a/src/tripwire/twcmdlineutil.cpp b/src/tripwire/twcmdlineutil.cpp index 67e5893..68fb7b2 100644 --- a/src/tripwire/twcmdlineutil.cpp +++ b/src/tripwire/twcmdlineutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -536,15 +536,16 @@ static bool EmailReportTo(const TSTRING &toAddress, const cFCOReportHeader& head // allocate the right kind of emailer object based on what came out of the config file. switch (modeCommon->mMailMethod) { - default: - ASSERT(false); - return false; +#if SUPPORTS_NETWORKING case cMailMessage::MAIL_BY_SMTP: reportMail = TW_UNIQUE_PTR(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort)); break; +#endif case cMailMessage::MAIL_BY_PIPE: reportMail = TW_UNIQUE_PTR(new cPipedMailMessage(modeCommon->mMailProgram)); break; + default: + return false; } TSTRING strTempFilename; @@ -690,15 +691,16 @@ bool cTWCmdLineUtil::SendEmailTestMessage(const TSTRING &mAddress, const cTWMode // allocate the right kind of emailer object based on what came out of the config file. switch (modeCommon->mMailMethod) { - default: - ASSERT(false); - return false; +#if SUPPORTS_NETWORKING case cMailMessage::MAIL_BY_SMTP: reportMail = TW_UNIQUE_PTR(new cSMTPMailMessage(modeCommon->mSmtpHost, modeCommon->mSmtpPort)); break; +#endif case cMailMessage::MAIL_BY_PIPE: reportMail = TW_UNIQUE_PTR(new cPipedMailMessage(modeCommon->mMailProgram)); break; + default: + return false; } diff --git a/src/tripwire/twcmdlineutil.h b/src/tripwire/twcmdlineutil.h index 8de0508..65608d4 100644 --- a/src/tripwire/twcmdlineutil.h +++ b/src/tripwire/twcmdlineutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/updatedb.cpp b/src/tripwire/updatedb.cpp index c957606..21e2063 100644 --- a/src/tripwire/updatedb.cpp +++ b/src/tripwire/updatedb.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tripwire/updatedb.h b/src/tripwire/updatedb.h index 34cca8a..0749870 100644 --- a/src/tripwire/updatedb.h +++ b/src/tripwire/updatedb.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/Makefile.am b/src/tw/Makefile.am index de2d025..1bea795 100644 --- a/src/tw/Makefile.am +++ b/src/tw/Makefile.am @@ -20,6 +20,7 @@ libtw_a_HEADERS = \ tw.h twerrors.h twinit.h twstrings.h twutil.h DEFS = @DEFS@ -DCONFIG_DIR=\"$(sysconfdir)\" +CLEANFILES = *.gcno *.gcda all: $(noinst_LIBRARIES) $(AR) ru ../../lib/libtripwire.a $(libtw_a_OBJECTS) diff --git a/src/tw/Makefile.in b/src/tw/Makefile.in index bac6b09..8749f14 100644 --- a/src/tw/Makefile.in +++ b/src/tw/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -306,7 +306,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -338,6 +337,7 @@ libtw_a_HEADERS = \ stdtw.h systeminfo.h textdbviewer.h textreportviewer.h \ tw.h twerrors.h twinit.h twstrings.h twutil.h +CLEANFILES = *.gcno *.gcda all: all-am .SUFFIXES: @@ -524,6 +524,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) diff --git a/src/tw/configfile.cpp b/src/tw/configfile.cpp index af13e78..cf97d1e 100644 --- a/src/tw/configfile.cpp +++ b/src/tw/configfile.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -238,7 +238,7 @@ void cConfigFile::WriteString( TSTRING& configText ) // throw( eFSServices ) void cConfigFile::ReadString(const TSTRING configText) // throw( eConfigFile ); { -#ifdef _DEBUG +#ifdef DEBUG // NOTE:BAM -- debug only code ! TCERR << _T("*** begin config text ***") << std::endl; TCERR << configText << std::endl; @@ -266,7 +266,7 @@ void cConfigFile::ReadString(const TSTRING configText) // throw( eConfigFile ); CheckThatAllMandatoryKeyWordsExists(); -#ifdef _DEBUG +#ifdef DEBUG // NOTE:BAM -- debug only code ! TSTRING sTemp; WriteString( sTemp ); diff --git a/src/tw/configfile.h b/src/tw/configfile.h index 6cbf2e9..11c8202 100644 --- a/src/tw/configfile.h +++ b/src/tw/configfile.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/dbdatasource.cpp b/src/tw/dbdatasource.cpp index db2f2b6..1065b1b 100644 --- a/src/tw/dbdatasource.cpp +++ b/src/tw/dbdatasource.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -64,14 +64,14 @@ cDbDataSourceIter::cDbDataSourceIter(cHierDatabase* pDb, int genreNum ) genreNum = cGenreSwitcher::GetInstance()->CurrentGenre(); mFCOCreateFunc = cGenreSwitcher::GetInstance()->GetFactoryForGenre( (cGenre::Genre)genreNum )->GetCreateFunc(); -#ifdef _DEBUG +#ifdef DEBUG // // make some assertions about the current genre's name info // iFCONameInfo* pNameInfo = cGenreSwitcher::GetInstance()->GetFactoryForGenre( (cGenre::Genre)genreNum )->GetNameInfo(); ASSERT( pDb->IsCaseSensitive() == pNameInfo->IsCaseSensitive() ); ASSERT( pDb->GetDelimitingChar() == pNameInfo->GetDelimitingChar() ); -#endif //#ifdef _DEBUG +#endif //#ifdef DEBUG } /////////////////////////////////////////////////////////////////////////////// @@ -263,20 +263,24 @@ void cDbDataSourceIter::SetFCOData( const iFCO* pFCO ) //throw (eError) { mDbIter.RemoveData(); } - // - // write the fco's property set to a memory archive... - // - // TODO -- does this need to be static? - static cMemoryArchive arch; - arch.Seek ( 0, cBidirArchive::BEGINNING ); - cSerializerImpl ser (arch, cSerializerImpl::S_WRITE); - ser.Init(); - ser.WriteObject ( pFCO->GetPropSet() ); - ser.Finit(); - // - // write this to the archive... - // - mDbIter.SetData( arch.GetMemory(), arch.CurrentPos() ); + + if( pFCO ) + { + // + // write the fco's property set to a memory archive... + // + // TODO -- does this need to be static? + static cMemoryArchive arch; + arch.Seek ( 0, cBidirArchive::BEGINNING ); + cSerializerImpl ser (arch, cSerializerImpl::S_WRITE); + ser.Init(); + ser.WriteObject ( pFCO->GetPropSet() ); + ser.Finit(); + // + // write this to the archive... + // + mDbIter.SetData( arch.GetMemory(), arch.CurrentPos() ); + } } /////////////////////////////////////////////////////////////////////////////// diff --git a/src/tw/dbdatasource.h b/src/tw/dbdatasource.h index 2196ae5..e656870 100644 --- a/src/tw/dbdatasource.h +++ b/src/tw/dbdatasource.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/dbdebug.cpp b/src/tw/dbdebug.cpp index 2f5318a..c14c316 100644 --- a/src/tw/dbdebug.cpp +++ b/src/tw/dbdebug.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/dbdebug.h b/src/tw/dbdebug.h index d90a0b6..25f6c9f 100644 --- a/src/tw/dbdebug.h +++ b/src/tw/dbdebug.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/dbexplore.cpp b/src/tw/dbexplore.cpp index 4d4692f..71f8b65 100644 --- a/src/tw/dbexplore.cpp +++ b/src/tw/dbexplore.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -250,6 +250,104 @@ void cDbExplore::Execute( cFCODatabaseFileIter& dbIter ) } } //----------------------------------------------------------------- + // mkdir + //----------------------------------------------------------------- + else if( verb.compare( _T("mkdir") ) == 0 ) + { + GetNoun(noun); + TCOUT << "Making a child of " << noun << std::endl; + if( pIter->SeekTo( noun.c_str() ) ) + { + pIter->AddChildArray(); + } + else + { + TCOUT << "Unable to find object " << noun << std::endl; + } + } + //----------------------------------------------------------------- + // mk + //----------------------------------------------------------------- + else if( verb.compare( _T("mk") ) == 0 ) + { + GetNoun(noun); + TCOUT << "Making object " << noun << std::endl; + if( pIter->SeekTo( noun.c_str() ) ) + { + TCOUT << "Error: object already exists!" << std::endl; + } + else + { + pIter->AddFCO( noun, 0 ); // add a null fco for now + } + } + //----------------------------------------------------------------- + // rmdir + //----------------------------------------------------------------- + else if( verb.compare( _T("rmdir") ) == 0 ) + { + GetNoun(noun); + TCOUT << "Removing the child of " << noun << std::endl; + if( pIter->SeekTo( noun.c_str() ) ) + { + if( pIter->CanRemoveChildArray() ) + { + pIter->RemoveChildArray(); + } + else + { + TCOUT << "Can't delete object; it still has children." << std::endl; + } + } + else + { + TCOUT << "Unable to find object " << noun << std::endl; + } + } + //----------------------------------------------------------------- + // rm + //----------------------------------------------------------------- + else if( verb.compare( _T("rm") ) == 0 ) + { + GetNoun(noun); + TCOUT << "Removing object " << noun << std::endl; + if( pIter->SeekTo( noun.c_str() ) ) + { + if( pIter->CanDescend() ) + { + TCOUT << "Can't delete object; it still has children." << std::endl; + } + else + { + pIter->RemoveFCO(); + } + } + else + { + TCOUT << "Unable to find object " << noun << std::endl; + } + } + else if( verb.compare( _T("rmdata") ) == 0 ) + { + GetNoun(noun); + TCOUT << "Removing object data " << noun << std::endl; + if( pIter->SeekTo( noun.c_str() ) ) + { + if( pIter->CanDescend() ) + { + TCOUT << "Can't delete object; it still has children." << std::endl; + } + else + { + pIter->RemoveFCOData(); + } + } + else + { + TCOUT << "Unable to find object " << noun << std::endl; + } + } + //----------------------------------------------------------------- // pwd //----------------------------------------------------------------- else if( verb.compare( _T("pwd") ) == 0 ) @@ -380,11 +478,11 @@ void cDbExplore::Execute( cFCODatabaseFileIter& dbIter ) // make sure the file is still valid... // - /* + #ifdef _BLOCKFILE_DEBUG - db.AssertAllBlocksValid() ; + dbIter.GetDb().AssertAllBlocksValid(); #endif - */ + } delete pIter; diff --git a/src/tw/dbexplore.h b/src/tw/dbexplore.h index 388a1e4..9e0e272 100644 --- a/src/tw/dbexplore.h +++ b/src/tw/dbexplore.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/fcodatabasefile.cpp b/src/tw/fcodatabasefile.cpp index d36a5c2..c7b9de1 100644 --- a/src/tw/fcodatabasefile.cpp +++ b/src/tw/fcodatabasefile.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -62,7 +62,7 @@ cFCODatabaseFile::tEntry::tEntry( cGenre::Genre genre ) } cFCODatabaseFile::cFCODatabaseFile() -#ifdef _DEBUG +#ifdef DEBUG : mFileName( _T("Unknown file name") ) #else : mFileName( _T("") ) // If we don't know the filename, lets just not have one in release mode. diff --git a/src/tw/fcodatabasefile.h b/src/tw/fcodatabasefile.h index 875ed4b..656c697 100644 --- a/src/tw/fcodatabasefile.h +++ b/src/tw/fcodatabasefile.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/fcodatabaseutil.cpp b/src/tw/fcodatabaseutil.cpp index a300cf2..e78a56c 100644 --- a/src/tw/fcodatabaseutil.cpp +++ b/src/tw/fcodatabaseutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/fcodatabaseutil.h b/src/tw/fcodatabaseutil.h index 5ab2d72..a40a234 100644 --- a/src/tw/fcodatabaseutil.h +++ b/src/tw/fcodatabaseutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/fcoreport.cpp b/src/tw/fcoreport.cpp index b66c231..d4c624d 100644 --- a/src/tw/fcoreport.cpp +++ b/src/tw/fcoreport.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -722,7 +722,7 @@ void cFCOReport::AddChangedFCO(const cFCOReportSpecIter& iter, const iFCO* pOldF // make some assertions about the iterator - #ifdef _DEBUG + #ifdef DEBUG // make sure iter points to one of our spec lists cFCOReport_i::GenreSpecList::iterator genreIter; for (genreIter = mpData->mGenreList.begin(); ; ++genreIter) diff --git a/src/tw/fcoreport.h b/src/tw/fcoreport.h index 7010edf..74dfe8d 100644 --- a/src/tw/fcoreport.h +++ b/src/tw/fcoreport.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/fcoreportutil.cpp b/src/tw/fcoreportutil.cpp index 076f524..539c65c 100644 --- a/src/tw/fcoreportutil.cpp +++ b/src/tw/fcoreportutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/fcoreportutil.h b/src/tw/fcoreportutil.h index b4e2510..8701f93 100644 --- a/src/tw/fcoreportutil.h +++ b/src/tw/fcoreportutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/filemanipulator.cpp b/src/tw/filemanipulator.cpp index 0ee37c3..ef7485c 100644 --- a/src/tw/filemanipulator.cpp +++ b/src/tw/filemanipulator.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/filemanipulator.h b/src/tw/filemanipulator.h index bb5c893..f0bc987 100644 --- a/src/tw/filemanipulator.h +++ b/src/tw/filemanipulator.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/headerinfo.cpp b/src/tw/headerinfo.cpp index 3f843be..66c4128 100644 --- a/src/tw/headerinfo.cpp +++ b/src/tw/headerinfo.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/headerinfo.h b/src/tw/headerinfo.h index 96ad016..25988be 100644 --- a/src/tw/headerinfo.h +++ b/src/tw/headerinfo.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/policyfile.cpp b/src/tw/policyfile.cpp index 9fc16c8..e5e9de6 100644 --- a/src/tw/policyfile.cpp +++ b/src/tw/policyfile.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/policyfile.h b/src/tw/policyfile.h index a24378d..7be894a 100644 --- a/src/tw/policyfile.h +++ b/src/tw/policyfile.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/stdtw.cpp b/src/tw/stdtw.cpp index 7111d82..32121c9 100644 --- a/src/tw/stdtw.cpp +++ b/src/tw/stdtw.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,4 +37,4 @@ // #include "stdtw.h" -// eof: stdtw.cpp + diff --git a/src/tw/stdtw.h b/src/tw/stdtw.h index e7a5a92..87c39ef 100644 --- a/src/tw/stdtw.h +++ b/src/tw/stdtw.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/systeminfo.cpp b/src/tw/systeminfo.cpp index a71b7d1..f099163 100644 --- a/src/tw/systeminfo.cpp +++ b/src/tw/systeminfo.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/systeminfo.h b/src/tw/systeminfo.h index 67e9f58..1a63f28 100644 --- a/src/tw/systeminfo.h +++ b/src/tw/systeminfo.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/textdbviewer.cpp b/src/tw/textdbviewer.cpp index d6dd5c3..9d4eba0 100644 --- a/src/tw/textdbviewer.cpp +++ b/src/tw/textdbviewer.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/textdbviewer.h b/src/tw/textdbviewer.h index b81e800..eaf31fa 100644 --- a/src/tw/textdbviewer.h +++ b/src/tw/textdbviewer.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/textreportviewer.cpp b/src/tw/textreportviewer.cpp index d1e8b61..9d84788 100644 --- a/src/tw/textreportviewer.cpp +++ b/src/tw/textreportviewer.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -2006,7 +2006,7 @@ void cTextReportViewer::GetChar() // sequence was not a valid mb character // (searched MB_CUR_MAX chars and didn't find a complete mb character) d.TraceDebug( _T("Invalid mb char found!\n") ); -#ifdef _DEBUG +#ifdef DEBUG for( int j = 0; j < MB_CUR_MAX; j++ ) d.TraceDebug( _T("%u\n"), (size_t)(unsigned char)mCurrentChar[j] ); #endif diff --git a/src/tw/textreportviewer.h b/src/tw/textreportviewer.h index 32ad6a1..f6adfb3 100644 --- a/src/tw/textreportviewer.h +++ b/src/tw/textreportviewer.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/tw.cpp b/src/tw/tw.cpp index dcb0d66..1ffba2e 100644 --- a/src/tw/tw.cpp +++ b/src/tw/tw.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -66,5 +66,5 @@ cTW::cTW() TSS_REGISTER_PKG_ERRORS( tw ) } -// eof: tw.cpp + diff --git a/src/tw/tw.h b/src/tw/tw.h index 547bfe7..e1ff4bd 100644 --- a/src/tw/tw.h +++ b/src/tw/tw.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/twerrors.cpp b/src/tw/twerrors.cpp index cf9be69..42a05bf 100644 --- a/src/tw/twerrors.cpp +++ b/src/tw/twerrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/twerrors.h b/src/tw/twerrors.h index df2613c..f8ecd31 100644 --- a/src/tw/twerrors.h +++ b/src/tw/twerrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/twinit.cpp b/src/tw/twinit.cpp index cac48aa..5d98cc5 100644 --- a/src/tw/twinit.cpp +++ b/src/tw/twinit.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -157,6 +157,9 @@ static bool SetExeDir( const TSTRING& strArgv0 ) TSTRING strFullPath; if( iFSServices::GetInstance()->GetExecutableFilename( strFullPath, strArgv0 ) && !strFullPath.empty() ) { +#if USES_DEVICE_PATH + strFullPath = cDevicePath::AsPosix(strFullPath); +#endif cSystemInfo::SetExePath(strFullPath); TSTRING::size_type s = strFullPath.find_last_of( _T('/') ); @@ -292,7 +295,7 @@ void cTWInit::Init( const TSTRING& strArgv0 ) tw_HandleSignal( SIGSEGV ); // Segmentation fault tw_HandleSignal( SIGQUIT ); // Quit signal - issued from terminal (CTRL-\) tw_HandleSignal( SIGILL ); // Illegal instruction - probably won't be an issue. -#ifndef _DEBUG +#ifndef DEBUG tw_HandleSignal( SIGTRAP ); // We don't want to mess up the debugger in debug builds... #endif tw_HandleSignal( SIGABRT ); // Supposedly we can only get this signal by calling abort() diff --git a/src/tw/twinit.h b/src/tw/twinit.h index 7179627..63874c1 100644 --- a/src/tw/twinit.h +++ b/src/tw/twinit.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/tw/twstrings.cpp b/src/tw/twstrings.cpp index da4637b..0e243f6 100644 --- a/src/tw/twstrings.cpp +++ b/src/tw/twstrings.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -42,7 +42,7 @@ #define UNICODE_STR _T("") -#ifdef _DEBUG +#ifdef DEBUG # define DEBUG_STR _T("d") #else # define DEBUG_STR _T("") @@ -111,7 +111,7 @@ TSS_BeginStringtable( cTW ) TSS_StringEntry( tw::STR_NEWLINE, _T("\n")), TSS_StringEntry( tw::STR_ERR_TWCFG_CANT_READ, _T("Configuration file could not be read.")), TSS_StringEntry( tw::STR_ERR_NO_MODE, _T("No mode specified.")), - TSS_StringEntry( tw::STR_UNKOWN_MODE_SPECIFIED, _T("Unknown mode specified: ")), + TSS_StringEntry( tw::STR_UNKNOWN_MODE_SPECIFIED, _T("Unknown mode specified: ")), TSS_StringEntry( tw::STR_ERR2_BAD_MODE_SWITCH, _T("Unrecognized mode: ")), TSS_StringEntry( tw::STR_OPEN_POLICY_FILE, _T("Opening policy file: ")), @@ -249,5 +249,5 @@ TSS_BeginStringtable( cTW ) TSS_EndStringtable( cTW ) -// eof: twstrings.cpp + diff --git a/src/tw/twstrings.h b/src/tw/twstrings.h index 80bee5d..8822f0b 100644 --- a/src/tw/twstrings.h +++ b/src/tw/twstrings.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -58,7 +58,7 @@ TSS_BeginStringIds( tw ) STR_NEWLINE, STR_ERR_TWCFG_CANT_READ, STR_ERR_NO_MODE, - STR_UNKOWN_MODE_SPECIFIED, + STR_UNKNOWN_MODE_SPECIFIED, STR_ERR2_BAD_MODE_SWITCH, STR_PARSING_POLICY, STR_ERR_REPORT_READ, diff --git a/src/tw/twutil.cpp b/src/tw/twutil.cpp index 62a25f3..d8a3a13 100644 --- a/src/tw/twutil.cpp +++ b/src/tw/twutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -64,20 +64,17 @@ #include "tw/twerrors.h" #include "core/ntmbs.h" #include "core/displayencoder.h" +#include "core/tw_signal.h" #ifdef TW_PROFILE #include "core/tasktimer.h" #endif -#include "core/fsservices.h" // for the util_IsDir() stuff - #include #include #if SUPPORTS_TERMIOS # include # include - -#include "core/tw_signal.h" int _getch(void); #endif @@ -335,61 +332,6 @@ bool cTWUtil::IsObjectEncrypted( const TCHAR* objFileName, const cFileHeaderID& return( fEncrypted ); } -bool cTWUtil::IsObjectEncrypted( cArchive &arch, const cFileHeaderID& fhid, const TSTRING& errorMsg ) -{ - bool fEncrypted = false; - cDebug d("IsObjectEncrypted"); - d.TraceDebug(_T("Reading from archive\n")); - - try - { - cFileHeader fileHeader; - cSerializerImpl fhSer(arch, cSerializerImpl::S_READ, TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME).c_str()); - fileHeader.Read(&fhSer); - - // check for a mismatched header - if (fileHeader.GetID() != fhid) - ThrowAndAssert(eSerializerInputStreamFmt(_T(""), TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME).c_str(), eSerializer::TY_FILE)); - - // switch on the type of encoding... - if(fileHeader.GetEncoding() == cFileHeader::ASYM_ENCRYPTION) - { - fEncrypted = true; - } - else if(fileHeader.GetEncoding() == cFileHeader::COMPRESSED) - { - fEncrypted = false; - } - else - // unknown encoding... - ThrowAndAssert(eSerializerInputStreamFmt(_T(""), TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME).c_str(), eSerializer::TY_FILE)); - } - catch(eArchive& e) - { - // Note: Output to TCERR is O.K. here, it is documented that this is what this function does - TSTRING msg = e.GetMsg(); - if( ! msg.empty() ) - msg += _T("\n"); - msg += errorMsg; - - cTWUtil::PrintErrorMsg(ePoly(e.GetID(), msg, e.GetFlags() )); - ThrowAndAssert(ePoly()); - } - catch(eSerializer& e) - { - // Note: Output to TCERR is O.K. here, it is documented that this is what this function does - TSTRING msg = e.GetMsg(); - if( ! msg.empty() ) - msg += _T("\n"); - msg += errorMsg; - - cTWUtil::PrintErrorMsg(ePoly(e.GetID(), msg, e.GetFlags() )); - ThrowAndAssert(ePoly()); - } - - return( fEncrypted ); -} - /////////////////////////////////////////////////////////////////////////////// // WriteDatabase @@ -403,7 +345,7 @@ void cTWUtil::WriteDatabase(const TCHAR* filename, cFCODatabaseFile& db, bool bE //fileHeader.SetVersion(1); #ifdef TW_PROFILE - cWin32TaskTimer timer(_T("Write Database")); + cTaskTimer timer(_T("Write Database")); timer.Start(); #endif @@ -428,7 +370,7 @@ void cTWUtil::ReadDatabase(const TCHAR* filename, cFCODatabaseFile& db, const cE cDisplayEncoder::EncodeInline( filename ).c_str() ); #ifdef TW_PROFILE - cWin32TaskTimer timer("cTWUtil::ReadDatabase"); + cTaskTimer timer("cTWUtil::ReadDatabase"); timer.Start(); #endif @@ -455,20 +397,6 @@ void cTWUtil::WriteReport(const TCHAR* filename, const cFCOReportHeader& reportH } -void cTWUtil::WriteReport(cArchive &archive, const cFCOReportHeader& reportHeader, const cFCOReport& r, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey) -{ - cFileHeader fileHeader; - fileHeader.SetID(cFCOReport::GetFileHeaderID()); - - TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME); - - WriteObjectToArchive(archive, filename.c_str(), &reportHeader, r, fileHeader, bEncrypt, pPrivateKey); - - iUserNotify::GetInstance()->Notify( iUserNotify::V_NORMAL, _T("%s%s\n"), - TSS_GetString( cTW, tw::STR_WRITE_REPORT_FILE).c_str(), - cDisplayEncoder::EncodeInline( filename ).c_str() ); -} - /////////////////////////////////////////////////////////////////////////////// // ReadReport /////////////////////////////////////////////////////////////////////////////// @@ -481,16 +409,6 @@ void cTWUtil::ReadReport(const TCHAR* reportFileName, cFCOReportHeader& reportHe ReadObject(reportFileName, &reportHeader, r, cFCOReport::GetFileHeaderID(), pPublicKey, bEncrypted); } -void cTWUtil::ReadReport(cArchive &archive, cFCOReportHeader& reportHeader, cFCOReport& r, const cElGamalSigPublicKey* pPublicKey, bool silent, bool& bEncrypted) -{ - TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME); - - iUserNotify::GetInstance()->Notify( iUserNotify::V_VERBOSE, _T("%s%s\n"), - TSS_GetString( cTW, tw::STR_OPEN_REPORT_FILE).c_str(), - cDisplayEncoder::EncodeInline( filename ).c_str()); - - ReadObjectFromArchive(archive, filename.c_str(), &reportHeader, r, cFCOReport::GetFileHeaderID(), pPublicKey, bEncrypted); -} /////////////////////////////////////////////////////////////////////////////// // UpdatePolicyFile @@ -601,38 +519,6 @@ void cTWUtil::WriteConfigText(const TCHAR* filename, const TSTRING configText, b cDisplayEncoder::EncodeInline( filename ).c_str() ); } -void cTWUtil::WriteConfigText(cArchive &archive, const TSTRING configText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey) -{ - cSerializableNString nstring; - - nstring.mString = CONFIG_FILE_MAGIC_8BYTE; - - TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME); - - std::string ns; - cStringUtil::Convert( ns, configText ); - nstring.mString += ns; - - cFileHeader fileHeader; - fileHeader.SetID(cConfigFile::GetFileHeaderID()); - - fileHeader.SetVersion(CURRENT_FIXED_VERSION); - - if (bEncrypt) - { - ASSERT(pPrivateKey != 0); - cElGamalSigPublicKey publicKey(*pPrivateKey); - fileHeader.GetBaggage().MapArchive(0, publicKey.GetWriteLen()); - publicKey.Write(fileHeader.GetBaggage().GetMap()); - } - - WriteObjectToArchive(archive, filename.c_str(), NULL, nstring, fileHeader, bEncrypt, pPrivateKey); - - iUserNotify::GetInstance()->Notify( iUserNotify::V_NORMAL, _T("%s%s\n"), - TSS_GetString( cTW, tw::STR_WRITE_CONFIG_FILE).c_str(), - cDisplayEncoder::EncodeInline( filename ).c_str()); -} - /////////////////////////////////////////////////////////////////////////////// // ReadConfigText @@ -745,111 +631,6 @@ void cTWUtil::ReadConfigText(const TCHAR* filename, TSTRING& configText, cArchiv } -void cTWUtil::ReadConfigText(cArchive &arch, TSTRING& configText, cArchive* pBaggage) -{ -// TODO -- neat up this function; try to use LoadObject() above... - - cSerializableNString nstring; - - TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME); - - // This was coppied from ReadObject(). We need to use the baggage of the - // file header to obtain the public key, thus the special casing. - cDebug d("ReadConfigText"); - d.TraceDebug(_T("Reading %s from file %s\n"), nstring.GetType().AsString(), filename.c_str()); - - iUserNotify::GetInstance()->Notify( iUserNotify::V_VERBOSE, _T("%s%s\n"), - TSS_GetString( cTW, tw::STR_OPEN_CONFIG_FILE).c_str(), - cDisplayEncoder::EncodeInline( filename ).c_str()); - - - cFileHeader fileHeader; - - try - { - cSerializerImpl fhSer(arch, cSerializerImpl::S_READ); - fileHeader.Read(&fhSer); - } - catch (eError&) - { - throw eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE); - } - -#if 0 // XXX: This is broken, how can you convert a class to an int??? -PH - d.TraceDebug("Found a file header of type %d.\n", fileHeader.GetEncoding()); -#endif - - // check for a mismatched header - if (fileHeader.GetID() != cConfigFile::GetFileHeaderID()) - throw eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE); - - // check the version - if (fileHeader.GetVersion() != CURRENT_FIXED_VERSION) - throw eSerializerVersionMismatch(_T(""), filename.c_str(), eSerializer::TY_FILE); - - // switch on the type of encoding... - if(fileHeader.GetEncoding() == cFileHeader::ASYM_ENCRYPTION) - { - d.TraceDebug("Config file is compressed, public key len %d.\n", fileHeader.GetBaggage().Length()); - - // tell the user the db is encrypted - iUserNotify::GetInstance()->Notify( iUserNotify::V_VERBOSE, TSS_GetString(cTW, tw::STR_FILE_ENCRYPTED).c_str()); - iUserNotify::GetInstance()->Notify( iUserNotify::V_VERBOSE, TSS_GetString(cTW, tw::STR_NEWLINE).c_str()); - - ASSERT(fileHeader.GetBaggage().Length() > 0); - if (fileHeader.GetBaggage().Length() <= 0) - ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE)); - - fileHeader.GetBaggage().MapArchive(0, fileHeader.GetBaggage().Length()); - - cElGamalSigPublicKey publicKey(fileHeader.GetBaggage().GetMap()); - - cElGamalSigArchive cryptoArchive; - cryptoArchive.SetRead(&arch, &publicKey); - - cSerializerImpl ser(cryptoArchive, cSerializerImpl::S_READ); - ser.Init(); - ser.ReadObject(&nstring); - ser.Finit(); - - // copy the baggage into the archive, if it was passed in - // Note: We rely in VerifySiteKey that we only fill out pBaggage if - // the config file is encrypted. - // - if( pBaggage ) - { - fileHeader.GetBaggage().Seek( 0, cBidirArchive::BEGINNING ); - pBaggage->Copy( &fileHeader.GetBaggage(), fileHeader.GetBaggage().Length() ); - } - } - else if(fileHeader.GetEncoding() == cFileHeader::COMPRESSED) - { - d.TraceDebug("Config file is not compressed.\n"); - - //not encrypted db... - cNullCryptoArchive cryptoArchive; - cryptoArchive.Start(&arch); - - cSerializerImpl ser(cryptoArchive, cSerializerImpl::S_READ); - ser.Init(); - ser.ReadObject(&nstring); - ser.Finit(); - } - else - // unknown encoding... - throw eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE); - - // check 8 byte header - if (nstring.mString.compare(0, 8*sizeof(byte), CONFIG_FILE_MAGIC_8BYTE) != 0) - ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE)); - - // remove 8 byte header - nstring.mString.assign(nstring.mString.substr(8)); - - cStringUtil::Convert( configText, nstring.mString ); -} - - /////////////////////////////////////////////////////////////////////////////// // Given a filename and the text of a policy file, write an encrypted version // of the policy file text to disk. @@ -874,26 +655,6 @@ void cTWUtil::WritePolicyText(const TCHAR* filename, const std::string& polText, cDisplayEncoder::EncodeInline( filename ).c_str() ); } -void cTWUtil::WritePolicyText(cArchive &archive, const std::string& polText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey) -{ - cSerializableNString nstring; - - TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME); - - // add a 8 byte header we can use to verify decryption - nstring.mString = POLICY_FILE_MAGIC_8BYTE; - - nstring.mString += polText; - - cFileHeader fileHeader; - fileHeader.SetID(cPolicyFile::GetFileHeaderID()); - - WriteObjectToArchive(archive, filename.c_str(), NULL, nstring, fileHeader, bEncrypt, pPrivateKey); - - iUserNotify::GetInstance()->Notify( iUserNotify::V_NORMAL, _T("%s%s\n"), - TSS_GetString( cTW, tw::STR_WRITE_POLICY_FILE).c_str(), - cDisplayEncoder::EncodeInline( filename ).c_str()); -} /////////////////////////////////////////////////////////////////////////////// // ReadPolicyText @@ -920,24 +681,6 @@ void cTWUtil::ReadPolicyText(const TCHAR* filename, std::string& polText, const polText = nstring.mString; } -void cTWUtil::ReadPolicyText(cArchive &archive, std::string& polText, const cElGamalSigPublicKey* pPublicKey) -{ - cSerializableNString nstring; - - TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME); - - bool bEncrypted; - ReadObjectFromArchive(archive, filename.c_str(), NULL, nstring, cPolicyFile::GetFileHeaderID(), pPublicKey, bEncrypted); - - // check 8 byte header - if (nstring.mString.compare(0, 8*sizeof(byte), POLICY_FILE_MAGIC_8BYTE) != 0) - ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE)); - - // remove 8 byte header - nstring.mString.assign(nstring.mString.substr(8)); - - polText = nstring.mString; -} /////////////////////////////////////////////////////////////////////////////// // OpenKeyFile @@ -1126,7 +869,7 @@ static struct termios Otty; static void RestoreEcho(int sig) { #if SUPPORTS_TERMIOS -#ifdef _DEBUG +#ifdef DEBUG std::cout << "Caught signal, resetting echo."<< std::endl; sleep(2); #endif diff --git a/src/tw/twutil.h b/src/tw/twutil.h index 9c51978..fa629a6 100644 --- a/src/tw/twutil.h +++ b/src/tw/twutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -106,16 +106,16 @@ public: // if an error occurs, this will print the error message to stderr and throw eError. static void WriteReport (const TCHAR* filename, const cFCOReportHeader& reportHeader, const cFCOReport& r, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); // throw eError - static void WriteReport (cArchive &archive, const cFCOReportHeader& reportHeader, const cFCOReport& r, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); // throw eError + static void ReadReport (const TCHAR* reportFileName, cFCOReportHeader& reportHeader, cFCOReport& r, const cElGamalSigPublicKey* pPublicKey, bool silent, bool& bEncrypted); // throw eError - static void ReadReport (cArchive &archive, cFCOReportHeader& reportHeader, cFCOReport& r, const cElGamalSigPublicKey* pPublicKey, bool silent, bool& bEncrypted); // throw eError + // same as Read/WriteDatabase above, except it operates on reports // if an error occurs, this will print the error message to stderr and throw eError. static void WriteConfigText(const TCHAR* filename, const TSTRING configText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); // throw (eArchive()) - static void WriteConfigText(cArchive &archive, const TSTRING configText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); // throw (eArchive()) + static void ReadConfigText(const TCHAR* filename, TSTRING& configText, cArchive* pBaggage = 0); - static void ReadConfigText(cArchive &archive, TSTRING& configText, cArchive* pBaggage = 0); + // read and write config file text to and from disk. // if pBaggage is non-NULL, the contents of the baggage( ie -- the public key ) is copied to the archive. // eArchive is thrown if filename can not be opened @@ -123,9 +123,9 @@ public: // eConfigFile is thrown if config file does not parse correctly during reading static void WritePolicyText(const TCHAR* filename, const std::string& policyText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); - static void WritePolicyText(cArchive &archive, const std::string& policyText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); + static void ReadPolicyText(const TCHAR* filename, std::string& policyText, const cElGamalSigPublicKey* pPublicKey); - static void ReadPolicyText(cArchive &archive, std::string& policyText, const cElGamalSigPublicKey* pPublicKey); + // read and write policy file to and from disk // eError() will be thrown on error diff --git a/src/twadmin/Makefile.am b/src/twadmin/Makefile.am index b59ec1c..538bde7 100644 --- a/src/twadmin/Makefile.am +++ b/src/twadmin/Makefile.am @@ -17,7 +17,7 @@ twadmin_HEADERS = \ twadmincl.h twadminerrors.h twadminstrings.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit -CLEANFILES = ../../bin/twadmin +CLEANFILES = ../../bin/twadmin *.gcno *.gcda all: $(sbin_PROGRAMS) @test -d ../../bin && $(LN) -f $(sbin_PROGRAMS) ../../bin diff --git a/src/twadmin/Makefile.in b/src/twadmin/Makefile.in index 7130f57..b3a8e68 100644 --- a/src/twadmin/Makefile.in +++ b/src/twadmin/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -295,7 +295,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -320,7 +319,7 @@ twadmin_HEADERS = \ keygeneration.h resource.h stdtwadmin.h twadmin.h \ twadmincl.h twadminerrors.h twadminstrings.h -CLEANFILES = ../../bin/twadmin +CLEANFILES = ../../bin/twadmin *.gcno *.gcda all: all-am .SUFFIXES: diff --git a/src/twadmin/keygeneration.cpp b/src/twadmin/keygeneration.cpp index b858d4e..edf47fa 100644 --- a/src/twadmin/keygeneration.cpp +++ b/src/twadmin/keygeneration.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -85,7 +85,7 @@ static void GeneratePublicPrivateKeys(void* pParams, const cElGamalSig::KeySize try { cKeyFile keyfile; -#ifdef _DEBUG +#ifdef DEBUG cDebug d("GeneratePublicPrivateKeys"); d.TraceDebug("calling keyfile.GenerateKeys()\n"); #endif @@ -101,7 +101,7 @@ static void GeneratePublicPrivateKeys(void* pParams, const cElGamalSig::KeySize return; } -#ifdef _DEBUG +#ifdef DEBUG d.TraceDebug(_T("writing to keyfile %s\n"), pGK->keyPath); #endif @@ -135,7 +135,7 @@ bool GenerateKey(const TCHAR* keyPath, wc16_string passphrase, const cElGamalSig passphrase.swapbytes(); #endif -#ifdef _DEBUG +#ifdef DEBUG // test reading in the keys wc16_string passphrase_copy = passphrase.c_str(); wc16_string passphrase_copy2 = passphrase.c_str(); @@ -169,7 +169,7 @@ bool GenerateKey(const TCHAR* keyPath, wc16_string passphrase, const cElGamalSig return false; } -#ifdef _DEBUG +#ifdef DEBUG // test reading in the keys cKeyFile keyfile; diff --git a/src/twadmin/keygeneration.h b/src/twadmin/keygeneration.h index 69be7df..67540ee 100644 --- a/src/twadmin/keygeneration.h +++ b/src/twadmin/keygeneration.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twadmin/resource.h b/src/twadmin/resource.h index 5510e67..6548173 100644 --- a/src/twadmin/resource.h +++ b/src/twadmin/resource.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twadmin/stdtwadmin.cpp b/src/twadmin/stdtwadmin.cpp index 380ac77..6de9773 100644 --- a/src/twadmin/stdtwadmin.cpp +++ b/src/twadmin/stdtwadmin.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,4 +37,4 @@ #include "stdtwadmin.h" -// eof: stdtwadmin.cpp + diff --git a/src/twadmin/stdtwadmin.h b/src/twadmin/stdtwadmin.h index 8d7c961..2f36b84 100644 --- a/src/twadmin/stdtwadmin.h +++ b/src/twadmin/stdtwadmin.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twadmin/twadmin.cpp b/src/twadmin/twadmin.cpp index 84f0fb1..92226e8 100644 --- a/src/twadmin/twadmin.cpp +++ b/src/twadmin/twadmin.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -69,4 +69,4 @@ cTWAdmin::cTWAdmin() TSS_REGISTER_PKG_ERRORS ( twadmin ); } -// eof: twadmin.cpp + diff --git a/src/twadmin/twadmin.h b/src/twadmin/twadmin.h index c825f82..cdc129a 100644 --- a/src/twadmin/twadmin.h +++ b/src/twadmin/twadmin.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twadmin/twadmincl.cpp b/src/twadmin/twadmincl.cpp index b4d1ddb..068d05f 100644 --- a/src/twadmin/twadmincl.cpp +++ b/src/twadmin/twadmincl.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -34,8 +34,6 @@ // #include "stdtwadmin.h" -#include - #include "twadmincl.h" #include "twadminstrings.h" #include "keygeneration.h" @@ -45,6 +43,7 @@ #include "core/usernotify.h" #include "core/cmdlineparser.h" #include "core/usernotify.h" +#include "core/corestrings.h" #include "fco/fconame.h" #include "tw/configfile.h" #include "tw/twutil.h" @@ -62,8 +61,10 @@ #include "twcrypto/crypto.h" #include "core/displayencoder.h" +#include + //Provide a swab() impl. from glibc, for platforms that don't have one -#if NEEDS_SWAB_IMPL +#if !HAVE_SWAB || NEEDS_SWAB_IMPL void swab (const void *bfrom, void *bto, ssize_t n) { const char *from = (const char *) bfrom; @@ -1553,15 +1554,19 @@ int cTWAModeExamine::Execute(cErrorQueue* pQueue) // Try different keys to see if they decrypt this file if (manip.GetEncoding() == cFileHeader::ASYM_ENCRYPTION) { + bool bFound = false; + // Output the keys that decrypt the file. iUserNotify::GetInstance()->Notify(iUserNotify::V_NORMAL, TSS_GetString(cTWAdmin, twadmin::STR_KEYS_DECRYPT ).c_str()); iUserNotify::GetInstance()->Notify(iUserNotify::V_NORMAL, TSS_GetString(cTW, tw::STR_NEWLINE ).c_str()); - + if (siteKey.KeysLoaded()) try { if (manip.TestDecryption(*siteKey.GetPublicKey(), false) != false) { + bFound = true; + iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, TSS_GetString(cTWAdmin, twadmin::STR_SITEKEYFILE ).c_str()); iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, cDisplayEncoder::EncodeInline( mSiteKeyFile ).c_str()); @@ -1575,6 +1580,8 @@ int cTWAModeExamine::Execute(cErrorQueue* pQueue) { if (manip.TestDecryption(*localKey.GetPublicKey(), false) != false) { + bFound = true; + iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, TSS_GetString(cTWAdmin, twadmin::STR_LOCALKEYFILE ).c_str()); iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, cDisplayEncoder::EncodeInline( mLocalKeyFile ).c_str()); @@ -1582,6 +1589,15 @@ int cTWAModeExamine::Execute(cErrorQueue* pQueue) } } catch (eError&) {} + + if (!bFound) + { + bResult = false; + iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, "\t"); + iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, TSS_GetString(cCore, core::STR_UNKNOWN).c_str()); + iUserNotify::GetInstance()->Notify(iUserNotify::V_SILENT, TSS_GetString(cTW, tw::STR_NEWLINE ).c_str()); + } + } TCOUT << std::endl; } diff --git a/src/twadmin/twadmincl.h b/src/twadmin/twadmincl.h index 1278071..520e04f 100644 --- a/src/twadmin/twadmincl.h +++ b/src/twadmin/twadmincl.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twadmin/twadminerrors.cpp b/src/twadmin/twadminerrors.cpp index 5c650ad..13e01ba 100644 --- a/src/twadmin/twadminerrors.cpp +++ b/src/twadmin/twadminerrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twadmin/twadminerrors.h b/src/twadmin/twadminerrors.h index ead4837..3146364 100644 --- a/src/twadmin/twadminerrors.h +++ b/src/twadmin/twadminerrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twadmin/twadminmain.cpp b/src/twadmin/twadminmain.cpp index 696032c..7ee97c7 100644 --- a/src/twadmin/twadminmain.cpp +++ b/src/twadmin/twadminmain.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -42,7 +42,7 @@ #include "tw/twutil.h" #include "tw/twstrings.h" #include "twadminstrings.h" -#include "core/timebomb.h" +#include "core/epoch.h" #include "core/errorbucketimpl.h" #include "core/archive.h" @@ -73,7 +73,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ], const TCHAR* envp[ ] ) int ret = 0; - if (TimeBombExploded()) + if (CheckEpoch()) return 1; cTWInit twInit; diff --git a/src/twadmin/twadminstrings.cpp b/src/twadmin/twadminstrings.cpp index 769dc10..2c3424d 100644 --- a/src/twadmin/twadminstrings.cpp +++ b/src/twadmin/twadminstrings.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twadmin/twadminstrings.h b/src/twadmin/twadminstrings.h index 4acaf26..2314491 100644 --- a/src/twadmin/twadminstrings.h +++ b/src/twadmin/twadminstrings.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twcrypto/Makefile.am b/src/twcrypto/Makefile.am index 27d1fd3..27aaa0c 100644 --- a/src/twcrypto/Makefile.am +++ b/src/twcrypto/Makefile.am @@ -13,6 +13,7 @@ libtwcrypto_a_HEADERS = \ stdtwcrypto.h twcrypto.h twcryptoerrors.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit +CLEANFILES = *.gcno *.gcda all: $(noinst_LIBRARIES) $(AR) ru ../../lib/libtripwire.a $(libtwcrypto_a_OBJECTS) diff --git a/src/twcrypto/Makefile.in b/src/twcrypto/Makefile.in index c4e40df..9afae2e 100644 --- a/src/twcrypto/Makefile.in +++ b/src/twcrypto/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -301,7 +301,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -326,6 +325,7 @@ libtwcrypto_a_HEADERS = \ bytequeue.h crypto.h cryptoarchive.h keyfile.h \ stdtwcrypto.h twcrypto.h twcryptoerrors.h +CLEANFILES = *.gcno *.gcda all: all-am .SUFFIXES: @@ -512,6 +512,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) diff --git a/src/twcrypto/bytequeue.cpp b/src/twcrypto/bytequeue.cpp index accc70b..bf9910e 100644 --- a/src/twcrypto/bytequeue.cpp +++ b/src/twcrypto/bytequeue.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twcrypto/bytequeue.h b/src/twcrypto/bytequeue.h index 9d1511f..a2582c4 100644 --- a/src/twcrypto/bytequeue.h +++ b/src/twcrypto/bytequeue.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twcrypto/crypto.cpp b/src/twcrypto/crypto.cpp index 92dbf25..0334555 100644 --- a/src/twcrypto/crypto.cpp +++ b/src/twcrypto/crypto.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -39,6 +39,7 @@ #include "core/errorgeneral.h" #include "time.h" #include "core/archive.h" +#include "core/usernotify.h" #include "cryptlib/sha.h" #include "cryptlib/rng.h" @@ -53,6 +54,9 @@ #include "cryptlib/rsa.h" #endif +#include +#include + const uint32 EL_GAMAL_SIG_PUBLIC_MAGIC_NUM = 0x7ae2c945; const uint32 EL_GAMAL_SIG_PRIVATE_MAGIC_NUM = 0x0d0ffa12; @@ -476,7 +480,7 @@ void cRSAPublicKey::Write(void* pDataStream) const WRITE_INTEGER(e); } -#ifdef _DEBUG +#ifdef DEBUG void cRSAPublicKey::TraceContents() { cDebug d("cRSAPublicKey::TraceContents"); @@ -687,7 +691,7 @@ void cRSA::GenerateKeys(cRSAPrivateKey*& retPrivate, cRSAPublicKey*& retPublic) retPublic->mpData->mpKey = pNewPublicKey; retPublic->mpData->mKeyLength = mpData->mKeyBits; -#ifdef _DEBUG +#ifdef DEBUG int l; l = retPublic->mpData->mpKey->MaxPlainTextLength(); ASSERT(l == GetBlockSizePlain()); @@ -954,7 +958,7 @@ bool cElGamalSigPublicKey::IsEqual(const cElGamalSigPublicKey& rhs) const ; } -#ifdef _DEBUG +#ifdef DEBUG void cElGamalSigPublicKey::TraceContents() { cDebug d("cElGamalSigPublicKey::TraceContents"); @@ -1167,7 +1171,7 @@ void cElGamalSig::GenerateKeys(cElGamalSigPrivateKey*& retPrivate, cElGamalSigPu retPublic->mpData->mpKey = pNewPublicKey; retPublic->mpData->mKeyLength = (int16)mpData->mKeyBits; -#ifdef _DEBUG +#ifdef DEBUG int l; l = retPublic->mpData->mpKey->SignatureLength(); ASSERT(l + PLAIN_BLOCK_SIZE <= GetBlockSizeCipher()); @@ -1235,13 +1239,40 @@ cHashedKey192::~cHashedKey192() RandomizeBytes(mKey, KEYLEN); } +///////////////////////////////////////////////////////// + +#if USE_DEV_URANDOM +static bool randomize_by_device(const char* device_name, int8* destbuf, int len) +{ + static int rng_device = -1; + + if (-1 == rng_device) + rng_device = open(device_name, O_RDONLY|O_NONBLOCK); + + if (rng_device >= 0) + { + int bytes_read = read(rng_device, destbuf, len); + if (bytes_read == len) + return true; + } + + return false; +} +#else +static bool gRandomizeBytesSeeded = false; +#endif + /////////////////////////////////////////////////////////////////////////////// // void RandomizeBytes(byte* destbuf, int len) -- Fill a buffer with random bytes -static bool gRandomizeBytesSeeded = false; - void RandomizeBytes(int8* destbuf, int len) { +#if USE_DEV_URANDOM + if (randomize_by_device("/dev/urandom", destbuf, len)) + return; + + ThrowAndAssert(eInternal(_T("Failed to read from RNG device"))); +#else if (!gRandomizeBytesSeeded) { // generate a rancom number from processor timing. @@ -1250,7 +1281,7 @@ void RandomizeBytes(int8* destbuf, int len) for (mask = 0xb147688c; time(NULL) - start < 1; mask += 0x8984cc88) ; - #ifdef _DEBUG + #ifdef DEBUG time_t t = time(NULL); t ^= mask; @@ -1267,5 +1298,6 @@ void RandomizeBytes(int8* destbuf, int len) int i; for (i = 0; i < len; ++i) destbuf[i] = (byte)( (rand() * 256 / RAND_MAX) ^ 0xdc ); // 0xdc came from random.org +#endif } diff --git a/src/twcrypto/crypto.h b/src/twcrypto/crypto.h index ddd5d13..4c3f441 100644 --- a/src/twcrypto/crypto.h +++ b/src/twcrypto/crypto.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -209,7 +209,7 @@ public: int GetWriteLen() const; void Write(void* pDataStream) const; -#ifdef _DEBUG +#ifdef DEBUG void TraceContents(); #endif @@ -315,7 +315,7 @@ public: // This is used to make sure the key used to sign the config // file is the same as the key we are currently using. -#ifdef _DEBUG +#ifdef DEBUG void TraceContents(); #endif diff --git a/src/twcrypto/cryptoarchive.cpp b/src/twcrypto/cryptoarchive.cpp index 65ae849..987da90 100644 --- a/src/twcrypto/cryptoarchive.cpp +++ b/src/twcrypto/cryptoarchive.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -116,7 +116,10 @@ cCryptoArchive::~cCryptoArchive() { ASSERT(mAction == MA_UNSTARTED || mAction == MA_UNKNOWN || mAction == MA_FINISHED || mAction == MA_READING); // check we did not leave a buffer unwritten - + + Finish(); + + // Finish() normally zeroes these out, but hey. delete mpDeflator; delete mpInflator; } diff --git a/src/twcrypto/cryptoarchive.h b/src/twcrypto/cryptoarchive.h index ff443ed..d0bc7ea 100644 --- a/src/twcrypto/cryptoarchive.h +++ b/src/twcrypto/cryptoarchive.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twcrypto/keyfile.cpp b/src/twcrypto/keyfile.cpp index 1c6ec9e..5a567b4 100644 --- a/src/twcrypto/keyfile.cpp +++ b/src/twcrypto/keyfile.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -398,7 +398,7 @@ void cKeyFile::ProtectKeys(int8* passphrase, int passphraseLen) // throw eKeyFil des.ProcessBlock(mpPrivateKeyMem + i, mpPrivateKeyMem + i); } -#ifdef _DEBUG +#ifdef DEBUG // try decoding it just to see if it worked if (GetPrivateKey(passphrase, passphraseLen) == 0) { diff --git a/src/twcrypto/keyfile.h b/src/twcrypto/keyfile.h index df844a0..fda38e1 100644 --- a/src/twcrypto/keyfile.h +++ b/src/twcrypto/keyfile.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twcrypto/stdtwcrypto.cpp b/src/twcrypto/stdtwcrypto.cpp index b5a0e4b..bd9b248 100644 --- a/src/twcrypto/stdtwcrypto.cpp +++ b/src/twcrypto/stdtwcrypto.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -38,4 +38,4 @@ #include "stdtwcrypto.h" -// eof: stdtwcrypto.cpp + diff --git a/src/twcrypto/stdtwcrypto.h b/src/twcrypto/stdtwcrypto.h index 70e0c55..20ea8cf 100644 --- a/src/twcrypto/stdtwcrypto.h +++ b/src/twcrypto/stdtwcrypto.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twcrypto/twcrypto.cpp b/src/twcrypto/twcrypto.cpp index ba4dba7..9182f22 100644 --- a/src/twcrypto/twcrypto.cpp +++ b/src/twcrypto/twcrypto.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -63,4 +63,4 @@ cTWCrypto::cTWCrypto() TSS_REGISTER_PKG_ERRORS( twcrypto ) } -// eof: twcrypto.cpp + diff --git a/src/twcrypto/twcrypto.h b/src/twcrypto/twcrypto.h index 27fe6e3..775393c 100644 --- a/src/twcrypto/twcrypto.h +++ b/src/twcrypto/twcrypto.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twcrypto/twcryptoerrors.cpp b/src/twcrypto/twcryptoerrors.cpp index 64cc046..9e7e8ae 100644 --- a/src/twcrypto/twcryptoerrors.cpp +++ b/src/twcrypto/twcryptoerrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twcrypto/twcryptoerrors.h b/src/twcrypto/twcryptoerrors.h index 149b9c3..7d1901f 100644 --- a/src/twcrypto/twcryptoerrors.h +++ b/src/twcrypto/twcryptoerrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/Makefile.am b/src/twparser/Makefile.am index bf75900..61fa23d 100644 --- a/src/twparser/Makefile.am +++ b/src/twparser/Makefile.am @@ -15,6 +15,7 @@ libtwparser_a_HEADERS = \ yylex.h yyparse.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit +CLEANFILES = *.gcno *.gcda all: $(noinst_LIBRARIES) $(AR) ru ../../lib/libtripwire.a $(libtwparser_a_OBJECTS) diff --git a/src/twparser/Makefile.in b/src/twparser/Makefile.in index fd23dd2..102f0d9 100644 --- a/src/twparser/Makefile.in +++ b/src/twparser/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -302,7 +302,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -329,6 +328,7 @@ libtwparser_a_HEADERS = \ stdtwparser.h twparser.h twparsererrors.h twparserstrings.h \ yylex.h yyparse.h +CLEANFILES = *.gcno *.gcda all: all-am .SUFFIXES: @@ -515,6 +515,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) diff --git a/src/twparser/genreparseinfo.cpp b/src/twparser/genreparseinfo.cpp index ad64f43..98e5c43 100644 --- a/src/twparser/genreparseinfo.cpp +++ b/src/twparser/genreparseinfo.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -75,6 +75,16 @@ cGenreParseInfo::cGenreParseInfo() InitPredefinedVariables(); } +cGenreParseInfo::~cGenreParseInfo() +{ + RuleListType::iterator itr; + for( itr = mRuleList.begin(); itr != mRuleList.end(); ++itr ) + { + delete *itr; + } + +} + /////////////////////////////////////////////////////////////////////////////// // AddStopPoint @@ -141,6 +151,8 @@ void cGenreParseInfo::InitPredefinedVariables() { mLocalPredefVarTable.Insert( sVarName, sValue ); } + + delete pGU; } diff --git a/src/twparser/genreparseinfo.h b/src/twparser/genreparseinfo.h index d47a0dc..d3895f8 100644 --- a/src/twparser/genreparseinfo.h +++ b/src/twparser/genreparseinfo.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -80,6 +80,7 @@ class cGenreParseInfo { public: cGenreParseInfo(); + ~cGenreParseInfo(); void AddStopPoint( const cFCOName& name ); // adds the specified path as a stop point -- for now, we just queue it up, diff --git a/src/twparser/parserhelper.cpp b/src/twparser/parserhelper.cpp index 3415907..90df7aa 100644 --- a/src/twparser/parserhelper.cpp +++ b/src/twparser/parserhelper.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -64,7 +64,7 @@ static bool util_IsOctal( const char ch ); static int util_GetEscapeValueOfChar( char ch ); static int util_GetRecurseDepth( const cParseNamedAttrList* pList ); //throw( eParserHelper ) static void util_LoseSurroundingWS( TSTRING& str ); -#ifdef _DEBUG +#ifdef DEBUG static bool util_AsciiCharsActLikeTheyShould(); #endif @@ -226,7 +226,7 @@ void cPreprocessor::PopState() ASSERT( ! mStateStack.empty() ); mStateStack.pop(); -#ifdef _DEBUG +#ifdef DEBUG if( !Empty() && TopState() == STATE_ACCEPT ) d.TraceDebug(_T("State == STATE_ACCEPT\n")); else @@ -502,7 +502,7 @@ void cParserUtil::InterpretEscapedString( const std::string& strEscapedString, T } } -#ifdef _DEBUG +#ifdef DEBUG std::string str; str = "before: <"; @@ -1085,7 +1085,7 @@ void util_LoseSurroundingWS( TSTRING& str ) } -#ifdef _DEBUG +#ifdef DEBUG bool util_AsciiCharsActLikeTheyShould() { // we need numbers whose character diff --git a/src/twparser/parserhelper.h b/src/twparser/parserhelper.h index 3392414..1d387f9 100644 --- a/src/twparser/parserhelper.h +++ b/src/twparser/parserhelper.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/parserobjects.cpp b/src/twparser/parserobjects.cpp index e29b086..3cdc90d 100644 --- a/src/twparser/parserobjects.cpp +++ b/src/twparser/parserobjects.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/parserobjects.h b/src/twparser/parserobjects.h index 4b52409..577d5f2 100644 --- a/src/twparser/parserobjects.h +++ b/src/twparser/parserobjects.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/policyparser.cpp b/src/twparser/policyparser.cpp index bdedd97..3a822f7 100644 --- a/src/twparser/policyparser.cpp +++ b/src/twparser/policyparser.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -170,7 +170,7 @@ std::string cPolicyParser::ConvertMultibyte( std::istream& in ) throw eParserBadCharacter(); } -#ifdef _DEBUG +#ifdef DEBUG TCERR << _T("*** begin policy text ***") << std::endl; std::cerr << ss.str() << std::endl; TCERR << _T("*** end policy text ***") << std::endl << std::endl; @@ -179,7 +179,7 @@ std::string cPolicyParser::ConvertMultibyte( std::istream& in ) // convert it to single byte escaped std::string str = util_ConvertMB( ss.str() ); -#ifdef _DEBUG +#ifdef DEBUG TCERR << _T("*** begin policy converted to ***") << std::endl; std::cerr << str << std::endl; TCERR << _T("*** end policy converted to ***") << std::endl << std::endl; diff --git a/src/twparser/policyparser.h b/src/twparser/policyparser.h index 85139d1..0a55cdf 100644 --- a/src/twparser/policyparser.h +++ b/src/twparser/policyparser.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/stdtwparser.cpp b/src/twparser/stdtwparser.cpp index bb8b146..b0c974c 100644 --- a/src/twparser/stdtwparser.cpp +++ b/src/twparser/stdtwparser.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,4 +37,4 @@ #include "stdtwparser.h" -// eof: stdtwparser.cpp + diff --git a/src/twparser/stdtwparser.h b/src/twparser/stdtwparser.h index 43d8038..7f32269 100644 --- a/src/twparser/stdtwparser.h +++ b/src/twparser/stdtwparser.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/twparser.cpp b/src/twparser/twparser.cpp index bb73220..ee576bc 100644 --- a/src/twparser/twparser.cpp +++ b/src/twparser/twparser.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/twparser.h b/src/twparser/twparser.h index 3689471..0241796 100644 --- a/src/twparser/twparser.h +++ b/src/twparser/twparser.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/twparsererrors.cpp b/src/twparser/twparsererrors.cpp index d3abacc..f53a77b 100644 --- a/src/twparser/twparsererrors.cpp +++ b/src/twparser/twparsererrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/twparsererrors.h b/src/twparser/twparsererrors.h index 04d2772..484d42d 100644 --- a/src/twparser/twparsererrors.h +++ b/src/twparser/twparsererrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/twparserstrings.cpp b/src/twparser/twparserstrings.cpp index 94e9bee..95225f1 100644 --- a/src/twparser/twparserstrings.cpp +++ b/src/twparser/twparserstrings.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/twparserstrings.h b/src/twparser/twparserstrings.h index 57b02f2..372bbd9 100644 --- a/src/twparser/twparserstrings.h +++ b/src/twparser/twparserstrings.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twparser/yylex.cpp b/src/twparser/yylex.cpp index ed66a60..b77935b 100644 --- a/src/twparser/yylex.cpp +++ b/src/twparser/yylex.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -478,7 +478,7 @@ static int yy_base[] = { }; -#line 152 "..\\..\\mkslexyacc\\etc\\yylex.cpp" +// #line 152 "..\\..\\mkslexyacc\\etc\\yylex.cpp" // MKS LEX prototype scanner code // Copyright 1991 by Mortice Kern Systems Inc. @@ -505,7 +505,7 @@ const int MIN_NUM_STATES = 20; #define REJECT goto yy_reject #define yymore() goto yy_more -#line 10 "tokens.l" +// #line 10 "tokens.l" #include "stdtwparser.h" @@ -515,7 +515,7 @@ const int MIN_NUM_STATES = 20; //#endif #include -#ifdef HAVE_MALLOC_H +#if HAVE_MALLOC_H && !IS_AROS #include #endif #include @@ -563,7 +563,7 @@ std::string FormatSyntaxError( char ch, const char* pszAdditionalMsg = NULL ) // saves typing #define TRACE_RETURN(x) lextrace(_T(#x)); return x -#line 178 "..\\..\\mkslexyacc\\etc\\yylex.cpp" +// #line 178 "..\\..\\mkslexyacc\\etc\\yylex.cpp" // Constructor for yy_scan. Set up tables @@ -614,10 +614,10 @@ yy_scan::~yy_scan() { if (mustfree) { mustfree = 0; - delete(yytext); - delete(state); + delete [] yytext; + delete [] state; #ifdef YY_PRESERVE - delete(save); + delete [] save; #endif } } @@ -762,7 +762,7 @@ yy_scan::yylex() int yyoldi, yyoleng; /* base i, yyleng before look-ahead */ int yyeof; /* 1 if eof has already been read */ -#line 375 "..\\..\\mkslexyacc\\etc\\yylex.cpp" +// #line 375 "..\\..\\mkslexyacc\\etc\\yylex.cpp" #ifdef YYEXIT @@ -876,43 +876,43 @@ yy_scan::yylex() YY_USER(); switch (yy_la_act[yyfmin] & 0777) { case 0: -#line 109 "tokens.l" +// #line 109 "tokens.l" { BEGIN( globals ); } break; case 1: -#line 114 "tokens.l" +// #line 114 "tokens.l" { BEGIN(INITIAL); return TWP_SECTION; } break; case 2: -#line 119 "tokens.l" +// #line 119 "tokens.l" { TRACE_RETURN(TWP_ECHO); } break; case 3: -#line 122 "tokens.l" +// #line 122 "tokens.l" { lextrace(_T("eating spaces...")); /* eat spaces */ } break; case 4: -#line 125 "tokens.l" +// #line 125 "tokens.l" { cParserHelper::IncrementLineNumber(); lextrace(_T("eating line continuation...")); /* eat line continuations */ } break; case 5: -#line 129 "tokens.l" +// #line 129 "tokens.l" { lextrace(_T("eating comment...")); } break; case 6: -#line 138 "tokens.l" +// #line 138 "tokens.l" { // we must make copy of string, otherwise another lexeme will clobber it cDebug d("\t\t\t\tlexer::string"); @@ -931,7 +931,7 @@ yy_scan::yylex() } break; case 7: -#line 155 "tokens.l" +// #line 155 "tokens.l" { // we must make copy of string, otherwise another lexeme will clobber it cDebug d("\t\t\t\tlexer::qstring"); @@ -960,19 +960,19 @@ yy_scan::yylex() } break; case 8: -#line 182 "tokens.l" +// #line 182 "tokens.l" { TRACE_RETURN(TWP_SEMICOLON); } break; case 9: -#line 183 "tokens.l" +// #line 183 "tokens.l" { TRACE_RETURN(TWP_EQUALS); } break; case 10: -#line 185 "tokens.l" +// #line 185 "tokens.l" { cParserHelper::IncrementLineNumber(); } break; case 11: -#line 186 "tokens.l" +// #line 186 "tokens.l" { std::string strError; strError = FormatSyntaxError( yytext[0], "The global section only accepts statements of the form:\n variable = value;\n" ); @@ -981,102 +981,102 @@ yy_scan::yylex() } /* catches anything that cannot be deemed a variable definition and exits. */ break; case 12: -#line 196 "tokens.l" +// #line 196 "tokens.l" { lextrace(_T("eating spaces...")); /* eat spaces */ } break; case 13: -#line 200 "tokens.l" +// #line 200 "tokens.l" { cParserHelper::IncrementLineNumber(); lextrace(_T("eating line continuation...")); /* eat line continuations */ } break; case 14: -#line 205 "tokens.l" +// #line 205 "tokens.l" { lextrace(_T("eating comment...")); } break; case 15: -#line 209 "tokens.l" +// #line 209 "tokens.l" { TRACE_RETURN(TWP_LBRACE); } break; case 16: -#line 210 "tokens.l" +// #line 210 "tokens.l" { TRACE_RETURN(TWP_RBRACE); } break; case 17: -#line 213 "tokens.l" +// #line 213 "tokens.l" { TRACE_RETURN(TWP_BANG); } break; case 18: -#line 215 "tokens.l" +// #line 215 "tokens.l" { TRACE_RETURN(TWP_RARROW); } break; case 19: -#line 216 "tokens.l" +// #line 216 "tokens.l" { TRACE_RETURN(TWP_EQUALS); } break; case 20: -#line 218 "tokens.l" +// #line 218 "tokens.l" { TRACE_RETURN(TWP_SEMICOLON); } break; case 21: -#line 219 "tokens.l" +// #line 219 "tokens.l" { TRACE_RETURN(TWP_LPAREN); } break; case 22: -#line 220 "tokens.l" +// #line 220 "tokens.l" { TRACE_RETURN(TWP_RPAREN); } break; case 23: -#line 221 "tokens.l" +// #line 221 "tokens.l" { TRACE_RETURN(TWP_COMMA); } break; case 24: -#line 222 "tokens.l" +// #line 222 "tokens.l" { TRACE_RETURN(TWP_PIPE); } break; case 25: -#line 226 "tokens.l" +// #line 226 "tokens.l" { TRACE_RETURN(TWP_DOLLAR); } break; case 26: -#line 227 "tokens.l" +// #line 227 "tokens.l" { TRACE_RETURN(TWP_OROR); } break; case 27: -#line 230 "tokens.l" +// #line 230 "tokens.l" { TRACE_RETURN(TWP_SECTION); } break; case 28: -#line 231 "tokens.l" +// #line 231 "tokens.l" { TRACE_RETURN(TWP_IFHOST); } break; case 29: -#line 232 "tokens.l" +// #line 232 "tokens.l" { TRACE_RETURN(TWP_ELSE); } break; case 30: -#line 233 "tokens.l" +// #line 233 "tokens.l" { TRACE_RETURN(TWP_ENDIF); } break; case 31: -#line 234 "tokens.l" +// #line 234 "tokens.l" { TRACE_RETURN(TWP_ERROR); } break; case 32: -#line 235 "tokens.l" +// #line 235 "tokens.l" { TRACE_RETURN(TWP_ECHO); } break; case 33: -#line 236 "tokens.l" +// #line 236 "tokens.l" { lextrace( _T( "@@end" ) ); return 0; } /* logical end of file */ break; case 34: -#line 239 "tokens.l" +// #line 239 "tokens.l" { // we must make copy of string, otherwise another lexeme will clobber it cDebug d("\t\t\t\tlexer::string"); @@ -1095,7 +1095,7 @@ yy_scan::yylex() } break; case 35: -#line 256 "tokens.l" +// #line 256 "tokens.l" { // we must make copy of string, otherwise another lexeme will clobber it cDebug d("\t\t\t\tlexer::qstring"); @@ -1121,12 +1121,12 @@ yy_scan::yylex() *mpstring = strW; -#ifdef _DEBUG +#ifdef DEBUG TSTRING strDisplay = *mpstring; cDisplayEncoder e; e.Encode( strDisplay ); d.TraceDetail("interpreted as --> <%s>\n", strDisplay.c_str()); -#endif // _DEBUG +#endif // DEBUG // attach to lval yylval.mpString = mpstring; @@ -1134,11 +1134,11 @@ yy_scan::yylex() } break; case 36: -#line 309 "tokens.l" +// #line 309 "tokens.l" { cParserHelper::IncrementLineNumber(); } break; case 37: -#line 310 "tokens.l" +// #line 310 "tokens.l" { std::string strError; strError = FormatSyntaxError( yytext[0] ); @@ -1147,7 +1147,7 @@ yy_scan::yylex() } /* catches anything else that's not in here and quits */ break; -#line 487 "..\\..\\mkslexyacc\\etc\\yylex.cpp" +// #line 487 "..\\..\\mkslexyacc\\etc\\yylex.cpp" } YY_SCANNER(); @@ -1231,7 +1231,7 @@ yy_scan::unput(int c) return c; } -#line 321 "tokens.l" +// #line 321 "tokens.l" diff --git a/src/twparser/yylex.h b/src/twparser/yylex.h index fa5e866..10a3b3f 100644 --- a/src/twparser/yylex.h +++ b/src/twparser/yylex.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -38,7 +38,7 @@ #endif #define YYNEWLINE 10 -#line 1 "..\\..\\mkslexyacc\\etc\\yylex.cpp" +//#line 1 "..\\..\\mkslexyacc\\etc\\yylex.cpp" // MKS LEX prototype scanner header // Copyright 1991 by Mortice Kern Systems Inc. // All rights reserved. diff --git a/src/twparser/yyparse.cpp b/src/twparser/yyparse.cpp index 9deb903..715d27a 100644 --- a/src/twparser/yyparse.cpp +++ b/src/twparser/yyparse.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -30,7 +30,7 @@ // info@tripwire.org or www.tripwire.org. // /* ..\. -LC -o ..\twparser\yyparse.cpp -P ..\..\mkslexyacc\etc\yyparse.cpp -D yyparse.h policy.y */ -#line 74 "policy.y" +// #line 74 "policy.y" #include "stdtwparser.h" @@ -349,7 +349,7 @@ int yy_parse::yynrule = 55; -#line 2 "..\\..\\mkslexyacc\\etc\\yyparse.cpp" +// #line 2 "..\\..\\mkslexyacc\\etc\\yyparse.cpp" // C++ YACC parser code // Copyright 1991 by Mortice Kern Systems Inc. All rights reserved. // @@ -419,16 +419,16 @@ yy_parse::yy_parse(int sz) yy_parse::~yy_parse() { if (mustfree) { - delete stateStack; - delete valueStack; + delete [] stateStack; + delete [] valueStack; } stateStack = (short *) 0; #if YYDEBUG - delete typeStack; + delete [] typeStack; #endif } -#ifdef YACC_WINDOWS +#if 0 //YACC_WINDOWS // The initial portion of the yacc parser. // In an windows environment, it will load the desired @@ -533,7 +533,7 @@ yy_parse::yyparse(yy_scan* ps) #endif /* YACC_WINDOWS */ { -#ifdef YACC_WINDOWS +#if 0 //YACC_WINDOWS short far *yyp; // needed as res tables locked in far memory short far *yyq; #else @@ -594,7 +594,7 @@ yyEncore: #endif } #endif -#ifdef YACC_WINDOWS +#if 0 //YACC_WINDOWS if (yystate >= Sizeof_yypact) /* simple state */ #else /* YACC_WINDOWS */ if (yystate >= (int)sizeof yypact/(int)sizeof yypact[0]) /* simple state */ @@ -640,7 +640,7 @@ yyEncore: * Fell through - take default action */ -#ifdef YACC_WINDOWS +#if 0 //YACC_WINDOWS if (yystate >= Sizeof_yydef) /* simple state */ #else /* YACC_WINDOWS */ if (yystate >= (int)sizeof yydef /(int)sizeof yydef[0]) @@ -689,22 +689,22 @@ yyEncore: switch (yyi) { /* perform semantic action */ case YYr6: { /* statement : variable_assignment TWP_SEMICOLON */ -#line 194 "policy.y" +// #line 194 "policy.y" cParserHelper::IncrementScopeStatementCount(); } break; case YYr7: { /* statement : global_variable_assignment TWP_SEMICOLON */ -#line 195 "policy.y" +// #line 195 "policy.y" cParserHelper::IncrementScopeStatementCount(); } break; case YYr8: { /* statement : rule TWP_SEMICOLON */ -#line 196 "policy.y" +// #line 196 "policy.y" cParserHelper::IncrementScopeStatementCount(); } break; case YYr12: { /* scoped_block : TWP_LPAREN attribute_list_with_opt_trailing_comma TWP_RPAREN TWP_LBRACE */ -#line 204 "policy.y" +// #line 204 "policy.y" cDebug d("Parse::scope"); @@ -721,7 +721,7 @@ case YYr12: { /* scoped_block : TWP_LPAREN attribute_list_with_opt_trailing_c } break; case YYr13: { /* scoped_block : TWP_LPAREN attribute_list_with_opt_trailing_comma TWP_RPAREN TWP_LBRACE $12 opt_statement_list TWP_RBRACE */ -#line 218 "policy.y" +// #line 218 "policy.y" if( 0 == cParserHelper::GetScopeStatementCount() && iUserNotify::GetInstance()->GetVerboseLevel() == iUserNotify::V_VERBOSE ) { @@ -737,7 +737,7 @@ case YYr13: { /* scoped_block : TWP_LPAREN attribute_list_with_opt_trailing_c } break; case YYr14: { /* directive_block : TWP_IFHOST host_name_list */ -#line 234 "policy.y" +// #line 234 "policy.y" cDebug d("Parse::#ifhost"); @@ -763,7 +763,7 @@ case YYr14: { /* directive_block : TWP_IFHOST host_name_list */ } break; case YYr15: { /* directive_block : TWP_IFHOST host_name_list $14 opt_statement_list opt_else_host TWP_ENDIF */ -#line 257 "policy.y" +// #line 257 "policy.y" cDebug d("Parse::#endif"); cPreprocessor::PopState(); @@ -773,7 +773,7 @@ case YYr15: { /* directive_block : TWP_IFHOST host_name_list $14 opt_statemen } break; case YYr16: { /* directive_block : TWP_SECTION string */ -#line 264 "policy.y" +// #line 264 "policy.y" cDebug d("Parse::#section"); @@ -787,7 +787,7 @@ case YYr16: { /* directive_block : TWP_SECTION string */ } break; case YYr17: { /* directive_block : TWP_ERROR string */ -#line 275 "policy.y" +// #line 275 "policy.y" if( cPreprocessor::GetState() == cPreprocessor::STATE_ACCEPT && !cParserHelper::ParseOnly() ) { @@ -801,7 +801,7 @@ case YYr17: { /* directive_block : TWP_ERROR string */ } break; case YYr18: { /* directive_block : TWP_ECHO string */ -#line 286 "policy.y" +// #line 286 "policy.y" if( cPreprocessor::GetState() == cPreprocessor::STATE_ACCEPT && !cParserHelper::ParseOnly() ) { @@ -814,7 +814,7 @@ case YYr18: { /* directive_block : TWP_ECHO string */ } break; case YYr19: { /* host_name_list : host_name_list TWP_OROR host_name */ -#line 299 "policy.y" +// #line 299 "policy.y" yyval.mpStringList = yypvt[-2].mpStringList; yyval.mpStringList->push_back( *yypvt[0].mpString ); @@ -822,7 +822,7 @@ case YYr19: { /* host_name_list : host_name_list TWP_OROR host_name */ } break; case YYr20: { /* host_name_list : host_name */ -#line 304 "policy.y" +// #line 304 "policy.y" yyval.mpStringList = new cParseStringList; yyval.mpStringList->push_back( *yypvt[0].mpString ); @@ -830,7 +830,7 @@ case YYr20: { /* host_name_list : host_name */ } break; case YYr21: { /* opt_else_host : TWP_ELSE */ -#line 312 "policy.y" +// #line 312 "policy.y" cDebug d("Parse::#else"); @@ -848,7 +848,7 @@ case YYr21: { /* opt_else_host : TWP_ELSE */ } break; case YYr24: { /* variable_assignment : variable_name TWP_EQUALS multi_string */ -#line 332 "policy.y" +// #line 332 "policy.y" cDebug d("Parse::variable_assignment"); @@ -869,7 +869,7 @@ case YYr24: { /* variable_assignment : variable_name TWP_EQUALS multi_string } break; case YYr25: { /* global_variable_assignment : global_string TWP_EQUALS global_multi_string */ -#line 353 "policy.y" +// #line 353 "policy.y" cDebug d("Parse::global variable_assignment"); @@ -890,7 +890,7 @@ case YYr25: { /* global_variable_assignment : global_string TWP_EQUALS global } break; case YYr26: { /* rule : fco_name TWP_RARROW spec_masks */ -#line 374 "policy.y" +// #line 374 "policy.y" cDebug d("Parse::rule(fco_name TWP_RARROW spec_masks)"); if( cPreprocessor::GetState() == cPreprocessor::STATE_IGNORE ) @@ -927,6 +927,7 @@ case YYr26: { /* rule : fco_name TWP_RARROW spec_masks */ // add to our lists cParserHelper::GetGenreInfo()->AddStopPoint( fcoName ); cParserHelper::GetGenreInfo()->AddRule( pnode ); + delete pGU; } delete yypvt[-2].mpStringList; @@ -935,7 +936,7 @@ case YYr26: { /* rule : fco_name TWP_RARROW spec_masks */ } break; case YYr27: { /* rule : TWP_BANG fco_name */ -#line 416 "policy.y" +// #line 416 "policy.y" cDebug d("Parse::rule(!fconame)"); @@ -959,6 +960,7 @@ case YYr27: { /* rule : TWP_BANG fco_name */ // add to stop list cParserHelper::GetGenreInfo()->AddStopPoint( fcoName ); + delete pGU; } delete yypvt[0].mpStringList; @@ -966,7 +968,7 @@ case YYr27: { /* rule : TWP_BANG fco_name */ } break; case YYr28: { /* spec_masks : prop_vector opt_spec_attributes */ -#line 447 "policy.y" +// #line 447 "policy.y" if( cPreprocessor::GetState() == cPreprocessor::STATE_ACCEPT ) { @@ -978,6 +980,7 @@ case YYr28: { /* spec_masks : prop_vector opt_spec_attributes */ yypvt[0].mpAttrList->MergeNoOverwrite( cParserHelper::GetGlobalAttrList() ); yyval.mpNode = pNode; + delete pGU; } delete yypvt[-1].mpString; @@ -987,28 +990,28 @@ case YYr28: { /* spec_masks : prop_vector opt_spec_attributes */ } break; case YYr29: { /* opt_spec_attributes : TWP_LPAREN attribute_list_with_opt_trailing_comma TWP_RPAREN */ -#line 485 "policy.y" +// #line 485 "policy.y" yyval.mpAttrList = yypvt[-1].mpAttrList; } break; case YYr30: { /* opt_spec_attributes : */ -#line 489 "policy.y" +// #line 489 "policy.y" yyval.mpAttrList = new cParseNamedAttrList; } break; case YYr31: { /* attribute_list_with_opt_trailing_comma : attribute_list opt_comma */ -#line 515 "policy.y" +// #line 515 "policy.y" yyval.mpAttrList = yypvt[-1].mpAttrList; } break; case YYr32: { /* attribute_list : attribute_list TWP_COMMA attribute */ -#line 522 "policy.y" +// #line 522 "policy.y" cDebug d("Parse::attribute_list"); ASSERT( yypvt[-2].mpAttrList && yypvt[0].mpAttr ); @@ -1024,7 +1027,7 @@ case YYr32: { /* attribute_list : attribute_list TWP_COMMA attribute */ } break; case YYr33: { /* attribute_list : attribute */ -#line 535 "policy.y" +// #line 535 "policy.y" cDebug d("Parse::attribute_list"); @@ -1038,7 +1041,7 @@ case YYr33: { /* attribute_list : attribute */ } break; case YYr34: { /* attribute : attribute_name TWP_EQUALS attribute_value */ -#line 548 "policy.y" +// #line 548 "policy.y" cDebug d("Parse::attribute"); @@ -1055,7 +1058,7 @@ case YYr34: { /* attribute : attribute_name TWP_EQUALS attribute_value */ } break; case YYr37: { /* variable : TWP_DOLLAR TWP_LPAREN variable_name TWP_RPAREN */ -#line 618 "policy.y" +// #line 618 "policy.y" cDebug d( " parser::variable" ); @@ -1082,7 +1085,7 @@ case YYr37: { /* variable : TWP_DOLLAR TWP_LPAREN variable_name TWP_RPAREN */ } break; case YYr38: { /* prop_vector : multi_string */ -#line 662 "policy.y" +// #line 662 "policy.y" yyval.mpString = new cParseString; *yyval.mpString = ConcatenateStrings( yypvt[0].mpStringList ); @@ -1091,7 +1094,7 @@ case YYr38: { /* prop_vector : multi_string */ } break; case YYr39: { /* attribute_name : string */ -#line 671 "policy.y" +// #line 671 "policy.y" cDebug d(" parser::string(attribute_name)"); yyval.mpString = yypvt[0].mpString; @@ -1099,7 +1102,7 @@ case YYr39: { /* attribute_name : string */ } break; case YYr40: { /* attribute_value : multi_string */ -#line 679 "policy.y" +// #line 679 "policy.y" yyval.mpString = new cParseString; cDebug d(" parser::multi_string(attribute_value)"); @@ -1109,7 +1112,7 @@ case YYr40: { /* attribute_value : multi_string */ } break; case YYr41: { /* fco_name : multi_string */ -#line 689 "policy.y" +// #line 689 "policy.y" cDebug d(" parser::multi_string(fco_name)"); yyval.mpStringList = yypvt[0].mpStringList; @@ -1117,7 +1120,7 @@ case YYr41: { /* fco_name : multi_string */ } break; case YYr42: { /* fco_name : multi_string TWP_PIPE multi_string */ -#line 695 "policy.y" +// #line 695 "policy.y" yypvt[-2].mpStringList->push_back( _T("|") ); @@ -1129,7 +1132,7 @@ case YYr42: { /* fco_name : multi_string TWP_PIPE multi_string */ } break; case YYr43: { /* host_name : string */ -#line 710 "policy.y" +// #line 710 "policy.y" cDebug d(" parser::multi_string(host_name)"); @@ -1138,7 +1141,7 @@ case YYr43: { /* host_name : string */ } break; case YYr44: { /* variable_name : TWP_STRING */ -#line 719 "policy.y" +// #line 719 "policy.y" cDebug d(" parser::string(variable_name)"); yyval.mpString = yypvt[0].mpString; @@ -1146,7 +1149,7 @@ case YYr44: { /* variable_name : TWP_STRING */ } break; case YYr45: { /* multi_string : multi_string string */ -#line 728 "policy.y" +// #line 728 "policy.y" yyval.mpStringList->push_back( *yypvt[0].mpString ); delete yypvt[0].mpString; @@ -1154,7 +1157,7 @@ case YYr45: { /* multi_string : multi_string string */ } break; case YYr46: { /* multi_string : string */ -#line 733 "policy.y" +// #line 733 "policy.y" yyval.mpStringList = new cParseStringList; yyval.mpStringList->push_back( *yypvt[0].mpString ); @@ -1163,7 +1166,7 @@ case YYr46: { /* multi_string : string */ } break; case YYr47: { /* global_multi_string : global_multi_string global_string */ -#line 742 "policy.y" +// #line 742 "policy.y" yyval.mpStringList->push_back( *yypvt[0].mpString ); delete yypvt[0].mpString; @@ -1171,7 +1174,7 @@ case YYr47: { /* global_multi_string : global_multi_string global_string */ } break; case YYr48: { /* global_multi_string : global_string */ -#line 747 "policy.y" +// #line 747 "policy.y" yyval.mpStringList = new cParseStringList; yyval.mpStringList->push_back( *yypvt[0].mpString ); @@ -1180,7 +1183,7 @@ case YYr48: { /* global_multi_string : global_string */ } break; case YYr49: { /* string : TWP_STRING */ -#line 757 "policy.y" +// #line 757 "policy.y" cDebug d(" parser::string(normal)"); d.TraceNever("--(STRING)--> got string (%s)\n", yypvt[0].mpString); @@ -1189,7 +1192,7 @@ case YYr49: { /* string : TWP_STRING */ } break; case YYr50: { /* string : variable */ -#line 763 "policy.y" +// #line 763 "policy.y" cDebug d(" parser::string(normal)"); d.TraceNever("--(STRING)--> got string (%s)\n", yypvt[0].mpString); @@ -1198,14 +1201,14 @@ case YYr50: { /* string : variable */ } break; case YYr51: { /* global_string : TWP_GLOBAL_STRING */ -#line 772 "policy.y" +// #line 772 "policy.y" cDebug d(" parser::string(normal)"); d.TraceNever("--(STRING)--> got string (%s)\n", yypvt[0].mpString); yyval.mpString = yypvt[0].mpString; } break; -#line 343 "..\\..\\mkslexyacc\\etc\\yyparse.cpp" +// #line 343 "..\\..\\mkslexyacc\\etc\\yyparse.cpp" case YYrACCEPT: YYACCEPT; case YYrERROR: @@ -1265,7 +1268,7 @@ yyError: , yytp-- #endif ) { -#ifdef YACC_WINDOWS +#if 0 //YACC_WINDOWS if (*yyps >= Sizeof_yypact) /* simple state */ #else /* YACC_WINDOWS */ if (*yyps >= (int)sizeof yypact/(int)sizeof yypact[0]) diff --git a/src/twparser/yyparse.h b/src/twparser/yyparse.h index 6a09190..38e588a 100644 --- a/src/twparser/yyparse.h +++ b/src/twparser/yyparse.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -133,7 +133,7 @@ typedef struct yyTypedRules_tag { /* Typed rule table */ } yyTypedRules; #endif -#ifdef YACC_WINDOWS +#if 0 // YACC_WINDOWS // include all windows prototypes, macros, constants, etc. @@ -155,7 +155,7 @@ extern HANDLE hInst; class yy_parse { protected: -#ifdef YACC_WINDOWS +#if 0 // YACC_WINDOWS // protected member function for actual scanning diff --git a/src/twprint/Makefile.am b/src/twprint/Makefile.am index 7973565..6b09237 100644 --- a/src/twprint/Makefile.am +++ b/src/twprint/Makefile.am @@ -17,7 +17,7 @@ twprint_HEADERS = \ twprinterrors.h twprintstrings.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit -CLEANFILES = ../../bin/twprint +CLEANFILES = ../../bin/twprint *.gcno *.gcda all: $(sbin_PROGRAMS) @test -d ../../bin && $(LN) -f $(sbin_PROGRAMS) ../../bin diff --git a/src/twprint/Makefile.in b/src/twprint/Makefile.in index 5a5ae62..afaa7af 100644 --- a/src/twprint/Makefile.in +++ b/src/twprint/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -295,7 +295,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -320,7 +319,7 @@ twprint_HEADERS = \ resource.h stdtwprint.h twprint.h twprintcmdline.h \ twprinterrors.h twprintstrings.h -CLEANFILES = ../../bin/twprint +CLEANFILES = ../../bin/twprint *.gcno *.gcda all: all-am .SUFFIXES: diff --git a/src/twprint/resource.h b/src/twprint/resource.h index 8fc8ab8..d0a48bf 100644 --- a/src/twprint/resource.h +++ b/src/twprint/resource.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twprint/stdtwprint.cpp b/src/twprint/stdtwprint.cpp index 6894eb9..27cc01c 100644 --- a/src/twprint/stdtwprint.cpp +++ b/src/twprint/stdtwprint.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,4 +37,4 @@ #include "stdtwprint.h" -// eof: stdtwprint.cpp + diff --git a/src/twprint/stdtwprint.h b/src/twprint/stdtwprint.h index 141f9c1..7f33645 100644 --- a/src/twprint/stdtwprint.h +++ b/src/twprint/stdtwprint.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twprint/twprint.cpp b/src/twprint/twprint.cpp index 921a4dd..79681ca 100644 --- a/src/twprint/twprint.cpp +++ b/src/twprint/twprint.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -69,4 +69,4 @@ cTWPrint::cTWPrint() TSS_REGISTER_PKG_ERRORS ( twprint ); } -// eof: twprint.cpp + diff --git a/src/twprint/twprint.h b/src/twprint/twprint.h index 635eb91..d20e174 100644 --- a/src/twprint/twprint.h +++ b/src/twprint/twprint.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twprint/twprintcmdline.cpp b/src/twprint/twprintcmdline.cpp index f3a435e..d8b141e 100644 --- a/src/twprint/twprintcmdline.cpp +++ b/src/twprint/twprintcmdline.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -194,7 +194,7 @@ iTWMode* cTWPrintCmdLine::GetMode( int argc, const TCHAR* const * argv ) // unknown mode switch cDebug d("cTWPrintCmdLine::GetMode"); d.TraceError(_T("Error: Bad mode switch: %s\n"), pcMode); - TCERR << TSS_GetString(cTW, tw::STR_UNKOWN_MODE_SPECIFIED) << pcMode << std::endl; + TCERR << TSS_GetString(cTW, tw::STR_UNKNOWN_MODE_SPECIFIED) << pcMode << std::endl; TCERR << TSS_GetString(cTW, tw::STR_GET_HELP) << std::endl; return NULL; } diff --git a/src/twprint/twprintcmdline.h b/src/twprint/twprintcmdline.h index b75fe4b..ab4e2b7 100644 --- a/src/twprint/twprintcmdline.h +++ b/src/twprint/twprintcmdline.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twprint/twprinterrors.cpp b/src/twprint/twprinterrors.cpp index 21c0d11..5828a39 100644 --- a/src/twprint/twprinterrors.cpp +++ b/src/twprint/twprinterrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twprint/twprinterrors.h b/src/twprint/twprinterrors.h index c5b1350..87bcc31 100644 --- a/src/twprint/twprinterrors.h +++ b/src/twprint/twprinterrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twprint/twprintmain.cpp b/src/twprint/twprintmain.cpp index dc04b56..e7ffa4a 100644 --- a/src/twprint/twprintmain.cpp +++ b/src/twprint/twprintmain.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -42,7 +42,7 @@ #include "core/cmdlineparser.h" #include "core/errorbucketimpl.h" #include "core/usernotifystdout.h" -#include "core/timebomb.h" +#include "core/epoch.h" #include "core/debug.h" @@ -81,7 +81,7 @@ int __cdecl _tmain( int argc, const TCHAR* argv[ ] ) int ret = 0; - if (TimeBombExploded()) + if (CheckEpoch()) return 1; cTWInit twInit; diff --git a/src/twprint/twprintstrings.cpp b/src/twprint/twprintstrings.cpp index 1930851..e159edc 100644 --- a/src/twprint/twprintstrings.cpp +++ b/src/twprint/twprintstrings.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -67,7 +67,7 @@ TSS_BeginStringtable( cTWPrint ) _T(" -c cfgfile --cfgfile cfgfile\n") _T(" -d database --dbfile database\n") _T(" -L localkey --local-keyfile localkey\n") - _T("[object1 [object2 ...]\n") + _T("[object1 [object2 ...]]\n") _T("\n") _T("The -v and -s options are mutually exclusive.\n") _T("\n") diff --git a/src/twprint/twprintstrings.h b/src/twprint/twprintstrings.h index f233b02..a739762 100644 --- a/src/twprint/twprintstrings.h +++ b/src/twprint/twprintstrings.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twtest/Makefile.am b/src/twtest/Makefile.am index 4361ccb..cedcf10 100644 --- a/src/twtest/Makefile.am +++ b/src/twtest/Makefile.am @@ -19,7 +19,7 @@ cmdlineparser_t.cpp \ codeconvert_t.cpp \ configfile_t.cpp \ cryptoarchive_t.cpp \ -crytpo_t.cpp \ +crypto_t.cpp \ dbdatasource_t.cpp \ debug_t.cpp \ displayencoder_t.cpp \ @@ -81,7 +81,13 @@ wchar16_t.cpp twtest_HEADERS = stdtest.h stringutil_t.h test.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit -CLEANFILES = ../../bin/twtest + +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + -rm -rf ../../bin/TWTestData + -rm -f ../../bin/twtest + -rm -f *.gcno *.gcda all: $(sbin_PROGRAMS) @test -d ../../bin && $(LN) -f $(sbin_PROGRAMS) ../../bin diff --git a/src/twtest/Makefile.in b/src/twtest/Makefile.in index cea3ef0..409d2bd 100644 --- a/src/twtest/Makefile.in +++ b/src/twtest/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -109,7 +109,7 @@ am_twtest_OBJECTS = archive_t.$(OBJEXT) blockfile_t.$(OBJEXT) \ blockrecordarray_t.$(OBJEXT) charutil_t.$(OBJEXT) \ cmdlineparser_t.$(OBJEXT) codeconvert_t.$(OBJEXT) \ configfile_t.$(OBJEXT) cryptoarchive_t.$(OBJEXT) \ - crytpo_t.$(OBJEXT) dbdatasource_t.$(OBJEXT) debug_t.$(OBJEXT) \ + crypto_t.$(OBJEXT) dbdatasource_t.$(OBJEXT) debug_t.$(OBJEXT) \ displayencoder_t.$(OBJEXT) error_t.$(OBJEXT) \ errorbucketimpl_t.$(OBJEXT) fcocompare_t.$(OBJEXT) \ fcodatabasefile_t.$(OBJEXT) fconame_t.$(OBJEXT) \ @@ -335,7 +335,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -361,7 +360,7 @@ cmdlineparser_t.cpp \ codeconvert_t.cpp \ configfile_t.cpp \ cryptoarchive_t.cpp \ -crytpo_t.cpp \ +crypto_t.cpp \ dbdatasource_t.cpp \ debug_t.cpp \ displayencoder_t.cpp \ @@ -421,7 +420,6 @@ usernotifystdout_t.cpp \ wchar16_t.cpp twtest_HEADERS = stdtest.h stringutil_t.h test.h -CLEANFILES = ../../bin/twtest all: all-am .SUFFIXES: @@ -646,7 +644,6 @@ install-strip: mostlyclean-generic: clean-generic: - -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) @@ -657,7 +654,7 @@ maintainer-clean-generic: @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-generic clean-sbinPROGRAMS mostlyclean-am +clean-am: clean-generic clean-local clean-sbinPROGRAMS mostlyclean-am distclean: distclean-am -rm -f Makefile @@ -725,15 +722,15 @@ uninstall-am: uninstall-sbinPROGRAMS uninstall-twtestHEADERS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ - clean-sbinPROGRAMS cscopelist-am ctags ctags-am distclean \ - distclean-compile distclean-generic distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-sbinPROGRAMS \ - install-strip install-twtestHEADERS installcheck \ - installcheck-am installdirs maintainer-clean \ + clean-local clean-sbinPROGRAMS cscopelist-am ctags ctags-am \ + distclean distclean-compile distclean-generic distclean-tags \ + distdir dvi dvi-am html html-am info info-am install \ + install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-sbinPROGRAMS install-strip install-twtestHEADERS \ + installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am uninstall-sbinPROGRAMS uninstall-twtestHEADERS @@ -741,6 +738,13 @@ uninstall-am: uninstall-sbinPROGRAMS uninstall-twtestHEADERS .PRECIOUS: Makefile +clean-local: clean-local-check +.PHONY: clean-local-check +clean-local-check: + -rm -rf ../../bin/TWTestData + -rm -f ../../bin/twtest + -rm -f *.gcno *.gcda + all: $(sbin_PROGRAMS) @test -d ../../bin && $(LN) -f $(sbin_PROGRAMS) ../../bin diff --git a/src/twtest/archive_t.cpp b/src/twtest/archive_t.cpp index 629c0e4..260ec4b 100644 --- a/src/twtest/archive_t.cpp +++ b/src/twtest/archive_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -38,11 +38,12 @@ #include "core/archive.h" #include "twtest/test.h" #include "core/error.h" +#include "tw/twutil.h" #include TSS_EXCEPTION(eTestArchiveError, eError); -void TestArchive() +void TestMemoryArchive() { // cMemoryArchive cMemoryArchive memarch; @@ -52,7 +53,7 @@ void TestArchive() memarch.WriteInt32(3); memarch.WriteInt32(4); - TSTRING s = _T("Weenus"); + TSTRING s = _T("Iridogorgia"); memarch.WriteString(s); memarch.WriteInt64(1234567L); @@ -74,7 +75,7 @@ void TestArchive() TSTRING s2; memarch.ReadString(s2); - TEST(s2.compare(_T("Weenus")) == 0); + TEST(s2.compare(_T("Iridogorgia")) == 0); memarch.ReadInt64(l); TEST(l == 1234567L); @@ -101,37 +102,73 @@ void TestArchive() TEST(memarch.GetMappedOffset() == 4 * sizeof(int32) + sizeof(int32) + 6); TEST(memarch.GetMappedLength() == sizeof(int64)); // TEST(tw_ntohll(*(int64*)memarch.GetMap()) == 1234567L); +} +void TestLockedTemporaryArchive() +{ + TSTRING s = _T("Metallogorgia"); + bool threw = false; // cLockedTemporaryFileArchive - TSTRING lockedFileName = TEMP_DIR; - lockedFileName += _T("/inaccessable_file.bin"); + TSTRING lockedFileName = TwTestPath("inaccessable_file.bin"); cLockedTemporaryFileArchive lockedArch; - // try to create an archive using a temp file - lockedArch.OpenReadWrite(); - lockedArch.Close(); + try + { + // try to create an archive using a temp file + lockedArch.OpenReadWrite(); + lockedArch.Close(); + } + catch (eError& e) + { + threw=true; + TCERR << "Error opening locked temp archive" << std::endl; + cTWUtil::PrintErrorMsg(e); + } + catch (...) + { + threw = true; + } - // this should open and lock the file -- shouldn't be able to access it - lockedArch.OpenReadWrite(lockedFileName.c_str()); - lockedArch.Seek(0, cBidirArchive::BEGINNING); + try + { + // this should open and lock the file -- shouldn't be able to access it + lockedArch.OpenReadWrite(lockedFileName.c_str()); + lockedArch.Seek(0, cBidirArchive::BEGINNING); - // shouldn't be able to see these changes - lockedArch.WriteInt32(1); - lockedArch.WriteInt32(2); - lockedArch.WriteInt32(3); - lockedArch.WriteInt32(4); - lockedArch.WriteString(s); - lockedArch.WriteInt64(1234567L); - lockedArch.WriteInt16(42); + // shouldn't be able to see these changes + lockedArch.WriteInt32(1); + lockedArch.WriteInt32(2); + lockedArch.WriteInt32(3); + lockedArch.WriteInt32(4); + lockedArch.WriteString(s); + lockedArch.WriteInt64(1234567L); + lockedArch.WriteInt16(42); - // this should delete the file - lockedArch.Close(); + // this should delete the file + lockedArch.Close(); + } + catch (eError& e) + { + threw=true; + TCERR << "Error writing locked temp archive" << std::endl; + cTWUtil::PrintErrorMsg(e); + } + catch (...) + { + threw = true; + } - // cFileArchive - TSTRING fileName = TEMP_DIR; - fileName += _T("/archive_test.bin"); + TEST(!threw); +} + +void TestFileArchive() +{ + bool threw = false; + TSTRING s = _T("Acanthogorgia"); + // cFileArchive + TSTRING fileName = TwTestPath("archive_test.bin"); cFileArchive filearch; filearch.OpenReadWrite(fileName.c_str()); @@ -163,7 +200,7 @@ void TestArchive() TSTRING s3; filearch.ReadString(s3); - TEST(s3.compare(_T("Weenus")) == 0); + TEST(s3.compare(_T("Acanthogorgia")) == 0); filearch.ReadInt64(k); TEST(k == 1234567L); @@ -181,8 +218,16 @@ void TestArchive() } catch (eError& e) { - TEST(false); + threw=true; (void)e; } + + TEST(!threw); } +void RegisterSuite_Archive() +{ + RegisterTest("Archive", "MemoryArchive", TestMemoryArchive); + RegisterTest("Archive", "LockedTemporaryArchive", TestLockedTemporaryArchive); + RegisterTest("Archive", "FileArchive", TestFileArchive); +} diff --git a/src/twtest/blockfile_t.cpp b/src/twtest/blockfile_t.cpp index 0581f42..9788af3 100644 --- a/src/twtest/blockfile_t.cpp +++ b/src/twtest/blockfile_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -41,80 +41,77 @@ void TestBlockFile() { cDebug d( "TestBlockFile" ); - try - { - static const TCHAR fileName[] = _T("test.bf"); - // truncate the file I am going to use... - // - cFileArchive a; - a.OpenReadWrite( fileName ); - a.Close(); - // - // open up the block file... - // - cBlockFile bf; - bf.Open( fileName, 2 ); // opened up with two pages - #ifdef _BLOCKFILE_DEBUG - bf.TraceContents(); - #endif + std::string fileName = TwTestPath("test.bf"); + // truncate the file I am going to use... + // + cFileArchive a; + a.OpenReadWrite( fileName.c_str() ); + a.Close(); + // + // open up the block file... + // + cBlockFile bf; + bf.Open( fileName, 2 ); // opened up with two pages + #ifdef _BLOCKFILE_DEBUG + bf.TraceContents(); + #endif - // get a block and write something to it... - // - cBlockFile::Block* pB = bf.GetBlock( 0 ); - TEST( pB ); - static const TCHAR str1[] = _T("Block 1"); - memcpy( pB->GetData(), str1, sizeof(str1) ); - pB->SetDirty(); - #ifdef _BLOCKFILE_DEBUG - bf.TraceContents(); - #endif + // get a block and write something to it... + // + cBlockFile::Block* pB = bf.GetBlock( 0 ); + TEST( pB ); + static const TCHAR str1[] = _T("Block 1"); + memcpy( pB->GetData(), str1, sizeof(str1) ); + pB->SetDirty(); + #ifdef _BLOCKFILE_DEBUG + bf.TraceContents(); + #endif - // get another block... - // - pB = bf.CreateBlock(); - TEST( pB ); - static const TCHAR str2[] = _T("Block 2"); - memcpy( pB->GetData(), str2, sizeof(str2) ); - pB->SetDirty(); - #ifdef _BLOCKFILE_DEBUG - bf.TraceContents(); - #endif + // get another block... + // + pB = bf.CreateBlock(); + TEST( pB ); + static const TCHAR str2[] = _T("Block 2"); + memcpy( pB->GetData(), str2, sizeof(str2) ); + pB->SetDirty(); + #ifdef _BLOCKFILE_DEBUG + bf.TraceContents(); + #endif - // get the first block we wrote... - // - pB = bf.GetBlock( 0 ); - TEST( pB ); - *pB->GetData() = _T('F'); - #ifdef _BLOCKFILE_DEBUG - bf.TraceContents(); - #endif + // get the first block we wrote... + // + pB = bf.GetBlock( 0 ); + TEST( pB ); + *pB->GetData() = _T('F'); + #ifdef _BLOCKFILE_DEBUG + bf.TraceContents(); + #endif - // - // create a third block -- someone will have to be paged out in order for this to happen - // - pB = bf.CreateBlock(); - TEST( pB ); - static const TCHAR str3[] = _T("Block 3"); - memcpy( pB->GetData(), str3, sizeof(str3) ); - pB->SetDirty(); - #ifdef _BLOCKFILE_DEBUG - bf.TraceContents(); - #endif - - // - // test the guard bytes... - /* - memcpy( pB->GetData() + (cBlockFile::BLOCK_SIZE - 4), str3, sizeof(str3) ); - memcpy( pB->GetData() - 1, str3, sizeof(str3) ); - pB->AssertValid(); - */ + // + // create a third block -- someone will have to be paged out in order for this to happen + // + pB = bf.CreateBlock(); + TEST( pB ); + static const TCHAR str3[] = _T("Block 3"); + memcpy( pB->GetData(), str3, sizeof(str3) ); + pB->SetDirty(); + #ifdef _BLOCKFILE_DEBUG + bf.TraceContents(); + #endif + + // + // test the guard bytes... + /* + memcpy( pB->GetData() + (cBlockFile::BLOCK_SIZE - 4), str3, sizeof(str3) ); + memcpy( pB->GetData() - 1, str3, sizeof(str3) ); + pB->AssertValid(); + */ - bf.Close(); - } - catch( eError& e ) - { - TCERR << "Exception: " << e.GetMsg() << std::endl; - d.TraceError( _T("Exception caught: %d %s\n"), e.GetID(), e.GetMsg().c_str() ); - TEST( false ); - } + bf.Close(); } + +void RegisterSuite_BlockFile() +{ + RegisterTest("BlockFile", "Basic", TestBlockFile); +} + diff --git a/src/twtest/blockrecordarray_t.cpp b/src/twtest/blockrecordarray_t.cpp index c160724..065bb95 100644 --- a/src/twtest/blockrecordarray_t.cpp +++ b/src/twtest/blockrecordarray_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,98 +37,115 @@ #include "core/debug.h" #include "core/error.h" +//TODO: This test needs more comprehensive validity checks void TestBlockRecordArray() { cDebug d( "TestBlockRecordArray" ); - try + + std::string fileName = TwTestPath("test2.bf"); + + cBlockFile bf; + bf.Open( fileName, 2, true ); // opened up with two pages + + // make sure the file is large enough... + // + while( bf.GetNumBlocks() < 2 ) { - static const TCHAR fileName[] = _T("test.bf"); - - cBlockFile bf; - bf.Open( fileName, 2, true ); // opened up with two pages - - // make sure the file is large enough... - // - while( bf.GetNumBlocks() < 2 ) - { - bf.CreateBlock(); - } - - // create the record arrays and associate them with the two blocks... - // - cBlockRecordArray ra1( &bf, 0 ); ra1.InitNewBlock(); - cBlockRecordArray ra2( &bf, 1 ); ra2.InitNewBlock(); - // - // now, start adding and removing things from the arrays... - // - static const char data1[] = "This is data 1"; - static const char data2[] = "And here we have data 2"; - static const char data3[] = "Here is d a t a 3!"; - static const char data4[] = "Three cheers for data 4!"; - ra1.AddItem( (int8*)data1, sizeof(data1), 1 ); - ra1.AddItem( (int8*)data2, sizeof(data2), 2 ); - ra1.AddItem( (int8*)data3, sizeof(data3), 3 ); - ra1.AddItem( (int8*)data4, sizeof(data4), 4 ); - #ifdef _BLOCKFILE_DEBUG - ra1.TraceContents(); - #endif - - // TODO -- try deleting the second to last and then the last thing from the array to - // see if we clean up properly. - - // delete item 2... - ra1.DeleteItem( 1 ); - #ifdef _BLOCKFILE_DEBUG - ra1.TraceContents(); - #endif - - // add a new item... - static const char data5[] = "fffiiivvveee!"; - ra1.AddItem( (int8*)data5, sizeof(data5), 5 ); - #ifdef _BLOCKFILE_DEBUG - ra1.TraceContents(); - #endif + bf.CreateBlock(); + } - // delete the second to last and last items to see if we clean up properly... - // note that there are four things here at this point. - ra1.DeleteItem( 2 ); - #ifdef _BLOCKFILE_DEBUG - ra1.TraceContents(); - #endif - ra1.DeleteItem( 3 ); - #ifdef _BLOCKFILE_DEBUG - ra1.TraceContents(); - #endif + // create the record arrays and associate them with the two blocks... + // + cBlockRecordArray ra1( &bf, 0 ); ra1.InitNewBlock(); + cBlockRecordArray ra2( &bf, 1 ); ra2.InitNewBlock(); - // delete the first item to see if that works ok.... - ra1.DeleteItem( 0 ); - #ifdef _BLOCKFILE_DEBUG - ra1.TraceContents(); - #endif + TEST(ra1.IsClassValid()); + TEST(ra2.IsClassValid()); - // add a couple more just for kicks :-) - static const char data6[] = "We're looking for six"; - static const char data7[] = "All 7s go to heaven"; - ra1.AddItem( (int8*)data6, sizeof(data6), 6 ); - ra1.AddItem( (int8*)data7, sizeof(data7), 7 ); - #ifdef _BLOCKFILE_DEBUG - ra1.TraceContents(); - #endif + TEST(ra1.Initialized()); - // Now, we will close the file, reopen it and see if we can read it ok. - // - bf.Close(); - bf.Open( fileName, 2, false ); - cBlockRecordArray ra3( &bf, 0 ); ra3.InitForExistingBlock(); - d.TraceDebug( "\n------ Tracing out the contents of the first block after being read back in from disk...\n\n"); - #ifdef _BLOCKFILE_DEBUG - ra3.TraceContents(); - #endif - } - catch( eError& e ) - { - d.TraceError( "Exception caught: %d %s\n", e.GetID(), e.GetMsg().c_str() ); - TEST( false ); - } + // + // now, start adding and removing things from the arrays... + // + static const char data1[] = "This is data 1"; + static const char data2[] = "And here we have data 2"; + static const char data3[] = "Here is d a t a 3!"; + static const char data4[] = "Three cheers for data 4!"; + ra1.AddItem( (int8*)data1, sizeof(data1), 1 ); +// TEST(ra1.IsItemValid(1)); + ra1.AddItem( (int8*)data2, sizeof(data2), 2 ); +// TEST(ra1.IsItemValid(2)); + ra1.AddItem( (int8*)data3, sizeof(data3), 3 ); +// TEST(ra1.IsItemValid(3)); + ra1.AddItem( (int8*)data4, sizeof(data4), 4 ); +// TEST(ra1.IsItemValid(4)); + #ifdef _BLOCKFILE_DEBUG + ra1.TraceContents(); + #endif + + // TODO -- try deleting the second to last and then the last thing from the array to + // see if we clean up properly. + + // delete item 2... + ra1.DeleteItem( 1 ); + TEST(!ra1.IsItemValid(1)); + #ifdef _BLOCKFILE_DEBUG + ra1.TraceContents(); + #endif + + // add a new item... + static const char data5[] = "fffiiivvveee!"; + ra1.AddItem( (int8*)data5, sizeof(data5), 5 ); +// TEST(ra1.IsItemValid(5)); + #ifdef _BLOCKFILE_DEBUG + ra1.TraceContents(); + #endif + + // delete the second to last and last items to see if we clean up properly... + // note that there are four things here at this point. + ra1.DeleteItem( 2 ); + TEST(!ra1.IsItemValid(2)); + #ifdef _BLOCKFILE_DEBUG + ra1.TraceContents(); + #endif + ra1.DeleteItem( 3 ); + TEST(!ra1.IsItemValid(3)); + #ifdef _BLOCKFILE_DEBUG + ra1.TraceContents(); + #endif + + // delete the first item to see if that works ok.... + ra1.DeleteItem( 0 ); + #ifdef _BLOCKFILE_DEBUG + ra1.TraceContents(); + #endif + + // add a couple more just for kicks :-) + static const char data6[] = "We're looking for six"; + static const char data7[] = "All 7s go to heaven"; + ra1.AddItem( (int8*)data6, sizeof(data6), 6 ); + ra1.AddItem( (int8*)data7, sizeof(data7), 7 ); + #ifdef _BLOCKFILE_DEBUG + ra1.TraceContents(); + #endif + + TEST(ra1.IsClassValid()); + + // Now, we will close the file, reopen it and see if we can read it ok. + // + bf.Close(); + bf.Open( fileName, 2, false ); + cBlockRecordArray ra3( &bf, 0 ); ra3.InitForExistingBlock(); + d.TraceDebug( "\n------ Tracing out the contents of the first block after being read back in from disk...\n\n"); + #ifdef _BLOCKFILE_DEBUG + ra3.TraceContents(); + #endif + + TEST(ra3.Initialized()); + TEST(ra3.IsClassValid()); } +void RegisterSuite_BlockRecordArray() +{ + RegisterTest("BlockRecordArray", "Basic", TestBlockRecordArray); +} diff --git a/src/twtest/charutil_t.cpp b/src/twtest/charutil_t.cpp index ff6872c..79166b7 100644 --- a/src/twtest/charutil_t.cpp +++ b/src/twtest/charutil_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -42,8 +42,23 @@ #include "core/errorbucketimpl.h" #include "twtest/test.h" +#include -void PrintChars( const TSTRING& str ) +bool localeIsUtf8() +{ + std::string locale(setlocale(LC_CTYPE, 0)); + std::transform(locale.begin(), locale.end(), locale.begin(), ::tolower); + + if(locale.find("utf-8") != std::string::npos) + return true; + + if(locale.find("utf8") != std::string::npos) + return true; + + return false; +} + +void CheckChars( const TSTRING& str, int length_expected = 1) { TSTRING::const_iterator cur = str.begin(); TSTRING::const_iterator end = str.end(); @@ -51,19 +66,11 @@ void PrintChars( const TSTRING& str ) while( cCharUtil::PopNextChar( cur, end, first, last ) ) { - TCOUT << _T("char length: ") << (int)(last - first) << std::endl; - - TCOUT << _T("char: <"); - for( TSTRING::const_iterator at = first; at != last; at++ ) - { - if( at != first ) - TCOUT << _T(","); - TCOUT << (int)*at; - } - TCOUT << _T(">") << std::endl; + int length = (int)(last - first); + if (length != length_expected ) + TCERR << "CheckChars on '" << str << "' : expected = " << length_expected << " | observed = " << length << std::endl; + TEST(length == length_expected); } - - TCOUT << _T("----------------------------") << std::endl; } /////////////////////////////////////////////////////////////////////////// @@ -71,23 +78,16 @@ void PrintChars( const TSTRING& str ) /////////////////////////////////////////////////////////////////////////// void TestCharUtilBasic() { - try - { - PrintChars( _T("foo") ); - PrintChars( _T("fo\x23 54") ); - } - catch( eError& e ) - { - cErrorReporter::PrintErrorMsg( e ); - TEST(false); - } + CheckChars( "foo" ); + CheckChars( "fo\x23 54" ); + + if(localeIsUtf8()) + CheckChars( "\U0001F408", 4 ); //Cat emoji, if UTF-8 + else + CheckChars( "\U0001F408", 1 ); // just a bag of bytes otherwise } - -/* -TSS_BeginTestSuiteFrom( cCharEncoderTest ) - - TSS_AddTestCase( Basic ); - -TSS_EndTestSuite( cCharEncoderTest ) -*/ +void RegisterSuite_CharUtil() +{ + RegisterTest("CharUtil", "Basic", TestCharUtilBasic); +} diff --git a/src/twtest/cmdlineparser_t.cpp b/src/twtest/cmdlineparser_t.cpp index 8996d80..d4898de 100644 --- a/src/twtest/cmdlineparser_t.cpp +++ b/src/twtest/cmdlineparser_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -88,7 +88,7 @@ const TCHAR* argv5[] = _T("frog") }; -#ifdef _DEBUG +#ifdef DEBUG static void PrintCmdLine(int argc, const TCHAR** argv, cDebug d) { TSTRING str; @@ -104,7 +104,7 @@ static void PrintCmdLine(int argc, const TCHAR** argv, cDebug d) static void test_parse(cCmdLineParser& parser, const int argc, const TCHAR** argv, bool should_throw) { -#ifdef _DEBUG +#ifdef DEBUG cDebug d("test_parse"); PrintCmdLine(argc, argv, d); #endif @@ -122,7 +122,7 @@ static void test_parse(cCmdLineParser& parser, const int argc, const TCHAR** arg TEST(threw == should_throw); -#ifdef _DEBUG +#ifdef DEBUG parser.TraceContents(); #endif } @@ -133,40 +133,38 @@ void TestCmdLineParser() { enum ArgId { ID_M, ID_TP, ID_V, ID_UNNAMED }; - try { - cCmdLineParser p; - p.AddArg(ID_M, TSTRING(_T("m")), TSTRING(_T("mode")), cCmdLineParser::PARAM_ONE); - p.AddArg(ID_TP, TSTRING(_T("tp")), TSTRING(_T("twoparam")), cCmdLineParser::PARAM_MANY); - p.AddArg(ID_V, TSTRING(_T("v")), TSTRING(_T("verbose")), cCmdLineParser::PARAM_NONE); - p.AddArg(ID_UNNAMED, TSTRING(_T("")), TSTRING(_T("")), cCmdLineParser::PARAM_MANY); + cCmdLineParser p; + p.AddArg(ID_M, TSTRING(_T("m")), TSTRING(_T("mode")), cCmdLineParser::PARAM_ONE); + p.AddArg(ID_TP, TSTRING(_T("tp")), TSTRING(_T("twoparam")), cCmdLineParser::PARAM_MANY); + p.AddArg(ID_V, TSTRING(_T("v")), TSTRING(_T("verbose")), cCmdLineParser::PARAM_NONE); + p.AddArg(ID_UNNAMED, TSTRING(_T("")), TSTRING(_T("")), cCmdLineParser::PARAM_MANY); - cDebug d("TestCmdLineParser"); + cDebug d("TestCmdLineParser"); - test_parse(p, argc1, argv1, false); - test_parse(p, argc2, argv2, true); - test_parse(p, argc3, argv3, true); - test_parse(p, argc4, argv4, false); + test_parse(p, argc1, argv1, false); + test_parse(p, argc2, argv2, true); + test_parse(p, argc3, argv3, true); + test_parse(p, argc4, argv4, false); - // command line arg mutual exclusion - d.TraceDebug("** Making -m and -v mutually exclusive, then running on first cmd line...\n"); - p.AddMutEx(ID_M, ID_V); - test_parse(p, argc1, argv1, true); // should fail - - // make the command line want one parameter - d.TraceDebug("** Changing cmd line to only want one last param...\n"); - p.AddArg(ID_UNNAMED, TSTRING(_T("")), TSTRING(_T("")), cCmdLineParser::PARAM_ONE); - test_parse(p, argc4, argv4, true); + // command line arg mutual exclusion + d.TraceDebug("** Making -m and -v mutually exclusive, then running on first cmd line...\n"); + p.AddMutEx(ID_M, ID_V); + test_parse(p, argc1, argv1, true); // should fail + + // make the command line want one parameter + d.TraceDebug("** Changing cmd line to only want one last param...\n"); + p.AddArg(ID_UNNAMED, TSTRING(_T("")), TSTRING(_T("")), cCmdLineParser::PARAM_ONE); + test_parse(p, argc4, argv4, true); - test_parse(p, argc5, argv5, false); + test_parse(p, argc5, argv5, false); - // TODO -- test a bunch more!!! - } - catch (eCmdLine &e) - { - TCERR << _T("Command line error: "); - TCERR << e.GetMsg() << std::endl; - //TODO... - TEST(false); - } + // TODO -- test a bunch more!!! } +void RegisterSuite_CmdLineParser() +{ + RegisterTest("CmdLineParser", "Basic", TestCmdLineParser); +} + + + diff --git a/src/twtest/codeconvert_t.cpp b/src/twtest/codeconvert_t.cpp index 36cb169..7700f0d 100644 --- a/src/twtest/codeconvert_t.cpp +++ b/src/twtest/codeconvert_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -52,7 +52,7 @@ void TestCodeConverter() { cDebug d("TestCodeConverter()"); -#if ( !(HAVE_ICONV_H) && WCHAR_REP_IS_UCS2 ) +#if 0 //( !(HAVE_ICONV_H) && WCHAR_REP_IS_UCS2 ) // // check that rep is really UCS2 @@ -66,8 +66,8 @@ void TestCodeConverter() // Took out this test as it currently throws and exception. // We expect not to be able to convert every UCS2 to a multi-byte char. -// d.TraceDetail("Testing double byte to multi byte conversion.\n"); -// TestDbToMb(); + d.TraceDetail("Testing double byte to multi byte conversion.\n"); + TestDbToMb(); } // first last identify the lhs string @@ -185,7 +185,8 @@ char NonZeroChar( char ch ) //TestMbToDb in codeconvert_t.cpp seems to hit an infinite loop or runs verrrry long; ifdef'd" void TestMbToDb() { - TCERR << "\nTODO: TestMbToDb in codeconvert_t.cpp is flaky & needs to be fixed/replaced; currently disabled." << std::endl; + skip("This test is flaky & needs to be fixed/replaced; currently disabled."); + #if 0 std::string s; s.resize( 0x10000 * 2 ); // two bytes for each combination @@ -240,6 +241,9 @@ void TestMbToDb() // dbchar_t to mbchar_t void TestDbToMb() { + skip("This test fails, most likely due to not speaking UTF-16. Should fix this."); + +#if 0 wc16_string ws; wc16_string::size_type n; const wc16_string::size_type max = 0x10000; @@ -263,9 +267,10 @@ void TestDbToMb() iCodeConverter::GetInstance()->Convert( (ntdbs_t)ws2.c_str(), max - 1, s.c_str(), s.length() ); TEST( ws.compare( ws2 ) == 0 ); +#endif } - +#if 0 bool util_IsWideCharSameAsNarrow( char ch ) { cDebug d("LowASCIILooksLikeUCS2InWchart()"); @@ -339,6 +344,10 @@ bool LowASCIILooksLikeUCS2InWchart() #endif return fOK; } +#endif -// eof: codeconvert_t.cpp - +void RegisterSuite_CodeConvert() +{ + RegisterTest("CodeConvert", "MbToDb", TestMbToDb); + RegisterTest("CodeConvert", "DbToMb", TestDbToMb); +} diff --git a/src/twtest/configfile_t.cpp b/src/twtest/configfile_t.cpp index 7ae3b8b..7b692a2 100644 --- a/src/twtest/configfile_t.cpp +++ b/src/twtest/configfile_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -47,90 +47,105 @@ using namespace std; +static void assertParse(const std::string& configLineIn, bool expectValid) +{ + static const std::string sMandatory = \ + "\nPOLFILE=foo" \ + "\nDBFILE=foo" \ + "\nREPORTFILE=foo" \ + "\nSITEKEYFILE=foo" \ + "\nLOCALKEYFILE=foo"; + + bool threw = false; + cConfigFile cfg; + + std::string configLine = configLineIn + sMandatory; + + try + { + cfg.ReadString( configLine ); + } + catch( eConfigFileMissReqKey& e) + { + TCERR << "Got a missing key exception, which should not happen" << std::endl; + TEST(false); + } + catch( eConfigFile& e ) + { + e.SetFatality(false); + cTWUtil::PrintErrorMsg( e ); + + threw = true; + } + +#ifdef _DEBUG + TCERR << "LINE [" << configLineIn << "]" << std::endl << "Expected = " << expectValid << std::endl << "Threw = " << threw << std::endl; +#endif + + TEST(expectValid != threw); +} + + void TestConfigFile(void) { - TSTRING asConfigFileText[] = - { - _T("BRIAN=foo"), // 0 fine - _T("BRIAN=foo\nBILL=bar"), // 1 fine - _T("BRIAN=foo\r\nBILL=bar"), // 2 fine - _T("BRIAN=foo\n\n\rBILL=bar\n"),// 3 fine - _T(" WS=foo \n\n\r BILL=bar\n"), // 4 fine - _T(" WS = foo \n\n\r BILL = bar \n"), // 5 fine - _T("FOO=foo\nBAR=$(FOO)"), // 6 fine - _T("FOO=foo\nBAR=$(FO)"), // 7 undefined var - _T("FOO=foo\nBAR=$(FOO"), // 8 no r paren - _T("FOO=foo\nBAR=$(FOO "), // 9 no r paren - _T("BAR=$(FOO\n"), // 10 no r paren - _T(" VAR =foo \nWS = $(VAR)\n"), // 11 fine - _T(""), // 12 fine - _T("\n"), // 13 fine - _T("\r"), // 14 fine - _T("\r\n"), // 15 fine - _T("B=POO\nA"), // 16 no equals - _T(" B=POO \n A \r"), // 17 no equals - _T("B=POO\nB=CRAP"), // 18 redefined var - _T("DATE=CRAP"), // 19 redefine predefine var - _T("B=POO\nDATE=CRAP"), // 20 redefine predefine var - _T("A=1\nB=$(A)\nC=$(B)"), // 21 fine -- checking var sub - _T("A=$(DATE)"), // 22 fine -- checking predef var sub - _T("A=1\nB=$(A)\nC=$(DATE)"), // 23 fine -- checking predef var sub - _T("A=1\n=$(A)\nC=$(DATE)"), // 24 no key - _T("A=$(DATE)-B"), // 25 fine -- check that the '-' shows up - _T("A=$(DATE)-$(DATE)"), // 26 fine -- check that the '-' shows up - }; + // should succeed + assertParse( _T("BRIAN=foo"), true ); // 0 fine + assertParse( _T("BRIAN=foo\nBILL=bar"), true ); // 1 fine + assertParse( _T("BRIAN=foo\r\nBILL=bar"), true ); // 2 fine + assertParse( _T("BRIAN=foo\n\n\rBILL=bar\n"), true ); // 3 fine + assertParse( _T(" WS=foo \n\n\r BILL=bar\n"), true ); // 4 fine + assertParse( _T(" WS = foo \n\n\r BILL = bar \n"), true ); // 5 fine + assertParse( _T("FOO=foo\nBAR=$(FOO)"), true ); // 6 fine - /* - TSTRING sMandatory = \ - _T("\nPOLFILE=foo") \ - _T("\nDBFILE=foo") \ - _T("\nREPORTFILE=foo") \ - _T("\nSITEKEYFILE=foo") \ - _T("\nLOCALKEYFILE=foo"); - */ + // should fail + assertParse( _T("FOO=foo\nBAR=$(FO)"), false ); // 7 undefined var + assertParse( _T("FOO=foo\nBAR=$(FOO"), false ); // 8 no r paren + assertParse( _T("FOO=foo\nBAR=$(FOO "), false ); // 9 no r paren + assertParse( _T("BAR=$(FOO\n"), false ); // 10 no r paren + // should succeed + assertParse( _T(" VAR =foo \nWS = $(VAR)\n"), true ); // 11 fine + assertParse( _T(""), true ); // 12 fine + assertParse( _T("\n"), true ); // 13 fine + assertParse( _T("\r"), true ); // 14 fine + assertParse( _T("\r\n"), true ); // 15 fine - for( TSTRING* at = &asConfigFileText[0]; - at != &asConfigFileText[countof(asConfigFileText)]; - at++ ) - { - cConfigFile cfg; - //*at += sMandatory; + // should fail + assertParse( _T("B=POO\nA"), false ); // 16 no equals + assertParse( _T(" B=POO \n A \r"), false ); // 17 no equals + +/* This next test asserts that you can't change a variable once you've defined it. + However there's no actual code in cConfigFile to check for this, and + OST appears to work fine if you redefine a config variable, so I'm not going + to change the current behavior. Leaving this test in w/ a note for reference. + + assertParse( _T("B=POO\nB=CRAP"), false ); // 18 redefined var +*/ + assertParse( _T("DATE=CRAP"), false ); // 19 redefine predefine var + assertParse( _T("B=POO\nDATE=CRAP"), false ); // 20 redefine predefine var + // should succeed + assertParse( _T("A=1\nB=$(A)\nC=$(B)"), true ); // 21 fine -- checking var sub + assertParse( _T("A=$(DATE)"), true ); // 22 fine -- checking predef var sub + assertParse( _T("A=1\nB=$(A)\nC=$(DATE)"), true ); // 23 fine -- checking predef var sub + + // should fail + assertParse( _T("A=1\n=$(A)\nC=$(DATE)"), false ); // 24 no key + + // should succeed + assertParse( _T("A=$(DATE)-B"), true ); // 25 fine -- check that the '-' shows up + assertParse( _T("A=$(DATE)-$(DATE)"), true ); // 26 fine -- check that the '-' shows up - TCERR << _T("*** line:") << std::endl; - TCERR << *at << std::endl; - TCERR << _T("*** eol:") << std::endl; - try - { - cfg.ReadString( *at ); - } - catch( eConfigFileMissReqKey& ) - { - // ignore.... - } - catch( eConfigFile& e ) - { - int offset = ( at - asConfigFileText ); - int itemSize = sizeof( asConfigFileText[0] ); - int num = offset / itemSize; - TCERR << num << std::endl; - cTWUtil::PrintErrorMsg( e ); - } - } } void TestConfigFile2(void) { cDebug d("Testconfigfile"); d.TraceDetail("Entering...\n"); - iFSServices* pFSServices = iFSServices::GetInstance(); + //iFSServices* pFSServices = iFSServices::GetInstance(); //Define some test values for pairs to be //stored in a test config. module. I'm going to use the //values specified in the install doc. -DA - TSTRING currpath; - pFSServices->GetCurrentDir(currpath); - const TSTRING testTWROOT = currpath; //TODO maybe also test read failure when mandatory config values aren't set @@ -145,7 +160,7 @@ void TestConfigFile2(void) write_cfgmod.Insert( _T("LOCALKEYFILE"), "local.key"); //Filename for writing/reading some value pairs: - const TSTRING testfile = testTWROOT + _T("/tripwire.cfg"); + const TSTRING testfile = TwTestPath("tripwire.cfg"); //Store these values on disk. TSTRING configText; @@ -178,5 +193,10 @@ void TestConfigFile2(void) TEST( lookup2 == "test.twd" ); d.TraceDetail("Tests Passed!\n"); -//#endif // NOT_BRIANS_TEST +} + +void RegisterSuite_ConfigFile() +{ + RegisterTest("ConfigFile", "Basic1", TestConfigFile); + RegisterTest("ConfigFile", "Basic2", TestConfigFile2); } diff --git a/src/twtest/crytpo_t.cpp b/src/twtest/crypto_t.cpp similarity index 96% rename from src/twtest/crytpo_t.cpp rename to src/twtest/crypto_t.cpp index 5777579..018f4bb 100644 --- a/src/twtest/crytpo_t.cpp +++ b/src/twtest/crypto_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -44,9 +44,13 @@ void TestCrypto() const int BUFSIZE = 9000; - char source[BUFSIZE]; - char crypt[COUNT + BUFSIZE]; // needs to be able to hold even number of blocks - char dest[COUNT]; + std::vector source_buf(BUFSIZE); + std::vector crypt_buf(COUNT + BUFSIZE); // needs to be able to hold even number of blocks + std::vector dest_buf(COUNT); + + char* source = &source_buf[0]; + char* crypt = &crypt_buf[0]; + char* dest = &dest_buf[0]; memcpy(source, "I love the smell of the sheep.", 31); @@ -407,6 +411,13 @@ void TestCrypto() delete pPublic; delete pPrivate; + delete pPublic2; + delete pPrivate2; } } +void RegisterSuite_Crypto() +{ + RegisterTest("Crypto", "Basic", TestCrypto); +} + diff --git a/src/twtest/cryptoarchive_t.cpp b/src/twtest/cryptoarchive_t.cpp index 97e80c9..3b754a4 100644 --- a/src/twtest/cryptoarchive_t.cpp +++ b/src/twtest/cryptoarchive_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -70,7 +70,7 @@ void TestCryptoArchive() d.TraceDetail("Encrypting using symmetric key\n"); cFileArchive outFile; - outFile.OpenReadWrite(TEMP_DIR _T("/crypted.bin")); + outFile.OpenReadWrite(TwTestPath("crypted.bin")); idea.SetKey(iCipher::ENCRYPT, ideaKey); cCryptoArchive outCrypt; @@ -90,7 +90,7 @@ void TestCryptoArchive() d.TraceDetail("Decrypting using symmetric key\n"); cFileArchive inFile; - inFile.OpenRead(TEMP_DIR _T("/crypted.bin")); + inFile.OpenRead(TwTestPath("crypted.bin")); idea.SetKey(iCipher::DECRYPT, ideaKey); cCryptoArchive inCrypt; @@ -129,7 +129,7 @@ void TestCryptoArchive() d.TraceDetail("Signing using asymmetric key\n"); cFileArchive outFile; - outFile.OpenReadWrite(TEMP_DIR _T("/rsacrypted.bin")); + outFile.OpenReadWrite(TwTestPath("rsacrypted.bin").c_str()); cElGamalSigArchive outCrypt; outCrypt.SetWrite(&outFile, privateKey); @@ -149,7 +149,7 @@ void TestCryptoArchive() d.TraceDetail("Verifying using asymmetric key\n"); cFileArchive inFile; - inFile.OpenRead(TEMP_DIR _T("/rsacrypted.bin")); + inFile.OpenRead(TwTestPath("rsacrypted.bin").c_str()); cElGamalSigArchive inCrypt; inCrypt.SetRead(&inFile, publicKey); @@ -206,7 +206,7 @@ void TestCryptoArchive() d.TraceDetail("Encrypting using asymmetric key\n"); cFileArchive outFile; - outFile.OpenReadWrite(TEMP_DIR _T("/rsacrypted.bin")); + outFile.OpenReadWrite(TwTestPath("rsacrypted.bin").c_str()); cRSAArchive outCrypt; outCrypt.SetWrite(&outFile, publicKey); @@ -226,7 +226,7 @@ void TestCryptoArchive() d.TraceDetail("Decrypting using asymmetric key\n"); cFileArchive inFile; - inFile.OpenRead(TEMP_DIR _T("/rsacrypted.bin")); + inFile.OpenRead(TwTestPath("rsacrypted.bin").c_str()); cRSAArchive inCrypt; inCrypt.SetRead(&inFile, privateKey); @@ -252,7 +252,7 @@ void TestCryptoArchive() d.TraceDetail("Signing using asymmetric key\n"); cFileArchive outFile; - outFile.OpenReadWrite(TEMP_DIR _T("/rsacrypted.bin")); + outFile.OpenReadWrite(TwTestPath("rsacrypted.bin").c_str()); cRSAArchive outCrypt; outCrypt.SetWrite(&outFile, privateKey); @@ -272,7 +272,7 @@ void TestCryptoArchive() d.TraceDetail("Verifying using asymmetric key\n"); cFileArchive inFile; - inFile.OpenRead(TEMP_DIR _T("/rsacrypted.bin")); + inFile.OpenRead(TwTestPath("rsacrypted.bin").c_str()); cRSAArchive inCrypt; inCrypt.SetRead(&inFile, publicKey); @@ -299,4 +299,7 @@ void TestCryptoArchive() #endif } - +void RegisterSuite_CryptoArchive() +{ + RegisterTest("CryptoArchive", "Basic", TestCryptoArchive); +} diff --git a/src/twtest/dbdatasource_t.cpp b/src/twtest/dbdatasource_t.cpp index 15c4322..c5d5b73 100644 --- a/src/twtest/dbdatasource_t.cpp +++ b/src/twtest/dbdatasource_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -41,268 +41,179 @@ #include "fco/fcoprop.h" #include "fco/fco.h" #include "twtest/test.h" +#include "fs/fsobject.h" -static void GetNoun( TSTRING& noun ) +static void AddFile(cDbDataSourceIter& iter, const TSTRING& filename, bool with_data=false) { - static TSTRING prevNoun; - TCIN >> noun; - if( noun.compare( _T("!$") ) == 0 ) + if (iter.SeekTo(filename.c_str())) + TCOUT << "Object " << filename << " already exists!" << std::endl; + + cFCOName fname(filename); + + if (with_data) { - noun = prevNoun; + iFCO* pFCO = new cFSObject(fname); + iter.AddFCO(filename,pFCO); } - prevNoun = noun; + else + { + iter.AddFCO(filename,0); + } + + TEST(iter.HasFCOData() == with_data); } -// -// TODO -- implement this with the prop displayer as well! -// -static void PrintFCO( const iFCO* pFCO ) +static void AddDirectory(cDbDataSourceIter& iter, const TSTRING& filename) { - TCOUT.setf(std::ios::left); - - TCOUT << "------- " << pFCO->GetName().AsString() << " -------" << std::endl; - // - // iterate over all of the properties - // - const iFCOPropSet* pPropSet = pFCO->GetPropSet(); - cFCOPropVector v = pPropSet->GetValidVector(); - for( int i=0; i < pPropSet->GetNumProps(); i++ ) - { - if( v.ContainsItem( i ) ) + if (iter.SeekTo(filename.c_str())) + TCOUT << "Object " << filename << " already exists!" << std::endl; + + iter.AddFCO(filename, 0); + iter.AddChildArray(); + + TEST(iter.CanDescend()); +} + +static void RemoveDirectory(cDbDataSourceIter& iter, const TSTRING& filename) +{ + TCOUT << "Removing the child of " << filename << std::endl; + if( iter.SeekTo( filename.c_str() ) ) + { + iter.RemoveChildArray(); + iter.RemoveFCO(); + } + else + { + TCOUT << "Unable to find object " << filename << std::endl; + } +} + +static void RemoveFile(cDbDataSourceIter& iter, const TSTRING& filename) +{ + TCOUT << "Removing object " << filename << std::endl; + cFCOName fname(filename); + iter.SeekToFCO(fname); + + if( iter.CanDescend() ) + { + TCOUT << "Can't delete object; it still has children." << std::endl; + } + else + { + iter.RemoveFCOData(); + iter.RemoveFCO(); + } +} + +static void ChDir(cDbDataSourceIter& iter, const TSTRING& filename) +{ + if( filename.compare( _T("..") ) == 0 ) + { + if( iter.AtRoot() ) + TCOUT << "At root already" << std::endl; + + TCOUT << "Ascending..." << std::endl; + iter.Ascend(); + } + else + { + if( iter.SeekTo( filename.c_str() ) ) { - TCOUT << "["; - TCOUT.width(2); - TCOUT << i << "]" ; - TCOUT.width(25); - TCOUT << pPropSet->GetPropName(i); - TCOUT.width(0); - TCOUT << pPropSet->GetPropAt( i )->AsString() << std::endl; + if( !iter.CanDescend()) + TCOUT << filename << " has no children; can't descend." << std::endl; + + TCOUT << "Descending into " << filename << std::endl; + iter.Descend(); + } + else + { + TCOUT << "Unable to find object " << filename << std::endl; } } - TCOUT << "--------------------------------------------" << std::endl; } - -void TestDbDataSource() +static void AssertData(cDbDataSourceIter& iter, const TSTRING& filename, bool should_have) +{ + bool exists = iter.SeekTo( filename.c_str() ); + TEST(exists == should_have); + + if (exists) + { + bool has_data = iter.HasFCOData(); + TEST(has_data == should_have); + + if (has_data) + { + iFCO* pFCO = iter.CreateFCO(); + TEST(pFCO); + TCOUT << "Roundtrip FCOName = " << pFCO->GetName().AsString() << std::endl; + TSTRING expected = filename + "/"; + TEST(pFCO->GetName().AsString() == expected); + } + } +} + +static void AssertExists(cDbDataSourceIter& iter, const TSTRING& filename, bool should_have) +{ + bool exists = iter.SeekTo( filename.c_str() ); + TEST(exists == should_have); +} + +static void AssertChildren(cDbDataSourceIter& iter, const TSTRING& filename, bool should_have) +{ + bool exists = iter.SeekTo( filename.c_str() ); + + if (exists) + { + bool has_children = iter.CanDescend(); + TEST(has_children == should_have); + } +} + +void TestDbDataSourceBasic() { - TCERR << std::endl << "TestDbDataSource needs to be redesigned so it doesn't require user interaction" << std::endl; - -#if 0 - cDebug d("TestDbDataSource"); cHierDatabase db; + std::string dbpath = TwTestPath("test.db"); + db.Open( dbpath, 5, true); + cDbDataSourceIter iter(&db); - const TSTRING dbName = _T("tw.db"); + AddFile(iter, "file1", true); + AddFile(iter, "file2", false); + AddFile(iter, "file3", false); + AddDirectory(iter, "dir1"); + AddDirectory(iter, "dir2"); + AddDirectory(iter, "dir3"); + AssertData(iter, "file1", true); + + ChDir(iter, "dir1"); + AddFile(iter, "dir1_file1"); + ChDir(iter, ".."); + + RemoveFile(iter, "file1"); + RemoveFile(iter, "file2"); + + AssertExists(iter, "file1", false); + AssertExists(iter, "file2", false); + AssertExists(iter, "file3", true); + + RemoveDirectory(iter, "dir2"); + + AssertExists(iter, "dir1", true); + AssertExists(iter, "dir2", false); + AssertExists(iter, "dir3", true); + + AssertChildren(iter, "dir1", true); + AssertChildren(iter, "dir3", true); + AssertChildren(iter, "file3", false); - try - { - // TODO -- get the case sensitiveness and delimiting char out of the factory instead of iFSServices - // - TCOUT << _T("Opening database ") << dbName << std::endl; - db.Open( dbName, 5, false ); - cDbDataSourceIter iter( &db ); - - //////////////////////////// - // the main event loop... - //////////////////////////// - while( true ) - { - TSTRING verb, noun; - TCOUT << _T(">>"); - TCIN >> verb; - // - // ok, now we switch on the command... - // - //----------------------------------------------------------------- - // quit - //----------------------------------------------------------------- - if( verb.compare( _T("quit") ) == 0 ) - { - // the quit command... - break; - } - //----------------------------------------------------------------- - // print - //----------------------------------------------------------------- - if( verb.compare( _T("print") ) == 0 ) - { - GetNoun(noun); - if( iter.SeekTo( noun.c_str() ) ) - { - if( iter.HasFCOData() ) - { - iFCO* pFCO = iter.CreateFCO(); - PrintFCO( pFCO ); - pFCO->Release(); - } - else - { - TCOUT << "Object has no data associated with it." << std::endl; - } - } - else - { - TCOUT << "Unable to find object " << noun << std::endl; - } - } - //----------------------------------------------------------------- - // mkdir - //----------------------------------------------------------------- - else if( verb.compare( _T("mkdir") ) == 0 ) - { - GetNoun(noun); - TCOUT << "Making a child of " << noun << std::endl; - if( iter.SeekTo( noun.c_str() ) ) - { - iter.AddChildArray(); - } - else - { - TCOUT << "Unable to find object " << noun << std::endl; - } - } - //----------------------------------------------------------------- - // mk - //----------------------------------------------------------------- - else if( verb.compare( _T("mk") ) == 0 ) - { - GetNoun(noun); - TCOUT << "Making object " << noun << std::endl; - if( iter.SeekTo( noun.c_str() ) ) - { - TCOUT << "Error: object already exists!" << std::endl; - } - else - { - iter.AddFCO( noun, 0 ); // add a null fco for now - } - } - //----------------------------------------------------------------- - // rmdir - //----------------------------------------------------------------- - // TODO -- still needs to be implemented in the iterator class! - // - /* - else if( verb.compare( _T("rmdir") ) == 0 ) - { - GetNoun(noun); - TCOUT << "Removing the child of " << noun << std::endl; - if( iter.SeekTo( noun.c_str() ) ) - { - //TODO -- check that it has an empty child - iter.DeleteChildArray(); - } - else - { - TCOUT << "Unable to find object " << noun << std::endl; - } - } - */ - //----------------------------------------------------------------- - // rm - //----------------------------------------------------------------- - else if( verb.compare( _T("rm") ) == 0 ) - { - GetNoun(noun); - TCOUT << "Removing object " << noun << std::endl; - if( iter.SeekTo( noun.c_str() ) ) - { - if( iter.CanDescend() ) - { - TCOUT << "Can't delete object; it still has children." << std::endl; - } - else - { - iter.RemoveFCO(); - } - } - else - { - TCOUT << "Unable to find object " << noun << std::endl; - } - } - //----------------------------------------------------------------- - // pwd - //----------------------------------------------------------------- - else if( verb.compare( _T("pwd") ) == 0 ) - { - TCOUT << iter.GetParentName().AsString() << std::endl; - } - //----------------------------------------------------------------- - // ls - //----------------------------------------------------------------- - else if( verb.compare( _T("ls") ) == 0 ) - { - int cnt = 0; - for( iter.SeekBegin(); ! iter.Done(); iter.Next(), cnt++ ) - { - TCOUT << "[" << cnt ; - if( iter.CanDescend() ) - { - TCOUT << "]*\t" ; - } - else - { - TCOUT << "]\t" ; - } - TCOUT << iter.GetShortName() << std::endl; - } - } - //----------------------------------------------------------------- - // cd - //----------------------------------------------------------------- - else if( verb.compare( _T("cd") ) == 0 ) - { - GetNoun(noun); - if( noun.compare( _T("..") ) == 0 ) - { - if( iter.AtRoot() ) - { - TCOUT << "Can't ascend above root." << std::endl; - } - else - { - TCOUT << "Ascending..." << std::endl; - iter.Ascend(); - } - } - else - { - if( iter.SeekTo( noun.c_str() ) ) - { - if( iter.CanDescend() ) - { - TCOUT << "Descending into " << noun << std::endl; - iter.Descend(); - } - else - { - TCOUT << noun << " has no children; can't descend." << std::endl; - } - } - else - { - TCOUT << "Unable to find object " << noun << std::endl; - } - } - } - - // make sure the file is still valid... - // -#ifdef _BLOCKFILE_DEBUG - db.AssertAllBlocksValid() ; -#endif - } - - TCOUT << "Exiting..." << std::endl; - - - } - catch( eError& e ) - { - d.TraceError("*** Caught error: %d %s\n", e.GetID(), e.GetMsg().c_str() ); - TEST(false); - } +#ifdef DEBUG + db.AssertAllBlocksValid(); #endif } + +void RegisterSuite_DbDataSource() +{ + RegisterTest("DbDataSource", "Basic", TestDbDataSourceBasic); +} diff --git a/src/twtest/debug_t.cpp b/src/twtest/debug_t.cpp index 26ab5bf..c30e353 100644 --- a/src/twtest/debug_t.cpp +++ b/src/twtest/debug_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -70,14 +70,14 @@ void TestDebug() d.TraceDebug("You should see this in stdout and trace.\n"); cDebug::RemoveOutTarget(cDebug::OUT_STDOUT); d.TraceDebug("You should see this in trace only.\n"); + + // set up an output file...use the temp file in test.h - std::string str = TEMP_DIR_N; - str += "/debug.out"; - bool bResult = false; - bResult = cDebug::SetOutputFile(str.c_str()); - //TODO... TEST(bResult); - if( !bResult) - TCERR << "SetOutputFile failed!" << std::endl; + std::string str = TwTestPath("debug.out"); + +#ifdef DEBUG + TEST(cDebug::SetOutputFile(str.c_str())); +#endif d.TraceDebug("This should be in trace and the file %s.\n", str.c_str()); @@ -88,6 +88,14 @@ void TestDebug() if(oldOutTarget & cDebug::OUT_FILE) cDebug::AddOutTarget(cDebug::OUT_FILE); else cDebug::RemoveOutTarget(cDebug::OUT_FILE); d.TraceDebug("Exiting...\n"); + +#ifndef DEBUG + TEST("Should always succeed in release builds & cDebug should do nothing"); +#endif + } - +void RegisterSuite_Debug() +{ + RegisterTest("Debug", "Basic", TestDebug); +} diff --git a/src/twtest/displayencoder_t.cpp b/src/twtest/displayencoder_t.cpp index cd31847..448d1c4 100644 --- a/src/twtest/displayencoder_t.cpp +++ b/src/twtest/displayencoder_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -71,7 +71,7 @@ static void util_TestUnprintable( const TSTRING& strCUnprintable ) TSTRING strEncoded = strCUnprintable; e.Encode( strEncoded ); - TCOUT << strEncoded << std::endl; +// TCOUT << strEncoded << std::endl; TSTRING strOut = strEncoded; e.Decode( strOut ); @@ -246,100 +246,102 @@ void TestQuoteAndBackSlash() /////////////////////////////////////////////////////////////////////////// // Basic /////////////////////////////////////////////////////////////////////////// -void TestDisplayEncoderBasic() +void TestDisplayEncoderBasic1() { - try - { - //============================================================= - // TEST UNPRINTABLE ENCODING/ROUNDTRIP - //============================================================= + //============================================================= + // TEST UNPRINTABLE ENCODING/ROUNDTRIP + //============================================================= - util_TestUnprintable( _T("normal string") ); + util_TestUnprintable( _T("normal string") ); - util_TestUnprintable( _T("return\n") ); - util_TestUnprintable( _T("ret\rurn\n") ); - util_TestUnprintable( _T("ret\rnurn\n") ); + util_TestUnprintable( _T("return\n") ); + util_TestUnprintable( _T("ret\rurn\n") ); + util_TestUnprintable( _T("ret\rnurn\n") ); - util_TestUnprintable( _T("bell\x08") ); - util_TestUnprintable( _T("\x08 bell") ); - util_TestUnprintable( _T("be\x08ll") ); + util_TestUnprintable( _T("bell\x08") ); + util_TestUnprintable( _T("\x08 bell") ); + util_TestUnprintable( _T("be\x08ll") ); - util_TestUnprintable( _T("\x1F\x1F\x1F") ); + util_TestUnprintable( _T("\x1F\x1F\x1F") ); - util_TestUnprintable( _T("big\xFF") ); - util_TestUnprintable( _T("\xEE big") ); - util_TestUnprintable( _T("\xEE\xEEtwo big") ); - util_TestUnprintable( _T("small\x01") ); - util_TestUnprintable( _T("\x01\x01two small") ); - - //============================================================= - // TEST UNCONVERTABLE CHARS - //============================================================= - TSTRING strMessWithMe = _T("Mess with me..."); - for( size_t c = TSS_TCHAR_MIN; - c < TSS_TCHAR_MAX; - c++ ) - { - if( ( c != '\0' ) ) - { - strMessWithMe += c; - } - } - util_TestUnprintable( strMessWithMe ); - - //============================================================= - // TEST \\ and \x ENCODING/ROUNDTRIP - //============================================================= - - util_TestUnprintable( _T("\\Other \\\\slashes") ); - util_TestUnprintable( _T("\\Other slashes\\\\") ); - util_TestUnprintable( _T("O\\ther slashes\\\\") ); - util_TestUnprintable( _T("\\\\\\") ); - - util_TestUnprintable( _T("\\xTricky") ); - util_TestUnprintable( _T("Tri\\xcky") ); - util_TestUnprintable( _T("Tricky\\x") ); - util_TestUnprintable( _T("\\Tricky\\\\x") ); - - - //============================================================= - // TEST UNCONVERTABLE, UNPRINTABLE, AND \\ and \" CHARS - //============================================================= - TSTRING strMessWithMe2 = _T("Mess with me..."); - for( size_t ch = TSS_TCHAR_MIN; - ch < TSS_TCHAR_MAX; - ch++ ) - { - if( ( ch != '\0' ) ) - { - strMessWithMe2 += ch; - } - } - - strMessWithMe2 += _T("\r\n\t\b\\\"\\\\\\\"\v\""); - util_TestUnprintable( strMessWithMe2 ); - - // TODO:BAM -- create multibyte tests (create a mb string at random, then test it. - // make sure there are '\' and '"' in it ) - } - catch( eError& e ) - { - cErrorReporter::PrintErrorMsg( e ); - TEST(false); - } + util_TestUnprintable( _T("big\xFF") ); + util_TestUnprintable( _T("\xEE big") ); + util_TestUnprintable( _T("\xEE\xEEtwo big") ); + util_TestUnprintable( _T("small\x01") ); + util_TestUnprintable( _T("\x01\x01two small") ); } -/*TSS_BeginTestSuiteFrom( cDisplayEncoderTest ) +void TestDisplayEncoderBasic2() +{ + //============================================================= + // TEST UNCONVERTABLE CHARS + //============================================================= + TSTRING strMessWithMe = _T("Mess with me..."); + for( size_t c = TSS_TCHAR_MIN; + c < TSS_TCHAR_MAX; + c++ ) + { + if( ( c != '\0' ) ) + { + strMessWithMe += c; + } + } + util_TestUnprintable( strMessWithMe ); +} - TSS_AddTestCase( Basic ); - TSS_AddTestCase( TestHexToChar ); - TSS_AddTestCase( TestCharToHex ); - TSS_AddTestCase( TestStringToHex ); - TSS_AddTestCase( TestHexToString ); - TSS_AddTestCase( TestUnconvertable ); - TSS_AddTestCase( TestUnprintable ); - TSS_AddTestCase( TestQuoteAndBackSlash ); - -TSS_EndTestSuite( cDisplayEncoderTest )*/ +void TestDisplayEncoderBasic3() +{ + //============================================================= + // TEST \\ and \x ENCODING/ROUNDTRIP + //============================================================= + + util_TestUnprintable( _T("\\Other \\\\slashes") ); + util_TestUnprintable( _T("\\Other slashes\\\\") ); + util_TestUnprintable( _T("O\\ther slashes\\\\") ); + util_TestUnprintable( _T("\\\\\\") ); + + util_TestUnprintable( _T("\\xTricky") ); + util_TestUnprintable( _T("Tri\\xcky") ); + util_TestUnprintable( _T("Tricky\\x") ); + util_TestUnprintable( _T("\\Tricky\\\\x") ); +} + +void TestDisplayEncoderBasic4() +{ + //============================================================= + // TEST UNCONVERTABLE, UNPRINTABLE, AND \\ and \" CHARS + //============================================================= + TSTRING strMessWithMe2 = _T("Mess with me..."); + for( size_t ch = TSS_TCHAR_MIN; + ch < TSS_TCHAR_MAX; + ch++ ) + { + if( ( ch != '\0' ) ) + { + strMessWithMe2 += ch; + } + } + + strMessWithMe2 += _T("\r\n\t\b\\\"\\\\\\\"\v\""); + util_TestUnprintable( strMessWithMe2 ); + + // TODO:BAM -- create multibyte tests (create a mb string at random, then test it. + // make sure there are '\' and '"' in it ) +} + +void RegisterSuite_DisplayEncoder() +{ + RegisterTest("DisplayEncoder", "Basic1", TestDisplayEncoderBasic1); + RegisterTest("DisplayEncoder", "Basic2", TestDisplayEncoderBasic2); + RegisterTest("DisplayEncoder", "Basic3", TestDisplayEncoderBasic3); + RegisterTest("DisplayEncoder", "Basic4", TestDisplayEncoderBasic4); + RegisterTest("DisplayEncoder", "CharToHex", TestCharToHex); + RegisterTest("DisplayEncoder", "HexToChar", TestHexToChar); + RegisterTest("DisplayEncoder", "StringToHex", TestStringToHex); + RegisterTest("DisplayEncoder", "HexToString", TestHexToString); + //RegisterTest("DisplayEncoder", "Unconvertable", TestUnconvertable); + //RegisterTest("DisplayEncoder", "Unprintable", TestUnprintable); + RegisterTest("DisplayEncoder", "QuoteAndBackSlash", TestQuoteAndBackSlash); +} diff --git a/src/twtest/error_t.cpp b/src/twtest/error_t.cpp index 1519fcd..114bcae 100644 --- a/src/twtest/error_t.cpp +++ b/src/twtest/error_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -44,16 +44,16 @@ void TestError() bool threw = false; try { - std::cout << "Before Exception" << std::endl; - std::cout << "Line number before throw: " << __LINE__ << std::endl; + // std::cout << "Before Exception" << std::endl; + // std::cout << "Line number before throw: " << __LINE__ << std::endl; throw eErrorGeneral(_T("This is an error!")); - std::cout << "After Exception" << std::endl; + // std::cout << "After Exception" << std::endl; } catch(eError& e) { threw = true; TEST(_tcscmp(e.GetMsg().c_str(), _T("This is an error!")) == 0); - TCOUT << _T("Exception caught!\n\nID=") << e.GetID() << _T("\n\t") << e.GetMsg() << std::endl; + // TCOUT << _T("Exception caught!\n\nID=") << e.GetID() << _T("\n\t") << e.GetMsg() << std::endl; } catch(...) { @@ -72,7 +72,7 @@ void TestError() { threw = true; TEST(_tcscmp(e.GetMsg().c_str(), _T("error_t.cpp")) == 0); - TCOUT << _T("Internal error caught!\n\nID=") << e.GetID() << _T("\n\t") << e.GetMsg() << std::endl; +// TCOUT << _T("Internal error caught!\n\nID=") << e.GetID() << _T("\n\t") << e.GetMsg() << std::endl; } catch(...) { @@ -81,3 +81,8 @@ void TestError() TEST(threw); } + +void RegisterSuite_Error() +{ + RegisterTest("Error", "Basic", TestError); +} diff --git a/src/twtest/errorbucketimpl_t.cpp b/src/twtest/errorbucketimpl_t.cpp index 1a7d96a..0ab4184 100644 --- a/src/twtest/errorbucketimpl_t.cpp +++ b/src/twtest/errorbucketimpl_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -143,3 +143,7 @@ void TestErrorBucketImpl() } +void RegisterSuite_ErrorBucketImpl() +{ + RegisterTest("ErrorBucketImpl", "Basic", TestErrorBucketImpl); +} diff --git a/src/twtest/fcocompare_t.cpp b/src/twtest/fcocompare_t.cpp index 52659c3..752a8f4 100644 --- a/src/twtest/fcocompare_t.cpp +++ b/src/twtest/fcocompare_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -62,18 +62,17 @@ static void PrintProps(const iFCO* pFCO) void TestFCOCompare() { - const TCHAR* FILE_NAME = TEMP_DIR _T("/dog.txt"); - const char* FILE_NAME_N = TEMP_DIR_N "/dog.txt"; + std::string filename = TwTestPath("dog.txt"); cDebug d("TestFCOCompare"); d.TraceDebug("Entering...\n"); // first, create an fco to compare with... - TOFSTREAM fstr(FILE_NAME_N); + TOFSTREAM fstr(filename.c_str()); if(fstr.bad()) { - d.TraceError("Unable to create test file %s!\n", FILE_NAME); + d.TraceError("Unable to create test file %s!\n", filename.c_str()); TEST(false); return; } @@ -83,7 +82,7 @@ void TestFCOCompare() // create the test FCO cFSDataSourceIter ds; - ds.SeekToFCO(cFCOName(FILE_NAME), false); + ds.SeekToFCO(cFCOName(filename), false); iFCO* pFCO = ds.CreateFCO(); TEST(pFCO); @@ -110,10 +109,10 @@ void TestFCOCompare() // change the file... d.TraceDebug("Changing the file...\n"); - fstr.open(FILE_NAME); + fstr.open(filename.c_str()); if(fstr.bad()) { - d.TraceError("Unable to reopen %s!\n", FILE_NAME_N); + d.TraceError("Unable to reopen %s!\n", filename.c_str()); TEST(false); return; } @@ -123,7 +122,7 @@ void TestFCOCompare() //need a new data source iter, otherwise the existing FCO gets updated & you get a ref to it, // and the resulting FCOs always match. cFSDataSourceIter ds2; - ds2.SeekToFCO(cFCOName(FILE_NAME), false); + ds2.SeekToFCO(cFCOName(filename), false); iFCO* pFCO2 = ds2.CreateFCO(); TEST(pFCO2); pFCO2->AcceptVisitor(&propCalc); @@ -137,7 +136,7 @@ void TestFCOCompare() //result.mPropVector.TraceContents(); cFSDataSourceIter ds3; - ds3.SeekToFCO(cFCOName(FILE_NAME), false); + ds3.SeekToFCO(cFCOName(filename), false); // try testing properties that weren't calculated... d.TraceDebug("Comparing FCOs with different properties calculated\n"); iFCO* pFCO3 = ds3.CreateFCO(); @@ -159,3 +158,8 @@ void TestFCOCompare() return; } + +void RegisterSuite_FCOCompare() +{ + RegisterTest("FCOCompare", "Basic", TestFCOCompare); +} diff --git a/src/twtest/fcodatabasefile_t.cpp b/src/twtest/fcodatabasefile_t.cpp index 829582a..0e1d19f 100644 --- a/src/twtest/fcodatabasefile_t.cpp +++ b/src/twtest/fcodatabasefile_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -32,8 +32,16 @@ // fcodatabasefile.cpp #include "tw/stdtw.h" #include "tw/fcodatabasefile.h" +#include "test.h" void TestFCODatabaseFile() { - //TODO - actually test something here + cDebug d("TestFCODatabaseFile"); + d.TraceError("Implement this!\n"); + skip("TestFCODatabaseFile not implemented"); +} + +void RegisterSuite_FCODatabaseFile() +{ + RegisterTest("FCODatabaseFile", "Basic", TestFCODatabaseFile); } diff --git a/src/twtest/fconame_t.cpp b/src/twtest/fconame_t.cpp index 551b883..674a276 100644 --- a/src/twtest/fconame_t.cpp +++ b/src/twtest/fconame_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -43,13 +43,8 @@ #include "core/archive.h" #include "fco/genreswitcher.h" -void TestFCOName() +void TestFCOName1() { -#if 0 - // the following only works w/case insensitive names - cGenreSwitcher::GetInstance()->SelectGenre( cGenre::NTFS ); -#endif - // test the relationship operator... cFCOName above (_T("/etc")); cFCOName extraDel (_T("/etc/")); @@ -87,7 +82,10 @@ void TestFCOName() TEST(_tcscmp(cat.Pop(),_T("cat")) == 0); TEST(dog.AsString().compare(cat.AsString()) == 0); TEST(dog.GetRelationship(cat) == cFCOName::REL_EQUAL); +} +void TestFCOName2() +{ cFCOName nullName; TEST(*nullName.AsString().c_str() == 0); @@ -103,28 +101,33 @@ void TestFCOName() cFCOName copyName(stringName); TEST(_tcscmp(copyName.AsString().c_str(), _T("/a/string/name")) == 0); - TCERR << "Multiple TODO tests in fconame_t.cpp" << std::endl; -#if 0 - cFCOName name(_T("new name")); + cFCOName name(_T("/new name")); nullName = name; - //TODO... TEST(_tcscmp(nullName.AsString().c_str(), _T("new name")) == 0); - - nullName = _T("newer name"); - //TODO... TEST(_tcscmp(nullName.AsString().c_str(), _T("newer name")) == 0); + TEST(_tcscmp(nullName.AsString().c_str(), _T("/new name")) == 0); + + nullName = _T("/newer name"); + TEST(_tcscmp(nullName.AsString().c_str(), _T("/newer name")) == 0); cMemoryArchive memArc; + { cSerializerImpl ser(memArc, cSerializerImpl::S_WRITE); ser.Init(); ser.WriteObject(&charName); - stringName.SetDelimiter(_T('\\')); + + //Note: backslash delimiters aren't supported (& don't work) in OST + //stringName.SetDelimiter(_T('\\')); + ser.WriteObject(&stringName); ser.Finit(); } + memArc.Seek(0, cBidirArchive::BEGINNING); + { cSerializerImpl ser(memArc, cSerializerImpl::S_READ); cFCOName name1, name2; + ser.Init(); ser.ReadObject(&name1); ser.ReadObject(&name2); @@ -132,12 +135,15 @@ void TestFCOName() TEST(name1.IsEqual(charName)); TEST(name2.IsEqual(stringName)); - TEST(! name1.IsCaseSensitive()); - TEST(! name2.IsCaseSensitive()); - TEST(name2.GetDelimiter() == _T('\\')); - TEST(name1.GetDelimiter() == _T('/')); + TEST(name1.IsCaseSensitive()); + TEST(name2.IsCaseSensitive()); + TEST(name2.GetDelimiter() == _T('/')); + TEST(name1.GetDelimiter() == _T('/')); } -#endif } - +void RegisterSuite_FCOName() +{ + RegisterTest("FCOName", "Basic1", TestFCOName1); + RegisterTest("FCOName", "Basic2", TestFCOName2); +} diff --git a/src/twtest/fconametbl_t.cpp b/src/twtest/fconametbl_t.cpp index a5ed4b2..a0e2dbd 100644 --- a/src/twtest/fconametbl_t.cpp +++ b/src/twtest/fconametbl_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -61,3 +61,8 @@ void TestFCONameTbl() pNode4->Release(); pNode5->Release(); } + +void RegisterSuite_FCONameTbl() +{ + RegisterTest("FCONameTbl", "Basic", TestFCONameTbl); +} diff --git a/src/twtest/fconametranslator_t.cpp b/src/twtest/fconametranslator_t.cpp index 878e0e5..fd4bae3 100644 --- a/src/twtest/fconametranslator_t.cpp +++ b/src/twtest/fconametranslator_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -115,3 +115,7 @@ void TestUnprintable( const TCHAR* pchName, const TCHAR* pchGenre ) TEST( fcoNameNew == fcoName ); } +void RegisterSuite_FCONameTranslator() +{ + RegisterTest("FCONameTranslator", "Basic", TestFCONameTranslator); +} diff --git a/src/twtest/fcopropimpl_t.cpp b/src/twtest/fcopropimpl_t.cpp index 11179c5..18b472d 100644 --- a/src/twtest/fcopropimpl_t.cpp +++ b/src/twtest/fcopropimpl_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -35,9 +35,9 @@ #include "core/debug.h" #include "twtest/test.h" -void TestFCOPropImpl() +void TestNumeric() { - cDebug d("TestFCOPropImpl"); + cDebug d("TestNumeric"); d.TraceDebug("Entering...\n"); // print the enum key: @@ -69,12 +69,18 @@ void TestFCOPropImpl() d.TraceDebug("333ui64 == 456ui64 = %d\n", pui64.Compare(&pui64b, iFCOProp::OP_EQ)); TEST( iFCOProp::CMP_FALSE == p2i64.Compare(&pi64, iFCOProp::OP_EQ)); - +} + +void TestStrings() +{ + cDebug d("TestStrings"); cFCOPropTSTRING pt1; cFCOPropTSTRING pt2; pt1.SetValue(TSTRING(_T("bar"))); pt2.SetValue(TSTRING(_T("foo"))); - + cFCOPropInt64 pi64; + pi64.SetValue(8675309); + d.TraceDebug(_T("property TSTRING = (should be \"bar\") %s\n"), pt1.AsString().c_str()); TEST(pt1.AsString() == "bar"); @@ -94,3 +100,8 @@ void TestFCOPropImpl() return; } +void RegisterSuite_FCOPropImpl() +{ + RegisterTest("FCOPropImpl", "Numeric", TestNumeric); + RegisterTest("FCOPropImpl", "Strings", TestStrings); +} diff --git a/src/twtest/fcopropvector_t.cpp b/src/twtest/fcopropvector_t.cpp index 6328afc..5b4bf27 100644 --- a/src/twtest/fcopropvector_t.cpp +++ b/src/twtest/fcopropvector_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -38,8 +38,8 @@ #endif static bool init (cFCOPropVector &testV); -static bool addRemove (cFCOPropVector &test1, cFCOPropVector &test2, cDebug& d); -static bool objManip (cFCOPropVector &testV, cDebug& d); +static void addRemove (cFCOPropVector &test1, cFCOPropVector &test2, cDebug& d); +static void objManip (cFCOPropVector &testV, cDebug& d); void TestFCOPropVector() { @@ -74,9 +74,8 @@ void TestFCOPropVector() } //Test ability to add and remove - TCERR << "TODO: addRemove test in fcopropvector_t.cpp" << std::endl; - // TEST(testout = addRemove (test1, test2, d)); - // d.TraceDetail("Add/Remove over all tests is %i \n", testout); + addRemove (test1, test2, d); + d.TraceDetail("Add/Remove over all tests is %i \n", testout); // test clear. d.TraceDetail("Testing Clear()\n"); @@ -93,14 +92,10 @@ void TestFCOPropVector() d.TraceDetail("Clear Test Done.\n"); //test operators - TEST(testout = objManip(test1, d)); - if (testout) - d.TraceDetail("Object manipulation tests are successful\n"); - else - d.TraceDetail("Object manipulation tests are not successful\n"); + objManip(test1, d); return; -}//end TestPropVector +} static bool init (cFCOPropVector &testV) { @@ -112,76 +107,25 @@ static bool init (cFCOPropVector &testV) return false; } //end for return true; -} //end init +} -#if 0 // TODO: rework this so it doesn't need user interaction -static bool addRemove (cFCOPropVector &test1, cFCOPropVector &test2, cDebug& d) +static void addRemove (cFCOPropVector &test1, cFCOPropVector &test2, cDebug& d) { int var1 = 0 , var2 = 64, var3 = 2; - bool local=true, out=true; - /* - bool loopvar = true; - int menu, var; - cFCOPropVector testV; - testV.SetSize(64); - while (loopvar) - { - - d.TraceAlways("\nChoose an operation to test:\n"); - d.TraceAlways("\t1)Add an item to vector.\n"); - d.TraceAlways("\t2)Remove an item from vector. \n"); - d.TraceAlways("\t3)Check vector for item. \n"); - d.TraceAlways("\t4)Display vector information \n"); - d.TraceAlways("\t5)Stop add/remove tests. \n"); - d.TraceAlways("Your choice [1-5]: "); - cin>>menu; - d.TraceAlways("\n"); - - switch (menu) - { - case 1: - d.TraceAlways("Item to add: "); - cin>> var; - d.TraceAlways("%i \n", testV.AddItem(var)); - break; - case 2: - d.TraceAlways("Item to remove: "); - cin>>var; - d.TraceAlways("%i \n", testV.RemoveItem(var)); - break; - case 3: - d.TraceAlways("Item to check: "); - cin>>var; - if (testV.ContainsItem(var)) - d.TraceAlways("\nItem present\n"); - else - d.TraceAlways("\nItem not present\n"); - break; - case 4: - testV.check(d); - break; - case 5: - loopvar = false; - break; - default: - d.TraceAlways("Not a valid menu option\n"); - break; - }//end switch - out &= local; //Keep track of results. - }//end while - */ - test1.AddItem(var1); - TEST(local &= test1.ContainsItem(var1)); //hopefully this is true! - TEST(local &= !test1.ContainsItem(var3)); + TEST(test1.ContainsItem(var1)); //hopefully this is true! + TEST(!test1.ContainsItem(var3)); + test2.SetSize(var2); - TEST(local &= (test2.GetSize() == ((var2/32)+1)*32)); - TEST(local &= (test1 != test2)); + TEST((test2.GetSize() == ((var2/32)+1)*32)); + TEST((test1 != test2)); + test1.RemoveItem(var1); test2.SetSize(test1.GetSize()); - TEST(local &= (test1 == test2)); + TEST(test1 == test2); + test1.AddItem(var3); test2 |= test1; d.TraceDetail("\nmMask should be 4!\n"); @@ -189,23 +133,19 @@ static bool addRemove (cFCOPropVector &test1, cFCOPropVector &test2, cDebug& d) test2.RemoveItem(var3); d.TraceDetail("\nmMask should be 0! \n"); test2.check(d); +} - out &= local; //and-ing of results. - return out; -}//end addRemove -#endif - -static bool objManip (cFCOPropVector &testV, cDebug& d) +static void objManip (cFCOPropVector &testV, cDebug& d) { cFCOPropVector test1, test2 = testV; - bool out = true; /*testV.check(d); test2.check(d);*/ - TEST(out &= (testV == test2)); //test operator = , == + // test operator = , == + TEST(testV == test2) test2.AddItem(1); - TEST(out &= (testV != test2)); //test operator != + TEST(testV != test2); // test operator != /*testV.check(d); test2.check(d);*/ @@ -217,12 +157,12 @@ static bool objManip (cFCOPropVector &testV, cDebug& d) test1 = testV | test2; //test operator | test1.check(d); - TEST(out&= (test1 == testV)); + TEST(test1 == testV); test2.RemoveItem(1); testV = (test2 & test1);//test operator & testV.check(d); - TEST(out&= !(test1 == testV)); + TEST( !(test1 == testV)); // test operator ^ cFCOPropVector v1, v2, v3; @@ -233,12 +173,14 @@ static bool objManip (cFCOPropVector &testV, cDebug& d) // expected result v3.AddItem(1); v3.AddItem(4); - TEST((v1 ^ v2) == v3); + TEST((v1 ^ v2) == v3); + // try with larger sizes... v2.SetSize(40); v2.Clear(); v2.AddItem(3); - TEST((v1 ^ v2) == v3); + TEST((v1 ^ v2) == v3); + v2.AddItem(38); v1.SetSize(40); v1.Clear(); @@ -248,7 +190,10 @@ static bool objManip (cFCOPropVector &testV, cDebug& d) v3.Clear(); v3.AddItem(1); v3.AddItem(3); - TEST((v1 ^ v2) == v3); + TEST((v1 ^ v2) == v3); +} - return out; -}//end objManip +void RegisterSuite_FCOPropVector() +{ + RegisterTest("FCOPropVector", "Basic", TestFCOPropVector); +} diff --git a/src/twtest/fcoreport_t.cpp b/src/twtest/fcoreport_t.cpp index 960c80d..1a91220 100644 --- a/src/twtest/fcoreport_t.cpp +++ b/src/twtest/fcoreport_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -94,92 +94,84 @@ void TestFCOReport() { cDebug d("TestFCOReport"); - try + cFCOSpecImpl* pSpec = new cFCOSpecImpl(_T("/etc"), NULL, new cFCOSpecStopPointSet); + cFCOSpecAttr* pAttr = new cFCOSpecAttr; + cFSObject* addedFCO = new cFSObject(cFCOName(_T("/etc/added_file"))); + cFSObject* removedFCO = new cFSObject(cFCOName(_T("/etc/removed_file"))); + cFSObject* changedFCO = new cFSObject(cFCOName(_T("/etc/changed_file"))); + cFSObject* oldChangedFCO = new cFSObject(cFCOName(_T("/etc/changed_file"))); + cFSObject* newChangedFCO = new cFSObject(cFCOName(_T("/etc/changed_file"))); + cFCOPropVector changedPropVector; + + //Calculate the time taken to generate the test report: + time_t* dummy_arg = NULL; + time_t time_finish; + //time_t time_begin = time(dummy_arg); + { - cFCOSpecImpl* pSpec = new cFCOSpecImpl(_T("/etc"), NULL, new cFCOSpecStopPointSet); - cFCOSpecAttr* pAttr = new cFCOSpecAttr; - cFSObject* addedFCO = new cFSObject(cFCOName(_T("/etc/added_file"))); - cFSObject* removedFCO = new cFSObject(cFCOName(_T("/etc/removed_file"))); - cFSObject* changedFCO = new cFSObject(cFCOName(_T("/etc/changed_file"))); - cFSObject* oldChangedFCO = new cFSObject(cFCOName(_T("/etc/changed_file"))); - cFSObject* newChangedFCO = new cFSObject(cFCOName(_T("/etc/changed_file"))); - cFCOPropVector changedPropVector; + cFCOReport report; - //Calculate the time taken to generate the test report: - time_t* dummy_arg = NULL; - time_t time_finish; - //time_t time_begin = time(dummy_arg); + changedPropVector.AddItem(cFSPropSet::PROP_SIZE); + pSpec->SetStartPoint(cFCOName(_T("/etc"))); + pAttr->SetName(_T("/etc")); + pAttr->SetSeverity(53); + report.AddSpec(cFS::GenreID(), pSpec, pAttr); + cFCOReportSpecIter it(report, cFS::GenreID()); + it.GetAddedSet()->Insert(addedFCO); + it.GetRemovedSet()->Insert(removedFCO); + report.AddChangedFCO(it, oldChangedFCO, newChangedFCO, changedPropVector); + + //Store the time taken to generate the test report: + time_finish = time(dummy_arg); + //report.SetCreationTime( (int64)difftime(time_finish, time_begin)); + //d.TraceDebug("Report calculation time = %I64i seconds.\n", report.GetCreationTime()); + + d.TraceDebug("Before serializing report:\n"); + TraceReport(report, d); { - cFCOReport report; + std::string filepath = TwTestPath("tmp.twr"); + cFileArchive outFile; + outFile.OpenReadWrite(filepath.c_str()); + cSerializerImpl outSer(outFile, cSerializerImpl::S_WRITE); - changedPropVector.AddItem(cFSPropSet::PROP_SIZE); - pSpec->SetStartPoint(cFCOName(_T("/etc"))); - pAttr->SetName(_T("/etc")); - pAttr->SetSeverity(53); + outSer.Init(); + outSer.WriteObject(&report); + outSer.Finit(); - report.AddSpec(cFS::GenreID(), pSpec, pAttr); - cFCOReportSpecIter it(report, cFS::GenreID()); - it.GetAddedSet()->Insert(addedFCO); - it.GetRemovedSet()->Insert(removedFCO); - report.AddChangedFCO(it, oldChangedFCO, newChangedFCO, changedPropVector); + outFile.Close(); - //Store the time taken to generate the test report: - time_finish = time(dummy_arg); - //report.SetCreationTime( (int64)difftime(time_finish, time_begin)); - //d.TraceDebug("Report calculation time = %I64i seconds.\n", report.GetCreationTime()); + cFileArchive inFile; + inFile.OpenRead(filepath.c_str()); + cSerializerImpl inSer(inFile, cSerializerImpl::S_READ); - d.TraceDebug("Before serializing report:\n"); - TraceReport(report, d); - { - cFileArchive outFile; - outFile.OpenReadWrite(_T("tmp.twr")); - cSerializerImpl outSer(outFile, cSerializerImpl::S_WRITE); + cFCOReport inReport; - outSer.Init(); - outSer.WriteObject(&report); - outSer.Finit(); + inSer.Init(); + inSer.ReadObject(&inReport); + inSer.Finit(); - outFile.Close(); - - cFileArchive inFile; - inFile.OpenRead(_T("tmp.twr")); - cSerializerImpl inSer(inFile, cSerializerImpl::S_READ); - - cFCOReport inReport; - - inSer.Init(); - inSer.ReadObject(&inReport); - inSer.Finit(); - - d.TraceDebug("Read in serialized report:\n"); - TraceReport(inReport, d); - } + d.TraceDebug("Read in serialized report:\n"); + TraceReport(inReport, d); } - - // TODO -- test cFCOReportSpecIter::Remove() - // TODO -- test cFCOReportChangeIter::Remove() - d.TraceDebug("*** We still need to test Remove() for the two iterator classes!\n"); - - pSpec->Release(); - pAttr->Release(); - addedFCO->Release(); - removedFCO->Release(); - changedFCO->Release(); - oldChangedFCO->Release(); - newChangedFCO->Release(); - } - catch(const eError& e) - { - TCERR << std::endl << e.GetMsg() << std::endl; - TEST(false); - } - catch(...) - { - TEST(false); - } - + + // TODO -- test cFCOReportSpecIter::Remove() + // TODO -- test cFCOReportChangeIter::Remove() + d.TraceDebug("*** We still need to test Remove() for the two iterator classes!\n"); + + pSpec->Release(); + pAttr->Release(); + addedFCO->Release(); + removedFCO->Release(); + changedFCO->Release(); + oldChangedFCO->Release(); + newChangedFCO->Release(); + d.TraceDebug("Leaving...\n"); } +void RegisterSuite_FCOReport() +{ + RegisterTest("FCOReport", "Basic", TestFCOReport); +} diff --git a/src/twtest/fcosetimpl_t.cpp b/src/twtest/fcosetimpl_t.cpp index ff81058..b840958 100644 --- a/src/twtest/fcosetimpl_t.cpp +++ b/src/twtest/fcosetimpl_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -75,10 +75,12 @@ void TestFCOSetImpl() pFCO3->Release(); // let's iterate over the fcos - cIterProxy pit(set.GetIter()); + iFCOIter* pIter = set.GetIter(); + cIterProxy pit(pIter); pit->SeekBegin(); PrintIter(pit, d); + // lookup a specific fco cIterProxy pit2(set.Lookup(cFCOName(_T("fco2")))); if(! (iFCOIter*)pit2) @@ -113,10 +115,14 @@ void TestFCOSetImpl() // test operator= cFCOSetImpl set2; set2 = set; - pit = set2.GetIter(); + + pIter->DestroyIter(); + pIter = set2.GetIter(); + pit = pIter; d.TraceDebug("Made a new set and set it equal to the first with operator=; printing out...\n"); PrintIter(pit, d); + // test IsEmpty set.Clear(); TEST(set.IsEmpty()); @@ -142,9 +148,14 @@ void TestFCOSetImpl() pit = set3.GetIter(); PrintIter(pit, d); + pIter->DestroyIter(); d.TraceDebug("Leaving...\n"); return; } +void RegisterSuite_FCOSetImpl() +{ + RegisterTest("FCOSetImpl", "Basic", TestFCOSetImpl); +} diff --git a/src/twtest/fcospec_t.cpp b/src/twtest/fcospec_t.cpp index d773a6f..ec391c1 100644 --- a/src/twtest/fcospec_t.cpp +++ b/src/twtest/fcospec_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -41,13 +41,14 @@ using namespace std; void TestFCOSpec() { - cout << "Begin\tTestFCOSpec" << endl; // all it seems I can test here is that the default mask works const iFCOSpecMask* pDefMask = iFCOSpecMask::GetDefaultMask(); - TEST(pDefMask->GetName().compare(TSTRING(_T("Default"))) == 0); + TEST(pDefMask->GetName().compare( TSTRING(_T("Default")) ) == 0); iFCO* pf1 = (iFCO*)0xbad, *pf2 = (iFCO*)0xcab; TEST( pDefMask->Accept(pf1) && pDefMask->Accept(pf2) ); - - cout << "End\tTestFCOSpec" << endl; - return; +} + +void RegisterSuite_FCOSpec() +{ + RegisterTest("FCOSpec", "Basic", TestFCOSpec); } diff --git a/src/twtest/fcospecattr_t.cpp b/src/twtest/fcospecattr_t.cpp index 0979dee..d483fe8 100644 --- a/src/twtest/fcospecattr_t.cpp +++ b/src/twtest/fcospecattr_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -55,48 +55,43 @@ static void TraceSpecAttr(const cFCOSpecAttr* pAttr, cDebug d) void TestFCOSpecAttr() { cDebug d("TestFCOSpecAttr"); - - try - { - d.TraceDebug("Entering\n"); - cFCOSpecAttr* pAttr = new cFCOSpecAttr; - pAttr->SetName (_T("My Name")); d.TraceDebug("Setting Name = My Name\n"); - pAttr->SetSeverity (53); d.TraceDebug("Setting Severity = 53\n"); - pAttr->AddEmail (_T("dog@bark.com")); d.TraceDebug("Adding email = dog@bark.com\n"); - pAttr->AddEmail (_T("cow@moo.com")); d.TraceDebug("Adding email = cow@moo.com\n"); - pAttr->AddEmail (_T("cat@meow.com")); d.TraceDebug("Adding email = cat@meow.com\n"); + d.TraceDebug("Entering\n"); + cFCOSpecAttr* pAttr = new cFCOSpecAttr; - // trace contents... - TraceSpecAttr(pAttr, d); + pAttr->SetName (_T("My Name")); d.TraceDebug("Setting Name = My Name\n"); + pAttr->SetSeverity (53); d.TraceDebug("Setting Severity = 53\n"); + pAttr->AddEmail (_T("dog@bark.com")); d.TraceDebug("Adding email = dog@bark.com\n"); + pAttr->AddEmail (_T("cow@moo.com")); d.TraceDebug("Adding email = cow@moo.com\n"); + pAttr->AddEmail (_T("cat@meow.com")); d.TraceDebug("Adding email = cat@meow.com\n"); - // test serialization... - d.TraceDebug("Testing Serialization; next output should be the same as the previous\n"); - cMemoryArchive a; - cSerializerImpl s(a, cSerializerImpl::S_WRITE); - s.Init(); - pAttr->Write(&s); - s.Finit(); - a.Seek(0, cBidirArchive::BEGINNING); - cFCOSpecAttr* pNew = new cFCOSpecAttr; - cSerializerImpl s2(a, cSerializerImpl::S_READ); - s2.Init(); - pNew->Read(&s2); - s2.Finit(); + // trace contents... + TraceSpecAttr(pAttr, d); - // trace contents... - TraceSpecAttr(pNew, d); + // test serialization... + d.TraceDebug("Testing Serialization; next output should be the same as the previous\n"); + cMemoryArchive a; + cSerializerImpl s(a, cSerializerImpl::S_WRITE); + s.Init(); + pAttr->Write(&s); + s.Finit(); + a.Seek(0, cBidirArchive::BEGINNING); + cFCOSpecAttr* pNew = new cFCOSpecAttr; + cSerializerImpl s2(a, cSerializerImpl::S_READ); + s2.Init(); + pNew->Read(&s2); + s2.Finit(); - pNew->Release(); - pAttr->Release(); - } - catch(const eError& e) - { - TCERR << std::endl << e.GetMsg() << std::endl; - TEST(false); - } - catch(...) - { - TEST(false); - } + // trace contents... + TraceSpecAttr(pNew, d); + + TEST( *pAttr == *pNew ); + + pNew->Release(); + pAttr->Release(); +} + +void RegisterSuite_FCOSpecAttr() +{ + RegisterTest("FCOSpecAttr", "Basic", TestFCOSpecAttr); } diff --git a/src/twtest/fcospechelper_t.cpp b/src/twtest/fcospechelper_t.cpp index 409f06f..5b86505 100644 --- a/src/twtest/fcospechelper_t.cpp +++ b/src/twtest/fcospechelper_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -129,3 +129,8 @@ void TestFCOSpecHelper() delete pHelp1; delete pHelp2; } + +void RegisterSuite_FCOSpecHelper() +{ + RegisterTest("FCOSpecHelper", "Basic", TestFCOSpecHelper); +} diff --git a/src/twtest/fcospeclist_t.cpp b/src/twtest/fcospeclist_t.cpp index 8eac699..e5557c7 100644 --- a/src/twtest/fcospeclist_t.cpp +++ b/src/twtest/fcospeclist_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -164,3 +164,7 @@ void TestFCOSpecList() return; } +void RegisterSuite_FCOSpecList() +{ + RegisterTest("FCOSpecList", "Basic", TestFCOSpecList); +} diff --git a/src/twtest/fcospecutil_t.cpp b/src/twtest/fcospecutil_t.cpp index e9d142e..4dbace8 100644 --- a/src/twtest/fcospecutil_t.cpp +++ b/src/twtest/fcospecutil_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -68,18 +68,20 @@ void TestFcoSpecUtil() pSet1->Add(removedName); TEST(! iFCOSpecUtil::FCOSpecEqual(*pSpec1, *pSpec2)); - - // TODO -- implement a more appropriate less-than test -/* pSpec1->SetStartPoint(cFCOName(_T("Dog"))); - pSpec2->AddStopPoint(cFCOName(_T("Howl"))); + pSpec1->SetStartPoint(cFCOName(_T("Dog"))); + pSet2->Add(cFCOName(_T("Dog/Howl"))); TEST(! iFCOSpecUtil::FCOSpecEqual (*pSpec1, *pSpec2)); TEST( iFCOSpecUtil::FCOSpecLessThan(*pSpec1, *pSpec2)); - pSpec1->AddStopPoint(cFCOName(_T("Howm"))); + pSet1->Add(cFCOName(_T("Dog/Howm"))); TEST( iFCOSpecUtil::FCOSpecLessThan(*pSpec2, *pSpec1)); -*/ pSpec1->Release(); pSpec2->Release(); d.TraceDebug("Leaving..\n"); } + +void RegisterSuite_FcoSpecUtil() +{ + RegisterTest("FcoSpecUtil", "Basic", TestFcoSpecUtil); +} diff --git a/src/twtest/file_t.cpp b/src/twtest/file_t.cpp index 8f0f16d..8ebc8f7 100644 --- a/src/twtest/file_t.cpp +++ b/src/twtest/file_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -38,56 +38,220 @@ #include void TestFile() -{ - try - { - TSTRING fileName = TEMP_DIR; - fileName += _T("/file_test.bin"); +{ + TSTRING fileName = TwTestPath("file_test.bin"); - //Create a temporary file for testing: - FILE* testStream; - testStream = _tfopen( fileName.c_str(), _T("w+b")); - TEST(testStream); - - TSTRING testString( _T("This is a test") ); - int iTestStringLength = testString.length(); + //Create a temporary file for testing: + FILE* testStream; + testStream = _tfopen( fileName.c_str(), _T("w+b")); + TEST(testStream); - //Write some data to the stream... - fwrite( testString.c_str(), sizeof(TCHAR), iTestStringLength, testStream ); - fclose( testStream ); + TSTRING testString( _T("This is a test") ); + int iTestStringLength = testString.length(); - //Open the file again, for reading only this time. - testStream = _tfopen( fileName.c_str(), _T("rb") ); - TEST(testStream); - - cFile fTempFile; - //Try attaching one of our file objects to the stream. - //TODO: fTempFile.AttachRead( testStream ); + //Write some data to the stream... + fwrite( testString.c_str(), sizeof(TCHAR), iTestStringLength, testStream ); + fclose( testStream ); - //Try reading something from the file object - TCHAR buffer[40]; - TCHAR buffer2[40]; - - fTempFile.Read( buffer, sizeof(TCHAR) * iTestStringLength ); - fTempFile.Close(); - - testStream = _tfopen( fileName.c_str(), _T("a+b") ); - TEST(testStream); - //TODO: fTempFile.AttachReadWrite( testStream ); - - //Now try writing something to the stream. - fTempFile.Write( testString.c_str(), sizeof(TCHAR) * iTestStringLength ); - fTempFile.Rewind(); - fTempFile.Read( buffer2, sizeof(TCHAR) * iTestStringLength * 2 ); - } - catch(const eError& e) - { - TCERR << std::endl << e.GetMsg() << std::endl; - TEST(false); - } - catch(...) - { - TEST(false); - } + //Open the file again, for reading only this time. + testStream = _tfopen( fileName.c_str(), _T("rb") ); + TEST(testStream); } +//////////////////////////////////////////////////////////////////////// + +void testDosAsPosix(const std::string& in, const std::string& expected) +{ + TEST( expected == cDosPath::AsPosix(in) ); +} + +void TestDosAsPosix() +{ + testDosAsPosix("c:\\foo", "/dev/c/foo"); + testDosAsPosix("c:\\foo\\bar\\baz.txt", "/dev/c/foo/bar/baz.txt"); + testDosAsPosix("c:/foo/bar/baz.txt", "/dev/c/foo/bar/baz.txt"); + + testDosAsPosix("c:\\", "/dev/c/"); + testDosAsPosix("c:", "/dev/c"); + + testDosAsPosix("foo.txt", "foo.txt"); + testDosAsPosix("bar\\foo.txt", "bar/foo.txt"); + testDosAsPosix("bar/foo.txt", "bar/foo.txt"); + + testDosAsPosix("/foo/bar/baz.txt", "/foo/bar/baz.txt"); +} + + +void testDosAsNative(const std::string& in, const std::string& expected) +{ + TEST( expected == cDosPath::AsNative(in) ); +} + +void TestDosAsNative() +{ + testDosAsNative("/dev/c/foo", "c:\\foo"); + testDosAsNative("/dev/c/", "c:\\"); + testDosAsNative("/dev/c", "c:\\"); + + testDosAsNative("/foo/bar/baz", "/foo/bar/baz"); +} + + +void testDosIsAbsolute(const std::string& in, bool expected) +{ + TEST( expected == cDosPath::IsAbsolutePath(in) ); +} + +void TestDosIsAbsolute() +{ + testDosIsAbsolute("C:\\", true); + testDosIsAbsolute("C:", true); + testDosIsAbsolute("C:\\foo", true); + testDosIsAbsolute("C:\\foo\\bar\\baz.txt", true); + + testDosIsAbsolute("/foo", true); + + testDosIsAbsolute("foo.txt", false); + testDosIsAbsolute("bar\\foo.txt", false); + testDosIsAbsolute("bar/foo.txt", false); +} + +void testDosBackupName(const std::string& in, const std::string& expected) +{ + TEST( expected == cDosPath::BackupName(in) ); +} + +void TestDosBackupName() +{ + testDosBackupName("C:\\12345678.123", "C:\\12345678"); + testDosBackupName("C:\\12345678", "C:\\12345678"); + testDosBackupName("C:\\1.123", "C:\\1_123"); + testDosBackupName("C:\\1", "C:\\1"); + + testDosBackupName("C:\\FOO\\12345678.123", "C:\\FOO\\12345678"); + testDosBackupName("C:\\FOO.BAR\\1234.123", "C:\\FOO.BAR\\1234_123"); +} + + +//////////////////////////////////////////////////////////////////////// +void testArosAsPosix(const std::string& in, const std::string& expected) +{ + TEST( expected == cArosPath::AsPosix(in) ); +} + +void TestArosAsPosix() +{ + testArosAsPosix("DH0:", "/DH0/"); + testArosAsPosix("DH0:Foo", "/DH0/Foo"); + testArosAsPosix("DH0:Foo/Bar", "/DH0/Foo/Bar"); + + testArosAsPosix("/DH0/Foo/Bar", "/DH0/Foo/Bar"); + + testArosAsPosix("Foo", "Foo"); + testArosAsPosix("Foo/Bar", "Foo/Bar"); +} + +void testArosAsNative(const std::string& in, const std::string& expected) +{ + TEST( expected == cArosPath::AsNative(in) ); +} + +void TestArosAsNative() +{ + testArosAsNative("/DH0", "DH0:"); + testArosAsNative("/DH0/Foo", "DH0:Foo" ); + testArosAsNative("/DH0/Foo/Bar", "DH0:Foo/Bar" ); + + testArosAsNative("DH0:Foo/Bar", "DH0:Foo/Bar"); + + testArosAsNative("Foo", "Foo"); + testArosAsNative("Foo/Bar", "Foo/Bar"); +} + +void testArosIsAbsolute(const std::string& in, bool expected) +{ + TEST( expected == cArosPath::IsAbsolutePath(in) ); +} + +void TestArosIsAbsolute() +{ + testArosIsAbsolute("DH0:", true); + testArosIsAbsolute("DH0:Foo", true); + testArosIsAbsolute("DH0:Foo/bar", true); + + testArosIsAbsolute("/DH0/Foo/bar", true); + + testArosIsAbsolute("Foo/bar", false); + testArosIsAbsolute("Foo", false); +} + + +//////////////////////////////////////////////////////////////////////// +void testRedoxAsPosix(const std::string& in, const std::string& expected) +{ + TEST( expected == cRedoxPath::AsPosix(in) ); +} + +void TestRedoxAsPosix() +{ + testRedoxAsPosix("file:/", "/file/"); + testRedoxAsPosix("file:/Foo", "/file/Foo"); + testRedoxAsPosix("file:/Foo/Bar", "/file/Foo/Bar"); + + testRedoxAsPosix("/file/Foo/Bar", "/file/Foo/Bar"); + + testRedoxAsPosix("Foo", "Foo"); + testRedoxAsPosix("Foo/Bar", "Foo/Bar"); +} + +void testRedoxAsNative(const std::string& in, const std::string& expected) +{ + TEST( expected == cRedoxPath::AsNative(in) ); +} + +void TestRedoxAsNative() +{ + testRedoxAsNative("/file", "file:/"); + testRedoxAsNative("/file/Foo", "file:/Foo" ); + testRedoxAsNative("/file/Foo/Bar", "file:/Foo/Bar" ); + + testRedoxAsNative("file:/Foo/Bar", "file:/Foo/Bar"); + + testRedoxAsNative("Foo", "Foo"); + testRedoxAsNative("Foo/Bar", "Foo/Bar"); +} + +void testRedoxIsAbsolute(const std::string& in, bool expected) +{ + TEST( expected == cRedoxPath::IsAbsolutePath(in) ); +} + +void TestRedoxIsAbsolute() +{ + testRedoxIsAbsolute("file:", true); + testRedoxIsAbsolute("file:/Foo", true); + testRedoxIsAbsolute("file:/Foo/bar", true); + + testRedoxIsAbsolute("/file/Foo/bar", true); + + testRedoxIsAbsolute("Foo/bar", false); + testRedoxIsAbsolute("Foo", false); +} + + +void RegisterSuite_File() +{ + RegisterTest("File", "Basic", TestFile); + RegisterTest("File", "DosAsPosix", TestDosAsPosix); + RegisterTest("File", "DosAsNative", TestDosAsNative); + RegisterTest("File", "DosIsAbsolute", TestDosIsAbsolute); + RegisterTest("File", "DosBackupName", TestDosBackupName); + + RegisterTest("File", "ArosAsPosix", TestArosAsPosix); + RegisterTest("File", "ArosAsNative", TestArosAsNative); + RegisterTest("File", "ArosIsAbsolute", TestArosIsAbsolute); + + RegisterTest("File", "RedoxAsPosix", TestRedoxAsPosix); + RegisterTest("File", "RedoxAsNative", TestRedoxAsNative); + RegisterTest("File", "RedoxIsAbsolute", TestRedoxIsAbsolute); +} diff --git a/src/twtest/fileheader_t.cpp b/src/twtest/fileheader_t.cpp index c561cb2..f4000b3 100644 --- a/src/twtest/fileheader_t.cpp +++ b/src/twtest/fileheader_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -126,3 +126,8 @@ void TestFileHeader() TEST(memcmp(buf, "abc123", 6) == 0); } } + +void RegisterSuite_FileHeader() +{ + RegisterTest("FileHeader", "Basic", TestFileHeader); +} diff --git a/src/twtest/fileutil_t.cpp b/src/twtest/fileutil_t.cpp index 50a98c5..007c797 100644 --- a/src/twtest/fileutil_t.cpp +++ b/src/twtest/fileutil_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -38,6 +38,8 @@ #include "util/stdutil.h" #include "util/fileutil.h" #include "core/debug.h" +#include "test.h" +#include using namespace std; @@ -47,15 +49,29 @@ using namespace std; void TestFileUtil() { - if(cFileUtil::FileExists("/etc/hosts")) - { - TSTRING source, dest; + TSTRING source = TwTestPath("copy_src"); - source = _T("/etc/hosts"); - dest = _T("/tmp/dest"); - bool blah = cFileUtil::Copy(source, dest); - (void)blah; - // TCOUT << _T("<") << wstr3 << _T(">") << std::endl; - } + //Create a temporary file for testing: + FILE* testStream; + testStream = _tfopen( source.c_str(), _T("w+b")); + TEST(testStream); + + TSTRING testString( _T("This is a test") ); + int iTestStringLength = testString.length(); + + //Write some data to the stream... + fwrite( testString.c_str(), sizeof(TCHAR), iTestStringLength, testStream ); + fclose( testStream ); + + TSTRING dest = TwTestPath("copy_dest"); + + TEST(cFileUtil::Copy(source, dest)); + + unlink(dest.c_str()); + unlink(source.c_str()); } +void RegisterSuite_FileUtil() +{ + RegisterTest("FileUtil", "Basic", TestFileUtil); +} diff --git a/src/twtest/fsdatasourceiter_t.cpp b/src/twtest/fsdatasourceiter_t.cpp index 7eb57d7..710618f 100644 --- a/src/twtest/fsdatasourceiter_t.cpp +++ b/src/twtest/fsdatasourceiter_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -36,83 +36,94 @@ #include "core/debug.h" #include "twtest/test.h" #include "fco/fco.h" +#include "fco/twfactory.h" +#include "core/errorbucketimpl.h" -/* -static void PrintDb( cHierDatabase::iterator iter, cDebug d, bool bFirst = true ) +namespace { - if( ! bFirst ) - { - iter.Descend(); - } - d.TraceDebug( "-- Processing directory %s\n", iter.GetCwd().c_str() ); +int num_processed = 0; - for( iter.SeekBegin(); ! iter.Done(); iter.Next() ) - { - d.TraceDebug( "Processing entry %s\n", iter.GetName().c_str() ); - if( iter.CanDescend() ) - { - d.TraceDebug( ">>Descending...\n" ); - PrintDb(iter, d, false); - } - } - - d.TraceDebug( "-- Done Processing directory %s\n", iter.GetCwd().c_str() ); -} -*/ - -static void PrintIter( cFSDataSourceIter iter, cDebug& d ) +void util_ProcessDir( iFCODataSourceIter* pIter ) { - // - //debug stuff - // - - if( ! iter.CanDescend() ) - { - d.TraceError( "Iterator cannot descend; returning!\n"); + TEST( ! pIter->Done() ); + TEST( pIter->CanDescend() ); + if( ! pIter->CanDescend() ) return; - } - iter.Descend(); - iter.TraceContents(); - for( iter.SeekBegin(); ! iter.Done(); iter.Next() ) + pIter->Descend(); + + for( pIter->SeekBegin(); ! pIter->Done(); pIter->Next() ) { - iFCO* pFCO = iter.CreateFCO(); + iFCO* pFCO = pIter->CreateFCO(); if( pFCO ) { - pFCO->TraceContents(); + num_processed++; pFCO->Release(); + + if( pIter->CanDescend() ) + { + TW_UNIQUE_PTR pCopy( pIter->CreateCopy() ); + util_ProcessDir( pCopy.get() ); + } } else { - d.TraceError( "*** Create of FCO failed!\n"); - } - if( iter.CanDescend() ) - { - d.TraceDebug( ">>Descending...\n" ); - PrintIter(iter, d); + fail("CreateFCO failure"); } } } +void util_ProcessDir( const cFCOName& name ) +{ + //Create a cFSDataSourceIter the same way we do in DB gen / IC + TW_UNIQUE_PTR pDSIter(iTWFactory::GetInstance()->CreateDataSourceIter()); + + cErrorQueue errorQueue; + pDSIter->SetErrorBucket(&errorQueue); + + pDSIter->SeekToFCO ( name, false ); // false means don't generate my peers... + if( ! pDSIter->Done() ) + { + iFCO* pFCO = pDSIter->CreateFCO(); + if( pFCO ) + { + num_processed++; + pFCO->Release(); + + if( pDSIter->CanDescend() ) + { + TW_UNIQUE_PTR pCopy( pDSIter->CreateCopy() ); + util_ProcessDir( pCopy.get() ); + } + } + else + { + fail("CreateFCO failure"); + } + } + + TEST( 0 == errorQueue.GetNumErrors()); + TEST( 0 < num_processed ); +} + + +} // namespace + + +////////////////////////////////////// void TestFSDataSourceIter() { - cFSDataSourceIter iter; cDebug d("TestFSDataSourceIter"); - try - { - // go to my temp directory and iterate over everything! - iter.SeekToFCO( cFCOName(_T("/tmp")) ); - // - // print out everything below the iterator - // - PrintIter( iter, d ); - } - catch( eError& e ) - { - d.TraceError( "*** Caught exception %d %s\n", e.GetID(), e.GetMsg().c_str() ); - TEST( false ); - } + + + cFCOName base(TwTestDir()); + util_ProcessDir(base); +} + +void RegisterSuite_FSDataSourceIter() +{ + RegisterTest("FSDataSourceIter", "Basic", TestFSDataSourceIter); } diff --git a/src/twtest/fsobject_t.cpp b/src/twtest/fsobject_t.cpp index bc17e42..bbdfd26 100644 --- a/src/twtest/fsobject_t.cpp +++ b/src/twtest/fsobject_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -32,8 +32,37 @@ // fsobject_t -- the file system object test driver #include "fs/stdfs.h" #include "fs/fsobject.h" +#include "fs/fspropcalc.h" +#include "test.h" +#include void TestFSObject() { - return; + cDebug d("TestFSObject"); + + cFCOName path( TwTestPath("fsobject") ); + std::ofstream fstr(path.AsString().c_str()); + if(fstr.bad()) + { + d.TraceError("Unable to create test file %s!\n", path.AsString().c_str()); + TEST(false); + } + fstr.close(); + + cFSObject obj(path); + + cFSPropCalc propCalc; + cFCOPropVector v(obj.GetPropSet()->GetValidVector().GetSize()); + for( int x=0; x < cFSPropSet::PROP_NUMITEMS; x++) + v.AddItem(x); + propCalc.SetPropVector(v); + + obj.AcceptVisitor(&propCalc); + + TEST(obj.GetPropSet()->GetNumProps() == cFSPropSet::PROP_NUMITEMS); +} + +void RegisterSuite_FSObject() +{ + RegisterTest("FSObject", "Basic", TestFSObject); } diff --git a/src/twtest/fspropcalc_t.cpp b/src/twtest/fspropcalc_t.cpp index 33df796..bb70f1e 100644 --- a/src/twtest/fspropcalc_t.cpp +++ b/src/twtest/fspropcalc_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -43,6 +43,8 @@ #include #include +#include +#include /////////////////////////////////////////////////////////////////////////////// // PrintProps -- prints out all the valid property names and values as pairs... @@ -67,8 +69,7 @@ void TestFSPropCalc() { cDebug d("TestFSPropCalc"); cFSDataSourceIter ds; - TSTRING foo_bin = TEMP_DIR; - foo_bin.append("/foo.bin"); + TSTRING foo_bin = TwTestPath("foo.bin"); //iFSServices* pFSServices = iFSServices::GetInstance(); @@ -138,3 +139,26 @@ void TestFSPropCalc() return; } + +void TestGetSymLinkStr() +{ + std::string file = TwTestPath("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); + std::string link = TwTestPath("linky"); + + int fd = creat(file.c_str(), 0777); + TEST(fd >= 0); + close(fd); + + unlink(link.c_str()); + TEST(0 == symlink(file.c_str(), link.c_str())); + + cMemoryArchive arch(1024*1024); + TEST(cFSPropCalc::GetSymLinkStr(link, arch, 8)); + TEST(arch.Length() == (int64)file.size()); +} + +void RegisterSuite_FSPropCalc() +{ + RegisterTest("FSPropCalc", "Basic", TestFSPropCalc); + RegisterTest("FSPropCalc", "GetSymLinkStr", TestGetSymLinkStr); +} diff --git a/src/twtest/fspropdisplayer_t.cpp b/src/twtest/fspropdisplayer_t.cpp index 9fa1b56..e2b5c3d 100644 --- a/src/twtest/fspropdisplayer_t.cpp +++ b/src/twtest/fspropdisplayer_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -83,11 +83,11 @@ void cTestFSPropDisplayer::Test() pPDNew->Merge( pPD ); - /* + //////////////////////// // write pd cFileArchive outFile; - outFile.OpenReadWrite(_T("c:\\tmp\\tmp.pd")); + outFile.OpenReadWrite( TwTestPath("tmp.pd").c_str() ); cSerializerImpl outSer(outFile, cSerializerImpl::S_WRITE); outSer.Init(); @@ -101,16 +101,17 @@ void cTestFSPropDisplayer::Test() //////////////////////// // read pd cFileArchive inFile; - inFile.OpenRead(_T("c:\\tmp\\tmp.pd")); + inFile.OpenRead( TwTestPath("tmp.pd").c_str() ); cSerializerImpl inSer(inFile, cSerializerImpl::S_READ); - cFSPropDisplayer* pPDNew = new cFSPropDisplayer(); + cFSPropDisplayer* pPDRead = new cFSPropDisplayer(); inSer.Init(); - pPDNew->Read( &inSer ); + pPDRead->Read( &inSer ); inSer.Finit(); - */ - + + TEST( *pPD == *pPDRead ); + TSTRING strRet; for( i = 0; i < 26; i++ ) { @@ -127,7 +128,14 @@ void cTestFSPropDisplayer::Test() d.TraceDebug("\n"); } + delete pPD; + delete pPDNew; + delete pPDRead; return; } +void RegisterSuite_FSPropDisplayer() +{ + RegisterTest("FSPropDisplayer", "Basic", TestFSPropDisplayer); +} diff --git a/src/twtest/fspropset_t.cpp b/src/twtest/fspropset_t.cpp index 6ad5803..89914d6 100644 --- a/src/twtest/fspropset_t.cpp +++ b/src/twtest/fspropset_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -38,8 +38,6 @@ /////////////////////////////////////////////////////////////////////////////// // PrintPropVector -- function that prints the contents of a cFCOPropVector -// TODO: We might want to add this functionality to the property vector some -// day... /////////////////////////////////////////////////////////////////////////////// static void PrintPropVector(const cFCOPropVector& v, cDebug& d) { @@ -94,3 +92,8 @@ void TestFSPropSet() return; } + +void RegisterSuite_FSPropSet() +{ + RegisterTest("FSPropSet", "Basic", TestFSPropSet); +} diff --git a/src/twtest/fsspec_t.cpp b/src/twtest/fsspec_t.cpp index cc6586d..c948d2f 100644 --- a/src/twtest/fsspec_t.cpp +++ b/src/twtest/fsspec_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -41,6 +41,7 @@ #include "fco/fcospechelper.h" #include "core/fsservices.h" +#include /////////////////////////////////////////////////////////////////////////////// // PrintFCOTree -- recursively prints an fco's name and all of it's children's @@ -65,23 +66,38 @@ static void PrintFCOTree(const iFCO* pFCO, cDebug d, int depth) } */ -void TestFCOSpecImpl() +void TestFCOSpecImpl1() { - cDebug d("TestFCOSpecImpl"); + cDebug d("TestFCOSpecImpl1"); d.TraceDebug("Entering...\n"); cFSDataSourceIter dataSrc; // test AllChildStopPoint fcos... - d.TraceDebug("Now testing a spec whose start point is the only thing it maps to (%s)\n", TEMP_DIR); - cFCOSpecImpl* pSpec2 = new cFCOSpecImpl(TEMP_DIR, &dataSrc, new cFCOSpecNoChildren); - pSpec2->SetStartPoint(cFCOName(TEMP_DIR)); - dataSrc.SeekToFCO(pSpec2->GetStartPoint(), false); + d.TraceDebug("Now testing a spec whose start point is the only thing it maps to (%s)\n", TwTestDir().c_str()); + cFCOSpecImpl* pSpec = new cFCOSpecImpl(TwTestDir(), &dataSrc, new cFCOSpecNoChildren); + pSpec->SetStartPoint(cFCOName(TwTestDir())); + + dataSrc.SeekToFCO(pSpec->GetStartPoint(), false); + TEST(!dataSrc.Done()); iFCO* pFCO = dataSrc.CreateFCO(); TEST(pFCO); //PrintFCOTree(pFCO, d, 0); pFCO->Release(); + pSpec->Release(); +} + +void TestFCOSpecImpl2() +{ + cDebug d("TestFCOSpecImpl2"); + d.TraceDebug("Entering...\n"); + + if( -1 == access("/etc", F_OK)) + skip("/etc not found/accessible"); + + cFSDataSourceIter dataSrc; + // create an FSSpec and set up some start and stop points... cFCOSpecStopPointSet* pSet = new cFCOSpecStopPointSet; cFCOSpecImpl* pSpec = new cFCOSpecImpl(_T("Test FSSpec"), &dataSrc, pSet); @@ -89,16 +105,21 @@ void TestFCOSpecImpl() pSet->Add(cFCOName(_T("/etc/open gl"))); pSet->Add(cFCOName(_T("/etc/pclient"))); - // create all the fcos... - cFSDataSourceIter dataSrc2; - dataSrc2.SeekToFCO(pSpec->GetStartPoint(), false); - iFCO* pFCO2 = dataSrc2.CreateFCO(); - TEST(pFCO2); + dataSrc.SeekToFCO(pSpec->GetStartPoint(), false); + TEST(!dataSrc.Done()); + iFCO* pFCO = dataSrc.CreateFCO(); + TEST(pFCO); //PrintFCOTree(pFCO, d, 0); - pFCO2->Release(); + + pFCO->Release(); // TODO -- test Clone(), copy ctor, operator= pSpec->Release(); } +void RegisterSuite_FCOSpecImpl() +{ + RegisterTest("FCOSpecImpl", "Basic1", TestFCOSpecImpl1); + RegisterTest("FCOSpecImpl", "Basic2", TestFCOSpecImpl2); +} diff --git a/src/twtest/genre_t.cpp b/src/twtest/genre_t.cpp index 666ab10..e9f3395 100644 --- a/src/twtest/genre_t.cpp +++ b/src/twtest/genre_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -33,31 +33,30 @@ // genre_t.cpp // -#include - #include "fco/stdfco.h" #include "fco/genreswitcher.h" #include "twtest/test.h" #include "fs/fs.h" -#include "fs/fsfactory.h" - -void TestGenreSwitcher() +void TestGenre() { - cDebug d("TestGenreSwitcher"); + cDebug d("TestGenre"); d.TraceDebug("Entering...\n"); - cGenreSwitcher* genreSwitcher = cGenreSwitcher::GetInstance(); + TEST(cGenreSwitcher::GetInstance()->StringToGenre(cGenreSwitcher::GetInstance()->GenreToString(cFS::GenreID())) == cFS::GenreID()); - TEST(genreSwitcher->CurrentGenre() == cFS::GenreID()); - - // can't switch to invalid genre - //genreSwitcher->SelectGenre(cGenre::GENRE_INVALID); - //TEST(genreSwitcher->CurrentGenre() == cGenre::GENRE_INVALID); + //TODO: GenreToString() dies w/ GENRE_INVALID. Figure out if this should be changed. + // + //TEST(cGenreSwitcher::GetInstance()->StringToGenre(cGenreSwitcher::GetInstance()->GenreToString(cGenre::GENRE_INVALID)) == cGenre::GENRE_INVALID); - genreSwitcher->SelectGenre(cFS::GenreID()); - TEST(genreSwitcher->CurrentGenre() == cFS::GenreID()); - TEST(typeid(*iTWFactory::GetInstance()) == typeid(cFSFactory)); + + TEST(cGenreSwitcher::GetInstance()->StringToGenre(_T("fs")) == cFS::GenreID()); + TEST(cGenreSwitcher::GetInstance()->StringToGenre(_T("none of the above")) == cGenre::GENRE_INVALID); d.TraceDebug("All tests passed.\n"); } + +void RegisterSuite_Genre() +{ + RegisterTest("Genre", "Basic", TestGenre); +} diff --git a/src/twtest/genrespeclist_t.cpp b/src/twtest/genrespeclist_t.cpp index 3e569dc..8b446c0 100644 --- a/src/twtest/genrespeclist_t.cpp +++ b/src/twtest/genrespeclist_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -91,3 +91,12 @@ void TestGenreSpecList() d.TraceDebug("All tests passed.\n"); } + +void RegisterSuite_GenreSpecList() +{ + RegisterTest("GenreSpecList", "Basic", TestGenreSpecList); +} + + + + diff --git a/src/twtest/genreswitcher_t.cpp b/src/twtest/genreswitcher_t.cpp index 3e898c3..6fbd8eb 100644 --- a/src/twtest/genreswitcher_t.cpp +++ b/src/twtest/genreswitcher_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -33,25 +33,36 @@ // genreswitcher_t.h // +#include + #include "fco/stdfco.h" #include "fco/genreswitcher.h" #include "twtest/test.h" #include "fs/fs.h" -void TestGenre() +#include "fs/fsfactory.h" + +void TestGenreSwitcher() { - cDebug d("TestGenre"); + cDebug d("TestGenreSwitcher"); d.TraceDebug("Entering...\n"); - TEST(cGenreSwitcher::GetInstance()->StringToGenre(cGenreSwitcher::GetInstance()->GenreToString(cFS::GenreID())) == cFS::GenreID()); - - //TODO: GenreToString() dies w/ GENRE_INVALID. Figure out if this should be changed. - // - //TEST(cGenreSwitcher::GetInstance()->StringToGenre(cGenreSwitcher::GetInstance()->GenreToString(cGenre::GENRE_INVALID)) == cGenre::GENRE_INVALID); - + cGenreSwitcher* genreSwitcher = cGenreSwitcher::GetInstance(); - TEST(cGenreSwitcher::GetInstance()->StringToGenre(_T("fs")) == cFS::GenreID()); - TEST(cGenreSwitcher::GetInstance()->StringToGenre(_T("none of the above")) == cGenre::GENRE_INVALID); + TEST(genreSwitcher->CurrentGenre() == cFS::GenreID()); + + // can't switch to invalid genre + //genreSwitcher->SelectGenre(cGenre::GENRE_INVALID); + //TEST(genreSwitcher->CurrentGenre() == cGenre::GENRE_INVALID); + + genreSwitcher->SelectGenre(cFS::GenreID()); + TEST(genreSwitcher->CurrentGenre() == cFS::GenreID()); + TEST(typeid(*iTWFactory::GetInstance()) == typeid(cFSFactory)); d.TraceDebug("All tests passed.\n"); } + +void RegisterSuite_GenreSwitcher() +{ + RegisterTest("GenreSwitcher", "Basic", TestGenreSwitcher); +} diff --git a/src/twtest/growheap_t.cpp b/src/twtest/growheap_t.cpp index 8178eab..abe30e7 100644 --- a/src/twtest/growheap_t.cpp +++ b/src/twtest/growheap_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -48,17 +48,17 @@ void TestGrowHeap() cGrowHeap gh( initSize, growBy, _T("growheap_t.cpp") ); // report initial state - TCOUT << _T("Initial size: ") << initSize << endl; +/* TCOUT << _T("Initial size: ") << initSize << endl; TCOUT << _T("Growby: ") << growBy << endl; TCOUT << _T("Initial Growheap memory usage: ") << gh.TotalMemUsage() << endl << endl; - +*/ const int growFactor = 5; // how much to enlarge requests each time // make it odd so we can see if the growheap // rounds to the alignment size for( size_t size = 1; size < growBy; size *= growFactor ) { // allocate memory - TCOUT << _T("Allocing by ") << size << endl; + //TCOUT << _T("Allocing by ") << size << endl; void* p = gh.Malloc( size ); TEST( p != NULL ); @@ -66,12 +66,12 @@ void TestGrowHeap() if( size > sizeof(int) ) { // read from memory - TCOUT << _T("Reading an int from memory...") << endl; + //TCOUT << _T("Reading an int from memory...") << endl; int* pi = static_cast< int* >( p ); int i = *pi; // write to memory - TCOUT << _T("Writing an int to memory...") << endl; + //TCOUT << _T("Writing an int to memory...") << endl; *pi = i; } @@ -79,21 +79,27 @@ void TestGrowHeap() if( size > sizeof(double) ) { // read from memory - TCOUT << _T("Reading a double from memory...") << endl; + //TCOUT << _T("Reading a double from memory...") << endl; double* pd = static_cast< double* >( p ); double d = *pd; // write to memory - TCOUT << _T("Writing a double to memory...") << endl; + //TCOUT << _T("Writing a double to memory...") << endl; *pd = d; } // report total usage - TCOUT << _T("Growheap memory usage: ") << gh.TotalMemUsage() << endl << endl; + //TCOUT << _T("Growheap memory usage: ") << gh.TotalMemUsage() << endl << endl; } + TEST( gh.TotalMemUsage() > 0); + // free memory gh.Clear(); TEST( gh.TotalMemUsage() == 0 ); } +void RegisterSuite_GrowHeap() +{ + RegisterTest("GrowHeap", "Basic", TestGrowHeap); +} diff --git a/src/twtest/hashtable_t.cpp b/src/twtest/hashtable_t.cpp index 4db455f..67b430e 100644 --- a/src/twtest/hashtable_t.cpp +++ b/src/twtest/hashtable_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -43,15 +43,6 @@ using namespace std; -void HashTest1(); -void HashTest2(); - -void TestHashTable(void) -{ - HashTest1(); - HashTest2(); -} - void HashTest1() { //Test the Hash table with Key = TSTRING @@ -110,7 +101,7 @@ void HashTest1() } // get statistics -#ifdef _DEBUG +#ifdef DEBUG htable.TraceDiagnostics(); #endif @@ -218,3 +209,9 @@ void HashTest2() d.TraceDebug("PASSED!\n"); } + +void RegisterSuite_HashTable() +{ + RegisterTest("HashTable", "Basic 1", HashTest1); + RegisterTest("HashTable", "Basic 2", HashTest2); +} diff --git a/src/twtest/hierdatabase_t.cpp b/src/twtest/hierdatabase_t.cpp index 22d6d49..4b87202 100644 --- a/src/twtest/hierdatabase_t.cpp +++ b/src/twtest/hierdatabase_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -35,319 +35,179 @@ #include "test.h" #include "core/error.h" -/*static void PrintDb( cHierDatabase::iterator iter, cDebug d, bool bFirst = true ) -{ - if( ! bFirst ) - { - iter.Descend(); - } - d.TraceDebug( "-- Processing directory %s\n", iter.GetCwd().c_str() ); - for( iter.SeekBegin(); ! iter.Done(); iter.Next() ) + +static const TSTRING g_block_data = "Hello World Hello World Hello World Hello World"; + + +static void AddFile(cHierDatabase::iterator& iter, const TSTRING& filename, bool with_data=false) +{ + if (iter.SeekTo(filename.c_str())) + TCOUT << "Object " << filename << " already exists!" << std::endl; + + iter.CreateEntry(filename); + + if (with_data) + { + iter.SetData( (int8*)g_block_data.c_str(), g_block_data.length() + 1 ); + } + + TEST(iter.HasData() == with_data); +} + +static void AddDirectory(cHierDatabase::iterator& iter, const TSTRING& filename) +{ + if (iter.SeekTo(filename.c_str())) + TCOUT << "Object " << filename << " already exists!" << std::endl; + + iter.CreateEntry(filename); + iter.CreateChildArray(); + + TEST(iter.CanDescend()); +} + +static void RemoveDirectory(cHierDatabase::iterator& iter, const TSTRING& filename) +{ + TCOUT << "Removing the child of " << filename << std::endl; + if( iter.SeekTo( filename.c_str() ) ) + { + iter.DeleteChildArray(); + iter.DeleteEntry(); + } + else + { + TCOUT << "Unable to find object " << filename << std::endl; + } +} + +static void RemoveFile(cHierDatabase::iterator& iter, const TSTRING& filename) +{ + TCOUT << "Removing object " << filename << std::endl; + if( iter.SeekTo( filename.c_str() ) ) { - d.TraceDebug( "Processing entry %s\n", iter.GetName() ); if( iter.CanDescend() ) { - d.TraceDebug( ">>Descending...\n" ); - PrintDb(iter, d, false); + TCOUT << "Can't delete object; it still has children." << std::endl; } - } - - d.TraceDebug( "-- Done Processing directory %s\n", iter.GetCwd().c_str() ); -}*/ - -static void GetNoun( TSTRING& noun ) -{ - static TSTRING prevNoun; - TCIN >> noun; - if( noun.compare( _T("!$") ) == 0 ) - { - noun = prevNoun; - } - prevNoun = noun; -} - -/////////////////////////////////////////////////////////////////////////////// -// TestHierDatabaseInteractive -- this provides an interactive interface to -// the database -/////////////////////////////////////////////////////////////////////////////// -void TestHierDatabaseInteractive() -{ - TCERR << std::endl << "TestHierDatabaseInteractive needs to be redesigned (& renamed) to not require user interaction" << std::endl; - -#if 0 - cDebug d( "TestHierDatabaseInteractive" ); - try - { - cHierDatabase db; - //db.Open( _T("c:/tmp/tw.hdb"), 5, true); - db.Open( _T("tw.db"), 5, false); - cHierDatabase::iterator iter(&db); - - while( true ) + else { - TSTRING verb, noun; - TCOUT << _T(">>"); - TCIN >> verb; - // - // ok, now we switch on the command... - // - //----------------------------------------------------------------- - // quit - //----------------------------------------------------------------- - if( verb.compare( _T("quit") ) == 0 ) - { - // the quit command... - break; - } - //----------------------------------------------------------------- - // print - //----------------------------------------------------------------- - if( verb.compare( _T("print") ) == 0 ) - { - // the print command... - ASSERT( false ); - // TODO -- Implement this! - } - //----------------------------------------------------------------- - // mkdir - //----------------------------------------------------------------- - else if( verb.compare( _T("mkdir") ) == 0 ) - { - GetNoun(noun); - TCOUT << "Making a child of " << noun << std::endl; - if( iter.SeekTo( noun.c_str() ) ) - { - iter.CreateChildArray(); - } - else - { - TCOUT << "Unable to find object " << noun << std::endl; - } - } - //----------------------------------------------------------------- - // mk - //----------------------------------------------------------------- - else if( verb.compare( _T("mk") ) == 0 ) - { - GetNoun(noun); - TCOUT << "Making object " << noun << std::endl; - if( iter.SeekTo( noun.c_str() ) ) - { - TCOUT << "Error: object already exists!" << std::endl; - } - else - { - iter.CreateEntry( noun ); - } - } - //----------------------------------------------------------------- - // rmdir - //----------------------------------------------------------------- - else if( verb.compare( _T("rmdir") ) == 0 ) - { - GetNoun(noun); - TCOUT << "Removing the child of " << noun << std::endl; - if( iter.SeekTo( noun.c_str() ) ) - { - //TODO -- check that it has an empty child - iter.DeleteChildArray(); - } - else - { - TCOUT << "Unable to find object " << noun << std::endl; - } - } - //----------------------------------------------------------------- - // rm - //----------------------------------------------------------------- - else if( verb.compare( _T("rm") ) == 0 ) - { - GetNoun(noun); - TCOUT << "Removing object " << noun << std::endl; - if( iter.SeekTo( noun.c_str() ) ) - { - if( iter.CanDescend() ) - { - TCOUT << "Can't delete object; it still has children." << std::endl; - } - else - { - iter.DeleteEntry(); - } - } - else - { - TCOUT << "Unable to find object " << noun << std::endl; - } - } - //----------------------------------------------------------------- - // pwd - //----------------------------------------------------------------- - else if( verb.compare( _T("pwd") ) == 0 ) - { - TCOUT << iter.GetCwd() << std::endl; - } - //----------------------------------------------------------------- - // ls - //----------------------------------------------------------------- - else if( verb.compare( _T("ls") ) == 0 ) - { - int cnt = 0; - for( iter.SeekBegin(); ! iter.Done(); iter.Next(), cnt++ ) - { - TCOUT << "[" << cnt ; - if( iter.CanDescend() ) - { - TCOUT << "]*\t" ; - } - else - { - TCOUT << "]\t" ; - } - TCOUT << iter.GetName() << std::endl; - } - } - //----------------------------------------------------------------- - // cd - //----------------------------------------------------------------- - else if( verb.compare( _T("cd") ) == 0 ) - { - GetNoun(noun); - if( noun.compare( _T("..") ) == 0 ) - { - if( iter.AtRoot() ) - { - TCOUT << "Can't ascend above root." << std::endl; - } - else - { - TCOUT << "Ascending..." << std::endl; - iter.Ascend(); - } - } - else - { - if( iter.SeekTo( noun.c_str() ) ) - { - if( iter.CanDescend() ) - { - TCOUT << "Descending into " << noun << std::endl; - iter.Descend(); - } - else - { - TCOUT << noun << " has no children; can't descend." << std::endl; - } - } - else - { - TCOUT << "Unable to find object " << noun << std::endl; - } - } - } - //----------------------------------------------------------------- - // rmdir - //----------------------------------------------------------------- - else if( verb.compare( _T("rmdir") ) == 0 ) - { - GetNoun(noun); - if( iter.SeekTo( noun.c_str() ) ) - { - if( iter.CanDescend() ) - { - TCOUT << "Deleting child of " << iter.GetName() << std::endl; - iter.DeleteChildArray(); - } - else - { - TCOUT << noun << " has no child; can't delete." << std::endl; - } - } - - } - //----------------------------------------------------------------- - // rm - //----------------------------------------------------------------- - else if( verb.compare( _T("rm") ) == 0 ) - { - GetNoun(noun); - if( iter.SeekTo( noun.c_str() ) ) - { - if( iter.CanDescend() ) - { - TCOUT << noun << " doesn't exist; can't delete." << std::endl; - } - else - { - TCOUT << "Deleting " << iter.GetName() << std::endl; - iter.DeleteEntry(); - } - } - - } - //----------------------------------------------------------------- - // set - //----------------------------------------------------------------- - else if( verb.compare( _T("set") ) == 0 ) - { - GetNoun(noun); - if( iter.SeekTo( noun.c_str() ) ) - { - if( iter.HasData() ) - { - iter.RemoveData(); - } - TSTRING data; - TCIN >> data; - iter.SetData( (int8*)data.c_str(), data.length() + 1 ); - TCOUT << "Setting " << noun << "'s data to " << data << std::endl; - } - else - { - TCOUT << "Can't find object " << noun << std::endl; - } - - } - //----------------------------------------------------------------- - // get - //----------------------------------------------------------------- - else if( verb.compare( _T("get") ) == 0 ) - { - GetNoun(noun); - if( iter.SeekTo( noun.c_str() ) ) - { - if( ! iter.HasData() ) - { - TCOUT << "Object has no data!" << std::endl; - } - else - { - int32 dummyLength; - TCOUT << noun << "'s data is: " << (TCHAR*)iter.GetData(dummyLength) << std::endl; - } - } - else - { - TCOUT << "Can't find object " << noun << std::endl; - } - - } - - // make sure the file is still valid... - // -#ifdef _BLOCKFILE_DEBUG - db.AssertAllBlocksValid() ; -#endif + iter.RemoveData(); + iter.DeleteEntry(); } - - TCOUT << "Exiting..." << std::endl; - } - catch( eError& e ) + else { - d.TraceError( "Exception caught: %d %s\n", e.GetID(), e.GetMsg().c_str() ); - TEST( false ); + TCOUT << "Unable to find object " << filename << std::endl; } +} + +static void ChDir(cHierDatabase::iterator& iter, const TSTRING& filename) +{ + if( filename.compare( _T("..") ) == 0 ) + { + if( iter.AtRoot() ) + TCOUT << "At root already" << std::endl; + + TCOUT << "Ascending..." << std::endl; + iter.Ascend(); + } + else + { + if( iter.SeekTo( filename.c_str() ) ) + { + if( !iter.CanDescend()) + TCOUT << filename << " has no children; can't descend." << std::endl; + + TCOUT << "Descending into " << filename << std::endl; + iter.Descend(); + } + else + { + TCOUT << "Unable to find object " << filename << std::endl; + } + } +} + +static void AssertData(cHierDatabase::iterator& iter, const TSTRING& filename, bool should_have) +{ + bool exists = iter.SeekTo( filename.c_str() ); + TEST(exists == should_have); + + if (exists) + { + bool has_data = iter.HasData(); + TEST(has_data == should_have); + + if (has_data) + { + int32 dummyLength; + TSTRING read_str( (TCHAR*)iter.GetData(dummyLength) ); + TEST(read_str == g_block_data); + } + } +} + +static void AssertExists(cHierDatabase::iterator& iter, const TSTRING& filename, bool should_have) +{ + bool exists = iter.SeekTo( filename.c_str() ); + TEST(exists == should_have); +} + +static void AssertChildren(cHierDatabase::iterator& iter, const TSTRING& filename, bool should_have) +{ + bool exists = iter.SeekTo( filename.c_str() ); + + if (exists) + { + bool has_children = iter.CanDescend(); + TEST(has_children == should_have); + } +} + +void TestHierDatabaseBasic() +{ + cHierDatabase db; + db.Open( _T("test.db"), 5, true); + cHierDatabase::iterator iter(&db); + + AddFile(iter, "file1", true); + AddFile(iter, "file2", false); + AddFile(iter, "file3", false); + + AddDirectory(iter, "dir1"); + AddDirectory(iter, "dir2"); + AddDirectory(iter, "dir3"); + + AssertData(iter, "file1", true); + + ChDir(iter, "dir1"); + AddFile(iter, "dir1_file1"); + ChDir(iter, ".."); + + RemoveFile(iter, "file1"); + RemoveFile(iter, "file2"); + + AssertExists(iter, "file1", false); + AssertExists(iter, "file2", false); + AssertExists(iter, "file3", true); + + RemoveDirectory(iter, "dir2"); + + AssertExists(iter, "dir1", true); + AssertExists(iter, "dir2", false); + AssertExists(iter, "dir3", true); + + AssertChildren(iter, "dir1", true); + AssertChildren(iter, "dir3", true); + AssertChildren(iter, "file3", false); + +#ifdef DEBUG + db.AssertAllBlocksValid(); #endif } + +void RegisterSuite_HierDatabase() +{ + RegisterTest("HierDatabase", "Basic", TestHierDatabaseBasic); +} + diff --git a/src/twtest/keyfile_t.cpp b/src/twtest/keyfile_t.cpp index fa6f79d..cae960a 100644 --- a/src/twtest/keyfile_t.cpp +++ b/src/twtest/keyfile_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -107,18 +107,19 @@ void TestKeyFile() elGamal.SetVerifying(keyfile2.GetPublicKey()); elGamal.ProcessBlock(ciphertext, recovered_text); - + TEST(memcmp(recovered_text, plaintext, elGamal.GetBlockSizePlain()) == 0); + delete [] pMem; } // save to and read from disk d.TraceDebug("Read/Write to file...\n"); { - keyfile.WriteFile(TEMP_DIR _T("/keyfile.key")); + keyfile.WriteFile(TwTestPath("keyfile.key").c_str()); cKeyFile keyfile2; TEST(!keyfile2.KeysLoaded()); - keyfile2.ReadFile(TEMP_DIR _T("/keyfile.key")); + keyfile2.ReadFile(TwTestPath("keyfile.key").c_str()); TEST(keyfile2.KeysLoaded()); cElGamalSig elGamal(*keyfile2.GetPublicKey()); @@ -133,3 +134,7 @@ void TestKeyFile() return; } +void RegisterSuite_KeyFile() +{ + RegisterTest("KeyFile", "Basic", TestKeyFile); +} diff --git a/src/twtest/platform_t.cpp b/src/twtest/platform_t.cpp index bd40342..4cb4b21 100644 --- a/src/twtest/platform_t.cpp +++ b/src/twtest/platform_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -39,6 +39,10 @@ #include "twtest/test.h" #include "core/error.h" +#if HAVE_SYS_UTSNAME_H +#include +#endif + using namespace std; ///////////////////////////////////////////////////////// @@ -68,16 +72,6 @@ class AlignMe byte a[sizeof(int64)+ALIGN_SIZE]; // we want to be able to access a int64 at address [ALIGN_SIZE] }; -///////////////////////////////////////////////////////// -// MAIN TEST FUNCTION -///////////////////////////////////////////////////////// - -void TestPlatform() -{ - TestAlignment(); - TestSizes(); -} - ///////////////////////////////////////////////////////// // TEMPLATIZED UTIL CLASSES IMPLEMENTATIONS ///////////////////////////////////////////////////////// @@ -91,8 +85,8 @@ AlignMe::AlignMe() // to have any need for that behavior, which begs the question of why // this test exists in the first place. // -bcox -#if (!IS_HPUX) - TCOUT << _T("Testing alignment of size ") << ALIGN_SIZE << std::endl; +#if (!IS_HPUX && !IS_SOLARIS) //Turns out Solaris SPARC is unhappy with this test too, btw + //TCOUT << _T("Testing alignment of size ") << ALIGN_SIZE << std::endl; // access a double in the byte array to see if it is aligned. if it isn't and the CPU // can't handle it, you'll get a bus error @@ -100,11 +94,11 @@ AlignMe::AlignMe() // this should choke if the CPU can't // handle misaligned memory access int32* pi = (int32*)&a[ALIGN_SIZE]; - TCOUT << _T("Testing alignment of an int32...") << std::endl; - TCOUT << _T("Reading...") << std::endl; + //TCOUT << _T("Testing alignment of an int32...") << std::endl; + //TCOUT << _T("Reading...") << std::endl; int32 i = *pi; // access memory for read - TCOUT << _T("Read succeeded.") << std::endl; - TCOUT << _T("Writing...") << std::endl; + //TCOUT << _T("Read succeeded.") << std::endl; + //TCOUT << _T("Writing...") << std::endl; *pi = i; // access memory for write TCOUT << _T("Write succeeded.") << std::endl; @@ -112,17 +106,21 @@ AlignMe::AlignMe() // this should choke if the CPU can't // handle misaligned memory access int64* pb = (int64*)&a[ALIGN_SIZE]; - TCOUT << _T("Testing alignment of an int64...") << std::endl; - TCOUT << _T("Reading...") << std::endl; + //TCOUT << _T("Testing alignment of an int64...") << std::endl; + //TCOUT << _T("Reading...") << std::endl; int64 I = *pb; // access memory for read - TCOUT << _T("Read succeeded") << std::endl; - TCOUT << _T("Writing...") << std::endl; + //TCOUT << _T("Read succeeded") << std::endl; + //TCOUT << _T("Writing...") << std::endl; *pb = I; // access memory for write - TCOUT << _T("Write succeeded.") << std::endl; -#endif + //TCOUT << _T("Write succeeded.") << std::endl; + - TCOUT << _T("Alignment of ") << ALIGN_SIZE << _T(" ") << ( ALIGN_SIZE == 1 ? _T("byte") : _T("bytes") ) << _T(" is OK") << std::endl - << _T("=========================================\n"); + /*TCOUT << _T("Alignment of ") << ALIGN_SIZE << _T(" ") << ( ALIGN_SIZE == 1 ? _T("byte") : _T("bytes") ) << _T(" is OK") << std::endl + << _T("=========================================\n"); */ + + TEST("Aligned"); // The actual test is not bus erroring up above; this just tells the framework we tested something. + +#endif } @@ -137,8 +135,8 @@ void TestAlignment() // The last AlignMe to be successfully constructed // - - - - - - - - - - - - - - - - - - - - - - - TCOUT << _T("Testing for byte alignment\n") - << _T("=========================================\n"); +// TCOUT << _T("Testing for byte alignment\n") +// << _T("=========================================\n"); AlignMe<128> a128; AlignMe<64> a64; @@ -162,10 +160,10 @@ void TestAlignment() a[0] = 0xAB; - TCOUT << _T("=========================================\n") +/* TCOUT << _T("=========================================\n") << _T("About to test memory access off by 1 byte\n") << _T("If you do not see a confirmation after this line, the test choked") - << std::endl; + << std::endl; */ // this should choke if the CPU can't // handle misaligned memory access @@ -173,6 +171,7 @@ void TestAlignment() *pi = *pi; // misaligned access (read and write) TCOUT << _T("Misaligned access OK.") << std::endl; + TEST("Misaligned ok"); //again, the test is not exploding up above // - - - - - - - - - - - - - - - - - - - - - - // make sure our BYTE_ALIGN value is correct -- @@ -185,36 +184,40 @@ void TestAlignment() // this should be fine b[0] = 0xAB; - TCOUT << _T("=========================================\n") +/* TCOUT << _T("=========================================\n") << _T("About to test memory access off by ") << BYTE_ALIGN << _T(" ") << ( BYTE_ALIGN == 1 ? _T("byte") : _T("bytes") ) << std::endl << _T("If you do not see a confirmation after this line, the test choked") << std::endl; - +*/ // this should choke if the CPU can't // handle misaligned memory access pi = (int32*)&b[BYTE_ALIGN]; *pi = *pi; // aligned (hopefully) access (read and write) - TCOUT << _T("Aligned access OK. BYTE_ALIGN value of ") << BYTE_ALIGN << _T(" is good.") << std::endl; +/* TCOUT << _T("Aligned access OK. BYTE_ALIGN value of ") << BYTE_ALIGN << _T(" is good.") << std::endl; TCOUT << _T("=========================================\n"); + TEST("BYTE_ALIGN ok"); // yet again, the test is not falling over a couple of lines up. */ } +// Not sure this is a super valuable test, since it just verifies that builtin integer types +// work the way we think they do. void TestSizes() { - /* - TEST( CanBeRepresentedAs( char(), char() ) ); - TEST( CanBeRepresentedAs( char(), unsigned char() ) ); - TEST( CanBeRepresentedAs( unsigned char(), char() ) ); - TEST( CanBeRepresentedAs( unsigned char(), unsigned char() ) ); - TEST( CanBeRepresentedAs( signed char(), char() ) ); - TEST( CanBeRepresentedAs( char(), signed char() ) ); - TEST( CanBeRepresentedAs( signed char(), signed char() ) ); - TEST( CanBeRepresentedAs( signed char(), unsigned char() ) ); - TEST( CanBeRepresentedAs( char(), signed char() ) ); - */ + TEST( CanBeRepresentedAs( int8(), int8() ) ); + TEST( ! CanBeRepresentedAs( int8(), uint8() ) ); + TEST( ! CanBeRepresentedAs( uint8(), int8() ) ); + TEST( CanBeRepresentedAs( uint8(), uint8() ) ); + + TEST( CanBeRepresentedAs( int8(), int16() ) ); + TEST( CanBeRepresentedAs( int16(), int32() ) ); + TEST( CanBeRepresentedAs( int32(), int64() ) ); + + TEST( CanBeRepresentedAs( uint8(), uint16() ) ); + TEST( CanBeRepresentedAs( uint16(), uint32() ) ); + TEST( CanBeRepresentedAs( uint32(), uint64() ) ); } - + ///////////////////////////////////////////////////////// // TEMPLATIZED UTIL FUNCTION IMPEMENTATIONS ///////////////////////////////////////////////////////// @@ -232,3 +235,92 @@ bool CanBeRepresentedAs( E e, T t ) return fReturn; } + + +//////////////////////////// + +#if IS_LINUX +const TSTRING expected_os("Linux"); +#elif IS_DARWIN +const TSTRING expected_os("Darwin"); +#elif IS_CYGWIN +const TSTRING expected_os("Cygwin"); +#elif IS_DOS_DJGPP +const TSTRING expected_os("FreeDOS"); // This will likely fail for other DOS flavors +#elif IS_ANDROID +const TSTRING expected_os("Android"); +#elif IS_DRAGONFLYBSD +const TSTRING expected_os("DragonFly"); +#elif IS_MIDNIGHTBSD +const TSTRING expected_os("MidnightBSD"); +#elif IS_FREEBSD +const TSTRING expected_os("FreeBSD"); +#elif IS_NETBSD +const TSTRING expected_os("NetBSD"); +#elif IS_MIRBSD +const TSTRING expected_os("MirBSD"); +#elif IS_BITRIG +const TSTRING expected_os("Bitrig"); +#elif IS_LIBERTYBSD +const TSTRING expected_os("LibertyBSD"); +#elif IS_OPENBSD +const TSTRING expected_os("OpenBSD"); +#elif IS_SOLARIS +const TSTRING expected_os("SunOS"); +#elif IS_AIX +const TSTRING expected_os("AIX"); +#elif IS_HPUX +const TSTRING expected_os("HP-UX"); +#elif IS_IRIX +const TSTRING expected_os("IRIX"); +#elif IS_OSF1 +const TSTRING expected_os("Tru64"); +#elif IS_MINIX +const TSTRING expected_os("Minix"); +#elif IS_HURD +const TSTRING expected_os("GNU"); +#elif IS_HAIKU +const TSTRING expected_os("Haiku"); +#elif IS_SYLLABLE +const TSTRING expected_os("Syllable"); +#elif IS_SKYOS +const TSTRING expected_os("SkyOS"); +#elif IS_SORTIX +const TSTRING expected_os("Sortix"); +#elif IS_MINT +const TSTRING expected_os("MiNT"); +#elif IS_AROS +const TSTRING expected_os("AROS"); +#elif IS_RTEMS +const TSTRING expected_os("RTEMS"); +#elif IS_RISCOS +const TSTRING expected_os("RISC OS"); +#elif IS_RISCOS +const TSTRING expected_os("Redox"); +#elif IS_QNX +const TSTRING expected_os("QNX"); +#else +const TSTRING expected_os("?!?!?"); +#endif + +void TestPlatformDetection() +{ +#if HAVE_SYS_UTSNAME_H + struct utsname os_info; + TEST( uname(&os_info) == 0); + + TSTRING observed_os(os_info.sysname); + + if ( observed_os != expected_os ) + TCERR << "Expected OS: " << expected_os << " | Observed OS: " << observed_os << std::endl; + + TEST( observed_os == expected_os ); +#endif +} + +void RegisterSuite_Platform() +{ + RegisterTest("Platform", "Alignment", TestAlignment); + RegisterTest("Platform", "Sizes", TestSizes); + RegisterTest("Platform", "PlatformDetection", TestPlatformDetection); +} diff --git a/src/twtest/policyparser_t.cpp b/src/twtest/policyparser_t.cpp index 8a5c3c5..6dfba0f 100644 --- a/src/twtest/policyparser_t.cpp +++ b/src/twtest/policyparser_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -45,7 +45,9 @@ #include "fco/fcospeclist.h" #include "twtest/test.h" #include "util/fileutil.h" + #include +#include // helper class that checks output of each fcospec class cPolicyParserTester { @@ -66,39 +68,34 @@ TSTRING get_test_file_dir() void test_policy_file(const std::string& polfile) { - try - { - cDebug::AddOutTarget(cDebug::OUT_STDOUT); - - TSTRING pol_path = get_test_file_dir(); - pol_path.append("/"); - pol_path.append(polfile); - - std::ifstream in; - in.open(pol_path.c_str()); - if( ! in.good() ) - throw eParserHelper( _T("couldn't open test file") ); - - cPolicyParser parser( in ); - - cGenreSpecListVector policy; - cErrorQueue errorQ; - cErrorReporter errorR; - cErrorTracer errorT; - - // set up an error bucket that will spit things to stderr - errorT.SetChild( &errorR ); - errorQ.SetChild( &errorT ); - - parser.Execute( policy, &errorQ ); - - } - catch(eError& e) - { - TCERR << (int)e.GetID() << " : " << e.GetMsg().c_str() << std::endl; - return; - } + cDebug::AddOutTarget(cDebug::OUT_STDOUT); + TSTRING pol_path = get_test_file_dir(); + pol_path.append("/"); + pol_path.append(polfile); + + if(-1 == access(pol_path.c_str(), F_OK)) + skip("policy parser test file not found/accessible"); + + std::ifstream in; + in.open(pol_path.c_str()); + if( ! in.good() ) + throw eParserHelper( _T("couldn't open test file") ); + + cPolicyParser parser( in ); + + cGenreSpecListVector policy; + cErrorQueue errorQ; + cErrorReporter errorR; + cErrorTracer errorT; + + // set up an error bucket that will spit things to stderr + errorT.SetChild( &errorR ); + errorQ.SetChild( &errorT ); + + parser.Execute( policy, &errorQ ); + TEST("No exceptions thrown in cPolicyParser::Execute"); + TCERR << "Parsed policy test file " << polfile << std::endl; return; } @@ -110,6 +107,9 @@ void TestPolicyParser() cDebug d("TestPolicyParser()"); test_policy_file("pol.txt"); + + TCERR << "TestPolicyParser: Parser needs work to be able to test more than one policy" << std::endl; + // test_policy_file("directives.txt"); //fails unless you substitute your hostname for 'your_host' in this file // TODO: test currently segfaults if you create more than one policy parser in a process. (Not a real world scenario). @@ -119,4 +119,7 @@ void TestPolicyParser() test_policy_file("polruleattr.txt"); */ } - +void RegisterSuite_PolicyParser() +{ + RegisterTest("PolicyParser", "Basic", TestPolicyParser); +} diff --git a/src/twtest/refcountobj_t.cpp b/src/twtest/refcountobj_t.cpp index 4d81267..610eab8 100644 --- a/src/twtest/refcountobj_t.cpp +++ b/src/twtest/refcountobj_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -33,6 +33,7 @@ #include "core/stdcore.h" #include "core/refcountobj.h" #include "core/debug.h" +#include "test.h" class cRefCountTestObj : public cRefCountObj { @@ -66,7 +67,7 @@ cRefCountTestObj::~cRefCountTestObj() mChildren.pop_front(); } - delete mpSomeMem; + delete [] mpSomeMem; } void cRefCountTestObj::AddChild(cRefCountTestObj* pChild) @@ -157,12 +158,20 @@ void TestRefCountObj() } } - //These fields only exist in debug builds, so we can't use TEST() here. - ASSERT(cRefCountObj::objectCounter == 0); - ASSERT(cRefCountObj::referenceCounter == 0); +#ifdef DEBUG + //These fields only exist in debug builds + TEST(cRefCountObj::objectCounter == 0); + TEST(cRefCountObj::referenceCounter == 0); +#else + TEST("This test can only make useful assertions in debug builds"); +#endif db.TraceAlways("Done...\n"); return; } +void RegisterSuite_RefCountObj() +{ + RegisterTest("RefCountObj", "Basic", TestRefCountObj); +} diff --git a/src/twtest/resources_t.cpp b/src/twtest/resources_t.cpp index 94332cf..9a35abb 100644 --- a/src/twtest/resources_t.cpp +++ b/src/twtest/resources_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -84,17 +84,18 @@ TSS_ImplementPackage( cTestResources ) void TestResources() { TSS_Package( cTestResources ).Count( 20 ); - - TCOUT << _T("Package::Count(") << TSS_Package( cTestResources ).Count() << _T(")\n" ) << std::endl; - TCOUT << TSS_GetString( cTestResources, test::IDS_TEST1 ) << std::endl; - TCOUT << TSS_GetString( cTestResources, test::IDS_TEST2 ) << std::endl; - TCOUT << TSS_GetString( cTestResources, test::IDS_TEST3 ) << std::endl; - TCOUT << TSS_GetString( cTestResources, test::IDS_INVALID ) << std::endl; - + TEST( TSS_Package( cTestResources ).Count() == 20) ; + TEST( TSS_GetString( cTestResources, test::IDS_TEST1 ) == _T("Test String 1") ); + TEST( TSS_GetString( cTestResources, test::IDS_TEST2 ) == _T("Test String 2") ); + TEST( TSS_GetString( cTestResources, test::IDS_TEST3 ) == _T("Test String 3") ); + TEST( TSS_GetString( cTestResources, test::IDS_INVALID ) == _T("") ); + TEST( TSS_GetString( cTestResources, 42 ) == _T("") ); +} +void RegisterSuite_Resources() +{ + RegisterTest("Resources", "Basic", TestResources); } -// eof: tss.resources_t.cpp - diff --git a/src/twtest/serializer_t.cpp b/src/twtest/serializer_t.cpp index abd10d1..498a2c9 100644 --- a/src/twtest/serializer_t.cpp +++ b/src/twtest/serializer_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -38,6 +38,7 @@ #include "core/stdcore.h" #include "core/serializer.h" #include "core/serializable.h" +#include "test.h" // The reading and writing functionality of the serializer is tested in // serializerimpl_t.cpp, so there's very little to be done here. @@ -70,4 +71,12 @@ cSerTestObject::cSerTestObject() void TestSerializer() { cSerTestObject test_obj; + + TEST( std::string(test_obj.GetType().AsString()) == std::string("cSerTestObject") ); + TEST( test_obj.Version() == 1); +} + +void RegisterSuite_Serializer() +{ + RegisterTest("Serializer", "Basic", TestSerializer); } diff --git a/src/twtest/serializerimpl_t.cpp b/src/twtest/serializerimpl_t.cpp index b461c6f..7762abf 100644 --- a/src/twtest/serializerimpl_t.cpp +++ b/src/twtest/serializerimpl_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -119,7 +119,7 @@ void TestSerializerImpl() // writing { cFileArchive file; - file.OpenReadWrite(TEMP_DIR _T("/tmp.bin")); + file.OpenReadWrite(TwTestPath("tmp.bin").c_str()); cSerializerImpl serializer(file, cSerializerImpl::S_WRITE); serializer.Init(); @@ -127,16 +127,16 @@ void TestSerializerImpl() cSerializerTestObject testobj; testobj.Write(&serializer); - db.TraceAlways(" Writeing object 1...\n"); + db.TraceAlways(" Writing object 1...\n"); serializer.WriteObject(&testobj); - db.TraceAlways(" Writeing object 2...\n"); + db.TraceAlways(" Writing object 2...\n"); serializer.WriteObject(&testobj); - db.TraceAlways(" Writeing object 3...\n"); + db.TraceAlways(" Writing object 3...\n"); serializer.WriteObject(&testobj); - db.TraceAlways(" Writeing object 4...\n"); + db.TraceAlways(" Writing object 4...\n"); serializer.WriteObject(&testobj); serializer.Finit(); @@ -145,7 +145,7 @@ void TestSerializerImpl() // reading { cFileArchive file; - file.OpenRead(TEMP_DIR _T("/tmp.bin")); + file.OpenRead(TwTestPath("tmp.bin").c_str()); cSerializerImpl serializer(file, cSerializerImpl::S_READ); serializer.Init(); @@ -178,3 +178,7 @@ void TestSerializerImpl() return; } +void RegisterSuite_SerializerImpl() +{ + RegisterTest("SerializerImpl", "Basic", TestSerializerImpl); +} diff --git a/src/twtest/signature_t.cpp b/src/twtest/signature_t.cpp index a02a2ec..b9dcd43 100644 --- a/src/twtest/signature_t.cpp +++ b/src/twtest/signature_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -43,11 +43,38 @@ using namespace std; -void TestSignature() +std::string getTestFile() +{ + // Create a file for which we know the signatures + // + //% siggen ~/signature_test.bin + //crc : AAAAAAAAAAy + //md5 : B/Y8ttBnlyw/NPCUu353ao + //crc32 : B1kP9v + //sha : Oia1aljHD793tfj7M55tND+3OG/ + //haval : BL6bFSo0EP5zf8lGSueeed + + static TSTRING sigFileName; + + if (sigFileName.empty()) + { + sigFileName = TwTestPath("signature_test.bin"); + + cFileArchive fileArc; + fileArc.OpenReadWrite(sigFileName.c_str()); + fileArc.WriteBlob("\x1\x2\x3\x4\x5\x6\x7\x8\x9\x0", 10); + fileArc.Close(); + } + + return sigFileName; +} + + +void TestSignatureBasic() { // Signature usage example (?) cCRC32Signature crcSig; - cDebug d("TestSignature"); + cDebug d("TestSignature1"); byte abData[ 64 ]; int i; @@ -58,7 +85,6 @@ void TestSignature() crcSig.Update( &abData[0], 32 ); crcSig.Update( &abData[32], 32 ); crcSig.Finit(); - TCOUT << _T("new way: ") << crcSig.AsString() << endl; cMemoryArchive arch; arch.WriteBlob( &abData[0], 32 ); @@ -69,33 +95,19 @@ void TestSignature() asg.AddSig( &crc ); asg.CalculateSignatures( arch ); - TCOUT << _T("old way: ") << crc.AsString() << endl; - + TEST( crc.AsStringHex() == crcSig.AsStringHex()); +} // Note: The following causes an ASSERT() in iSignature::Compare(), as it should, but // we don't want asserts to occur in a working test suite! // TEST(nullSig.Compare(&checksumSig, iFCOProp::OP_EQ) == iFCOProp::CMP_WRONG_PROP_TYPE); - - // Create a file for which we know the signatures - // - //% siggen ~/signature_test.bin - //crc : AAAAAAAAAAy - //md5 : B/Y8ttBnlyw/NPCUu353ao - //crc32 : B1kP9v - //sha : Oia1aljHD793tfj7M55tND+3OG/ - //haval : BL6bFSo0EP5zf8lGSueeed - - TSTRING sigFileName = TEMP_DIR; - sigFileName += TSTRING( _T("/signature_test.bin") ); - +void TestChecksum() +{ + TSTRING sigFileName = getTestFile(); cFileArchive fileArc; - fileArc.OpenReadWrite(sigFileName.c_str()); - fileArc.WriteBlob("\x1\x2\x3\x4\x5\x6\x7\x8\x9\x0", 10); - fileArc.Close(); - - + cDebug d("TestChecksum"); // test begins here // general signature & archive variables @@ -146,8 +158,19 @@ void TestSignature() check2.Read(&readSer); TEST(check1.Compare(&check2, iFCOProp::OP_EQ) == iFCOProp::CMP_TRUE); } +} + +void TestCRC32() +{ + TSTRING sigFileName = getTestFile(); + cFileArchive fileArc; + cDebug d("TestCRC32"); + + // general signature & archive variables + byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE]; + const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE; + int cbRead; - // test CRC32 cCRC32Signature crc1, crc2; d.TraceDetail("Testing CRC32.\n"); @@ -191,7 +214,18 @@ void TestSignature() crc2.Read(&readSer); TEST(crc1.Compare(&crc2, iFCOProp::OP_EQ) == iFCOProp::CMP_TRUE); } +} +void TestMD5() +{ + TSTRING sigFileName = getTestFile(); + cFileArchive fileArc; + cDebug d("TestMD5"); + + // general signature & archive variables + byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE]; + const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE; + int cbRead; // test MD5 cMD5Signature md51, md52; @@ -236,7 +270,18 @@ void TestSignature() md52.Read(&readSer); TEST(md51.Compare(&md52, iFCOProp::OP_EQ) == iFCOProp::CMP_TRUE); } +} +void TestSHA1() +{ + TSTRING sigFileName = getTestFile(); + cFileArchive fileArc; + cDebug d("TestSHA1"); + + // general signature & archive variables + byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE]; + const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE; + int cbRead; // test SHA cSHASignature sha1, sha2; @@ -281,8 +326,19 @@ void TestSignature() sha2.Read(&readSer); TEST(sha1.Compare(&sha2, iFCOProp::OP_EQ) == iFCOProp::CMP_TRUE); } +} + +void TestHAVAL() +{ + TSTRING sigFileName = getTestFile(); + cFileArchive fileArc; + cDebug d("TestHAVAL"); + + // general signature & archive variables + byte abBuf[iSignature::SUGGESTED_BLOCK_SIZE]; + const int cbToRead = iSignature::SUGGESTED_BLOCK_SIZE; + int cbRead; - // test HAVAL cHAVALSignature haval1, haval2; d.TraceDetail("Testing HAVAL.\n"); @@ -323,10 +379,16 @@ void TestSignature() haval1.Write(&writeSer); sigArchive.Seek(0, cBidirArchive::BEGINNING); cSerializerImpl readSer(sigArchive, cSerializerImpl::S_READ); - md52.Read(&readSer); + haval2.Read(&readSer); TEST(haval1.Compare(&haval2, iFCOProp::OP_EQ) == iFCOProp::CMP_TRUE); } - +} + +void TestArchiveSigGen() +{ + TSTRING sigFileName = getTestFile(); + cFileArchive fileArc; + cDebug d("TestArchiveSigGen"); // test cArchiveSigGen cArchiveSigGen asgtest; @@ -357,8 +419,96 @@ void TestSignature() TEST(haval3.AsString().compare(_T("BL6bFSo0EP5zf8lGSueeed")) == 0); TEST(haval3.AsStringHex().compare(_T("4be9b152a3410fe737fc9464ae79e79d")) == 0); - fileArc.Close(); - - return; + fileArc.Close(); } +void assertMD5(const std::string& source, const std::string& expectedHex) +{ + // Signature usage example (?) + cMD5Signature md5Sig; + + md5Sig.Init(); + md5Sig.Update( (const byte*)source.c_str(), source.length() ); + md5Sig.Finit(); + + TEST( md5Sig.AsStringHex() == expectedHex); +} + +void assertSHA1(const std::string& source, const std::string& expectedHex) +{ + // Signature usage example (?) + cSHASignature shaSig; + + shaSig.Init(); + shaSig.Update( (const byte*)source.c_str(), source.length() ); + shaSig.Finit(); + + TEST( shaSig.AsStringHex() == expectedHex); +} + + +void TestRFC1321() +{ + // All MD5 test cases from RFC 1321, appendix A.5 + // https://www.ietf.org/rfc/rfc1321.txt + + assertMD5("", "d41d8cd98f00b204e9800998ecf8427e"); + assertMD5("a", "0cc175b9c0f1b6a831c399e269772661"); + assertMD5("abc", "900150983cd24fb0d6963f7d28e17f72"); + assertMD5("message digest", "f96b697d7cb7938d525a2f31aaf161d0"); + assertMD5("abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b"); + assertMD5( + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + "d174ab98d277d9f5a5611c2c9f419d9f"); + assertMD5( + "12345678901234567890123456789012345678901234567890123456789012345678901234567890", + "57edf4a22be3c955ac49da2e2107b67a"); +} + +void TestRFC3174() +{ + // SHA1 test cases from RFC 3174, section 7.3 + // https://www.ietf.org/rfc/rfc3174.txt + // plus BSD libmd test cases + // https://opensource.apple.com/source/libmd/libmd-3/Makefile + // + // TODO: Compare against NIST test vectors for extra pedanticity + // http://csrc.nist.gov/groups/STM/cavp/secure-hashing.html + + assertSHA1("abc", "a9993e364706816aba3e25717850c26c9cd0d89d"); + assertSHA1( + "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", + "84983e441c3bd26ebaae4aa1f95129e5e54670f1"); + + assertSHA1("a", "86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"); + assertSHA1( + "0123456701234567012345670123456701234567012345670123456701234567", + "e0c094e867ef46c350ef54a7f59dd60bed92ae83"); + + assertSHA1("", "da39a3ee5e6b4b0d3255bfef95601890afd80709"); + assertSHA1("abc", "a9993e364706816aba3e25717850c26c9cd0d89d"); + assertSHA1("message digest", "c12252ceda8be8994d5fa0290a47231c1d16aae3"); + assertSHA1( + "abcdefghijklmnopqrstuvwxyz", + "32d10c7b8cf96570ca04ce37f2a19d84240d3a89"); + assertSHA1( + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + "761c457bf73b14d27e9e9265c46f4b4dda11f940"); + assertSHA1( + "12345678901234567890123456789012345678901234567890123456789012345678901234567890", + "50abf5706a150990a08b2c5ea40fa0e585554732"); +} + + +void RegisterSuite_Signature() +{ + RegisterTest("Signature", "Basic", TestSignatureBasic); + RegisterTest("Signature", "Checksum", TestChecksum); + RegisterTest("Signature", "CRC32", TestCRC32); + RegisterTest("Signature", "MD5", TestMD5); + RegisterTest("Signature", "SHA1", TestSHA1); + RegisterTest("Signature", "HAVAL", TestHAVAL); + RegisterTest("Signature", "ArchiveSigGen", TestArchiveSigGen); + RegisterTest("Signature", "RFC1321", TestRFC1321); + RegisterTest("Signature", "RFC3174", TestRFC3174); +} diff --git a/src/twtest/srefcountobj_t.cpp b/src/twtest/srefcountobj_t.cpp index 3ac76ae..9f0b118 100644 --- a/src/twtest/srefcountobj_t.cpp +++ b/src/twtest/srefcountobj_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -95,11 +95,9 @@ void cSerRefCountObjTest::Write(iSerializer* pSerializer) const void TestSerRefCountObj() { - TCERR << "TODO: TestSerRefCountObj ifdef'd due to internal error" << std::endl; -#if 0 // first, we need to register the object with the serializer class... cSerializerImpl::RegisterSerializableRefCt(CLASS_TYPE(cSerRefCountObjTest), cSerRefCountObjTest::Create); - + cSerRefCountObjTest* pObj1 = new cSerRefCountObjTest; cSerRefCountObjTest* pObj2 = new cSerRefCountObjTest; pObj1->AddRef(); @@ -144,6 +142,9 @@ void TestSerRefCountObj() pObj4->Release(); return; -#endif } +void RegisterSuite_SerRefCountObj() +{ + RegisterTest("SerRefCountObj", "Basic", TestSerRefCountObj); +} diff --git a/src/twtest/stdtest.cpp b/src/twtest/stdtest.cpp index 483df60..3287586 100644 --- a/src/twtest/stdtest.cpp +++ b/src/twtest/stdtest.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -37,4 +37,4 @@ // #include "stdtest.h" -// eof: stdtest.cpp + diff --git a/src/twtest/stdtest.h b/src/twtest/stdtest.h index 291a3fc..3fd6dc5 100644 --- a/src/twtest/stdtest.h +++ b/src/twtest/stdtest.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/twtest/stringencoder_t.cpp b/src/twtest/stringencoder_t.cpp index 646ca31..bd39f26 100644 --- a/src/twtest/stringencoder_t.cpp +++ b/src/twtest/stringencoder_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -86,10 +86,14 @@ void OutputString( TSTRING& str ) { cQuoteEncoder qe; - TCOUT << _T("Plain string: <") << str << _T(">") << endl; +/* TCOUT << _T("Plain string: <") << str << _T(">") << endl; TCOUT << _T("Encoded string: <") << qe.Encode( str ) << _T(">") << endl; - TCOUT << _T("Decoded string: <") << qe.Unencode( str ) << _T(">") << endl << endl ; + TCOUT << _T("Decoded string: <") << qe.Unencode( str ) << _T(">") << endl << endl ; */ TEST( str == qe.Unencode(qe.Encode(str)) ); } +void RegisterSuite_StringEncoder() +{ + RegisterTest("StringEncoder", "Basic", TestStringEncoder); +} diff --git a/src/twtest/stringutil_t.h b/src/twtest/stringutil_t.h index 12a5bdf..5a34a15 100644 --- a/src/twtest/stringutil_t.h +++ b/src/twtest/stringutil_t.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -42,10 +42,7 @@ #define __STRINGUTIL_T_H #include "core/ntmbs.h" - -#if USING_NTDBS_STUFF #include "core/ntdbs.h" -#endif // USING_NTDBS_STUFF //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Char traits for WCHAR16 (aka dbchar_t) and NTMBCS (mctype_t) @@ -54,7 +51,6 @@ inline void TestStringUtil() { -#if USING_NTDBS_STUFF cDebug db("Test std::char_traits"); db.TraceAlways("Entering...\n"); @@ -63,12 +59,10 @@ void TestStringUtil() tss::dbstring b; std::string c; // Control String -//#if !IS_UNIX // need to get the L"" stuff working - static char NTMBS1[] = { 65, 66, 67, 68, 0 }; static dbchar_t NTDBS1[] = { 65, 66, 67, 68, 0 }; static dbchar_t NTDBS2[] = { 40, 66, 67, 68, 0 }; - static dbchar_t NTDBS0[] = { 65, 66, 67, 68, 0, 0 }; +// static dbchar_t NTDBS0[] = { 65, 66, 67, 68, 0, 0 }; c.assign( NTMBS1 ); a.assign( NTDBS1 ); @@ -126,7 +120,6 @@ void TestStringUtil() tss::dbstring x( NTDBS1 ); tss::dbstring ref = x; - TEST( x.c_str() == ref.c_str() ); TEST( x == ref ); TEST( std::equal( x.begin(), x.end(), ref.begin() ) ); TEST( x.size() == ref.size() ); @@ -167,8 +160,12 @@ void TestStringUtil() TEST(tStr.length() == 9); db.TraceAlways("Done...\n"); -#endif // USING_NTDBS_STUFF } #endif//__STRINGUTIL_T_H + +void RegisterSuite_StringUtil() +{ + RegisterTest("StringUtil", "Basic", TestStringUtil); +} diff --git a/src/twtest/tasktimer_t.cpp b/src/twtest/tasktimer_t.cpp index 2770e28..b702093 100644 --- a/src/twtest/tasktimer_t.cpp +++ b/src/twtest/tasktimer_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -31,9 +31,34 @@ // // tasktimer_t -- test driver for cTaskTimer #include "core/stdcore.h" +#include "test.h" +#include "core/tasktimer.h" +#include void TestTaskTimer() { + cTaskTimer timer("unit testing"); + + TEST(!timer.IsRunning()); + TEST(0 == timer.GetTotalTime()); + TEST(0 == timer.GetNumTimesStarted()); + + for( int counter=0; counter<5; counter++) + { + timer.Start(); + TEST(timer.IsRunning()); + sleep(1); + timer.Stop(); + TEST(!timer.IsRunning()); + } + + TEST(!timer.IsRunning()); + TEST(5 <= timer.GetTotalTime()); + TEST(5 == timer.GetNumTimesStarted()); } +void RegisterSuite_TaskTimer() +{ + RegisterTest("TaskTimer", "Basic", TestTaskTimer); +} diff --git a/src/twtest/tchar_t.cpp b/src/twtest/tchar_t.cpp index 9d1e0a5..fa48662 100644 --- a/src/twtest/tchar_t.cpp +++ b/src/twtest/tchar_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -39,18 +39,22 @@ #include "core/debug.h" #endif +#include "test.h" + TSTRING test_wost(int, const TSTRING&); void test_wist(const TSTRING&, cDebug& d); void TestTCHAR() { + TCERR << "TODO: Right now this test mostly verifies that STL string & file classes work, which is not overly useful." << std::endl; + cDebug d("TestTCHAR()"); d.TraceDetail("Entering...\n"); //Testing TCOUT: TCOUT<< _T("Simple test of TSTRING (and TCOUT) :\n\n"); - TCERR<< _T("This should show up on cerr"); + TCERR<< _T("This should show up on cerr") << std::endl; TSTRING pString; pString = _T("Hi Mom!"); @@ -80,37 +84,36 @@ void TestTCHAR() //A true statement! d.TraceDetail("Testing TISTRINGSTREAM with TSTRING:\n"); - TSTRING send = _T("These should appear on seperate lines"); + TSTRING send = _T("These should appear on separate lines"); test_wist(send, d); //Did they? //Testing file streams //explict constructors of 'TIFSTREAM' and "TOFSTREAM' take char* - const char* inputfile = "fun"; - const char* outputfile = "mo'fun"; + std::string inputfile = TwTestPath("fun"); + std::string outputfile = TwTestPath("mo'fun"); //Set up the input file. TOFSTREAM out; - out.open(inputfile, std::ios_base::out); + out.open(inputfile.c_str(), std::ios_base::out); out<<"Unicode is fun\n"; out.close(); TIFSTREAM from; - from.open(inputfile, std::ios_base::in); - if(!from) - d.TraceDetail("error opening input file\n"); + from.open(inputfile.c_str(), std::ios_base::in); + TEST(from); - TOFSTREAM to(outputfile, std::ios_base::trunc); - if(!to) - d.TraceDetail("error opening output file\n"); + + TOFSTREAM to(outputfile.c_str(), std::ios_base::trunc); + TEST(to); //Copy contents of input file to output file. TCHAR ch; while(from.get(ch)) to.put(ch); - if(!from.eof() || !to) - d.TraceDetail("something has gone terribly wrong...\n"); + + TEST(from.eof() && to); return; } @@ -131,3 +134,8 @@ void test_wist(const TSTRING& input, cDebug& d) d.TraceDetail("%s \n", parse.c_str() ); } +void RegisterSuite_TCHAR() +{ + RegisterTest("TCHAR", "Basic", TestTCHAR); +} + diff --git a/src/twtest/test.cpp b/src/twtest/test.cpp index 799d587..aeb4c50 100644 --- a/src/twtest/test.cpp +++ b/src/twtest/test.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -42,8 +42,6 @@ #include "twparser/twparser.h" #include "tw/tw.h" #include "fco/fco.h" - - #include "fs/fs.h" #include "util/util.h" @@ -51,6 +49,7 @@ #include "core/debug.h" #include "core/error.h" #include "core/twlocale.h" +#include "core/fsservices.h" #include "test.h" #include "core/errorbucketimpl.h" #include "tw/twinit.h" @@ -62,205 +61,325 @@ #include "db/blockrecordarray.h" #include "db/hierdatabase.h" +#include +#include -// the test routines -void TestFCOName(); -void TestFCOTest(); -void TestFCOSetImpl(); -void TestFCOSpec(); -void TestFCOPropVector(); -void TestFileHeader(); -void TestFSPropSet(); -void TestFCOSpecImpl(); -void TestFSPropCalc(); -void TestFCOPropImpl(); -void TestFCOCompare(); -//void TestTripwire(); -void TestWin32FSServices(); -void TestFCOSpecList(); -void TestFCOReport(); -void TestArchive(); -void TestSerializer(); -void TestSerializerImpl(); -void TestRefCountObj(); -void TestSignature(); -void TestSerRefCountObj(); -void TestUnixFSServices(); -void TestError(); -void TestDebug(); -void TestFcoSpecUtil(); -void TestTypes(); -void TestTCHAR(); -void TestErrorBucketImpl(); -void TestHashTable(); -void TestTextReportViewer(); -void TestFCONameTbl(); -void TestConfigFile(); - -void TestPolicyParser(); - -void TestFCOSpecHelper(); -void TestCrypto(); -void TestCryptoArchive(); -void TestFCOSpecAttr(); -void TestCmdLineParser(); -void TestTaskTimer(); -void TestKeyFile(); -void TestTWUtil(); -void TestFSPropDisplayer(); -void TestFSPropDisplayer(); -void TestGenre(); -void TestFSDataSourceIter(); -void TestGenerateDb(); -void TestHierDatabaseInteractive(); -void TestGenreSwitcher(); -void TestDbDataSource(); -void TestGenreSpecList(); -void TestIntegrityCheck(); -void TestFCODatabaseFile(); -void TestWchar16(); -void TestStringEncoder(); - -void TestGrowHeap(); -void TestPlatform(); -void TestBlockFile(); -void TestBlockRecordArray(); -void TestTWLocale(); -void TestFileUtil(); -void TestFCONameTranslator(); -void TestCodeConverter(); - -void TestCharToHex(); -void TestHexToChar(); -void TestStringToHex(); -void TestHexToString(); -//void TestUnconvertable(); -//void TestUnprintable(); -void TestQuoteAndBackSlash(); -void TestDisplayEncoderBasic(); -void TestCharUtilBasic(); -void TestConfigFile2(); +// Known test suites +void RegisterSuite_Archive(); +void RegisterSuite_BlockFile(); +void RegisterSuite_BlockRecordArray(); +void RegisterSuite_CharUtil(); +void RegisterSuite_CmdLineParser(); +void RegisterSuite_CodeConvert(); +void RegisterSuite_ConfigFile(); +void RegisterSuite_CryptoArchive(); +void RegisterSuite_Crypto(); +void RegisterSuite_DbDataSource(); +void RegisterSuite_Debug(); +void RegisterSuite_DisplayEncoder(); +void RegisterSuite_Error(); +void RegisterSuite_ErrorBucketImpl(); +void RegisterSuite_FCOCompare(); +void RegisterSuite_FCODatabaseFile(); +void RegisterSuite_FCOName(); +void RegisterSuite_FCONameTbl(); +void RegisterSuite_FCONameTranslator(); +void RegisterSuite_FCOPropImpl(); +void RegisterSuite_FCOPropVector(); +void RegisterSuite_FCOReport(); +void RegisterSuite_FCOSetImpl(); +void RegisterSuite_FCOSpec(); +void RegisterSuite_FCOSpecAttr(); +void RegisterSuite_FCOSpecHelper(); +void RegisterSuite_FCOSpecList(); +void RegisterSuite_FcoSpecUtil(); +void RegisterSuite_File(); +void RegisterSuite_FileHeader(); +void RegisterSuite_FileUtil(); +void RegisterSuite_FSDataSourceIter(); +void RegisterSuite_FSObject(); +void RegisterSuite_FSPropCalc(); +void RegisterSuite_FSPropDisplayer(); +void RegisterSuite_FSPropSet(); +void RegisterSuite_FCOSpecImpl(); +void RegisterSuite_GenreSwitcher(); +void RegisterSuite_GenreSpecList(); +void RegisterSuite_Error(); +void RegisterSuite_GrowHeap(); +void RegisterSuite_HashTable(); +void RegisterSuite_HierDatabase(); +void RegisterSuite_KeyFile(); +void RegisterSuite_Platform(); +void RegisterSuite_PolicyParser(); +void RegisterSuite_RefCountObj(); +void RegisterSuite_Resources(); +void RegisterSuite_Serializer(); +void RegisterSuite_SerializerImpl(); +void RegisterSuite_Signature(); +void RegisterSuite_SerRefCountObj(); +void RegisterSuite_StringEncoder(); +void RegisterSuite_StringUtil(); +void RegisterSuite_TaskTimer(); +void RegisterSuite_TCHAR(); +void RegisterSuite_TextReportViewer(); +void RegisterSuite_TWLocale(); +void RegisterSuite_TWUtil(); +void RegisterSuite_Types(); +void RegisterSuite_UnixFSServices(); +void RegisterSuite_UserNotifyStdout(); +void RegisterSuite_Wchar16(); /// This is easier than all the (cpp) files and declarations #include "stringutil_t.h" void Usage() { - TCERR << _T("Usage: test {all | testid [testid ...]}\n") + TCERR << _T("Usage: test {all | list | testid [testid ...]}\n") _T("\n") - _T("Ex: test 1 2 3 12\n") - _T("(runs test id's 1, 2, 3, and 12)\n\n"); + _T("Ex: test foo bar/baz\n") + _T("(runs suite foo and test bar/baz)\n\n"); } -const int MAX_TEST_ID = 88; - +static int ran_count = 0; static int failed_count = 0; +static int skipped_count = 0; +static int macro_count = 0; -static void Test(int testID) +static std::vector error_strings; +static std::vector skipped_strings; + +class skip_exception : public std::runtime_error { - TCERR << std::endl << "=== Running test ID #" << testID << " ===" << std::endl; - - try { - - switch (testID) +public: + skip_exception(const std::string& reason) : std::runtime_error(reason) {} +}; + +void skip(const std::string& reason) +{ + throw skip_exception(reason); +} + +void fail(const std::string& reason) +{ + throw std::runtime_error(reason); +} + +void CountMacro() +{ + macro_count++; +} + +///////////////////////// + +static TestMap tests; + +void RegisterTest(const std::string& suite, const std::string testName, TestPtr testPtr ) +{ + tests[suite][testName] = testPtr; +} + + +static void RunTest(const std::string& suiteName, const std::string& testName, TestPtr testPtr) +{ + try + { + if (testPtr) { - case 1: TestArchive(); break; - case 2: TestCmdLineParser(); break; - case 3: TestCrypto(); break; - case 4: TestCryptoArchive(); break; - case 5: TestDebug(); break; - case 6: TestError(); break; - case 7: TestErrorBucketImpl(); break; - case 8: TestFCOCompare(); break; - - case 12: TestFCOName(); break; - case 13: TestFCONameTbl(); break; - case 14: TestFCOPropVector(); break; - case 15: TestFCOPropImpl(); break; - case 16: TestFCOReport(); break; - - case 18: TestFCOSetImpl(); break; - - case 20: TestFCOSpecAttr(); break; - case 21: TestFCOSpecHelper(); break; - case 22: TestFCOSpecList(); break; - case 23: TestFcoSpecUtil(); break; - case 24: TestFileHeader(); break; - - case 26: TestFSPropSet(); break; - case 27: TestFSPropCalc(); break; - case 28: TestFCOSpecImpl(); break; - case 29: TestHashTable(); break; - - case 31: TestRefCountObj(); break; - case 32: TestSerializerImpl(); break; - case 33: TestSerRefCountObj(); break; - case 34: TestSignature(); break; - case 35: TestTaskTimer(); break; - //case 36: TestTripwire(); break; - case 37: TestTextReportViewer(); break; - case 39: TestSerRefCountObj(); break; - case 40: TestError(); break; - case 41: TestFCODatabaseFile(); break; - case 42: TestHashTable(); break; - case 43: TestTCHAR(); break; - case 44: TestUnixFSServices(); break; - case 46: TestConfigFile(); break; - case 47: TestPolicyParser(); break; - case 48: TestKeyFile(); break; - case 49: TestTWUtil(); break; - case 50: TestFSPropDisplayer(); break; - case 52: TestGenre(); break; - case 53: TestFSDataSourceIter(); break; - //case 54: TestGenerateDb(); break; - case 55: TestHierDatabaseInteractive(); break; - case 56: TestGenreSwitcher(); break; - case 57: TestDbDataSource(); break; - case 58: TestGenreSpecList(); break; - //case 59: TestIntegrityCheck(); break; - - case 65: TestWchar16(); break; - case 66: TestStringEncoder(); break; - - case 69: TestGrowHeap(); break; - case 70: TestPlatform(); break; - case 71: TestBlockFile(); break; - case 72: TestBlockRecordArray(); break; - case 74: TestFileUtil(); break; - case 75: TestTWLocale(); break; - case 76: TestFCONameTranslator(); break; - case 77: TestStringUtil(); break; - case 78: TestCodeConverter(); break; - - case 79: TestCharToHex(); break; - case 80: TestHexToChar(); break; - case 81: TestStringToHex(); break; - case 82: TestHexToString(); break; - // case 83: TestUnconvertable(); break; - // case 84: TestUnprintable(); break; - case 85: TestQuoteAndBackSlash(); break; - case 86: TestDisplayEncoderBasic(); break; - case 87: TestCharUtilBasic(); break; - case 88: TestConfigFile2(); break; + ran_count++; + int pre_count = macro_count; + testPtr(); + if (macro_count > pre_count) + TCERR << "PASSED" << std::endl; + else + skip("Test did not make any TEST assertions"); } + return; + } + catch (skip_exception& e) + { + TCERR << "SKIPPED: " << e.what() << std::endl; + std::stringstream sstr; + sstr << "Test " << suiteName << "/" << testName << ": " << e.what(); + skipped_strings.push_back(sstr.str()); + + skipped_count++; } catch (eError& error) { TCERR << "FAILED: " ; cTWUtil::PrintErrorMsg(error); + + std::stringstream sstr; + sstr << "Test " << suiteName << "/" << testName << ": " << error.GetMsg(); + error_strings.push_back(sstr.str()); + failed_count++; } catch (std::exception& e) { TCERR << "FAILED: " << e.what() << std::endl; + + std::stringstream sstr; + sstr << "Test " << suiteName << "/" << testName << ": " << e.what(); + error_strings.push_back(sstr.str()); + failed_count++; } catch (...) { TCERR << "FAILED: " << std::endl; - failed_count++; + + std::stringstream sstr; + sstr << "Test " << suiteName << "/" << testName << ": "; + error_strings.push_back(sstr.str()); } - - TCERR << std::endl << "=== test ID #" << testID << " completed ===" << std::endl; +} + + +static void RunTestSuite(const std::string& suiteName, SuiteMap suite) +{ + SuiteMap::const_iterator itr; + for( itr = suite.begin(); itr != suite.end(); ++itr) + { + TCERR << "----- Running test: " << suiteName << "/" << itr->first << " -----" << std::endl << std::endl; + RunTest(suiteName, itr->first, itr->second); + TCERR << std::endl << "----- Finished test: " << suiteName << "/" << itr->first << " -----" << std::endl; + } +} + +static void RunAllTests() +{ + TestMap::const_iterator itr; + for( itr = tests.begin(); itr != tests.end(); ++itr) + { + TCERR << std::endl << "===== Starting test suite: " << itr->first << " =====" << std::endl; + RunTestSuite(itr->first, itr->second); + TCERR << "===== Finished test suite: " << itr->first << " =====" << std::endl; + } +} + +static void ListTests() +{ + TestMap::const_iterator itr; + for( itr = tests.begin(); itr != tests.end(); ++itr) + { + std::string suiteName = itr->first; + SuiteMap suite = itr->second; + + TCERR << suiteName << std::endl; + SuiteMap::const_iterator itr; + for( itr = suite.begin(); itr != suite.end(); ++itr) + { + TCERR << " " << suiteName << "/" << itr->first << std::endl; + } + } +} + +static void RunTest(const std::string& to_run) +{ + std::string::size_type pos = to_run.find_first_of("/"); + if(pos == std::string::npos) + { + RunTestSuite(to_run, tests[to_run]); + } + else + { + std::string suite = to_run.substr(0, pos); + std::string testName = to_run.substr(pos+1); + RunTest(suite, testName, tests[suite][testName]); + } +} + +static void RegisterSuites() +{ + RegisterSuite_Archive(); + RegisterSuite_BlockFile(); + RegisterSuite_BlockRecordArray(); + RegisterSuite_CharUtil(); + RegisterSuite_CmdLineParser(); + RegisterSuite_CodeConvert(); + RegisterSuite_ConfigFile(); + RegisterSuite_CryptoArchive(); + RegisterSuite_Crypto(); + RegisterSuite_DbDataSource(); + RegisterSuite_Debug(); + RegisterSuite_DisplayEncoder(); + RegisterSuite_Error(); + RegisterSuite_ErrorBucketImpl(); + RegisterSuite_FCOCompare(); + RegisterSuite_FCODatabaseFile(); + RegisterSuite_FCOName(); + RegisterSuite_FCONameTbl(); + RegisterSuite_FCONameTranslator(); + RegisterSuite_FCOPropImpl(); + RegisterSuite_FCOPropVector(); + RegisterSuite_FCOReport(); + RegisterSuite_FCOSetImpl(); + RegisterSuite_FCOSpec(); + RegisterSuite_FCOSpecAttr(); + RegisterSuite_FCOSpecHelper(); + RegisterSuite_FCOSpecList(); + RegisterSuite_FcoSpecUtil(); + RegisterSuite_File(); + RegisterSuite_FileHeader(); + RegisterSuite_FileUtil(); + RegisterSuite_FSDataSourceIter(); + RegisterSuite_FSObject(); + RegisterSuite_FSPropCalc(); + RegisterSuite_FSPropDisplayer(); + RegisterSuite_FSPropSet(); + RegisterSuite_FCOSpecImpl(); + RegisterSuite_GenreSwitcher(); + RegisterSuite_GenreSpecList(); + RegisterSuite_Error(); + RegisterSuite_GrowHeap(); + RegisterSuite_HashTable(); + RegisterSuite_HierDatabase(); + RegisterSuite_KeyFile(); + RegisterSuite_Platform(); + RegisterSuite_PolicyParser(); + RegisterSuite_RefCountObj(); + RegisterSuite_Resources(); + RegisterSuite_Serializer(); + RegisterSuite_SerializerImpl(); + RegisterSuite_Signature(); + RegisterSuite_SerRefCountObj(); + RegisterSuite_StringEncoder(); + RegisterSuite_StringUtil(); + RegisterSuite_TaskTimer(); + RegisterSuite_TCHAR(); + RegisterSuite_TextReportViewer(); + RegisterSuite_TWLocale(); + RegisterSuite_TWUtil(); + RegisterSuite_Types(); + RegisterSuite_UnixFSServices(); + RegisterSuite_UserNotifyStdout(); + RegisterSuite_Wchar16(); +} + + +std::string TwTestDir() +{ + static std::string dir; + + if(dir.empty()) + { + iFSServices::GetInstance()->GetCurrentDir(dir); + dir.append("/TWTestData"); + TCERR << "Using test directory: " << dir << std::endl; + mkdir(dir.c_str(), 0777); + } + + return dir; +} + +std::string TwTestPath(const std::string& child) +{ + std::stringstream sstr; + sstr << TwTestDir(); + if (child[0] != '/') + sstr << '/'; + sstr << child; + return sstr.str(); } /////////////////////////////////////////////////////////////////////////////// @@ -301,17 +420,21 @@ void tw_unexpected_handler() int _tmain(int argc, TCHAR** argv) { +#ifdef _DEBUG std::cout << "Test: Init" << std::endl; + std::cout << "Test: Setup" << std::endl; + std::cout << "Test: argc - " << argc << std::endl; + std::cout << "Test: *argv - " << argv[0] << std::endl; +#endif - try + try { - std::cout << "Test: Setup" << std::endl; - std::cout << "Test: argc - " << argc << std::endl; - std::cout << "Test: *argv - " << argv[0] << std::endl; - EXCEPTION_NAMESPACE set_terminate(tw_terminate_handler); EXCEPTION_NAMESPACE set_unexpected(tw_unexpected_handler); + if (argc < 2) + Usage(); + cTWInit twInit; twInit.Init( argv[0] ); @@ -320,20 +443,24 @@ int _tmain(int argc, TCHAR** argv) //cDebug::SetDebugLevel(cDebug::D_NEVER); cDebug::SetDebugLevel(cDebug::D_DETAIL); //cDebug::SetDebugLevel(cDebug::D_DEBUG); - - int i; - if (argc < 2) - Usage(); - else if (_tcsicmp(argv[1], _T("all")) == 0) - // run all the tests - for (i = 1; i <= MAX_TEST_ID; ++i) - Test(i); + RegisterSuites(); + + if (_tcsicmp(argv[1], _T("all")) == 0) + { + RunAllTests(); + } + else if(_tcsicmp(argv[1], _T("list")) == 0) + { + ListTests(); + } else - for (i = 1; i < argc; ++i) - Test(_ttoi(argv[i])); // Note: if atoi returns 0, Test() will handle it fine. - - } + { + for (int i = 1; i < argc; ++i) + RunTest(argv[i]); + } + + } catch (eError& error) { cTWUtil::PrintErrorMsg(error); @@ -347,13 +474,34 @@ int _tmain(int argc, TCHAR** argv) return 1; } - // make sure all the refrence counted objects have been destroyed + // make sure all the reference counted objects have been destroyed // this test always fails because of the static cFCONameTbl //TEST(cRefCountObj::AllRefCountObjDestoryed() == true); - // force user to hit + std::cout << std::endl << "Ran " << ran_count << " unit tests with " << failed_count << " failures, " << skipped_count << " skipped." << std::endl; + std::cout << "(total test assertions: " << macro_count << ")" << std::endl; - std::cout << std::endl << "Tests completed with " << failed_count << " failures." << std::endl; + if (failed_count) + { + std::cout << std::endl << "Failures: " << std::endl; + std::vector::iterator itr; + for (itr = error_strings.begin(); itr != error_strings.end(); ++itr) + { + std::cout << "\t" << *itr << std::endl; + } + } + + if (skipped_count) + { + std::cout << std::endl << "Skipped: " << std::endl; + std::vector::iterator itr; + for (itr = skipped_strings.begin(); itr != skipped_strings.end(); ++itr) + { + std::cout << "\t" << *itr << std::endl; + } + } + + std::cout << std::endl; return failed_count ? -1 : 0; } diff --git a/src/twtest/test.h b/src/twtest/test.h index d465124..db1d32d 100644 --- a/src/twtest/test.h +++ b/src/twtest/test.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -66,18 +66,32 @@ public: TSS_EndPackage( cTest ) +void CountMacro(); + /////////////////////////////////////////////////////////////////////////////// -// TEST() -- Works like ASSERT() but it also breaks during release mode -#define TEST(exp) if (!(exp)) \ +// TEST() -- throw a std::runtime error if test condition is false. +// +#define TEST(exp) CountMacro(); \ + if (!(exp)) \ { \ std::cerr<<"TEST(" << #exp << ") failure, file " << __FILE__ << " line " << __LINE__ << std::endl; \ throw std::runtime_error(#exp); \ } /////////////////////////////////////////////////////////////////////////////// -// Platform dependancies -#define TEMP_DIR _T("/tmp") -#define TEMP_DIR_N "/tmp" + +std::string TwTestDir(); +std::string TwTestPath(const std::string& child); + +typedef void (*TestPtr)(); +typedef std::map< std::string, TestPtr > SuiteMap; +typedef std::map< std::string, SuiteMap > TestMap; + +void RegisterTest(const std::string& suite, const std::string testName, TestPtr testPtr ); + +void skip(const std::string& reason); +void fail(const std::string& reason); + #endif // __TEST_H diff --git a/src/twtest/textreportviewer_t.cpp b/src/twtest/textreportviewer_t.cpp index 731969c..7616862 100644 --- a/src/twtest/textreportviewer_t.cpp +++ b/src/twtest/textreportviewer_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -127,7 +127,7 @@ static void TraceReport(const cFCOReport& r, cDebug& d) void TestTextReportViewer() { - TCERR << std::endl << "TestTextReportViewer needs to be cleaned up & fixed, currently disabled" << std::endl; + skip("TestTextReportViewer needs to be cleaned up & fixed, currently disabled"); #if 0 cFCOReport report; @@ -380,7 +380,7 @@ void TestTextReportViewer() d.TraceDebug("Read in serialized report:\n"); //TraceReport(inReport, d); - trv.PrintTextReport(TSTRING( TEMP_DIR _T( "/test2.txt" ) ) ); + trv.PrintTextReport(TSTRING( TwTestPath("test2.txt" ) ) ); //TODO: this does not work any more //trv.LaunchEditorOnFile( TSTRING( TEMP_DIR _T("/test2.txt") ), _T("") ); @@ -476,3 +476,7 @@ void MakeDir( const TCHAR* const lpszDirName ) //#endif //FIXED_TRV_TEST_SUITE +void RegisterSuite_TextReportViewer() +{ + RegisterTest("TextReportViewer", "Basic", TestTextReportViewer); +} diff --git a/src/twtest/twlocale_t.cpp b/src/twtest/twlocale_t.cpp index c1ad872..4b3e2ec 100644 --- a/src/twtest/twlocale_t.cpp +++ b/src/twtest/twlocale_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -40,6 +40,7 @@ #include "core/stdcore.h" #include "core/debug.h" #include "core/twlocale.h" +#include "test.h" void TestAtoi(); void TestItoa(); @@ -54,174 +55,50 @@ void TestHex(); TEST( false ); \ } catch( error& ) {} -void TestTWLocale() -{ -#ifdef DOESNTWORK - TestHex(); - TestAtoi(); - TestItoa(); - TestFlags(); - TestRoundtrip(); -#endif//NOTDONE -} - -#ifdef DOESNTWORK - -void TestAtoi() -{ - // - // setup - // - int32 n; - TSTRING str = _T("123456"); - - // - // Try formatting with our default locale - // - cTWLocale::InitGlobalLocale(); - n = cTWLocale::FormatNumber( str ); - TEST( n == 123456 ); - - // - // Try formatting with "" locale - // - std::locale::global( std::locale("") ); - n = cTWLocale::FormatNumber( str ); - TEST( n == 123456 ); - - // - // Try formatting with "C" locale - // - std::locale::global( std::locale("") ); - n = cTWLocale::FormatNumber( str ); - TEST( n == 123456 ); -} - void TestItoa() { - // - // can't do ASSERT( str == _T("123456") ) - // because locale may turn it into "123,465" or whatever - // + try + { + // + // can't do ASSERT( str == _T("123456") ) + // because locale may turn it into "123,465" or whatever + // - // - // setup - // - int32 n = 123456; - TSTRING str; + // + // setup + // + int32 n = 123456; + TSTRING str; - // - // Try formatting with our default locale - // - cTWLocale::InitGlobalLocale(); - cTWLocale::FormatNumber( n, str ); - TCOUT << str << std::endl; + // + // Try formatting with our default locale + // + cTWLocale::InitGlobalLocale(); + cTWLocale::FormatNumber( n, str ); + TEST( str == "123456" ); - // - // Try formatting with "" locale - // - std::locale::global( std::locale("") ); - cTWLocale::FormatNumber( n, str ); - TCOUT << str << std::endl; + // + // Try formatting with "" locale + // + std::locale::global( std::locale("") ); + cTWLocale::FormatNumber( n, str ); + TEST( str == "123,456" ); - // - // Try formatting with "C" locale - // - std::locale::global( std::locale("") ); - cTWLocale::FormatNumber( n, str ); - TCOUT << str << std::endl; + // + // Try formatting with "C" locale + // + std::locale::global( std::locale("") ); + cTWLocale::FormatNumber( n, str ); + TEST( str == "123,456" ); + } + catch(const std::runtime_error& e) + { + skip("Skipping test due to configuration issue w/ 'C' locale"); + } } -void TestRoundtrip() +void RegisterSuite_TWLocale() { - // - // init - // - cTWLocale::InitGlobalLocale(); - - // - // atoitoa - // - TSTRING strIn = _T("123456"); - TSTRING strOut; - strOut = cTWLocale::FormatNumber( cTWLocale::FormatNumber( strIn ), strOut ); - // don't know if string will be the same due to possible changes in formatting from locale - // ASSERT( strOut == strIn ); <---- can't do this ^^^ - TEST( 123456 == cTWLocale::FormatNumber( strOut ) ); - - - // - // itoatoi - // - int32 nIn = 654321; - int32 nOut; - nOut = cTWLocale::FormatNumber( cTWLocale::FormatNumber( nIn, strIn ) ); - TEST( nOut == nIn ); + RegisterTest("TWLocale", "Itoa", TestItoa); } - -void TestFlags() -{ - // - // init - // - cTWLocale::InitGlobalLocale(); - - // - // hex - // - TSTRING str = _T("FF"); - int n = cTWLocale::FormatNumber( str, std::ios_base::hex ); - TEST( n == 0xFF ); - - // - // bad number for dec - // - ASSERT_THAT_IT_THROWS( cTWLocale::FormatNumberAsHex( str ), eError ); - - // - // oct - // - TSTRING strOct = _T("0712"); - n = cTWLocale::FormatNumber( strOct, std::ios_base::oct ); - TEST( n == 0712 ); - - // - // oct again - // - strOct = _T("00712"); - n = cTWLocale::FormatNumber( strOct, std::ios_base::oct ); - TEST( n == 0712 ); - - // - // oct again again - // - strOct = _T("712"); - n = cTWLocale::FormatNumber( strOct, std::ios_base::oct ); - TEST( n == 0712 ); - - // - // try bad oct - // - ASSERT_THAT_IT_THROWS( cTWLocale::FormatNumber( _T("99"), std::ios_base::oct ), eError ); -} - - -void TestHex() -{ - TSTRING str; - - str = cTWLocale::FormatNumberAsHex( 0x1234 ); - TEST( str == _T("1234") ); - - str = cTWLocale::FormatNumberAsHex( 16 ); - TEST( str == _T("10") ); - - str = cTWLocale::FormatNumberAsHex( 0x12344321 ); - TEST( str == _T("12344321") ); - - str = cTWLocale::FormatNumberAsHex( 0xFFFFFFFF ); - TEST( str == _T("FFFFFFFF") || str == _T("ffffffff") ); -} -#endif//DOESNTWORK - diff --git a/src/twtest/twutil_t.cpp b/src/twtest/twutil_t.cpp index 71b124f..b1fbcb6 100644 --- a/src/twtest/twutil_t.cpp +++ b/src/twtest/twutil_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -58,10 +58,8 @@ void TestTWUtil() // assuming the current dir is writable, this test should succeed TEST(cFileUtil::FileWritable(_T("afilethatdoesnotexist.tmp")) == true); - TSTRING tmpDir = TEMP_DIR; - tmpDir += _T("/fileexistdir"); - TSTRING tmpFN = tmpDir; - tmpFN += _T("/fileexiststest.tmp"); + TSTRING tmpDir = TwTestPath("fileexistdir"); + TSTRING tmpFN = TwTestPath("fileexiststest.tmp"); // make a subdir in the TEMP_DIR mkdir(tmpDir.c_str(), 0700); @@ -77,11 +75,18 @@ void TestTWUtil() TEST(cFileUtil::FileWritable(tmpFN) == true) TEST(cFileUtil::FileExists(tmpFN) == false); +#if IS_AROS + bool is_root = (65534 == getuid()); //AROS doesn't really have users, & posixy fns use this pseudo value. +#else + bool is_root = (0 == getuid()); +#endif + // make the dir read only and make sure write tests false // windows fails this test, perhaps because I am an administrator? - chmod(tmpDir.c_str(), 0500); - TEST(cFileUtil::FileWritable(tmpFN) == false); - chmod(tmpDir.c_str(), 0700); +// chmod(tmpDir.c_str(), 0500); +// TODO - is this valid now that we don't use /tmp? +// TEST(cFileUtil::FileWritable(tmpFN) == is_root); +// chmod(tmpDir.c_str(), 0700); // create the file { @@ -91,7 +96,7 @@ void TestTWUtil() // test a read only file chmod(tmpFN.c_str(), 0400); - TEST(cFileUtil::FileWritable(tmpFN) == false); + TEST(cFileUtil::FileWritable(tmpFN) == is_root); // test a writable file chmod(tmpFN.c_str(), 0666); @@ -107,3 +112,8 @@ std::string WideToNarrow( const TSTRING& strWide ) return strWide; } +void RegisterSuite_TWUtil() +{ + RegisterTest("TWUtil", "Basic", TestTWUtil); +} + diff --git a/src/twtest/types_t.cpp b/src/twtest/types_t.cpp index 22f578c..1b4fe67 100644 --- a/src/twtest/types_t.cpp +++ b/src/twtest/types_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -50,3 +50,8 @@ void TestTypes() TEST(sizeof(float32) == 4); TEST(sizeof(float64) == 8); } + +void RegisterSuite_Types() +{ + RegisterTest("Types", "Basic", TestTypes); +} diff --git a/src/twtest/unixfsservices_t.cpp b/src/twtest/unixfsservices_t.cpp index 1a9280c..34a5654 100644 --- a/src/twtest/unixfsservices_t.cpp +++ b/src/twtest/unixfsservices_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -42,143 +42,182 @@ #include "twtest/test.h" #endif +#include + using namespace std; -//Tests the functions that are currently implemented in win32fsservices. -void TestUnixFSServices() + +std::string makeTestFile(const std::string &filename) { - cDebug d("TestUnixFSServices"); + TSTRING testfile = TwTestPath(filename); + cFileArchive filearch; + filearch.OpenReadWrite(testfile.c_str()); + filearch.Seek(0, cBidirArchive::BEGINNING); + filearch.WriteString(_T("This is a test")); + filearch.Close(); + + return testfile; +} + +//Tests the functions that are currently implemented in win32fsservices. +void TestReadDir() +{ + cDebug d("TestReadDir"); // d.RemoveOutTarget(cDebug::OUT_STDOUT); - try + iFSServices* pFSServices = iFSServices::GetInstance(); + + // working primarily with the temp dir. + cFCOName name(TwTestDir()); + + // Check to make sure test dir is a dir + //TEST(pFSServices->GetFileType(name) == cFSStatArgs::TY_DIR); + + // get directory contents (test readdir) + std::vector v; + pFSServices->ReadDir(name.AsString(), v); + { - iFSServices* pFSServices = iFSServices::GetInstance(); + d.TraceDebug("name: %d entries\n", v.size()); - // working primarily with the temp dir. - cFCOName name(_T("/tmp")); // dies here - - // Check to make sure /tmp is a dir - //TEST(pFSServices->GetFileType(name) == cFSStatArgs::TY_DIR); - - // get directory contents (test readdir) - std::vector v; - pFSServices->ReadDir(name.AsString(), v); - - { - d.TraceDebug("name: %d entries\n", v.size()); - - std::vector ::iterator p; - size_t n = 0; - for (p = v.begin(); p != v.end(); ++p) { - d.TraceDetail(" %s\n", p->c_str()); - n++; - } - - TEST(n == v.size()); + std::vector ::iterator p; + size_t n = 0; + for (p = v.begin(); p != v.end(); ++p) { + d.TraceDetail(" %s\n", p->c_str()); + n++; } - //Test the Stat method - cFSStatArgs stat; - - //TO DO: use archive to create this file - TSTRING testfile = "/tmp/tmp.tmp"; - cFileArchive filearch; - filearch.OpenReadWrite(testfile.c_str()); - filearch.Seek(0, cBidirArchive::BEGINNING); - filearch.WriteString(_T("This is a test")); - filearch.Close(); - - pFSServices->Stat(testfile, stat); - - //print out the information returned by Stat - d.TraceDetail("Information returned by Stat: \n"); - d.TraceDetail("Group ID : %-5d \n", stat.gid); - //d.TraceDetail("Last access time: %d \n", stat.atime); - d.TraceDetail("Last inode change: %d \n", stat.ctime); - d.TraceDetail("Last modified: %d \n", stat.mtime); - d.TraceDetail("Major/minor device nums: %d \n", stat.dev); - d.TraceDetail("Inode # of file : %d \n", stat.ino); - d.TraceDetail("Mode bits: %d \n", stat.mode); - d.TraceDetail("Num links: %d \n", stat.nlink); - d.TraceDetail("Major/minor dev if special: %d \n", stat.rdev); - d.TraceDetail("File size: %d \n", stat.size); - d.TraceDetail("User ID: %d \n", stat.uid); - - //Test GetCurrentDir: - TSTRING currpath; - pFSServices->GetCurrentDir(currpath); - d.TraceDetail("GetCurrentDir returned %s\n", currpath.c_str()); - //TEST(currpath == _T("~")); - //they should both be ~!! - - //Test MakeTempFilename - TSTRING _template(_T("twtempXXXXXX")); - pFSServices->MakeTempFilename(_template); - d.TraceDetail("Testing MakeTempFilename: \n"); - d.TraceDetail("%s \n", _template.c_str() ); - - // Test GetMachineName - d.TraceDetail("Testing GetMachineName:\n"); - TSTRING uname; - pFSServices->GetMachineName(uname); - d.TraceDetail("GetMachineName returned: %s\n", uname.c_str()); - - // Test GetHostID - d.TraceDetail("Testing GetHostID:\n"); - TSTRING hostid; - pFSServices->GetHostID(hostid); - d.TraceDetail("GetHostID returned: %s\n", hostid.c_str()); - - // Test GetCurrentUserName - d.TraceDetail("Testing GetCurrentUserName:\n"); - TSTRING username; - TEST( pFSServices->GetCurrentUserName(username) ); - d.TraceDetail("GetCurrentUserName returned: %s\n", username.c_str()); - - TCERR << "TODO: unixfsservices_t.cpp, Test GetIPAddress segfaults mysteriously." << std::endl; - // Test GetIPAddress - /*d.TraceDetail("Testing GetIPAddress:\n"); - uint32 *ipaddr; - TEST( pFSServices->GetIPAddress( *ipaddr ) ); - d.TraceDetail("GetIPAddress returned: %d\n", ipaddr); - */ - // test GetExecutableFilename - d.TraceDetail("Testing GetExecutableFilename: \n"); - TSTRING filename = _T("sh"); - TSTRING fullpath = _T("/bin/"); - TEST(pFSServices->GetExecutableFilename(fullpath, filename)); - filename = _T("/bin/sh"); - TEST(pFSServices->GetExecutableFilename(fullpath, filename)); - - // test Rename - d.TraceDetail("Testing Rename:\n"); - TSTRING newtestfile = _T("/tmp/new.tmp"); - TEST( pFSServices->Rename( testfile, newtestfile ) ); - - // test GetOwnerForFile - d.TraceDetail("Testing GetOwnerForFile:\n"); - TSTRING ownername; - TEST( pFSServices->GetOwnerForFile( newtestfile, ownername ) ); - d.TraceDetail("GetOwnerForFile returned owner %s.\n", ownername.c_str()); - - // test GetGroupForFile - d.TraceDetail("Testing GetGroupForFile:\n"); - TSTRING groupname; - TEST( pFSServices->GetGroupForFile( newtestfile, groupname ) ); - d.TraceDetail("GetGroupForFile returned group %s.\n", groupname.c_str()); - - // test FileDelete - d.TraceDetail("Testing FileDelete:\n"); - TEST( pFSServices->FileDelete( newtestfile ) ); - - - - }//end try block - catch (eError& e) - { - d.TraceError("Exception caught: %s\n", e.GetMsg().c_str()); + TEST(n == v.size()); } +} +void TestStat() +{ + //Test the Stat method + cFSStatArgs stat; + + std::string testfile = makeTestFile("stat.tmp"); + + iFSServices::GetInstance()->Stat(testfile, stat); + + TEST("Stat() did not throw"); +/* + cDebug d("TestStat"); + //print out the information returned by Stat + d.TraceDetail("Information returned by Stat: \n"); + d.TraceDetail("Group ID : %-5d \n", stat.gid); + //d.TraceDetail("Last access time: %d \n", stat.atime); + d.TraceDetail("Last inode change: %d \n", stat.ctime); + d.TraceDetail("Last modified: %d \n", stat.mtime); + d.TraceDetail("Major/minor device nums: %d \n", stat.dev); + d.TraceDetail("Inode # of file : %d \n", stat.ino); + d.TraceDetail("Mode bits: %d \n", stat.mode); + d.TraceDetail("Num links: %d \n", stat.nlink); + d.TraceDetail("Major/minor dev if special: %d \n", stat.rdev); + d.TraceDetail("File size: %d \n", stat.size); + d.TraceDetail("User ID: %d \n", stat.uid); +*/ +} + +void TestGetCurrentDir() +{ + TSTRING currpath; + iFSServices::GetInstance()->GetCurrentDir(currpath); + + TEST("GetCurrentDir() did not throw"); + + //d.TraceDetail("GetCurrentDir returned %s\n", currpath.c_str()); + //TEST(currpath == _T("~")); + //they should both be ~!! +} + +void TestMakeTempFilename() +{ + TSTRING _template(_T("twtempXXXXXX")); + iFSServices::GetInstance()->MakeTempFilename(_template); + + TEST("MakeTempFilename() did not throw"); +} + +void TestGetMachineName() +{ + TSTRING uname; + iFSServices::GetInstance()->GetMachineName(uname); + + TEST("GetMachineName() did not throw"); +} + +void TestGetHostID() +{ + TSTRING hostid; + iFSServices::GetInstance()->GetHostID(hostid); + + TEST("GetHostID() did not throw:"); +} + +void TestGetCurrentUserName() +{ +#if !IS_SKYOS // SkyOS breaks on this, for as-yet-unknown reasons + TSTRING username; + bool success = iFSServices::GetInstance()->GetCurrentUserName(username); + if ( !success ) + skip("GetCurrentUserName test skipped, usually caused by system configuration problems"); + + TEST("GetCurrentUserName() did not throw"); +#endif +} + +void TestGetIPAddress() +{ + uint32 ipaddr; + bool success = iFSServices::GetInstance()->GetIPAddress( ipaddr ); + if ( !success ) + skip("GetIPAddress test skipped, usually caused by hostname/IP configuration problems"); + + TEST("GetIPAddress() did not throw"); +} + +void TestGetExecutableFilename() +{ + if( -1 == access("/bin/sh", F_OK)) + skip("/bin/sh not found/accessible"); + + TSTRING filename = _T("sh"); + TSTRING fullpath = _T("/bin/"); + TEST( iFSServices::GetInstance()->GetExecutableFilename(fullpath, filename)); + + filename = _T("/bin/sh"); + TEST( iFSServices::GetInstance()->GetExecutableFilename(fullpath, filename)); +} + +void TestRename() +{ + std::string testfile = makeTestFile("rename_from"); + + TSTRING newtestfile = TwTestPath("rename_to"); + TEST( iFSServices::GetInstance()->Rename( testfile, newtestfile ) ); +} + +void TestFileDelete() +{ + std::string to_rm = makeTestFile("to_rm"); + + TEST( iFSServices::GetInstance()->FileDelete( to_rm ) ); +} + +void RegisterSuite_UnixFSServices() +{ + RegisterTest("UnixFSServices", "ReadDir", TestReadDir); + RegisterTest("UnixFSServices", "Stat", TestStat); + RegisterTest("UnixFSServices", "GetCurrentDir", TestGetCurrentDir); + RegisterTest("UnixFSServices", "MakeTempFilename", TestMakeTempFilename); + RegisterTest("UnixFSServices", "GetMachineName", TestGetMachineName); + RegisterTest("UnixFSServices", "GetHostID", TestGetHostID); + RegisterTest("UnixFSServices", "GetCurrentUserName", TestGetCurrentUserName); + RegisterTest("UnixFSServices", "GetIPAddress", TestGetIPAddress); + RegisterTest("UnixFSServices", "GetExecutableFilename", TestGetExecutableFilename); + RegisterTest("UnixFSServices", "Rename", TestRename); + RegisterTest("UnixFSServices", "FileDelete", TestFileDelete); } @@ -186,5 +225,3 @@ void TestUnixFSServices() - - diff --git a/src/twtest/usernotifystdout_t.cpp b/src/twtest/usernotifystdout_t.cpp index edcbffc..29b6846 100644 --- a/src/twtest/usernotifystdout_t.cpp +++ b/src/twtest/usernotifystdout_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -41,5 +41,10 @@ void TestUserNotifyStdout() { cDebug d("TestUserNotifyStdout"); d.TraceError("Implement this!\n"); - TEST(false); + skip("TestUserNotifyStdout unimplemented"); +} + +void RegisterSuite_UserNotifyStdout() +{ + RegisterTest("UserNotifyStdout", "Basic", TestUserNotifyStdout); } diff --git a/src/twtest/wchar16_t.cpp b/src/twtest/wchar16_t.cpp index 2107a54..2d3a3c8 100644 --- a/src/twtest/wchar16_t.cpp +++ b/src/twtest/wchar16_t.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -124,3 +124,8 @@ void TestWchar16() db.TraceAlways("Done...\n"); } + +void RegisterSuite_Wchar16() +{ + RegisterTest("Wchar16", "Basic", TestWchar16); +} diff --git a/src/util/Makefile.am b/src/util/Makefile.am index a268a3d..bd39842 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -12,6 +12,7 @@ libutil_a_HEADERS = fileutil.h miscutil.h stdutil.h \ stringencoder.h util.h utilerrors.h utilstrings.h DEFS = @DEFS@ # This gets rid of the -I. so AM_CPPFLAGS must be more explicit +CLEANFILES = *.gcno *.gcda all: $(noinst_LIBRARIES) $(AR) ru ../../lib/libtripwire.a $(libutil_a_OBJECTS) diff --git a/src/util/Makefile.in b/src/util/Makefile.in index f2a7741..96f23e3 100644 --- a/src/util/Makefile.in +++ b/src/util/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.15 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2014 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -300,7 +300,6 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ -runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -324,6 +323,7 @@ libutil_a_SOURCES = \ libutil_a_HEADERS = fileutil.h miscutil.h stdutil.h \ stringencoder.h util.h utilerrors.h utilstrings.h +CLEANFILES = *.gcno *.gcda all: all-am .SUFFIXES: @@ -510,6 +510,7 @@ install-strip: mostlyclean-generic: clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) diff --git a/src/util/fileutil.cpp b/src/util/fileutil.cpp index 69dd3a6..37e5cac 100644 --- a/src/util/fileutil.cpp +++ b/src/util/fileutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -208,7 +208,12 @@ bool cFileUtil::BackupFile(const TSTRING& filename, bool printWarningOnFailure) throw eFileWrite(filename, iFSServices::GetInstance()->GetErrString() ); } +#if IS_DOS_DJGPP + TSTRING backup_filename = cDosPath::BackupName( cDosPath::AsNative(filename) ); +#else TSTRING backup_filename = filename; +#endif + backup_filename += iFSServices::GetInstance()->GetStandardBackupExtension(); // remove the backup file if it exists. We ingore the return value from diff --git a/src/util/fileutil.h b/src/util/fileutil.h index f0591fc..7e87198 100644 --- a/src/util/fileutil.h +++ b/src/util/fileutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/util/miscutil.h b/src/util/miscutil.h index dd1f69d..14a71cf 100644 --- a/src/util/miscutil.h +++ b/src/util/miscutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/util/stdutil.cpp b/src/util/stdutil.cpp index 7d53ebd..2a32898 100644 --- a/src/util/stdutil.cpp +++ b/src/util/stdutil.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -38,4 +38,4 @@ #include "stdutil.h" -// eof: stdutil.cpp + diff --git a/src/util/stdutil.h b/src/util/stdutil.h index 2189466..0b29950 100644 --- a/src/util/stdutil.h +++ b/src/util/stdutil.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/util/stringencoder.cpp b/src/util/stringencoder.cpp index d2bcf4f..354872a 100644 --- a/src/util/stringencoder.cpp +++ b/src/util/stringencoder.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/util/stringencoder.h b/src/util/stringencoder.h index 6eb419c..0060c84 100644 --- a/src/util/stringencoder.h +++ b/src/util/stringencoder.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/util/util.cpp b/src/util/util.cpp index 9ea5874..a8d3c90 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -71,4 +71,4 @@ TSS_EndTestSuite( cUtil ) #endif // #ifdef TSS_TEST -// eof: util.cpp + diff --git a/src/util/util.h b/src/util/util.h index 20adbdd..203d949 100644 --- a/src/util/util.h +++ b/src/util/util.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/util/utilerrors.cpp b/src/util/utilerrors.cpp index 0427df2..6625035 100644 --- a/src/util/utilerrors.cpp +++ b/src/util/utilerrors.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/util/utilerrors.h b/src/util/utilerrors.h index 10aa2c6..049c6af 100644 --- a/src/util/utilerrors.h +++ b/src/util/utilerrors.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // diff --git a/src/util/utilstrings.cpp b/src/util/utilstrings.cpp index 2c78e15..2b90759 100644 --- a/src/util/utilstrings.cpp +++ b/src/util/utilstrings.cpp @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. // @@ -49,4 +49,4 @@ TSS_BeginStringtable( cUtil ) TSS_EndStringtable( cUtil ) -// eof: utilstrings.cpp + diff --git a/src/util/utilstrings.h b/src/util/utilstrings.h index 0e37e21..994cd2c 100644 --- a/src/util/utilstrings.h +++ b/src/util/utilstrings.h @@ -1,6 +1,6 @@ // // The developer of the original code and/or files is Tripwire, Inc. -// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, +// Portions created by Tripwire, Inc. are copyright (C) 2000-2017 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights // reserved. //