Merge pull request #6 from brc0x1/master

Open Source Tripwire 2.4.3.0
This commit is contained in:
Brian Cox 2016-04-12 11:06:34 -07:00
commit a47c49cfe1
125 changed files with 8585 additions and 9266 deletions

24
.gitignore vendored Normal file
View File

@ -0,0 +1,24 @@
stamp-h1
config.h
config.h.in~
config.log
config.status
compile
autom4te.cache/
bin/
lib/
**/Makefile
**/*.o
**/*.dylib
**/*.a
**/*.so
**/*.dll
**/siggen
**/tripwire
**/twadmin
**/twprint
**/siggen.exe
**/tripwire.exe
**/twadmin.exe
**/twprint.exe
releases/

View File

@ -1,3 +1,29 @@
2016-04-11 Brian Cox <bcox@tripwire.com>
* Bump version to 2.4.3.0
* Compilation fixes for gcc 4.7+ and LLVM/clang
(see http://www.linuxfromscratch.org/blfs/view/svn/postlfs/tripwire.html )
* Absorb fixes from FreeBSD ports patchset
(see http://svnweb.freebsd.org/ports/head/security/tripwire/ )
* Fix handling of SHA hashes (with and without OpenSSL hash impl.)
* Update GNU config.guess & config.sub to current versions
* Compilation fixes for various and sundry Posix-esque platforms
(Mac OS X, OpenBSD, OpenSolaris, Cygwin, Minix 3.x, GNU/Hurd, MidnightBSD, Haiku, Syllable, SkyOS, Sortix, MiNT)
* Add script to bump buildys file timestaps, to fix
spurious aclocal/automake errors on a fresh clone/untar/etc.
* Update 'make dist' to bundle manpages & policy files
* Replace broken RPM spec w/ 'Packaging' doc that explains where to get packaging stuff.
* Add contributed files from 2.4.2.3 fork (see below)
* Fix large file support on e.g. 32-bit Linux
* Add '-h' option to display hashes as hex instead of base64
* Add MAILFROMADDRESS config param (see twconfig man page)
* Use O_NONBLOCK, to avoid blocking on fifos & mandatory-locked files
* Report Solaris door & event port file types correctly
2014-01-01 Barry Allard <barry.allard@gmail.com>
* Bumping version to 2.4.2.3
* Fixed compilation on clang and gcc compilers
2011-11-21 Stephane Dudzinski <tripwire@frlinux.net>
* Bumping version to 2.4.2.2

View File

@ -1,6 +1,7 @@
Open Source Tripwire Maintainers:
tripwire@frlinux.net
Brian Cox (bcox@tripwire.com)
tripwire@frlinux.net (maintains the fork at github.com/frlinux/tripwire-open-source)
Previous Maintainer:
@ -9,6 +10,8 @@ itripn@users.sourceforge.net
Community Contributors:
Thom O'Connor (https://github.com/thomoco): Contributed LLVM/clang build fixes.
Paul Herman (www.frenchfries.net/paul/tripwire): Paul is almost solely
responsible for the meat of the 2.4.0.1 release. His work on the autoconf
and gcc 3.x support (among other things) has contributed to a much more

View File

@ -1,5 +1,6 @@
AUTOMAKE_OPTIONS = foreign no-dependencies
SUBDIRS = man src
EXTRA_DIST = COMMERCIAL MAINTAINERS TRADEMARK touchconfig.sh contrib policy
install-data-hook:
prefix="$(prefix)" sysconfdir="$(sysconfdir)" \

View File

@ -36,11 +36,12 @@ POST_UNINSTALL = :
host_triplet = @host@
DIST_COMMON = $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure COPYING ChangeLog INSTALL config.guess \
config.sub install-sh ltmain.sh missing mkinstalldirs
$(top_srcdir)/configure COPYING ChangeLog config.guess \
config.sub install-sh missing mkinstalldirs
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
@ -106,6 +107,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -114,6 +117,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
@ -175,6 +179,7 @@ target_os = @target_os@
target_vendor = @target_vendor@
AUTOMAKE_OPTIONS = foreign no-dependencies
SUBDIRS = man src
EXTRA_DIST = COMMERCIAL MAINTAINERS TRADEMARK touchconfig.sh contrib policy
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive

27
Packaging Executable file
View File

@ -0,0 +1,27 @@
Packaging for Open Source Tripwire is maintained by various third parties:
* RPM (Fedora): http://pkgs.fedoraproject.org/cgit/rpms/tripwire.git/
* RPM (OpenSuSE): https://build.opensuse.org/package/show/security/tripwire
* RPM (AIX): http://www.perzl.org/aix/index.php?n=Main.Tripwire
* Debian: https://tracker.debian.org/pkg/tripwire
* Gentoo: https://packages.gentoo.org/packages/app-admin/tripwire
Gentoo also has an SELinux policy for OST:
https://packages.gentoo.org/packages/sec-policy/selinux-tripwire
* Chef cookbook: https://github.com/rackspace-cookbooks/rackspace_tripwire
* FreeBSD Ports: http://svnweb.freebsd.org/ports/head/security/tripwire/
* FreshPorts (BSD): http://www.freshports.org/security/tripwire
* MacPorts: https://trac.macports.org/browser/trunk/dports/security/tripwire
* NetBSD pkgsrc: http://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/security/tripwire/README.html
NOTE: At present (April 2016) pkgsrc only provides the obsolete Tripwire 1.2, from the mid-1990s.
That version lacks contemporary hash algorithms, and you probably don't want to use it.

95
ReadMe-2.4.3 Normal file
View File

@ -0,0 +1,95 @@
What's new in Open Source Tripwire 2.4.3.0:
* This update fixes compilation errors on modern compilers (GCC 4.7+ and LLVM/clang),
as well as some additional errors encountered on various platforms. This is intended
to supersede patches against 2.4.2.x, e.g. http://www.linuxfromscratch.org/blfs/view/svn/postlfs/tripwire.html
and the additional changes in the FreeBSD ports tree: http://svnweb.freebsd.org/ports/head/security/tripwire/
* This update also fixes handling of SHA hashes, which appears to have broken when
someone added support for using OpenSSL's hash algorithms vs. the ones in the OST tree.
This resulted in SHA hashes always being reported as 'AAAAAAAAAAAAAAAAA'. This is
now fixed for both with- and without-OpenSSL builds.
* The 2.4.3 tree no longer contains an RPM spec file. Instead, the 'Packaging' file
points at where current RPM, Debian, & other package configs can be obtained.
* The 'touchconfig.sh' script bumps file timestamps to prevent spurious make errors
(usually about a missing aclocal-1.8) on a fresh clone/untar/etc., which occur due
to all files in the tree initially having the same timestamps. The only case where
an 'autoreconf -i' is actually required is on SkyOS 5, where SIZEOF_LONG_LONG gets
defined incorrectly otherwise.
* Imported a set of contributed scripts from 2.4.2.3 fork (github.com/steakknife/tripwire)
* Fixed large file (>2GB) support for various platforms, including 32-bit Linux.
* Added '-h' argument to display hashes as hex instead of base64 (siggen already allowed this)
* Added the long-requested MAILFROMADDRESS config param for email reporting.
The update has been tested on a variety of platforms:
Linuxes
- CentOS 7 (amd64) + gcc 4.8.5
- Ubuntu 14.0.4 (amd64) + gcc 4.x
- RHEL 3.4 (Itanium) + gcc 3.4.3
- Alpine Linux 3.3.3 + gcc 5.3.0
- Android 6.0 (arm) + gcc 4.9
- Raspbian 7 (wheezy) (armv6l) + gcc 4.6.3
- openSuSE Tumbleweed (20160408) (i586) + gcc 5.3.1
OSX
- Mac OS X 10.11 + LLVM 7.0.2 / clang-700.1.81
BSDs
- FreeBSD 10.2 (amd64) + LLVM/clang
- OpenBSD 5.8 (amd64 & x86) + gcc 4.2.1
- NetBSD 6.0 (x86) + gcc 4.5.1
- DragonflyBSD 4.4.2 + gcc 5.2.1
- MidnightBSD 0.7 + gcc 4.2.1
- HardenedBSD 11.0 + gcc 4.8.5
UNIXes
- Solaris 10 x86 + gcc 3.4.3
- OpenIndiana 151 + gcc 4.8.5 [an OpenSolaris/illumos distro]
- AIX 5.2 + gcc 4.3.1
- HP-UX 11.23 + gcc 4.2.3
Other
- Minix 3.3.0 + LLVM/clang
- Debian GNU/Hurd 0.6 + gcc 4.9.2
- Cygwin 2.4.1 (amd64) + gcc 5.3.0
- Haiku R1 Alpha 4 + gcc 4
- Syllable 0.67 + gcc 4.1.2
- SkyOS 5 (beta 6947) + gcc 4.1.1
- Sortix 1.0 + gcc 5.3.0
- Icaros 2.1 (AROS) + gcc 4.6.4
- MiNT 1.17 (Atari ST/TT) + gcc 4.6.4
Building Notes:
* If cross compiling, a '--disable-openssl' argument must be passed to ./configure,
since its OpenSSL existence check currently uses an AC_TRY_RUN macro. Additionally,
generated Makefiles don't automagically find the cross-compiler's 'ar' and try to
use the local one, which fails. Until this is resolved, this can be fixed with a symlink
named 'ar' pointing at the cross-compiler copy, with a path such that make finds it
instead of the local 'ar'.
* The '--enable-static' configure argument is not guaranteed to work on all
platforms, and your mileage may vary. And when it works, it may not be doing
what you expect. For example, even if a program is statically linked with
glibc, the static glibc code may still load shared libraries behind the
scenes, for things like iconv character conversion and nsswitch name lookups.
* To create PIE (Position-Independent Executable) binaries, add “-fPIE" to CFLAGS
and "-fPIE -pie" to LDFLAGS. This is required by recent Android versions, and
may be desirable elsewhere. It's simplest to add these to configure.in and run
autoreconf -i instead of hand-editing each Makefile individually.
* Older versions of Open Source Tripwire reportedly do not build on Tru64 UNIX.
This is likely to be true with 2.4.3.0 as well, due to the lack of appropriate
hardware to test it on. If anyone out there has a Tru64 box and wants to fix
this, patches are always welcome.

24
acinclude.m4 Normal file
View File

@ -0,0 +1,24 @@
# Custom m4 macros for Open Source Tripwire 2.4.3
# a non-symlinky variant of AC_PROG_LN_S, via: http://www.opensource.apple.com/source/zsh/zsh-34/zsh/aclocal.m4
#
AC_DEFUN([AC_PROG_LN],
[AC_MSG_CHECKING(whether ln works)
AC_CACHE_VAL(ac_cv_prog_LN,
[rm -f conftestdata conftestlink
echo > conftestdata
if ln conftestdata conftestlink 2>/dev/null
then
rm -f conftestdata conftestlink
ac_cv_prog_LN="ln"
else
rm -f conftestdata
ac_cv_prog_LN="cp"
fi])dnl
LN="$ac_cv_prog_LN"
if test "$ac_cv_prog_LN" = "ln"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
AC_SUBST(LN)dnl
])

1
aclocal.m4 vendored
View File

@ -930,3 +930,4 @@ fi
INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
m4_include([acinclude.m4])

1578
autogen.sh Executable file

File diff suppressed because it is too large Load Diff

67
autogen.sh.README Normal file
View File

@ -0,0 +1,67 @@
a u t o g e n . s h
"also known as buildconf"
http://buildconf.brlcad.org
INTRODUCTION
============
The autogen.sh script provides automatic build system preparation for
projects that use the GNU Autotools build system. In brief, the
script is a drop-in replacement for running 'autoreconf' while
detecting and cleanly reporting on a variety of common configuration
issues.
The script does a lot more than 'autoreconf' can, though, accounting
for a lot of common issues, bugs, and misconfiguration problems that
would otherwise be problems passed on to your users. Unlike the
philosophy of some of the GNU developers, the autogen.sh script helps
make things "just work" a little better without imposing unnecessary
burden on your users.
INSTALLING
==========
To install the script, simply copy the script into your source
repository and run it:
sh autogen.sh
RUNNING
=======
The AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER
environment variables and corresponding _OPTIONS variables (e.g.
AUTORECONF_OPTIONS) may be used to override the default automatic
detection behaviors. Similarly the _VERSION variables will override
the minimum required version numbers. Otherwise, you can edit the
script directly to set minimum version numbers.
Examples:
To obtain help on usage:
./autogen.sh --help
To obtain verbose output:
./autogen.sh --verbose
To skip autoreconf and prepare manually:
AUTORECONF=false ./autogen.sh
To verbosely try running with an older (unsupported) autoconf:
AUTOCONF_VERSION=2.50 ./autogen.sh --verbose
CONTACT
=======
Author:
Christopher Sean Morrison <morrison@brlcad.org>
Patches:
Sebastian Pipping <sebastian@pipping.org>
The autogen.sh script is distributed under the terms of a standard
3-clause BSD-style license. See the script for the exact language.

5
clean Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
# Contributed by Barry Allard in 2.4.2.3 fork (github.com/steakknife/tripwire)
git clean -dff
git clean -Xff
rm -rf autom4te.cache

1496
config.guess vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,8 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* Define if building universal (internal helper macro) */
#undef AC_APPLE_UNIVERSAL_BUILD
/* Compile with debug code */
#undef DEBUG
@ -126,6 +129,9 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
@ -162,9 +168,17 @@
/* Version number of package */
#undef VERSION
/* Define to 1 if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
#if defined AC_APPLE_UNIVERSAL_BUILD
# if defined __BIG_ENDIAN__
# define WORDS_BIGENDIAN 1
# endif
#else
# ifndef WORDS_BIGENDIAN
# undef WORDS_BIGENDIAN
# endif
#endif
/* Define to empty if `const' does not conform to ANSI C. */
#undef const

774
config.sub vendored

File diff suppressed because it is too large Load Diff

10847
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@ dnl
AC_INIT
AC_CONFIG_SRCDIR([src/tw/tw.cpp])
AC_CANONICAL_TARGET([])
AM_INIT_AUTOMAKE(tripwire, 2.4.2.2)
AM_INIT_AUTOMAKE(tripwire, 2.4.3.0)
AM_CONFIG_HEADER(config.h)
dnl #################################
@ -17,8 +17,8 @@ chmod 755 install-sh 2> /dev/null
dnl ###############
dnl Setup defaults
dnl ###############
CFLAGS=${CFLAGS:-"-O -pipe -Wall -Wno-non-virtual-dtor"}
CXXFLAGS=${CXXFLAGS:-"-O -pipe -Wall -Wno-non-virtual-dtor"}
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"}
dnl #####################
dnl Configuration options
@ -42,6 +42,8 @@ AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_YACC
AC_PROG_LN_S
AC_PROG_LN
AC_PATH_PROG(path_to_vi, vi)
AC_PATH_PROG(path_to_sendmail, sendmail, "", [$PATH:/usr/libexec])
@ -118,7 +120,9 @@ dnl gethostbyname? Solaris has it somewhere else.
AC_CHECK_LIB(c, gethostbyname, [:], [
AC_CHECK_LIB(nsl, gethostbyname, [
LIBS="-lnsl $LIBS"
], [:]) ])
], [
AC_CHECK_LIB(network, gethostbyname, [LIBS="-lnetwork $LIBS"] [:])
]) ])
dnl check for stl library
AC_LANG_SAVE

12
contrib/generate_from_template Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
set -e
if [ $# != 6 ]; then
echo "$0 file.in file.out TRIPWIRE_ROOT TRIPWIRE_ETC_DIR TRIPWIRE_DB_DIR TRIPWIRE_LOG_DIR" >&2
echo >&2
echo " file.in cannot be the same as file.out" >&2
exit 1
fi
sed "s%TRIPWIRE_ROOT%$3%g;s%TRIPWIRE_ETC_DIR%$4;s%TRIPWIRE_DB_DIR%$5%g;s%TRIPWIRE_LOG_DIR%$6%g" "$1" > "$2"
test -x "$1" && chmod +x "$2"

23
contrib/generic_install_scripts Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
#
# 1. install all tripwire_* scripts from contrib/
# 2. installs policy and config text files
# 3. installs the plist but does not launch it
#
set -e
## start config -- edits okay here
TRIPWIRE_ROOT="${TRIPWIRE_ROOT-/usr/local}"
TRIPWIRE_ETC_DIR="${TRIPWIRE_ETC_DIR-/etc}"
TRIPWIRE_DB_DIR="${TRIPWIRE_DB_DIR-/var/db/tripwire}"
TRIPWIRE_LOG_DIR="${TRIPWIRE_LOG_DIR-/var/log/tripwire}"
## end config -- dont edit past here
mkdir -p "$TRIPWIRE_ROOT" "$TRIPWIRE_ETC_DIR" "$TRIPWIRE_DB_DIR" "$TRIPWIRE_LOG_DIR"
THIS_SCRIPT_DIR="$(cd `dirname "$0"`; pwd)"
GENERATE_FROM_TEMPLATE="${THIS_SCRIPT}/generate_from_template"
for GENERIC_SCRIPT in tripwire_*; do
"$GENERATE_FROM_TEMPLATE" $GENERIC_SCRIPT "$TRIPWIRE_ROOT/sbin/$GENERIC_SCRIPT" "$TRIPWIRE_ROOT" "$TRIPWIRE_ETC_DIR" "$TRIPWIRE_DB_DIR" "$TRIPWIRE_LOG_DIR"
done

View File

@ -1,21 +1,99 @@
#!/bin/sh
#!/usr/bin/env bash
#
# A very cheesy script to prep a release
#
set -e
PRODUCT=tripwire
VERSION=2.4.2.2
ARCH=x86
TYPE=bin
ROOT_DIR=$PRODUCT-$VERSION-$ARCH-$TYPE
EXCLUDES=.svn
VERSION=2.4.3.0
mkdir $ROOT_DIR
platform() {
case `uname` in
Darwin) echo 'osx' ;;
Linux) echo 'linux' ;;
FreeBSD) echo 'freebsd' ;;
*) echo 'unknown' ;;
esac
}
arch() {
case "$1" in
osx|freebsd|linux)
if file bin/tripwire | grep -q '64-bit'; then
echo 'x86_64'
else
echo 'x86'
fi
;;
*) echo 'unknown'
esac
}
PLATFORM=$(platform)
ARCH=$(arch $PLATFORM)
TYPE=bin
ROOT_DIR=$PRODUCT-$VERSION-$PLATFORM-$ARCH-$TYPE
EXCLUDES='.svn .git .gitignore'
EXCLUDES="$(for EXCLUDE in $EXCLUDES; do echo --exclude $EXCLUDE; done)"
SCRIPT_DIR="$(cd `dirname $0`; pwd)"
SCRIPT_DIR_DOTDOT="$(dirname "$SCRIPT_DIR")"
if ! test -x bin/tripwire* ; then
echo "tripwire not ready for release (bins not found in bin/ dir)" >&2
exit 1
fi
trap 'RESULT=$?; rm -rf "$SCRIPT_DIR_DOTDOT/releases/$ROOT_DIR"; exit $RESULT' INT QUIT EXIT TERM ERR
mkdir -p "$SCRIPT_DIR_DOTDOT/releases"
cd "$SCRIPT_DIR_DOTDOT/releases"
mkdir "$ROOT_DIR"
ln -s ../bin ../contrib ../man ../policy $ROOT_DIR/
ln -s ../COPYING ../ChangeLog ../INSTALL ../MAINTAINERS $ROOT_DIR/
ln -s ../COPYING ../ChangeLog ../Packaging ../ReadMe-2.4.3 ../MAINTAINERS $ROOT_DIR/
ln -s ../TRADEMARK ../COMMERCIAL ../install ../install-sh $ROOT_DIR/
tar jhcf $ROOT_DIR.tar.bz2 $ROOT_DIR --exclude $EXCLUDES
EXTENSIONS=(tar.bz2 tar.gz tar.xz)
TAR_OPTIONS=(j z J)
sha1sum $ROOT_DIR.tar.bz2 > $ROOT_DIR.sha1
sha1sum bin/* >> $ROOT_DIR.sha1
sha1() {
sha1sum "$@" || shasum "$@"
}
sha512() {
sha512sum "$@" || shasum -a 512 "$@"
}
sign() {
if which gpg >/dev/null 2>&1; then
gpg --detach-sign --output "$1.asc" "$1"
else
echo "gpg unavailable, release is unsigned !!" >&2
exit 1
fi
}
for INDEX in 1 2 3; do
EXTENSION="${EXTENSIONS[$INDEX]}"
TAR_OPTIONS="${TAR_OPTIONS[$INDEX]}"
TARBALL="$ROOT_DIR.${EXTENSION}"
tar $EXCLUDES -${TAR_OPTIONS}hcf $TARBALL $ROOT_DIR
sha1 $TARBALL > $ROOT_DIR.sha1
sha1 bin/* >> $ROOT_DIR.sha1
sha512 $TARBALL > $ROOT_DIR.sha512
sha512 bin/* >> $ROOT_DIR.sha512
# sign the tarball
sign $TARBALL
# sign the hashes
sign $ROOT_DIR.sha1
sign $ROOT_DIR.sha512
done

41
contrib/osx/README.md Normal file
View File

@ -0,0 +1,41 @@
# OSX readme
## What this does
- Runs tripwire whenever connected to power
- Automatically grooms logs (not reports, its a todo)
## Installation
1. Edit `./homebrew_install_scripts_and_config` to taste
2. Run `./homebrew_install_scripts_and_config` as root
3. Modify `TRIPWIRE_ETC_DIR/twcfg.txt` and `TRIPWIRE_ETC_DIR/twpol.txt` to taste
4. Make up two brand-new, 24+ character passwords (they MUST not be the same), and store them securely before continuing:
- site passphrase
- local passphrase
5. Run the following commands as root:
```
TRIPWIRE_ROOT/sbin/tripwire_set_site_and_local_passphrases
TRIPWIRE_ROOT/sbin/tripwire_update_config_file # twcfg.txt -> tw.cfg
TRIPWIRE_ROOT/sbin/tripwire_update_policy_file # twpol.txt -> tw.pol
TRIPWIRE_ROOT/sbin/tripwire --init # this creates a new encrypted database
```
6. Enable periodic jobs (run as root):
```
launchctl load -w /Library/LaunchDaemons/org.tripwire.Tripwire.plist
```
## Uninstallation (run with sudo or su)
launchctl unload -w /Library/LaunchDaemons/org.tripwire.Tripwire.plist
rm -f /Library/LaunchDaemons/org.tripwire.Tripwire.plist
TRIPWIRE_ROOT/sbin/tripwire_uninstall
# or remove everything: TRIPWIRE_ROOT/sbin/tripwire_uninstall -A

View File

@ -0,0 +1,35 @@
#!/bin/sh
#
# 1. install all tripwire_* scripts from contrib/ and contrib/osx/
# 2. installs policy and config text files
# 3. installs the plist but does not launch it
#
set -e
## start config -- edits okay here
TRIPWIRE_ROOT="${TRIPWIRE_ROOT-/usr/local/tripwire}"
TRIPWIRE_ETC_DIR="${TRIPWIRE_ETC_DIR-$TRIPWIRE_ROOT/etc}"
TRIPWIRE_DB_DIR="${TRIPWIRE_DB_DIR-$TRIPWIRE_ROOT/lib/tripwire}"
TRIPWIRE_LOG_DIR="${TRIPWIRE_LOG_DIR-/usr/local/var/log}"
## end config -- dont edit past here
export TRIPWIRE_ROOT
export TRIPWIRE_ETC_DIR
export TRIPWIRE_DB_DIR
export TRIPWIRE_LOG_DIR
THIS_SCRIPT_DIR="$(cd `dirname "$0"`; pwd)"
THIS_SCRIPT_DIR_DOTDOT="$(dirname "$THIS_SCRIPT_DIR")"
GENERATE_FROM_TEMPLATE="${THIS_SCRIPT_DIR_DOTDOT}/generate_from_template"
"$THIS_SCRIPT_DIR_DOTDOT/generic_install_scripts"
for OSX_SCRIPT in tripwire_*; do
"$GENERATE_FROM_TEMPLATE" $OSX_SCRIPT "$TRIPWIRE_ROOT/sbin/$OSX_SCRIPT" "$TRIPWIRE_ROOT" "$TRIPWIRE_ETC_DIR" "$TRIPWIRE_DB_DIR" "$TRIPWIRE_LOG_DIR"
done
for ETC_FILE_SAMPLE in tw*.txt.sample; do
ETC_FILE="$(echo $ETC_FILE | sed 's/\.sample//')"
"$GENERATE_FROM_TEMPLATE" $ETC_FILE_SAMPLE "$TRIPWIRE_ETC_DIR/$ETC_FILE" "$TRIPWIRE_ROOT" "$TRIPWIRE_ETC_DIR" "$TRIPWIRE_DB_DIR" "$TRIPWIRE_LOG_DIR"
done
"$GENERATE_FROM_TEMPLATE" org.tripwire.Tripwire.plist /Library/LaunchDaemons/org.tripwire.Tripwire.plist "$TRIPWIRE_ROOT" "$TRIPWIRE_ETC_DIR" "$TRIPWIRE_DB_DIR" "$TRIPWIRE_LOG_DIR"

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.tripwire.Tripwire</string>
<key>Nice</key>
<integer>5</integer>
<key>ProgramArguments</key>
<array>
<string>TRIPWIRE_ROOT/sbin/tripwire_periodic_check</string>
</array>
<key>Disabled</key>
<true/>
<key>RunAtLoad</key>
<false/>
<key>StartInterval</key>
<integer>3600</integer>
</dict>
</plist>

View File

@ -0,0 +1,15 @@
ROOT =TRIPWIRE_ROOT/sbin
POLFILE =TRIPWIRE_ETC_DIR/tw.pol
DBFILE =TRIPWIRE_DB_DIR/$(HOSTNAME).twd
REPORTFILE =TRIPWIRE_DB_DIR/report/$(HOSTNAME)-$(DATE).twr
SITEKEYFILE =TRIPWIRE_ETC_DIR/site.key
LOCALKEYFILE =TRIPWIRE_ETC_DIR/$(HOSTNAME)-local.key
EDITOR =/usr/bin/vi
LATEPROMPTING =false
LOOSEDIRECTORYCHECKING =false
MAILNOVIOLATIONS =true
EMAILREPORTLEVEL =3
REPORTLEVEL =3
MAILMETHOD =SENDMAIL
SYSLOGREPORTING =false
MAILPROGRAM =/usr/sbin/sendmail -oi -t

View File

@ -0,0 +1,366 @@
##############################################################################
# ##
############################################################################## #
# # #
# Policy file for Mac OS X # #
# December 31, 2013 # #
# ##
##############################################################################
##############################################################################
# ##
############################################################################## #
# # #
# 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
TW_ROOT="TRIPWIRE_ROOT"
TW_DB_DIR="TRIPWIRE_DB_DIR"
TW_ETC_DIR="TRIPWIRE_ETC_DIR"
TWDOCS="$(TW_ROOT)/doc/tripwire";
TWBIN="$(TW_ROOT)/sbin";
TWPOL="$(TW_ETC_DIR)";
TWDB="$(TW_DB_DIR)";
TWSKEY="$(TW_ETC_DIR)";
TWLKEY="$(TW_ETC_DIR)";
TWREPORT="$(TW_DB_DIR)/report";
#USER1=frodo ;
##############################################################################
# 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
#
##############################################################################
SEC_DEVICE = +pugsr-dintlbamcCMSH ;
SEC_DYNAMIC = +pinugt-dsrlbamcCMSH ;
SEC_READONLY = +pinugtsbmCM-drlacSH ;
SEC_GROWING = +pinugtl-dsrbamcCMSH ;
IgnoreAll = -pinugtsdrlbamcCMSH ;
IgnoreNone = +pinugtsdrbamcCMSH-l ;
Temporary = +pugt ;
@@section FS
########################################
# ##
######################################## #
# # #
# Tripwire Binaries and Data Files # #
# ##
########################################
# Tripwire Binaries
(
rulename = "Tripwire Binaries", severity=100
)
{
$(TWBIN)/siggen -> $(SEC_READONLY) ;
$(TWBIN)/tripwire -> $(SEC_READONLY) ;
$(TWBIN)/twadmin -> $(SEC_READONLY) ;
$(TWBIN)/twprint -> $(SEC_READONLY) ;
}
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
(
rulename = "Tripwire Data Files", severity=100
)
{
# 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_DYNAMIC) -i ;
$(TWPOL)/tw.pol -> $(SEC_READONLY) -i ;
$(TWPOL)/tw.cfg -> $(SEC_READONLY) -i ;
# $(TWLKEY)/local.key -> $(SEC_READONLY) ;
$(TWSKEY)/site.key -> $(SEC_READONLY) ;
# don't scan the individual reports
$(TWREPORT) -> $(SEC_DYNAMIC)(recurse=0) ;
}
################################################
# ##
################################################ #
# # #
# OS Boot and Configuration Files # #
# ##
################################################
(
rulename = "OS Boot and Configuration Files", severity=100
)
{
#/mach.sym -> $(SEC_READONLY)-im ;
/mach_kernel -> $(SEC_READONLY) ;
/private/etc -> $(SEC_READONLY)-m ;
#/private/etc/appletalk.cfg -> $(SEC_READONLY)-im ;
#/private/etc/appletalk.nvram.en0 -> $(SEC_DYNAMIC) ;
/private/etc/cups/certs -> $(SEC_DYNAMIC) -i(recurse=0) ;
#/private/etc/smb.conf -> $(SEC_READONLY)-im ;
/Library -> $(SEC_READONLY) ;
/System -> $(SEC_READONLY) ;
/Library/Printers -> $(SEC_READONLY)(recurse=2) ;
/Library/Documentation -> $(SEC_READONLY)(recurse=2) ;
/Library/Filesystems -> $(SEC_DYNAMIC)-i ;
/Library/"Application Support" -> $(SEC_DYNAMIC)-im(recurse=2) ;
/System/Library/Filesystems -> $(SEC_DYNAMIC)-i ;
/System/Library/CoreServices -> $(SEC_READONLY)-im ;
/System/Library/Filesystems/hfs.fs -> $(SEC_DYNAMIC)(recurse=0) ;
}
###################################################
# ##
################################################### #
# # #
# Mount Points # #
# ##
###################################################
(
rulename = "Mount Points", severity=60
)
{
/ -> $(SEC_READONLY)(recurse=0) ;
/Volumes -> $(SEC_READONLY)-M (recurse=0) ;
/usr -> $(SEC_READONLY)(recurse=0) ;
}
################################################
# ##
################################################ #
# # #
# System Devices # #
# ##
################################################
(
rulename = "System Devices", severity=60
)
{
/dev -> $(SEC_DEVICE)(recurse=0) ;
}
################################################
# ##
################################################ #
# # #
# OS Binaries and Libraries # #
# ##
################################################
(
rulename = "OS Binaries and Libraries", severity=100
)
{
/bin -> $(SEC_READONLY) ;
/sbin -> $(SEC_READONLY) ;
/usr/bin -> $(SEC_READONLY) ;
/usr/lib -> $(SEC_READONLY) ;
/usr/libexec -> $(SEC_READONLY) ;
/usr/sbin -> $(SEC_READONLY) ;
/usr/X11 -> $(SEC_READONLY)(recurse=2) ; # May not be present
#/usr/X11/man -> $(SEC_DYNAMIC)-i(recurse=1) ; # May not be present
/usr/share -> $(SEC_READONLY) ;
/usr/share/man -> $(SEC_DYNAMIC)-i(recurse=1) ;
}
################################################
# ##
################################################ #
# # #
# OS X Applications # #
# ##
################################################
(
rulename = "OS Binaries and Libraries", severity=100
)
{
/Applications -> $(SEC_READONLY)-im(recurse=2) ;
}
################################################
# ##
################################################ #
# # #
# Usr Local Files # #
# ##
################################################
(
rulename = "Usr Local Files", severity=60
)
{
/usr/local -> $(SEC_READONLY) ;
/usr/local/sbin -> $(SEC_READONLY) ;
/usr/local/bin -> $(SEC_READONLY) ;
/usr/local/include -> $(SEC_READONLY) ;
/usr/local/opt -> $(SEC_READONLY) ;
/usr/local/libexec -> $(SEC_READONLY) ;
/usr/local/lib -> $(SEC_READONLY) ;
/usr/local/etc -> $(SEC_READONLY) ;
/usr/local/share -> $(SEC_READONLY) ;
/usr/local/man -> $(SEC_READONLY) ;
/usr/local/Frameworks -> $(SEC_READONLY) ;
# Homebrew
/usr/local/.git -> $(SEC_READONLY) ;
/usr/local/Cellar -> $(SEC_READONLY) ;
}
################################################
# ##
################################################ #
# # #
# Temporary Files and Directories # #
# ##
################################################
(
rulename = "Variable System Files", severity=60
)
{
/private/tmp -> $(SEC_DYNAMIC)-in(recurse=0) ;
/private/tftpboot -> $(SEC_READONLY)-i ;
/private/var -> $(SEC_READONLY)-i ;
/private/var/backups -> $(SEC_READONLY)-imc(severity=100) ;
#/private/var/backups/local.nidump -> $(SEC_DYNAMIC) -i(severity=100) ;
#/private/var/cron -> $(SEC_DYNAMIC) -i ;
/private/var/db -> $(SEC_READONLY)-im ;
/private/var/db/BootCache.playlist -> $(SEC_DYNAMIC) -i ;
#/private/var/db/netinfo/local.nidb/Store.384 -> $(SEC_READONLY)-imc(severity=100) ;
#/private/var/db/netinfo/local.nidb/Store.672 -> $(SEC_READONLY)-imc(severity=100) ;
#/private/var/db/prebindOnDemandBadFiles -> $(SEC_DYNAMIC) -i ;
/private/var/log -> $(SEC_DYNAMIC) -i ;
#/private/var/mail -> $(SEC_DYNAMIC) ;
/private/var/msgs/bounds -> $(SEC_READONLY)-smbCM ;
/private/var/root/Library/Caches -> $(SEC_DYNAMIC) -i ;
/private/var/run -> $(SEC_DYNAMIC) -i(rulename="Running Services") ;
#/private/var/slp.regfile -> $(SEC_READONLY)-im ;
#/private/var/spool/clientmqueue -> $(SEC_DYNAMIC)(recurse=0) ;
/private/var/spool/mqueue -> $(SEC_DYNAMIC)(recurse=0) ;
#/private/var/spool/lock -> $(SEC_DYNAMIC) -i(recurse=1) ;
/private/var/spool/cups -> $(SEC_DYNAMIC) -i(recurse=0) ;
/private/var/tmp -> $(SEC_DYNAMIC) -i(recurse=0) ;
/private/var/vm -> $(SEC_DYNAMIC)(recurse=0) ;
/Library/Caches -> $(SEC_DYNAMIC) -i ;
/Library/Logs -> $(SEC_DYNAMIC) -i(recurse=1) ;
/Library/Preferences -> $(SEC_DYNAMIC) -i(recurse=1) ;
"/Library/Internet Plug-Ins" -> $(SEC_DYNAMIC) -i ;
!/private/var/db/dhcpclient ;
!/private/var/db/dhcpd_leases ;
!/private/var/db/locate.database ;
!/private/var/db/SystemEntropyCache ;
!/private/var/db/mds/messages/se_SecurityMessages ;
!/private/var/db/samba/secrets.tdb ;
!/private/var/db/ntp.drift ;
!/private/var/folders ;
!/private/var/vm/sleepimage ;
!/private/var/vm/swap0 ;
!/private/var/vm/swap[1-9][0-9]* ;
# Sophos
!/Library/Caches/com.sophos.sau ;
!/Library/Caches/com.sophos.sxld ;
}
###################################################
# ##
################################################### #
# # #
# User Home Directories # #
# ##
###################################################
(
rulename = "Home Directories", severity=60
)
{
/Users -> $(SEC_READONLY)(recurse=0) ; # Modify as needed
#####
#
# USER1 as defined at top of policy
#
#####
# /Users/$(USER1) -> $(SEC_READONLY)-mc ;
# /Users/$(USER1)/Library/Preferences -> $(SEC_DYNAMIC)-i ;
# "/Users/$(USER1)/Library/Recent Servers" -> $(SEC_DYNAMIC)-i ;
# "/Users/$(USER1)/Library/Safari" -> $(SEC_DYNAMIC)-i(recurse=3) ;
# "/Users/$(USER1)/Library/Spelling" -> $(SEC_DYNAMIC)-i ;
# "/Users/$(USER1)/Library/Mail" -> $(SEC_DYNAMIC)-i(recurse=2) ;
# "/Users/$(USER1)/Pictures/iPhoto Library" -> $(SEC_DYNAMIC)-i(recurse=1) ;
# "/Users/$(USER1)/Library/Application Support" -> $(SEC_DYNAMIC)-im(recurse=2) ;
# /Users/$(USER1)/Documents -> $(SEC_DYNAMIC)(recurse=0) ;
# /Users/$(USER1)/Desktop -> $(SEC_DYNAMIC)(recurse=0) ;
#!"/Users/$(USER1)/Documents/Virtual PC List" ; # These items are *huge*, and are of little value to scan.
#!"/Users/$(USER1)/Library/Preferences/Microsoft/Clipboard" ;
#!"/Users/$(USER1)/Library/Safari/Icons" ;
#!"/Users/$(USER1)/Music/iTunes" ;
#!"/Users/$(USER1)/Library/Caches" ;
#!"/Users/$(USER1)/Library/Cookies" ;
#!"/Users/$(USER1)/Library/Logs" ;
#!"/Users/$(USER1)/Library/Folding@home" ;
#!"/Users/$(USER1)/setiathome" ;
#!"/Users/$(USER1)/Documents/seti-A" ;
#!"/Users/$(USER1)/Documents/seti-B" ;
#!"/Users/$(USER1)/.tcsh_history" ;
#!"/Users/$(USER1)/.DS_Store" ;
#!"/Users/$(USER1)/Public/.DS_Store" ;
#!"/Users/$(USER1)/.jpi_cache" ;
#!"/Users/$(USER1)/.lpoptions" ;
#!"/Users/$(USER1)/.Trash" ;
}

View File

@ -0,0 +1,6 @@
#!/bin/sh
TIMESTAMP=$(/bin/date +%Y-%m-%dT%H:%M:%S%z)
REPORT="$(find TRIPWIRE_ROOT/lib/tripwire/report -type f | tail -1)"
read -p "Accept $REPORT ? [accept] " PROMPT
test "$PROMPT" != 'accept' && exit 1
time TRIPWIRE_ROOT/sbin/tripwire -m u -a -r "$REPORT" 2>&1 | tee TRIPWIRE_LOG_DIR/tripwire_database-updated-baseline_$TIMESTAMP.log

23
contrib/tripwire_check Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
#
# Tripwire cron script borrowed from Linux and modified for generic situations.
# You should of course change path names to suit your environment.
#
# Contributed by Timothy K Ewing <Timothy.Ewing@celera.com>
#
HOST_NAME=`uname -n`
TWCFG_PATH=TRIPWIRE_ETC_DIR
TWDB_PATH=TRIPWIRE_DB_DIR
TWROOT_PATH=TRIPWIRE_ROOT
MAILTO="root" # Email addresses that should recieve reports
#
# Define checks which alert user to misconfiguration or run the check
#
if [ ! -e ${TWDB_PATH}/${HOST_NAME}.twd ]; then
echo "**** Error: Tripwire database for ${HOST_NAME} not found. ****"
echo "**** Verify tripwire was installed and/or "tripwire --init". ****"
else
test -f ${TWCFG_PATH}/tw.cfg && ${TWROOT_PATH}/tripwire --check | \
mail -s "${HOST_NAME} tripwire-check" ${MAILTO}
fi

50
contrib/tripwire_log_rotate Executable file
View File

@ -0,0 +1,50 @@
#!/bin/sh -e
RM='rm -f'
#RM='echo rm -f'
LOG_START="$1"
LOG_EXT="$2"
NOW="$(/bin/date +%Y%m%d)"
NOW_YEAR="$(echo $NOW | cut -c-4)"
NOW_MONTH="$(echo $NOW | cut -c5-6)"
NOW_DAY="$(echo $NOW | cut -c7-8)"
LOG_START_LEN="$(echo $LOG_START | wc -c | awk '{print$1}')"
YEARS="$(ls $LOG_START*$LOG_EXT | cut -c$LOG_START_LEN-$[LOG_START_LEN+3] | sort -u)"
for YEAR in $YEARS; do
if [ "$YEAR" = "$NOW_YEAR" ]; then
# only keep one per day
for MONTH in `seq -f "%02g" 12`; do
for DAY in `seq -f "%02g" 31`; do
if [ "$NOW_MONTH" = "$MONTH" ] && [ "$NOW_DAY" = "$DAY" ]; then
# if now is today, dont prune anything
:;
else
# save only the first report per day
FILES="$(ls -rt ${LOG_START}${YEAR}-${MONTH}-${DAY}T*${LOG_EXT} 2>/dev/null | tail -n +2)"
#FILES="$(ls -rt ${LOG_START}${YEAR}-${MONTH}-${DAY}T*${LOG_EXT} | tail -n +2)"
if [ -n "$FILES" ]; then
set -x
$RM $FILES
set +x
fi
fi
done # DAY
done # MONTH
else # not current year
# only keep one per month
for MONTH in `seq -f "%02g" 12`; do
FILES="$(ls -rt ${LOG_START}${YEAR}-${MONTH}-*${LOG_EXT} 2>/dev/null | tail -n +2)"
#FILES="$(ls -rt ${LOG_START}${YEAR}-${MONTH}-*${LOG_EXT} | tail -n +2)"
if [ -n "$FILES" ]; then
set -x
$RM $FILES
set +x
fi
done # MONTH
fi
done # YEAR

18
contrib/tripwire_periodic_check Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
on_battery_power() {
case `uname` in
Darwin) pmset -g batt | grep -q discharging
*) false
esac
}
if on_battery_power; then
echo "Skipping tripwire check due to computer being on battery power" >&2
exit 1
fi
TIMESTAMP=$(/bin/date +%Y-%m-%dT%H:%M:%S%z)
time TRIPWIRE_ROOT/sbin/tripwire -m c 2>&1 | tee TRIPWIRE_LOG_DIR/tripwire_periodic_$TIMESTAMP.log
TRIPWIRE_ROOT/sbin/tripwire_log_rotate "TRIPWIRE_LOG_DIR/tripwire_periodic_" ".log"
## Todo: Automatically groom reports in `TRIPWIRE_DB_DIR/report/*.twr`

View File

@ -0,0 +1,3 @@
#!/bin/sh
# creates TRIPWIRE_ROOT/etc/site.key and TRIPWIRE_ROOT/etc/(hostname)-local.key
TRIPWIRE_ROOT/sbin/twadmin --generate-keys --local-keyfile TRIPWIRE_ROOT/etc/$(hostname -f)-local.key --site-keyfile TRIPWIRE_ROOT/etc/site.key

152
contrib/tripwire_uninstall Executable file
View File

@ -0,0 +1,152 @@
#!/bin/sh
set -e
unset NO_CONFIRM
unset NO_REMOVE
unset REMOVE_REPORTS
unset REMOVE_LOGS
unset REMOVE_DB
unset REMOVE_KEYS
unset RM
UNAME=`uname`
help() {
cat >&2 << 'HELP'
tripwire_uninstall [-y] [-N] [ [-R] [-L] [-D] [-K] | [-A] ]
-y no confirmation (unattended operation)
-N dont remove binaries, docs and man pages
-A remove everything (logs, reports, db and keys)
-R remove reports
-L remove logs
-D remove db
-K remove keys
-N with -Y is valid
HELP
}
while [ "$#" != 0 ]; do
case "$1" in
-y) NO_CONFIRM=1 ;;
-N) NO_REMOVE=1 ;;
-L) REMOVE_LOGS=1 ;;
-D) REMOVE_DB=1 ;;
-K) REMOVE_KEYS=1 ;;
-A) REMOVE_LOGS=1
REMOVE_KEYS=1
REMOVE_DB=1
;;
*) help ; exit 1
esac
shift
done
secure_rm() {
case $UNAME in
Darwin)
/usr/bin/srm -vf -- "$@"
;;
Linux)
/usr/bin/shred -vfu -- "$@"
;;
FreeBSD|*)
# 3x wipe
for FILE in "$@"; do
/bin/dd if=/dev/random of="$FILE" bs=1 count=$(/usr/bin/wc -c < "$FILE" | /usr/bin/sed "s/[^0-9]//g")
/bin/dd if=/dev/random of="$FILE" bs=1 count=$(/usr/bin/wc -c < "$FILE" | /usr/bin/sed "s/[^0-9]//g")
/bin/dd if=/dev/random of="$FILE" bs=1 count=$(/usr/bin/wc -c < "$FILE" | /usr/bin/sed "s/[^0-9]//g")
done
rm -vf "$@"
;;
esac
}
secure_rm_rf() {
case $UNAME in
Darwin)
/usr/bin/srm -vrf -- "$@"
;;
Linux)
/usr/bin/find "$@" -type f -exec /usr/bin/shred -vfu -- {} \;
rm -vrf "$@"
;;
FreeBSD|*)
# 3x wipe
/usr/bin/find "$@" -type f | xargs -I% sh -c '/bin/dd if=/dev/random of="%" bs=1 count=$(/usr/bin/wc -c < "%" | /usr/bin/sed "s/[^0-9]//g")'
/usr/bin/find "$@" -type f | xargs -I% sh -c '/bin/dd if=/dev/random of="%" bs=1 count=$(/usr/bin/wc -c < "%" | /usr/bin/sed "s/[^0-9]//g")'
/usr/bin/find "$@" -type f | xargs -I% sh -c '/bin/dd if=/dev/random of="%" bs=1 count=$(/usr/bin/wc -c < "%" | /usr/bin/sed "s/[^0-9]//g")'
rm -vrf "$@"
;;
esac
}
if [ -n "$NO_CONFIRM" ]; then
:; # noop
else
printf "Uninstall tripwire ? [Yn] "
unset PROMPT
read PROMPT
if [ "$PROMPT" = 'y' ] || [ "$PROMPT" = 'Y' ]; then
:; # noop
else
echo "user cancelled" >&2
exit 1
fi
fi
if [ -z "$NO_REMOVE" ]; then
echo "removing tripwire binaries, scripts, docs and man pages" >&2
# binaries
secure_rm "TRIPWIRE_ROOT/sbin/siggen"
secure_rm "TRIPWIRE_ROOT/sbin/tripwire"
secure_rm "TRIPWIRE_ROOT/sbin/twadmin"
secure_rm "TRIPWIRE_ROOT/sbin/twprint"
# scripts
secure_rm "TRIPWIRE_ROOT/sbin/tripwire_"*
# docs
secure_rm_rf "TRIPWIRE_ROOT/doc/tripwire"
# man pages
secure_rm "TRIPWIRE_ROOT/share/man/man4/twconfig.4"
secure_rm "TRIPWIRE_ROOT/share/man/man4/twpolicy.4"
secure_rm "TRIPWIRE_ROOT/share/man/man5/twfiles.5"
secure_rm "TRIPWIRE_ROOT/share/man/man8/siggen.8"
secure_rm "TRIPWIRE_ROOT/share/man/man8/tripwire.8"
secure_rm "TRIPWIRE_ROOT/share/man/man8/twadmin.8"
secure_rm "TRIPWIRE_ROOT/share/man/man8/twintro.8"
secure_rm "TRIPWIRE_ROOT/share/man/man8/twprint.8"
fi
if [ -n "$REMOVE_REPORTS" ]; then
echo "removing tripwire reports" >&2
secure_rm "TRIPWIRE_ROOT/lib/tripwire/report"/*.twr
fi
if [ -n "$REMOVE_LOGS" ]; then
echo "removing tripwire logs" >&2
secure_rm "TRIPWIRE_LOG_DIR/tripwire_periodic_"*.log
fi
if [ -n "$REMOVE_DB" ]; then
echo "removing tripwire db" >&2
secure_rm "TRIPWIRE_ROOT/lib/tripwire"/*.twd*
fi
if [ -n "$REMOVE_KEYS" ]; then
echo "removing tripwire keys" >&2
secure_rm "TRIPWIRE_ROOT/etc"/*.key
fi
echo "finished removing tripwire" >&2

View File

@ -0,0 +1,22 @@
#!/bin/sh
#
# Overwrites TRIPWIRE_ROOT/etc/tw.cfg
# TRIPWIRE_ROOT/etc/twcfg.txt -> TRIPWIRE_ROOT/etc/tw.cfg
#
set -e
if [ ! -e "TRIPWIRE_ROOT/etc/site.key" ]; then
echo "Missing TRIPWIRE_ROOT/etc/site.key" >&2
echo >&2
echo "Run TRIPWIRE_ROOT/sbin/tripwire_set_site_and_local_passphrases first" >&2
exit 1
fi
if [ ! -e "TRIPWIRE_ROOT/etc/twcfg.txt" ]; then
echo "Missing TRIPWIRE_ROOT/etc/twcfg.txt" >&2
echo >&2
echo "Create and customize it for your environment and try again" >&2
exit 1
fi
TRIPWIRE_ROOT/sbin/twadmin --create-cfgfile -S TRIPWIRE_ROOT/etc/site.key TRIPWIRE_ROOT/etc/twcfg.txt

View File

@ -0,0 +1,29 @@
#!/bin/sh
#
# Overwrites TRIPWIRE_ROOT/etc/tw.pol
# TRIPWIRE_ROOT/etc/twpol.txt -> TRIPWIRE_ROOT/etc/tw.pol
#
set -e
if [ ! -e "TRIPWIRE_ROOT/etc/site.key" ]; then
echo "Missing TRIPWIRE_ROOT/etc/site.key" >&2
echo >&2
echo "Run TRIPWIRE_ROOT/sbin/tripwire_set_site_and_local_passphrases first" >&2
exit 1
fi
if [ ! -e "TRIPWIRE_ROOT/etc/tw.cfg" ]; then
echo "Missing TRIPWIRE_ROOT/etc/tw.cfg" >&2
echo >&2
echo "Run TRIPWIRE_ROOT/sbin/tripwire_update_config_file first" >&
exit 1
fi
if [ ! -e "TRIPWIRE_ROOT/etc/twpol.txt" ]; then
echo "Missing TRIPWIRE_ROOT/etc/twpol.txt" >&2
echo >&2
echo "Create and customize it for your environment and try again" >&2
exit 1
fi
TRIPWIRE_ROOT/sbin/twadmin --create-polfile -S TRIPWIRE_ROOT/etc/site.key TRIPWIRE_ROOT/etc/twpol.txt

View File

@ -37,7 +37,8 @@ host_triplet = @host@
subdir = man
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -91,6 +92,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -99,6 +102,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@

View File

@ -1,2 +1,3 @@
AUTOMAKE_OPTIONS = foreign no-dependencies
man_MANS = twconfig.4 twpolicy.4
dist_man_MANS = twconfig.4 twpolicy.4

View File

@ -35,9 +35,11 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = man/man4
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -50,7 +52,7 @@ DIST_SOURCES =
man4dir = $(mandir)/man4
am__installdirs = "$(DESTDIR)$(man4dir)"
NROFF = nroff
MANS = $(man_MANS)
MANS = $(dist_man_MANS) $(man_MANS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
@ -86,6 +88,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -94,6 +98,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
@ -155,6 +160,7 @@ target_os = @target_os@
target_vendor = @target_vendor@
AUTOMAKE_OPTIONS = foreign no-dependencies
man_MANS = twconfig.4 twpolicy.4
dist_man_MANS = twconfig.4 twpolicy.4
all: all-am
.SUFFIXES:

View File

@ -274,6 +274,11 @@ However, mailing no violations reports will increase the amount of data
that must be processed.
.br
Initial value: \fItrue\fR
.IP \f(CWMAILFROMADDRESS\fP
Specifies the value of the "From:" field in email reports.
.br
Initial value: \fItripwire@hostname\fP, where 'hostname' is the local
machine name.
.SH VERSION INFORMATION
This man page describes
.IR "Tripwire 2.4" "."

View File

@ -1,2 +1,3 @@
AUTOMAKE_OPTIONS = foreign no-dependencies
man_MANS = twfiles.5
dist_man_MANS = twfiles.5

View File

@ -35,9 +35,11 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = man/man5
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -50,7 +52,7 @@ DIST_SOURCES =
man5dir = $(mandir)/man5
am__installdirs = "$(DESTDIR)$(man5dir)"
NROFF = nroff
MANS = $(man_MANS)
MANS = $(dist_man_MANS) $(man_MANS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
@ -86,6 +88,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -94,6 +98,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
@ -155,6 +160,7 @@ target_os = @target_os@
target_vendor = @target_vendor@
AUTOMAKE_OPTIONS = foreign no-dependencies
man_MANS = twfiles.5
dist_man_MANS = twfiles.5
all: all-am
.SUFFIXES:

View File

@ -1,2 +1,3 @@
AUTOMAKE_OPTIONS = foreign no-dependencies
man_MANS = siggen.8 tripwire.8 twadmin.8 twintro.8 twprint.8
dist_man_MANS = siggen.8 tripwire.8 twadmin.8 twintro.8 twprint.8

View File

@ -35,9 +35,11 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = man/man8
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -50,7 +52,7 @@ DIST_SOURCES =
man8dir = $(mandir)/man8
am__installdirs = "$(DESTDIR)$(man8dir)"
NROFF = nroff
MANS = $(man_MANS)
MANS = $(dist_man_MANS) $(man_MANS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
@ -86,6 +88,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -94,6 +98,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
@ -155,6 +160,7 @@ target_os = @target_os@
target_vendor = @target_vendor@
AUTOMAKE_OPTIONS = foreign no-dependencies
man_MANS = siggen.8 tripwire.8 twadmin.8 twintro.8 twprint.8
dist_man_MANS = siggen.8 tripwire.8 twadmin.8 twintro.8 twprint.8
all: all-am
.SUFFIXES:

View File

@ -2,28 +2,25 @@
.\" Do not move or remove previous line.
.\" Used by some man commands to know that tbl should be used.
.nh
.TH SIGGEN 8 "1 July 2000"
.TH SIGGEN 8 "19 Feb 2004"
.SH NAME
siggen \- signature gathering routine for Tripwire
.SH SYNOPSIS
.B siggen
.RI "[ " "options..." " ]"
.IR file1 " [ " "file2..." " ] "
.I Options:
.RS +0.5i
.TS
;
lbw(0.8i) lb.
-t --terse
-h --hexadecimal
-a --all
-C --CRC32
-M --MD5
-S --SHA
-H --HAVAL
.TE
.RE
[
.BR -t | --terse
] [
.BR -h | --hexadecimal
] [
.BR -a | --all
] [
.BR -C | --CRC32
] [
.BR -S | --SHA
] [
.BR -h | --HAVAL
]
.IR file1 ,,,
.SH DESCRIPTION
.PP
\fBsiggen\fP is a utility that displays the hash function values

View File

@ -273,6 +273,7 @@ lbw(1.2i) lb.
-x \fIsection\fP --section \fIsection\fP
-M --email-report
-t \fR{ 0|1|2|3|4 }\fP --email-report-level \fR{ 0|1|2|3|4 }\fP
-h --hexadecimal
.TE
.RI "[ " object1 " [ " object2... " ]]"
.RE
@ -369,6 +370,9 @@ EMAILREPORTLEVEL variable in the configuration file. \fIlevel\fR must
be a number from 0\ to\ 4.
Valid only with (\fB\(hyM\fP).
.TP
.BR \(hyh ", " --hexadecimal
Display hash values as hexadecimal in email reports
.TP
.RI "[ " object1 " [ " object2... " ]]"
List of files and directories that should be integrity checked.
Default is all files. If files are specified for checking, the

View File

@ -53,6 +53,7 @@ lbw(1.2i) lb.
-m r --print-report
-v --verbose
-s --silent\fR,\fP --quiet
-h --hexadecimal
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-r \fIreport\fP --twrfile \fIreport\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
@ -69,6 +70,9 @@ Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BR \(hyh ", " --hexadecimal
Display hash values as hexadecimal.
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Use the specified configuration file.
.TP
@ -92,6 +96,7 @@ lbw(1.2i) lb.
-m d --print-dbfile
-v --verbose
-s --silent\fR,\fP --quiet
-h --hexadecimal
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-d \fIdatabase\fP --dbfile \fIdatabase\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
@ -108,6 +113,9 @@ Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BR \(hyh ", " --hexadecimal
Display hash values as hexadecimal.
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Use the specified configuration file.
.TP

View File

@ -37,7 +37,8 @@ host_triplet = @host@
subdir = src
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -89,6 +90,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -97,6 +100,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@

View File

@ -1,2 +1,2 @@
#define BUILD_NUM _T("2")
#define BUILD_NUM _T("0")

View File

@ -1,2 +0,0 @@
#define BUILD_NUM _T("1")

View File

@ -40,7 +40,8 @@ host_triplet = @host@
subdir = src/core
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -117,6 +118,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -125,6 +128,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@

7
src/core/archive.cpp Normal file → Executable file
View File

@ -678,6 +678,7 @@ void cFileArchive::OpenRead(const TCHAR* filename, uint32 openFlags)
uint32 flags = cFile::OPEN_READ;
flags |= ( ( openFlags & FA_OPEN_TRUNCATE ) ? cFile::OPEN_TRUNCATE : 0 );
flags |= ( ( openFlags & FA_OPEN_TEXT ) ? cFile::OPEN_TEXT : 0 );
flags |= ( ( openFlags & FA_NONBLOCKING ) ? cFile::OPEN_NONBLOCKING :0 );
mCurrentFilename = filename;
mCurrentFile.Open( filename, flags );
@ -703,6 +704,7 @@ void cFileArchive::OpenReadWrite(const TCHAR* filename, uint32 openFlags)
uint32 flags = cFile::OPEN_WRITE;
flags |= ( ( openFlags & FA_OPEN_TRUNCATE ) ? cFile::OPEN_TRUNCATE : 0 );
flags |= ( ( openFlags & FA_OPEN_TEXT ) ? cFile::OPEN_TEXT : 0 );
flags |= ( ( openFlags & FA_NONBLOCKING ) ? cFile::OPEN_NONBLOCKING :0 );
mCurrentFilename = filename;
mCurrentFile.Open( filename, flags );
@ -883,11 +885,10 @@ void cLockedTemporaryFileArchive::OpenReadWrite( const TCHAR* filename, uint32 o
strTempFile += _T("twtempXXXXXX");
iFSServices::GetInstance()->MakeTempFilename( strTempFile );
}
catch( eFSServices& e)
catch( eFSServices& fileError)
{
TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY );
eArchiveOpen e(strTempFile, errStr);
throw e;
throw eArchiveOpen(strTempFile, errStr);
}
}
///////////////////////////////////////////////////////////////////////////////

5
src/core/archive.h Normal file → Executable file
View File

@ -85,6 +85,8 @@ TSS_EXCEPTION( eArchiveStringTooLong, eArchive );
class cArchive
{
public:
virtual ~cArchive() {}
// convenience methods
//
// Specific Read functions throw(eArchive) if EOF is reached because
@ -257,7 +259,8 @@ public:
enum OpenFlags
{
FA_OPEN_TEXT = 0x1,
FA_OPEN_TRUNCATE = 0x2
FA_OPEN_TRUNCATE = 0x2,
FA_NONBLOCKING = 0x4
};
// TODO: Open should throw

View File

@ -817,8 +817,9 @@ void cEncoder::ValidateSchema() const
bool cEncoder::OnlyOneCatagoryPerChar() const
{
// TODO:BAM - man, is there a better way to do this?
TCHAR ach[2] = {0};
TCHAR ch = std::numeric_limits<TCHAR>::min();
TSTRING ach(1,ch);
if( ch != std::numeric_limits<TCHAR>::max() )
{
do
@ -828,8 +829,7 @@ bool cEncoder::OnlyOneCatagoryPerChar() const
ach[0] = ch;
for( sack_type::const_iterator atE = m_encodings.begin(); atE != m_encodings.end(); atE++ )
{
TSTRING::const_iterator first(&ach[0]), last(&ach[1]);
if( (*atE)->NeedsEncoding( first, last ) )
if( (*atE)->NeedsEncoding( ach.begin(), ach.end() ) )
{
if( fFailedATest )
return false; // each char can only fail one test

9
src/core/errorutil.cpp Normal file → Executable file
View File

@ -43,14 +43,15 @@
#if IS_UNIX
namespace //unique
{
TCHAR* _itot( int value, TCHAR* string, int radix)
TCHAR* tw_itot( int value, TCHAR* string, int radix)
{
_stprintf( string, "%d", value );
return string;
}
}
#endif
#else
#define tw_itot _itot
#endif //IS_UNIX
eInternal::eInternal(TCHAR* sourceFile, int lineNum)
: eError(_T(""))
@ -60,7 +61,7 @@ eInternal::eInternal(TCHAR* sourceFile, int lineNum)
mMsg = _T("File: ");
mMsg += sourceFile;
mMsg += _T(" Line: ");
mMsg += _itot(lineNum, buf, 10);
mMsg += tw_itot(lineNum, buf, 10);
}
//=============================================================================

42
src/core/file.h Normal file → Executable file
View File

@ -47,7 +47,9 @@
#include "fileerror.h"
#endif
#ifdef __MINT__ // for off_t
#include <sys/types.h>
#endif
//=============================================================================
// eFile exception class
@ -73,8 +75,7 @@ class cFile
{
public:
#if IS_UNIX
typedef int32 File_t;
typedef off_t File_t;
#else //WIN32
typedef int64 File_t;
@ -82,22 +83,22 @@ public:
enum SeekFrom
{
SEEK_BEGIN = 0,
SEEK_CURRENT,
SEEK_EOF
SEEK_BEGIN = 0,
SEEK_CURRENT,
SEEK_EOF
};
enum OpenFlags
{
// note that reading from the file is implicit
//
OPEN_READ = 0x00000001, // not needed, but makes calls nice...
OPEN_WRITE = 0x00000002, // we will be writing to the file
OPEN_LOCKED_TEMP = 0x00000004, // the file should not be readable by other processes and should be removed when closed
OPEN_TRUNCATE = 0x00000008, // opens an empty file. creates it if it doesn't exist. Doesn't make much sense without OF_WRITE
OPEN_CREATE = 0x00000010, // create the file if it doesn't exist; this is implicit if OF_TRUNCATE is set
OPEN_TEXT = 0x00000020,
OPEN_EXCLUSIVE = 0x00000040 // Use O_CREAT | O_EXCL
// note that reading from the file is implicit
OPEN_READ = 0x00000001, // not needed, but makes calls nice...
OPEN_WRITE = 0x00000002, // we will be writing to the file
OPEN_LOCKED_TEMP = 0x00000004, // the file should not be readable by other processes and should be removed when closed
OPEN_TRUNCATE = 0x00000008, // opens an empty file. creates it if it doesn't exist. Doesn't make much sense without OF_WRITE
OPEN_CREATE = 0x00000010, // create the file if it doesn't exist; this is implicit if OF_TRUNCATE is set
OPEN_TEXT = 0x00000020,
OPEN_EXCLUSIVE = 0x00000040, // Use O_CREAT | O_EXCL
OPEN_NONBLOCKING = 0x00000080, // Use non-blocking i/o [Unix]
};
//Ctor, Dtor, CpyCtor, Operator=:
@ -140,5 +141,16 @@ public:
bool isWritable;
};
#ifdef __AROS__
class cArosPath
{
public:
static TSTRING AsPosix(const TSTRING& in);
static TSTRING AsNative(const TSTRING& in);
};
#endif
#endif //__FILE_H

52
src/core/file_unix.cpp Normal file → Executable file
View File

@ -119,8 +119,15 @@ cFile::~cFile()
///////////////////////////////////////////////////////////////////////////////
// Open
///////////////////////////////////////////////////////////////////////////////
#ifndef __AROS
void cFile::Open( const TSTRING& sFileName, uint32 flags )
{
#else
void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
{
TSTRING sFileName = cArosPath::AsNative(sFileNameC);
#endif
mode_t openmode = 0664;
if ( mpData->mpCurrStream != NULL )
Close();
@ -158,9 +165,13 @@ void cFile::Open( const TSTRING& sFileName, uint32 flags )
openmode = (mode_t) 0600; // Make sure only root can read the file
}
if ( flags & OPEN_CREATE )
perm |= O_CREAT;
if ( flags & OPEN_CREATE )
perm |= O_CREAT;
#ifdef O_NONBLOCK
if( flags & OPEN_NONBLOCKING )
perm |= O_NONBLOCK;
#endif
//
// actually open the file
//
@ -169,6 +180,8 @@ void cFile::Open( const TSTRING& sFileName, uint32 flags )
{
throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) );
}
#ifndef __AROS__
if( flags & OPEN_LOCKED_TEMP )
{
// unlink this file
@ -176,9 +189,10 @@ void cFile::Open( const TSTRING& sFileName, uint32 flags )
{
// we weren't able to unlink file, so close handle and fail
close( fh );
throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) );
throw( eFileOpen( sFileName, iFSServices::GetInstance()->GetErrString() ) );
}
}
#endif
//
// turn the file handle into a FILE*
@ -248,7 +262,7 @@ cFile::File_t cFile::Seek( File_t offset, SeekFrom From) const //throw(eFile)
fprintf(stderr, "%d\n", blowupCount);
#endif
if (fseek( mpData->mpCurrStream, offset, apiFrom ) != 0)
if (fseeko( mpData->mpCurrStream, offset, apiFrom ) != 0)
{
#ifdef _DEBUG
cDebug d("cFile::Seek");
@ -257,7 +271,7 @@ cFile::File_t cFile::Seek( File_t offset, SeekFrom From) const //throw(eFile)
throw eFileSeek();
}
return ftell( mpData->mpCurrStream );
return ftello(mpData->mpCurrStream);
}
///////////////////////////////////////////////////////////////////////////
@ -369,3 +383,31 @@ void cFile::Truncate( File_t offset ) // throw(eFile)
throw( eFileTrunc( mpData->mFileName, iFSServices::GetInstance()->GetErrString() ) );
}
#ifdef __AROS__
TSTRING cArosPath::AsPosix( const TSTRING& in )
{
if (in[0] == '/')
return in;
TSTRING out = '/' + in;
std::replace(out.begin(), out.end(), ':', '/');
return out;
}
TSTRING cArosPath::AsNative( const TSTRING& in )
{
if (in[0] != '/')
return in;
int x;
for (x=1; in[x] == '/' && x<in.length(); x++);
TSTRING out = in.substr(x);
TSTRING::size_type t = out.find_first_of('/');
out[t] = ':';
return out;
}
#endif

View File

@ -66,7 +66,9 @@
//=========================================================================
#if IS_UNIX
#include <sys/param.h>
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#endif
//=========================================================================
@ -112,7 +114,7 @@ typedef int64 cFSType;
// it is the union of MAX(elem) for all the file systems that we support
class cACLElem {
// TODO this is just a place holder
uint32 mUid;
// uint32 mUid;
};
// this class is used only to pass arguments to iFSServices
@ -126,7 +128,9 @@ struct cFSStatArgs {
TY_CHARDEV,
TY_SYMLINK,
TY_FIFO,
TY_SOCK
TY_SOCK,
TY_DOOR,
TY_PORT
};
// attr is fs dependent?
@ -177,7 +181,7 @@ TSS_FILE_EXCEPTION( eFSServicesGeneric, eFSServices );
class iFSServices
{
public:
virtual ~iFSServices() {}
///////////////////////////////////////////////////////////////
// ENUMS
///////////////////////////////////////////////////////////////
@ -203,7 +207,11 @@ class iFSServices
enum
{
#if IS_UNIX
TW_MAX_PATH = MAXPATHLEN
#ifdef MAXPATHLEN
TW_MAX_PATH = MAXPATHLEN
#else
TW_MAX_PATH = 1024
#endif
#endif
};
@ -217,9 +225,9 @@ class iFSServices
////////////////////////////////////////
virtual bool IsCaseSensitive() const = 0;
// returns true if the file system is case sensitive
virtual TCHAR GetPathSeperator() const = 0;
virtual TCHAR GetPathSeparator() const = 0;
// returns "/" for unix and "\\" for win32
virtual TCHAR* GetStandardBackupExtension() const = 0;
virtual const TCHAR* GetStandardBackupExtension() const = 0;
// returns normal string to append to backup files for this os.
////////////////////////////////////////
@ -239,7 +247,7 @@ class iFSServices
virtual void SetTempDirName( TSTRING& tmpName ) = 0;
virtual TSTRING& MakeTempFilename( TSTRING& strName ) const throw( eFSServices ) = 0;
virtual TSTRING& MakeTempFilename( TSTRING& strName ) const throw( eFSServices ) = 0;
// create temporary file
// TSTRING must have the form ("baseXXXXXX"), where the X's are replaced with
// characters to make it a unique file. There must be at least 6 Xs.
@ -258,15 +266,15 @@ class iFSServices
////////////////////////////////////////
// minor filesystem functions
////////////////////////////////////////
virtual void GetHostID( TSTRING& name ) const = 0;
virtual void GetHostID( TSTRING& name ) const = 0;
virtual void GetMachineName( TSTRING& name ) const throw(eFSServices) = 0;
virtual void GetMachineNameFullyQualified( TSTRING& name ) const = 0;
virtual bool GetCurrentUserName( TSTRING& tstrName ) const = 0;
virtual bool GetCurrentUserName( TSTRING& tstrName ) const = 0;
virtual bool GetIPAddress( uint32& uiIPAddress ) = 0;
virtual bool GetIPAddress( uint32& uiIPAddress ) = 0;
////////////////////////////////////////

View File

@ -77,8 +77,13 @@
* in "../../include/byteorder.h" to get this information.
*/
#include "stdcore.h"
#include "config.h"
#include <stdio.h>
#include <memory.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#else
#include <string.h>
#endif
#include "haval.h"
#include "debug.h"

View File

@ -71,9 +71,12 @@
/*
* set, reset environment to be passed to mpopem
*/
#include "config.h"
#include <stdio.h>
#include <sys/types.h>
#include <sys/file.h>
#ifndef _SORTIX_SOURCE
# include <sys/file.h>
#endif
#include <sys/stat.h>
#include <sys/wait.h>
#include <time.h>
@ -87,7 +90,9 @@
# include <unistd.h>
# include <stdlib.h>
#endif
#include <sys/param.h>
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#include <assert.h>
#include "msystem.h"
@ -144,6 +149,12 @@
# define MAX_DESC 256
#endif
#ifdef NOFILE
# define TW_NO_DESC NOFILE
#else
# define TW_NO_DESC MAX_DESC+1
#endif
/*
* in case the subprocess fails to exec the command properly
*/
@ -734,7 +745,6 @@ FILE *fp;
return(-1);
}
/*
* like popen but A LOT safer
* uses file descriptors for all three files
@ -861,6 +871,10 @@ FILE *fp[];
return(mfpclose(indx, fp));
}
#ifdef __AROS__
#define fork() vfork()
#endif
/*
* signal values
*/
@ -887,7 +901,6 @@ int mask;
register int i; /* counter in for loop */
register int ch_pid; /* child PID */
register int euid, egid; /* in case reset[gu]id is -1 */
/*
* create 1 pipe for each of standard input, output, error
*/
@ -919,7 +932,7 @@ int mask;
(void) umask(mask);
/* close the unused ends of the pipe */
/* and all other files except 0, 1, 2 */
for(i = 3; i < NOFILE; i++)
for(i = 3; i < TW_NO_DESC; i++)
if (fp == NULL || (!fdleave[i] && i != p[0][0]
&& i != p[1][1] && i != p[2][1]))
(void) close(i);
@ -983,7 +996,6 @@ int mask;
(void) close(p[2][0]);
}
}
/*
* return child's PID
*/

View File

@ -114,7 +114,11 @@ int echild();
# define GID_RESET -2 /* reset EGID to RGID */
#endif
#ifndef DEF_PATH
# define DEF_PATH "PATH=/bin:/usr/bin:/usr/ucb" /* default search path */
# ifdef __FreeBSD_cc_version
# define DEF_PATH "PATH=/sbin:/usr/sbin:/bin:/usr/bin" /* default search path */
# else
# define DEF_PATH "PATH=/bin:/usr/bin:/usr/ucb" /* default search path */
# endif
#endif
#ifndef DEF_SHELL
# define DEF_SHELL "SHELL=/bin/sh" /* default shell */

View File

@ -319,7 +319,7 @@ void shsFinal(SHS_INFO *shsInfo)
shsTransform( shsInfo );
#ifndef WORDS_BIGENDIAN
byteReverse( shsInfo->data, SHS_BLOCKSIZE );
byteReverse( shsInfo->data, SHS_DIGESTSIZE );
#endif /* #ifndef WORDS_BIGENDIAN */
}

View File

@ -150,6 +150,11 @@ inline void tss_insert_in_hash( const wc16_string& lhs, const std::string& rhs )
std::string::const_iterator
cStringUtil::Convert( std::string& nbs, const wc16_string& dbs )
{
#ifdef __AROS__
nbs.resize(dbs.length());
for (int x=0; x<dbs.length(); ++x)
nbs[x] = (unsigned char)dbs[x];
#else
cDebug d("cStringUtil::Convert( char, w16 )");
ASSERT( (void*)nbs.c_str() != (void*)dbs.c_str() );
@ -192,7 +197,7 @@ cStringUtil::Convert( std::string& nbs, const wc16_string& dbs )
tss_insert_in_hash( dbs, nbs );
}
#endif
return nbs.begin();
}
@ -200,6 +205,12 @@ cStringUtil::Convert( std::string& nbs, const wc16_string& dbs )
wc16_string::const_iterator
cStringUtil::Convert( wc16_string& dbs, const std::string& nbs )
{
#ifdef __AROS__
dbs.resize(nbs.length());
for (int x=0; x<nbs.length(); x++)
dbs[x] = (unsigned short)nbs[x];
#else
cDebug d("cStringUtil::Convert( w16, char )");
if (nbs.size() != 0)
@ -231,6 +242,7 @@ cStringUtil::Convert( wc16_string& dbs, const std::string& nbs )
}
else
dbs.resize(0);
#endif
return dbs.begin();
}

View File

@ -125,8 +125,9 @@ typedef std::ifstream TIFSTREAM;
#define _T(x) x
// misc...
#ifndef __cdecl
#define __cdecl
#endif
#endif // WIN32

View File

@ -54,6 +54,10 @@
#define TIME_MAX 2147483647L // largest signed 32 bit number
#ifdef __AROS__
#define tzset()
#endif
struct tm* cTimeUtil::TimeToDateGMT( const int64& seconds )
{
ASSERT( seconds < TIME_MAX );// this assumes time_t size is 32 bit. Yikes!

View File

@ -77,9 +77,14 @@ void util_SignalHandler( int sig )
}
#if IS_UNIX
#ifndef NSIG
#define NSIG 32
#endif
void tw_psignal(int sig, const TCHAR *str)
{
TCHAR *siglist[NSIG] = {
const TCHAR *siglist[NSIG] = {
_T("Unknown Signal"),
_T("Hangup"),
_T("Interrupt"),

View File

@ -66,6 +66,9 @@ static TSTRING& util_FormatTime( struct tm* ptm, TSTRING& strBuf );
// PUBLIC METHOD CODE
//=========================================================================
#ifdef __AROS__
#define tzset()
#endif
void cTWLocale::InitGlobalLocale()
{
@ -243,7 +246,6 @@ TSTRING& cTWLocale::FormatTime( int64 t, TSTRING& strBuf )
{
// clear return string
strBuf.erase();
tzset();
time_t tmpTime = t;
struct tm * ptm = localtime( &tmpTime );

View File

@ -110,7 +110,7 @@ namespace tss
#if USE_STD_CPP_LOCALE_WORKAROUND
return std::use_facet( l, pf );
#else
return std::use_facet< FacetT >( l ); pf; // This is C++ standard
return std::use_facet< FacetT >( l ); (void)pf; // This is C++ standard
#endif
}
}

View File

@ -37,6 +37,7 @@
#include "core/stdcore.h"
#include "core/corestrings.h"
#include "core/file.h"
#if !IS_UNIX //encase this all in an ifdef so it won't cause compile errors
#error Must be unix for unixfsservices
@ -54,7 +55,9 @@
#include <dirent.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/param.h>
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
#ifdef HAVE_SYS_MOUNT_H
# include <sys/mount.h>
#endif
@ -172,14 +175,20 @@ void cUnixFSServices::GetHostID( TSTRING& name ) const
}
// returns "/" for unix and "\\" for win32
TCHAR cUnixFSServices::GetPathSeperator() const
TCHAR cUnixFSServices::GetPathSeparator() const
{
return '/';
}
#ifndef __AROS__
void cUnixFSServices::ReadDir(const TSTRING& strFilename, std::vector<TSTRING> &v, bool bFullPaths) const throw(eFSServices)
{
#else
void cUnixFSServices::ReadDir(const TSTRING& strFilenameC, std::vector<TSTRING>& v, bool bFullPaths) const throw(eFSServices)
{
TSTRING strFilename = cArosPath::AsNative(strFilenameC);
#endif
//Get all the filenames
DIR* dp;
dp = opendir( strFilename.c_str() );
@ -228,9 +237,9 @@ cFSStatArgs::FileType cUnixFSServices::GetFileType(const cFCOName &filename) thr
void cUnixFSServices::GetCurrentDir( TSTRING& strCurDir ) const throw(eFSServices)
{
TCHAR pathname[MAXPATHLEN];
TCHAR pathname[iFSServices::TW_MAX_PATH];
pathname[0] = '\0';
TCHAR* ret = getcwd(pathname, sizeof(TCHAR)*MAXPATHLEN);
TCHAR* ret = getcwd(pathname, sizeof(TCHAR)*iFSServices::TW_MAX_PATH);
if (ret == NULL)
throw eFSServicesGeneric( strCurDir, iFSServices::GetInstance()->GetErrString() );
@ -248,12 +257,12 @@ void cUnixFSServices::ChangeDir( const TSTRING& strDir ) const throw(eFSServices
TSTRING& cUnixFSServices::MakeTempFilename( TSTRING& strName ) const throw(eFSServices)
{
char* pchTempFileName;
char szTemplate[MAXPATHLEN];
char szTemplate[iFSServices::TW_MAX_PATH];
int fd;
#ifdef _UNICODE
// convert template from wide character to multi-byte string
char mbBuf[MAXPATHLEN];
char mbBuf[iFSServices::TW_MAX_PATH];
wcstombs( mbBuf, strName.c_str(), strName.length() + 1 );
strcpy( szTemplate, mbBuf );
#else
@ -326,8 +335,14 @@ void cUnixFSServices::SetTempDirName(TSTRING& tmpPath) {
}
#ifndef __AROS__
void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const throw(eFSServices)
{
#else
void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const throw(eFSServices)
{
TSTRING strName = cArosPath::AsNative(strNameC);
#endif
//local variable for obtaining info on file.
struct stat statbuf;
@ -366,14 +381,21 @@ void cUnixFSServices::Stat( const TSTRING& strName, cFSStatArgs &stat ) const th
stat.blocks = statbuf.st_blocks;
// set the file type
if(S_ISREG(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_FILE;
if(S_ISREG(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_FILE;
else if(S_ISDIR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_DIR;
else if(S_ISLNK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_SYMLINK;
else if(S_ISBLK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_BLOCKDEV;
else if(S_ISCHR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_CHARDEV;
else if(S_ISFIFO(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_FIFO;
else if(S_ISSOCK(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_SOCK;
else stat.mFileType = cFSStatArgs::TY_INVALID;
#ifdef S_IFDOOR
else if(S_ISDOOR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_DOOR;
#endif
#ifdef S_IFPORT
else if(S_ISPORT(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_PORT;
#endif
else stat.mFileType = cFSStatArgs::TY_INVALID;
}
void cUnixFSServices::GetMachineName( TSTRING& strName ) const throw( eFSServices )
@ -390,7 +412,7 @@ void cUnixFSServices::GetMachineNameFullyQualified( TSTRING& strName ) const
char buf[256];
if (gethostname(buf, 256) != 0)
{
#ifdef SOLARIS_NO_GETHOSTBYNAME
#if defined(SOLARIS_NO_GETHOSTBYNAME) || defined(_SORTIX_SOURCE)
strName = buf;
return;
#else
@ -445,6 +467,7 @@ bool cUnixFSServices::GetIPAddress( uint32& uiIPAddress )
bool fGotAddress = false;
cDebug d( _T("cUnixFSServices::GetIPAddress") );
#ifndef _SORTIX_SOURCE
struct utsname utsnameBuf;
if( EFAULT != uname( &utsnameBuf) )
{
@ -476,6 +499,7 @@ bool cUnixFSServices::GetIPAddress( uint32& uiIPAddress )
}
else
d.TraceError( _T("uname failed") );
#endif
return( fGotAddress );
}
@ -572,31 +596,42 @@ void cUnixFSServices::ConvertModeToString( uint64 perm, TSTRING& tstrPerm ) cons
{
case S_IFDIR:
szPerm[0] = _T('d');
break;
break;
case S_IFCHR:
szPerm[0] = _T('c');
break;
break;
case S_IFBLK:
szPerm[0] = _T('b');
break;
break;
case S_IFIFO:
szPerm[0] = _T('p');
break;
break;
case S_IFLNK:
szPerm[0] = _T('l');
break;
#ifdef S_IFDOOR
case S_IFDOOR:
szPerm[0] = _T('D');
break;
#endif
#ifdef S_IFPORT
case S_IFPORT:
szPerm[0] = _T('P');
break;
#endif
break;
}
// check owner read and write
if (perm & S_IREAD)
if (perm & S_IRUSR)
szPerm[1] = _T('r');
if (perm & S_IWRITE)
if (perm & S_IWUSR)
szPerm[2] = _T('w');
// check owner execute
if (perm & S_ISUID && perm & S_IEXEC)
if (perm & S_ISUID && perm & S_IXUSR)
szPerm[3] = _T('s');
else if (perm & S_IEXEC)
else if (perm & S_IXUSR)
szPerm[3] = _T('x');
else if (perm & S_ISUID)
szPerm[3] = _T('S');
@ -792,7 +827,7 @@ bool cUnixFSServices::FullPath( TSTRING& strFullPath, const TSTRING& strRelPathC
// Returns normal string to append to backup files for this os.
// (e.g. "~" for unix and ".bak" for winos)
///////////////////////////////////////////////////////////////////////////////
TCHAR* cUnixFSServices::GetStandardBackupExtension() const
const TCHAR* cUnixFSServices::GetStandardBackupExtension() const
{
return _T(".bak");
}

View File

@ -99,10 +99,10 @@ class cUnixFSServices : public iFSServices
////////////////////////////////////////
virtual bool IsCaseSensitive() const;
// returns true if the file system is case sensitive
virtual TCHAR* GetStandardBackupExtension() const;
virtual const TCHAR* GetStandardBackupExtension() const;
// returns normal string to append to backup files for this os.
// (e.g. "~" for unix and ".bak" for winos)
virtual TCHAR GetPathSeperator() const;
virtual TCHAR GetPathSeparator() const;
////////////////////////////////////////
// process functions

View File

@ -33,7 +33,9 @@
#include "stdcore.h"
#include "usernotify.h"
#if defined(__OpenBSD__) /* OpenBSD's varargs seems wacky */
// There was a problem with varargs on some combo of old OpenBSD & old compiler.
// Not needed with current, but it's here if you need it.
#ifdef TW_OLD_OPENBSD_VARARGS
# undef va_start
# ifdef __GNUC__
# define va_start(ap, last) \
@ -42,7 +44,7 @@
# define va_start(ap, last) \
((ap) = (va_list)&(last) + __va_size(last))
# endif
#endif /* __OpenBSD__ */
#endif // TW_OLD_OPENBSD_VARARGS
iUserNotify* iUserNotify::mpInstance = 0;

View File

@ -35,10 +35,13 @@
// Function and classes dealing with the WCHAR16 type
//
#include "stdcore.h"
#include "config.h"
#include "wchar16.h"
#include "debug.h"
#include <stdexcept> // for stl::out_of_range
#include <memory.h>
#ifdef HAVE_MEMORY_H
# include <memory.h>
#endif
int wchar16len(const WCHAR16* s)
{

View File

@ -1,7 +1,7 @@
AUTOMAKE_OPTIONS = foreign no-dependencies
INCLUDES = -I.. -I../..
LN=@LN@
DEFAULT_INCLUDES = $(D_INCLUDES)
noinst_LIBRARIES = libcryptlib.a
@ -15,4 +15,4 @@ DEFS = @DEFS@ # This gets rid of the -I. so INCLUDES must be more explicit
CLEANFILES = ../../lib/libcryptlib.a
all: $(noinst_LIBRARIES)
ln -f $(noinst_LIBRARIES) ../../lib/libcryptlib.a
$(LN) -f $(noinst_LIBRARIES) ../../lib/libcryptlib.a

View File

@ -40,7 +40,8 @@ host_triplet = @host@
subdir = src/cryptlib
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -105,6 +106,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -113,6 +116,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
@ -401,7 +405,7 @@ uninstall-am: uninstall-info-am
all: $(noinst_LIBRARIES)
ln -f $(noinst_LIBRARIES) ../../lib/libcryptlib.a
$(LN) -f $(noinst_LIBRARIES) ../../lib/libcryptlib.a
# 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:

View File

@ -55,7 +55,7 @@ template <class T> class AbstractField : public AbstractRing<T>
{
public:
bool IsUnit(const typename T::Element &a) const
{return !Equal(a, this->Zero());}
{return !this->Equal(a, this->Zero());}
};
template <class T> class AbstractEuclideanDomain : public AbstractRing<T>
@ -273,7 +273,7 @@ template <class T> T AbstractEuclideanDomain<T>::Gcd(const Element &a, const Ele
Element g[3]={b, a};
unsigned int i0=0, i1=1, i2=2;
while (!Equal(g[i1], this->Zero()))
while (!this->Equal(g[i1], this->Zero()))
{
g[i2] = Mod(g[i0], g[i1]);
unsigned int t = i0; i0 = i1; i1 = i2; i2 = t;
@ -289,7 +289,7 @@ template <class T> typename QuotientRing<T>::Element QuotientRing<T>::Multiplica
typename T::Element y;
unsigned int i0=0, i1=1, i2=2;
while (!Equal(g[i1], Zero()))
while (!this->Equal(g[i1], Zero()))
{
// y = g[i0] / g[i1];
// g[i2] = g[i0] % g[i1];

View File

@ -43,8 +43,8 @@ void StreamCipher::ProcessString(byte *outString, const byte *inString, unsigned
void StreamCipher::ProcessString(byte *inoutString, unsigned int length)
{
while(length--)
*inoutString++ = ProcessByte(*inoutString);
for(;length--; inoutString++)
*inoutString = ProcessByte(*inoutString);
}
bool MessageAuthenticationCode::Verify(const byte *macIn)

View File

@ -13,6 +13,8 @@
#include "algebra.cpp"
#include "eprecomp.cpp"
#include <string.h>
#define MAKE_DWORD(lowWord, highWord) ((dword(highWord)<<WORD_BITS) | (lowWord))
union dword_union

View File

@ -3,7 +3,16 @@
#include "config.h"
#include <assert.h>
#include <memory.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#else
#include <string.h>
#endif
#ifdef __MINT__ // has memory.h, but memset defined in string.h anyway.
#include <string.h>
#endif
#include <algorithm>
inline unsigned int bitsToBytes(unsigned int bitCount)

View File

@ -40,7 +40,8 @@ host_triplet = @host@
subdir = src/db
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -102,6 +103,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -110,6 +113,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@

View File

@ -143,7 +143,7 @@ public:
class cHierRoot : public cHierNode
{
public:
cHierRoot() : cHierNode( TYPE_ROOT ) {}
cHierRoot() : cHierNode( TYPE_ROOT ), mbCaseSensitive(true), mDelimitingChar('/') {}
cHierAddr mChild; // points to a cHierArray or an invalid address
bool mbCaseSensitive; // determines the case-sensitiveness of lookups, ordering, etc.
@ -177,10 +177,11 @@ public:
}
mChild.Read ( arch );
int32 cs;
arch.ReadInt32 ( cs );
arch.ReadInt32(cs);
mbCaseSensitive = cs ? true : false;
TSTRING dc;
arch.ReadString ( dc );
arch.ReadString(dc);
if( dc.length() != 1 )
{
ASSERT( false );

View File

@ -40,7 +40,8 @@ host_triplet = @host@
subdir = src/fco
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -93,7 +94,7 @@ CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@ -fpermissive
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@ # This gets rid of the -I. so INCLUDES must be more explicit
DEPDIR = @DEPDIR@
@ -110,6 +111,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -118,6 +121,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@

View File

@ -200,10 +200,7 @@ void cFCODataSourceIterImpl::Next()
iFCO* cFCODataSourceIterImpl::CreateFCO() //throw (eError)
{
ASSERT( ! Done() );
if( ! InitializeTypeInfo( *mCurPos ) )
return 0;
InitializeTypeInfo( *mCurPos );
(*mCurPos)->AddRef();
return *mCurPos;
}

View File

@ -93,7 +93,7 @@ void cFCOName::ClearNameTable()
// ctor, dtor
///////////////////////////////////////////////////////////////////////////////
cFCOName::cFCOName(iFCONameInfo* pNI) :
mpPathName(0)
mpPathName(0), mDelimiter('/')
{
SetNameInfo(pNI);
mpPathName = new cFCOName_i;
@ -118,7 +118,7 @@ cFCOName::cFCOName(const cFCOName& rhs) :
}
cFCOName::cFCOName(const TSTRING& rhs, iFCONameInfo* pNI) :
mpPathName(0)
mpPathName(0), mDelimiter('/')
{
SetNameInfo(pNI);
mpPathName = new cFCOName_i;
@ -132,7 +132,7 @@ cFCOName::cFCOName(const TSTRING& rhs, iFCONameInfo* pNI) :
}
cFCOName::cFCOName(const TCHAR* rhs, iFCONameInfo* pNI) :
mpPathName(0)
mpPathName(0), mDelimiter('/')
{
SetNameInfo(pNI);
mpPathName = new cFCOName_i;
@ -211,88 +211,43 @@ void cFCOName::operator = (const TCHAR* rhs)
#endif
}
///////////////////////////////////////////////////////////////////////////////
// ParseString
// here is how the string is broken down: between every item in
// mpPathName.mNames, there is assumed to be a delimiter. It is assumed there
// is no delimiter at the beginning of the path. If there is, or if
// double delimiters appear anywhere, that is signified by putting an empty
// string into the list. Any delimiter that appears at the end of the string
// is removed (so that /etc/ becomes /etc)
///////////////////////////////////////////////////////////////////////////////
#define RADS_NTMBS_VER // Try it out first
#ifndef RADS_NTMBS_VER
void cFCOName::ParseString(const TCHAR* str)
{
ASSERT(mpPathName);
mpPathName->ClearList();
int len = _tcslen(str);
TSTRING name;
const TCHAR* pEnd = str + len;
const TCHAR* pChar = str;
// break off the next word to add..
const TCHAR* pBegin = pChar;
while(pChar < pEnd)
{
while((*pChar != mDelimiter) && (pChar < pEnd))
pChar++;
// if pChar == pBegin, then we have an extra delimiter; add it.
// TODO -- right now, I will suppress the final delimiter; I don't know if this is the
// right thing to do
if(pChar == pBegin)
{
// NOTE -- there is a special case here -- "/" (the root directory); it will be represented
// as a single empty node. This is handled by the (pChar != str) below.
if((pChar + 1 >= pEnd) && (pChar != str))
// don't add the trailing slash
break;
name = _T("");
}
else
name.assign(pBegin, (pChar - pBegin));
cFCONameTblNode* pNode = cFCOName_i::msNameTbl.CreateNode(name);
mpPathName->mNames.push_back(pNode);
pBegin = ++pChar;
}
}
#else//RADS_NTMBS_VER
void cFCOName::ParseString( const TCHAR* pszin )
{
ASSERT( mpPathName != 0);
mpPathName->ClearList();
TSTRING ats = const_cast<TCHAR *>(pszin + 0);
TSTRING::const_iterator at = ats.begin();
TSTRING::const_iterator end = at;
while ( *end ) ++end; // NOTE: Find end
ASSERT(mpPathName != 0);
ASSERT(pszin != 0);
mpPathName->ClearList();
const TCHAR* at = (pszin + 0);
const TCHAR* begin = at;
const TCHAR* end = at;
int components = 0;
TSTRING::const_iterator beg = at;
while ( at < end )
{
while ( !(*at == mDelimiter) && at < end )
at = *at ? at + 1 : at;
while (*end)
++end;
if ( at == beg && (*at ? at + 1 : at) >= end && at != ats.begin() )
break;
while (at < end)
{
while (*at && !(*at == mDelimiter) && (at < end))
at++;
cFCONameTblNode* pNode =
cFCOName_i::msNameTbl.CreateNode( TSTRING( beg, at ) );
TSTRING name(begin, at);
mpPathName->mNames.push_back( pNode );
beg = ( at = (*at ? at + 1 : at) );
}
if (name.length() > 0 || components == 0)
{
cFCONameTblNode* pNode =
cFCOName_i::msNameTbl.CreateNode(name);
mpPathName->mNames.push_back(pNode);
}
components++;
at++;
begin=at;
//begin = (at = tss::strinc(at));
}
}
#endif//RADS_NTMBS_VER
///////////////////////////////////////////////////////////////////////////////
// AsString
@ -317,14 +272,15 @@ TSTRING cFCOName::AsString() const
return str;
}
// end ugly root dir hacks ...
ListType::iterator i = mpPathName->mNames.begin();
while(i != mpPathName->mNames.end())
{
TSTRING current = (*i)->GetString();
// the loop is constructed in this odd fashion because I don't want a trailing mDelimiter
str += (*i)->GetString();
str += current;
i++;
if(i != mpPathName->mNames.end())
if(i != mpPathName->mNames.end() && current != "/")
str += mDelimiter;
}
@ -411,17 +367,15 @@ void cFCOName::Read(iSerializer* pSerializer, int32 version)
TSTRING str;
pSerializer->ReadString(str);
int16 dummy = 0;
// serialize the delimiter
#ifdef _UNICODE
pSerializer->ReadInt16( (int16&)mDelimiter );
#else
pSerializer->ReadInt16( dummy );
const wchar_t wc = dummy;
size_t N = ::wcstombs( &mDelimiter, &wc, 1 );
if ( N == (size_t)-1 )
throw eCharacterEncoding();
pSerializer->ReadInt16( dummy ); // delimiter, but it's always '/' anyway in OST.
mDelimiter = '/';
#endif
// read the case-sensitiveness
@ -450,8 +404,7 @@ void cFCOName::Write(iSerializer* pSerializer) const
#ifdef _UNICODE
pSerializer->WriteInt16(mDelimiter);
#else
wchar_t wc;
mbtowc(&wc, &mDelimiter, 1);
unsigned short wc = (unsigned short)'/';
pSerializer->WriteInt16(wc);
#endif

View File

@ -1,231 +0,0 @@
//
// The developer of the original code and/or files is Tripwire, Inc.
// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire,
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
// reserved.
//
// This program is free software. The contents of this file are subject
// to the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version. You may redistribute it and/or modify it
// only in compliance with the GNU General Public License.
//
// This program is distributed in the hope that it will be useful.
// However, this program is distributed AS-IS WITHOUT ANY
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
// FOR A PARTICULAR PURPOSE. Please 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, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
//
// Nothing in the GNU General Public License or any other license to use
// the code or files shall permit you to use Tripwire's trademarks,
// service marks, or other intellectual property without Tripwire's
// prior written consent.
//
// If you have any questions, please contact Tripwire, Inc. at either
// info@tripwire.org or www.tripwire.org.
//
///////////////////////////////////////////////////////////////////////////////
// fconame.h
//
// cFCOName -- represents the name of an FCO
#ifndef __FCONAME_H
#define __FCONAME_H
#ifndef __SERIALIZABLE_H
#include "core/serializable.h"
#endif
#ifndef __FCONAMEINFO_H
#include "fconameinfo.h"
#endif
///////////////////////////////////////////////////////////////////////////////
// class cFCOName -- How we name a FCO. The implementation has ended up being
// a wrapper around a standard string.
///////////////////////////////////////////////////////////////////////////////
class cFCONameTblNode;
class cFCONameIter;
class cFCOName : public iTypedSerializable
{
DECLARE_TYPEDSERIALIZABLE()
public:
typedef cFCONameIter iterator;
cFCOName(iFCONameInfo* iNI = NULL);
cFCOName(const cFCOName& rhs);
explicit cFCOName(const TSTRING& rhs, iFCONameInfo* iNI = NULL);
explicit cFCOName(const TCHAR* rhs, iFCONameInfo* iNI = NULL);
// these ctors are explicit because it is expensive to create these things, so we don't want to
// do it unexpectedly
virtual ~cFCOName();
void operator = (const cFCOName& rhs);
void operator = (const TSTRING& rhs);
void operator = (const TCHAR* rhs);
bool operator < (const cFCOName& rhs) const;
// defines an arbitrary order for cFCONames. This is so that names can
// be stored in trees and other ordered data structures in order to facilitate
// fast lookups.
bool operator == (const cFCOName& rhs) const;
bool operator != (const cFCOName& rhs) const;
bool IsEqual (const cFCOName& rhs) const;
// both of these are synonyms for (GetRelationship(rhs) == REL_EQUAL)
TSTRING AsString() const;
// return a string representation of the string
bool IsCaseSensitive() const;
void SetCaseSensitive(bool val);
// determines how name comparisons are done. If two cFCONames are compared who are
// both case insensitive, a case insensitive compare is done. If both are case sensitive,
// a case sensitive compare is done. If one is and one isn't case sensitive (? TODO: what
// is the right thing to do in this case? ASSERT(0)? do a case sensitive compare??)
TCHAR GetDelimiter() const;
void SetDelimiter(TCHAR delimiter);
// defines what the path-delimiting character is
void Push(const TSTRING& str);
// pushes the named string onto the end of the path. A delimiter is implicitely placed between the old end
// and the new string. if debug is defined, it is asserted that the new string does not contain the
// delimiting character
const TCHAR* Pop();
// removes the last part of the path from the name and returns it. ASSERTS and returns an undefined value if
// the path is empty
const TCHAR* PopFront();
// removes the first part of the path from the name and returns it. ASSERTS and returns an undefined value if
// the path is empty
void Clear();
// removes all elements from the name; after this, GetSize() == 0.
const TCHAR* GetShortName() const;
// this will return the final string in the vector. It will assert that the name is not empty.
int GetSize() const;
// returns the number of path items (strings between delimiters) that are in the fco name. It is always equal
// to the number of delimiters in the path plus one.
enum Relationship
{
REL_BELOW, // an fco is below another (/etc/passwd is below /etc)
REL_ABOVE, // an fco is above another (/etc is above /etc/passwd)
REL_EQUAL, // the fcos are equal (/etc/passwd is equal to /etc/passwd)
REL_UNRELATED // the fcos are unrelated (/var/spool/mail is unrelated to /var/log/pig.log)
};
Relationship GetRelationship(const cFCOName& rhs) const;
// returns the relationship of _this_ name to the one passed in (ie -- if REL_BELOW is returned,
// this fco name is below the one passed in)
virtual void Read (iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive)
virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive)
//////////////////////////////////
// Debugging method
//////////////////////////////////
static void ClearNameTable();
// this method should _only_ be called when the program is exiting, and you are positively sure you
// will not be using or creating any more cFCONames. Violating this rule will result in unpredictable
// results. This clears out the cFCOName internal name table, making memory leaks easier to find.
protected:
friend class cFCOName_i;
friend class cFCONameIter;
void ParseString(const TCHAR* str);
// helper function that takes the pathname pointer to by str and fills out mpPathName
void CopyOnModify();
// if the fconame is modified and mpPathName is shared by more than one object, this will
// release mpPathName and create a new one, so we don't change any other object's data
void SetNameInfo(iFCONameInfo* pNI);
// sets the delimiter and case sensitiveness to the name info's
cFCOName_i* mpPathName;
TCHAR mDelimiter; // the delimiting character in names (ie -- in file systems, it is '/')
bool mbCaseSensitive; // determines whether name compares are case sensitive of not
// this is what type of structure holds the elements of the name
//
typedef std::vector<cFCONameTblNode*> ListType;
#ifdef _DEBUG
TSTRING mDebugStrName; // so we can see this guy's value in the debug window
#endif
};
//-----------------------------------------------------------------------------
// cFCONameIter
//-----------------------------------------------------------------------------
class cFCONameIter_i;
class cFCONameIter
{
public:
cFCONameIter(const cFCOName& name);
~cFCONameIter();
int GetSize() const; // returns the number of entries in the fco name
void SeekBegin();
void Next();
void Prev();
bool Done() const;
int Index() const;
// return the current offset from the beginning of the short name list
void SeekTo( int index );
// seeks to the given index. asserts that the index is appropriate for the
// current fco name.
const TCHAR* GetName() const;
private:
void operator=(const cFCONameIter& rhs); // not impl
cFCONameIter(const cFCONameIter& rhs); // not impl
// the data...
//
const cFCOName& mName;
cFCOName::ListType::const_iterator mIter;
};
//#############################################################################
// inline implementation
inline bool cFCOName::IsCaseSensitive() const
{
return mbCaseSensitive;
}
inline void cFCOName::SetCaseSensitive(bool val)
{
mbCaseSensitive = val;
}
inline TCHAR cFCOName::GetDelimiter() const
{
return mDelimiter;
}
inline void cFCOName::SetDelimiter(TCHAR delimiter)
{
mDelimiter = delimiter;
}
///////////////////////////////////////////////////////////////////////////////
// IsEqual
///////////////////////////////////////////////////////////////////////////////
inline bool cFCOName::IsEqual(const cFCOName& rhs) const
{
return (GetRelationship(rhs) == cFCOName::REL_EQUAL);
}
inline bool cFCOName::operator==(const cFCOName& rhs) const
{
return IsEqual(rhs);
}
inline bool cFCOName::operator!=(const cFCOName& rhs) const
{
return (! IsEqual(rhs));
}
#endif //__FCONAME_H

View File

@ -1,128 +0,0 @@
//
// The developer of the original code and/or files is Tripwire, Inc.
// Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire,
// Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights
// reserved.
//
// This program is free software. The contents of this file are subject
// to the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2 of the License, or (at your
// option) any later version. You may redistribute it and/or modify it
// only in compliance with the GNU General Public License.
//
// This program is distributed in the hope that it will be useful.
// However, this program is distributed AS-IS WITHOUT ANY
// WARRANTY; INCLUDING THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS
// FOR A PARTICULAR PURPOSE. Please 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, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
// USA.
//
// Nothing in the GNU General Public License or any other license to use
// the code or files shall permit you to use Tripwire's trademarks,
// service marks, or other intellectual property without Tripwire's
// prior written consent.
//
// If you have any questions, please contact Tripwire, Inc. at either
// info@tripwire.org or www.tripwire.org.
//
///////////////////////////////////////////////////////////////////////////////
// fcosetimpl.h
//
// class cFCOSetImpl -- concrete implementation of an FCO set
// class cFCOIterImpl -- the iterator over the set
#ifndef __FCOSETIMPL_H
#define __FCOSETIMPL_H
#ifndef __FCO_H
#include "fco.h"
#endif
#include "fconame.h"
#ifndef __FCONAME_H
#include "fconame.h"
#endif
class cFCOSetImpl : public iFCOSet
{
friend class cFCOIterImpl;
DECLARE_TYPEDSERIALIZABLE()
public:
cFCOSetImpl();
cFCOSetImpl(const cFCOSetImpl& rhs);
virtual ~cFCOSetImpl();
void operator=(const cFCOSetImpl& rhs);
virtual const iFCOIter* Lookup(const cFCOName& name) const;
virtual iFCOIter* Lookup(const cFCOName& name);
virtual const iFCOIter* GetIter() const;
virtual iFCOIter* GetIter();
virtual void Insert(iFCO* pFCO);
virtual void Clear();
virtual bool IsEmpty() const;
virtual int Size() const { return mFCOSet.size(); };
virtual void TraceContents(int dl = -1) const;
// iSerializable interface
virtual void Read (iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive)
virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive)
private:
void ReturnIter(const cFCOIterImpl* pIter) const;
// returns the iterator to its owner; the reciprocal action
// to Lookup() or GetIter(); called by the iterator when it is destroyed
// class we store in the set below; it is a hack that allows us to
// look up iFCOs using cFCONames in a std::set
class cFCONode
{
public:
iFCO* mpFCO;
const cFCOName* mpFCOName;
cFCONode() : mpFCO(0), mpFCOName(0) {}
cFCONode(iFCO* pFCO) : mpFCO(pFCO), mpFCOName(&pFCO->GetName()) {}
cFCONode(const cFCOName& name) : mpFCO(0), mpFCOName(&name) {}
cFCONode(const cFCONode& rhs) : mpFCO(rhs.mpFCO), mpFCOName(rhs.mpFCOName) {}
bool operator < (const cFCONode& rhs) const { if(mpFCOName) return (*mpFCOName < *rhs.mpFCOName); else return false; }
bool operator ==(const cFCONode& rhs) const { if(mpFCOName) return (*mpFCOName == *rhs.mpFCOName); else return false; }
};
std::set<cFCONode> mFCOSet;
// this is what actually stores the iFCOs.
};
class cFCOIterImpl : public iFCOIter
{
friend class cFCOSetImpl;
public:
cFCOIterImpl(cFCOSetImpl* pSet);
cFCOIterImpl(const cFCOSetImpl* pSet);
virtual void SeekBegin() const;
virtual bool Done() const;
virtual bool IsEmpty() const;
virtual void Next() const;
virtual const iFCO* FCO() const;
virtual iFCO* FCO();
virtual bool SeekToFCO(const cFCOName& name) const;
virtual void Remove();
virtual void Remove() const;
virtual void DestroyIter() const;
private:
virtual ~cFCOIterImpl() ;
cFCOSetImpl* mpSet;
mutable std::set<cFCOSetImpl::cFCONode>::iterator mIter;
// the definition of a const iterator is not that its position cannot change,
// but that it cannot modify the set it is iterating over, hence the "mutable"
};
#endif //__FCOSETIMPL_H

View File

@ -51,6 +51,7 @@
class cDefaultSpecMask : public iFCOSpecMask
{
public:
cDefaultSpecMask() {}
virtual const TSTRING& GetName() const;
virtual bool Accept(const iFCO* pFCO) const;
private:

View File

@ -53,6 +53,7 @@ class cFCOName;
class iParserGenreUtil
{
public:
virtual ~iParserGenreUtil() {}
virtual bool MapStringToProperty( const TSTRING& str, int& propIndex ) const = 0;
// maps the given string to an index into a property vector for the genre
virtual void AddSubTypeProps( cFCOPropVector& v ) const = 0;

199
src/fco/signature.cpp Normal file → Executable file
View File

@ -97,6 +97,7 @@ iFCOProp::CmpResult iSignature::Compare(const iFCOProp* rhs, Op op) const
return (op == iFCOProp::OP_NE) ? iFCOProp::CMP_TRUE : iFCOProp::CMP_FALSE;
}
bool cArchiveSigGen::mHex = false;
void cArchiveSigGen::AddSig( iSignature* pSig )
{
@ -129,6 +130,16 @@ void cArchiveSigGen::CalculateSignatures( cArchive& a )
mSigList[i]->Finit();
}
bool cArchiveSigGen::Hex()
{
return mHex;
}
void cArchiveSigGen::SetHex(bool hex)
{
mHex = hex;
}
///////////////////////////////////////////////////////////////////////////////
// btob64 -- convert arbitrary bits to base 64 string
//
@ -169,7 +180,7 @@ char* btob64(const register byte* pcbitvec, register char* pcout, int numbits)
}
*pcout = '\0';
return (char *) pcorig;
}
@ -216,7 +227,7 @@ void cNullSignature::Init()
{
}
void cNullSignature::Update( const byte* pbData, int cbDataLen )
void cNullSignature::Update( const byte* const pbData, int cbDataLen )
{
}
@ -292,8 +303,9 @@ void cChecksumSignature::Init()
{
}
void cChecksumSignature::Update( const byte* pbData, int cbDataLen )
void cChecksumSignature::Update( const byte* const pbDataC, int cbDataLen )
{
byte* pbData = (byte*)pbDataC;
for( int i = 0; i < cbDataLen; i++, pbData++ )
mChecksum += *pbData;
}
@ -382,7 +394,7 @@ void cCRC32Signature::Init()
crcInit( mCRCInfo );
}
void cCRC32Signature::Update( const byte* pbData, int cbDataLen )
void cCRC32Signature::Update( const byte* const pbData, int cbDataLen )
{
ASSERT( sizeof( byte ) == sizeof( uint8 ) );
crcUpdate( mCRCInfo, (uint8*)pbData, cbDataLen );
@ -398,6 +410,9 @@ void cCRC32Signature::Finit()
// mCRC
TSTRING cCRC32Signature::AsString() const
{
if (cArchiveSigGen::Hex())
return AsStringHex();
TSTRING ret;
char *ps_signature;
char buf[100];
@ -481,7 +496,7 @@ void cMD5Signature::Init()
#endif
}
void cMD5Signature::Update( const byte* pbData, int cbDataLen )
void cMD5Signature::Update( const byte* const pbData, int cbDataLen )
{
#ifdef HAVE_OPENSSL_MD5_H
MD5_Update( &mMD5Info, (uint8*)pbData, cbDataLen );
@ -504,6 +519,9 @@ void cMD5Signature::Finit()
// AsString -- Converts to Base64 representation and returns a TSTRING
TSTRING cMD5Signature::AsString() const
{
if (cArchiveSigGen::Hex())
return AsStringHex();
TSTRING ret;
char buf[24];
int length;
@ -519,6 +537,7 @@ TSTRING cMD5Signature::AsString() const
#else
ret.append(buf);
#endif
return ret;
//return ret;
//ret holds base64 representation of digest.
@ -583,7 +602,9 @@ IMPLEMENT_TYPEDSERIALIZABLE(cSHASignature, _T("cSHASignature"), 0, 1)
cSHASignature::cSHASignature()
{
memset( &mSHAInfo, 0, sizeof( mSHAInfo ) );
#ifdef HAVE_OPENSSL_SHA_H
memset( sha_digest, 0, SHA_DIGEST_LENGTH );
#endif
}
cSHASignature::~cSHASignature()
@ -598,7 +619,7 @@ void cSHASignature::Init()
#endif
}
void cSHASignature::Update( const byte* pbData, int cbDataLen )
void cSHASignature::Update( const byte* const pbData, int cbDataLen )
{
ASSERT( sizeof( byte ) == sizeof( uint8 ) );
#ifdef HAVE_OPENSSL_SHA_H
@ -614,65 +635,133 @@ void cSHASignature::Finit()
SHA1_Final( (unsigned char *)sha_digest, &mSHAInfo );
#else
shsFinal( &mSHAInfo );
bcopy(&mSHAInfo.digest, sha_digest, SHA_DIGEST_LENGTH);
{
/* sha_digest is a byte array, so can't be in
* host order.
*/
int i;
uint32 *j = (uint32 *)sha_digest;
uint32 *k = (uint32 *)&mSHAInfo.digest;
for(int i=0; i<SIG_UINT32_SIZE; i++)
# ifdef WORDS_BIGENDIAN
j[i] = k[i];
# else
j[i] = ( (k[i] & 0x00ff) << 24 ) | ( (k[i] & 0xff00) << 8)|
( (k[i] >> 8) & 0xff00 ) | ( (k[i] >> 24) & 0x00ff );
# endif //WORDS_BIGENDIAN
}
#endif
}
////////////////////////////////////////////////////////////////////////////////
// AsString -- Converts to Base64 representation and returns a TSTRING
#ifdef HAVE_OPENSSL_SHA_H
TSTRING cSHASignature::AsString(void) const
{
TSTRING ret;
char* ps_signature;
char buf[100];
int length;
ps_signature = btob64((uint8*)sha_digest, buf, SIG_UINT32_SIZE*sizeof(uint32)*8);
//converting to base64 representation.
length = strlen(ps_signature);
#ifdef _UNICODE //making it TSTRING sensitive
ret.resize(length);
mbstowcs((TCHAR*) ret.data(), ps_signature, length);
if (cArchiveSigGen::Hex())
return AsStringHex();
TSTRING ret;
char* ps_signature;
char buf[100];
int length;
ps_signature = btob64((uint8*)sha_digest, buf, SIG_UINT32_SIZE*sizeof(uint32)*8);
//converting to base64 representation.
length = strlen(ps_signature);
#ifdef _UNICODE //making it TSTRING sensitive
ret.resize(length);
mbstowcs((TCHAR*) ret.data(), ps_signature, length);
#else
ret.append(ps_signature);
ret.append(ps_signature);
#endif
return ret;
return ret;
}
TSTRING cSHASignature::AsStringHex() const
{
TSTRING ret;
TCHAR stringBuffer[128];
TCHAR sigStringOut[128];
sigStringOut[0] = '\0';
uint8 *dbuf = (uint8 *)sha_digest;
for (int i=0; i < SIG_UINT32_SIZE*(int)sizeof(uint32); ++i)
{
_stprintf(stringBuffer, _T("%02x"), dbuf[i]);
_tcscat(sigStringOut, stringBuffer);
}
ret.append(sigStringOut);
return ret;
}
///////////////////////////////////////////////////////////////////////////////
// Copy -- Copies a new sig value from a base pointer
void cSHASignature::Copy(const iFCOProp* rhs)
{
ASSERT(GetType() == rhs->GetType());
for (int i = 0; i<SIG_UINT32_SIZE; ++i)
sha_digest[i] = ((static_cast<const cSHASignature*>(rhs))->sha_digest)[i];
}
///////////////////////////////////////////////////////////////////////////////
// Serializer Implementation: Read and Write
void cSHASignature::Read (iSerializer* pSerializer, int32 version)
{
if (version > Version())
ThrowAndAssert(eSerializerVersionMismatch(_T("SHA Read")));
for (int i = 0; i < SIG_UINT32_SIZE; ++i)
pSerializer->ReadInt32((int32&)sha_digest[i]);
}
void cSHASignature::Write(iSerializer* pSerializer) const
{
for (int i = 0; i < SIG_UINT32_SIZE; ++i)
pSerializer->WriteInt32(sha_digest[i]);
}
///////////////////////////////////////////////////////////////////////////////
// IsEqual -- Tests for equality, given a base pointer (iSignature)
bool cSHASignature::IsEqual(const iSignature& rhs) const
{
if (this == &rhs)
return true;
else {
return (memcmp(sha_digest, ((cSHASignature&)rhs).sha_digest, SIG_UINT32_SIZE * sizeof(uint32)) == 0);
}
}
#else // HAVE_OPENSSL_SHA_H
TSTRING cSHASignature::AsString(void) const
{
if (cArchiveSigGen::Hex())
return AsStringHex();
TSTRING ret;
char* ps_signature;
char buf[100];
buf[99]=0;
ps_signature = pltob64((uint32*)mSHAInfo.digest, buf, SIG_UINT32_SIZE);
//converting to base64 representation.
#ifdef _UNICODE //making it TSTRING sensitive
int length = strlen(ps_signature);
ret.resize(length);
mbstowcs((TCHAR*) ret.data(), ps_signature, length);
#else
ret.append(ps_signature);
#endif
return ret;
//return ret;
}
TSTRING cSHASignature::AsStringHex() const
TSTRING cSHASignature::AsStringHex() const
{
TSTRING ret;
TCHAR stringBuffer[128];
TCHAR sigStringOut[128];
sigStringOut[0] = '\0';
uint8 *dbuf = (uint8 *)sha_digest;
TSTRING ret;
for (int i=0; i < SIG_UINT32_SIZE*(int)sizeof(uint32); ++i)
{
_stprintf(stringBuffer, _T("%02x"), dbuf[i]);
_tcscat(sigStringOut, stringBuffer);
}
ret.append(sigStringOut);
return ret;
TCHAR stringBuffer[128];
TCHAR sigStringOut[128];
sigStringOut[0] = '\0';
for (int i=0; i < SIG_UINT32_SIZE; ++i)
{
_stprintf(stringBuffer, _T("%08x"), mSHAInfo.digest[i]);
_tcscat(sigStringOut, stringBuffer);
}
ret.append(sigStringOut);
return ret;
}
///////////////////////////////////////////////////////////////////////////////
@ -711,7 +800,7 @@ bool cSHASignature::IsEqual(const iSignature& rhs) const
return (memcmp(mSHAInfo.digest, ((cSHASignature&)rhs).mSHAInfo.digest, SIG_UINT32_SIZE * sizeof(uint32)) == 0);
}
}
#endif
///////////////////////////////////////////////////////////////////////////////
// class cHAVALSignature --
///////////////////////////////////////////////////////////////////////////////
@ -732,7 +821,7 @@ void cHAVALSignature::Init()
haval_start( &mHavalState );
}
void cHAVALSignature::Update( const byte* pbData, int cbDataLen )
void cHAVALSignature::Update( const byte* const pbData, int cbDataLen )
{
haval_hash( &mHavalState, (uint8*)pbData, cbDataLen );
}
@ -746,6 +835,9 @@ void cHAVALSignature::Finit()
// AsString -- Returns Base64 representation of mSignature in a TSTRING
TSTRING cHAVALSignature::AsString() const
{
if (cArchiveSigGen::Hex())
return AsStringHex();
TSTRING ret;
char buf[24];
int length;
@ -760,6 +852,7 @@ TSTRING cHAVALSignature::AsString() const
#else
ret.append(buf);
#endif
return ret;
//return ret;
//ret holds base64 representation of digest.

View File

@ -75,6 +75,8 @@
// TODO: figure out a way to do this without including these headers.
// pool of objects?
///////////////////////////////////////////////////////////////////////////////
// class iSignatrue -- Interface all signatures will implement.
///////////////////////////////////////////////////////////////////////////////
@ -98,7 +100,7 @@ public:
//
virtual void Init () = 0;
// call before beginning hashing
virtual void Update( const byte* pbData, int cbDataLen ) = 0;
virtual void Update( const byte* const pbData, int cbDataLen ) = 0;
// may be called multiple times -- best to call with blocks of size SUGGESTED_BLOCK_SIZE,
// but can handle any size data.
virtual void Finit () = 0;
@ -145,6 +147,9 @@ public:
// produces signature of archive for all signatures in the list
// remember to rewind archive!
static bool Hex();
static void SetHex(bool);
private:
// don't let C++ create these functions
cArchiveSigGen( const cArchiveSigGen& );
@ -152,6 +157,8 @@ private:
typedef std::vector< iSignature* > container_type;
container_type mSigList;
static bool mHex;
};
@ -168,7 +175,7 @@ public:
virtual ~cNullSignature();
virtual void Init ();
virtual void Update( const byte* pbData, int cbDataLen );
virtual void Update( const byte* const pbData, int cbDataLen );
virtual void Finit ();
virtual TSTRING AsString() const;
virtual TSTRING AsStringHex() const;
@ -195,7 +202,7 @@ public:
virtual ~cChecksumSignature();
virtual void Init ();
virtual void Update( const byte* pbData, int cbDataLen );
virtual void Update( const byte* const pbData, int cbDataLen );
virtual void Finit ();
virtual TSTRING AsString() const;
virtual TSTRING AsStringHex() const;
@ -223,7 +230,7 @@ public:
virtual ~cCRC32Signature();
virtual void Init ();
virtual void Update( const byte* pbData, int cbDataLen );
virtual void Update( const byte* const pbData, int cbDataLen );
virtual void Finit ();
virtual TSTRING AsString() const;
@ -252,7 +259,7 @@ public:
virtual ~cMD5Signature();
virtual void Init ();
virtual void Update( const byte* pbData, int cbDataLen );
virtual void Update( const byte* const pbData, int cbDataLen );
virtual void Finit ();
virtual TSTRING AsString() const;
virtual TSTRING AsStringHex() const;
@ -281,7 +288,7 @@ public:
virtual ~cSHASignature();
virtual void Init ();
virtual void Update( const byte* pbData, int cbDataLen );
virtual void Update( const byte* const pbData, int cbDataLen );
virtual void Finit ();
virtual TSTRING AsString() const;
virtual TSTRING AsStringHex() const;
@ -291,12 +298,17 @@ public:
virtual void Write(iSerializer* pSerializer) const;
protected:
enum { SIG_UINT32_SIZE = SHA_DIGEST_LENGTH/4 };
SHA_CTX mSHAInfo;
virtual bool IsEqual(const iSignature& rhs) const;
#ifdef HAVE_OPENSSL_SHA_H
enum { SIG_UINT32_SIZE = SHA_DIGEST_LENGTH/4 };
SHA_CTX mSHAInfo;
uint32 sha_digest[SHA_DIGEST_LENGTH/4];
#else
enum { SIG_UINT32_SIZE = 5 };
SHS_INFO mSHAInfo;
#endif
};
///////////////////////////////////////////////////////////////////////////////
@ -312,7 +324,7 @@ public:
virtual ~cHAVALSignature();
virtual void Init ();
virtual void Update( const byte* pbData, int cbDataLen );
virtual void Update( const byte* const pbData, int cbDataLen );
virtual void Finit ();
virtual TSTRING AsString() const;
virtual TSTRING AsStringHex() const;

View File

@ -40,7 +40,8 @@ host_triplet = @host@
subdir = src/fs
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -105,6 +106,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN = @LN@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -113,6 +116,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@

View File

@ -249,6 +249,12 @@ bool cFSDataSourceIter::InitializeTypeInfo(iFCO* pFCO)
case cFSStatArgs::TY_SOCK:
propSet.SetFileType(cFSPropSet::FT_SOCK);
break;
case cFSStatArgs::TY_DOOR:
propSet.SetFileType(cFSPropSet::FT_DOOR);
break;
case cFSStatArgs::TY_PORT:
propSet.SetFileType(cFSPropSet::FT_PORT);
break;
default:
// set it to invalid
propSet.SetFileType(cFSPropSet::FT_INVALID);

View File

@ -41,6 +41,7 @@
#include "fsparserutil.h"
#include "core/fsservices.h"
#include "core/file.h"
#include "fspropset.h"
#include "fsstrings.h"
#include "fco/fcopropvector.h"
@ -136,6 +137,10 @@ void cFSParserUtil::InterpretFCOName( const std::list<TSTRING>& l, cFCOName& nam
for( std::list<TSTRING>::const_iterator i = l.begin(); i != l.end(); i++ )
strT += *i;
#ifdef __AROS__
strT = cArosPath::AsPosix(strT);
#endif
// let cFCOName handle interpretation
nameOut = strT;
}

8
src/fs/fspropcalc.cpp Normal file → Executable file
View File

@ -255,6 +255,12 @@ void cFSPropCalc::VisitFSObject(cFSObject& obj)
case cFSStatArgs::TY_SOCK:
propSet.SetFileType(cFSPropSet::FT_SOCK);
break;
case cFSStatArgs::TY_DOOR:
propSet.SetFileType(cFSPropSet::FT_DOOR);
break;
case cFSStatArgs::TY_PORT:
propSet.SetFileType(cFSPropSet::FT_PORT);
break;
default:
// set it to invalid
propSet.SetFileType(cFSPropSet::FT_INVALID);
@ -295,7 +301,7 @@ void cFSPropCalc::VisitFSObject(cFSObject& obj)
pTheArch = &arch;
try
{
arch.OpenRead(strName.c_str());
arch.OpenRead(strName.c_str(), cFileArchive::FA_NONBLOCKING);
}
catch (eArchive&)
{

View File

@ -58,7 +58,9 @@ TSTRING cFCOPropFileType::AsString() const
fs::STR_FT_CHARDEV,
fs::STR_FT_SYMLINK,
fs::STR_FT_FIFO,
fs::STR_FT_SOCK
fs::STR_FT_SOCK,
fs::STR_FT_DOOR,
fs::STR_FT_PORT
};
int32 fileType = GetValue();

View File

@ -109,6 +109,8 @@ public:
FT_SYMLINK,
FT_FIFO,
FT_SOCK,
FT_DOOR,
FT_PORT,
FT_NUMITEMS
};

View File

@ -49,6 +49,8 @@ TSS_BeginStringtable( cFS )
TSS_StringEntry( fs::STR_FT_SYMLINK, _T("Symbolic Link") ),
TSS_StringEntry( fs::STR_FT_FIFO, _T("FIFO") ),
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") ),
// property names
TSS_StringEntry( fs::STR_PROP_DEV, _T("Device Number") ),

View File

@ -53,6 +53,8 @@ TSS_BeginStringIds( fs )
STR_FT_SYMLINK,
STR_FT_FIFO,
STR_FT_SOCK,
STR_FT_DOOR,
STR_FT_PORT,
// property names
STR_PROP_DEV,

View File

@ -4,6 +4,7 @@ AM_INSTALL_PROGRAM_FLAGS = -m 755
INCLUDES = -I..
LIBS = -ltripwire -lcryptlib @LIBS@
LDFLAGS = @LDFLAGS@ -L../../lib
LN_S = @LN@
sbin_PROGRAMS = siggen
siggen_SOURCES = \
@ -14,4 +15,4 @@ DEFS = @DEFS@ # This gets rid of the -I. so INCLUDES must be more explicit
CLEANFILES = ../../bin/siggen
all: $(sbin_PROGRAMS)
@test -d ../../bin && ln -f $(sbin_PROGRAMS) ../../bin
@test -d ../../bin && $(LN) -f $(sbin_PROGRAMS) ../../bin

View File

@ -41,7 +41,8 @@ sbin_PROGRAMS = siggen$(EXEEXT)
subdir = src/siggen
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -102,6 +103,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@ -L../../lib
LIBOBJS = @LIBOBJS@
LIBS = -ltripwire -lcryptlib @LIBS@
LN = @LN@
LN_S = @LN@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -110,6 +113,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
@ -417,7 +421,7 @@ uninstall-am: uninstall-info-am uninstall-sbinPROGRAMS
all: $(sbin_PROGRAMS)
@test -d ../../bin && ln -f $(sbin_PROGRAMS) ../../bin
@test -d ../../bin && $(LN) -f $(sbin_PROGRAMS) ../../bin
# 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:

View File

@ -4,6 +4,7 @@ AM_INSTALL_PROGRAM_FLAGS = -m 755
INCLUDES = -I..
LIBS = -ltripwire -lcryptlib @LIBS@
LDFLAGS = @LDFLAGS@ -L../../lib
LN_S = @LN@
sbin_PROGRAMS = tripwire
tripwire_SOURCES = \
@ -16,4 +17,4 @@ DEFS = @DEFS@ # This gets rid of the -I. so INCLUDES must be more explicit
CLEANFILES = ../../bin/tripwire ../../lib/libtripwire.a
all: $(sbin_PROGRAMS)
@test -d ../../bin && ln -f $(sbin_PROGRAMS) ../../bin
@test -d ../../bin && $(LN) -f $(sbin_PROGRAMS) ../../bin

View File

@ -41,7 +41,8 @@ sbin_PROGRAMS = tripwire$(EXEEXT)
subdir = src/tripwire
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
@ -106,6 +107,8 @@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@ -L../../lib
LIBOBJS = @LIBOBJS@
LIBS = -ltripwire -lcryptlib @LIBS@
LN = @LN@
LN_S = @LN@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
@ -114,6 +117,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
@ -423,7 +427,7 @@ uninstall-am: uninstall-info-am uninstall-sbinPROGRAMS
all: $(sbin_PROGRAMS)
@test -d ../../bin && ln -f $(sbin_PROGRAMS) ../../bin
@test -d ../../bin && $(LN) -f $(sbin_PROGRAMS) ../../bin
# 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:

View File

@ -258,7 +258,7 @@ bool cMailMessageUtil::ReadDate( TSTRING& strDateBuf )
}
static char* util_Get_IANA_CharSet()
static const char* util_Get_IANA_CharSet()
{
const char* pCP = setlocale( LC_CTYPE, NULL );

View File

@ -54,6 +54,10 @@
#include <arpa/inet.h>
#include <sys/utsname.h>
#ifdef _SORTIX_SOURCE
# include <sys/select.h>
#endif
/* Some systems like Solaris and AIX don't define
* INADDR_NONE, but it's pretty standard. If not,
* then the OS _should_ define it for us.
@ -66,6 +70,12 @@
#define INVALID_SOCKET -1
#ifdef __AROS__
#ifndef HAVE_GETHOSTNAME
#define HAVE_GETHOSTNAME 1
#endif
#endif
#ifndef HAVE_GETHOSTNAME
static int gethostname( char* name, int namelen )
{
@ -87,7 +97,6 @@ static int gethostname( char* name, int namelen )
}
}
#endif
// Unix does not require us to go though any silly DLL hoops, so we'll
// just #define the pointers to functions needed by Windows to be the
// berkely functions.
@ -187,12 +196,16 @@ long cSMTPMailMessage::GetServerAddress()
}
else
{
#ifdef _SORTIX_SOURCE
return INADDR_NONE;
#else
// do a DNS lookup of the hostname and get the long
hostent *ent = mPfnGethostbyname(sNarrowString.c_str());
if (!ent)
return INADDR_NONE;
else
return *(long *)ent->h_addr_list[0];
#endif
}
}

Some files were not shown because too many files have changed in this diff Show More