Open Source Tripwire 2.4.2.2

Initial commit of code from Sourceforge repository.
This commit is contained in:
Ken Westin 2015-05-03 22:26:18 -07:00
parent cf736bbbe7
commit c8dc58df50
612 changed files with 144538 additions and 0 deletions

6
COMMERCIAL Normal file
View File

@ -0,0 +1,6 @@
If you desire enterprise capable software with commercial support, check out
Tripwire, Inc. at http://www.tripwire.com.
For a more detailed comparison of the Open Source Tripwire software and
commercial Tripwire(R) product(s) please visit http://www.tripwire.org.

372
COPYING Normal file
View File

@ -0,0 +1,372 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
---------------------------
Tripwire Trademark Information
The developer of the original code and/or files is Tripwire, Inc. Portions
created by Tripwire, Inc. are copyright 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.
End of Tripwire Trademark Information
---------------------------------------------
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

86
ChangeLog Normal file
View File

@ -0,0 +1,86 @@
2011-11-21 Stephane Dudzinski <tripwire@frlinux.net>
* Bumping version to 2.4.2.2
* Updated version revision in reports and all
* Added experimental policy creation (see policy/policy_generator_readme.txt)
* Fixed report formating and sendmail issues
* Added Debian patches for crypto and hostnames
* Fixed compiling issue on recent GCC compilers (-fpermissive)
2011-07-14 Stephane Dudzinski <tripwire@frlinux.net>
* Bumping version to 2.4.2.1
* Fixed version numbering and added RPM spec file
2010-03-11 Stephane Dudzinski <tripwire@frlinux.net>
* Bumping version to 2.4.2
* Added patch to fix bug [ 1962485 ] Cannot change or expect-script
passphrases - thanks to Ross Tyler (rtyle)
* Removed RPM spec file for now, will be fixed in next release
2007-04-16 Ron Forrester <rjf@theforrest.org>
* Bumping all versions to 2.4.1.2
* Fixed bug in install script when sendmail isn't installed
target system.
* Removed some non-existent files from installer
2005-08-18 Ron Forrester <rjf@theforrest.org>
* Wow, has it been 4+ years? :)
* Starting fresh with Paul's autoconf'ed code base
* Bumped version number, misc cleanup, etc.
2001-02-25 Ron Forrester <rjf@theforrest.org>
* Bumped version to 2.3.1.
* BSD support, thanks to Paul Herman <pherman@frenchfries.net>.
The support was added for FreeBSD 4.2, your mileage may vary on
other BSD's.
* Fixed long standing bug with recurse=3
* If TEMPDIRECTORY was missing trailing /, bad things could
happen. Tripwire now appends a / if one isn't present. Thanks
Jarno.
* Fixed GLOBALEMAIL bug where no global emails would be sent
unless there were emailto attributes somewhere in the policy
file. Additionally, reports were being sliced to global
recipients, despite the fact that global recipients should get
the full report.
2001-02-03 Ron Forrester <rjf@theforrest.org>
* Fixed possible security problem with the handling of temp
files. We now open temp files with O_EXCL set to make sure a
particular file doesn't already exist. Thanks to Jarno for this
suggestion and help via a patch.
* Added the configuration file variable TEMPDIRECTORY. This
variable can be set to the full path to where tripwire should
write its temporary files. By default it is /tmp. Because /tmp has
to be world writable, this isn't a good place for tripwire to
write temporary files. Setting TEMPDIRECTORY to a directory with
permissions 700 is much more secure. Updated man page with info on
this variable.
* Added the configuration file variable GLOBALEMAIL. This variable
can be set to a list of email addresses which are semi-colon or
comma separated. If a report is about to be emailed to addresses
reaped from the policy file, it will also be emailed to the
addresses in the GLOBALEMAIL list, allowing designation of one or
more people to always get email reports. Updated the man page with
info on this variable.
* Began a convention of providing a "Solution:" line to all errors
(exceptions) emitted by tripwire. Only the two latest error
messages incorporate this convention, but all future ones will as
well, and I hope to revist all current errors and retrofit them
with Solution: lines as well.

19
MAINTAINERS Normal file
View File

@ -0,0 +1,19 @@
Open Source Tripwire Maintainers:
tripwire@frlinux.net
Previous Maintainer:
itripn@users.sourceforge.net
Community Contributors:
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
portable code base, and an easier place to start for adding additional
features.
David LaPalomento: David kindly provided precompiled binaries on Red Hat
Enterprise Linux AS release 4 (Nahant Update 3) on IA-64.

7
Makefile.am Normal file
View File

@ -0,0 +1,7 @@
AUTOMAKE_OPTIONS = foreign no-dependencies
SUBDIRS = man src
install-data-hook:
prefix="$(prefix)" sysconfdir="$(sysconfdir)" \
path_to_vi="$(path_to_vi)" path_to_sendmail="$(path_to_sendmail)" \
./install/install.sh

597
Makefile.in Normal file
View File

@ -0,0 +1,597 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
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
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(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 \
configure.lineno configure.status.lineno
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
depcomp =
am__depfiles_maybe =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CORE_CRYPT_O = @CORE_CRYPT_O@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
YACC = @YACC@
YFLAGS = @YFLAGS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
path_to_sendmail = @path_to_sendmail@
path_to_vi = @path_to_vi@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
AUTOMAKE_OPTIONS = foreign no-dependencies
SUBDIRS = man src
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
.SUFFIXES:
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \
cd $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| mkdir "$(distdir)/$$subdir" \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="../$(top_distdir)" \
distdir="../$(distdir)/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
$(AMTAR) chof - $(distdir) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-tarZ: distdir
$(AMTAR) chof - $(distdir) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
$(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(AMTAR) xf - ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(AMTAR) xf - ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile config.h
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-hdr distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
@$(NORMAL_INSTALL)
$(MAKE) $(AM_MAKEFLAGS) install-data-hook
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \
check-am clean clean-generic clean-recursive ctags \
ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-shar \
dist-tarZ dist-zip distcheck distclean distclean-generic \
distclean-hdr distclean-recursive distclean-tags \
distcleancheck distdir distuninstallcheck dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic maintainer-clean-recursive \
mostlyclean mostlyclean-generic mostlyclean-recursive pdf \
pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
uninstall-info-am
install-data-hook:
prefix="$(prefix)" sysconfdir="$(sysconfdir)" \
path_to_vi="$(path_to_vi)" path_to_sendmail="$(path_to_sendmail)" \
./install/install.sh
# 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:

18
TRADEMARK Normal file
View File

@ -0,0 +1,18 @@
TRIPWIRE COPYRIGHT & TRADEMARK NOTICE
COPYRIGHT
The developer of the original code and/or files is Tripwire, Inc. Portions
created by Tripwire, Inc. are copyright 2000 Tripwire, Inc.
TRADEMARK
Tripwire is a registered trademark (the "Trademark") of Tripwire, Inc. All
rights reserved.
The GNU General Public License permits you to use the original code and/or
files created by Tripwire. Nothing in the GNU General Public License or any
other license shall permit you to use the Trademark. If you commercially
distribute or modify the code and/or files, you must obtain Tripwire's prior
written consent to use or reproduce the Trademark.
If you have any questions, please contact Tripwire, Inc. at
info@tripwire.com.

932
aclocal.m4 vendored Normal file
View File

@ -0,0 +1,932 @@
# generated automatically by aclocal 1.8.5 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
# Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# -*- Autoconf -*-
# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
# Generated from amversion.in; do not edit by hand.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.8"])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.8.5])])
# AM_AUX_DIR_EXPAND
# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is `.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# serial 6
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])
AC_SUBST([$1_FALSE])
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.])
fi])])
# serial 7 -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
case $depmode in
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
none) break ;;
esac
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this.
if depmode=$depmode \
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE(dependency-tracking,
[ --disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
#serial 2
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[for mf in $CONFIG_FILES; do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# So let's grep whole file.
if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue
# Extract the definition of DEP_FILES from the Makefile without
# running `make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR"
# We invoke sed twice because it is the simplest approach to
# changing $(DEPDIR) to its actual value in the expansion.
for file in `sed -n '
/^DEP_FILES = .*\\\\$/ {
s/^DEP_FILES = //
:loop
s/\\\\$//
p
n
/\\\\$/ b loop
p
}
/^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each `.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# serial 7
# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS.
AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
# Do all the work for Automake. -*- Autoconf -*-
# This macro actually does too much some checks are only needed if
# your package does certain things. But this isn't really a big deal.
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# serial 11
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.58])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
# test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" &&
test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
AM_MISSING_PROG(AUTOCONF, autoconf)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
AM_MISSING_PROG(AUTOHEADER, autoheader)
AM_MISSING_PROG(MAKEINFO, makeinfo)
AM_MISSING_PROG(AMTAR, tar)
AM_PROG_INSTALL_SH
AM_PROG_INSTALL_STRIP
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES(CC)],
[define([AC_PROG_CC],
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES(CXX)],
[define([AC_PROG_CXX],
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
])
])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$1 | $1:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
install_sh=${install_sh-"$am_aux_dir/install-sh"}
AC_SUBST(install_sh)])
# -*- Autoconf -*-
# Copyright (C) 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# serial 1
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# serial 2
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo done
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# We grep out `Entering directory' and `Leaving directory'
# messages which can occur if `w' ends up in MAKEFLAGS.
# In particular we don't look at `^make:' because GNU make might
# be invoked under some other name (usually "gmake"), in which
# case it prints its new name instead of `make'.
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
am__include=include
am__quote=
_am_result=GNU
fi
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
am__include=.include
am__quote="\""
_am_result=BSD
fi
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# -*- Autoconf -*-
# Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# serial 3
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it supports --run.
# If it does, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
AC_MSG_WARN([`missing' script is too old or missing])
fi
])
# AM_PROG_MKDIR_P
# ---------------
# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
# Copyright (C) 2003, 2004 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
# created by `make install' are always world readable, even if the
# installer happens to have an overly restrictive umask (e.g. 077).
# This was a mistake. There are at least two reasons why we must not
# use `-m 0755':
# - it causes special bits like SGID to be ignored,
# - it may be too restrictive (some setups expect 775 directories).
#
# Do not use -m 0755 and let people choose whatever they expect by
# setting umask.
#
# We cannot accept any implementation of `mkdir' that recognizes `-p'.
# Some implementations (such as Solaris 8's) are not thread-safe: if a
# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
# concurrently, both version can detect that a/ is missing, but only
# one can create it and the other will error out. Consequently we
# restrict ourselves to GNU make (using the --version option ensures
# this.)
AC_DEFUN([AM_PROG_MKDIR_P],
[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
# Keeping the `.' argument allows $(mkdir_p) to be used without
# argument. Indeed, we sometimes output rules like
# $(mkdir_p) $(somedir)
# where $(somedir) is conditionally defined.
# (`test -n '$(somedir)' && $(mkdir_p) $(somedir)' is a more
# expensive solution, as it forces Make to start a sub-shell.)
mkdir_p='mkdir -p -- .'
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# exists.
for d in ./-p ./--version;
do
test -d $d && rmdir $d
done
# $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
if test -f "$ac_aux_dir/mkinstalldirs"; then
mkdir_p='$(mkinstalldirs)'
else
mkdir_p='$(install_sh) -d'
fi
fi
AC_SUBST([mkdir_p])])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# serial 2
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# ------------------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
# _AM_SET_OPTIONS(OPTIONS)
# ----------------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
#
# Check to make sure that the build environment is sane.
#
# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# serial 3
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT(yes)])
# AM_PROG_INSTALL_STRIP
# Copyright (C) 2001, 2003 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# One issue with vendor `install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in `make install-strip', and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'. However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])

1
bin/.fix Normal file
View File

@ -0,0 +1 @@
needed

1298
config.guess vendored Normal file

File diff suppressed because it is too large Load Diff

173
config.h.in Normal file
View File

@ -0,0 +1,173 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* Compile with debug code */
#undef DEBUG
/* this is the prefix for STL exception functions */
#undef EXCEPTION_NAMESPACE
/* Define to 1 if you have the <bits/signum.h> header file. */
#undef HAVE_BITS_SIGNUM_H
/* Uses the GNU gcc compiler */
#undef HAVE_GCC
/* Define to 1 if you have the `gethostid' function. */
#undef HAVE_GETHOSTID
/* Define to 1 if you have the `gethostname' function. */
#undef HAVE_GETHOSTNAME
/* Define to 1 if you have the <iconv.h> header file. */
#undef HAVE_ICONV_H
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define to 1 if you have the <malloc.h> header file. */
#undef HAVE_MALLOC_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `mkstemp' function. */
#undef HAVE_MKSTEMP
/* Define to 1 if you have the `mktemp' function. */
#undef HAVE_MKTEMP
/* Define to 1 if you have the <openssl/md5.h> header file. */
#undef HAVE_OPENSSL_MD5_H
/* Define to 1 if you have the <openssl/sha.h> header file. */
#undef HAVE_OPENSSL_SHA_H
/* Define to 1 if you have the <signum.h> header file. */
#undef HAVE_SIGNUM_H
/* Define to 1 if you have the <stdarg.h> header file. */
#undef HAVE_STDARG_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the `strftime' function. */
#undef HAVE_STRFTIME
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <syslog.h> header file. */
#undef HAVE_SYSLOG_H
/* Define to 1 if you have the <sys/mount.h> header file. */
#undef HAVE_SYS_MOUNT_H
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/statfs.h> header file. */
#undef HAVE_SYS_STATFS_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/syslog.h> header file. */
#undef HAVE_SYS_SYSLOG_H
/* Define to 1 if you have the <sys/sysmacros.h> header file. */
#undef HAVE_SYS_SYSMACROS_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <sys/ustat.h> header file. */
#undef HAVE_SYS_USTAT_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <varargs.h> header file. */
#undef HAVE_VARARGS_H
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
/* Is byte aligned */
#undef IS_BYTE_ALIGNED
/* Is a unix type platform */
#undef IS_UNIX
/* don't generate debuging code */
#undef NDEBUG
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* The size of `int', as computed by sizeof. */
#undef SIZEOF_INT
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
/* The size of `long long', as computed by sizeof. */
#undef SIZEOF_LONG_LONG
/* Don't use gethostbyname() on Solaris */
#undef SOLARIS_NO_GETHOSTBYNAME
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Target OS */
#undef TARGET_OS
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
/* Uses one's complement */
#undef USES_1S_COMPLEMENT
/* Uses two's complement */
#undef USES_2S_COMPLEMENT
/* Uses signed magnitute */
#undef USES_SIGNED_MAGNITUDE
/* 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 to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t

1375
config.sub vendored Normal file

File diff suppressed because it is too large Load Diff

11966
configure vendored Executable file

File diff suppressed because it is too large Load Diff

431
configure.in Normal file
View File

@ -0,0 +1,431 @@
dnl Process this file with autoconf to produce a configure script.
dnl
dnl
AC_INIT
AC_CONFIG_SRCDIR([src/tw/tw.cpp])
AC_CANONICAL_TARGET([])
AM_INIT_AUTOMAKE(tripwire, 2.4.2.2)
AM_CONFIG_HEADER(config.h)
dnl #################################
dnl Cleanup Cruft Leftover From Patch
dnl #################################
rm -f src/tripwire/syslog.h 2> /dev/null
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"}
dnl #####################
dnl Configuration options
dnl #####################
AC_ARG_ENABLE(static, [ --enable-static compile static binaries])
if test "x$enable_static" = xyes
then LDFLAGS="${LDFLAGS} -static"
fi
AC_ARG_ENABLE(debug, [ --enable-debug compile with debuging enabled])
if test "x$enable_debug" = xyes
then
CFLAGS="${CFLAGS} -g"
CXXFLAGS="${CXXFLAGS} -g"
AC_DEFINE(DEBUG, 1, [Compile with debug code])
fi
dnl ###################
dnl Checks for programs
dnl ###################
AC_PROG_CC
AC_PROG_CXX
AC_PROG_RANLIB
AC_PROG_YACC
AC_PATH_PROG(path_to_vi, vi)
AC_PATH_PROG(path_to_sendmail, sendmail, "", [$PATH:/usr/libexec])
if test "x${GXX}" != "x"; then
AC_DEFINE(HAVE_GCC, 1, [Uses the GNU gcc compiler])
else
AC_DEFINE(HAVE_GCC, 0, [Uses the GNU gcc compiler])
fi
dnl #######################
dnl Checks for header files
dnl #######################
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(sys/mount.h,,,
[[#if defined(HAVE_SYS_PARAM_H)
#include <sys/param.h>
#endif
]])
AC_CHECK_HEADERS(sys/ustat.h sys/sysmacros.h sys/syslog.h)
AC_CHECK_HEADERS(unistd.h syslog.h iconv.h langinfo.h sys/statfs.h)
AC_CHECK_HEADERS(signum.h bits/signum.h, break )
AC_CHECK_HEADERS(stdarg.h varargs.h, break )
dnl # Special case for malloc.h, because it's depreciated on most systems.
CPPFLAGS_SAVE="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} -Werror"
AC_CHECK_HEADERS(malloc.h)
CPPFLAGS="${CPPFLAGS_SAVE}"
dnl #############################################################
dnl Checks for typedefs, structures, and compiler characteristics
dnl #############################################################
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(long long)
dnl All platforms we support use 2's complement, are byte aligned, etc...
AC_DEFINE(USES_1S_COMPLEMENT, 0, [Uses one's complement])
AC_DEFINE(USES_2S_COMPLEMENT, 1, [Uses two's complement])
AC_DEFINE(USES_SIGNED_MAGNITUDE, 0, [Uses signed magnitute])
AC_DEFINE(IS_BYTE_ALIGNED, 1, [Is byte aligned])
AC_DEFINE(EXCEPTION_NAMESPACE, std::, [this is the prefix for STL exception functions])
dnl We used to check for UNIX or Unix-like target platforms,
dnl but that is a little extreme, so just assume that the
dnl target is unix. This can still be changed in config.h
AC_DEFINE(IS_UNIX, 1, [Is a unix type platform])
dnl whether or not to generate debuging code?
AC_DEFINE(NDEBUG, 1, [don't generate debuging code])
dnl #############################
dnl Checks for standard functions
dnl #############################
AC_CHECK_FUNCS(strftime gethostname gethostid)
AC_CHECK_FUNCS(mkstemp mktemp, break)
dnl ##############################################
dnl Checks for various platform specific libraries
dnl ##############################################
dnl socket? Solaris has it somewhere else.
AC_CHECK_LIB(c, socket, [:], [
AC_CHECK_LIB(socket, socket, [
LIBS="-lsocket $LIBS"
], [:]) ])
dnl gethostbyname? Solaris has it somewhere else.
AC_CHECK_LIB(c, gethostbyname, [:], [
AC_CHECK_LIB(nsl, gethostbyname, [
LIBS="-lnsl $LIBS"
], [:]) ])
dnl check for stl library
AC_LANG_SAVE
AC_LANG_CPLUSPLUS
dnl
dnl Check for STL headers
dnl
AC_CHECK_HEADER(locale,, [
dnl Don't have native STL headers, look in other places
AC_CACHE_CHECK([for STLport directory], ac_cv_stlportdir, [
found_locale=""
for inclpath in /usr/local/include /usr/local/include/stlport
do
CPPFLAGS_save=${CPPFLAGS}
CPPFLAGS="${CPPFLAGS} -I${inclpath}"
AC_TRY_COMPILE([
#include <locale>
]
, , [ found_locale="1" ], )
CPPFLAGS=${CPPFLAGS_save}
if test "x${found_locale}" = "x1"
then
ac_cv_stlportdir=${inclpath}
break
fi
done
if test "x${found_locale}" = "x"; then
echo "not found"
AC_MSG_WARN( [
*** You don't seem to have STL support in your C++ compiler.
*** You can try to build tripwire, but it probably won't compile.
])
fi
])
])
if test "x${ac_cv_stlportdir}" != "x"
then
CPPFLAGS="${CPPFLAGS} -I${ac_cv_stlportdir}"
fi
AC_TRY_LINK([#include <locale>],,,[
dnl Don't have native STL library, look in other places
dnl First check for POSIX threads if we compile STLport, because it needs it
AC_CHECK_FUNC(pthread_getspecific, [:], [
LDFLAGS_TEMP="${LDFLAGS}"
LDFLAGS="${LDFLAGS_TEMP} -pthread"
unset ac_cv_func_pthread_getspecific
AC_CHECK_FUNC(pthread_getspecific, [:], [
LDFLAGS="${LDFLAGS_TEMP} -lpthread"
unset ac_cv_func_pthread_getspecific
AC_CHECK_FUNC(pthread_getspecific, [:], [
LDFLAGS="${LDFLAGS_TEMP}"
AC_MSG_ERROR([No posix threads detected, cannot continue.]) ])
])
])
AC_CACHE_CHECK([for STLport library directory], ac_cv_stlportlib, [
found_lib=""
for inclpath in /usr/local/lib /usr/local/lib/stlport
do
for stllib in stlport stlport_gcc
do
LDFLAGS_save=${LDFLAGS}
LIBS_save=${LIBS}
LDFLAGS="${LDFLAGS} -L${inclpath}"
LIBS="${LIBS} -l${stllib}"
AC_TRY_LINK([
#include <locale>
]
, , [ found_lib="1" ], )
LDFLAGS=${LDFLAGS_save}
LIBS=${LIBS_save}
if test "x${found_lib}" = "x1"
then
ac_cv_stlportlib=${inclpath}
break
fi
done
if test "x${found_lib}" = "x1"
then
break
fi
done
if test "x${found_lib}" = "x"; then
echo "not found"
AC_MSG_WARN( [
*** You don't seem to have STL support in your C++ compiler.
*** You can try to build tripwire, but it probably won't compile.
])
fi
])
if test "x${ac_cv_stlportdir}" != "x"
then
LDFLAGS="${LDFLAGS} -L${ac_cv_stlportlib}"
LIBS="${LIBS} -l${stllib}"
fi
])
AC_LANG_RESTORE
dnl #####################
dnl STL specific headers
dnl #####################
AC_CHECK_HEADERS(wchar.h)
dnl #######################################################################
dnl Local checks/hacks. The goal is to make this part as short as possible
dnl #######################################################################
AC_DEFINE_UNQUOTED(TARGET_OS, "${target}", [Target OS])
case $target in
i386-*-freebsd*)
;;
alpha-*-freebsd*)
;;
i386-*-openbsd*)
;;
*-*-netbsd*)
;;
i[[0-9]]86-pc-linux*)
;;
sparc-*-linux*)
;;
*-sun-solaris*)
if test "x$enable_static" = xyes
then
AC_MSG_WARN( [
Sorry, tripwire will not properly link staticaly under Solaris.
This is due to tripwire's extensive use of gethostbyname(),
which can only be linked dynamicaly. Please rerun configure
without the --enable-static option.
])
AC_DEFINE(SOLARIS_NO_GETHOSTBYNAME, 1, [Don't use gethostbyname() on Solaris])
fi
LIBS="-ldl $LIBS"
AC_CHECK_HEADERS(strings.h)
;;
alpha*-*-osf*)
CXXFLAGS="${CXXFLAGS} -D_ALPHA"
;;
*)
;;
esac
dnl ###################################################
dnl Try linking a simple program with the flags we have
dnl ###################################################
AC_TRY_LINK( , return 0 , , [ AC_MSG_WARN( [
Hmmm... doesn't look so good. I just tried linking a program
and it failed. One reason could be missing static libraries
if you are trying to compile a static binary.
]) ] )
dnl Check for OpenSSL, now that we have a working compiler
AC_ARG_ENABLE(openssl,
[ --disable-openssl don't link against OpenSSL libraries])
AC_ARG_WITH(ssl-dir,
[ --with-ssl-dir=PATH Specify path to OpenSSL installation ],
[
if test "x$withval" != "xno" ; then
tryssldir=$withval
fi
]
)
dnl #################
dnl Check for OpenSSL
dnl #################
CORE_CRYPT_O="md5.o sha.o"
if test "x${enable_openssl}" != "xno"
then
saved_LIBS="$LIBS"
saved_LDFLAGS="$LDFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
if test "x$prefix" != "xNONE" ; then
tryssldir="$tryssldir $prefix"
fi
AC_CACHE_CHECK([for OpenSSL directory], ac_cv_openssldir, [
for ssldir in $tryssldir "" /usr/local/openssl /usr/lib/openssl /usr/local/ssl /usr/lib/ssl /usr/local /usr/pkg /opt /opt/openssl ; do
CPPFLAGS="$saved_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS -lcrypto"
# Skip directories if they don't exist
if test ! -z "$ssldir" -a ! -d "$ssldir" ; then
continue;
fi
if test ! -z "$ssldir" -a "x$ssldir" != "x/usr"; then
# Try to use $ssldir/lib if it exists, otherwise
# $ssldir
if test -d "$ssldir/lib" ; then
LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
if test ! -z "$need_dash_r" ; then
LDFLAGS="-R$ssldir/lib $LDFLAGS"
fi
else
LDFLAGS="-L$ssldir $saved_LDFLAGS"
if test ! -z "$need_dash_r" ; then
LDFLAGS="-R$ssldir $LDFLAGS"
fi
fi
# Try to use $ssldir/include if it exists, otherwise
# $ssldir
if test -d "$ssldir/include" ; then
CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
else
CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
fi
fi
# Basic test to check for compatible library and
# correct linking
AC_TRY_RUN(
[
#include <string.h>
#include <openssl/rand.h>
int main(void)
{
char a[2048];
memset(a, 0, sizeof(a));
RAND_add(a, sizeof(a), sizeof(a));
return(RAND_status() <= 0);
}
],
[
found_crypto=1
break;
], []
)
if test ! -z "$found_crypto" ; then
break;
fi
done
if test -z "$ssldir" ; then
ssldir="(system)"
fi
if test -z "$found_crypto" ; then
ac_cv_openssldir="not found"
else
ac_cv_openssldir=$ssldir
fi
])
LIBS="$saved_LIBS"
if (test ! -z "$ac_cv_openssldir" && test "x$ac_cv_openssldir" != "xnot found") ; then
dnl Need to recover ssldir - test above runs in subshell
ssldir=$ac_cv_openssldir
if test "x$ssldir" != "x/usr" -a "x$ssldir" != "x(system)"; then
# Try to use $ssldir/lib if it exists, otherwise
# $ssldir
if test -d "$ssldir/lib" ; then
LDFLAGS="-L$ssldir/lib $saved_LDFLAGS"
if test ! -z "$need_dash_r" ; then
LDFLAGS="-R$ssldir/lib $LDFLAGS"
fi
else
LDFLAGS="-L$ssldir $saved_LDFLAGS"
if test ! -z "$need_dash_r" ; then
LDFLAGS="-R$ssldir $LDFLAGS"
fi
fi
# Try to use $ssldir/include if it exists, otherwise
# $ssldir
if test -d "$ssldir/include" ; then
CPPFLAGS="-I$ssldir/include $saved_CPPFLAGS"
else
CPPFLAGS="-I$ssldir $saved_CPPFLAGS"
fi
fi
LIBS="$saved_LIBS -lcrypto"
AC_CHECK_HEADERS(openssl/md5.h openssl/sha.h)
CORE_CRYPT_O=""
fi
fi
dnl #####################################
dnl Export the variables we use
dnl #####################################
AC_SUBST(CORE_CRYPT_O)
AC_CONFIG_FILES([
Makefile
man/Makefile
man/man4/Makefile
man/man5/Makefile
man/man8/Makefile
src/Makefile
src/cryptlib/Makefile
src/core/Makefile
src/db/Makefile
src/fco/Makefile
src/fs/Makefile
src/tw/Makefile
src/twcrypto/Makefile
src/twparser/Makefile
src/util/Makefile
src/twprint/Makefile
src/twadmin/Makefile
src/siggen/Makefile
src/tripwire/Makefile
])
AC_OUTPUT

21
contrib/make-bin-dist Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
#
# A very cheesy script to prep a release
#
PRODUCT=tripwire
VERSION=2.4.2.2
ARCH=x86
TYPE=bin
ROOT_DIR=$PRODUCT-$VERSION-$ARCH-$TYPE
EXCLUDES=.svn
mkdir $ROOT_DIR
ln -s ../bin ../contrib ../man ../policy $ROOT_DIR/
ln -s ../COPYING ../ChangeLog ../INSTALL ../MAINTAINERS $ROOT_DIR/
ln -s ../TRADEMARK ../COMMERCIAL ../install ../install-sh $ROOT_DIR/
tar jhcf $ROOT_DIR.tar.bz2 $ROOT_DIR --exclude $EXCLUDES
sha1sum $ROOT_DIR.tar.bz2 > $ROOT_DIR.sha1
sha1sum bin/* >> $ROOT_DIR.sha1

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=/usr/local/etc
TWDB_PATH=/usr/local/lib/tripwire
TWROOT_PATH=/usr/local/sbin
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

251
install-sh Executable file
View File

@ -0,0 +1,251 @@
#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"
# put in absolute paths if you don't have them in your path; or use env. vars.
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"
transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
-d) dir_arg=true
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
*) if [ x"$src" = x ]
then
src=$1
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
then
echo "install: no input file specified"
exit 1
else
true
fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
else
instcmd=mkdir
fi
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
then
true
else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
exit 1
else
true
fi
# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic
if [ -d $dst ]
then
dst="$dst"/`basename $src`
else
true
fi
fi
## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# this part is taken from Noah Friedman's mkinstalldirs script
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"
pathcomp=''
while [ $# -ne 0 ] ; do
pathcomp="${pathcomp}${1}"
shift
if [ ! -d "${pathcomp}" ] ;
then
$mkdirprog "${pathcomp}"
else
true
fi
pathcomp="${pathcomp}/"
done
fi
if [ x"$dir_arg" != x ]
then
$doit $instcmd $dst &&
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
true
fi
# Make a temp file name in the proper directory.
dsttmp=$dstdir/#inst.$$#
# Move or copy the file name to the temp name
$doit $instcmd $src $dsttmp &&
trap "rm -f ${dsttmp}" 0 &&
# and set any options; do chmod last to preserve setuid bits
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
exit 0

109
install/install.cfg Normal file
View File

@ -0,0 +1,109 @@
#
# install.cfg
#
# default install.cfg for:
# Tripwire(R) 2.4 Open Source
#
# NOTE: This is a Bourne shell script that stores installation
# parameters for your installation. The installer will
# execute this file to generate your config file and also to
# locate any special configuration needs for your install.
# Protect this file, because it is possible for
# malicious code to be inserted here
#
# This version of Tripwire has been modified to conform to the FHS
# standard for Unix-like operating systems.
#
# To change the install directory for any tripwire files, modify
# the paths below as necessary.
#
#=======================================================
# If CLOBBER is true, then existing files are overwritten.
# If CLOBBER is false, existing files are not overwritten.
CLOBBER=false
# Tripwire binaries are stored in TWBIN.
TWBIN="${prefix}/sbin"
# Tripwire policy files are stored in TWPOLICY.
TWPOLICY="${sysconfdir}"
# Tripwire manual pages are stored in TWMAN.
TWMAN="${prefix}/man"
# Tripwire database files are stored in TWDB.
TWDB="${prefix}/lib/tripwire"
# Tripwire documents directory
TWDOCS="${prefix}/doc/tripwire"
# The Tripwire site key files are stored in TWSITEKEYDIR.
TWSITEKEYDIR="${TWPOLICY}"
# The Tripwire local key files are stored in TWLOCALKEYDIR.
TWLOCALKEYDIR="${TWPOLICY}"
# Tripwire report files are stored in TWREPORT.
TWREPORT="${TWDB}/report"
# This sets the default text editor for Tripwire.
TWEDITOR="${path_to_vi}"
# TWLATEPROMTING controls the point when tripwire asks for a password.
TWLATEPROMPTING=false
# TWLOOSEDIRCHK selects whether the directory should be monitored for
# properties that change when files in the directory are monitored.
TWLOOSEDIRCHK=false
# TWMAILNOVIOLATIONS determines whether Tripwire sends a no violation
# report when integrity check is run with --email-report but no rule
# violations are found. This lets the admin know that the integrity
# was run, as opposed to having failed for some reason.
TWMAILNOVIOLATIONS=true
# TWEMAILREPORTLEVEL determines the verbosity of e-mail reports.
TWEMAILREPORTLEVEL=3
# TWREPORTLEVEL determines the verbosity of report printouts.
TWREPORTLEVEL=3
# TWSYSLOG determines whether Tripwire will log events to the system log
TWSYSLOG=false
#####################################
# Mail Options - Choose the appropriate
# method and comment the other section
#####################################
#####################################
# SENDMAIL options - DEFAULT
#
# Either SENDMAIL or SMTP can be used to send reports via TWMAILMETHOD.
# Specifies which sendmail program to use.
#####################################
TWMAILMETHOD=SENDMAIL
#####################################
# SMTP options
#
# TWSMTPHOST selects the SMTP host to be used to send reports.
# SMTPPORT selects the SMTP port for the SMTP mail program to use.
#####################################
#TWMAILMETHOD=SMTP
#TWSMTPHOST="mail.domain.com"
#TWSMTPPORT=25
# If sendmail wasn't found in the path, set then clear out
# TWMAILPROGRAM so the install.sh does the right thing and
# tells the user about the missing configuration
#
path_to_sendmail=/usr/sbin/sendmail
if [ -z "$path_to_sendmail" ] ; then
TWMAILPROGRAM=""
else
TWMAILPROGRAM="${path_to_sendmail} -oi -t"
fi

922
install/install.sh Executable file
View File

@ -0,0 +1,922 @@
#!/bin/sh
#########################################################
#########################################################
##
## Tripwire(R) 2.4 Open Source install script
##
#########################################################
#########################################################
##=======================================================
## Setup
##=======================================================
##-------------------------------------------------------
## Sanity checks, mostly stolen (with permission)
## from Larry Wall's metaconfig.
##-------------------------------------------------------
PATH='.:/bin:/usr/bin'
export PATH || (echo 'You must use sh to run this script'; kill $$)
if [ ! -t 0 ] ; then
echo "Say 'sh install.sh', not 'sh < install.sh'"
exit 1
fi
##-------------------------------------------------------
## The usage message.
##-------------------------------------------------------
USAGE="install.sh [<configfile>] [-n] [-f] [-s <sitepassphrase>] [-l <localpassphrase>]"
##-------------------------------------------------------
## Figure out how to do an echo without newline.
##-------------------------------------------------------
if [ "`echo -n`" = "-n" ] ; then
n=""
c="\c"
else
n=" -n"
c=""
fi
##-------------------------------------------------------
## Better have a copy of tar!
## If /bin/sh does not exist or is not readable (seems
## fairly unlikely), then this will fail.
##-------------------------------------------------------
(tar cvf /dev/null /bin/sh) 2> /dev/null 1>&2
if [ $? -ne 0 ]; then
echo "tar command not found -- aborting install."
exit 1
fi
##-------------------------------------------------------
## Can't live without sed.
##-------------------------------------------------------
(echo 'abc' | sed 's/abc/def/') 2> /dev/null 1>&2
if [ $? -ne 0 ]; then
echo "sed command not found -- aborting install."
exit 1
fi
##-------------------------------------------------------
## Does this system have a copy of awk we can use?
##-------------------------------------------------------
AWK=""
awknames="awk nawk gawk"
for p in $awknames; do
($p '{ exit 0 }' < /dev/null) 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
AWK=$p
break
fi
done
##-------------------------------------------------------
## Does this system have a copy of grep we can use?
## Some greps don't return status (amazing, huh?),
## so we look for a copy of grep that
## returns 0 status for an exact match
## returns 0 status for a case-insensitive match
## returns 0 status for a wildcard match
## returns non-zero status for a failed match
##-------------------------------------------------------
GREP=""
grepnames="grep egrep"
lcgrepstr="findensiemich" # all lower case
mcgrepstr="FindenSieMich" # mixed case
wcgrepstr="sie.ich$" # wild card match
nogrepstr="WoBistDu" # should not be able to find this
for p in $grepnames; do
(echo "$lcgrepstr" | $p "$lcgrepstr") 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
(echo "$lcgrepstr" | $p -i "$mcgrepstr") 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
(echo "$lcgrepstr" | $p "$wcgrepstr") 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
(echo "$lcgrepstr" | $p "$nogrepstr") 2> /dev/null 1>&2
if [ $? -ne 0 ]; then
GREP=$p
break
fi
fi
fi
fi
done
##-------------------------------------------------------
## Does this system have a pager that we can use?
## Use cat if desperate.
##-------------------------------------------------------
MORE="cat"
morenames="more less cat"
for p in $morenames; do
($p $0 < /dev/null) 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
MORE=$p
break
fi
done
##-------------------------------------------------------
## Does this system have a copy of uname we can use?
##-------------------------------------------------------
UNAME=""
(uname -s -r -v) 2> /dev/null 1>&2
if [ $? -eq 0 ]; then
UNAME=uname
fi
##=======================================================
## Command line
##=======================================================
##-------------------------------------------------------
## Miscellaneous configuration parameters.
##-------------------------------------------------------
# prefix
prefix="${prefix:=/usr}"
# License File name
TWLICENSEFILE="COPYING"
# Default Tripwire configuration file.
TW_CONFIG_FILE="tw.cfg"
# Name of initial cleartext Tripwire config file.
CLR_CONFIG_FILE="twcfg.txt"
# Name of initial cleartext Tripwire policy file.
CLR_POLICY_FILE="twpol.txt"
# Default installation script configuration file.
INSTALL_CONFIG_FILE="./install/install.cfg"
# Relative path to dir that contains the pkg files.
PKG_DIR="pkg"
# Names of the package files.
# See also copy-files section below.
BIN_PKG="bin.pkg"
POL_PKG="policy.pkg"
MAN_PKG="man.pkg"
# Starting directory.
START_DIR=`pwd`
# Site passphrase.
TW_SITE_PASS=""
# Local passphrase.
TW_LOCAL_PASS=""
# If clobber==true, overwrite files; if false, do not overwrite files.
CLOBBER="false"
# If prompt==true, ask for confirmation before continuing with install.
PROMPT="true"
# Guess where the toplevel for the distribution is.
# A bad guess is the current directory
TAR_DIR=${TAR_DIR:-${START_DIR}}
OS=`uname -s`
POLICYSRC="twpol-${OS:=GENERIC}.txt"
if [ ! -r ${TAR_DIR}/policy/${POLICYSRC} ]
then POLICYSRC="twpol-GENERIC.txt"
fi
##-------------------------------------------------------
## Parse the command line.
##-------------------------------------------------------
while [ "x$1" != "x" ] ; do
case "$1" in
-n) PROMPT="false"; xCLOBBER="true" ;;
-f) xCLOBBER="true" ;;
-s) case "$2" in
"" | -*)
echo "Error: missing sitepassphrase with -s option." 1>&2
echo "$USAGE"
exit 1 ;;
*) TW_SITE_PASS="$2"; shift ;;
esac ;;
-l) case "$2" in
"" | -*)
echo "Error: missing localpassphrase with -l option." 1>&2
echo "$USAGE"
exit 1 ;;
*) TW_LOCAL_PASS="$2"; shift ;;
esac ;;
-*) echo "Error: unknown argument $1" 1>&2
echo "$USAGE"
exit 1 ;;
*) INSTALL_CONFIG_FILE="$1"
if [ $xgot ] ; then
echo "Error: incorrect number of arguments" 1>&2
echo "$USAGE"
exit 1
fi
xgot="true"
;;
esac
shift
done
##-------------------------------------------------------
## Print the sign-on banner here before the first
## non-error message is displayed.
##-------------------------------------------------------
cat << END_OF_TEXT
Installer program for:
Tripwire(R) 2.4 Open Source
Copyright (C) 1998-2000 Tripwire (R) Security Systems, Inc. Tripwire (R)
is a registered trademark of the Purdue Research Foundation and is
licensed exclusively to Tripwire (R) Security Systems, Inc.
END_OF_TEXT
##-------------------------------------------------------
## Print a message if the user aborts the install.
##-------------------------------------------------------
trap "echo ; echo 'Installation has been halted.' ; exit 1" 1 2 15
##-------------------------------------------------------
## The pathname variables we expect to find in the
## install.cfg file.
##-------------------------------------------------------
paths="TWBIN TWMAN TWPOLICY TWREPORT TWDB TWSITEKEYDIR TWLOCALKEYDIR"
path2="TWBIN TWPOLICY TWREPORT TWDB TWSITEKEYDIR TWLOCALKEYDIR"
path3="TWMAN TWDOCS"
##=======================================================
## User License Agreement
##=======================================================
##-------------------------------------------------------
## Where is the license agreement file?
##-------------------------------------------------------
EULA_PATH="$TWLICENSEFILE"
##-------------------------------------------------------
## If prompting is turned on, get acceptance from user before moving on.
##-------------------------------------------------------
if [ "$PROMPT" = "true" ] ; then
echo
echo "LICENSE AGREEMENT for Tripwire(R) 2.4 Open Source"
echo
echo "Please read the following license agreement. You must accept the"
echo "agreement to continue installing Tripwire."
echo
echo "Press ENTER to view the License Agreement."
echo
read inputstring
# Show the user the license:
${PAGER:-${MORE}} $EULA_PATH
# Now confirm that the user agrees to the license:
echo
echo 'Please type "accept" to indicate your acceptance of this'
(echo $n "license agreement. [do not accept] " $c) 1>&2
read ans
case "$ans" in
accept|Accept|ACCEPT) ;;
*) echo "YOU DID NOT ACCEPT THE LICENSE AGREEMENT. INSTALLATION TERMINATED."
exit 1
;;
esac
fi
##-------------------------------------------------------
## Execute the installation configuration file
##-------------------------------------------------------
echo "Using configuration file $INSTALL_CONFIG_FILE"
echo
. $INSTALL_CONFIG_FILE
##=======================================================
## Process the configuration parameters.
##=======================================================
##-------------------------------------------------------
## Value on command line, if present, overrides value in
## config file. Value must either be "true" or "false"
## exactly; if it's not the former, make it the latter.
##-------------------------------------------------------
CLOBBER=${xCLOBBER-$CLOBBER}
if [ ! "$CLOBBER" = "true" ] ; then
CLOBBER="false"
fi
##-------------------------------------------------------
## If no prompting was selected, both site and local
## passphrases must be specified on the command line.
##-------------------------------------------------------
if [ "$PROMPT" = "false" ] ; then
if [ -z "$TW_SITE_PASS" ] || [ -z "$TW_LOCAL_PASS" ] ; then
echo "Error: You must specify site and local passphrase" 1>&2
echo "if no prompting is chosen." 1>&2
echo "$USAGE"
exit 1
fi
fi
##-------------------------------------------------------
## For each pathname variable:
## Make sure it's defined.
## Strip trailing slashes from each of the directory variables.
## Determine length of longest parameter name.
##-------------------------------------------------------
len=0
for i in $paths; do
# Is it defined?
eval "test \"\$${i}\""
if [ $? -ne 0 ] ; then
echo "Error: configuration parameter \$$i undefined." 1>&2
echo "There is an error in the configuration file ${INSTALL_CONFIG_FILE}." 1>&2
exit 1
fi
# Strip trailing slashes.
# Squash multiple internal slashes down to one.
eval "xtmp=\$${i}"
xtmp=`echo $xtmp | sed 's/\/*$//'`
xtmp=`echo $xtmp | sed 's/\/\/*/\//g'`
eval "${i}=\"$xtmp\""
# Does it start with a slash (i.e. is it an absolute pathname)?
ytmp=`echo $xtmp | sed 's/^\///'`
if [ "$xtmp" = "$ytmp" ] ; then
echo "Error: \$$i is not an absolute pathname." 1>&2
echo 'Relative pathnames may not be used.' 1>&2
exit 1
fi
# What is the length of the longest variable name?
if [ "$AWK" != "" ] ; then
xlen=`echo "${i}" | $AWK '{ print length }'`
if [ $xlen -gt $len ] ; then
len=$xlen
fi
fi
done
##-------------------------------------------------------
## Check Mailmethod for SMTP. If SMTP ignore MAILPROGRAM.
## If SENDMAIL is specified, verify that the specified
## mail program exists
##-------------------------------------------------------
echo "Checking for programs specified in install configuration file...."
echo
TWMAILMETHOD=${TWMAILMETHOD:-'SENDMAIL'}
if [ "$TWMAILMETHOD" = "SENDMAIL" ] ; then
if [ -n "$TWMAILPROGRAM" ] ; then
echo "${TWMAILPROGRAM} exists. Continuing installation."
echo
else
echo ""
echo "*** No sendmail found. Edit install.cfg and set"
echo "*** TWMAILPROGRAM to full path to sendmail, or"
echo "*** change TWMAILMETHOD to SMTP and set SMTP"
echo "*** settings appropriately."
echo ""
exit 1
fi
else
echo "Using SMTP mail protocol."
echo "MAILPROGRAM variable will be ignored."
echo "Continuing installation."
echo
fi
##-------------------------------------------------------
## Verify that the specified editor program exists
##-------------------------------------------------------
TWEDITOR=${TWEDITOR:-'/bin/vi'}
if [ -x ${TWEDITOR} ]; then
echo "${TWEDITOR} exists. Continuing installation."
echo
else
echo "${TWEDITOR} does not exist. Exiting."
exit 1
fi
##-------------------------------------------------------
## Where are the bin files? Did they build okay? Don't
## bother to install if they don't exist.
##-------------------------------------------------------
echo
echo "----------------------------------------------"
echo "Verifying existence of binaries..."
echo
BASE_DIR="./"
if [ ! -z "$BASE_DIR" ] ; then
BIN_DIR="${BASE_DIR}bin"
fi
CWD=`pwd`
cd "$TAR_DIR"
TAR_DIR=`pwd`
cd "$BASE_DIR"
files="$BIN_DIR/siggen $BIN_DIR/tripwire $BIN_DIR/twprint $BIN_DIR/twadmin"
for i in $files; do
if [ -s "$i" ] ; then
echo "$i found"
else
echo "$i missing. Build did not complete successfully."
exit 1
fi
done
cd "$CWD"
##-------------------------------------------------------
## Print the list of target directories.
##-------------------------------------------------------
echo
echo "This program will copy Tripwire files to the following directories:"
echo
for i in $paths; do
if [ "$AWK" != "" ] ; then
eval "echo \"${i}\" | $AWK '{printf \"%${len}s: \", \$1}'"
eval "echo \"\$${i}\""
else
eval "echo \"\$${i}\""
fi
done
##-------------------------------------------------------
## Display value of clobber.
##-------------------------------------------------------
echo
echo "CLOBBER is $CLOBBER."
##-------------------------------------------------------
## Prompt to continue.
##-------------------------------------------------------
if [ "$PROMPT" = "true" ] ; then
echo
(echo $n "Continue with installation? [y/n] " $c) 1>&2
read ans
case "$ans" in
[yY]*) ;;
*) echo "Installation has been halted."
exit 1;
;;
esac
fi
##=======================================================
## Create directories.
##=======================================================
echo
echo "----------------------------------------------"
echo "Creating directories..."
echo
##-------------------------------------------------------
## Create only directories that do not already exist.
## Change permissions only on directories we create.
## Exit if mkdir fails.
##-------------------------------------------------------
for i in $path2; do
eval "d=\$${i}"
if [ ! -d "$d" ] ; then
mkdir -p "$d"
if [ ! -d "$d" ] ; then
echo "Error: unable to create directory $d"
exit 1
else
echo "$d: created"
chmod 0750 "$d" > /dev/null
fi
else
echo "$d: already exists"
fi
done
for i in $path3; do
eval "d=\$${i}"
if [ ! -d "$d" ] ; then
mkdir -p "$d"
if [ ! -d "$d" ] ; then
echo "Error: unable to create directory $d"
exit 1
else
echo "$d: created"
chmod 0755 "$d" > /dev/null
fi
else
echo "$d: already exists"
fi
done
##=======================================================
## Copy all files to the location specified.
##=======================================================
echo
echo "----------------------------------------------"
echo "Copying files..."
echo
##-------------------------------------------------------
## Find all the relevant files. For each
## file in the list, if it exists with size greater
## than zero AND (clobber == false), then don't
## overwrite that file.
## Associate loose file names with directories.
## Special case the Release_Notes file through README_LOC.
## This is used in the install script's closing message.
## Make sure README_LOC and fil1 stay in sync.
##-------------------------------------------------------
#f1=' ff=$README ; d="" ; dd=$TWDOCS ; rr=0444 '
#f2=' ff=$REL_NOTES ; d="" ; dd=$TWDOCS ; rr=0444 '
f3=' ff=$TWLICENSEFILE ; d="" ; dd=$TWDOCS ; rr=0444 '
#f4=' ff=tripwire ; d="/bin" ; dd=$TWBIN ; rr=0550 '
#f5=' ff=twadmin ; d="/bin" ; dd=$TWBIN ; rr=0550 '
#f6=' ff=twprint ; d="/bin" ; dd=$TWBIN ; rr=0550 '
#f7=' ff=siggen ; d="/bin" ; dd=$TWBIN ; rr=0550 '
f8=' ff=TRADEMARK ; d="" ; dd=$TWDOCS ; rr=0444 '
f9=' ff=policyguide.txt ; d="/policy" ; dd=$TWDOCS ; rr=0444 '
f10=' ff=${POLICYSRC} ; d="/policy" ; dd=$TWPOLICY ; rr=0640 '
#f11=' ff=twpolicy.4 ; d="/man/man4" ; dd=$TWMAN/man4 ; rr=0444 '
#f12=' ff=twconfig.4 ; d="/man/man4" ; dd=$TWMAN/man4 ; rr=0444 '
#f13=' ff=twfiles.5 ; d="/man/man5" ; dd=$TWMAN/man5 ; rr=0444 '
#f14=' ff=siggen.8 ; d="/man/man8" ; dd=$TWMAN/man8 ; rr=0444 '
#f15=' ff=tripwire.8 ; d="/man/man8" ; dd=$TWMAN/man8 ; rr=0444 '
#f16=' ff=twadmin.8 ; d="/man/man8" ; dd=$TWMAN/man8 ; rr=0444 '
#f17=' ff=twintro.8 ; d="/man/man8" ; dd=$TWMAN/man8 ; rr=0444 '
#f18=' ff=twprint.8 ; d="/man/man8" ; dd=$TWMAN/man8 ; rr=0444 '
# Binaries and manpages are already installed by the install target
loosefiles="f3 f8 f9 f10"
for i in $loosefiles; do
eval "eval \"\$$i\""
f=${TAR_DIR}$d/$ff
ff=${dd}/$ff
if [ -s $ff ] && [ "$CLOBBER" = "false" ] ; then
echo "$ff: file already exists"
else
cp "$f" "$dd"
if [ $? -eq 0 ]; then
echo "$ff: copied"
chmod "$rr" "$ff" > /dev/null
else
echo "$ff: copy failed"
fi
fi
done
##=======================================================
## Files are now present on user's system.
## Begin Tripwire configuration.
##=======================================================
##-------------------------------------------------------
## Set default values for Tripwire file names.
##-------------------------------------------------------
HOST_NAME=`uname -n 2>/dev/null`
LOCAL_KEY="${TWLOCALKEYDIR}/${HOST_NAME:=localhost}-local.key"
SITE_KEY="${TWSITEKEYDIR}/site.key"
CONFIG_FILE="${TWPOLICY}/$TW_CONFIG_FILE" # Signed config file
POLICY_FILE="${TWPOLICY}/tw.pol" # Signed policy file
TXT_CFG="${TWPOLICY}/${CLR_CONFIG_FILE}" # Cleartext config file
TXT_POL="${TWPOLICY}/$CLR_POLICY_FILE" # Cleartext policy file
TWADMIN="${TWBIN}/twadmin"
##-------------------------------------------------------
## If user has to enter a passphrase, give some
## advice about what is appropriate.
##-------------------------------------------------------
if [ -z "$TW_SITE_PASS" ] || [ -z "$TW_LOCAL_PASS" ]; then
cat << END_OF_TEXT
----------------------------------------------
The Tripwire site and local passphrases are used to
sign a variety of files, such as the configuration,
policy, and database files.
Passphrases should be at least 8 characters in length
and contain both letters and numbers.
See the Tripwire manual for more information.
END_OF_TEXT
fi
##=======================================================
## Generate keys.
##=======================================================
echo
echo "----------------------------------------------"
echo "Creating key files..."
##-------------------------------------------------------
## Site key file.
##-------------------------------------------------------
# If clobber is true, and prompting is off (unattended operation)
# and the key file already exists, remove it. Otherwise twadmin
# will prompt with an "are you sure?" message.
if [ "$CLOBBER" = "true" ] && [ "$PROMPT" = "false" ] && [ -f "$SITE_KEY" ] ; then
rm -f "$SITE_KEY"
fi
if [ -f "$SITE_KEY" ] && [ "$CLOBBER" = "false" ] ; then
echo "The site key file \"$SITE_KEY\""
echo 'exists and will not be overwritten.'
else
cmdargs="--generate-keys --site-keyfile \"$SITE_KEY\""
if [ -n "$TW_SITE_PASS" ] ; then
cmdargs="$cmdargs --site-passphrase \"$TW_SITE_PASS\""
fi
eval "\"$TWADMIN\" $cmdargs"
if [ $? -ne 0 ] ; then
echo "Error: site key generation failed"
exit 1
else chmod 640 "$SITE_KEY"
fi
fi
##-------------------------------------------------------
## Local key file.
##-------------------------------------------------------
# If clobber is true, and prompting is off (unattended operation)
# and the key file already exists, remove it. Otherwise twadmin
# will prompt with an "are you sure?" message.
if [ "$CLOBBER" = "true" ] && [ "$PROMPT" = "false" ] && [ -f "$LOCAL_KEY" ] ; then
rm -f "$LOCAL_KEY"
fi
if [ -f "$LOCAL_KEY" ] && [ "$CLOBBER" = "false" ] ; then
echo "The site key file \"$LOCAL_KEY\""
echo 'exists and will not be overwritten.'
else
cmdargs="--generate-keys --local-keyfile \"$LOCAL_KEY\""
if [ -n "$TW_LOCAL_PASS" ] ; then
cmdargs="$cmdargs --local-passphrase \"$TW_LOCAL_PASS\""
fi
eval "\"$TWADMIN\" $cmdargs"
if [ $? -ne 0 ] ; then
echo "Error: local key generation failed"
exit 1
else chmod 640 "$LOCAL_KEY"
fi
fi
##=======================================================
## Generate tripwire configuration file.
##=======================================================
echo
echo "----------------------------------------------"
echo "Generating Tripwire configuration file..."
cat << END_OF_TEXT > "$TXT_CFG"
ROOT =$TWBIN
POLFILE =$POLICY_FILE
DBFILE =$TWDB/\$(HOSTNAME).twd
REPORTFILE =$TWREPORT/\$(HOSTNAME)-\$(DATE).twr
SITEKEYFILE =$SITE_KEY
LOCALKEYFILE =$LOCAL_KEY
EDITOR =$TWEDITOR
LATEPROMPTING =${TWLATEPROMPTING:-false}
LOOSEDIRECTORYCHECKING =${TWLOOSEDIRCHK:-false}
MAILNOVIOLATIONS =${TWMAILNOVIOLATIONS:-true}
EMAILREPORTLEVEL =${TWEMAILREPORTLEVEL:-3}
REPORTLEVEL =${TWREPORTLEVEL:-3}
MAILMETHOD =${TWMAILMETHOD:-SENDMAIL}
SYSLOGREPORTING =${TWSYSLOG:=true}
END_OF_TEXT
if [ "$TWMAILMETHOD" = "SMTP" ] ; then
cat << SMTP_TEXT >> "$TXT_CFG"
SMTPHOST =${TWSMTPHOST:-mail.domain.com}
SMTPPORT =${TWSMTPPORT:-"25"}
SMTP_TEXT
else
cat << SENDMAIL_TEXT >> "$TXT_CFG"
MAILPROGRAM =$TWMAILPROGRAM
SENDMAIL_TEXT
fi
if [ ! -s "$TXT_CFG" ] ; then
echo "Error: unable to create $TXT_CFG"
exit 1
fi
chmod 640 "$TXT_CFG"
##=======================================================
## Create signed tripwire configuration file.
##=======================================================
echo
echo "----------------------------------------------"
echo "Creating signed configuration file..."
##-------------------------------------------------------
## If noclobber, then backup any existing config file.
##-------------------------------------------------------
if [ "$CLOBBER" = "false" ] && [ -s "$CONFIG_FILE" ] ; then
backup="${CONFIG_FILE}.$$.bak"
echo "Backing up $CONFIG_FILE"
echo " to $backup"
`mv "$CONFIG_FILE" "$backup"`
if [ $? -ne 0 ] ; then
echo "Error: backup of configuration file failed."
exit 1
fi
fi
##-------------------------------------------------------
## Build command line.
##-------------------------------------------------------
cmdargs="--create-cfgfile"
cmdargs="$cmdargs --cfgfile \"$CONFIG_FILE\""
cmdargs="$cmdargs --site-keyfile \"$SITE_KEY\""
if [ -n "$TW_SITE_PASS" ] ; then
cmdargs="$cmdargs --site-passphrase \"$TW_SITE_PASS\""
fi
##-------------------------------------------------------
## Sign the file.
##-------------------------------------------------------
eval "\"$TWADMIN\" $cmdargs \"$TXT_CFG\""
if [ $? -ne 0 ] ; then
echo "Error: signing of configuration file failed."
exit 1
fi
# Set the rights properly
chmod 640 "$CONFIG_FILE"
##-------------------------------------------------------
## We keep the cleartext version around.
##-------------------------------------------------------
cat << END_OF_TEXT
A clear-text version of the Tripwire configuration file
$TXT_CFG
has been preserved for your inspection. It is recommended
that you delete this file manually after you have examined it.
END_OF_TEXT
##=======================================================
## Modify default policy file with file locations
##=======================================================
echo
echo "----------------------------------------------"
echo "Customizing default policy file..."
sed '/@@section GLOBAL/,/@@section FS/ {
s?^\(TWROOT=\).*$?TWDOCS='\""$TWDOCS"\"';?
s?^\(TWBIN=\).*$?\1'\""$TWBIN"\"';?
s?^\(TWPOL=\).*$?\1'\""$TWPOLICY"\"';?
s?^\(TWDB=\).*$?\1'\""$TWDB"\"';?
s?^\(TWSKEY=\).*$?\1'\""$TWSITEKEYDIR"\"';?
s?^\(TWLKEY=\).*$?\1'\""$TWLOCALKEYDIR"\"';?
s?^\(TWREPORT=\).*$?\1'\""$TWREPORT"\"';?
s?^\(HOSTNAME=\).*$?\1'"$HOST_NAME"';?
}' "${TWPOLICY}/${POLICYSRC}" > "${TXT_POL}.tmp"
# copy the tmp file back over the default policy
[ -f "${TXT_POL}" ] && cp "${TXT_POL}" "${TXT_POL}.bak"
mv "${TXT_POL}.tmp" "${TXT_POL}"
rm -f "${TWPOLICY}/${POLICYSRC}"
# reset rights on the policy files to 640
[ -f "${TXT_POL}" ] && chmod 640 "$TXT_POL"
[ -f "${TXT_POL}.bak" ] && chmod 640 "${TXT_POL}.bak"
##=======================================================
## Create signed tripwire policy file.
##=======================================================
echo
echo "----------------------------------------------"
echo "Creating signed policy file..."
##-------------------------------------------------------
## If noclobber, then backup any existing policy file.
##-------------------------------------------------------
if [ "$CLOBBER" = "false" ] && [ -s "$POLICY_FILE" ] ; then
backup="${POLICY_FILE}.$$.bak"
echo "Backing up $POLICY_FILE"
echo " to $backup"
mv "$POLICY_FILE" "$backup"
if [ $? -ne 0 ] ; then
echo "Error: backup of policy file failed."
exit 1
fi
fi
##-------------------------------------------------------
## Build command line.
##-------------------------------------------------------
cmdargs="--create-polfile"
cmdargs="$cmdargs --cfgfile \"$CONFIG_FILE\""
cmdargs="$cmdargs --site-keyfile \"$SITE_KEY\""
if [ -n "$TW_SITE_PASS" ] ; then
cmdargs="$cmdargs --site-passphrase \"$TW_SITE_PASS\""
fi
##-------------------------------------------------------
## Sign the file.
##-------------------------------------------------------
eval "\"$TWADMIN\" $cmdargs \"$TXT_POL\""
if [ $? -ne 0 ] ; then
echo "Error: signing of policy file failed."
exit 1
fi
# Set the proper rights on the newly signed policy file.
chmod 0640 "$POLICY_FILE"
##-------------------------------------------------------
## We keep the cleartext version around.
##-------------------------------------------------------
cat << END_OF_TEXT
A clear-text version of the Tripwire policy file
$TXT_POL
has been preserved for your inspection. This implements
a minimal policy, intended only to test essential
Tripwire functionality. You should edit the policy file
to describe your system, and then use twadmin to generate
a new signed copy of the Tripwire policy.
END_OF_TEXT
##=======================================================
## Clean-up.
##=======================================================
cat << END_OF_TEXT
----------------------------------------------
The installation succeeded.
Please refer to $README_LOC
for release information and to the printed user documentation
for further instructions on using Tripwire 2.4 Open Source.
END_OF_TEXT
cd "$START_DIR"

0
lib/.keepme Normal file
View File

12
man/Makefile.am Normal file
View File

@ -0,0 +1,12 @@
AUTOMAKE_OPTIONS = foreign no-dependencies
SUBDIRS = man4 man5 man8
#man_MANS = \
# ./man4/twconfig.4 \
# ./man4/twpolicy.4 \
# ./man5/twfiles.5 \
# ./man8/siggen.8 \
# ./man8/tripwire.8 \
# ./man8/twadmin.8 \
# ./man8/twintro.8 \
# ./man8/twprint.8

458
man/Makefile.in Normal file
View File

@ -0,0 +1,458 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
depcomp =
am__depfiles_maybe =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CORE_CRYPT_O = @CORE_CRYPT_O@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
YACC = @YACC@
YFLAGS = @YFLAGS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
path_to_sendmail = @path_to_sendmail@
path_to_vi = @path_to_vi@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
AUTOMAKE_OPTIONS = foreign no-dependencies
SUBDIRS = man4 man5 man8
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign man/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| mkdir "$(distdir)/$$subdir" \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="../$(top_distdir)" \
distdir="../$(distdir)/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-recursive ctags ctags-recursive \
distclean distclean-generic distclean-recursive distclean-tags \
distdir dvi dvi-am html html-am info info-am install \
install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
maintainer-clean-recursive mostlyclean mostlyclean-generic \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am uninstall-info-am
#man_MANS = \
# ./man4/twconfig.4 \
# ./man4/twpolicy.4 \
# ./man5/twfiles.5 \
# ./man8/siggen.8 \
# ./man8/tripwire.8 \
# ./man8/twadmin.8 \
# ./man8/twintro.8 \
# ./man8/twprint.8
# 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:

2
man/man4/Makefile.am Normal file
View File

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

360
man/man4/Makefile.in Normal file
View File

@ -0,0 +1,360 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = man/man4
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
depcomp =
am__depfiles_maybe =
SOURCES =
DIST_SOURCES =
man4dir = $(mandir)/man4
am__installdirs = "$(DESTDIR)$(man4dir)"
NROFF = nroff
MANS = $(man_MANS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CORE_CRYPT_O = @CORE_CRYPT_O@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
YACC = @YACC@
YFLAGS = @YFLAGS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
path_to_sendmail = @path_to_sendmail@
path_to_vi = @path_to_vi@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
AUTOMAKE_OPTIONS = foreign no-dependencies
man_MANS = twconfig.4 twpolicy.4
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/man4/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign man/man4/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
uninstall-info-am:
install-man4: $(man4_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man4dir)" || $(mkdir_p) "$(DESTDIR)$(man4dir)"
@list='$(man4_MANS) $(dist_man4_MANS) $(nodist_man4_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.4*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
4*) ;; \
*) ext='4' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man4dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man4dir)/$$inst"; \
done
uninstall-man4:
@$(NORMAL_UNINSTALL)
@list='$(man4_MANS) $(dist_man4_MANS) $(nodist_man4_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.4*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
4*) ;; \
*) ext='4' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man4dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man4dir)/$$inst"; \
done
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(MANS)
installdirs:
for dir in "$(DESTDIR)$(man4dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-man
install-exec-am:
install-info: install-info-am
install-man: install-man4
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-man
uninstall-man: uninstall-man4
.PHONY: all all-am check check-am clean clean-generic distclean \
distclean-generic distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-man4 install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
uninstall-am uninstall-info-am uninstall-man uninstall-man4
# 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:

300
man/man4/twconfig.4 Normal file
View File

@ -0,0 +1,300 @@
.\" Macros added by addw@phcomp.co.uk for those systems where the an
.\" troff macro package doesn't know about .Ps & .Pe.
.\" Note it is assumed that CW is a constant width font.
.\" Ps - Start display text
.de Ps
.nf
.in +0.5i
.ft CW
..
.\" Pe - end of display text
.de Pe
.fi
.in -0.5i
.ft 1
..
.\"
.\" Macros added by TSS.
.\" Nf - no fill, use constant width font
.\" Fi - fill, restore previous font
.\" Register Ni holds indent to use for Nf sections in points.
.nr Ni 30
.de Nf
.nr OF \\n(.f
.nr OS \\n(.s
.ps \\n(.s-1
.ft CW
.in +\\n(Nip
.nf
..
.de Fi
.fi
.ft \\n(OF
.ps \\n(OS
.in -\\n(Nip
..
.nh
.ad l
.TH TWCONFIG 4 "1 July 2000"
.SH NAME
twconfig \- \fITripwire\fP configuration file reference
.SH DESCRIPTION
.PP
The configuration file stores system-specific information, including the
location of \fITripwire\fP data files, and the settings used to send
email notification. The configuration file settings are
generated during the installation process, but can be changed by the system
administrator at any time. The configuration file is
signed with the site key, and the site passphrase is
required to edit the file.
.PP
During installation, a signed \fITripwire\fP configuration file \fItw.cfg\fP will be created in the \fI/etc/tripwire\fP directory, and a plain text copy of this configuration file \fItwcfg.txt\fP will be created in the same directory.
.PP
The configuration file is modified using the
.B twadmin\ \(hy\(hycreate\(hycfgfile
command. With this command, the user can designate
an existing plain text file as the current configuration file.
Using the current site key and passphrase, the new configuration file
is cryptographically signed and saved with this command.
.\"
.SS Components of the Configuration File
The \fITripwire\fP configuration file is structured as a list of
keyword-value pairs, and may also contain comments and variable
definitions. Any lines with "#" in the first column are treated as
comments.
.PP
The general syntax for variable definition is:
.br
.in +\n(Nip
.nf
\fIkeyword\fP = \fIvalue\fP
.fi
.in
For example:
.Nf
ROOT = /usr/tripwire
EDITOR = /usr/local/bin/jove
.Fi
.PP
Variable substitution on the right hand side is permitted using the syntax:
.br
.in +\n(Nip
.nf
$(\fI varname \fP)
.fi
.in
For example:
.Nf
DBFILE = $(ROOT)/db/$(HOSTNAME).twd
.Fi
.PP
Variable names are case-sensitive, and may contain all alphanumeric
characters, underscores, the characters "+\(hy@:", and the period.
Two variables are predefined in the configuration file, and may
not be changed. \f(CWHOSTNAME\fP is the
unqualified hostname that \fITripwire\fP is running on, and
\fR\f(CWDATE\fP
is a string representation of the date and time.
.SS Required Variables
The following variables must be set in order for \fITripwire\fP to
operate. The values listed below are assigned during installation.
.PP
.if n .nr Ti \n(.i
.Nf
.if n .in 0
POLFILE Default = /etc/tripwire/tw.pol
DBFILE Default = /var/lib/tripwire/$(HOSTNAME).twd
REPORTFILE Default = /var/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr
SITEKEYFILE Default = /etc/tripwire/site.key
LOCALKEYFILE Default = /etc/tripwire/$(HOSTNAME)-local.key
.Fi
.if n .in +\n(Tiu
.SS Other Variables
The following variables are not required to run \fITripwire\fP, but
some of the program's functionality will be lost without them. The
values assigned during installation are listed.
.IP \f(CWEDITOR\fP
Specifies an editor to be used in interactive modes. If \fIEDITOR\fP
is not defined, and no editor is specified on the command line, using
interactive modes will cause an error.
.br
Initial value: \fI/bin/vi\fP
.IP \f(CWTEMPDIRECTORY\fP
This variable can be set to the location to which tripwire should write
its temporary files. By default it is /tmp, which due to the default
permissions can be very insecure. It is recommended that you use this
configuration variable to provide tripwire with a secure place to write
temporary files. The directory used should have its permissions set such
that only the owning process can read/write to it, i.e. "chmod 700".
.br
Initial value: \fI/tmp\fP
.IP \f(CWGLOBALEMAIL\fP
This variable is set to a list of email addresses separated by either
a comma ",", or semi-colon ";". If a report would have normally been
sent out, it will also be send to this list of recipients.
.br
Initial value: \fInone\fP
.IP \f(CWLATEPROMPTING\fP
Prompt for passphrase as late as possible to minimize the amount of
time that the passphrase is stored in memory. If the value is
\fItrue\fP (case-sensitive), then late prompting is turned on. With
any other value, or if the variable is removed from the configuration
file, late prompting is turned off.
.br
Initial value: \fIfalse\fP
.IP \f(CWLOOSEDIRECTORYCHECKING\fP
When a file is added or removed from a directory, \fITripwire\fP
reports both the changes to the file itself, and the modification to
the directory (size, num links, etc.). This can create redundant
entries in \fITripwire\fP reports. With loose directory checking,
Tripwire will not check directories for any properties that would
change when a file was added or deleted. This includes: size, number
of links, access time, change time, modification time, number of blocks,
growing file, and all hashes.
.IP \ \ \
If the value for this variable is \fItrue\fP (case-sensitive),
then loose directory checking is turned on, and these
properties will be ignored for all directories. With any other value,
or if the variable is removed from the configuration file, loose
directory checking is turned off. Turning loose directory checking
on is equivalent to appending the following propertymask to
the rules for all directory inodes:
.ft CW
.ps \n(.s-1
\(hysnacmblCMSH
.ps \n(.s+1
.ft R
.br
Initial value: \fIfalse\fP
.IP \f(CWSYSLOGREPORTING\fP
If this variable is set to \fItrue\fR, messages are sent
to the syslog for four events: database initialization,
integrity check completions, database updates, and policy updates.
The syslog messages are sent from the "user" facility at
the "notice" level. For more information, see the
.BR syslogd (1)
man page and the
.I syslog.conf
file. The following illustrates the information logged
in the syslog for each of the four events:
.if n .nr Ti \n(.i
.Nf
.if n .in 0
Jun 18 14:09:42 lighthouse tripwire[9444]: Database initialized:
/var/lib/tripwire/test.twd
Jun 18 14:10:57 lighthouse tripwire[9671]: Integrity Check Complete:
TWReport lighthouse 20000618141057 V:2 S:90 A:1 R:0 C:1
Jun 18 14:11:19 lighthouse tripwire[9672]: Database Update Complete:
/var/lib/tripwire/test.twd
Jun 18 14:18:26 lighthouse tripwire[9683]: Policy Update Complete:
/var/lib/tripwire/test.twd
.Fi
.if n .in +\n(Tiu
The letters in the Integrity Checking log correspond to # of
violations, maximum severity level, and # of files added,
deleted, and changed,
respectively. With any value other than \fItrue\fR, or if this
variable is removed from the configuration file, syslog reporting will
be turned off.
.br
Initial value: \fItrue\fP
.IP \f(CWREPORTLEVEL\fP
Specifies the default level of report produced by the \fBtwprint
\(hy\(hyprint\(hyreport\fP mode. Valid values for this option are 0 to
4. The report
level specified by this option can be overridden with the (\fB\(hyt\fP\ or\ \fB\(hy\(hyreport\(hylevel\fP) option on the command line. If
this variable is not included in the configuration file, the default
report level is 3. Note that only reports printed using the
\fBtwprint\ \(hy\(hyprint\(hyreport\fP mode are affected by this
parameter; reports displayed by other modes and other commands
are not affected.
.br
Initial value: \fI3\fP
.SS Email Notification Variables
.IP \f(CWMAILMETHOD
Specifies the protocol to be used by \fITripwire\fR for email
notification. The only acceptable values for this field are
\fR\f(CWSMTP\fP or \f(CWSENDMAIL\fP. Any other value will
produce an error message.
.br
Initial value: \fISENDMAIL\fP
.IP \f(CWSMTPHOST
Specifies the domain name or IP address of the SMTP server used for
email notification. Ignored unless \f(CWMAILMETHOD\fP is set to
\f(CWSMTP\fP.
.br
Initial value: \fImail.domain.com\fP
.IP \f(CWSMTPPORT
Specifies the port number used with SMTP. Ignored unless
\f(CWMAILMETHOD\fP is set to \f(CWSMTP\fP.
.br
Initial value: \fI25\fP
.IP \f(CWMAILPROGRAM\fP
Specifies the program used for email reporting of rule violations if
\f(CWMAILMETHOD\fP is set to \f(CWSENDMAIL\fP. The program must take
an RFC822 style mail header, and recipients will be listed in the "To:"
field of the mail header. Some mail programs interpret a line
consisting of only a single period character to mean
end\(hyof\(hyinput, and all text after that is ignored. Since there is
a small possibility that a
.I Tripwire
report would contain such a line, the mail program specified must be
able to ignore lines that consist of a single period (the \fB-oi\fP
option to sendmail produces this behavior).
.br
Initial value: \fI/usr/lib/sendmail -oi -t\fP
.IP \f(CWEMAILREPORTLEVEL\fP
Specifies the default level of report produced by the \fBtripwire
\(hy\(hycheck\fP mode email report. Valid values for this option are 0
to 4. The
report level specified by this option can be overridden with the
(\fB\(hyt\fP\ or\ \fB\(hy\(hyemail\(hyreport\(hylevel\fP) option on the
command\(hyline. If this variable is not included in the configuration
file, the default report level is 3.
.br
Initial value: \fI3\fP
.IP \f(CWMAILNOVIOLATIONS\fP
This option controls the way that \fITripwire\fR sends email
notification if no rule violations are found during an integrity check.
If \fR\f(CWMAILNOVIOLATIONS\fP is set to \fIfalse\fP and no violations
are found, \fITripwire\fR will not send a report. With any other value,
or if the variable is removed from the configuration file,
\fITripwire\fR will send an email message stating that no violations
were found.
.IP \ \ \
Mailing reports of no violations allows an administrator to distinguish
between unattended integrity checks that are failing to run and
integrity checks that are running but are not finding any violations.
However, mailing no violations reports will increase the amount of data
that must be processed.
.br
Initial value: \fItrue\fR
.SH VERSION INFORMATION
This man page describes
.IR "Tripwire 2.4" "."
.SH AUTHORS
Tripwire, Inc.
.SH COPYING PERMISSIONS
Permission is granted to make and distribute verbatim copies of this man page provided the copyright notice and this permission notice are preserved on all copies.
.PP
Permission is granted to copy and distribute modified versions of this man page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
.PP
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
.PP
Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
.SH SEE ALSO
.BR twintro (8),
.BR tripwire (8),
.BR twadmin (8),
.BR twprint (8),
.BR siggen (8),
.BR twpolicy (4),
.BR twfiles (5),
.BR sendmail (1),
.BR vi (1),
.BR syslogd (1)

548
man/man4/twpolicy.4 Normal file
View File

@ -0,0 +1,548 @@
.\" Macros added by addw@phcomp.co.uk for those systems where the an
.\" troff macro package doesn't know about .Ps & .Pe.
.\" Note it is assumed that CW is a constant width font.
.\" Ps - Start display text
.de Ps
.nf
.in +0.5i
.ft CW
..
.\" Pe - end of display text
.de Pe
.fi
.in -0.5i
.ft 1
..
.\"
.\" Macros added by TSS.
.\" Nf - no fill, use constant width font
.\" Fi - fill, restore previous font
.\" Register Ni holds indent to use for Nf sections in points.
.nr Ni 36
.de Nf
.nr OF \\n(.f
.nr OS \\n(.s
.ps \\n(.s-1
.ft CW
.in +\\n(Nip
.nf
..
.de Fi
.fi
.ft \\n(OF
.ps \\n(OS
.in -\\n(Nip
..
.\"
.nh
.ad l
.TH TWPOLICY 4 "1 July 2000"
.SH NAME
twpolicy \- \fITripwire\fP policy file reference
.SH DESCRIPTION
.PP
The policy file describes system objects to be monitored by
\fITripwire\fP, and specifies what properties for each object should be
collected and stored in the database file. Each object in the policy
file is associated with a property mask, which describes what changes
to the file or directory \fITripwire\fP should monitor, and which ones
can safely be ignored. By customizing the various aspects of the
policy file, the system administrator can very closely control how
\fITripwire\fP checks the integrity of any system.
.PP
During installation, an encoded and signed policy file (\fItw.pol\fP)
will be created in the \fI/etc/tripwire\fP directory,
and a plain text copy of this policy file (\fItwpol.txt\fP) will be
generated in the same directory. An additional text file
(\fIpolicyguide.txt\fP) illustrates all of the features of the policy
language. Both of the text files are heavily commented and can be used
as a reference during policy file creation.
.PP
A new policy file is first created using the
\fBtwadmin\ \(hy\(hycreate\(hypolfile\fP
command. With this command, the
user can designate an existing plain text file as the current policy
file. Using the current site key and passphrase, the new configuration
file is encoded, signed and saved.
.PP
Once the initial policy file has been generated, any changes should be
made with the \fBtripwire\ \(hy\(hyupdate\(hypolicy\fP command, rather
than by simply overwriting the policy file with the
\fBtwadmin\ \(hy\(hycreate\(hypolfile\fP command. This is an important
.ie n distinction\(hy\(hywhen
.el distinction\(emwhen
a new policy file is created, the \fITripwire\fP
database must be re-initialized. If an intruder has modified files
since the last integrity check, these changes will not be detected, and
will be included as part of the new "baseline" database.
.\"
.SH COMPONENTS OF THE POLICY FILE
The basic components of policy files are comments, rules, directives,
and variables. Each of these components is described in greater detail
below.
.SS Comments
In a policy file, any text following a '#', up to the next line break,
is considered a comment. Example:
.PP
.Nf
# This is a comment.
/bin -> $(ReadOnly); # A comment can go here, too.
.Fi
.\"
.SS Rules
Policy rules determine whether and to what extent \fITripwire\fP will
check particular files and directories. There are two kinds of policy
rules recognized by \fITripwire\fP:
.PP
1) Normal rules define which properties of a particular file or
directory tree \fITripwire\fP scans.
.br
2) Stop points tell \fITripwire\fP not to scan a particular file or
directory.
.SS Normal Rules
The format for a normal rule is:
.br
.in +\n(Nip
\fIobject_name\fP -> \fIproperty_mask\fP;
.in
.PP
where the \fIobject_name\fP is the fully qualified pathname for a
directory or file, and \fIproperty_mask\fP
specifies what properties of an object to examine or ignore.
The '\(hy>' token separates the pathname and the property mask.
Whitespace must separate the object name and '\(hy>' token.
A semicolon must terminate the rule. If the
pathname specified is a directory, the directory and all of its
descendants will be scanned with the indicated property mask. If the
pathname refers to an individual file, only that file will be scanned
with the specified property mask. Examples:
.PP
.Nf
# Defines Tripwire behavior for entire /bin directory tree.
/bin -> $(ReadOnly);
# Defines Tripwire behavior for a single file. In this case,
# Tripwire watches for all properties of hostname.hme0.
/etc/hostname.hme0 -> $(IgnoreNone) -ar;
# Scan the entire /etc directory tree using mask1, except the
# file /etc/passwd, which should be scanned using mask2.
/etc -> $(mask1);
/etc/passwd -> $(mask2);
.Fi
.PP
Only one rule may be associated with any given object. If any object
has more than one rule in a policy file, \fITripwire\fP will print an
error message and exit without scanning any files. For example:
.PP
.Nf
# This is an example of an illegal construct.
/usr/bin -> $(mask3);
/usr/bin -> $(mask4);
.Fi
.PP
.\"
.SS Object Names
In this document, policy file objects are fully qualified pathnames of
files and directories. Environment variables are not allowed for
security reasons. Examples:
.PP
.Nf
/etc # valid object name.
/etc/passwd # valid object name.
$HOME # not valid.
.Fi
.\"
.SS Property Masks
Property masks designate which \fITripwire\fP properties of a given
object should be examined. A property mask consists of a series of
single-character symbols, each of which may be preceded by an optional
plus or minus sign. Each character symbol stands for a particular
\fITripwire\fP property to be examined during integrity checking. If
the character is preceded by a plus, checking is done for that
property; if preceded by a minus, checking is not done for that
property. For example:
.PP
.Nf
\+p # compare permissions.
\-p # ignore permissions.
.Fi
.PP
Each rule in the policy file must have a property mask. Examples:
.PP
.Nf
/etc -> $(IgnoreAll); #valid property mask.
/etc -> +p-p; #valid property mask.
/etc -> ; #invalid property mask.
.Fi
.PP
Characters in a property mask without a preceding plus or minus sign
are assumed to be plus. If a property is not specified in the property
mask, it is ignored, which is equivalent to turning it off with
the minus sign. Examples:
.PP
.Nf
# Examine permissions and link count.
# All three of the following are equivalent.
+p+n
pn
pn-g
.Fi
.PP
Characters used in property masks, with descriptions:
.PP
.Nf
\- Ignore the following properties
\+ Record and check the following properties
a Access timestamp
b Number of blocks allocated
c Inode timestamp (create/modify)
d ID of device on which inode resides
g File owner's group ID
i Inode number
l File is increasing in size (a "growing file")
m Modification timestamp
n Number of links (inode reference count)
p Permissions and file mode bits
.if t r ID of device pointed to by inode (valid only for device objects)
.if n r ID of device pointed to by inode
.if n \ (valid only for device objects)
s File size
t File type
u File owner's user ID
C CRC-32 hash value
H Haval hash value
M MD5 hash value
S SHA hash value
.Fi
.\"
.SS Stop Points
Stop points are used to specify specific files or directories that
\fITripwire\fP should not scan. The syntax for stop points is:
.br
.in +\n(Nip
.nf
\&! \fIobject_name\fP ;
.fi
.in
For example:
.Nf
!/etc/init.d;
# The directory /etc/init.d will not be scanned.
/etc -> $(ReadOnly);
!/etc/rc.d;
!/etc/mnttab;
# Scan all of /etc, but do not scan two particular
# files in the /etc hierarchy.
.Fi
.\"
.SS Rule Attributes
Rule attributes work with normal rules to modify their behavior or
provide additional information. Multiple attributes can be assigned to
each rule. Rule attributes are not case-sensitive.
Rule attributes may be applied to a single rule
using the following syntax:
.br
.in +\n(Nip
\fIobject_name\fP -> \fIproperty_mask\fP (\fIrule attribute\fP = \fIvalue\fP);
.in
For example:
.Nf
/usr/lib -> $(ReadOnly) (emailto = admin@foo.com, severity = 80);
#This rule will notify the admin if any violations of the
#rule occur and designate the severity as 80.
.Fi
.PP
Rule attributes can also be specified for a group of rules,
using the format:
.br
.in +\n(Nip
(\fIattribute list\fP)
.br
{
.in +\n(Nip
\fIrule list\fP;
.in -\n(Nip
}
.in -\n(Nip
For example:
.Nf
(emailto = admin@foo.com, severity = 80)
{
/usr/lib -> $(ReadOnly);
}
.Fi
is equivalent to the attribute example above.
.PP
The following four rule attributes are supported by \fITripwire\fP:
./"
.IP \f(CWrulename\fP 15
The \f(CWrulename\fP attribute is used to associate a rule or set
of rules with a specific name. In a report file, this name will be
associated with violations to the specified rule. This feature is
useful if you want to track certain objects within a large
\fITripwire\fP database. For instance, if you associate the rule name
"watchme" with important files, you can sort through the \fITripwire\fP
report using "watchme" as a sorting key.
.br
Example:
.Nf
/etc -> +ug (rulename=watchme);
.Fi
./"
.IP \f(CWemailto\fP 15
The \f(CWemailto\fP attribute associates one or more email addresses
with a rule or group of rules. When an integrity check is run with the
.B \(hy\(hyemail\(hyreport
option and a rule is violated, a report of that violation will be sent
to the specified email address(es), using the report format specified
by the
.\" Do not remove the \fR at the start of the following line.
.\" Formatting weirdness results otherwise on AIX.
\fR\f(CWEMAILREPORTLEVEL\fP variable in the configuration file.
.br
Example:
.Nf
/etc -> +ug (emailto=admin@domain.com);
.Fi
.IP
To specify multiple email addresses, include them as a quoted,
semicolon-delimited list.
.Nf
.if n .in -\n(Nip
/etc -> +ug (emailto="admin@foo.com;admin2@foo.com");
.if n .in +\n(Nip
.Fi
./"
.IP \f(CWseverity\fP 15
The \f(CWseverity\fP attribute associates a numeric severity level with
a rule. When \fITripwire\fP is run in Integrity Checking mode, it is
possible to specify that only rules exceeding a certain severity level
are used. The default severity level is 0, and values can range from 0
to 1,000,000.
.br
Example:
.Nf
/etc -> +ug (severity=50);
.Fi
./"
.IP \f(CWrecurse\fP 15
The \f(CWrecurse\fP attribute specifies how a rule will scan
directories. Valid values for \f(CWrecurse\fP are \fItrue\fR,
\fIfalse\fR, or a number from -1 to 1,000,000. If \fR\f(CWrecurse\fP is set
to \fItrue\fR (or\ \(hy1), tripwire will recursively scan the entire
contents of the directory (both files and subdirectories). When
\fR\f(CWrecurse\fP is set to \fIfalse\fR (or\ 0), and the rule refers to a
directory, \fITripwire\fP will scan the inode of the directory but none
of the files or subdirectories contained therein. For positive
\fR\f(CWrecurse\fP value \fIn\fR, the rule will monitor all objects up to
\fIn\fR levels below the start point. Stop points within the recursed
directory still apply, and will prevent the specified file or directory
from being scanned.
.IP
When a rule refers to a file, specifying the \f(CWrecurse\fP attribute
has no
.ie n effect\(hy\(hyfiles
.el effect\(emfiles
will be scanned no matter what value is given for
\f(CWrecurse\fP. The default value for \f(CWrecurse\fP is \fItrue\fR.
.br
Example:
.Nf
/etc -> +ug (recurse=2);
.Fi
./"
.SS Directives
\fITripwire\fP supports a small number of directives that allow
conditional interpretation of the policy file and certain diagnostic
and debugging operations. The primary purpose of directives is to
support sharing of a policy file among multiple machines. Directives
use the following syntax:
.br
.in +\n(Nip
.nf
@@ \fIdirective_name\fP [\fIarguments\fP]
.fi
.in
.PP
Where the directive name is one of the directives listed below:
.PP
.Nf
@@section # Designates a section of the policy file.
@@ifhost # Allow conditional interpretation
@@else # of the policy file.
@@endif
@@print # Print a message to standard output.
@@error # Print a message to standard output and then exit.
@@end # Marks the logical end-of-file.
.Fi
.PP
The @@section directive is used to designate sections of the policy
file that are OS-specific. With \fITripwire 2.4\fP, valid
arguments for the @@section directive are
.\" Do not remove the \fR at the start of the following line.
.\" Formatting weirdness results otherwise on AIX.
\fR\f(CWFS\fP
and \f(CWGLOBAL\fP. If no @@section
directive is specified, \f(CWFS\fP will be assumed.
If the argument to the @@section directive is either
\f(CWNTFS\fP or \f(CWNTREG\fP (which have meaning only on
Windows NT systems),
\fITripwire\fP will skip all policy file text down to the
next valid @@section directive. Any other argument will
cause an error.
.PP
The @@ifhost, @@else, and @@endif directives are used to allow
conditional interpretation of the policy file. With the @@ifhost
directive, multiple hostnames can be expressed as arguments, but they
must be separated by an '||', interpreted as the logical 'OR'. This example illustrates how one might employ directives to use one policy file with multiple hosts.
.PP
.Nf
@@ifhost spock || kirk
/bin -> $(ReadOnly);
@@endif
@@ifhost chekov || uhura
/usr/bin -> +pinug;
@@else
/usr/bin -> +pinugsmC;
@@endif
.Fi
.PP
The @@print and @@error directives are intended for debugging and remote
diagnostics. The syntax for these commands is:
.br
.in +\n(Nip
.nf
@@print "\fIstring\fP"
@@error "\fIstring\fP"
.fi
.in
.PP
The @@print directive prints \fIstring\fP to \fIstdout\fP, while the
@@error directive prints \fIstring\fP to \fIstdout\fP and causes the
calling program to exit with a non-zero status.
.PP
The @@end directive marks the end of the policy file. Any text
appearing after this directive will be ignored by \fITripwire\fP.
.\"
.SS Variables
For user convenience, \fITripwire\fP's policy file supports variables
for string substitution. Variables can be defined anywhere between
rules. The syntax for variable definition is:
.br
.in +\n(Nip
.nf
\fIvariable\fP = \fIvalue\fP;
.fi
.in
.PP
Variable substitution is legal anywhere that a string could appear.
The syntax for variable substitution is:
.br
.in +\n(Nip
.nf
$( \fIvariable\fP )
.fi
.in
.PP
Examples of variable definition and variable substitution on the left,
right, and both sides of rules. Note that variable names are
case sensitive.
.PP
.Nf
param1 = +SMCH; # Set variable param1.
dir1 = /etc/inet; # Set variable dir1.
DIR1 = /etc/init.d; # Variables are case sensitive.
$(dir1) -> +tbamc; # Left hand substitution.
/etc/inet -> $(param1); # Right hand substitution.
$(DIR1) -> $(param1); # Double substitution.
.Fi
.PP
A number of variables are predefined by \fITripwire\fP and may not be
changed. These variables represent different ways that files can
change, and can be used on the right side of rules to design a policy
file quickly.
.IP ReadOnly 15
ReadOnly is good for files that are widely available but are intended
to be read-only.
.br
Value:
.ft CW
.ps \n(.s-1
\+pinugtsdbmCM\(hyrlacSH
.ps \n(.s+1
.ft
.IP Dynamic 15
Dynamic is good for monitoring user directories and files that tend to
be dynamic in behavior.
.br
Value:
.ft CW
.ps \n(.s-1
+pinugtd\(hysrlbamcCMSH
.ps \n(.s+1
.ft
.IP Growing 15
The Growing variable is intended for files that should only get larger.
.br
Value:
.ft CW
.ps \n(.s-1
\+pinugtdl\(hysrbamcCMSH
.ps \n(.s+1
.ft
.IP Device 15
Device is good for devices or other files that \fITripwire\fP should not
attempt to open.
.br
Value:
.ft CW
.ps \n(.s-1
\+pugsdr\(hyintlbamcCMSH
.ps \n(.s+1
.ft R
.IP IgnoreAll 15
IgnoreAll tracks a file's presence or absence, but doesn't check any
other properties.
.br
Value:
.ft CW
.ps \n(.s-1
\(hypinugtsdrlbamcCMSH
.ps \n(.s+1
.ft
.IP IgnoreNone 15
IgnoreNone turns on all properties and provides a convenient starting point for defining your own property masks. (For\ example,\ \f(CWmymask\ =\ $(IgnoreNone)\ -ar;\fP)
.br
Value:
.ft CW
.ps \n(.s-1
\+pinugtsdrbamcCMSH\(hyl
.ps \n(.s+1
.ft
.SH VERSION INFORMATION
This man page describes
.IR "Tripwire 2.4" "."
.SH AUTHORS
Tripwire, Inc.
.SH COPYING PERMISSIONS
Permission is granted to make and distribute verbatim copies of this man page provided the copyright notice and this permission notice are preserved on all copies.
.PP
Permission is granted to copy and distribute modified versions of this man page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
.PP
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
.PP
Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
.SH SEE ALSO
.BR twintro (8),
.BR tripwire (8),
.BR twadmin (8),
.BR twprint (8),
.BR siggen (8),
.BR twconfig (4),
.BR twfiles (5)

2
man/man5/Makefile.am Normal file
View File

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

360
man/man5/Makefile.in Normal file
View File

@ -0,0 +1,360 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = man/man5
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
depcomp =
am__depfiles_maybe =
SOURCES =
DIST_SOURCES =
man5dir = $(mandir)/man5
am__installdirs = "$(DESTDIR)$(man5dir)"
NROFF = nroff
MANS = $(man_MANS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CORE_CRYPT_O = @CORE_CRYPT_O@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
YACC = @YACC@
YFLAGS = @YFLAGS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
path_to_sendmail = @path_to_sendmail@
path_to_vi = @path_to_vi@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
AUTOMAKE_OPTIONS = foreign no-dependencies
man_MANS = twfiles.5
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/man5/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign man/man5/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
uninstall-info-am:
install-man5: $(man5_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man5dir)" || $(mkdir_p) "$(DESTDIR)$(man5dir)"
@list='$(man5_MANS) $(dist_man5_MANS) $(nodist_man5_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.5*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
5*) ;; \
*) ext='5' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man5dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man5dir)/$$inst"; \
done
uninstall-man5:
@$(NORMAL_UNINSTALL)
@list='$(man5_MANS) $(dist_man5_MANS) $(nodist_man5_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.5*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
5*) ;; \
*) ext='5' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man5dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man5dir)/$$inst"; \
done
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(MANS)
installdirs:
for dir in "$(DESTDIR)$(man5dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-man
install-exec-am:
install-info: install-info-am
install-man: install-man5
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-man
uninstall-man: uninstall-man5
.PHONY: all all-am check check-am clean clean-generic distclean \
distclean-generic distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-man5 install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
uninstall-am uninstall-info-am uninstall-man uninstall-man5
# 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:

123
man/man5/twfiles.5 Normal file
View File

@ -0,0 +1,123 @@
.\" Macros added by addw@phcomp.co.uk for those systems where the an
.\" troff macro package doesn't know about .Ps & .Pe.
.\" Note it is assumed that CW is a constant width font.
.\" Ps - Start display text
.de Ps
.nf
.in +0.5i
.ft CW
..
.\" Pe - end of display text
.de Pe
.fi
.in -0.5i
.ft 1
..
.\"
.\" Macro added by TSS.
.\" Ms - display subsection on two lines in nroff, one line in troff.
.de Ms
.ie n \{ .SS \\$1
\\$2
.br \}
.el .SS \\$1 (\\$2)
..
.\"
.nh
.ad l
.TH TWFILES 5 "1 July 2000"
.SH NAME
twfiles \- overview of files used by \fITripwire\fR and file backup process
.\"
.SH DESCRIPTION
.\"
.Ms "Configuration File" "\fPdefault:\fP \fI/etc/tripwire/tw.cfg\fP"
The configuration file stores system-specific information, such as the
location of \fITripwire\fR data files. The configuration settings are
generated during the installation process, but can be changed by the system administrator at any time. See the
\fBtwconfig\fR(4) man page for a more complete discussion.
.\"
.Ms "Policy File" "\fPdefault:\fP \fI/etc/tripwire/tw.pol\fP"
The policy file consists of a series of rules specifying the system
objects that \fITripwire\fR should monitor, and the data for each
object that should be collected and stored in the database file.
Should unexpected changes occur, the policy file can describe the
person to be notified and the severity of the violation. See the
\fIpolicyguide.txt\fR file in the policy directory and the
\fBtwpolicy\fR(4) man page for a more complete discussion.
.\"
.Ms "Database File" "\fPdefault:\fP \fI/var/lib/$(HOSTNAME).twd\fP"
The database file serves as the
baseline for integrity checking. After installation, \fITripwire\fR
creates the initial database file, a "snapshot" of the filesystem in a
known secure state. Later, when an integrity check is run,
\fITripwire\fR compares each system object described in the policy file
against its corresponding entry in the database. A report is created,
and if an object has changed outside of constraints defined in the
policy file, a violation is reported. See the \fBtripwire\fR(8) and
\fBtwprint\fR(8) man pages for more information on creating and
maintaining database files.
.\"
.Ms "Report Files" "\fPdefault:\fP \fI/var/lib/tripwire/report/$(HOSTNAME)\(hy$(DATE).twr\fP"
Once the above three files have been created, \fITripwire\fR can run an
integrity check and search for any differences between the current
system and the data stored in the "baseline" \fITripwire\fR database.
This information is archived into report files, a collection of rule
violations discovered during an integrity check.
With the appropriate settings, a report can also be emailed to one
or more recipients. See the
\fBtripwire\fR(8) and \fBtwprint\fR(8) man pages for information on
creating and printing report files.
.\"
.Ms "Key Files" "\fPdefaults:\fP \fI/etc/tripwire/site.key\fP \fPand\fP \fI/etc/tripwire/$(HOSTNAME)\(hylocal.key\fP"
It is critical that \fITripwire\fR files be protected from unauthorized
.ie n access\(hy\(hyan
.el access\(eman
attacker who is able to modify these files can subvert \fITripwire\fR
operation. For this reason, all of the above files are
signed using public key cryptography to prevent unauthorized
modification. Two separate sets of keys protect critical \fITripwire\fR data files. One or both of these key sets is necessary for performing
almost every \fITripwire\fR task.
.PP
The site key is used to protect files that could be used across several
systems. This includes the policy and configuration files. The local
key is used to protect files specific to the local machine, such as the
\fITripwire\fR database. The local key may also be used for signing
integrity check reports. See the \fBtwadmin\fR(8) man page for more
information on keys.
.\"
.br
.br
.SS File Backup
To prevent the accidental deletion of important data, \fITripwire\fR
automatically creates backup files whenever any \fITripwire\fR file is
overwritten. The existing file will be renamed with a \fI.bak\fR
extension, and the new version of the file will take its place. Only
one backup copy for each filename can exist at any time. If a backup
copy of a file already exists, the older backup file will be deleted
and replaced with the newer one.
.PP
File backup is an integral part of \fITripwire\fR, and cannot be
removed or changed.
.SH VERSION INFORMATION
This man page describes
.IR "Tripwire 2.4" "."
.SH AUTHORS
Tripwire, Inc.
.\"
.SH COPYING PERMISSIONS
Permission is granted to make and distribute verbatim copies of this man page provided the copyright notice and this permission notice are preserved on all copies.
.PP
Permission is granted to copy and distribute modified versions of this man page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
.PP
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
.PP
Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
.SH SEE ALSO
.BR twintro (8),
.BR tripwire (8),
.BR twadmin (8),
.BR twprint (8),
.BR siggen (8),
.BR twconfig (4),
.BR twpolicy (4)

2
man/man8/Makefile.am Normal file
View File

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

360
man/man8/Makefile.in Normal file
View File

@ -0,0 +1,360 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_triplet = @host@
subdir = man/man8
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
depcomp =
am__depfiles_maybe =
SOURCES =
DIST_SOURCES =
man8dir = $(mandir)/man8
am__installdirs = "$(DESTDIR)$(man8dir)"
NROFF = nroff
MANS = $(man_MANS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CORE_CRYPT_O = @CORE_CRYPT_O@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
YACC = @YACC@
YFLAGS = @YFLAGS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
path_to_sendmail = @path_to_sendmail@
path_to_vi = @path_to_vi@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
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
all: all-am
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign man/man8/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign man/man8/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
uninstall-info-am:
install-man8: $(man8_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man8dir)" || $(mkdir_p) "$(DESTDIR)$(man8dir)"
@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.8*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
8*) ;; \
*) ext='8' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst"; \
done
uninstall-man8:
@$(NORMAL_UNINSTALL)
@list='$(man8_MANS) $(dist_man8_MANS) $(nodist_man8_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.8*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
8*) ;; \
*) ext='8' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man8dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man8dir)/$$inst"; \
done
tags: TAGS
TAGS:
ctags: CTAGS
CTAGS:
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(MANS)
installdirs:
for dir in "$(DESTDIR)$(man8dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-generic
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-man
install-exec-am:
install-info: install-info-am
install-man: install-man8
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am uninstall-man
uninstall-man: uninstall-man8
.PHONY: all all-am check check-am clean clean-generic distclean \
distclean-generic distdir dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-man8 install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \
uninstall-am uninstall-info-am uninstall-man uninstall-man8
# 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:

81
man/man8/siggen.8 Normal file
View File

@ -0,0 +1,81 @@
'\" t
.\" 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"
.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
.SH DESCRIPTION
.PP
\fBsiggen\fP is a utility that displays the hash function values
for the specified files.
.SH OPTIONS
.TP
.BI \(hyt ", " --terse
Terse mode.
Prints requested hashes for a given file on one line, delimited
by spaces, with no extraneous information.
.TP
.BI \(hyh ", " --hexadecimal
Display results in hexadecimal rather than base64 notation.
.TP
.BI \(hya ", " --all
Display all hash function values (default).
.TP
.BI \(hyC ", " --CRC32
Display CRC-32, POSIX 1003.2 compliant 32-bit Cyclic Redundancy
Check.
.TP
.BI \(hyM ", " --MD5
Display MD5, the RSA Data Security, Inc. Message Digest Algorithm.
.TP
.BI \(hyS ", " --SHA
Display SHA, \fITripwire\fP's implementation of the
NIST Secure Hash Standard, SHS (NIST FIPS 180).
.TP
.BI \(hyH ", " --HAVAL
Display Haval value, a 128-bit hash code.
.TP
.IR file1 " [ " "file2... " ]
List of filesystem objects for which to display values.
.SH VERSION INFORMATION
This man page describes
.B siggen
version 2.4.
.SH AUTHORS
Tripwire, Inc.
.SH COPYING PERMISSIONS
Permission is granted to make and distribute verbatim copies of this man page provided the copyright notice and this permission notice are preserved on all copies.
.PP
Permission is granted to copy and distribute modified versions of this man page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
.PP
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
.PP
Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
.SH SEE ALSO
.BR twintro (8),
.BR tripwire (8),
.BR twadmin (8),
.BR twprint (8),
.BR twconfig (4),
.BR twpolicy (4),
.BR twfiles (5)

577
man/man8/tripwire.8 Normal file
View File

@ -0,0 +1,577 @@
'\" t
.\" Do not move or remove previous line.
.\" Used by some man commands to know that tbl should be used.
.\"
.\" Macros added by addw@phcomp.co.uk for those systems where the an
.\" troff macro package doesn't know about .Ps & .Pe.
.\" Note it is assumed that CW is a constant width font.
.\" Ps - Start display text
.de Ps
.nf
.in +0.5i
.ft CW
.ps \\n(.s-1
..
.\" Pe - end of display text
.de Pe
.fi
.in -0.5i
.ft 1
.ps \\n(OS
..
.\" Macro added by TSS.
.\" The command mode descriptions run together visually, so
.\" macro Hr draws a horizontal rule to give some separation
.\" between modes. Register Vs dithers the amount of vertical
.\" space before the rule, in lines.
.nr Vs 1
.de Hr
.ne \\n(Vs+2
.sp \\n(Vsli
.nr Oi \\n(.i
.in 0
\\l'\\n(.lu'
.in \\n(.iu
..
.\"
.nh
.ad l
.TH TRIPWIRE 8 "1 July 2000"
.SH NAME
tripwire \- a file integrity checker for \s-1UNIX\s0 systems
.SH SYNOPSIS
.B tripwire
.RB "{ " "-m i" " | " "--init" " } "
.RI "[ " options... " ]"
.br
.B tripwire
.RB "{ " "-m c" " | " "--check" " } "
.RI "[ " options... " ] "
.if n .br
.if n .ti +.5i
.RI "[ " "object1" " [ " "object2..." " ]]"
.br
.B tripwire
.RB "{ " "-m u" " | " "--update" " } "
.RI "[ " options... " ]"
.br
.B tripwire
.RB "{ " "-m p" " | " "--update-policy" " } "
.RI "[ " options... " ]"
.if n .br
.if n .ti +.5i
.I policyfile.txt
.br
.B tripwire
.RB "{ " "-m t" " | " "--test" " } "
.RI "[ " options... " ]"
.\"
.SH DESCRIPTION
.\"
.SS Database Initialization Mode
Running \fBtripwire\fP in Database Initialization mode is
typically one of the first steps in setting up
\fITripwire\fR for regular operation. This mode creates a baseline
database in the location specified by the
.hy 0
\fR\f(CWDBFILE\fP
.hy 1
variable in the \fITripwire\fP configuration file. The
database is essentially a snapshot of the objects residing on the
system. During later \fITripwire\fP integrity checks, this database
serves as the basis for comparison.
.PP
When run in Database Initialization mode, \fBtripwire\fP reads the
policy file, generates a database based on its contents, and then
cryptographically signs the resulting database. Options can be entered
on the command line to specify which policy, configuration, and key
files are used to create the database. The filename for the database
can be specified as well. If no options are specified, the default
values from the current configuration file are used.
.\"
.\" *****************************************
.SS Integrity Checking Mode
After building the \fITripwire\fP database, the next step is typically
to run \fBtripwire\fP in Integrity Checking mode. This mode scans the
system for violations, as specified in the policy file. Using the
policy file rules, \fITripwire\fP will compare the state of the current
file system against the initial baseline database. An integrity
checking report is printed to \fIstdout\fP and is saved in the
location specified by the
.hy 0
\fR\f(CWREPORTFILE\fP
.hy 1
setting in the \fITripwire\fR configuration file.
.PP
The generated report describes each policy file violation in detail,
depending on whether the specified file system object was added,
deleted, or changed. Each report item lists the properties of the
object as it currently resides on the file system, and, if appropriate,
the old value stored in the database. If there are differences between
the database and the current system, the administrator can either fix
the problem by replacing the current file with the correct file (e.g.,
an intruder replaced \fI/bin/login\fP), or update the database to
reflect the new file (e.g., a fellow system administrator installed a
new version of \fI/usr/local/bin/emacs\fP). The (\fB\(hyI\fP or
\fB\(hy\(hyinteractive\fP) option launches an editor that allows the
user to update the database quickly. The Database Update mode of
\fBtripwire\fP can also be used.
.\"
.\" *****************************************
.SS Database Update Mode
Running \fBtripwire\fP in Database Update mode allows any differences
between the database and the current system to be reconciled. This
will prevent the violation from showing up in future reports. If the
reported change is unexpected and potentially malicious, then the
changed file should be replaced with the original version. If there is
a valid reason for the change, the database must be changed to match
the current files.
.PP
In Database Update mode, the items to be changed are specified in a
"ballot box" in the plain text report
that is launched in an editor program.
The entries to
be updated are specified by leaving the "x" next to each policy
violation. After the user exits the editor and provides the correct
local passphrase,
\fBtripwire\fP will update the database.
Options to control this operation include the
.hy 0
(\fB\(hyZ\fP\ or\ \fB\(hy\(hysecure\(hymode\fP) and (\fB\(hya\fP\ or\ \fB\(hy\(hyaccept\(hyall\fP) flags.
.hy 1
.\"
.\" *****************************************
.SS Policy Update Mode
Policy update mode is used by \fBtripwire\fP to change or update the
policy file and to synchronize an earlier database with new policy
file information. The filename of the new clear text version of the
policy file is specified on the command line. The new policy file is
compared to the existing version, and the database is updated according
to the new policy rules. Any changes in the database since the last
integrity check will be detected and reported. How these violations
are interpreted depends on the security mode specified with the
(\fB\(hyZ\fP or \fB\(hy\(hysecure\(hymode\fP) option.
In \fBhigh\fP security mode (the default), \fITripwire\fR will print a list of
violations and exit without making changes to the database. In
\fBlow\fP security mode, the violations are still
reported, but changes to the database are made automatically.
.PP
Because the policy and database files are binary-encoded and
cryptographically signed, the user will be prompted for the site and
local passphrases to change the policy settings. After the database is
successfully updated, the
database and policy files are re-encoded and signed.
.\"
.\" *****************************************
.SS Test Mode
Test mode is used to check the operation of the \fITripwire\fR email
notification system. When run in this mode, \fITripwire\fR will use the
email notification settings specified in the configuration file to send
a test email message. If MAILMETHOD is set to SMTP, the SMTPHOST and
SMTPPORT values will be used to send email. If MAILMETHOD is set to
SENDMAIL, the MAILPROGRAM value will be used. If email notification is
working correctly, the address specified on the command line will
receive the following message:
.PP
.Ps
To: user@domain.com
From: user <user@domain.com>
Subject: Test email message from Tripwire
If you receive this message, email notification
from Tripwire is working correctly.
.Pe
.PP
Test mode only tests email notification for the address specified on
the command-line, and does not check for errors in the syntax used with
the \f(CWemailto\fP attribute in the policy file.
.if \n(.t<700 .bp
.SH OPTIONS
.\"
.\" *****************************************
.SS Database Initialization mode:
.\"
.\"
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m i --init
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-p \fIpolfile\fP --polfile \fIpolfile\fP
-d \fIdatabase\fP --dbfile \fIdatabase\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
-P \fIpassphrase\fP --local-passphrase \fIpassphrase\fP
-e --no-encryption
.TE
.RE
.TP
.BR "\(hym i" ", " --init
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Use the specified configuration file.
.TP
.BI \(hyp " polfile\fR, " --polfile " polfile"
Use the specified policy file.
.TP
.BI \(hyd " database\fR, " --dbfile " database"
Write to the specified database file.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Use the specified site key file to read the configuration and policy
files.
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Use the specified local key file to write the new database file.
Mutually exclusive with (\fB\(hye\fR).
.TP
.BI \(hyP " passphrase\fR, " --local-passphrase " passphrase"
Specifies passphrase to be used with local key to sign the new database.
Mutually exclusive with (\fB\(hye\fR).
.TP
.BR \(hye ", " --no-encryption
Do not sign the database being stored.
The database file will still be compressed and will not be
human-readable.
Mutually exclusive with (\fB\(hyL\fR) and (\fB\(hyP\fR).
.\"
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Integrity Checking mode:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m c --check
-I --interactive
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-p \fIpolfile\fP --polfile \fIpolfile\fP
-d \fIdatabase\fP --dbfile \fIdatabase\fP
-r \fIreport\fP --twrfile \fIreport\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
-P \fIpassphrase\fP --local-passphrase \fIpassphrase\fP
-n --no-tty-output
-V \fIeditor\fP --visual \fIeditor\fP
-E --signed-report
-i \fIlist\fP --ignore \fIlist\fP
-l \fR{ \fIlevel\fR | \fIname\fR }\fP --severity \fR{ \fIlevel\fR | \fIname\fR }\fP
-R \fIrule\fP --rule-name \fIrule\fP
-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
.TE
.RI "[ " object1 " [ " object2... " ]]"
.RE
.TP
.BR "\(hym c" ", " --check
Mode selector.
.TP
.BR \(hyI ", " --interactive
At the end of integrity checking, the resulting report is opened
in an editor where database updates can be easily specified using
the ballot boxes included in the report.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile
Use the specified configuration file.
.TP
.BI \(hyp " polfile\fR, " --polfile " polfile
Use the specified policy file.
.TP
.BI \(hyd " database\fR, " --dbfile " database"
Use the specified database file.
.TP
.BI \(hyr " report\fR, " --twrfile " report"
Write the specified report file.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Use the specified site key file to read the configuration
and policy files.
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Use the specified local key file to read the database
file and, if (\fB\(hyE\fR) is specified, to write the report file.
.TP
.BI \(hyP " passphrase\fR, " --local-passphrase " passphrase"
Specifies passphrase to be used with local key to
sign the database when (\fB\(hyI\fR) is used, and to
sign the report when (\fB\(hyE\fR) is used.
Valid only with (\fB\(hyI\fR) or (\fB\(hyE\fR).
.TP
.BR \(hyn ", " --no-tty-output
Suppress the report from being printed at the console.
.TP
.BI \(hyV " editor\fR, " --visual " editor
Use the specified editor to edit the update ballot boxes.
Meaningful only with (\fB\(hyI\fP).
.TP
.BR \(hyE ", " --signed-report
Specifies that the \fITripwire\fR report will be signed. If
no passphrase is specified on the command line, \fBtripwire\fR
will prompt for the local passphrase.
.TP
.BI \(hyi " list\fR, " --ignore " list
Do not compute or compare the properties specified in \fIlist\fR. Any
of the letter codes (abcdgimnprstulCHMS) specified in propertymasks can
be excluded.
Use of this option overrides information from the policy file.
The format to be used for \fIlist\fP is a double-quoted, comma-delimited list
of properties (e.g.\ \fI\-\-ignore\ "p,c,m"\fP).
.TP
\fB\(hyl \fR{ \fIlevel \fR| \fIname \fR}, \fB--severity \fR{ \fIlevel \fR| \fIname \fR}
Check only policy rules with severity greater than or equal to
the given level. The level may be specified as a number or as a name.
Severity names are defined as follows:
.nf
.ta 0.5iL +1.5iR
Low 33
Medium 66
High 100
.fi
Mutually exclusive with (\fB\(hyR\fP).
.DT
.TP
.BI \(hyR " rule\fR, " --rule-name " rule
Check only the specified policy rule. Mutually exclusive with
(\fB\(hyl\fP).
.TP
.BI \(hyx " section\fR, " --section " section
Only check the rules in the specified section of the policy file. For
\fITripwire 2.4\fR, \fR\f(CWFS\fP is the only meaningful
argument for this flag.
.TP
.BR \(hyM ", " --email-report
Specifies that reports be emailed to the recipient(s) designated in the
policy file.
.TP
.BI \(hyt " level\fR, " --email-report-level " level
Specifies the detail level of email reports, overriding the
EMAILREPORTLEVEL variable in the configuration file. \fIlevel\fR must
be a number from 0\ to\ 4.
Valid only with (\fB\(hyM\fP).
.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
\fB--severity\fR and \fB--rule-name\fR options will be ignored.
.\"
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Database Update mode:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m u --update
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-p \fIpolfile\fP --polfile \fIpolfile\fP
-d \fIdatabase\fP --dbfile \fIdatabase\fP
-r \fIreport\fP --twrfile \fIreport\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
-P \fIpassphrase\fP --local-passphrase \fIpassphrase\fP
-V \fIeditor\fP --visual \fIeditor\fP
-a --accept-all
-Z \fR{ low | high }\fP --secure-mode \fR{ low | high }\fP
.TE
.RE
.TP
.BR "\(hym u" ", " --update
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile
Use the specified configuration file.
.TP
.BI \(hyp " polfile\fR, " --polfile " polfile
Use the specified policy file.
.TP
.BI \(hyd " database\fR, " --dbfile " database"
Update the specified database file.
.TP
.BI \(hyr " report\fR, " --twrfile " report"
Read the specified report file.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Use the specified site key file to read the configuration
and policy files.
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Use the specified local key file to read the database
file and report file, and to re-write the database file.
.TP
.BI \(hyP " passphrase\fR, " --local-passphrase " passphrase"
Specifies passphrase to be used with local key to
sign the database.
.TP
.BI \(hyV " editor\fR, " --visual " editor"
Use the specified editor to edit the update ballot boxes. Mutually
exclusive with (\fB\(hya\fP).
.TP
.BR \(hya ", " --accept-all
Specifies that all the entries in the report file are updated
without prompting. Mutually exclusive with (\fB\(hyV\fP).
.TP
\fB\(hyZ \fR{ low | high \fR}, \fB--secure-mode \fR{ low | high \fR}
Specifies the security level, which affects how certain conditions are
handled when inconsistent information is found between the report file
and the current database:
.sp
High: In \fBhigh\fP security mode, if a file does not match the
properties in the report file, Tripwire reports the differences as
warnings, and exits without changing the database.
.sp
Low: In \fBlow\fP security mode, inconsistencies
are reported as warnings,
but the changes are still made to the database.
.\"
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Policy Update mode:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m p --update-policy
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-p \fIpolfile\fP --polfile \fIpolfile\fP
-d \fIdatabase\fP --dbfile \fIdatabase\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
-P \fIpassphrase\fP --local-passphrase \fIpassphrase\fP
-Q \fIpassphrase\fP --site-passphrase \fIpassphrase\fP
-Z \fR{ low | high }\fP --secure-mode \fR{ low | high }\fP
.TE
.I policyfile.txt
.RE
.TP
.BR "\(hym p" ", " --update-policy
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile
Use the specified configuration file.
.TP
.BI \(hyp " polfile\fR, " --polfile " polfile
Write the specified policy file.
.TP
.BI \(hyd " database\fR, " --dbfile " database"
Use the specified database file.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Use the specified site key file to read the configuration
file, and read and write the policy file.
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Use the specified local key file to read and write the database
file.
.TP
.BI \(hyP " passphrase\fR, " --local-passphrase " passphrase"
Specifies passphrase to be used with local key to
sign the database.
.TP
.BI \(hyQ " passphrase\fR, " --site-passphrase " passphrase"
Specifies passphrase to be used with site key to sign
the new policy file.
.TP
\fB\(hyZ \fR{ low | high \fR}, \fB--secure-mode \fR{ low | high \fR}
Specifies the security level, which affects how certain conditions are
handled when the existing filesystem does not match the database
information. Since the database produced at the end of a policy update
becomes the baseline for future integrity checks, this
consistency-checking ensures that no substantive filesystem changes
have occurred since the last integrity check.
.sp
High: In \fBhigh\fP security mode, if a file on the filesystem does
not match the properties in the database file, Tripwire reports the
differences as warnings, and exits without changing the database or the
policy file.
.sp
Low: In \fBlow\fP security mode, inconsistencies are reported as
warnings, but the changes are still made to the database and policy
file.
.if \n(.t<700 .bp
.TP
.I policyfile.txt
Specifies the text policy file that will become the new policy file.
.\"
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Test mode:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m t --test
-e \fIuser@domain.com\fP --email \fIuser@domain.com\fP
.TE
.RE
.TP
.BR "\(hym t" ", " --test
Mode selector.
.TP
.BI \(hye " user@domain.com\fR, " --email " user@domain.com"
Use the specified email address. This parameter must
be supplied when test mode is used. Only one address
may be specified.
.SH VERSION INFORMATION
This man page describes
.B tripwire
version 2.4
.SH AUTHORS
Tripwire, Inc.
.SH COPYING PERMISSIONS
Permission is granted to make and distribute verbatim copies of this man page provided the copyright notice and this permission notice are preserved on all copies.
.PP
Permission is granted to copy and distribute modified versions of this man page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
.PP
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
.PP
Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
.SH SEE ALSO
.BR twintro (8),
.BR twadmin (8),
.BR twprint (8),
.BR siggen (8),
.BR twconfig (4),
.BR twpolicy (4),
.BR twfiles (5)
.PP
.IR "The Design and Implementation of Tripwire: A \s-1UNIX\s0 File Integrity Checker"
by Gene Kim and Eugene Spafford. Purdue Technical Report CSD-TR-93-071.

558
man/man8/twadmin.8 Normal file
View File

@ -0,0 +1,558 @@
'\" t
.\" Do not move or remove previous line.
.\" Used by some man commands to know that tbl should be used.
.\"
.\" Macro added by TSS.
.\" The command mode descriptions run together visually, so
.\" macro Hr draws a horizontal rule to give some separation
.\" between modes. Register Vs dithers the amount of vertical
.\" space before the rule, in lines.
.nr Vs 1
.de Hr
.ne \\n(Vs+2
.sp \\n(Vsli
.nr Oi \\n(.i
.in 0
\\l'\\n(.lu'
.in \\n(.iu
..
.ad l
.TH TWADMIN 8 "1 July 2000"
.SH NAME
twadmin \- Tripwire administrative and utility tool
.SH SYNOPSIS
.B twadmin
.RB "{ " "-m F" " | " "--create-cfgfile" " } "
.I " options... "
.if n .br
.if n .ti +.5i
.I "configfile.txt"
.br
.B twadmin
.RB "{ " "-m f" " | " "--print-cfgfile" " } "
.RI "[ " options... " ]"
.br
.B twadmin
.RB "{ " "-m P" " | " "--create-polfile" " } "
.RI "[ " options... " ] "
.if n .br
.if n .ti +.5i
.I "policyfile.txt"
.br
.B twadmin
.RB "{ " "-m p" " | " "--print-polfile" " } "
.RI "[ " options... " ]"
.br
.B twadmin
.RB "{ " "-m R" " | " "--remove-encryption" " } "
.RI "[ " options... " ] "
.if n .br
.if n .ti +.5i
.IR file1 " [ " file2... " ]"
.br
.B twadmin
.RB "{ " "-m E" " | " "--encrypt" " } "
.RI "[ " options... " ] "
.if n .br
.if n .ti +.5i
.IR file1 " [ " file2... " ]"
.br
.B twadmin
.RB "{ " "-m e" " | " "--examine" " } "
.RI "[ " options... " ] "
.if n .br
.if n .ti +.5i
.IR file1 " [ " file2... " ]"
.br
.B twadmin
.RB "{ " "-m G" " | " "--generate-keys" " } "
.I options...
.br
.B twadmin
.RB "{ " "-m C" " | " "--change-passphrases" " } "
.I options...
.br
.SH DESCRIPTION
.PP
The \fBtwadmin\fR utility is used to perform certain administrative
functions related to \fITripwire\fR files and configuration options.
Specifically, \fBtwadmin\fR allows encoding, decoding,
signing, and verification of
\fITripwire\fR files, and provides a means to generate and change
local and site keys.
.\" *****************************************
.SS Creating a configuration file (--create-cfgfile)
This command mode designates an existing text file as the new
configuration file for \fITripwire\fR.
The plain text configuration
file must be specified on the command line.
Using the site key, the new configuration file
is encoded and saved.
.\" *****************************************
.SS Printing a configuration file (--print-cfgfile)
This command mode prints the specified encoded and signed
configuration file in clear-text form to standard output.
.\" *****************************************
.SS Replacing a policy file (--create-polfile)
This command mode designates an existing text file as the new
policy file for \fITripwire\fR.
The plain text policy file must be specified on the
command line.
Using the site key, the new policy file is encoded and saved.
.\" *****************************************
.SS Printing a policy file (--print-polfile)
This command mode prints the
specified encoded and signed policy file
in clear-text form to standard output.
.\" *****************************************
.SS Removing encryption from a file (--remove-encryption)
This command mode allows the user to remove signing from signed
configuration, policy, database, or report files. Multiple
files may be specified on the command line. The
user will need to enter the appropriate local or site keyfile,
or both if a combination of files is to be verified. Even with the
cryptographic signing removed, these files will be in a binary encoded
(non-human-readable) form.
.\" *****************************************
.SS Encrypting a file (--encrypt)
This command mode allows the user to sign
configuration, policy, database files, or reports.
Multiple files may be specified on the command line.
The files will be signed using either the site or local key,
as appropriate for the type of file.
To automate the process, the passphrase for the key
files can be included on the command line.
.\" *****************************************
.hy 0
.SS "Examining the signing status of a file (\(hy\(hyexamine)"
.hy 1
This command allows the user to examine the listed files
and print a report of their signing status. This report
displays the filename, file type, whether or not a file is
signed, and what key (if any) is used to sign it.
.\" *****************************************
.SS Generating keys (--generate-keys)
This command mode generates site and/or local key files with
names specified by the user.
.\" *****************************************
.SS Changing passphrases (--change-passphrases)
This command reencrypts the private part of the
site and/or local key files using the key filenames and passphrases
specified by the user.
.\" *****************************************
.if \n(.t<700 .bp
.SH OPTIONS
.\" *****************************************
.SS Creating a configuration file:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m F --create-cfgfile
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
-Q \fIpassphrase\fP --site-passphrase \fIpassphrase\fP
-e --no-encryption
.TE
.I configfile.txt
.RE
.TP
.BR "\(hym F" ", " "--create-cfgfile"
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Specify the destination of the encoded (and optionally signed)
configuration file.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Use the specified site key file to encode and sign the new
configuration file.
Exactly one of (\fB\(hyS\fR) or (\fB\(hye\fP) must be specified.
.TP
.BI \(hyQ " passphrase\fR, " --site-passphrase " passphrase"
Specifies passphrase to be used with site key for
configuration file encoding and signing.
Valid only in conjunction with (\fB\(hyS\fR).
.TP
.BR \(hye ", " --no-encryption
Do not sign the configuration file being stored.
The configuration
file will still be compressed, and will not be human-readable.
Mutually exclusive with (\fB\(hyQ\fR) and (\fB\(hyS\fR).
.TP
.I configfile.txt
Specifies the text configuration file that will become
the new configuration file.
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Printing a configuration file:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m f --print-cfgfile
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
.TE
.RE
.TP
.BR "\(hym f" ", " "--print-cfgfile"
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Print the specified configuration file.
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Creating a policy file:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m P --create-polfile
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-p \fIpolfile\fP --polfile \fIpolfile\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
-Q \fIpassphrase\fP --site-passphrase \fIpassphrase\fP
-e --no-encryption
.TE
.I policyfile.txt
.RE
.TP
.BR "\(hym P" ", " --create-polfile
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Use the specified configuration file.
.TP
.BI \(hyp " polfile\fR, " --polfile " polfile"
Specify the destination of the encoded (and optionally signed) policy
file.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Use the specified site key file. Mutually exclusive with (\fB\(hye\fR).
.TP
.BI \(hyQ " passphrase\fR, " --site-passphrase " passphrase"
Specifies passphrase to be used with site key for policy signing.
Mutually exclusive with (\fB\(hye\fR).
.TP
.BR \(hye ", " --no-encryption
Do not sign the policy file being stored. The policy
file will still be compressed, and will not be human-readable.
Mutually exclusive with (\fB\(hyQ\fR) and (\fB\(hyS\fR).
.TP
.I policyfile.txt
Specifies the text policy file that will become the new
policy file.
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Printing a policy file:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m p --print-polfile
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-p \fIpolfile\fP --polfile \fIpolfile\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
.TE
.RE
.TP
.BR "\(hym p" ", " --print-polfile
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Use the specified configuration file.
.TP
.BI \(hyp " polfile\fR, " --polfile " polfile"
Print the specified policy file.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Use the specified site key file.
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Removing encryption from a file:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m R --remove-encryption
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
-P \fIpassphrase\fP --local-passphrase \fIpassphrase\fP
-Q \fIpassphrase\fP --site-passphrase \fIpassphrase\fP
.TE
.IR "file1" " [ " "file2..." " ]"
.RE
.TP
.BR "\(hym R" ", " --remove-encryption
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Use the specified configuration file.
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Specify the local keyfile to use to verify database files and reports.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Specify the site keyfile to use to verify configuration
and policy files.
.TP
.BI \(hyP " passphrase\fR, " --local-passphrase " passphrase"
Specify the passphrase to use when verifying with the
old local keyfile.
.TP
.BI \(hyQ " passphrase\fR, " --site-passphrase " passphrase"
Specify the passphrase to use when verifying with the
old site keyfile.
.TP
.IR file1 " [ " file2... " ]"
List of files from which signing is to be removed.
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Encrypting a file:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m E --encrypt
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
-P \fIpassphrase\fP --local-passphrase \fIpassphrase\fP
-Q \fIpassphrase\fP --site-passphrase \fIpassphrase\fP
.TE
.IR "file1" " [ " "file2..." " ]"
.RE
.TP
.BR "\(hym E" ", " --encrypt
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Use the specified configuration file.
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Specify the local keyfile to use to sign database
files and reports.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Specify the site keyfile to use to sign configuration
and policy files.
.TP
.BI \(hyP " passphrase\fR, " --local-passphrase " passphrase"
Specify the passphrase to use when signing with the
local keyfile.
.TP
.BI \(hyQ " passphrase\fR, " --site-passphrase " passphrase"
Specify the passphrase to use when signing with the
site keyfile.
.TP
.IR file1 " [ " file2... " ]"
List of files to sign using the new key(s).
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS "Examining the encryption status of a file:"
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m e --examine
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
.TE
.IR file1 " [ " file2... " ]"
.RE
.TP
.BR "\(hym e" ", " --examine
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Use the specified configuration file.
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Specifies the key to use as a local key.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Specifies the key to use as a site key.
.TP
.IR file1 " [ " file2... " ]"
List of files to examine.
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Generating keys:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m G --generate-keys
-v --verbose
-s --silent\fR,\fP --quiet
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
-P \fIpassphrase\fP --local-passphrase \fIpassphrase\fP
-Q \fIpassphrase\fP --site-passphrase \fIpassphrase\fP
.TE
.RE
.TP
.BR "\(hym G" ", " --generate-keys
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Generate the local key into the specified file. At least one of
(\fB\(hyL\fR) or (\fB\(hyS\fR) must be specified.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Generate the site key into the specified file. At least one of
(\fB\(hyS\fR) or (\fB\(hyL\fR) must be specified.
.TP
.BI \(hyP " passphrase\fR, " --local-passphrase " passphrase"
Specify local passphrase to be used when generating
the local key.
.TP
.BI \(hyQ " passphrase\fR, " --site-passphrase " passphrase"
Specify site passphrase to be used when generating
the site key.
.\" *****************************************
.Hr
.if \n(.t<700 .bp
.SS Changing passphrases:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m C --change-passphrases
-v --verbose
-s --silent\fR,\fP --quiet
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
-S \fIsitekey\fP --site-keyfile \fIsitekey\fP
-P \fIpassphrase\fP --local-passphrase \fIpassphrase\fP
-Q \fIpassphrase\fP --site-passphrase \fIpassphrase\fP
--local-passphrase-old \fIpassphraseOld\fP
--site-passphrase-old \fIpassphraseOld\fP
.TE
.RE
.TP
.BR "\(hym C" ", " --change-passphrases
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Change passphrase used to encrypt the private key in the specified localkey
file. At least one of (\fB\(hyL\fR) or (\fB\(hyS\fR) must be specified.
.TP
.BI \(hyS " sitekey\fR, " --site-keyfile " sitekey"
Change passphrase used to encrypt the private key in the specified sitekey
file. At least one of (\fB\(hyL\fR) or (\fB\(hyS\fR) must be specified.
.TP
.BI \(hyP " passphrase\fR, " --local-passphrase " passphrase"
Specify passphrase used to encrypt the private key in the specified localkey
file.
.TP
.BI \(hyQ " passphrase\fR, " --site-passphrase " passphrase"
Specify passphrase used to encrypt the private key in the specified sitekey
file.
.TP
.BI --local-passphrase-old " passphraseOld"
Specify passphrase used to decrypt the private key in the specified localkey
file.
.TP
.BI --site-passphrase-old " passphraseOld"
Specify passphrase used to decrypt the private key in the specified sitekey
file.
.\" *****************************************
.SH VERSION INFORMATION
This man page describes
.B twadmin
version 2.4.
.SH AUTHORS
Tripwire, Inc.
.SH COPYING PERMISSIONS
Permission is granted to make and distribute verbatim copies of this man page provided the copyright notice and this permission notice are preserved on all copies.
.PP
Permission is granted to copy and distribute modified versions of this man page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
.PP
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
.PP
Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
.SH SEE ALSO
.BR twintro (8),
.BR tripwire (8),
.BR twprint (8),
.BR siggen (8),
.BR twconfig (4),
.BR twpolicy (4),
.BR twfiles (5)

112
man/man8/twintro.8 Normal file
View File

@ -0,0 +1,112 @@
.\" Macros added by addw@phcomp.co.uk for those systems where the an
.\" troff macro package doesn't know about .Ps & .Pe.
.\" Note it is assumed that CW is a constant width font.
.\" Ps - Start display text
.de Ps
.nf
.in +0.5i
.ft CW
..
.\" Pe - end of display text
.de Pe
.fi
.in -0.5i
.ft 1
..
.\"
.nh
.ad l
.TH TWINTRO 8 "1 July 2000"
.SH NAME
twintro \- introduction to \fITripwire\fP software
.SH DESCRIPTION
.PP
\fITripwire 2.4\fP is a file integrity assessment product for Linux networks. Rather than preventing an intruder or virus
from attacking system files, \fITripwire\fP detects intrusions when
they do occur. By comparing system files and directories against a
previously stored "baseline" database, \fITripwire\fP finds any
additions, deletions, or changes to specified properties. This allows
the system administrator to determine the extent of the problem and
begin necessary damage control.
.PP
After \fITripwire\fP is installed on a system, the following four
commands are used:
.RS 0.3i
.ie n .HP
.el .PP
.BR tripwire (8)
is used for most of the basic operations of the
software. This includes creation of the \fITripwire\fP database, and
checking the integrity of the filesystem against that database.
.ie n .HP
.el .PP
.BR twadmin (8)
is used to create, encode, and sign \fITripwire\fP policy,
configuration, and key files, and
for various administrative functions.
.ie n .HP
.el .PP
.BR twprint (8)
prints \fITripwire\fP database and report files in
a plain text format.
.ie n .HP
.el .PP
.BR siggen (8)
is a file utility that displays hash
values for files.
.RE
.PP
In addition to the command references listed above, the following three
man pages provide information on important components of the
\fITripwire\fP package.
.RS 0.3i
.ie n .HP
.el .PP
.BR twfiles (5)
provides an overview of the various files created and
used by \fITripwire\fP, including default locations and settings.
.ie n .HP
.el .PP
.BR twconfig (4)
explains the configuration file, which is used to set
system-specific information that affects \fITripwire\fP operation.
.ie n .HP
.el .PP
.BR twpolicy (4)
explains the policy file, which specifies the files
and directories \fITripwire\fP should check, and how they should be
scanned.
.RE
.PP
Using the
.B \(hy\(hyhelp
flag with any \fITripwire\fP command
(e.g.\ \fBtripwire\ \(hy\(hyhelp\fP) will print a short summary of the
command modes for that command. If a mode selector is also specified
(e.g.\ \fBtripwire\ \(hy\(hycheck\ \(hy\(hyhelp\fP), a mode\(hyspecific
usage message will be displayed. Using the \fBall\fP argument with the
\fB--help\fP flag (e.g.\ \fBtripwire\ \(hy\(hyhelp\ all\fP) will print
detailed usage messages for all modes of the specified command.
.SH VERSION INFORMATION
This man page describes
.IR "Tripwire 2.4" "."
.SH AUTHORS
Tripwire, Inc.
.SH COPYING PERMISSIONS
Permission is granted to make and distribute verbatim copies of this man page provided the copyright notice and this permission notice are preserved on all copies.
.PP
Permission is granted to copy and distribute modified versions of this man page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
.PP
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
.PP
Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
.SH SEE ALSO
.BR tripwire (8),
.BR twadmin (8),
.BR twprint (8),
.BR siggen (8),
.BR twconfig (4),
.BR twpolicy (4),
.BR twfiles (5)
.PP
.IR "The Design and Implementation of Tripwire: A \s-1UNIX\s0 File Integrity Checker" by Gene Kim and Eugene Spafford. Purdue Technical Report CSD-TR-93-071.

148
man/man8/twprint.8 Normal file
View File

@ -0,0 +1,148 @@
'\" t
.\" Do not move or remove previous line.
.\" Used by some man commands to know that tbl should be used.
.ad l
.TH TWPRINT 8 "1 July 2000"
.nh
.SH NAME
twprint \- Tripwire database and report printer
.SH SYNOPSIS
.B twprint
.RB "{ " "-m r" " | " "--print-report" " } "
.RI "[ " options... " ]"
.br
.B twprint
.RB "{ " "-m d" " | " "--print-dbfile" " } "
.RI "[ " options... " ]"
.if n .br
.if n .ti +.5i
.RI " [ " "object1" " [ " "object2..." " ]]"
.SH DESCRIPTION
.PP
Prints \fITripwire\fR database and report files in clear text format.
.SS Report Printing mode
.PP
In Report Printing mode, \fBtwprint\fR verifies and displays the
contents of a \fITripwire\fR report file (\fI.twr\fR). If no report is
specified on the command line,
the report specified in the
\f(CWREPORTFILE\fR
variable in the configuration file will be used. By default,
this value includes the date and time to the nearest second. Because
this value is constantly changing, \fBtwprint\fR may not be able to
find the correct report file. For this reason, the (\fB\(hyr\fR or
\fB--twrfile\fR) flag should be used with the desired report name to
print a specific report.
.SS Database Printing mode
.PP
This option is used to print a \fITripwire\fR database file in
human-readable (clear text) form. In Database Printing mode,
\fBtwprint\fR verifies and
prints the contents of a specified database to \fIstdout\fR. If no
database file is specified
on the command line, the default database specified by the
\f(CWDBFILE\fR
variable in the configuration file is used.
.SH OPTIONS
.\" *****************************************
.SS Report printing mode:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m r --print-report
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-r \fIreport\fP --twrfile \fIreport\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
-t \fR{ 0|1|2|3|4 }\fP --report-level \fR{ 0|1|2|3|4 }\fP
.TE
.RE
.TP
.BR "\(hym r" ", " --print-report
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Use the specified configuration file.
.TP
.BI \(hyr " report\fR, " --twrfile " report"
Print the specified report file.
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Use the specified local key file to perform verification
with reports which are signed.
.TP
.BI \(hyt " level\fR, " --report-level " level
Specifies the detail level of the printed report, overriding the
\f(CWREPORTLEVEL\fP variable in the configuration
file. \fIlevel\fR must be a number from 0\ to\ 4.
.\" *****************************************
.SS Database printing mode:
.RS 0.4i
.TS
;
lbw(1.2i) lb.
-m d --print-dbfile
-v --verbose
-s --silent\fR,\fP --quiet
-c \fIcfgfile\fP --cfgfile \fIcfgfile\fP
-d \fIdatabase\fP --dbfile \fIdatabase\fP
-L \fIlocalkey\fP --local-keyfile \fIlocalkey\fP
.TE
.RI "[ " "object1" " [ " "object2..." " ]]"
.RE
.TP
.BR "\(hym d" ", " --print-dbfile
Mode selector.
.TP
.BR \(hyv ", " --verbose
Verbose output mode. Mutually exclusive with (\fB\(hys\fR).
.TP
.BR \(hys ", " --silent ", " --quiet
Silent output mode. Mutually exclusive with (\fB\(hyv\fR).
.TP
.BI \(hyc " cfgfile\fR, " --cfgfile " cfgfile"
Use the specified configuration file.
.TP
.BI \(hyd " database\fR, " --dbfile " database"
Print the specified database file.
.TP
.BI \(hyL " localkey\fR, " --local-keyfile " localkey"
Use the specified local key file to read the database.
.TP
.RI "[ " "object1" " [ " "object2..." " ]]"
List of filesystem objects in the database to print. If no
objects are specified, every object in the database will
be printed. The format for a list of objects is:
.if n .I "section: objname objname... section: objname..."
.if t .br
.if t .I "section: objectname objectname... section: objectname..."
.SH VERSION INFORMATION
This man page describes
.B twprint
version 2.4.
.SH AUTHORS
Tripwire, Inc.
.SH COPYING PERMISSIONS
Permission is granted to make and distribute verbatim copies of this man page provided the copyright notice and this permission notice are preserved on all copies.
.PP
Permission is granted to copy and distribute modified versions of this man page under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
.PP
Permission is granted to copy and distribute translations of this man page into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Tripwire, Inc.
.PP
Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire, Inc. in the United States and other countries. All rights reserved.
.SH SEE ALSO
.BR twintro (8),
.BR tripwire (8),
.BR twadmin (8),
.BR siggen (8),
.BR twconfig (4),
.BR twpolicy (4),
.BR twfiles (5)

283
missing Executable file
View File

@ -0,0 +1,283 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
# Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing 0.3 - GNU automake"
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
aclocal)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
if test -z "$run" && (makeinfo --version > /dev/null 2>&1); then
# We have makeinfo, but it failed.
exit 1
fi
echo 1>&2 "\
WARNING: \`$1' is missing on your system. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
tar)
shift
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
fi
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar ${1+"$@"} && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar ${1+"$@"} && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" ${1+"$@"} && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" ${1+"$@"} && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and you do not seem to have it handy on your
system. You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequirements for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0

40
mkinstalldirs Executable file
View File

@ -0,0 +1,40 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
# Author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain
# $Id: mkinstalldirs,v 1.1 2001/02/18 15:08:31 pherman Exp $
errstatus=0
for file
do
set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
shift
pathcomp=
for d
do
pathcomp="$pathcomp$d"
case "$pathcomp" in
-* ) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
fi
fi
pathcomp="$pathcomp/"
done
done
exit $errstatus
# mkinstalldirs ends here

View File

@ -0,0 +1,15 @@
* Tripwire 2.4.2.2 Policy Generator README
This readme is a quick guide on something introduced in this version
of Tripwire: the Policy Generator. The idea behind is to generate a
custom file fitting your system.
It has so far been tested on Debian Wheezy and CentOS 5.7/6.0, your
mileage may vary.
This is not part of the standard install so you will have to do this
manually for now if you want to use it.
This is also provided as-is but if you happen to find out bugs, have
improvement suggestions or patches, send them to: tripwire@frlinux.net

215
policy/policyguide.txt Normal file
View File

@ -0,0 +1,215 @@
# Demonstration policy file for Linux and Unix
# Tripwire, Inc. is not responsible for the accuracy
# of this file or its relevance to your system. This file is provided
# only as a starting point and example. We highly encourage you to
# use this file to create a new policy file that suits the security needs
# and eccentricities of your own machine.
# This policy file contains individually valid rules to demonstrate all
# current language features created for the Tripwire 2.3 release.
# This is a comment. Tripwire treats all text following a "#" as a comment.
/etc/hosts -> +pinugs; # This is a very basic rule.
# Tripwire will alert you if any of
# the specified properties for
# the file /etc/hosts are modified.
!/etc/init.d ; # The "!" indicates a stop point.
# The directory /etc/init.d will
# not be scanned.
!/etc/netmasks ; # Stop point on a file. Tripwire
# will not scan /etc/netmasks
"/home/fred/big file" -> +pingus; # Double quotes can be used to
# protect special cases such as
# filenames with spaces and escaped
# characters.
"/home/emu/o\163trich" -> +s; # Escaped octal character
"/home/emu/\x64odo" -> +m; # Escaped hex character
"/home/emu/blue\'jay" -> +c; # Escaped character
# The following rules demonstrate a scan using each of the individual
# property selection masks.
/etc/passwd -> +a; # Access timestamp
/etc/passwd -> +b; # Number of blocks
/etc/passwd -> +c; # Inode timestamp (create/modify)
/etc/passwd -> +d; # Inode storage disk device number
/etc/passwd -> +g; # File owner's group ID
/etc/passwd -> +i; # Inode number
/etc/passwd -> +m; # Modification timestamp
/etc/passwd -> +n; # inode reference count
/etc/passwd -> +p; # Permissions and file mode bits
/etc/passwd -> +r; # Device Number
/etc/passwd -> +s; # File size
/etc/passwd -> +t; # File Type
/etc/passwd -> +u; # File owner's user ID
/etc/passwd -> +l; # File is increasing in size
/etc/passwd -> +C; # CRC-32 hash value
/etc/passwd -> +M; # MD5 hash value
/etc/passwd -> +S; # SHA hash value
/etc/passwd -> +H; # Haval signature value
# Rules can be given specific attributes which influence how tripwire
# behaves either while scanning or when it detects an infraction.
/etc -> +ug (recurse=false); # The recurse attribute controls
# recursive scanning of the
# contents of a directory. In this
# case, recurse is set to false, so
# tripwire will scan the /etc
# directory but not its contents.
/etc -> +ug (rulename=software); # Setting a rulename allows you to
# associate a rule or set of rules
# with a specific name. This can
# help you to sort data in your
# Tripwire reports. For this rule,
# any infraction in the /etc
# directory will appear as part of
# the "software" section of the
# report.
/etc -> +ug (emailto=admin@domain.com); # The emailto attribute will cause
# Tripwire to send email to a
# specified user if the indicated
# rule is broken. In this case,
# admin@domain.com will receive a
# tripwire report if someone
# changes the user or group id on
# any file in the /etc directory.
/etc -> +ug (emailto="admin@domain.com webmaster@domain.com")
# you can use quotes to email to
# more than one person.
/etc -> +ug (severity=50); # You can set the severity of a
# rule so that you can quickly scan
# through a report to find the
# most critical changes.
# Setting variables is a good way to easily change the parameters for
# several rules at once.
param1 = +SMCH; # Set variable param1.
dir1 = /etc/inet; # Set variable dir1
DIR1 = /etc/init.d; # Variables are case sensitive
$(dir1) -> +tbamc; # Rule using directory substitution
# or "left Hand substitution"
/etc/inet -> $(param1); # Rule using selection mask
# substitution or "Right Hand
# substitution".
$(DIR1) -> $(param1); # It is also possible to do a
# double substitution.
# Tripwire also provides several predefined variables.
/etc/httpd/weblog -> $(Growing); # The Growing variable is intended
# for files that should only grow,
# such as the web log in this
# example. Growing uses the
# following masks: +pinugtdl
/etc/passwd -> $(IgnoreNone); # IgnoreNone should be used on
# critical files such as passwd.
# It checks all file attributes:
# +pinusgamctdbCMSH
/home/fred/mytextfile -> $(IgnoreAll); # If you want to track a file's
# presence or absence but do
# not care about its properties,
# use IgnoreAll. IgnoreAll ignores
# all attributes: pinusglamctdbCMSH
/usr/httpd/index.html -> $(ReadOnly); # ReadOnly is good for files that
# are widely available but are
# intended to be read-only.
# Attributes: +pinugsmtdbCM
/home/fred -> $(Dynamic); # Dynamic is good for monitoring
# user directories and files that
# tend to be dynamic in behavior.
# Attributes: +pinugtd
/dev/null -> $(Device); # Device is appropriate for checking
# system devices and any other
# files that may be important, but
# should be relatively static and
# accessed often: +pugs
# Directives are useful if you want to use one policy across your network
# servers, but also require special rules for each machine.
@@ifhost salmon # The following rule will only run
/etc -> +abcdgimnpstul; # will only run if the server name
# is salmon.
@@else
/bin -> +abcdgimnpstul; # All other servers will run this
@@endif # rule.
# Directives can also be nested:
@@ifhost crayfish
/etc/passwd -> $(Growing); # Will only check /etc/passwd if
# your hostname is crayfish.
@@else # Otherwise it will check if your
@@ifhost salmon # hostname is salmon. If so it
/etc/passwd -> $(IgnoreAll); # will ignore passwd.
@@endif # If your server has any other name
/etc/passwd -> $(IgnoreNone); # then passwd is fully examined.
@@endif
# The following examples demonstrate more complicated uses of Tripwire that
# are more likely to be seen in a real environment.
# Trailing rules: These are typical of the rule format used in most of
# this file. This is by far the most common usage.
/home/fred/specialfile -> asd (emailto=fred@domain.com, Rulename=special, severity=50);
/home/fred/generalworkfile -> bm (Rulename=work, severity=60);
/home/fred/myreport -> CSH (Rulename=report, severity=75);
/home/fred/mypresentation.data -> Mpi (Rulename=urgent, severity=90);
# Preceding rules: These are extremely helpful if you wish to apply a rule
# to a large group of files or directories.
(Rulename=standard, severity=30)
{
/home/fred -> lgu;
/home/jane -> CHM;
/home/project/report.file -> $(Growing);
}
#=============================================================================
#
# Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
# Inc. All rights reserved.
#
# Linux is a registered trademark of Linus Torvalds.
#
# UNIX is a registered trademark of The Open Group.
#
#=============================================================================
#
# Permission is granted to make and distribute verbatim copies of this document
# provided the copyright notice and this permission notice are preserved on all
# copies.
#
# Permission is granted to copy and distribute modified versions of this
# document under the conditions for verbatim copying, provided that the entire
# resulting derived work is distributed under the terms of a permission notice
# identical to this one.
#
# Permission is granted to copy and distribute translations of this document
# into another language, under the above conditions for modified versions,
# except that this permission notice may be stated in a translation approved by
# Tripwire, Inc.

View File

@ -0,0 +1,59 @@
#!/bin/bash
#
# 2011-11-21 - v0.2 : added more checks
# 2011-09-21 - v0.1 : first attempt to create a custom file
# FRLinux - tripwire@frlinux.net
#
echo " "
echo "Please run this as ROOT, failing to do so might prevent from"
echo "indexing all directories."
echo " "
BASECONFIG="."
POL="$BASECONFIG/../twpol.txt"
POL_HEADER="$BASECONFIG/twpol-header.txt"
POL_FOOTER="$BASECONFIG/twpol-footer.txt"
echo "# `date` " > $POL
echo "#" >> $POL
echo "# New Policy file format - FRLinux tripwire@frlinux.net" >> $POL
echo "# This is experimental, check the readme before using this." >> $POL
echo "#" >> $POL
cat $POL_HEADER >> $POL
echo "" >> $POL
echo "# File System and Disk Administration Programs." >> $POL
echo "" >> $POL
if [ `uname -i` = "x86_64" ]; then
dir64="/lib64"
else
dir64=""
fi
for dir in /bin /sbin /lib /etc $dir64
do
echo "(" >> $POL
echo " rulename = \"files in $dir\"," >> $POL
echo " severity = \$(SIG_HI)" >> $POL
echo ")" >> $POL
echo "{" >> $POL
find $dir -type f -printf " %p -> \$(SEC_CRIT);\n" >> $POL
echo "}" >> $POL
echo "" >> $POL
done
for type in root sys
do
cat $type.tpl >> $POL
done
cat $POL_FOOTER >> $POL
echo " "
echo "Copy this file in $TRIPWIRE_INSTALL/etc/twpol.txt"
echo "then execute: tripwire --update-policy twpol.txt"
echo " "
echo "Done."

33
policy/templates/root.tpl Normal file
View File

@ -0,0 +1,33 @@
# These files change the behavior of the root account
(
rulename = "Root config files",
severity = 100
)
{
/root -> $(SEC_CRIT) ; # Catch all additions to /root
/root/.Xresources -> $(SEC_CONFIG) ;
/root/.bashrc -> $(SEC_CONFIG) ;
/root/.bash_profile -> $(SEC_CONFIG) ;
/root/.bash_logout -> $(SEC_CONFIG) ;
/root/.cshrc -> $(SEC_CONFIG) ;
/root/.tcshrc -> $(SEC_CONFIG) ;
#/root/Mail -> $(SEC_CONFIG) ;
#/root/mail -> $(SEC_CONFIG) ;
#/root/.amandahosts -> $(SEC_CONFIG) ;
#/root/.addressbook.lu -> $(SEC_CONFIG) ;
#/root/.addressbook -> $(SEC_CONFIG) ;
/root/.bash_history -> $(SEC_CONFIG) ;
#/root/.elm -> $(SEC_CONFIG) ;
/root/.esd_auth -> $(SEC_CONFIG) ;
#/root/.gnome_private -> $(SEC_CONFIG) ;
#/root/.gnome-desktop -> $(SEC_CONFIG) ;
/root/.gnome -> $(SEC_CONFIG) ;
/root/.ICEauthority -> $(SEC_CONFIG) ;
#/root/.mc -> $(SEC_CONFIG) ;
#/root/.pinerc -> $(SEC_CONFIG) ;
#/root/.sawfish -> $(SEC_CONFIG) ;
/root/.Xauthority -> $(SEC_CONFIG) -i ; # Changes Inode number on login
#/root/.xauth -> $(SEC_CONFIG) ;
#/root/.xsession-errors -> $(SEC_CONFIG) ;
}

47
policy/templates/sys.tpl Normal file
View File

@ -0,0 +1,47 @@
(
rulename = "Critical devices",
severity = $(SIG_HI),
recurse = false
)
{
/dev/kmem -> $(Device) ;
/dev/mem -> $(Device) ;
/dev/null -> $(Device) ;
/dev/zero -> $(Device) ;
/proc/devices -> $(Device) ;
/proc/net -> $(Device) ;
/proc/sys -> $(Device) ;
/proc/cpuinfo -> $(Device) ;
/proc/modules -> $(Device) ;
/proc/mounts -> $(Device) ;
/proc/dma -> $(Device) ;
/proc/filesystems -> $(Device) ;
/proc/pci -> $(Device) ;
/proc/interrupts -> $(Device) ;
/proc/driver/rtc -> $(Device) ;
/proc/ioports -> $(Device) ;
/proc/scsi -> $(Device) ;
/proc/kcore -> $(Device) ;
/proc/self -> $(Device) ;
/proc/kmsg -> $(Device) ;
/proc/stat -> $(Device) ;
/proc/ksyms -> $(Device) ;
/proc/loadavg -> $(Device) ;
/proc/uptime -> $(Device) ;
/proc/locks -> $(Device) ;
/proc/version -> $(Device) ;
/proc/mdstat -> $(Device) ;
/proc/meminfo -> $(Device) ;
/proc/cmdline -> $(Device) ;
/proc/misc -> $(Device) ;
/sys/block -> $(Device) ;
/sys/bus -> $(Device) ;
/sys/class -> $(Device) ;
/sys/devices -> $(Device) ;
/sys/firmware -> $(Device) ;
/sys/fs -> $(Device) ;
/sys/kernel -> $(Device) ;
/sys/module -> $(Device) ;
/sys/power -> $(Device) ;
}

View File

@ -0,0 +1,28 @@
# license:
#=============================================================================
#
# Copyright 2011 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
# Inc. in the United States and other countries. All rights reserved.
#
# Linux is a registered trademark of Linus Torvalds.
#
# UNIX is a registered trademark of The Open Group.
#
#=============================================================================
#
# Permission is granted to make and distribute verbatim copies of this document
# provided the copyright notice and this permission notice are preserved on all
# copies.
#
# Permission is granted to copy and distribute modified versions of this
# document under the conditions for verbatim copying, provided that the entire
# resulting derived work is distributed under the terms of a permission notice
# identical to this one.
#
# Permission is granted to copy and distribute translations of this document
# into another language, under the above conditions for modified versions,
# except that this permission notice may be stated in a translation approved by
# Tripwire, Inc.
#
# DCM

View File

@ -0,0 +1,90 @@
# identifier: tripwire IDS policy input file
# host: Fedora Core release 1 (Yarrow)
# version: 2.4.3
# maintainer: FRLinux <tripwire[AT]frlinux.net>
# validator: unvalidated
# date: Wed Sep 21 13:50:21 UTC 2011
# description:
# This is an example Tripwire Policy input file. It is intended as the
# starting point to creating your own custom Tripwire Policy. Referring
# to it, as well as the Tripwire Policy Guide, should give you enough
# information to make a good custom Tripwire Policy that better fits
# your configuration and security needs. This text version will be used
# by tripwire as input to create a proprietary type of file called a
# Tripwire Policy file, which will then be signed for further security.
# It is recommended that once you complete the creation of the Policy
# file, you move this plaintext version to a secure location (possibly
# on removable media) or encrypt the file using a tool such as GPG. You
# should also do this for the Tripwire plaintext configuration file
# (twcfg.txt) once you have finished setting up the Policy.
#
# Note that this file is tuned to an "everything" install of Fedora
# Linux. If run unmodified, this file should create no errors on
# database creation, or violations on a subsequent integrity check.
# However, it is impossible for there to be one policy file for all
# machines, so this existing one errs on the side of security. Your
# Linux configuration will most likely differ from the one our policy
# file was tuned to, and will therefore require some editing of the
# default Tripwire Policy file. The example policy file is best run
# with "Loose Directory Checking" enabled.
#
# Set LOOSEDIRECTORYCHECKING=TRUE in the Tripwire Configuration file.
#
# Note - legacy entries (which are commented out) are included for
# historical reasons only, and are overdue for removal. They will
# likely disappear from future releases.
#
# The following info is only really useful for non-RPM distributions:
#
# Email support is not included and must be added to this file. Add the
# "emailto=" to the rule directive section of each rule (add a comma
# after the "severity=" line and add an "emailto=" and include the
# email addresses you want the violation reports to go to). Addresses
# are semi-colon delimited.
#
# If you installed from the Fedora RPM, a cron job has already been set
# up for you. Tripwire will perform an integrity check once every day,
# and the generated report will be emailed to root. In this case, you
# do not need to perform the steps in the previous paragraph.
# policy:
# Global Variable Definitions
@@section GLOBAL
TWROOT=/usr/sbin;
TWBIN=/usr/sbin;
TWPOL="/etc/tripwire";
TWDB="/var/lib/tripwire";
TWSKEY="/etc/tripwire";
TWLKEY="/etc/tripwire";
TWREPORT="/var/lib/tripwire/report";
HOSTNAME=dub6041;
@@section FS
SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change
SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set
SEC_BIN = $(ReadOnly) ; # Binaries that should not change
SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often
SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership
SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
SIG_MED = 66 ; # Non-critical files that are of significant security impact
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
# Commonly accessed directories that should remain static with regards
# to owner and group.
(
rulename = "Invariant Directories",
severity = $(SIG_MED)
)
{
/ -> $(SEC_INVARIANT) (recurse = 0) ;
/home -> $(SEC_INVARIANT) (recurse = 0) ;
/etc -> $(SEC_INVARIANT) (recurse = 0) ;
}

281
policy/twpol-AIX.txt Normal file
View File

@ -0,0 +1,281 @@
##############################################################################
# ##
############################################################################## #
# # #
# Policy file for AIX 5.X # #
# ##
##############################################################################
##############################################################################
# ##
############################################################################## #
# # #
# 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
TWDOCS=;
TWROOT=;
TWBIN=;
TWPOL=;
TWDB=;
TWSKEY=;
TWLKEY=;
TWREPORT=;
HOSTNAME=;
##############################################################################
# Predefined Variables #
##############################################################################
#
# Property Masks
#
# - ignore the following properties
# + check the following properties
#
# a access timestamp (mutually exclusive with +CMSH)
# b number of blocks allocated
# c inode creation/modification timestamp
# d ID of device on which inode resides
# g group id of owner
# i inode number
# l growing files (logfiles for example)
# m modification timestamp
# n number of links
# p permission and file mode bits
# r ID of device pointed to by inode (valid only for device objects)
# s file size
# t file type
# u user id of owner
#
# C CRC-32 hash
# H HAVAL hash
# M MD5 hash
# S SHA hash
#
##############################################################################
Device = +pugsdr-intlbamcCMSH ;
Dynamic = +pinugtd-srlbamcCMSH ;
Growing = +pinugtdl-srbamcCMSH ;
IgnoreAll = -pinugtsdrlbamcCMSH ;
IgnoreNone = +pinugtsdrbamcCMSH-l ;
ReadOnly = +pinugtsdbmCM-rlacSH ;
Temporary = +pugt ;
@@section FS
########################################
# ##
######################################## #
# # #
# Tripwire Binaries and Data Files # #
# ##
########################################
# Tripwire Binaries
(
rulename = "Tripwire Binaries",
)
{
$(TWBIN)/siggen -> $(ReadOnly) ;
$(TWBIN)/tripwire -> $(ReadOnly) ;
$(TWBIN)/twadmin -> $(ReadOnly) ;
$(TWBIN)/twprint -> $(ReadOnly) ;
}
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
(
rulename = "Tripwire Data Files",
)
{
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
# it does so by renaming the old file and creating a new one (which will
# have a new inode number). Inode is left turned on for keys, which shouldn't
# ever change.
# NOTE: The first integrity check triggers this rule and each integrity check
# afterward triggers this rule until a database update is run, since the
# database file does not exist before that point.
$(TWDB) -> $(Dynamic) -i ;
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
$(TWSKEY)/site.key -> $(ReadOnly) ;
# don't scan the individual reports
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
}
################################################
# ##
################################################ #
# # #
# OS Boot and Configuration Files # #
# ##
################################################
(
rulename = "OS Boot and Configuration Files",
)
{
/etc -> $(IgnoreNone) -SHa ;
}
###################################################
# ##
################################################### #
# # #
# Mount Points # #
# ##
###################################################
(
rulename = "Mount Points",
)
{
/ -> $(ReadOnly) ;
/usr -> $(ReadOnly) ;
/var -> $(ReadOnly) ;
}
###################################################
# ##
################################################### #
# # #
# Misc Top-Level Directories # #
# ##
###################################################
(
rulename = "Misc Top-Level Directories",
)
{
/lost+found -> $(ReadOnly) ;
/hacmplocal -> $(ReadOnly) ;
/homelocal -> $(ReadOnly) ;
/opt -> $(ReadOnly) ;
!/var/adm/csd ;
}
################################################
# ##
################################################ #
# # #
# System Devices # #
# ##
################################################
(
rulename = "System Devices",
)
{
/dev -> $(Device) ;
}
################################################
# ##
################################################ #
# # #
# OS Binaries and Libraries # #
# ##
################################################
(
rulename = "OS Binaries and Libraries",
)
{
/sbin -> $(ReadOnly) ;
/usr/bin -> $(ReadOnly) ;
/usr/lib -> $(ReadOnly) ;
/usr/sbin -> $(ReadOnly) ;
}
################################################
# ##
################################################ #
# # #
# Root Directory and Files # #
# ##
################################################
(
rulename = "Root Directory and Files",
)
{
#/.dtprofile -> $(Dynamic) ;
! /.netscape/cache ;
/.netscape/history.dat -> $(Dynamic) ;
/.sh_history -> $(Dynamic) ;
#/.Xauthority -> $(ReadOnly) ;
}
################################################
# ##
################################################ #
# # #
# Temporary Directories # #
# ##
################################################
(
rulename = "Temporary Directories",
)
{
/tmp -> $(Temporary) ;
/var/tmp -> $(Temporary) ;
}
################################################
# ##
################################################ #
# # #
# Directories to Ignore # #
# ##
################################################
(
rulename = "Directories to Ignore",
)
{
!/proc ;
}
################################################
# ##
################################################ #
# # #
# System and Boot Changes # #
# ##
################################################
(
rulename = "System and Boot Changes",
)
{
/etc/es/objrepos -> $(ReadOnly) -SHacm ;
/etc/es/objrepos/HACMPresource -> $(ReadOnly) -SHCMcm ;
/etc/lpp/diagnostics/data -> $(ReadOnly) -SHCMacm ;
/etc/ntp.drift -> $(ReadOnly) -SHiacm ;
!/etc/objrepos ;
/etc/security -> $(ReadOnly) -SHacm ;
/usr/es/adm/cluster.log -> $(ReadOnly) -SHCMsbm ;
/usr/es/sbin/cluster/etc/objrepos/active -> $(ReadOnly) -SHim ;
!/usr/etc/sbin/cluster/history ;
/usr/share/lib/objrepos -> $(ReadOnly) -m ;
/usr/lib/objrepos -> $(ReadOnly) -m ;
!/var/adm/SPlogs ;
/var/ha/log -> $(Growing) -i ;
!/var/adm ;
!/var/ct ;
#/var/backups -> $(Dynamic) -i ;
#/var/db/host.random -> $(ReadOnly) -mCM ;
#/var/db/locate.database -> $(ReadOnly) -misCM ;
#/var/cron -> $(Growing) -i ;
#/var/log -> $(Growing) -i ;
#/var/run -> $(Dynamic) -i ;
#/var/mail -> $(Growing) ;
#/var/msgs/bounds -> $(ReadOnly) -smbCM ;
#/var/spool/clientmqueue -> $(Temporary) ;
#/var/spool/mqueue -> $(Temporary) ;
#!/var/tmp/vi.recover ; # perl script periodically removes this
}

381
policy/twpol-Darwin.txt Normal file
View File

@ -0,0 +1,381 @@
##############################################################################
# ##
############################################################################## #
# # #
# Policy file for Mac OS X # #
# September 3, 2003 # #
# ##
##############################################################################
##############################################################################
# ##
############################################################################## #
# # #
# Global Variable Definitions # #
# # #
# These are defined at install time by the installation script. You may # #
# manually edit these if you are using this file directly and not from the # #
# installation script itself. # #
# ##
##############################################################################
@@section GLOBAL
TWROOT=;
TWBIN=;
TWPOL=;
TWDB=;
TWSKEY=;
TWLKEY=;
TWREPORT=;
#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) ;
#/private/var/cron/tabs/.sock -> $(SEC_DEVICE) ;
}
################################################
# ##
################################################ #
# # #
# 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/X11R6 -> $(SEC_READONLY)(recurse=2) ; # May not be present
#/usr/X11R6/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) ;
"/Applications (Mac OS 9)" -> $(SEC_READONLY) ;
!/Applications/Internet/P2P/Downloads ;
!/Applications/Games/"Warcraft III Folder"/Save ;
}
################################################
# ##
################################################ #
# # #
# Usr Local Files # #
# ##
################################################
(
rulename = "Usr Local Files", severity=60
)
{
/usr/local -> $(SEC_READONLY) ;
#/usr/local/bin -> $(SEC_READONLY) ;
/usr/local/etc -> $(SEC_READONLY) ;
#/usr/local/sbin -> $(SEC_READONLY) ;
#/usr/local/share -> $(SEC_READONLY) ;
}
################################################
# ##
################################################ #
# # #
# Temporary Files and Directories # #
# ##
################################################
(
rulename = "Variable System Files", severity=60
)
{
/private/tmp -> $(SEC_DYNAMIC)-in(recurse=0) ;
/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/samba/secrets.tdb ;
}
################################################
# ##
################################################ #
# # #
# Classic Environment # #
# ##
################################################
(
rulename = "Classic Environment", severity=100
)
{
/"System Folder" -> $(SEC_READONLY) ;
/"System Folder"/Preferences -> $(SEC_DYNAMIC)-i(recurse=0) ;
/"System Folder"/Extensions -> $(SEC_READONLY)-im ;
/"System Folder/Apple Menu Items" -> $(SEC_READONLY)-im(recurse=0) ;
/"System Folder"/Clipboard -> $(SEC_DYNAMIC) ;
!/"System Folder"/VolumeNameIconPict ;
}
###################################################
# ##
################################################### #
# # #
# 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" ;
}
#
# JTI
#

655
policy/twpol-FreeBSD.txt Normal file
View File

@ -0,0 +1,655 @@
#
# Policy file for FreeBSD
#
# $FreeBSD: ports/security/tripwire/files/twpol.txt,v 1.2 2002/03/04 16:55:21 cy Exp $
# $Id: twpol-FreeBSD.txt,v 1.1 2003/06/08 02:00:06 pherman Exp $
#
# This is the example Tripwire Policy file. It is intended as a place to
# start creating your own custom Tripwire Policy file. Referring to it as
# well as the Tripwire Policy Guide should give you enough information to
# make a good custom Tripwire Policy file that better covers your
# configuration and security needs. A text version of this policy file is
# called twpol.txt.
#
# Note that this file is tuned to an install of FreeBSD using
# buildworld. If run unmodified, this file should create no errors on
# database creation, or violations on a subsiquent integrity check.
# However it is impossible for there to be one policy file for all machines,
# so this existing one errs on the side of security. Your FreeBSD
# configuration will most likey differ from the one our policy file was
# tuned to, and will therefore require some editing of the default
# Tripwire Policy file.
#
# The example policy file is best run with 'Loose Directory Checking'
# enabled. Set LOOSEDIRECTORYCHECKING=TRUE in the Tripwire Configuration
# file.
#
# Email support is not included and must be added to this file.
# Add the 'emailto=' to the rule directive section of each rule (add a comma
# after the 'severity=' line and add an 'emailto=' and include the email
# addresses you want the violation reports to go to). Addresses are
# semi-colon delimited.
#
#
# Global Variable Definitions
#
# These are defined at install time by the installation script. You may
# Manually edit these if you are using this file directly and not from the
# installation script itself.
#
@@section GLOBAL
TWROOT=;
TWBIN=;
TWPOL=;
TWDB=;
TWSKEY=;
TWLKEY=;
TWREPORT=;
HOSTNAME=;
@@section FS
SEC_CRIT = $(IgnoreNone)-SHa ; # Critical files that cannot change
SEC_SUID = $(IgnoreNone)-SHa ; # Binaries with the SUID or SGID flags set
SEC_BIN = $(ReadOnly) ; # Binaries that should not change
SEC_CONFIG = $(Dynamic) ; # Config files that are changed infrequently but accessed often
SEC_TTY = $(Dynamic)-ugp ; # Tty files that change ownership at login
SEC_LOG = $(Growing) ; # Files that grow, but that should never change ownership
SEC_INVARIANT = +tpug ; # Directories that should never change permission or ownership
SIG_LOW = 33 ; # Non-critical files that are of minimal security impact
SIG_MED = 66 ; # Non-critical files that are of significant security impact
SIG_HI = 100 ; # Critical files that are significant points of vulnerability
# Tripwire Binaries
(
rulename = "Tripwire Binaries",
severity = $(SIG_HI)
)
{
$(TWBIN)/siggen -> $(SEC_BIN) ;
$(TWBIN)/tripwire -> $(SEC_BIN) ;
$(TWBIN)/twadmin -> $(SEC_BIN) ;
$(TWBIN)/twprint -> $(SEC_BIN) ;
}
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
(
rulename = "Tripwire Data Files",
severity = $(SIG_HI)
)
{
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
# it does so by renaming the old file and creating a new one (which will
# have a new inode number). Inode is left turned on for keys, which shouldn't
# ever change.
# NOTE: The first integrity check triggers this rule and each integrity check
# afterward triggers this rule until a database update is run, since the
# database file does not exist before that point.
$(TWDB) -> $(SEC_CONFIG) -i ;
$(TWPOL)/tw.pol -> $(SEC_BIN) -i ;
$(TWPOL)/tw.cfg -> $(SEC_BIN) -i ;
$(TWPOL)/twcfg.txt -> $(SEC_BIN) ;
$(TWPOL)/twpol.txt -> $(SEC_BIN) ;
$(TWLKEY)/$(HOSTNAME)-local.key -> $(SEC_BIN) ;
$(TWSKEY)/site.key -> $(SEC_BIN) ;
#don't scan the individual reports
$(TWREPORT) -> $(SEC_CONFIG) (recurse=0) ;
}
# Tripwire HQ Connector Binaries
#(
# rulename = "Tripwire HQ Connector Binaries",
# severity = $(SIG_HI)
#)
#{
# $(TWBIN)/hqagent -> $(SEC_BIN) ;
#}
#
# Tripwire HQ Connector - Configuration Files, Keys, and Logs
#
# Note: File locations here are different than in a stock HQ Connector
# installation. This is because Tripwire 2.3 uses a different path
# structure than Tripwire 2.2.1.
#
# You may need to update your HQ Agent configuation file (or this policy
# file) to correct the paths. We have attempted to support the FHS standard
# here by placing the HQ Agent files similarly to the way Tripwire 2.3
# places them.
#
#(
# rulename = "Tripwire HQ Connector Data Files",
# severity = $(SIG_HI)
#)
#{
#
# # NOTE: Removing the inode attribute because when Tripwire creates a backup
# # it does so by renaming the old file and creating a new one (which will
# # have a new inode number). Leaving inode turned on for keys, which
# # shouldn't ever change.
#
#
# $(TWBIN)/agent.cfg -> $(SEC_BIN) -i ;
# $(TWLKEY)/authentication.key -> $(SEC_BIN) ;
# $(TWDB)/tasks.dat -> $(SEC_CONFIG) ;
# $(TWDB)/schedule.dat -> $(SEC_CONFIG) ;
#
# # Uncomment if you have agent logging enabled.
# #/var/log/tripwire/agent.log -> $(SEC_LOG) ;
#}
# Commonly accessed directories that should remain static with regards to owner and group
(
rulename = "Invariant Directories",
severity = $(SIG_MED)
)
{
/ -> $(SEC_INVARIANT) (recurse = false) ;
/home -> $(SEC_INVARIANT) (recurse = false) ;
}
#
# First, root's "home"
#
(
rulename = "Root's home",
severity = $(SIG_HI)
)
{
# /.rhosts -> $(SEC_CRIT) ;
/.profile -> $(SEC_CRIT) ;
/.cshrc -> $(SEC_CRIT) ;
/.login -> $(SEC_CRIT) ;
# /.exrc -> $(SEC_CRIT) ;
# /.logout -> $(SEC_CRIT) ;
# /.forward -> $(SEC_CRIT) ;
/root -> $(SEC_CRIT) (recurse = true) ;
!/root/.history ;
!/root/.bash_history ;
# !/root/.lsof_SYSTEM_NAME ; # Uncomment if lsof is installed
}
#
# FreeBSD Kernel
#
(
rulename = "FreeBSD Kernel",
severity = $(SIG_HI)
)
{
/kernel -> $(SEC_CRIT) ;
/kernel.old -> $(SEC_CRIT) ;
/kernel.GENERIC -> $(SEC_CRIT) ;
}
#
# FreeBSD Modules
#
(
rulename = "FreeBSD Modules",
severity = $(SIG_HI)
)
{
/modules -> $(SEC_CRIT) (recurse = true) ;
/modules.old -> $(SEC_CRIT) (recurse = true) ;
# /lkm -> $(SEC_CRIT) (recurse = true) ; # uncomment if using lkm kld
}
#
# System Administration Programs
#
(
rulename = "System Administration Programs",
severity = $(SIG_HI)
)
{
/sbin -> $(SEC_CRIT) (recurse = true) ;
/usr/sbin -> $(SEC_CRIT) (recurse = true) ;
}
#
# User Utilities
#
(
rulename = "User Utilities",
severity = $(SIG_HI)
)
{
/bin -> $(SEC_CRIT) (recurse = true) ;
/usr/bin -> $(SEC_CRIT) (recurse = true) ;
}
#
# /dev
#
(
rulename = "/dev",
severity = $(SIG_HI)
)
{
/dev -> $(Device) (recurse = true) ;
!/dev/vga ;
!/dev/dri ;
/dev/console -> $(SEC_TTY) ;
/dev/ttyv0 -> $(SEC_TTY) ;
/dev/ttyv1 -> $(SEC_TTY) ;
/dev/ttyv2 -> $(SEC_TTY) ;
/dev/ttyv3 -> $(SEC_TTY) ;
/dev/ttyv4 -> $(SEC_TTY) ;
/dev/ttyv5 -> $(SEC_TTY) ;
/dev/ttyv6 -> $(SEC_TTY) ;
/dev/ttyv7 -> $(SEC_TTY) ;
/dev/ttyp0 -> $(SEC_TTY) ;
/dev/ttyp1 -> $(SEC_TTY) ;
/dev/ttyp2 -> $(SEC_TTY) ;
/dev/ttyp3 -> $(SEC_TTY) ;
/dev/ttyp4 -> $(SEC_TTY) ;
/dev/ttyp5 -> $(SEC_TTY) ;
/dev/ttyp6 -> $(SEC_TTY) ;
/dev/ttyp7 -> $(SEC_TTY) ;
/dev/ttyp8 -> $(SEC_TTY) ;
/dev/ttyp9 -> $(SEC_TTY) ;
/dev/ttypa -> $(SEC_TTY) ;
/dev/ttypb -> $(SEC_TTY) ;
/dev/ttypc -> $(SEC_TTY) ;
/dev/ttypd -> $(SEC_TTY) ;
/dev/ttype -> $(SEC_TTY) ;
/dev/ttypf -> $(SEC_TTY) ;
/dev/ttypg -> $(SEC_TTY) ;
/dev/ttyph -> $(SEC_TTY) ;
/dev/ttypi -> $(SEC_TTY) ;
/dev/ttypj -> $(SEC_TTY) ;
/dev/ttypl -> $(SEC_TTY) ;
/dev/ttypm -> $(SEC_TTY) ;
/dev/ttypn -> $(SEC_TTY) ;
/dev/ttypo -> $(SEC_TTY) ;
/dev/ttypp -> $(SEC_TTY) ;
/dev/ttypq -> $(SEC_TTY) ;
/dev/ttypr -> $(SEC_TTY) ;
/dev/ttyps -> $(SEC_TTY) ;
/dev/ttypt -> $(SEC_TTY) ;
/dev/ttypu -> $(SEC_TTY) ;
/dev/ttypv -> $(SEC_TTY) ;
/dev/cuaa0 -> $(SEC_TTY) ; # modem
}
#
# /etc
#
(
rulename = "/etc",
severity = $(SIG_HI)
)
{
/etc -> $(SEC_CRIT) (recurse = true) ;
# /etc/mail/aliases -> $(SEC_CONFIG) ;
/etc/dumpdates -> $(SEC_CONFIG) ;
/etc/motd -> $(SEC_CONFIG) ;
!/etc/ppp/connect-errors ;
/etc/skeykeys -> $(SEC_CONFIG) ;
# Uncomment the following 4 lines if your password file does not change
# /etc/passwd -> $(SEC_CONFIG) ;
# /etc/master.passwd -> $(SEC_CONFIG) ;
# /etc/pwd.db -> $(SEC_CONFIG) ;
# /etc/spwd.db -> $(SEC_CONFIG) ;
}
#
# Copatibility (Linux)
#
(
rulename = "Linux Compatibility",
severity = $(SIG_HI)
)
{
/compat -> $(SEC_CRIT) (recurse = true) ;
#
# Uncomment the following if Linux compatibility is used. Replace
# HOSTNAME1 and HOSTNAME2 with the hosts that have Linux emulation port
# installed.
#
#@@ifhost HOSTNAME1 || HOSTNAME2
# /compat/linux/etc -> $(SEC_INVARIANT) (recurse = false) ;
# /compat/linux/etc/X11 -> $(SEC_CONFIG) (recurse = true) ;
# /compat/linux/etc/pam.d -> $(SEC_CONFIG) (recurse = true) ;
# /compat/linux/etc/profile.d -> $(SEC_CONFIG) (recurse = true) ;
# /compat/linux/etc/real -> $(SEC_CONFIG) (recurse = true) ;
# /compat/linux/etc/bashrc -> $(SEC_CONFIG) ;
# /compat/linux/etc/csh.login -> $(SEC_CONFIG) ;
# /compat/linux/etc/host.conf -> $(SEC_CONFIG) ;
# /compat/linux/etc/hosts.allow -> $(SEC_CONFIG) ;
# /compat/linux/etc/hosts.deny -> $(SEC_CONFIG) ;
# /compat/linux/etc/info-dir -> $(SEC_CONFIG) ;
# /compat/linux/etc/inputrc -> $(SEC_CONFIG) ;
# /compat/linux/etc/ld.so.conf -> $(SEC_CONFIG) ;
# /compat/linux/etc/nsswitch.conf -> $(SEC_CONFIG) ;
# /compat/linux/etc/profile -> $(SEC_CONFIG) ;
# /compat/linux/etc/redhat-release -> $(SEC_CONFIG) ;
# /compat/linux/etc/rpc -> $(SEC_CONFIG) ;
# /compat/linux/etc/securetty -> $(SEC_CONFIG) ;
# /compat/linux/etc/shells -> $(SEC_CONFIG) ;
# /compat/linux/etc/termcap -> $(SEC_CONFIG) ;
# /compat/linux/etc/yp.conf -> $(SEC_CONFIG) ;
# !/compat/linux/etc/ld.so.cache ;
# !/compat/linux/var/spool/mail ;
#@@endif
}
#
# Libraries, include files, and other system files
#
(
rulename = "Libraries, include files, and other system files",
severity = $(SIG_HI)
)
{
/usr/include -> $(SEC_CRIT) (recurse = true) ;
/usr/lib -> $(SEC_CRIT) (recurse = true) ;
/usr/libdata -> $(SEC_CRIT) (recurse = true) ;
/usr/libexec -> $(SEC_CRIT) (recurse = true) ;
/usr/share -> $(SEC_CRIT) (recurse = true) ;
/usr/share/man -> $(SEC_CONFIG) ;
!/usr/share/man/whatis ;
!/usr/share/man/.glimpse_filenames ;
!/usr/share/man/.glimpse_filenames_index ;
!/usr/share/man/.glimpse_filetimes ;
!/usr/share/man/.glimpse_filters ;
!/usr/share/man/.glimpse_index ;
!/usr/share/man/.glimpse_messages ;
!/usr/share/man/.glimpse_partitions ;
!/usr/share/man/.glimpse_statistics ;
!/usr/share/man/.glimpse_turbo ;
/usr/share/man/man1 -> $(SEC_CRIT) (recurse = true) ;
/usr/share/man/man2 -> $(SEC_CRIT) (recurse = true) ;
/usr/share/man/man3 -> $(SEC_CRIT) (recurse = true) ;
/usr/share/man/man4 -> $(SEC_CRIT) (recurse = true) ;
/usr/share/man/man5 -> $(SEC_CRIT) (recurse = true) ;
/usr/share/man/man6 -> $(SEC_CRIT) (recurse = true) ;
/usr/share/man/man7 -> $(SEC_CRIT) (recurse = true) ;
/usr/share/man/man8 -> $(SEC_CRIT) (recurse = true) ;
/usr/share/man/man9 -> $(SEC_CRIT) (recurse = true) ;
/usr/share/man/mann -> $(SEC_CRIT) (recurse = true) ;
! /usr/share/man/cat1 ;
! /usr/share/man/cat2 ;
! /usr/share/man/cat3 ;
! /usr/share/man/cat4 ;
! /usr/share/man/cat5 ;
! /usr/share/man/cat6 ;
! /usr/share/man/cat7 ;
! /usr/share/man/cat8 ;
! /usr/share/man/cat9 ;
! /usr/share/man/catl ;
! /usr/share/man/catn ;
/usr/share/perl/man -> $(SEC_CONFIG) ;
!/usr/share/perl/man/whatis ;
!/usr/share/perl/man/.glimpse_filenames ;
!/usr/share/perl/man/.glimpse_filenames_index ;
!/usr/share/perl/man/.glimpse_filetimes ;
!/usr/share/perl/man/.glimpse_filters ;
!/usr/share/perl/man/.glimpse_index ;
!/usr/share/perl/man/.glimpse_messages ;
!/usr/share/perl/man/.glimpse_partitions ;
!/usr/share/perl/man/.glimpse_statistics ;
!/usr/share/perl/man/.glimpse_turbo ;
/usr/share/perl/man/man3 -> $(SEC_CRIT) (recurse = true) ;
! /usr/share/perl/man/cat3 ;
/usr/local/lib/perl5/5.00503/man -> $(SEC_CONFIG) ;
! /usr/local/lib/perl5/5.00503/man/whatis ;
! /usr/local/lib/perl5/5.00503/man/.glimpse_filters ;
! /usr/local/lib/perl5/5.00503/man/.glimpse_filetimes ;
! /usr/local/lib/perl5/5.00503/man/.glimpse_messages ;
! /usr/local/lib/perl5/5.00503/man/.glimpse_statistics ;
! /usr/local/lib/perl5/5.00503/man/.glimpse_index ;
! /usr/local/lib/perl5/5.00503/man/.glimpse_turbo ;
! /usr/local/lib/perl5/5.00503/man/.glimpse_partitions ;
! /usr/local/lib/perl5/5.00503/man/.glimpse_filenames ;
! /usr/local/lib/perl5/5.00503/man/.glimpse_filenames_index ;
/usr/local/lib/perl5/5.00503/man/man3 -> $(SEC_CRIT) (recurse = true) ;
! /usr/local/lib/perl5/5.00503/man/cat3 ;
}
#
# X11R6
#
(
rulename = "X11R6",
severity = $(SIG_HI)
)
{
/usr/X11R6 -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/lib/X11/xdm -> $(SEC_CONFIG) (recurse = true) ;
!/usr/X11R6/lib/X11/xdm/xdm-errors ;
!/usr/X11R6/lib/X11/xdm/authdir/authfiles ;
!/usr/X11R6/lib/X11/xdm/xdm-pid ;
/usr/X11R6/lib/X11/xkb/compiled -> $(SEC_CONFIG) (recurse = true) ;
/usr/X11R6/man -> $(SEC_CONFIG) ;
!/usr/X11R6/man/whatis ;
!/usr/X11R6/man/.glimpse_filenames ;
!/usr/X11R6/man/.glimpse_filenames_index ;
!/usr/X11R6/man/.glimpse_filetimes ;
!/usr/X11R6/man/.glimpse_filters ;
!/usr/X11R6/man/.glimpse_index ;
!/usr/X11R6/man/.glimpse_messages ;
!/usr/X11R6/man/.glimpse_partitions ;
!/usr/X11R6/man/.glimpse_statistics ;
!/usr/X11R6/man/.glimpse_turbo ;
/usr/X11R6/man/man1 -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/man/man2 -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/man/man3 -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/man/man4 -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/man/man5 -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/man/man6 -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/man/man7 -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/man/man8 -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/man/man9 -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/man/manl -> $(SEC_CRIT) (recurse = true) ;
/usr/X11R6/man/mann -> $(SEC_CRIT) (recurse = true) ;
! /usr/X11R6/man/cat1 ;
! /usr/X11R6/man/cat2 ;
! /usr/X11R6/man/cat3 ;
! /usr/X11R6/man/cat4 ;
! /usr/X11R6/man/cat5 ;
! /usr/X11R6/man/cat6 ;
! /usr/X11R6/man/cat7 ;
! /usr/X11R6/man/cat8 ;
! /usr/X11R6/man/cat9 ;
! /usr/X11R6/man/catl ;
! /usr/X11R6/man/catn ;
}
#
# sources
#
(
rulename = "Sources",
severity = $(SIG_HI)
)
{
/usr/src -> $(SEC_CRIT) (recurse = true) ;
/usr/src/sys/compile -> $(SEC_CONFIG) (recurse = false) ;
}
#
# NIS
#
(
rulename = "NIS",
severity = $(SIG_HI)
)
{
/var/yp -> $(SEC_CRIT) (recurse = true) ;
!/var/yp/binding ;
}
#
# Temporary directories
#
(
rulename = "Temporary directories",
recurse = false,
severity = $(SIG_LOW)
)
{
/usr/tmp -> $(SEC_INVARIANT) ;
/var/tmp -> $(SEC_INVARIANT) ;
/var/preserve -> $(SEC_INVARIANT) ;
/tmp -> $(SEC_INVARIANT) ;
}
#
# Local files
#
(
rulename = "Local files",
severity = $(SIG_MED)
)
{
/usr/local/bin -> $(SEC_BIN) (recurse = true) ;
/usr/local/sbin -> $(SEC_BIN) (recurse = true) ;
/usr/local/etc -> $(SEC_BIN) (recurse = true) ;
/usr/local/lib -> $(SEC_BIN) (recurse = true ) ;
/usr/local/libexec -> $(SEC_BIN) (recurse = true ) ;
/usr/local/share -> $(SEC_BIN) (recurse = true ) ;
/usr/local/man -> $(SEC_CONFIG) ;
!/usr/local/man/whatis ;
!/usr/local/man/.glimpse_filenames ;
!/usr/local/man/.glimpse_filenames_index ;
!/usr/local/man/.glimpse_filetimes ;
!/usr/local/man/.glimpse_filters ;
!/usr/local/man/.glimpse_index ;
!/usr/local/man/.glimpse_messages ;
!/usr/local/man/.glimpse_partitions ;
!/usr/local/man/.glimpse_statistics ;
!/usr/local/man/.glimpse_turbo ;
/usr/local/man/man1 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/man/man2 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/man/man3 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/man/man4 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/man/man5 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/man/man6 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/man/man7 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/man/man8 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/man/man9 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/man/manl -> $(SEC_CRIT) (recurse = true) ;
/usr/local/man/mann -> $(SEC_CRIT) (recurse = true) ;
! /usr/local/man/cat1 ;
! /usr/local/man/cat2 ;
! /usr/local/man/cat3 ;
! /usr/local/man/cat4 ;
! /usr/local/man/cat5 ;
! /usr/local/man/cat6 ;
! /usr/local/man/cat7 ;
! /usr/local/man/cat8 ;
! /usr/local/man/cat9 ;
! /usr/local/man/catl ;
! /usr/local/man/catn ;
/usr/local/krb5 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man -> $(SEC_CONFIG) ;
!/usr/local/krb5/man/whatis ;
!/usr/local/krb5/man/.glimpse_filenames ;
!/usr/local/krb5/man/.glimpse_filenames_index ;
!/usr/local/krb5/man/.glimpse_filetimes ;
!/usr/local/krb5/man/.glimpse_filters ;
!/usr/local/krb5/man/.glimpse_index ;
!/usr/local/krb5/man/.glimpse_messages ;
!/usr/local/krb5/man/.glimpse_partitions ;
!/usr/local/krb5/man/.glimpse_statistics ;
!/usr/local/krb5/man/.glimpse_turbo ;
/usr/local/krb5/man/man1 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man/man2 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man/man3 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man/man4 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man/man5 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man/man6 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man/man7 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man/man8 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man/man9 -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man/manl -> $(SEC_CRIT) (recurse = true) ;
/usr/local/krb5/man/mann -> $(SEC_CRIT) (recurse = true) ;
! /usr/local/krb5/man/cat1 ;
! /usr/local/krb5/man/cat2 ;
! /usr/local/krb5/man/cat3 ;
! /usr/local/krb5/man/cat4 ;
! /usr/local/krb5/man/cat5 ;
! /usr/local/krb5/man/cat6 ;
! /usr/local/krb5/man/cat7 ;
! /usr/local/krb5/man/cat8 ;
! /usr/local/krb5/man/cat9 ;
! /usr/local/krb5/man/catl ;
! /usr/local/krb5/man/catn ;
/usr/local/www -> $(SEC_CONFIG) (recurse = true) ;
}
(
rulename = "Security Control",
severity = $(SIG_HI)
)
{
/etc/group -> $(SEC_CRIT) ;
/etc/crontab -> $(SEC_CRIT) ;
}
#=============================================================================
#
# Copyright 2000 Tripwire, Inc. Tripwire is a registered trademark of Tripwire,
# Inc. in the United States and other countries. All rights reserved.
#
# FreeBSD is a registered trademark of the FreeBSD Project Inc.
#
# UNIX is a registered trademark of The Open Group.
#
#=============================================================================
#
# Permission is granted to make and distribute verbatim copies of this document
# provided the copyright notice and this permission notice are preserved on all
# copies.
#
# Permission is granted to copy and distribute modified versions of this
# document under the conditions for verbatim copying, provided that the entire
# resulting derived work is distributed under the terms of a permission notice
# identical to this one.
#
# Permission is granted to copy and distribute translations of this document
# into another language, under the above conditions for modified versions,
# except that this permission notice may be stated in a translation approved by
# Tripwire, Inc.
#
# DCM

1107
policy/twpol-GENERIC.txt Normal file

File diff suppressed because it is too large Load Diff

355
policy/twpol-Linux.txt Normal file
View File

@ -0,0 +1,355 @@
##############################################################################
# ##
############################################################################## #
# # #
# Policy file for Red Hat Linux # #
# ##
##############################################################################
##############################################################################
# ##
############################################################################## #
# # #
# Global Variable Definitions # #
# # #
# These are defined at install time by the installation script. You may # #
# Manually edit these if you are using this file directly and not from the # #
# installation script itself. # #
# ##
##############################################################################
@@section GLOBAL
TWROOT=;
TWBIN=;
TWPOL=;
TWDB=;
TWSKEY=;
TWLKEY=;
TWREPORT=;
HOSTNAME=;
##############################################################################
# Predefined Variables #
##############################################################################
#
# Property Masks
#
# - ignore the following properties
# + check the following properties
#
# a access timestamp (mutually exclusive with +CMSH)
# b number of blocks allocated
# c inode creation/modification timestamp
# d ID of device on which inode resides
# g group id of owner
# i inode number
# l growing files (logfiles for example)
# m modification timestamp
# n number of links
# p permission and file mode bits
# r ID of device pointed to by inode (valid only for device objects)
# s file size
# t file type
# u user id of owner
#
# C CRC-32 hash
# H HAVAL hash
# M MD5 hash
# S SHA hash
#
##############################################################################
Device = +pugsdr-intlbamcCMSH ;
Dynamic = +pinugtd-srlbamcCMSH ;
Growing = +pinugtdl-srbamcCMSH ;
IgnoreAll = -pinugtsdrlbamcCMSH ;
IgnoreNone = +pinugtsdrbamcCMSH-l ;
ReadOnly = +pinugtsdbmCM-rlacSH ;
Temporary = +pugt ;
@@section FS
########################################
# ##
######################################## #
# # #
# Tripwire Binaries and Data Files # #
# ##
########################################
# Tripwire Binaries
(
rulename = "Tripwire Binaries",
)
{
$(TWBIN)/siggen -> $(ReadOnly) ;
$(TWBIN)/tripwire -> $(ReadOnly) ;
$(TWBIN)/twadmin -> $(ReadOnly) ;
$(TWBIN)/twprint -> $(ReadOnly) ;
}
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
(
rulename = "Tripwire Data Files",
)
{
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
# it does so by renaming the old file and creating a new one (which will
# have a new inode number). Inode is left turned on for keys, which shouldn't
# ever change.
# NOTE: The first integrity check triggers this rule and each integrity check
# afterward triggers this rule until a database update is run, since the
# database file does not exist before that point.
$(TWDB) -> $(Dynamic) -i ;
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
$(TWSKEY)/site.key -> $(ReadOnly) ;
# don't scan the individual reports
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
}
################################################
# ##
################################################ #
# # #
# RPM Checksum Files # #
# ##
################################################
(
rulename = "RPM Checksum Files",
)
{
/var/lib/rpm -> $(ReadOnly);
/var/lib/rpm/__db.001 -> $(Dynamic) ;
/var/lib/rpm/__db.002 -> $(Dynamic) ;
/var/lib/rpm/__db.003 -> $(Dynamic) ;
}
################################################
# ##
################################################ #
# # #
# Global Configuration Files (/etc/) # #
# ##
################################################
(
rulename = "Global Configuration Files",
)
{
/etc -> $(IgnoreNone) -SHa ;
/etc/adjtime -> $(Dynamic) ;
/etc/aliases.db -> $(Dynamic) ;
/etc/bashrc -> $(Dynamic) ;
/etc/csh.cshrc -> $(Dynamic) ;
/etc/csh.login -> $(Dynamic) ;
/etc/mail/statistics -> $(Growing) ;
/etc/profile -> $(Dynamic) -i ;
/etc/mtab -> $(Dynamic) -i ;
/etc/rc.d -> $(IgnoreNone) -SHa ;
/etc/sysconfig -> $(IgnoreNone) -SHa ;
/etc/sysconfig/hwconf -> $(Dynamic) -m ;
}
################################################
# ##
################################################ #
# # #
# OS Boot Files and Mount Points # #
# ##
################################################
(
rulename = "OS Boot Files and Mount Points",
)
{
/boot -> $(ReadOnly) ;
/cdrom -> $(Dynamic) ;
/floppy -> $(Dynamic) ;
/mnt -> $(Dynamic) ;
}
################################################
# ##
################################################ #
# # #
# OS Devices and Misc Directories # #
# ##
################################################
(
rulename = "OS Devices and Misc Directories",
)
{
/dev -> $(Device) ;
/initrd -> $(Dynamic) ;
/opt -> $(Dynamic) ;
/lost+found -> $(Dynamic) ;
/var/lost+found -> $(Dynamic) ;
/home/lost+found -> $(Dynamic) ;
!/dev/pts ; # Ignore this file
!/dev/shm ; # Ignore this file
}
################################################
# ##
################################################ #
# # #
# OS Binaries and Libraries # #
# ##
################################################
(
rulename = "OS Binaries and Libraries",
)
{
/bin -> $(ReadOnly) ;
/lib -> $(ReadOnly) ;
/sbin -> $(ReadOnly) ;
/usr/bin -> $(ReadOnly) ;
/usr/lib -> $(ReadOnly) ;
/usr/libexec -> $(ReadOnly) ;
/usr/sbin -> $(ReadOnly) ;
/usr/X11R6/lib -> $(ReadOnly) ;
}
################################################
# ##
################################################ #
# # #
# User Binaries and Libraries # #
# ##
################################################
(
rulename = "User Binaries and Libraries",
)
{
!/home/local;
/usr/local -> $(ReadOnly) ;
/usr/local/bin -> $(ReadOnly) ;
/usr/local/doc -> $(ReadOnly) ;
/usr/local/etc -> $(ReadOnly) ;
/usr/local/games -> $(ReadOnly) ;
/usr/local/include -> $(ReadOnly) ;
/usr/local/lib -> $(ReadOnly) ;
/usr/local/libexec -> $(ReadOnly) ;
/usr/local/man -> $(ReadOnly) ;
/usr/local/sbin -> $(ReadOnly) ;
/usr/local/share -> $(ReadOnly) ;
/usr/local/src -> $(ReadOnly) ;
/usr/local/sysinfo -> $(ReadOnly) ;
}
################################################
# ##
################################################ #
# # #
# Root Directory and Files # #
# ##
################################################
(
rulename = "Root Directory and Files",
)
{
/root -> $(IgnoreNone) -SHa ;
/root/.bashrc -> $(Dynamic) ;
/root/.bash_history -> $(Dynamic) ;
#/root/.bash_logout -> $(Dynamic) ;
/root/.bash_profile -> $(Dynamic) ;
/root/.cshrc -> $(Dynamic) ;
#/root/.enlightenment -> $(Dynamic) ;
#/root/.esd-auth -> $(Dynamic) ;
!/root/.gconf ;
!/root/.gconfd ;
#/root/.gnome -> $(Dynamic) ;
#/root/.gnome-desktop -> $(Dynamic) ;
#/root/.gnome2 -> $(Dynamic) ;
#/root/.gtkrc -> $(Dynamic) ;
#/root/.gtkrc-1.2-gnome2 -> $(Dynamic) ;
#/root/.metacity -> $(Dynamic) ;
#/root/.nautilus -> $(Dynamic) ;
#/root/.rhn-applet.conf -> $(Dynamic) ;
#/root/.tcshrc -> $(Dynamic) ;
#/root/.xauth -> $(Dynamic) ;
#/root/.ICEauthority -> $(Dynamic) ;
#/root/.Xauthority -> $(Dynamic) -i ;
#/root/.Xresources -> $(Dynamic) ;
}
################################################
# ##
################################################ #
# # #
# Temporary Directories # #
# ##
################################################
(
rulename = "Temporary Directories",
)
{
/usr/tmp -> $(Temporary) ;
/var/tmp -> $(Temporary) ;
/tmp -> $(Temporary) ;
#/tmp/.fam-socket -> $(Temporary) ;
#/tmp/.ICE-unix -> $(Temporary) ;
#/tmp/.X11-unix -> $(Temporary) ;
!/tmp/orbit-root ;
}
################################################
# ##
################################################ #
# # #
# System Boot Changes # #
# ##
################################################
(
rulename = "System Boot Changes",
)
{
/.autofsck -> $(Dynamic) -m ;
/var/cache/man/whatis -> $(Growing) ;
/var/lib/logrotate.status -> $(Growing) ;
#/var/lib/nfs/statd -> $(Growing) ;
!/var/lib/random-seed ;
#/var/lib/slocate/slocate.db -> $(Growing) -is ;
/var/lock/subsys -> $(Dynamic) -i ;
/var/log -> $(Growing) -i ;
!/var/log/sa;
!/var/log/cisco;
/var/run -> $(Dynamic) -i ;
/etc/cron.daily -> $(Growing);
/etc/cron.weekly -> $(Growing);
/etc/cron.monthly -> $(Growing);
/var/spool/mail -> $(Growing);
}
################################################
# ##
################################################ #
# # #
# Monitor Filesystems # #
# ##
################################################
(
rulename = "Monitor Filesystems",
)
{
/ -> $(ReadOnly) ;
/home -> $(ReadOnly) ; # Modify as needed
/usr -> $(ReadOnly) ;
/var -> $(ReadOnly) ;
}
################################################
# ##
################################################ #
# # #
# Proc Filesystem # #
# ##
################################################
(
rulename = "Proc Filesystem",
)
{
!/proc ; # Ignore most of this directory
}

292
policy/twpol-OpenBSD.txt Normal file
View File

@ -0,0 +1,292 @@
##############################################################################
# ##
############################################################################## #
# # #
# Policy file for OpenBSD 3.5 # #
# May 20, 2003 # #
# ##
##############################################################################
##############################################################################
# ##
############################################################################## #
# # #
# Global Variable Definitions # #
# # #
# These are defined at install time by the installation script. You may # #
# manually edit these if you are using this file directly and not from the # #
# installation script itself. # #
# ##
##############################################################################
@@section GLOBAL
TWROOT=;
TWBIN=;
TWPOL=;
TWDB=;
TWSKEY=;
TWLKEY=;
TWREPORT=;
HOSTNAME=;
##############################################################################
# Predefined Variables #
##############################################################################
#
# Property Masks
#
# - ignore the following properties
# + check the following properties
#
# a access timestamp (mutually exclusive with +CMSH)
# b number of blocks allocated
# c inode creation/modification timestamp
# d ID of device on which inode resides
# g group id of owner
# i inode number
# l growing files (logfiles for example)
# m modification timestamp
# n number of links
# p permission and file mode bits
# r ID of device pointed to by inode (valid only for device objects)
# s file size
# t file type
# u user id of owner
#
# C CRC-32 hash
# H HAVAL hash
# M MD5 hash
# S SHA hash
#
##############################################################################
Device = +pugsdr-intlbamcCMSH ;
Dynamic = +pinugtd-srlbamcCMSH ;
Growing = +pinugtdl-srbamcCMSH ;
IgnoreAll = -pinugtsdrlbamcCMSH ;
IgnoreNone = +pinugtsdrbamcCMSH-l ;
ReadOnly = +pinugtsdbmCM-rlacSH ;
Temporary = +pugt ;
@@section FS
########################################
# ##
######################################## #
# # #
# Tripwire Binaries and Data Files # #
# ##
########################################
# Tripwire Binaries
(
rulename = "Tripwire Binaries",
)
{
$(TWBIN)/siggen -> $(ReadOnly) ;
$(TWBIN)/tripwire -> $(ReadOnly) ;
$(TWBIN)/twadmin -> $(ReadOnly) ;
$(TWBIN)/twprint -> $(ReadOnly) ;
}
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
(
rulename = "Tripwire Data Files",
)
{
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
# it does so by renaming the old file and creating a new one (which will
# have a new inode number). Inode is left turned on for keys, which shouldn't
# ever change.
# NOTE: The first integrity check triggers this rule and each integrity check
# afterward triggers this rule until a database update is run, since the
# database file does not exist before that point.
$(TWDB) -> $(Dynamic) -i ;
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
$(TWSKEY)/site.key -> $(ReadOnly) ;
# don't scan the individual reports
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
# In this configuration /usr/local is a symbolic link to /home/local.
# We want to ignore the following directories since they are already
# scanned using the real directory or mount point. Otherwise we see
# duplicates in the reports.
!/home/local ;
}
################################################
# ##
################################################ #
# # #
# OS Boot and Configuration Files # #
# ##
################################################
(
rulename = "OS Boot and Configuration Files",
)
{
/boot -> $(ReadOnly) ;
/bsd -> $(ReadOnly) ;
/etc -> $(IgnoreNone) -SHa ;
}
###################################################
# ##
################################################### #
# # #
# Mount Points # #
# ##
###################################################
(
rulename = "Mount Points",
)
{
/ -> $(ReadOnly) ;
/cdrom -> $(Dynamic) ;
/floppy -> $(Dynamic) ;
/home -> $(ReadOnly) ; # Modify as needed
/mnt -> $(Dynamic) ;
/usr -> $(ReadOnly) ;
/var -> $(ReadOnly) ;
}
###################################################
# ##
################################################### #
# # #
# Misc Top-Level Directories # #
# ##
###################################################
(
rulename = "Misc Top-Level Directories",
)
{
/altroot -> $(Dynamic) ;
/stand -> $(Dynamic) ;
}
################################################
# ##
################################################ #
# # #
# System Devices # #
# ##
################################################
(
rulename = "System Devices",
)
{
/dev -> $(Device) ;
/dev/fd -> $(Device) ;
/var/cron/tabs/.sock -> $(Device) ;
/var/empty/dev/log -> $(Device) ;
}
################################################
# ##
################################################ #
# # #
# OS Binaries and Libraries # #
# ##
################################################
(
rulename = "OS Binaries and Libraries",
)
{
/bin -> $(ReadOnly) ;
/sbin -> $(ReadOnly) ;
/usr/bin -> $(ReadOnly) ;
/usr/lib -> $(ReadOnly) ;
/usr/libexec -> $(ReadOnly) ;
/usr/sbin -> $(ReadOnly) ;
/usr/X11R6/bin -> $(ReadOnly) ;
/usr/X11R6/lib -> $(ReadOnly) ;
}
################################################
# ##
################################################ #
# # #
# Usr Local Files # #
# ##
################################################
#OK(
#OKrulename = "Usr Local Files",
#OK)
#OK{
#OK/usr/local -> $(ReadOnly) ;
#OK/usr/local/bin -> $(ReadOnly) ;
#OK/usr/local/doc -> $(ReadOnly) ;
#OK/usr/local/etc -> $(ReadOnly) ;
#OK/usr/local/include -> $(ReadOnly) ;
#OK/usr/local/info -> $(ReadOnly) ;
#OK/usr/local/lib -> $(ReadOnly) ;
#OK/usr/local/libdata -> $(ReadOnly) ;
#OK/usr/local/libexec -> $(ReadOnly) ;
#OK/usr/local/man -> $(ReadOnly) ;
#OK/usr/local/sbin -> $(ReadOnly) ;
#OK/usr/local/share -> $(ReadOnly) ;
#OK/usr/local/src -> $(ReadOnly) ;
#OK}
################################################
# ##
################################################ #
# # #
# Root Directory and Files # #
# ##
################################################
(
rulename = "Root Directory and Files",
)
{
/root -> $(IgnoreNone) -SHa ;
/root/.cshrc -> $(Dynamic) ;
/root/.profile -> $(Dynamic) ;
}
################################################
# ##
################################################ #
# # #
# Temporary Directories # #
# ##
################################################
(
rulename = "Temporary Directories",
)
{
/tmp -> $(Temporary) ;
/var/tmp -> $(Temporary) ;
}
################################################
# ##
################################################ #
# # #
# System and Boot Changes # #
# ##
################################################
(
rulename = "System and Boot Changes",
)
{
/var/backups -> $(Dynamic) -i ;
/var/db/host.random -> $(ReadOnly) -mCM ;
/var/cron -> $(Growing) -i ;
/var/log -> $(Growing) -i ;
/var/run -> $(Dynamic) -i ;
/var/mail -> $(Growing) ;
/var/msgs/bounds -> $(ReadOnly) -smbCM ;
/var/spool/clientmqueue -> $(Temporary) ;
/var/spool/mqueue -> $(Temporary) ;
}
#
# $Id: twpol-OpenBSD.txt,v 1.2 2004/05/14 21:56:21 pherman Exp $
#

314
policy/twpol-SunOS.txt Normal file
View File

@ -0,0 +1,314 @@
##############################################################################
# ##
############################################################################## #
# # #
# Policy file for Solaris 8 # #
# ##
##############################################################################
##############################################################################
# ##
############################################################################## #
# # #
# Global Variable Definitions # #
# # #
# These are defined at install time by the installation script. You may # #
# manually edit these if you are using this file directly and not from the # #
# installation script itself. # #
# ##
##############################################################################
@@section GLOBAL
TWROOT=;
TWBIN=;
TWPOL=;
TWDB=;
TWSKEY=;
TWLKEY=;
TWREPORT=;
HOSTNAME=;
##############################################################################
# Predefined Variables #
##############################################################################
#
# Property Masks
#
# - ignore the following properties
# + check the following properties
#
# a access timestamp (mutually exclusive with +CMSH)
# b number of blocks allocated
# c inode creation/modification timestamp
# d ID of device on which inode resides
# g group id of owner
# i inode number
# l growing files (logfiles for example)
# m modification timestamp
# n number of links
# p permission and file mode bits
# r ID of device pointed to by inode (valid only for device objects)
# s file size
# t file type
# u user id of owner
#
# C CRC-32 hash
# H HAVAL hash
# M MD5 hash
# S SHA hash
#
##############################################################################
Device = +pugsdr-intlbamcCMSH ;
Dynamic = +pinugtd-srlbamcCMSH ;
Growing = +pinugtdl-srbamcCMSH ;
IgnoreAll = -pinugtsdrlbamcCMSH ;
IgnoreNone = +pinugtsdrbamcCMSH-l ;
ReadOnly = +pinugtsdbmCM-rlacSH ;
Temporary = +pugt ;
@@section FS
########################################
# ##
######################################## #
# # #
# Tripwire Binaries and Data Files # #
# ##
########################################
# Tripwire Binaries
(
rulename = "Tripwire Binaries",
)
{
$(TWBIN)/siggen -> $(ReadOnly) ;
$(TWBIN)/tripwire -> $(ReadOnly) ;
$(TWBIN)/twadmin -> $(ReadOnly) ;
$(TWBIN)/twprint -> $(ReadOnly) ;
}
# Tripwire Data Files - Configuration Files, Policy Files, Keys, Reports, Databases
(
rulename = "Tripwire Data Files",
)
{
# NOTE: We remove the inode attribute because when Tripwire creates a backup,
# it does so by renaming the old file and creating a new one (which will
# have a new inode number). Inode is left turned on for keys, which shouldn't
# ever change.
# NOTE: The first integrity check triggers this rule and each integrity check
# afterward triggers this rule until a database update is run, since the
# database file does not exist before that point.
$(TWDB) -> $(Dynamic) -i ;
$(TWPOL)/tw.pol -> $(ReadOnly) -i ;
$(TWPOL)/tw.cfg -> $(ReadOnly) -i ;
$(TWLKEY)/$(HOSTNAME)-local.key -> $(ReadOnly) ;
$(TWSKEY)/site.key -> $(ReadOnly) ;
# don't scan the individual reports
$(TWREPORT) -> $(Dynamic) (recurse=0) ;
# In this configuration /usr/local is a symbolic link to /home/local.
# We want to ignore the following directories since they are already
# scanned using the real directory or mount point. Otherwise we see
# duplicates in the reports.
!/home/local ; # Ignore since /home already scanned
}
################################################
# ##
################################################ #
# # #
# OS Boot and Configuration Files # #
# ##
################################################
(
rulename = "OS Boot and Configuration Files",
)
{
/etc -> $(IgnoreNone) -SHa ;
/kernel -> $(ReadOnly) ;
}
###################################################
# ##
################################################### #
# # #
# Mount Points # #
# ##
###################################################
(
rulename = "Mount Points",
)
{
/ -> $(ReadOnly) ;
/cdrom -> $(Dynamic) ;
/home -> $(ReadOnly) ;
/mnt -> $(Dynamic) ;
/usr -> $(ReadOnly) ;
/var -> $(ReadOnly) ;
/opt -> $(ReadOnly) ;
}
###################################################
# ##
################################################### #
# # #
# Misc Top-Level Directories # #
# ##
###################################################
(
rulename = "Misc Top-Level Directories",
)
{
/lost+found -> $(ReadOnly) ;
}
################################################
# ##
################################################ #
# # #
# System Devices # #
# ##
################################################
(
rulename = "System Devices",
)
{
/dev -> $(Device) ;
/devices -> $(Device) ;
}
################################################
# ##
################################################ #
# # #
# OS Binaries and Libraries # #
# ##
################################################
(
rulename = "OS Binaries and Libraries",
)
{
/sbin -> $(ReadOnly) ;
/usr/bin -> $(ReadOnly) ;
/usr/lib -> $(ReadOnly) ;
/usr/sbin -> $(ReadOnly) ;
/usr/openwin/bin -> $(ReadOnly) ;
/usr/openwin/lib -> $(ReadOnly) ;
}
################################################
# ##
################################################ #
# # #
# Root Directory and Files # #
# ##
################################################
(
rulename = "Root Directory and Files",
)
{
! /.netscape/cache ;
/.bash_history -> $(ReadOnly) -smbCM;
/.sh_history -> $(Dynamic) ;
/.Xauthority -> $(ReadOnly) ;
}
################################################
# ##
################################################ #
# # #
# Temporary Directories # #
# ##
################################################
(
rulename = "Temporary Directories",
)
{
/tmp -> $(Temporary) ;
/var/tmp -> $(Temporary) ;
}
################################################
# ##
################################################ #
# # #
# System Doors and Misc Mounts # #
# ##
################################################
(
rulename = "System Doors and Misc Mounts",
)
{
!/etc/mnttab ;
!/etc/.name_service_door ;
!/etc/sysevent/syseventconfd_event_service ;
!/etc/sysevent/sysevent_door ;
!/etc/sysevent/piclevent_door ;
!/dev/fd ;
!/net ;
!/proc ;
!/var/run ;
!/var/run/syslog_door ;
!/vol ;
!/xfn ;
}
################################################
# ##
################################################ #
# # #
# System FIFOs # #
# ##
################################################
(
rulename = "System FIFOs",
)
{
!/etc/cron.d/FIFO ;
!/etc/initpipe ;
!/etc/saf/_cmdpipe ;
!/etc/saf/_sacpipe ;
!/etc/saf/zsmon/_pmpipe ;
!/etc/utmppipe ;
!/var/spool/lp/fifos/FIFO ;
!/tmp/.removable ;
!/tmp/.X11-pipe/X0 ;
}
################################################
# ##
################################################ #
# # #
# System and Boot Changes # #
# ##
################################################
(
rulename = "System and Boot Changes",
)
{
/etc/.pwd.lock -> $(ReadOnly) -cm;
/etc/coreadm.conf -> $(ReadOnly) -cm;
/var/adm -> $(Growing) -i;
#/var/backups -> $(Dynamic) -i ;
/var/cron/log -> $(Growing) -i ;
#/var/db/host.random -> $(ReadOnly) -mCM ;
#/var/db/locate.database -> $(ReadOnly) -misCM ;
/var/log -> $(Growing) -i ;
#/var/run -> $(Dynamic) -i ;
#/var/mail -> $(Growing) ;
#/var/msgs/bounds -> $(ReadOnly) -smbCM ;
!/var/sendmail ;
!/var/spool/clientmqueue ;
!/var/spool/mqueue ;
#!/var/tmp/vi.recover ; # perl script periodically removes this
}

2
src/Makefile.am Normal file
View File

@ -0,0 +1,2 @@
SUBDIRS = cryptlib core db fco fs tw twcrypto twparser util
SUBDIRS+= twprint twadmin siggen tripwire

445
src/Makefile.in Normal file
View File

@ -0,0 +1,445 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CORE_CRYPT_O = @CORE_CRYPT_O@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
YACC = @YACC@
YFLAGS = @YFLAGS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
path_to_sendmail = @path_to_sendmail@
path_to_vi = @path_to_vi@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
SUBDIRS = cryptlib core db fco fs tw twcrypto twparser util twprint twadmin siggen tripwire
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
uninstall-info-am:
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@set fnord $$MAKEFLAGS; amf=$$2; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| mkdir "$(distdir)/$$subdir" \
|| exit 1; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="../$(top_distdir)" \
distdir="../$(distdir)/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am:
install-exec-am:
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-recursive ctags ctags-recursive \
distclean distclean-generic distclean-recursive distclean-tags \
distdir dvi dvi-am html html-am info info-am install \
install-am install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-strip installcheck installcheck-am installdirs \
installdirs-am maintainer-clean maintainer-clean-generic \
maintainer-clean-recursive mostlyclean mostlyclean-generic \
mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \
uninstall uninstall-am uninstall-info-am
# 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:

2
src/buildnum.bat Normal file
View File

@ -0,0 +1,2 @@
set BLDLBL=Build_.2
set BLDNUM=.2

2
src/buildnum.h Normal file
View File

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

2
src/buildnum.h~ Normal file
View File

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

1
src/buildnum.txt Normal file
View File

@ -0,0 +1 @@
1

42
src/buildnuminc.pl Executable file
View File

@ -0,0 +1,42 @@
###############################################################################
# buildnuminc.pl
#
# Open the file 'buildnum.h', search for the line '#define BUILD_NUM "DDD"' (where
# DDD is a decimal integer), increment DDD, re-save the "buildnum.h" with
# the new build number
#
###############################################################################
$filename = 'buildnum.h';
$textname = 'buildnum.txt';
$batname = 'buildnum.bat';
$project = $ENV{"PROPROJ"};
open (TEXT, "<$textname") || die "Unable to open text file containing current build number!\n";
while (<TEXT>) {
$curver = $_;
}
print "$curver\n";
if ($curver !="") {
$newbuildnum = $curver + 1;
};
$verstring = "$project.$newbuildnum";
print ("Incrementing Project Build Number to: $verstring\n");
close (TEXT);
open (HEADER, ">$filename");
print (HEADER "#define BUILD_NUM _T(\"$newbuildnum\")\n\n");
close (HEADER);
open (TEXT, ">$textname");
print (TEXT "$newbuildnum\n");
close (TEXT);
open (BAT, ">$batname");
print (BAT "set BLDLBL=Build_$verstring\n");
print (BAT "set BLDNUM=$verstring\n");
close (BAT);

105
src/check_st.pl Executable file
View File

@ -0,0 +1,105 @@
###############################################################################
# check_st.pl
#
# created 26 may 1999 mdb
#
# Purpose:
# This script verifies that all of the string refrenced in a tripwire string
# table header file has a corresponding entry in the .cpp file
#
# Usage:
# Run from the root Tripwire directory. set PKGS to the package names that you
# want to check.
#
# TODO: gracefully handle packages with no string table
# TODO: handle commented out blocks in cpp files.
#
@PKGS = ( "core", "fco", "tw", "fs", "ntfs",
"ntreg", "siggen", "tripwire", "twadmin", "twprint" );
##-----------------------------------------------------------------------------
## execute main
##-----------------------------------------------------------------------------
sub main;
main();
exit 0;
##-----------------------------------------------------------------------------
## make_string_list
##
## opens the string header file and retrieves all of the string enums
## (identified by lines starting with \s*STR_) and returns them in a list
##
## Parameters:
## package name (ie -- core)
##-----------------------------------------------------------------------------
sub make_string_list
{
my $pkg_name = shift( @_ );
my $header_name = "${pkg_name}/${pkg_name}strings.h";
my @rtn_list;
open( IN, "<$header_name" ) || die "Unable to open $header_name\n";
while( <IN> )
{
if( /^\s*(STR_[a-zA-Z0-9_]+)/ )
{
push( @rtn_list, $1 );
}
}
close( IN );
return @rtn_list;
}
##-----------------------------------------------------------------------------
## verify_string_list
##
## takes as input a list of string identifiers, opens the string cpp
## file and makes sure that all strings in the list appear in that file.
##
## Limitation:
## can't tell whether entries in the cpp file are commented out.
##-----------------------------------------------------------------------------
sub verify_string_list
{
my $pkg_name = shift( @_ );
my @str_list = @_;
my $cpp_name = "${pkg_name}/${pkg_name}strings.cpp";
my @cpp_lines;
my $result;
# first, load the entire cpp file into an array...
#
open( IN, "<$cpp_name" ) || die "Unable to open $cpp_name\n";
while( <IN> )
{
push( @cpp_lines, $_ );
}
# now, iterate through the string list, looking for each
# string in the cpp file.
#
foreach $str (@str_list)
{
$result = grep( /$str/, @cpp_lines );
if( $result == 0 )
{
print "$str is missing from $pkg_name string table!\n";
}
}
}
##-----------------------------------------------------------------------------
## main
##-----------------------------------------------------------------------------
sub main
{
my @str_list;
foreach $pkg (@PKGS)
{
print "\n*** Processing $pkg ***\n";
@str_list = make_string_list( $pkg );
verify_string_list( $pkg, @str_list );
}
}

27
src/core/Makefile.am Normal file
View File

@ -0,0 +1,27 @@
AUTOMAKE_OPTIONS = foreign no-dependencies
INCLUDES = -I..
noinst_LIBRARIES = libcore.a
libcore_a_SOURCES = \
file_unix.cpp unixfsservices.cpp \
charutil_t.cpp displayencoder_t.cpp archive.cpp charutil.cpp \
cmdlineparser.cpp codeconvert.cpp core.cpp coreerrors.cpp \
corestrings.cpp crc32.cpp debug.cpp displayencoder.cpp \
displayutil.cpp error.cpp errorbucketimpl.cpp errortable.cpp \
errorutil.cpp fileerror.cpp fileheader.cpp fsservices.cpp \
growheap.cpp hashtable.cpp haval.cpp msystem.cpp ntmbs.cpp \
objectpool.cpp refcountobj.cpp serializable.cpp serializer.cpp \
serializerimpl.cpp serializerutil.cpp serstring.cpp \
srefcountobj.cpp srefcounttbl.cpp stdcore.cpp stringutil.cpp \
timebomb.cpp timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \
unixexcept.cpp usernotify.cpp usernotifystdout.cpp utf8.cpp \
wchar16.cpp
libcore_a_LIBADD = @CORE_CRYPT_O@
libcore_a_DEPENDENCIES = @CORE_CRYPT_O@
DEFS = @DEFS@ # This gets rid of the -I. so INCLUDES must be more explicit
all: $(noinst_LIBRARIES)
$(AR) ru ../../lib/libtripwire.a $(libcore_a_OBJECTS) $(libcore_a_LIBADD)

427
src/core/Makefile.in Normal file
View File

@ -0,0 +1,427 @@
# Makefile.in generated by automake 1.8.5 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
SOURCES = $(libcore_a_SOURCES)
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ../..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LIBRARIES = $(noinst_LIBRARIES)
AR = ar
ARFLAGS = cru
libcore_a_AR = $(AR) $(ARFLAGS)
am_libcore_a_OBJECTS = file_unix.$(OBJEXT) unixfsservices.$(OBJEXT) \
charutil_t.$(OBJEXT) displayencoder_t.$(OBJEXT) \
archive.$(OBJEXT) charutil.$(OBJEXT) cmdlineparser.$(OBJEXT) \
codeconvert.$(OBJEXT) core.$(OBJEXT) coreerrors.$(OBJEXT) \
corestrings.$(OBJEXT) crc32.$(OBJEXT) debug.$(OBJEXT) \
displayencoder.$(OBJEXT) displayutil.$(OBJEXT) error.$(OBJEXT) \
errorbucketimpl.$(OBJEXT) errortable.$(OBJEXT) \
errorutil.$(OBJEXT) fileerror.$(OBJEXT) fileheader.$(OBJEXT) \
fsservices.$(OBJEXT) growheap.$(OBJEXT) hashtable.$(OBJEXT) \
haval.$(OBJEXT) msystem.$(OBJEXT) ntmbs.$(OBJEXT) \
objectpool.$(OBJEXT) refcountobj.$(OBJEXT) \
serializable.$(OBJEXT) serializer.$(OBJEXT) \
serializerimpl.$(OBJEXT) serializerutil.$(OBJEXT) \
serstring.$(OBJEXT) srefcountobj.$(OBJEXT) \
srefcounttbl.$(OBJEXT) stdcore.$(OBJEXT) stringutil.$(OBJEXT) \
timebomb.$(OBJEXT) timeconvert.$(OBJEXT) tw_signal.$(OBJEXT) \
twlimits.$(OBJEXT) twlocale.$(OBJEXT) unixexcept.$(OBJEXT) \
usernotify.$(OBJEXT) usernotifystdout.$(OBJEXT) utf8.$(OBJEXT) \
wchar16.$(OBJEXT)
libcore_a_OBJECTS = $(am_libcore_a_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp =
am__depfiles_maybe =
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
-o $@
SOURCES = $(libcore_a_SOURCES)
DIST_SOURCES = $(libcore_a_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CORE_CRYPT_O = @CORE_CRYPT_O@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@ # This gets rid of the -I. so INCLUDES must be more explicit
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
YACC = @YACC@
YFLAGS = @YFLAGS@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
path_to_sendmail = @path_to_sendmail@
path_to_vi = @path_to_vi@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
AUTOMAKE_OPTIONS = foreign no-dependencies
INCLUDES = -I..
noinst_LIBRARIES = libcore.a
libcore_a_SOURCES = \
file_unix.cpp unixfsservices.cpp \
charutil_t.cpp displayencoder_t.cpp archive.cpp charutil.cpp \
cmdlineparser.cpp codeconvert.cpp core.cpp coreerrors.cpp \
corestrings.cpp crc32.cpp debug.cpp displayencoder.cpp \
displayutil.cpp error.cpp errorbucketimpl.cpp errortable.cpp \
errorutil.cpp fileerror.cpp fileheader.cpp fsservices.cpp \
growheap.cpp hashtable.cpp haval.cpp msystem.cpp ntmbs.cpp \
objectpool.cpp refcountobj.cpp serializable.cpp serializer.cpp \
serializerimpl.cpp serializerutil.cpp serstring.cpp \
srefcountobj.cpp srefcounttbl.cpp stdcore.cpp stringutil.cpp \
timebomb.cpp timeconvert.cpp tw_signal.cpp twlimits.cpp twlocale.cpp \
unixexcept.cpp usernotify.cpp usernotifystdout.cpp utf8.cpp \
wchar16.cpp
libcore_a_LIBADD = @CORE_CRYPT_O@
libcore_a_DEPENDENCIES = @CORE_CRYPT_O@
all: all-am
.SUFFIXES:
.SUFFIXES: .cpp .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/core/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --foreign src/core/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
libcore.a: $(libcore_a_OBJECTS) $(libcore_a_DEPENDENCIES)
-rm -f libcore.a
$(libcore_a_AR) libcore.a $(libcore_a_OBJECTS) $(libcore_a_LIBADD)
$(RANLIB) libcore.a
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
.cpp.o:
$(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
uninstall-info-am:
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(LIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am
distclean: distclean-am
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am:
install-exec-am:
install-info: install-info-am
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-info-am
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
clean-noinstLIBRARIES ctags distclean distclean-compile \
distclean-generic distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-exec install-exec-am install-info \
install-info-am install-man install-strip installcheck \
installcheck-am installdirs maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
uninstall-am uninstall-info-am
all: $(noinst_LIBRARIES)
$(AR) ru ../../lib/libtripwire.a $(libcore_a_OBJECTS) $(libcore_a_LIBADD)
# 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:

935
src/core/archive.cpp Normal file
View File

@ -0,0 +1,935 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// archive.cpp -- classes that abstract a raw byte archive
//
// cArchive -- interface for single-direction (one pass) reads and writes
// cBidirArchive -- interface for a random-access archive
// cMemArchive -- implementation of a bidirectional archive in memory
// cFileArchive -- implementation of a bidirectional archive as a file
#include "stdcore.h"
#include "archive.h"
#include "fsservices.h"
#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <iostream>
#include "file.h"
#include "stringutil.h"
#include "corestrings.h" // for: STR_ERR2_ARCH_CRYPTO_ERR
#if FSEEK_TAKES_INT32
#define FSEEK(x, y, z) fseek((x), (int32)(y), (z))
#else
#define FSEEK(x, y, z) fseek((x), (y), (z))
#endif
//=============================================================================
// Utility Functions
//=============================================================================
///////////////////////////////////////////////////////////////////////////////
// util_IsDir -- returns true if a given file is a directory
///////////////////////////////////////////////////////////////////////////////
bool util_IsDir( const TSTRING& fileName )
{
cFSStatArgs s;
try
{
iFSServices::GetInstance()->Stat( fileName, s );
}
catch( eFSServices )
{
return false;
}
return( s.mFileType == cFSStatArgs::TY_DIR );
}
//=============================================================================
// eArchiveCrypto
//=============================================================================
TSTRING eArchiveCrypto::GetMsg( ) const
{
// RAD: Updated this to use new stringtable
return ( mMsg + TSS_GetString( cCore, core::STR_ERR2_ARCH_CRYPTO_ERR ) );
}
//=============================================================================
// cArchive
//=============================================================================
// convenience methods
//
// Specific Read functions throw eArchive if EOF is reached because
// if the caller is requesting a certain amount of data to be present,
// reaching EOF is unexpected
//
// ReadBlob and WriteBlob return number of bytes read or written. Notice
// that ReadBlob does not throw an exception since eventually EOF is expected.
//
// ReadBlob can take NULL as a destination pointer
//
// All write functions throw exceptions for unexpected events like
// running out of memory or disk space.
//
void cArchive::ReadInt16(int16& ret) // throw(eArchive)
{
if (ReadBlob(&ret, sizeof(int16)) != sizeof(int16))
throw eArchiveEOF();
ret = tw_ntohs(ret);
}
void cArchive::ReadInt32(int32& ret) // throw(eArchive)
{
if (ReadBlob(&ret, sizeof(int32)) != sizeof(int32))
throw eArchiveEOF();
ret = tw_ntohl(ret);
}
void cArchive::ReadInt64(int64& ret) // throw(eArchive)
{
if (ReadBlob(&ret, sizeof(int64)) != sizeof(int64))
throw eArchiveEOF();
ret = tw_ntohll(ret);
}
// NOTE:BAM 10/11/99 -- we store unsigned size, but it really only works with
// lengths < INT16_MAX due to sign extension in integral promotion during the
// resize() in ReadString().
// format for written string: 16-bit unsigned size, then a list of 16-bit UCS2 (Unicode) characters
// not including terminating NULL
void cArchive::ReadString(TSTRING& ret) // throw(eArchive)
{
// read in size of string
int16 size;
ReadInt16( size );
// create buffer for WCHAR16 string
wc16_string ws;
ws.resize( size );
WCHAR16* pwc = (WCHAR16*)ws.data();
for( int n = 0; n < size; n++ )
{
int16 i16;
ReadInt16( i16 );
*pwc++ = i16;
}
// convert WCHAR16 string to a TSTRING
ret = cStringUtil::WstrToTstr( ws );
}
int cArchive::ReadBlob(void* pBlob, int count)
{
return Read(pBlob, count);
}
void cArchive::WriteInt16(int16 i) // throw(eArchive)
{
i = tw_htons(i);
WriteBlob(&i, sizeof(int16));
}
void cArchive::WriteInt32(int32 i) // throw(eArchive)
{
i = tw_htonl(i);
WriteBlob(&i, sizeof(int32));
}
void cArchive::WriteInt64(int64 i) // throw(eArchive)
{
i = tw_htonll(i);
WriteBlob(&i, sizeof(int64));
}
// NOTE:BAM 10/11/99 -- we store unsigned size, but it really only works with
// lengths < INT16_MAX due to sign extension in integral promotion during the
// resize() in ReadString().
// format for written string: 16-bit unsigned size, then a list of 16-bit UCS2 (Unicode) characters
// not including terminating NULL
void cArchive::WriteString(TSTRING s) // throw(eArchive)
{
// convert string to a UCS2 string
wc16_string ws;
cStringUtil::Convert( ws, s ); // Make convert "type-dispatched"
// we assume that we can represent the size as a unsigned 16-bit number
// (we actually write it as a signed number, but we cast it)
if( ws.length() > TSS_INT16_MAX )
ThrowAndAssert( eArchiveStringTooLong() );
WriteInt16( static_cast<int16>( ws.length() ) );
// write out each 16 bit character
// RAD:09/03/99 -- Optimized for performance with "const"
wc16_string::const_iterator at = ws.begin();
while ( at != ws.end() )
WriteInt16( *at++ );
}
void cArchive::WriteBlob(const void* pBlob, int count) // throw(eArchive)
{
if (Write(pBlob, count) < count)
ThrowAndAssert(eArchiveWrite());
}
int32 cArchive::GetStorageSize(const TSTRING& str)
{
int32 size = sizeof(int32); // the length is always stored
//
// after the length, all of the characters in the string are written as 16-bit values,
// except for the null character
//
size += ( str.length() * 2 );
return size;
}
int64 cArchive::Copy(cArchive* pFrom, int64 amt)
{
enum { BUF_SIZE = 2048 };
int8 buf[BUF_SIZE];
int64 amtLeft = amt;
while(amtLeft > 0)
{
int64 amtToRead = amtLeft > BUF_SIZE ? BUF_SIZE : amtLeft;
int64 amtRead = pFrom->ReadBlob(buf, static_cast<int>( amtToRead ) );
amtLeft -= amtRead;
WriteBlob(buf, static_cast<int>( amtRead ) );
if(amtRead < amtToRead)
break;
}
// return the amount copied ...
return (amt - amtLeft);
}
///////////////////////////////////////////////////////////////////////////////
// class cMemMappedArchive -- Archive that can be memory mapped.
///////////////////////////////////////////////////////////////////////////////
cMemMappedArchive::cMemMappedArchive()
{
mpMappedMem = 0;
mMappedOffset = 0;
mMappedLength = 0;
}
cMemMappedArchive::~cMemMappedArchive()
{
}
int64 cMemMappedArchive::GetMappedOffset() const // throw(eArchive)
{
if (mpMappedMem == 0)
ThrowAndAssert(eArchiveMemmap());
return mMappedOffset;
}
int64 cMemMappedArchive::GetMappedLength() const // throw(eArchive)
{
if (mpMappedMem == 0)
ThrowAndAssert(eArchiveMemmap());
return mMappedLength;
}
const void* cMemMappedArchive::GetMap() const // throw(eArchive)
{
if (mpMappedMem == 0)
ThrowAndAssert(eArchiveMemmap());
return mpMappedMem;
}
void* cMemMappedArchive::GetMap() // throw(eArchive)
{
if (mpMappedMem == 0)
ThrowAndAssert(eArchiveMemmap());
return mpMappedMem;
}
void cMemMappedArchive::SetNewMap(void* pMap, int64 offset, int64 length) const
{
if (pMap == 0)
{
mpMappedMem = 0;
mMappedOffset = 0;
mMappedLength = 0;
}
else
{
mpMappedMem = pMap;
mMappedOffset = offset;
mMappedLength = length;
}
}
///////////////////////////////////////////////////////////////////////////////
// class cMemoryArchive -- An archive that stores itself in a memory buffer.
// This buffer can grow as needed up until a pre-specified maximum
// size. The buffer can be read and written to and can be memory
// mapped.
///////////////////////////////////////////////////////////////////////////////
cMemoryArchive::cMemoryArchive(int maxSize)
: mMaxAllocatedLen(maxSize)
{
ASSERT(maxSize > 0);
mpMemory = 0;
mAllocatedLen = 0;
mLogicalSize = 0;
mReadHead = 0;
}
cMemoryArchive::~cMemoryArchive()
{
delete [] mpMemory;
}
bool cMemoryArchive::EndOfFile()
{
return mReadHead >= mLogicalSize;
}
void cMemoryArchive::Seek(int64 offset, SeekFrom from) // throw(eArchive)
{
switch (from)
{
case cBidirArchive::BEGINNING:
break;
case cBidirArchive::CURRENT:
offset = mReadHead + (int)offset;
break;
case cBidirArchive::END:
offset = mLogicalSize + (int)offset;
break;
default:
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
}
if (offset > mLogicalSize)
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
mReadHead = static_cast<int>( offset );
}
int64 cMemoryArchive::CurrentPos() const
{
return mReadHead;
}
int64 cMemoryArchive::Length() const
{
return mLogicalSize;
}
void cMemoryArchive::Truncate()
{
ASSERT(mReadHead >= 0);
mLogicalSize = mReadHead;
AllocateMemory(mLogicalSize);
}
void cMemoryArchive::MapArchive(int64 offset, int64 len) // throw(eArchive)
{
if ( offset + (int)len > mLogicalSize )
AllocateMemory( static_cast<int>( offset + len ) );
SetNewMap(mpMemory + offset, offset, len);
}
void cMemoryArchive::MapArchive(int64 offset, int64 len) const // throw(eArchive)
{
if (offset + (int)len > mLogicalSize)
ThrowAndAssert(eArchiveMemmap());
SetNewMap(mpMemory + offset, offset, len);
}
int cMemoryArchive::Read(void* pDest, int count)
{
if (mReadHead + count > mLogicalSize)
count = mLogicalSize - mReadHead;
if (pDest != 0)
memcpy(pDest, mpMemory + mReadHead, count);
mReadHead += count;
return count;
}
int cMemoryArchive::Write(const void* pDest, int count) // throw(eArchive)
{
if (mReadHead + count > mLogicalSize)
{
AllocateMemory(mReadHead + count);
}
memcpy(mpMemory + mReadHead, pDest, count);
mReadHead += count;
return count;
}
void cMemoryArchive::AllocateMemory(int len) // throw(eArchive)
{
const int MIN_ALLOCATED_SIZE = 1024;
if (len > mAllocatedLen)
{
// grow the buffer
// only error if we are in debug mode
#ifdef _DEBUG
if (len > mMaxAllocatedLen)
ThrowAndAssert(eArchiveOutOfMem());
#endif
if( 0 == mAllocatedLen )
mAllocatedLen = MIN_ALLOCATED_SIZE;
while (mAllocatedLen < len)
mAllocatedLen *= 2;
int8* pNewMem = new int8[mAllocatedLen];
if (mpMemory != 0)
{
memcpy(pNewMem, mpMemory, mLogicalSize);
delete [] mpMemory;
}
mpMemory = pNewMem;
mLogicalSize = len;
// update memory map if there is one
if (mpMappedMem)
SetNewMap(mpMemory + mMappedOffset, mMappedOffset, mMappedLength);
}
else
{
// check for memory map conflict
if (mpMappedMem && len < mMappedOffset + mMappedLength)
ThrowAndAssert(eArchiveMemmap());
if (len < (mAllocatedLen >> 1) && mAllocatedLen > MIN_ALLOCATED_SIZE)
{
// shrink the buffer
int8* pNewMem = new int8[len];
ASSERT(mpMemory);
memcpy(pNewMem, mpMemory, len);
delete [] mpMemory;
mpMemory = pNewMem;
mLogicalSize = len;
// update memory map if there is one
if (mpMappedMem)
SetNewMap(mpMemory + mMappedOffset, mMappedOffset, mMappedLength);
}
else
{
// no need to grow or shrink
mLogicalSize = len;
}
}
}
/*
class cFixedMemArchive : public cBidirArchive
{
public:
int8* mpMemory;
int32 mSize;
int32 mReadHead;
};
*/
//-----------------------------------------------------------------------------
// cFixedMemArchive
//-----------------------------------------------------------------------------
cFixedMemArchive::cFixedMemArchive()
: mpMemory (0),
mSize (0),
mReadHead (0)
{
}
cFixedMemArchive::cFixedMemArchive( int8* pMem, int32 size )
: mpMemory (0),
mSize (0),
mReadHead (0)
{
Attach( pMem, size );
}
cFixedMemArchive::~cFixedMemArchive()
{
}
void cFixedMemArchive::Attach( int8* pMem, int32 size )
{
mpMemory = pMem;
mSize = size;
mReadHead = 0;
}
void cFixedMemArchive::Seek(int64 offset, SeekFrom from) // throw(eArchive)
{
switch (from)
{
case cBidirArchive::BEGINNING:
break;
case cBidirArchive::CURRENT:
offset = mReadHead + (int)offset;
break;
case cBidirArchive::END:
offset = mSize + (int)offset;
break;
default:
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
}
if (offset > mSize)
ThrowAndAssert(eArchiveSeek(TSS_GetString( cCore, core::STR_MEMARCHIVE_FILENAME), TSS_GetString( cCore, core::STR_MEMARCHIVE_ERRSTR)));
mReadHead = static_cast<int32>( offset );
}
int64 cFixedMemArchive::CurrentPos() const
{
return mReadHead;
}
int64 cFixedMemArchive::Length() const
{
return mSize;
}
bool cFixedMemArchive::EndOfFile()
{
return (mReadHead >= mSize);
}
int cFixedMemArchive::Read(void* pDest, int count) // throw(eArchive)
{
ASSERT( pDest );
if (mReadHead + count > mSize)
{
count = static_cast<int>( mSize - mReadHead );
if (count <= 0)
return 0;
}
if (pDest != 0)
memcpy(pDest, mpMemory + mReadHead, count);
mReadHead += count;
return count;
}
int cFixedMemArchive::Write(const void* pDest, int count) // throw(eArchive)
{
if (mReadHead + count > mSize)
{
ASSERT( false );
throw eArchiveWrite();
}
memcpy(mpMemory + mReadHead, pDest, count);
mReadHead += count;
return count;
}
///////////////////////////////////////////////////////////////////////////////
// class cFileArchive -- Archive for files...
///////////////////////////////////////////////////////////////////////////////
//Ctor -- Initialize member variables to 0 or NULL equivalents.
cFileArchive::cFileArchive() :
mFileSize(0),
mReadHead(0),
isWritable(false)
{}
cFileArchive::~cFileArchive()
{
}
bool cFileArchive::EndOfFile()
{
return ( mReadHead >= mFileSize );
}
////////////////////////////////////////////////////////////////////////
// Seek -- This is where the actual offset is performed. The default
// for each archive will be 0.
/////////////////////////////////////////////////////////////////////////
void cFileArchive::Seek( int64 offset, SeekFrom from) // throw(eArchive)
{
try
{
switch (from)
{
case cBidirArchive::BEGINNING:
break;
case cBidirArchive::CURRENT:
offset = mReadHead + offset;
break;
case cBidirArchive::END:
offset = mFileSize + offset;
break;
default:
throw eArchiveSeek( mCurrentFilename, iFSServices::GetInstance()->GetErrString() ) ;
}
if ( offset > mFileSize )
throw eArchiveSeek( mCurrentFilename, iFSServices::GetInstance()->GetErrString() ) ;
mReadHead = offset;
mCurrentFile.Seek(mReadHead, cFile::SEEK_BEGIN);
//This is where the actual read/writehead is set!!
}//try
catch( eFile& fileError )
{
throw( eArchiveSeek( mCurrentFilename, fileError.GetDescription() ) );
}
}
int64 cFileArchive::CurrentPos(void) const
{
return mReadHead;
}
/////////////////////////////////////////////////////////////////////////
// Length -- Returns the size of the current file archive.
/////////////////////////////////////////////////////////////////////////
int64 cFileArchive::Length(void) const
{
try
{
return mCurrentFile.GetSize();
}
catch(eFile& fileError)
{
throw( eArchiveSeek( mCurrentFilename, fileError.GetDescription() ) );
}
}
/////////////////////////////////////////////////////////////////////////
// OpenRead -- Opens the file to be read only.
/////////////////////////////////////////////////////////////////////////
void cFileArchive::OpenRead(const TCHAR* filename, uint32 openFlags)
{
try
{
// set up open flags
uint32 flags = cFile::OPEN_READ;
flags |= ( ( openFlags & FA_OPEN_TRUNCATE ) ? cFile::OPEN_TRUNCATE : 0 );
flags |= ( ( openFlags & FA_OPEN_TEXT ) ? cFile::OPEN_TEXT : 0 );
mCurrentFilename = filename;
mCurrentFile.Open( filename, flags );
isWritable = false;
mFileSize = mCurrentFile.GetSize();
mReadHead = mCurrentFile.Seek( 0, cFile::SEEK_BEGIN );
}
catch(eFile& fileError)
{
throw(eArchiveOpen( mCurrentFilename, fileError.GetDescription() ) );
}
}
/////////////////////////////////////////////////////////////////////////
// OpenReadWrite -- Opens the file to be read or written to
/////////////////////////////////////////////////////////////////////////
void cFileArchive::OpenReadWrite(const TCHAR* filename, uint32 openFlags)
{
try
{
// set up open flags
uint32 flags = cFile::OPEN_WRITE;
flags |= ( ( openFlags & FA_OPEN_TRUNCATE ) ? cFile::OPEN_TRUNCATE : 0 );
flags |= ( ( openFlags & FA_OPEN_TEXT ) ? cFile::OPEN_TEXT : 0 );
mCurrentFilename = filename;
mCurrentFile.Open( filename, flags );
isWritable = true;
mFileSize = mCurrentFile.GetSize();
mReadHead = mCurrentFile.Seek( 0, cFile::SEEK_BEGIN );
}
catch(eFile& fileError)
{
throw( eArchiveOpen( mCurrentFilename, fileError.GetDescription() ) );
}
}
/////////////////////////////////////////////////////////////////////////
// GetCurrentFilename -- Returns the name of the file currently associated
// with the FileArchive.
/////////////////////////////////////////////////////////////////////////
TSTRING cFileArchive::GetCurrentFilename(void) const
{
return mCurrentFilename;
}
/////////////////////////////////////////////////////////////////////////
// Close -- Closes the file currently referenced by mpCurrStream
/////////////////////////////////////////////////////////////////////////
void cFileArchive::Close()
{
try
{
mCurrentFile.Close();
mFileSize = 0;
mReadHead = 0;
mCurrentFilename = _T("");
}
catch(eFile& fileError)
{
throw( eArchive( mCurrentFilename, fileError.GetDescription() ) );
}
}
/////////////////////////////////////////////////////////////////////////
// Read -- Read places bytes in location designated by pDest. Returns
// The actual amount read into *pDest.
/////////////////////////////////////////////////////////////////////////
int cFileArchive::Read(void* pDest, int count)
{
try
{
if ( mReadHead + count > mFileSize )
count = static_cast<int>( mFileSize - mReadHead );
if ( pDest != NULL )
{
int nbRead =
static_cast<int>( mCurrentFile.Read( pDest, count ) );
// 'count' may not be equal to 'nbRead' if the file is open in
// text mode.
count = nbRead;
if(count < 0) count = 0;
}
else
{
int i;
int32 dummy;
for (i = count; ; i -= sizeof(int32))
{
if (i < (int)sizeof(int32))
{
if (i > 0)
mCurrentFile.Read( &dummy, i );
break;
}
mCurrentFile.Read( &dummy, i );
}
}
mReadHead += count;
return count;
}
catch( eFile& fileError )
{
throw( eArchiveRead( mCurrentFilename, fileError.GetDescription() ) );
}
}
/////////////////////////////////////////////////////////////////////////
// Write -- Writes to file designated by fh. If isWritable is not set,
// function returns 0. Otherwise, the actual # written is returned.
/////////////////////////////////////////////////////////////////////////
int cFileArchive::Write(const void* pDest, int count) // throw(eArchive)
{
try
{
int64 actual_count = 0;
ASSERT( mCurrentFile.isWritable );
actual_count = mCurrentFile.Write( pDest, count );
if ( actual_count < count )
{
//Disk full??
throw eArchiveWrite( mCurrentFilename, iFSServices::GetInstance()->GetErrString() ) ;
}
// increment the read/write head
mReadHead += actual_count;
// increase the size, if needed
if( mReadHead > mFileSize )
{
#if 0 // IS_SUNPRO
// These two lines seem to be all there is between code that crashes and code that works for sunpro
cDebug d("cFileArchive::Write()");
d.TraceDebug(_T("file(%s) adjusted mFileSize = %d mReadHead = %d\n"), mCurrentFilename.c_str(), (int)mFileSize, (int)mReadHead);
#endif
mFileSize = mReadHead;
}
return (int)actual_count;
}
catch( eFile& fileError )
{
throw( eArchiveWrite( mCurrentFilename, fileError.GetDescription() ) );
}
}
/////////////////////////////////////////////////////////////////////////
// Truncate
/////////////////////////////////////////////////////////////////////////
void cFileArchive::Truncate() // throw(eArchive)
{
ASSERT( mCurrentFile.IsOpen() );
ASSERT( mCurrentFile.isWritable );
try
{
mCurrentFile.Truncate ( mReadHead );
}
catch( eFile& fileError )
{
//TODO: create an error number for truncate...
throw( eArchiveWrite( mCurrentFilename, fileError.GetDescription() ) );
}
mFileSize = mReadHead;
}
/////////////////////////////////////////////////////////////////////////
// OpenReadWrite -- Opens the file to be read or written to
//
// since we'll never open an existing file, the truncateFile flag is unnecessary.
/////////////////////////////////////////////////////////////////////////
void cLockedTemporaryFileArchive::OpenReadWrite( const TCHAR* filename, uint32 openFlags )
{
TSTRING strTempFile;
try {
ASSERT( !mCurrentFile.IsOpen() ); // shouldn't be able to create a new file when we're already open
if ( mCurrentFile.IsOpen() )
throw( eArchive( mCurrentFilename, _T("Internal Error") ) );
///////////////////////////////////////////////////////////////////////////////
// if filename is NULL, create a temp file for the caller
if( filename == NULL )
{
try
{
iFSServices::GetInstance()->GetTempDirName( strTempFile );
strTempFile += _T("twtempXXXXXX");
iFSServices::GetInstance()->MakeTempFilename( strTempFile );
}
catch( eFSServices& e)
{
TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY );
eArchiveOpen e(strTempFile, errStr);
throw e;
}
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// create file
// set up flags
uint32 flags = cFile::OPEN_WRITE | cFile::OPEN_LOCKED_TEMP | cFile::OPEN_CREATE | cFile::OPEN_EXCLUSIVE;
if ( openFlags & FA_OPEN_TRUNCATE )
flags |= cFile::OPEN_TRUNCATE;
if ( openFlags & FA_OPEN_TEXT )
flags |= cFile::OPEN_TEXT;
// open file
mCurrentFilename = filename ? filename : strTempFile.c_str();
mCurrentFile.Open( mCurrentFilename, flags );
isWritable = true;
mFileSize = mCurrentFile.GetSize();
mReadHead = mCurrentFile.Seek( 0, cFile::SEEK_BEGIN );
#if 0 // IS_SUNPRO
cDebug d("cLockedTemporaryFileArchive::OpenReadWrite()");
d.TraceDebug(_T("file(%s) set mFileSize to %d mReadHead to %d\n"), mCurrentFilename.c_str(), (int)mFileSize, (int)mReadHead);
#endif
}//try
catch (eFile& fileError) {
TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY );
eArchiveOpen e(strTempFile, errStr);
throw e;
}
///////////////////////////////////////////////////////////////////////////////
}
/////////////////////////////////////////////////////////////////////////
// Close -- Closes the file currently referenced by fh
void cLockedTemporaryFileArchive::Close()
{
// Note: this deletes the file as well
cFileArchive::Close();
}

346
src/core/archive.h Normal file
View File

@ -0,0 +1,346 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// archive.h -- classes that abstract a raw byte archive
//
// cArchive -- interface for single-direction (one pass) reads and writes
// cBidirArchive -- interface for a random-access archive
// cMemArchive -- implementation of a bidirectional archive in memory
// cFileArchive -- implementation of a bidirectional archive as a file
#ifndef __ARCHIVE_H
#define __ARCHIVE_H
#ifndef __DEBUG_H
#include "debug.h"
#endif
#ifndef __ERRORUTIL_H
#include "errorutil.h"
#endif
#ifndef __FILEERROR_H
#include "fileerror.h"
#endif
#ifndef __FILE_H
#include "file.h"
#endif
//=============================================================================
// eArchive exception classes
//=============================================================================
TSS_FILE_EXCEPTION( eArchive, eFileError );
TSS_FILE_EXCEPTION( eArchiveOpen, eArchive );
TSS_FILE_EXCEPTION( eArchiveWrite, eArchive );
TSS_FILE_EXCEPTION( eArchiveRead, eArchive );
TSS_FILE_EXCEPTION( eArchiveEOF, eArchive );
TSS_FILE_EXCEPTION( eArchiveSeek, eArchive );
TSS_FILE_EXCEPTION( eArchiveMemmap, eArchive );
TSS_FILE_EXCEPTION( eArchiveOutOfMem, eArchive );
TSS_FILE_EXCEPTION( eArchiveInvalidOp, eArchive );
TSS_FILE_EXCEPTION( eArchiveFormat, eArchive );
TSS_FILE_EXCEPTION( eArchiveNotRegularFile, eArchive );
TSS_BEGIN_EXCEPTION( eArchiveCrypto, eArchive )
virtual TSTRING GetMsg() const;
// eCryptoArchive appends a special string to the end of
// all exception messages
TSS_END_EXCEPTION()
TSS_EXCEPTION( eArchiveStringTooLong, eArchive );
// throw( eArchiveOpen( cErrorUtil::MakeFileError( fileError.GetMsg(), strTempFile ) ) );
//=============================================================================
// cArchive
//=============================================================================
class cArchive
{
public:
// convenience methods
//
// Specific Read functions throw(eArchive) if EOF is reached because
// if the caller is requesting a certain amount of data to be present,
// reaching EOF is unexpected
//
// ReadBlob and WriteBlob return number of bytes read or written. Notice
// that ReadBlob does not throw an exception since eventually EOF is expected.
//
// ReadBlob can take NULL as a destination pointer
//
// All write functions throw exceptions for unexpected events like
// running out of memory or disk space.
//
void ReadInt16(int16& ret); // throw(eArchive)
void ReadInt32(int32& ret); // throw(eArchive)
void ReadInt64(int64& ret); // throw(eArchive)
void ReadString(TSTRING& ret); // throw(eArchive)
int ReadBlob(void* pBlob, int count);
void WriteInt16(int16 i); // throw(eArchive)
void WriteInt32(int32 i); // throw(eArchive)
void WriteInt64(int64 i); // throw(eArchive)
void WriteString(TSTRING s); // throw(eArchive)
void WriteBlob(const void* pBlob, int count); // throw(eArchive)
static int32 GetStorageSize(const TSTRING& str);
// this method calculates how many bytes the given string will take up in the archive and returns
// that value
// NOTE -- if the implementation of ReadString() or WriteString() ever changes, this method will also
// need to change.
int64 Copy(cArchive* pFrom, int64 amt); // throw(eArchive)
// this method copies amt bytes from pFrom to itself, throwing an eArchive if anything goes wrong.
// only makes sense to call for reading archives
virtual bool EndOfFile() = 0;
protected:
// overrides
virtual int Read(void* pDest, int count) = 0;
virtual int Write(const void* pDest, int count) = 0; // throw(eArchive);
};
///////////////////////////////////////////////////////////////////////////////
// class cBidirArchive --
///////////////////////////////////////////////////////////////////////////////
class cBidirArchive : public cArchive
{
public:
enum SeekFrom {
BEGINNING = 0,
CURRENT = 1,
END = -1
};
virtual void Seek(int64 offset, SeekFrom from) = 0; // throw(eArchive);
virtual int64 CurrentPos() const = 0;
virtual int64 Length() const = 0;
};
///////////////////////////////////////////////////////////////////////////////
// class cMemMappedArchive -- Archive that can be memory mapped.
///////////////////////////////////////////////////////////////////////////////
class cMemMappedArchive : public cBidirArchive
{
public:
enum {
MAP_TO_EOF = -1
};
cMemMappedArchive();
virtual ~cMemMappedArchive();
virtual void MapArchive(int64 offset, int64 len) = 0; // throw(eArchive);
virtual void MapArchive(int64 offset, int64 len) const = 0; // throw(eArchive);
// the const version of MapArchive() does not allow the archive to grow in size
int64 GetMappedOffset() const; // throw(eArchive)
int64 GetMappedLength() const; // throw(eArchive)
void* GetMap(); // throw(eArchive)
const void* GetMap() const;
protected:
mutable void* mpMappedMem;
mutable int64 mMappedOffset;
mutable int64 mMappedLength;
// call in derived class to set above vars
void SetNewMap(void* pMap, int64 offset, int64 length) const;
};
///////////////////////////////////////////////////////////////////////////////
// class cMemoryArchive -- An archive that stores itself in a memory buffer.
// This buffer can grow as needed up until a pre-specified maximum
// size. The buffer can be read and written to and can be memory
// mapped.
///////////////////////////////////////////////////////////////////////////////
class cMemoryArchive : public cMemMappedArchive
{
public:
cMemoryArchive(int maxSize = 0x8000000); // default max size == 128MB
~cMemoryArchive();
virtual bool EndOfFile();
virtual void Seek(int64 offset, SeekFrom from); // throw(eArchive)
virtual int64 CurrentPos() const;
virtual int64 Length() const;
virtual void MapArchive(int64 offset, int64 len); // throw(eArchive)
virtual void MapArchive(int64 offset, int64 len) const; // throw(eArchive)
void Truncate(); // set the length to the current pos
int8* GetMemory() const { return mpMemory; }
protected:
int8* mpMemory;
int mAllocatedLen;
int mMaxAllocatedLen;
int mLogicalSize;
int mReadHead;
virtual int Read(void* pDest, int count);
virtual int Write(const void* pDest, int count); // throw(eArchive)
virtual void AllocateMemory(int len); // throw(eArchive)
};
///////////////////////////////////////////////////////////////////////////////
// cFixedMemArchive -- a memory archive that operates on a fixed-sized block of
// memory that has already been allocated
///////////////////////////////////////////////////////////////////////////////
class cFixedMemArchive : public cBidirArchive
{
public:
cFixedMemArchive();
cFixedMemArchive( int8* pMem, int32 size );
virtual ~cFixedMemArchive();
void Attach( int8* pMem, int32 size );
// this method associates the archive with pMem and sets the size of the
// archive. Unlike cMemoryArchive, this may never grow or shrink in size.
//-----------------------------------
// cBidirArchive interface
//-----------------------------------
virtual void Seek (int64 offset, SeekFrom from) ; // throw(eArchive);
virtual int64 CurrentPos () const ;
virtual int64 Length () const ;
virtual bool EndOfFile();
protected:
//-----------------------------------
// cArchive interface
//-----------------------------------
virtual int Read(void* pDest, int count); // throw(eArchive)
virtual int Write(const void* pDest, int count); // throw(eArchive)
int8* mpMemory;
int32 mSize;
int32 mReadHead;
};
class cFileArchive : public cBidirArchive
{
public:
cFileArchive();
virtual ~cFileArchive();
enum OpenFlags
{
FA_OPEN_TEXT = 0x1,
FA_OPEN_TRUNCATE = 0x2
};
// TODO: Open should throw
virtual void OpenRead(const TCHAR* filename, uint32 openFlags = 0 );
virtual void OpenReadWrite(const TCHAR* filename, uint32 openFlags = FA_OPEN_TRUNCATE );
// opens a file for reading or writing; the file is always created if it doesn't exist,
// and is truncated to zero length if truncateFile is set to true;
TSTRING GetCurrentFilename(void) const;
virtual void Close(void);
void Truncate(); // throw(eArchive) // set the length to the current pos
//-----------------------------------
// cBidirArchive interface
//-----------------------------------
virtual bool EndOfFile();
virtual void Seek(int64 offset, SeekFrom from); // throw(eArchive)
virtual int64 CurrentPos() const;
virtual int64 Length() const;
protected:
int64 mFileSize; //Size of FileArchive
int64 mReadHead; //Current position of read/write head
//-----------------------------------
// cArchive interface
//-----------------------------------
virtual int Read(void* pDest, int count);
virtual int Write(const void* pDest, int count); //throw(eArchive)
bool isWritable;
cFile mCurrentFile;
TSTRING mCurrentFilename; //current file
};
///////////////////////////////////////////////////////////////
// cLockedTemporaryFileArchive -- this class uses as an archive a file
// that is not accessable to any other process besides the calling one.
// the file will be deleted from the filesystem on Close();
//
// implemented by using cFileArchive and overwriting open and close
// functions
//
class cLockedTemporaryFileArchive : public cFileArchive
{
public:
virtual void OpenReadWrite ( const TCHAR* filename = NULL, uint32 openFlags = FA_OPEN_TRUNCATE );
// creates the file. filename must not exist on the file system.
// if filename is NULL, the class will create and use a temporary file.
// truncateFile has no meaning
//virtual void OpenReadWriteThrow ( const TCHAR* filename = NULL, bool truncateFile = true ) throw (eArchive);
// this is the same as OpenReadWrite, except an exception is thrown on error (of type
// cArchive::ERR_OPEN_FAILED)
virtual void Close();
// close and delete the file
private:
// open for read only makes no sense if we're always creating the file,
// so disallow read only file opens
virtual void OpenRead( const TCHAR*, uint32 openFlags = 0 ) { ASSERT( false ); THROW_INTERNAL("archive.h"); }
};
/*
// TODO: fill these out
///////////////////////////////////////////////////////////////////////////////
// class cMMFileArchive --
///////////////////////////////////////////////////////////////////////////////
class cMMFileArchive : public cMemMappedArchive
{
public:
};
///////////////////////////////////////////////////////////////////////////////
// class cNetArchive --
///////////////////////////////////////////////////////////////////////////////
class cNetArchive : public cArchive
{
public:
};
*/
#endif

188
src/core/archive_t.cpp Normal file
View File

@ -0,0 +1,188 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// archive_t.cpp
//
// test the archive component
#include "stdcore.h"
#include "archive.h"
#include "test/test.h"
#include "error.h"
#include <stdio.h>
TSS_EXCEPTION(eTestArchiveError, eError);
void TestArchive()
{
// cMemoryArchive
cMemoryArchive memarch;
memarch.WriteInt32(1);
memarch.WriteInt32(2);
memarch.WriteInt32(3);
memarch.WriteInt32(4);
TSTRING s = _T("Weenus");
memarch.WriteString(s);
memarch.WriteInt64(1234567L);
memarch.WriteInt16(42);
memarch.Seek(0, cBidirArchive::BEGINNING);
int32 i;
int64 l;
memarch.ReadInt32(i);
TEST(i == 1);
memarch.ReadInt32(i);
TEST(i == 2);
memarch.ReadInt32(i);
TEST(i == 3);
memarch.ReadInt32(i);
TEST(i == 4);
TSTRING s2;
memarch.ReadString(s2);
TEST(s2.compare(_T("Weenus")) == 0);
memarch.ReadInt64(l);
TEST(l == 1234567L);
TEST(memarch.ReadBlob(NULL, sizeof(int16)) == sizeof(int16));
TEST(memarch.ReadBlob(NULL, 1024) == 0);
try {
memarch.ReadInt32(i);
throw eTestArchiveError();
}
catch (eArchive& e)
{
// Cool we got the right exception
(void)e;
}
catch (eError& e)
{
TEST(false);
(void)e;
}
memarch.MapArchive(4 * sizeof(int32) + sizeof(int32) + 6, sizeof(int64));
TEST(memarch.GetMappedOffset() == 4 * sizeof(int32) + sizeof(int32) + 6);
TEST(memarch.GetMappedLength() == sizeof(int64));
// TEST(tw_ntohll(*(int64*)memarch.GetMap()) == 1234567L);
// cLockedTemporaryFileArchive
TSTRING lockedFileName = TEMP_DIR;
lockedFileName += _T("/inaccessable_file.bin");
cLockedTemporaryFileArchive lockedArch;
// try to create an archive using a temp file
lockedArch.OpenReadWrite();
lockedArch.Close();
// this should open and lock the file -- shouldn't be able to access it
lockedArch.OpenReadWrite(lockedFileName.c_str());
lockedArch.Seek(0, cBidirArchive::BEGINNING);
// shouldn't be able to see these changes
lockedArch.WriteInt32(1);
lockedArch.WriteInt32(2);
lockedArch.WriteInt32(3);
lockedArch.WriteInt32(4);
lockedArch.WriteString(s);
lockedArch.WriteInt64(1234567L);
lockedArch.WriteInt16(42);
// this should delete the file
lockedArch.Close();
// cFileArchive
TSTRING fileName = TEMP_DIR;
fileName += _T("/archive_test.bin");
cFileArchive filearch;
filearch.OpenReadWrite(fileName.c_str());
filearch.Seek(0, cBidirArchive::BEGINNING);
filearch.WriteInt32(1);
filearch.WriteInt32(2);
filearch.WriteInt32(3);
filearch.WriteInt32(4);
filearch.WriteString(s);
filearch.WriteInt64(1234567L);
filearch.WriteInt16(42);
filearch.Close();
int32 j;
int64 k;
filearch.OpenRead(fileName.c_str());
filearch.Seek(0, cBidirArchive::BEGINNING);
filearch.ReadInt32(j);
TEST(j == 1);
filearch.ReadInt32(j);
TEST(j == 2);
filearch.ReadInt32(j);
TEST(j == 3);
filearch.ReadInt32(j);
TEST(j == 4);
TSTRING s3;
filearch.ReadString(s3);
TEST(s3.compare(_T("Weenus")) == 0);
filearch.ReadInt64(k);
TEST(k == 1234567L);
TEST(filearch.ReadBlob(NULL, sizeof(int16)) == sizeof(int16));
TEST(filearch.ReadBlob(NULL, 1024) == 0); // should be EOF
try {
filearch.ReadInt32(j);
throw eTestArchiveError();
}
catch (eArchive& e)
{
// Cool we got the right exception
(void)e;
}
catch (eError& e)
{
TEST(false);
(void)e;
}
}

190
src/core/charutil.cpp Normal file
View File

@ -0,0 +1,190 @@
//
// 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.
//
//
// Name....: charutil.cpp
// Date....: 10/20/99
// Creator.: Brian McFeely (bmcfeely)
//
// [Description]
//
#include "stdcore.h"
#include "charutil.h"
#include "ntmbs.h"
/* NOW WE USE tss::strinc
// like mblen but also for wchar_t
int util_tlen( const TCHAR* cur, size_t count )
{
int nch = -2; // 'unused' value
ASSERT( count >= 0 );
#ifdef _UNICODE
if( count > 0 )
nch = 1; // next char is always one TCHAR long
else
nch = 0; // no more chars
#else
nch = ::mblen( cur, count ); // here sizeof(TCHAR) == 1
#endif
ASSERT( nch != -2 ); // make sure nch was set
return nch;
}
*/
//
// finds the next whole character in string identified by ['cur'-'end')
// identifies beginning of char in 'first', then end of character in 'last'
// returns number of TCHARs that make up the next character
// if there are no more characters, will return 0 and first = last = end
// POSTCONDITIONS:
//
// RETURNS:
//
// THROWS:
//
// COMPLEXITY:
//
//
/* static */
bool cCharUtil::PeekNextChar( const TSTRING::const_iterator& cur,
const TSTRING::const_iterator& end,
TSTRING::const_iterator& first,
TSTRING::const_iterator& last )
{
//
// do we have a valid string here?
//
if( cur > end )
{
return false;
}
if( cur == end )
{
first = last = end;
return false;
}
if( *cur == _T('\0') )
{
first = last = cur;
return false;
}
first = cur;
// last = tss::strinc( cur );
last = *cur ? cur + 1 : cur;
return true;
}
/* OLD way of doing this...
NOW WE USE tss::strinc
int cCharUtil::PeekNextChar( const TSTRING::const_iterator& cur,
const TSTRING::const_iterator& end,
TSTRING::const_iterator& first,
TSTRING::const_iterator& last,
bool fThrowOnError )
{
//
// do we have a valid string here?
//
if( cur > end )
return -1;
//
// determine length of character in TCHARs
//
int charSizeInTCHARs = util_tlen( cur, (size_t)end - (size_t)cur );
if( charSizeInTCHARs == -1 ) // TODO:BAM -- what if size is zero? does that make sense?
{
if( fThrowOnError )
throw eCharUtilUnrecognizedChar();
else
return -1;
}
//
// denote beginning and end of character
//
first = cur; // first char always starts at 'cur'
last = first + charSizeInTCHARs;
//
// there exist more characters
//
return charSizeInTCHARs;
}
*/
//=============================================================================
//
// /* static */
// bool cCharUtil::PopNextChar( TSTRING::const_iterator& cur,
// const TSTRING::const_iterator& end,
// TSTRING::const_iterator& first,
// TSTRING::const_iterator& last )
//-----------------------------------------------------------------------------
// REQUIRES:
//
// EFFECTS:
//
// same as PeekNextChar but increments 'cur' to 'last'
//
// POSTCONDITIONS:
//
// RETURNS:
//
// THROWS:
//
// COMPLEXITY:
//
//
/* static */
bool cCharUtil::PopNextChar( TSTRING::const_iterator& cur,
const TSTRING::const_iterator& end,
TSTRING::const_iterator& first,
TSTRING::const_iterator& last )
{
bool f = PeekNextChar( cur, end, first, last );
cur = last; // pop causes 'cur' to move to just beyond character ('last')
return f;
}
// eof: charutil.cpp

66
src/core/charutil.h Normal file
View File

@ -0,0 +1,66 @@
//
// 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.
//
//
// Name....: charutil.h
// Date....: 10/20/99
// Creator.: Brian McFeely (bmcfeely)
//
// [Description]
//
#ifndef __CHARUTIL_H
#define __CHARUTIL_H
// TODO:BAM -- get rid of this class and just use tss::strinc() !!!!!
class cCharUtil
{
public:
// finds the next whole character in string identified by ['cur'-'end')
// identifies beginning of char in 'first', then end of character in 'last'
// returns 'are there more characters in string?'
// if there are no more characters, will return 0 and first = last = end
static bool PeekNextChar( const TSTRING::const_iterator& cur,
const TSTRING::const_iterator& end,
TSTRING::const_iterator& first,
TSTRING::const_iterator& last );
// same as PeekNextChar but increments 'cur' to 'last'
static bool PopNextChar( TSTRING::const_iterator& cur,
const TSTRING::const_iterator& end,
TSTRING::const_iterator& first,
TSTRING::const_iterator& last );
};
#endif//__CHARUTIL_H

105
src/core/charutil_t.cpp Normal file
View File

@ -0,0 +1,105 @@
//
// 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.
//
//
// Name....: charutil_t.cpp
// Date....: 10/22/99
// Creator.: Brian McFeely (bmcfeely)
//
#include "stdcore.h"
#ifdef TSS_TEST
#include "test/utx.h"
#include "charutil.h"
#include "debug.h"
#include "errorbucketimpl.h"
///////////////////////////////////////////////////////////////////////////////
// cCharEncoderTest
///////////////////////////////////////////////////////////////////////////////
class cCharEncoderTest
{
public:
void PrintChars( const TSTRING& str )
{
const TCHAR* cur = str.begin();
const TCHAR* end = str.end();
const TCHAR* first = NULL;
const TCHAR* last = NULL;
while( cCharUtil::PopNextChar( cur, end, first, last ) )
{
TCOUT << _T("char length: ") << (int)(last - first) << std::endl;
TCOUT << _T("char: <");
for( const TCHAR* at = first; at != last; at++ )
{
if( at != first )
TCOUT << _T(",");
TCOUT << (int)*at;
}
TCOUT << _T(">") << std::endl;
}
TCOUT << _T("----------------------------") << std::endl;
}
///////////////////////////////////////////////////////////////////////////
// Basic
///////////////////////////////////////////////////////////////////////////
void Basic( tss::TestContext& ctx )
{
try
{
PrintChars( _T("foo") );
PrintChars( _T("fo\x2354") );
}
catch( eError& e )
{
cErrorReporter::PrintErrorMsg( e );
ASSERT(false);
}
}
};
TSS_BeginTestSuiteFrom( cCharEncoderTest )
TSS_AddTestCase( Basic );
TSS_EndTestSuite( cCharEncoderTest )
#endif // TSS_TEST
// eof: charutil_t.cpp

472
src/core/cmdlineparser.cpp Normal file
View File

@ -0,0 +1,472 @@
//
// 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.
//
// cmdlineparser.cpp
#include "stdcore.h"
#include "cmdlineparser.h"
#include "corestrings.h"
///////////////////////////////////////////////////////////////////////////////
// ctor, dotr
///////////////////////////////////////////////////////////////////////////////
cCmdLineParser::cCmdLineParser() :
mArgTable(HASH_VERY_SMALL),
mLastArgInfo(-1, PARAM_NONE)
{
}
cCmdLineParser::~cCmdLineParser()
{
}
///////////////////////////////////////////////////////////////////////////////
// AddArg
///////////////////////////////////////////////////////////////////////////////
void cCmdLineParser::AddArg(int argId, const TSTRING& arg, const TSTRING& alias, ParamCount numParams, bool multipleAllowed)
{
if(arg.empty() && alias.empty())
{
// this refers to the list of parameters that comes after all the cmd line switches
mLastArgInfo.mId = argId;
mLastArgInfo.mNumParams = numParams;
return ;
}
if(! arg.empty())
mArgTable.Insert(arg, cArgInfo(argId, numParams));
if(! alias.empty())
{
// put the alias in the table with a '-' prepended to it so it matches '--'
TSTRING str(_T("-"));
str += alias;
mArgTable.Insert(str, cArgInfo(argId, numParams));
}
// This argument can appear more than once on the command line.
if( multipleAllowed )
mMultipleAllowed.insert( argId );
}
///////////////////////////////////////////////////////////////////////////////
// Clear
///////////////////////////////////////////////////////////////////////////////
void cCmdLineParser::Clear()
{
mLastArgInfo.mId = -1;
mLastArgInfo.mNumParams = PARAM_INVALID;
mArgTable.Clear();
mArgData.clear();
mMutExList.clear();
}
///////////////////////////////////////////////////////////////////////////////
// Parse
///////////////////////////////////////////////////////////////////////////////
void cCmdLineParser::Parse(int argc, const TCHAR *const * argv)
{
// clear out any existing data
mArgData.clear();
const TCHAR* pCurArg = 0;
bool bProcessedFinalParams = false; // gets set to true when the parameters to the command line are processed
// I assume argv[0] is the executable name...
for(int i=1; i < argc; i++)
{
if(argv[i][0] == _T('-'))
{
pCurArg = argv[i];
// this is a switch; find it in the table...
cArgInfo argInfo;
if ( !mArgTable.Lookup( TSTRING(&argv[i][1] ), argInfo ) )
{
// unknown switch!
throw eCmdLineInvalidArg(
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
+ pCurArg );
}
//
// make sure this hasn't been specified yet...
//
if( ArgInList( argInfo.mId ) )
{
// Make sure it isn't okay for this one to appear more than once...
std::set<int>::iterator it = mMultipleAllowed.find( argInfo.mId );
if( it == mMultipleAllowed.end() )
{
// It wasn't in our list of allowed params, so error.
throw eCmdLineMultiArg(
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
+ argv[i] );
}
}
//
// add it to the list..
//
mArgData.push_back(cArgData(argInfo.mId, TSTRING(argv[i])));
cArgData& curArg = mArgData.back();
switch( argInfo.mNumParams )
{
case PARAM_NONE:
// make sure there are no parameters to this, but be careful because
// it is legal to start the parameters to the executable here.
if((i+1 < argc) && (argv[i+1][0] != _T('-')))
{
// search for any more parameters
// TODO: In the future we may want to support a '--' switch that specifies the start
// of parameters to the executable.
for (int j = i + 2; j < argc; ++j )
{
if (argv[j][0] == _T('-'))
{
// >0 parameter passed !
throw eCmdLineBadParam(
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
+ pCurArg );
}
}
}
break;
case PARAM_ONE:
// get the next parameter...
i++;
if ( (i >= argc) || (argv[i][0] == _T('-')) )
{
// zero parameters passed to something that needed one param
throw eCmdLineBadParam(
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
+ pCurArg );
}
curArg.mParams.push_back( TSTRING(argv[i]) );
break;
case PARAM_MANY:
i++;
while((i < argc) && (argv[i][0] != _T('-')))
{
curArg.mParams.push_back(TSTRING(argv[i]));
i++;
}
i--; // since we have gone too far at this point
break;
default:
ASSERTMSG( false, "Unknown number of arguments to parser" );
}
}
else
{
bProcessedFinalParams = true;
// this must be the final "unnamed" arg
// first, make sure it is consistent with the current info...
bool bResult = true;
switch(mLastArgInfo.mNumParams)
{
case PARAM_NONE:
// this is an error; they didn't want any command line parameters...
bResult = false;
break;
case PARAM_ONE:
if(i+1 != argc)
// there is >1 final parameter; it is an error
bResult = false;
break;
case PARAM_MANY:
// we'll catch errors below
break;
default:
ASSERT(false);
}
if(! bResult)
{
throw eCmdLineBadParam( );
}
// ok, we can push the final parameter info onto the list...
mArgData.push_back(cArgData(mLastArgInfo.mId));
cArgData& curArg = mArgData.back();
while ( i < argc )
{
if ( argv[i][0] == _T('-') )
{
if ( ! pCurArg )
{
throw eCmdLineBadSwitchPos(
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
+ argv[i] );
}
else
{
// there was an extra parameter passed somewhere!
throw eCmdLineBadArgParam(
TSS_GetString( cCore, core::STR_ERR2_BAD_ARG_PARAMS )
+ pCurArg );
}
}
// add this param to the list
curArg.mParams.push_back(TSTRING(argv[i]));
i++;
}
}
}
// it is possible not to process the final command line parameters in the "else" case above
// (this only occurs if there are no command line parameters specified) so let's make sure that
// is consistent with what we are configured with...
// NOTE -- it is ok to have no cmd line parameters if they specified PARAM_NONE or PARAM_MANY
if(! bProcessedFinalParams)
{
if(mLastArgInfo.mNumParams == PARAM_ONE)
{
throw eCmdLineBadParam( );
}
}
// Check for "relationship errors":
TestMutEx();
TestDependency();
}
///////////////////////////////////////////////////////////////////////////////
// TestMutEx
///////////////////////////////////////////////////////////////////////////////
void cCmdLineParser::TestMutEx()
{
std::list<std::pair<int,int> >::const_iterator i;
cCmdLineIter iter1(*this), iter2(*this);
for(i = mMutExList.begin(); i != mMutExList.end(); i++)
{
//TODO -- there is a much more efficent way to do this (using cFCOPropVector, for example)
// the command line is presumably small enough, tho, that it probably isn't a big
// deal to do it this way.
iter1.SeekToArg(i->first);
if(! iter1.Done())
{
iter2.SeekToArg(i->second);
if(! iter2.Done())
{
// we have a mutual exclusion violation!
throw eCmdLineMutEx(
iter1.ActualParam()
+ _T(", ")
+ iter2.ActualParam() );
}
}
}
}
///////////////////////////////////////////////////////////////////////////////
// TestDependency
///////////////////////////////////////////////////////////////////////////////
void cCmdLineParser::TestDependency()
{
std::list< std::pair< std::pair< int, int>, bool > >::const_iterator i;
cCmdLineIter iter1(*this), iter2(*this);
for( i = mDependencyList.begin(); i != mDependencyList.end(); ++i)
{
iter1.SeekToArg( i->first.first );
// was it on the command line?
if( !iter1.Done() )
{
// it was, is the corresponding arg on the command line?
iter2.SeekToArg( i->first.second );
if( iter2.Done() ) // it wasn't, dependency error
{
TSTRING arg1, arg2, alias1, alias2;
cCmdLineParser::LookupArgInfo( i->first.first, arg1, alias1 );
cCmdLineParser::LookupArgInfo( i->first.second, arg2, alias2 );
// determine in which form the user passed the arguments,
// and construct the error message in the same form
if ( iter1.ActualParam().length() == 2 )
throw eCmdLineDependency( _T("The switch -") + arg1 + _T(" requires -") + arg2 +_T(".") );
else
throw eCmdLineDependency( _T("The switch --") + alias1 + _T(" requires --") + alias2 + _T(".") );
}
}
else if( i->second )
// only make this second check if the dependencies are MUTUAL,
// as indicated (or not) by the bool value.
{
iter2.SeekToArg( i->first.second );
// the first arg in the pair was not on the command line,
// so just make sure the second isn't there...
if( !iter2.Done() )
{
// arg2 appeared without arg1, so dependency error.
TSTRING arg1, arg2, alias1, alias2;
cCmdLineParser::LookupArgInfo( i->first.first, arg1, alias1 );
cCmdLineParser::LookupArgInfo( i->first.second, arg2, alias2 );
// determine in which form the user passed the arguments,
// and construct the error message in the same form
if ( iter1.ActualParam().length() == 2 )
throw eCmdLineDependency( _T("The switch -") + arg2 + _T(" requires -") + arg1 +_T(".") );
else
throw eCmdLineDependency( _T("The switch --") + alias2 + _T(" requires --") + alias1 + _T(".") );
}
}
} //end for
}
///////////////////////////////////////////////////////////////////////////////
// AddMutEx
///////////////////////////////////////////////////////////////////////////////
void cCmdLineParser::AddMutEx(int argId1, int argId2)
{
// note that I do no checking for duplicates here...
std::pair<int, int> mutEx(argId1, argId2);
ASSERT(argId1 != argId2);
mMutExList.push_back(mutEx);
}
///////////////////////////////////////////////////////////////////////////////
// AddDependency
///////////////////////////////////////////////////////////////////////////////
void cCmdLineParser::AddDependency(int argId1, int argId2, bool mutual )
{
// again, no checking for duplicates... would a set
// prove to be a better container for this operation?
std::pair< int, int > Args( argId1, argId2 );
std::pair< std::pair< int, int >, bool > Dep( Args, mutual );
ASSERT(argId1 != argId2);
mDependencyList.push_back( Dep);
}
///////////////////////////////////////////////////////////////////////////////
// TraceContents
///////////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
void cCmdLineParser::TraceContents(int dl)
{
cDebug d("cCmdLineParser::TraceContents");
if(dl == -1)
dl = cDebug::D_DEBUG;
std::list<cArgData>::const_iterator i;
for(i = mArgData.begin(); i != mArgData.end(); i++)
{
d.Trace(dl, "* Item id:%d\n", i->mId);
for(std::vector<TSTRING>::const_iterator vi = i->mParams.begin(); vi != i->mParams.end(); vi++)
{
d.Trace(dl, "\t%s\n", vi->c_str());
}
}
d.Trace(dl, "--- Switch id table ---\n");
cHashTableIter<TSTRING, cArgInfo> iter(mArgTable);
for(iter.SeekBegin(); ! iter.Done(); iter.Next())
{
d.Trace(dl, "[%d] %s\n", iter.Val().mId, iter.Key().c_str());
}
d.Trace(dl, "[%d] Final Param List\n", mLastArgInfo.mId);
}
#endif
///////////////////////////////////////////////////////////////////////////////
// LookupArgInfo
///////////////////////////////////////////////////////////////////////////////
bool cCmdLineParser::LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) const
{
arg = _T("");
alias = _T("");
cHashTableIter<TSTRING, cArgInfo> iter(mArgTable);
for(iter.SeekBegin(); ! iter.Done(); iter.Next())
{
if(iter.Val().mId == argId)
{
TSTRING str = iter.Key();
if((str.length() > 0) && (str[0] == _T('-')))
{
// this is the alias!
alias = (str.c_str() + 1);
}
else
{
// this is the arg...
arg = str;
}
}
}
return ((! arg.empty()) || (! alias.empty()));
}
///////////////////////////////////////////////////////////////////////////////
// ArgInList
///////////////////////////////////////////////////////////////////////////////
bool cCmdLineParser::ArgInList(int argId)
{
std::list<cArgData>::iterator i;
for( i = mArgData.begin(); i != mArgData.end(); i++ )
{
if( i->mId == argId )
return true;
}
return false;
}
//#############################################################################
// cCmdLineIter
//#############################################################################
///////////////////////////////////////////////////////////////////////////////
// SeekToArg
///////////////////////////////////////////////////////////////////////////////
bool cCmdLineIter::SeekToArg(int argId) const
{
for(SeekBegin(); ! Done(); Next())
{
if(ArgId() == argId)
return true;
}
return false;
}

267
src/core/cmdlineparser.h Normal file
View File

@ -0,0 +1,267 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// cmdlineparser.h
//
// cCmdLineParser.h -- class that tokenizes the command line
#ifndef __CMDLINEPARSER_H
#define __CMDLINEPARSER_H
#ifndef __HASHTABLE_H
#include "hashtable.h"
#endif
#ifndef __DEBUG_H
#include "debug.h"
#endif
#ifndef __ERROR_H
#include "error.h"
#endif
//=============================================================================
// eCmdLine
//=============================================================================
TSS_EXCEPTION( eCmdLine, eError )
TSS_EXCEPTION( eCmdLineInvalidArg, eCmdLine ) // an arg on the command line is not recognized
TSS_EXCEPTION( eCmdLineBadArgParam, eCmdLine ) // wrong number of parameters to an argument
TSS_EXCEPTION( eCmdLineBadParam, eCmdLine ) // wrong number of paramters to the executable (not associated with any arguments)
TSS_EXCEPTION( eCmdLineBadSwitchPos,eCmdLine ) // a '-' arg appeared after the final parameter list
TSS_EXCEPTION( eCmdLineMutEx, eCmdLine ) // a mutual exclusion error has occured
TSS_EXCEPTION( eCmdLineDependency, eCmdLine ) // a dependency error has occurred.
TSS_EXCEPTION( eCmdLineMultiArg, eCmdLine ) // an arg was found twice in the command line
/*
// cCmdLineParser owns errors 600-699
// these can be turned into a string by using cErrorTable
enum ErrorType
{
ERR_NONE = 601, // no error
ERR_INVALID_ARG = 602, // an arg on the command line is not recognized
ERR_BAD_ARG_PARAMS = 603, // wrong number of parameters to an argument
ERR_BAD_PARAMS = 604, // wrong number of paramters to the executable (not associated with any arguments)
ERR_SWITCH_AFTER_FINAL_LIST = 605, // a '-' arg appeared after the final paramter list
ERR_MUTUAL_EXCLUSION = 606, // a mutual exclusion error has occured
ERR_MULTIPLE_ARG = 607, // an arg was found twice in the command line
ERR_INVALID // top of enum
};
// for storing error information
ErrorType mCurError;
TSTRING mCurErrorString;
void GetErrorInfo(ErrorType& et, TSTRING& errorData) const;
// returns information on the type of error that occured in a Parse() command. Only
// returns valid information if Parse() had just been called and returned false. A
// second call to Parse() might alter existing error info
*/
//=============================================================================
// cCmdLineParser
//=============================================================================
class cCmdLineParser
{
public:
cCmdLineParser();
~cCmdLineParser();
enum ParamCount
{
PARAM_NONE, // no parameters to arg
PARAM_ONE, // one parameter to arg
PARAM_MANY, // zero or more paramters to arg
PARAM_INVALID // top of enum
};
void AddArg(int argId, const TSTRING& arg, const TSTRING& alias, ParamCount numParams, bool multipleAllowed = false);
// this method should be called for each argument that can appear on the
// command line.
// argId -- a number that uniquely identifies the argument; no two arguments
// may have the same id (ASSERT-enforced)
// arg -- string that comes after the '-'. can be _T("") if there is only
// a string representation
// alias -- string that comes after '--' which has the same meaning. Can be _T("")
// if there is no alias. If both arg and alias are empty strings, then this arg
// represents the list of arguments that comes at the end of the command line
// numParams -- number of parameters that this argument needs
void AddMutEx(int argId1, int argId2);
// this adds a mutual exclusion constraint. When Parse() is called, if argId1 and
// argId2 both exist on the command line, then the parse will fail and the error
// value ERR_MUTUAL_EXCLUSION will be set.
void AddDependency(int argId1, int argId2, bool mutual = false );
// This adds a dependency constraint. When Parse() is called, if argId1
// exists on the command line independent from argId2, then the parse will fail.
// If the default param mutual is true, then the command parser will check for
// argId1 if argId2 is passed. We do this, since it is possible for one arg to
// depend on another, but have the other arg alone on the command line, legally.
void Parse(int argc, const TCHAR *const * argv); // throw eCmdLine
// after AddArg() has been called for every argument that could be processed by the
// command line, call this to tokenize argv. If the return value is false, then
// the input was invalid in some way; the actual error can be determined by calling
// GetErrorInfo() below.
void Clear();
// clear out all information that this class contains
bool LookupArgInfo(int argId, TSTRING& arg, TSTRING& alias) const;
// given an argId, fill out the strings with the argument and alias strings. Returns false
// if the argId cannot be found. This method is not very fast, so don't use it often.
#ifdef _DEBUG
void TraceContents(int dl = -1) ;
#endif
private:
void TestMutEx();
// tests for mutual exclusion violations; if it fails, the current error is set and false
// is returned.
void TestDependency();
// tests for all dependency violations.
bool ArgInList(int argId);
// returns true if an argument with the specified id already exists in the list; this is used
// to make sure the same arg doesn't appear >1 time on the command line
// for storing information on paramers
struct cArgInfo
{
int mId;
ParamCount mNumParams;
cArgInfo(int i = -1, ParamCount p = PARAM_INVALID) : mId(i), mNumParams(p) {}
};
// for storing parsed argv information
struct cArgData
{
int mId;
std::vector<TSTRING> mParams;
TSTRING mActualParam; // a string representation of what was actually on the command line
cArgData(int id = -1, const TSTRING& actualParam = TSTRING(_T(""))) : mId(id), mActualParam(actualParam) {}
};
cHashTable<TSTRING, cArgInfo> mArgTable;
cArgInfo mLastArgInfo; // info on the argument that comes at the end of the command line (with no associated '-x' or '--x')
std::list<cArgData> mArgData;
std::list<std::pair<int,int> > mMutExList; // all of the mutual exclusions
std::list< std::pair < std::pair<int,int>, bool > > mDependencyList; // all of the dependencies
std::set< int > mMultipleAllowed;
friend class cCmdLineIter;
};
///////////////////////////////////////////////////////////////////////////////
// cCmdLineIter -- used to iterate over the tokenized command line parameters;
// is only useful after cCmdLineParser::Parse() has been called.
///////////////////////////////////////////////////////////////////////////////
class cCmdLineIter
{
public:
cCmdLineIter(const cCmdLineParser& parser);
// iteration
void SeekBegin() const;
bool Done() const;
bool IsEmpty() const;
void Next() const;
bool SeekToArg(int argId) const;
// seeks to the argument with the given argId. returns
// false and Done() == true if it couldn't find it.
// access to the argument data
int ArgId() const;
// returns the id of this arg; ASSERTs if Done() == true
int NumParams() const;
// returns the number of parameters this argument has
const TSTRING& ActualParam() const;
// returns exactly what was passed on the command line (ie -- what the user typed)
const TSTRING& ParamAt(int index) const;
// returns the parameter at the specified index. ASSERTs if
// the index is out of range.
private:
const std::list<cCmdLineParser::cArgData>& mList;
mutable std::list<cCmdLineParser::cArgData>::const_iterator mIter;
};
//#############################################################################
// inline implementation
//#############################################################################
inline cCmdLineIter::cCmdLineIter(const cCmdLineParser& parser) :
mList(parser.mArgData)
{
SeekBegin();
}
inline void cCmdLineIter::SeekBegin() const
{
mIter = mList.begin();
}
inline bool cCmdLineIter::Done() const
{
return (mIter == mList.end());
}
inline bool cCmdLineIter::IsEmpty() const
{
return (mList.size() == 0);
}
inline void cCmdLineIter::Next() const
{
mIter++;
}
inline int cCmdLineIter::ArgId() const
{
ASSERT(! Done());
return mIter->mId;
}
inline int cCmdLineIter::NumParams() const
{
ASSERT(! Done());
return mIter->mParams.size();
}
inline const TSTRING& cCmdLineIter::ActualParam() const
{
ASSERT(! Done());
return mIter->mActualParam;
}
inline const TSTRING& cCmdLineIter::ParamAt(int index) const
{
ASSERT((index >= 0) && (index < NumParams()));
return mIter->mParams[index];
}
#endif

View File

@ -0,0 +1,178 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// cmdlineparser_t.cpp
#include "stdcore.h"
#include "cmdlineparser.h"
#include "test/test.h"
//#include "tw/twutil.h"
//#include "tw/twstrings.h"
const int argc1 = 9;
const TCHAR* argv1[] =
{
_T("tripwire.exe"),
_T("-m"),
_T("Init"),
_T("-tp"),
_T("one"),
_T("two"),
_T("--verbose"),
_T("frog"),
_T("cat")
};
const int argc2 = 3;
const TCHAR* argv2[] =
{
_T("tripwire.exe"),
_T("-m"),
_T("-v")
};
const int argc3 = 3;
const TCHAR* argv3[] =
{
_T("tripwire.exe"),
_T("dog"),
_T("-v"),
};
// test with the last param wanting 1 or 0 parameters :-)
const int argc4 = 5;
const TCHAR* argv4[] =
{
_T("tripwire.exe"),
_T("-tp"),
_T("-v"),
_T("frog"),
_T("cat")
};
const int argc5 = 4;
const TCHAR* argv5[] =
{
_T("tripwire.exe"),
_T("-tp"),
_T("-v"),
_T("frog")
};
static void PrintCmdLine(int argc, const TCHAR** argv, cDebug d)
{
TSTRING str;
d.TraceDebug("Testing command line:\n");
for(int i=0; i < argc; i++)
{
str += argv[i];
str += _T(" ");
}
d.TraceDebug(_T(">>>%s\n"), str.c_str());
}
void TestCmdLineParser()
{
enum ArgId { ID_M, ID_TP, ID_V, ID_UNNAMED };
try {
cCmdLineParser p;
p.AddArg(ID_M, TSTRING(_T("m")), TSTRING(_T("mode")), cCmdLineParser::PARAM_ONE);
p.AddArg(ID_TP, TSTRING(_T("tp")), TSTRING(_T("twoparam")), cCmdLineParser::PARAM_MANY);
p.AddArg(ID_V, TSTRING(_T("v")), TSTRING(_T("verbose")), cCmdLineParser::PARAM_NONE);
p.AddArg(ID_UNNAMED, TSTRING(_T("")), TSTRING(_T("")), cCmdLineParser::PARAM_MANY);
cDebug d("TestCmdLineParser");
PrintCmdLine(argc1, argv1, d);
p.Parse(argc1, argv1);
#ifdef _DEBUG
p.TraceContents();
#endif
PrintCmdLine(argc2, argv2, d);
p.Parse(argc2, argv2); // should fail.
#ifdef _DEBUG
p.TraceContents();
#endif
PrintCmdLine(argc3, argv3, d);
p.Parse(argc3, argv3); // should fail
#ifdef _DEBUG
p.TraceContents();
#endif
PrintCmdLine(argc4, argv4, d);
p.Parse(argc4, argv4);
#ifdef _DEBUG
p.TraceContents();
#endif
/*
// TODO - test mutual exclusion...
cCmdLineParser::ErrorType et;
TSTRING errStr;
d.TraceDebug("** Making -m and -v mutually exclusive, then running on first cmd line...\n");
p.AddMutEx(ID_M, ID_V);
p.Parse(argc1, argv1); // should fail
p.GetErrorInfo(et, errStr);
TEST(et == cCmdLineParser::ERR_MUTUAL_EXCLUSION);
d.TraceDebug(_T("Mutual exclusion test worked; here is the error string: %s\n"), errStr.c_str());
*/
// make the command line want one parameter
d.TraceDebug("** Changing cmd line to only want one last param...\n");
p.AddArg(ID_UNNAMED, TSTRING(_T("")), TSTRING(_T("")), cCmdLineParser::PARAM_ONE);
PrintCmdLine(argc4, argv4, d);
p.Parse(argc4, argv4); // should fail
#ifdef _DEBUG
p.TraceContents();
#endif
PrintCmdLine(argc5, argv5, d);
p.Parse(argc5, argv5);
#ifdef _DEBUG
p.TraceContents();
#endif
// TODO -- test a bunch more!!!
}
catch (eCmdLine &e)
{
TCERR << _T("Command line error: ");
TCERR << e.GetMsg() << std::endl;
TEST(false);
}
}

1544
src/core/codeconvert.cpp Normal file

File diff suppressed because it is too large Load Diff

275
src/core/codeconvert.h Normal file
View File

@ -0,0 +1,275 @@
//
// 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.
//
//
// Name....: codeconvert.h
// Date....: 9/2/99
// Creator.: Brian McFeely (bmcfeely)
//
// CodePage Conversion between Character Sequences
//
// Notes on Terminology
// --------------------
// ntbs_t -- A null-terminated single byte sequence (pointer)
// char -- A single character
//
// ntmbs_t -- A null-terminated multibyte sequence (pointer)
// mbchar_t -- A single lead or trail byte
//
// ntdbs_t -- A null-terminated two-byte character sequence (pointer)
// dbchar_t -- A single double-byte character
//
// ntwcs_t -- null-terminated two or four-byte wide character sequence (pointer)
// wchar_t -- A single wide (double or quad) character
//
// This module happens to use only multibyte (ntmbs) and double-byte only
// (ntwcs). None of these routines should be used with a wide character
// of unknown size, such as wchar_t, or a UCS4 or quad-byte (ntqbs) pointer.
//
#ifndef __CODECONVERT_H
#define __CODECONVERT_H
/// Requirements
#include "platform.h" // for: Platform specific code
#include "ntmbs.h" // for: NTBS, NTMBS, NTWCS, and NTDBS types
/// Exceptions
TSS_EXCEPTION( eConverter, eError );
TSS_EXCEPTION( eConverterReset, eConverter );
TSS_EXCEPTION( eConverterFatal, eConverter );
TSS_EXCEPTION( eConverterUnsupportedConversion, eConverter );
TSS_EXCEPTION( eConverterUnknownCodepage, eConverter );
/// Classes
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* iCodeConverter -- The CodePage Converter Interface
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
* SYNOPSIS: Converts between the local code page and UCS2 (if possible)
* Ensures a one-to-one correspondance between mb and UCS2 by
* making sure the mapping is roundtrip. If it is not roundtrip,
* or a byte value is not a character, it is cast to a reserved
* region of UCS2 ( 0xE000 - 0xE0FF ).
* CONSTRAINTS:
*
* INVARIANTS:
*
*/
class iCodeConverter
{
public:
static iCodeConverter* GetInstance(); // Singleton
/// Subclass Responsibilities
virtual
int
Convert(
ntmbs_t, // NTMBS buffer
size_t, // Capacity in mbchar_t's (bytes)
const_ntdbs_t, // null terminated two-byte wide character (UCS2 rep)
size_t nCount ) = 0; // Amount to convert in dbchar_t's
// returns number of buffer items converted, -1 on error
virtual
int
Convert(
ntdbs_t, // NTDBS (Null-terminated two byte sequence) buf
size_t, // Capacity in dbchar_t's
const_ntmbs_t, // Null-terminated multi-byte sequence
size_t ) = 0; // Capacity in mbchar_t's (bytes)
// returns number of buffer items converted, -1 on error
protected:
iCodeConverter()
{
};
private:
static iCodeConverter* CreateConverter();
static iCodeConverter* CreateGoodEnoughConverter();
static iCodeConverter* m_pInst;
};
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// cIconvConverter -- Concrete Converter
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#ifdef HAVE_ICONV_H
#include <iconv.h>
#ifdef HAVE_LANGINFO_H
#ifndef __USE_XOPEN
#define __USE_XOPEN 1
#endif
#include <langinfo.h>
#endif
class cIconvUtil
{
public:
static const char* GetCodePageID(); // gets code page id for current locale, throws if error
static bool GetCodePageID( const char** ppCP );
static const char* GetIconvDbIdentifier();
static const char* GetMiddleIdentifier();
static void ResetConverter( iconv_t );
static bool TestConverter( const char* pTo, const char* pFrom );
static iconv_t OpenHandle( const char* pTo, const char* pFrom ); // throws
static void CloseHandle( iconv_t ic );
};
class cIconvConverter : public iCodeConverter
{
public:
static bool Test(); // is there a conversion for the current codepage?
virtual int Convert( ntmbs_t, size_t, const_ntdbs_t, size_t );
virtual int Convert( ntdbs_t, size_t, const_ntmbs_t, size_t );
cIconvConverter();
~cIconvConverter();
private:
void Init();
iconv_t icToDb;
iconv_t icFromDb;
};
class cDoubleIconvConverter : public iCodeConverter
{
public:
static bool Test(); // is there a conversion for the current codepage?
virtual int Convert( ntmbs_t, size_t, const_ntdbs_t, size_t );
virtual int Convert( ntdbs_t, size_t, const_ntmbs_t, size_t );
cDoubleIconvConverter();
~cDoubleIconvConverter();
private:
void Init();
iconv_t icMbToUTF8;
iconv_t icUTF8ToDb;
iconv_t icDbToUTF8;
iconv_t icUTF8ToMb;
};
#endif // HAVE_ICONV_H
/// QUESTION:RAD -- Why not just have one platform-specific of the below
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// cWcharIs32BitUcs2Converterer
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#if WCHAR_IS_32_BITS
// TODO:BAM -- this is not really correct! Convert will not honor nSource!!
// it looks for the first null char!
class cWcharIs32BitUcs2Converterer : public iCodeConverter
{
public:
virtual int Convert( ntmbs_t, size_t, const_ntdbs_t, size_t );
virtual int Convert( ntdbs_t, size_t, const_ntmbs_t, size_t );
};
#endif // WCHAR_IS_32_BITS
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// cWcharIs16BitUcs2Converterer
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#if WCHAR_IS_16_BITS
// TODO:BAM -- this is not really correct! Convert will not honor nSource!!
// it looks for the first null char!
class cWcharIs16BitUcs2Converterer : public iCodeConverter
{
public:
virtual int Convert( ntmbs_t, size_t, const_ntdbs_t, size_t );
virtual int Convert( ntdbs_t, size_t, const_ntmbs_t, size_t );
};
#endif // WCHAR_IS_16_BITS
// does a straight cast of each mbchar_t byte to a dbchar_t and back.
// converts mbchars > 0x7F to our reserved space
class cGoodEnoughConverterer : public iCodeConverter
{
public:
virtual int Convert( ntmbs_t, size_t, const_ntdbs_t, size_t );
virtual int Convert( ntdbs_t, size_t, const_ntmbs_t, size_t );
};
class cConvertUtil
{
enum
{
TSS_UCS2_RESERVED_START = 0xE800u, // E000-E8FF is private use range, but
TSS_UCS2_RESERVED_END = 0xE8FFu, // SJIS and EUC use E000-E757
TSS_HIGH_ASCII_START = 0x0080u,
TSS_HIGH_ASCII_END = 0x00FFu
};
public:
static dbchar_t ConvertNonChar( mbchar_t ch );
static mbchar_t ConvertNonChar( dbchar_t ch );
static bool ValueInReservedRange( mbchar_t ch );
static bool ValueInReservedRange( dbchar_t ch );
};
#endif //__CODECONVERT_H

341
src/core/codeconvert_t.cpp Normal file
View File

@ -0,0 +1,341 @@
//
// 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.
//
//
// Name....: codeconvert_t.cpp
// Date....: 9/8/99
// Creator.: Brian McFeely (bmcfeely)
//
// [Description]
#include "stdcore.h"
#include "codeconvert.h"
#include "core/wchar16.h"
#include "test/test.h"
#include <iomanip>
bool util_IsWideCharSameAsNarrow( char ch );
bool LowASCIILooksLikeUCS2InWchart();
void TestMbToDb();
void TestDbToMb();
void TestCodeConverter()
{
cDebug d("TestCodeConverter()");
#if ( !(HAVE_ICONV_H) && WCHAR_REP_IS_UCS2 )
//
// check that rep is really UCS2
//
TEST( LowASCIILooksLikeUCS2InWchart() );
#endif
d.TraceDetail("Testing multi byte to double byte conversion.\n");
TestMbToDb();
d.TraceDetail("TestMbToDb() done.\n");
// Took out this test as it currently throws and exception.
// We expect not to be able to convert every UCS2 to a multi-byte char.
// d.TraceDetail("Testing double byte to multi byte conversion.\n");
// TestDbToMb();
}
// first last identify the lhs string
// x identifies the start of the second string
// start identifies the original start of the lhs string
template< class IterT >
bool Compare( IterT first, IterT last, IterT x, IterT start )
{
std::pair< IterT, IterT >
p = std::mismatch( first,
last,
x );
if( p.first != last )
{
// success !!
std::cout << "*** mismatched value at: "
<< (int)(p.first - start)
<< ". Values are: "
<< (size_t)tss::util::char_to_size(*p.first)
<< " and "
<< (size_t)tss::util::char_to_size(*p.second)
<< std::endl;
return Compare( p.first + 1, last, p.second + 1, start );
}
return true;
}
void CompareStrings( const std::string& s1, const std::string& s2 )
{
if( s1.length() != s2.length() )
{
std::cout << "*** string lengths didn't match. Lengths were: "
<< s1.length()
<< " and "
<< s2.length()
<< std::endl;
}
if( Compare( s1.begin(), s1.end(), s2.begin(), s1.begin() ) )
{
std::cout << "** string matched."
<< std::endl;
}
}
void DisplayString( const std::string& s )
{
std::string::size_type i;
for( i = 0; i < s.length(); ++i )
{
std::cout << std::hex
<< std::setw(2)
<< std::setfill('0')
<< (size_t)(unsigned char) s[i]
<< " ";
}
}
size_t DistanceToOne( size_t n )
{
size_t dist;
for( dist = 0;
n != 1;
dist++ )
{
n = ( n >> 1 );
}
ASSERT( n == 1 ); // n was not a power of 2!
return dist;
}
void ConvertAndCompareString( const std::string& s )
{
std::cout << "* Converting: ";
DisplayString( s );
std::cout << std::endl;
// convert to dbchar_t string
int nWrote;
wc16_string ws;
ws.resize( s.length() );
nWrote = iCodeConverter::GetInstance()->Convert( (ntdbs_t)ws.c_str(), ws.length(), s.c_str(), ws.length() );
ASSERT( nWrote != -1 );
ws.resize( nWrote );
// convert back to mbchar_t string
std::string s2;
s2.resize( ws.length() * MB_CUR_MAX );
nWrote = iCodeConverter::GetInstance()->Convert( (ntmbs_t)s2.c_str(), s2.length(), ws.c_str(), ws.length() );
ASSERT( nWrote != -1 );
s2.resize( nWrote );
std::cout << "* Result : ";
DisplayString( s2 );
std::cout << std::endl;
CompareStrings( s, s2 );
}
char NonZeroChar( char ch )
{
return ch == 0 ? '0' : ch;
}
// mbchar_t to dbchar_t
void TestMbToDb()
{
std::string s;
s.resize( 0x10000 * 2 ); // two bytes for each combination
for( size_t i = 0; i < 0x1000; i++ )
{
for( size_t j = 0; j < 0x10; j++ )
{
size_t first_byte = ( i & 0xFF00 ) >> 8;
ASSERT( first_byte <= 0xFF );
size_t second_byte = ( ( i & 0x00F0 ) >> 4 ) | j;
ASSERT( second_byte <= 0xFF );
s[ 2 * j ] = NonZeroChar( (char)first_byte );
s[ ( 2 * j ) + 1 ] = NonZeroChar( (char)second_byte );
}
ConvertAndCompareString( s );
}
/*
const std::string::size_type TOTAL_VALUE_COMBINATIONS = 0x10000; // 0x100 ^ 2 (256 possible per byte, and two bytes) (must always be this value)
const std::string::size_type CHARS_AT_A_TIME = 0x10; // can change this, but needs to be a power of 2
const std::string::size_type FIRST_BYTE_MASK = TOTAL_VALUE_COMBINATIONS - CHARS_AT_A_TIME;
const std::string::size_type SECOND_BYTE_MASK = CHARS_AT_A_TIME - 1;
std::string s;
s.resize( CHARS_AT_A_TIME * 2 ); // two bytes for each combination
for( size_t i = 0; i < TOTAL_VALUE_COMBINATIONS / CHARS_AT_A_TIME; i++ )
{
for( size_t j = 0; j < CHARS_AT_A_TIME; j++ )
{
size_t first_byte = ( ( i & FIRST_BYTE_MASK ) >> DistanceToOne( CHARS_AT_A_TIME ) );
ASSERT( first_byte <= 0xFF );
size_t second_byte = ( ( i & ( SECOND_BYTE_MASK << DistanceToOne( CHARS_AT_A_TIME ) ) | j );
ASSERT( second_byte <= 0xFF );
s[ 2 * j ] = NonZeroChar( (char)first_byte );
s[ ( 2 * j ) + 1 ] = NonZeroChar( (char)second_byte );
}
ConvertAndCompareString( s );
}
*/
}
// dbchar_t to mbchar_t
void TestDbToMb()
{
wc16_string ws;
wc16_string::size_type n;
const wc16_string::size_type max = 0x10000;
// Setup string will all UCS2 characters
ws.resize( max );
for( n = 1; n < max; n++ )
{
TEST( n < std::numeric_limits< wc16_string::size_type >::max() );
ws[ n - 1 ] = (WCHAR16)n;
}
// convert to mbchar_t string
std::string s;
s.resize((max - 1) * MB_CUR_MAX);
iCodeConverter::GetInstance()->Convert( (ntmbs_t)s.c_str(), s.length(), ws.c_str(), max - 1 );
// convert back to dbchar_t string
wc16_string ws2;
ws2.resize(max - 1);
iCodeConverter::GetInstance()->Convert( (ntdbs_t)ws2.c_str(), max - 1, s.c_str(), s.length() );
TEST( ws.compare( ws2 ) == 0 );
}
bool util_IsWideCharSameAsNarrow( char ch )
{
cDebug d("LowASCIILooksLikeUCS2InWchart()");
//
// translate to a wide char
//
wchar_t wc;
int i = mbtowc( &wc, &ch, 1 );
//
// assure that it has some representation in
// the wchar character set
//
if( i == -1 )
{
d.TraceDebug( "mbtowc failed on ch=0x%04X\n", (size_t)(unsigned char)ch );
return false;
}
//
// assure that the wide char representation looks like
// UCS2 ( a 8859-1 char in UCS2 looks like 0x00XX, where
// XX is the value of the char )
//
if( (char)wc != ch )
{
d.TraceDebug( "comparison failed on ch=0x%04X, wc=0x%04X\n", (size_t)(unsigned char)ch, (size_t)wc );
return false;
}
return true;
}
bool LowASCIILooksLikeUCS2InWchart()
{
cDebug d("LowASCIILooksLikeUCS2InWchart()");
bool fOK = true;
#if 0 // I hear this function isn't even correct... rjf
//
// save old locale
//
char* pOldLocale =
strdup(
setlocale( LC_CTYPE, NULL ) );
d.TraceDebug( "Old locale: %s\n", pOldLocale );
//
// set to C locale
//
setlocale( LC_CTYPE, "C" );
TEST( 0 == strcmp( "C", setlocale( LC_CTYPE, NULL ) ) );
//
// check each C locale char ( which is the ISO 8859-1 set )
// against it's wchar_trepresentation
//
for( char ch = 0x00; fOK && (unsigned char)ch < 0x80U; ch++ )
fOK &= util_IsWideCharSameAsNarrow( ch );
//
// reset locale
//
setlocale( LC_CTYPE, pOldLocale );
TEST( 0 == strcmp( pOldLocale, setlocale( LC_CTYPE, NULL ) ) );
free( pOldLocale );
#endif
return fOK;
}
// eof: codeconvert_t.cpp

64
src/core/core.cpp Normal file
View File

@ -0,0 +1,64 @@
//
// 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.
//
//
// Name....: core.cpp
// Date....: 5/17/99
// Creator.: Matthew Brinkley (brinkley)
//
//
#include "stdcore.h"
#include "core.h"
#include "coreerrors.h"
#include "codeconvert.h" // for: iCodeConverter::GetInstance
#include "twlocale.h" // for: cTWLocale::InitGlobalLocale
TSS_ImplementPackage( cCore )
cCore::cCore()
{
TSS_REGISTER_PKG_ERRORS( core );
// NOTE: Initialize code converter when cCore is a dependency
// of another package (created on first call to GetInstance(),
// forcing creation here to hasten the display of any errors)
cDebug::SetDebugLevel( cDebug::D_DEBUG );
cDebug::AddOutTarget( cDebug::OUT_STDOUT );
cTWLocale::InitGlobalLocale();
iCodeConverter::GetInstance();
}
// eof: core.cpp

61
src/core/core.h Normal file
View File

@ -0,0 +1,61 @@
//
// 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.
//
//
// Name....: core.h
// Date....: 05/04/99
// Creator.: Robert DiFalco (rdifalco)
//
// The Package class for the TSS core library module.
//
#ifndef __CORE_H
#define __CORE_H
//--Requirements
#include "package.h" // for: Packaging Abstraction
//--Classes
TSS_BeginPackage( cCore )
TSS_DECLARE_STRINGTABLE;
public:
cCore();
TSS_EndPackage( cCore )
#endif //__CORE_H

168
src/core/coreerrors.cpp Normal file
View File

@ -0,0 +1,168 @@
//
// 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.
//
// coreerrors.cpp
//
// Registers all error strings in the core package
//
#include "stdcore.h"
#include "coreerrors.h"
#include "errorgeneral.h"
#include "archive.h"
#include "error.h"
#include "unixexcept.h"
#include "fsservices.h"
#include "serializer.h"
#include "cmdlineparser.h"
#include "twlocale.h"
#include "codeconvert.h"
#include "ntmbs.h"
#include "displayencoder.h"
TSS_BEGIN_ERROR_REGISTRATION( core )
/// Internal
TSS_REGISTER_ERROR( eInternal(), _T("Internal error.") )
/// General
TSS_REGISTER_ERROR( eErrorGeneral(), _T("General Error") );
TSS_REGISTER_ERROR( eOpen(), _T("File could not be opened.") );
TSS_REGISTER_ERROR( eOpenRead(), _T("File could not be opened for reading.") );
TSS_REGISTER_ERROR( eOpenWrite(), _T("File could not be opened for writing.") );
TSS_REGISTER_ERROR( eBadModeSwitch(), _T("Unknown mode specified.") );
TSS_REGISTER_ERROR( eBadCmdLine(), _T("Command line error.") );
/// Archive
TSS_REGISTER_ERROR( eArchive(), _T("Archive error.") )
TSS_REGISTER_ERROR( eArchiveOpen(), _T("File could not be opened.") )
TSS_REGISTER_ERROR( eArchiveWrite(), _T("File could not be written.") )
TSS_REGISTER_ERROR( eArchiveRead(), _T("File could not be read.") )
TSS_REGISTER_ERROR( eArchiveEOF(), _T("End of file reached.") )
TSS_REGISTER_ERROR( eArchiveSeek(), _T("File seek failed.") )
TSS_REGISTER_ERROR( eArchiveMemmap(), _T("Memory mapped archive file invalid.") )
TSS_REGISTER_ERROR( eArchiveOutOfMem(), _T("Archive ran out of memory.") )
TSS_REGISTER_ERROR( eArchiveInvalidOp(),_T("Archive logic error.") )
TSS_REGISTER_ERROR( eArchiveFormat(), _T("Archive file format invalid.") )
TSS_REGISTER_ERROR( eArchiveNotRegularFile(), _T("File is not a regular file.") )
TSS_REGISTER_ERROR( eArchiveCrypto(), _T("File could not be decrypted.") )
TSS_REGISTER_ERROR( eArchiveStringTooLong(), _T("String was too long.") )
/// File
TSS_REGISTER_ERROR( eFile(), _T("File error.") )
TSS_REGISTER_ERROR( eFileOpen(), _T("File could not be opened.") )
TSS_REGISTER_ERROR( eFileWrite(), _T("File could not be written.") )
TSS_REGISTER_ERROR( eFileRead(), _T("File could not be read.") )
TSS_REGISTER_ERROR( eFileEOF(), _T("End of file reached.") )
TSS_REGISTER_ERROR( eFileSeek(), _T("File seek failed.") )
TSS_REGISTER_ERROR( eFileInvalidOp(), _T("File logic error.") )
TSS_REGISTER_ERROR( eFileTrunc(), _T("File could not be truncated.") )
TSS_REGISTER_ERROR( eFileClose(), _T("File could not be closed.") )
TSS_REGISTER_ERROR( eFileFlush(), _T("File could not be flushed.") )
TSS_REGISTER_ERROR( eFileRewind(), _T("File could not be rewound.") )
/// Win32
#if IS_UNIX
TSS_REGISTER_ERROR(eUnix(), _T("Unix API failure.") )
#endif
/// FSServices
TSS_REGISTER_ERROR( eFSServices(), _T("File system error.") )
TSS_REGISTER_ERROR( eFSServicesGeneric(),_T("File system error.") )
/// Serializer
TSS_REGISTER_ERROR( eSerializerUnknownType(), _T("Unknown type encountered in file.\nFile format may not be valid for this platform.") )
TSS_REGISTER_ERROR( eSerializerInputStreamFmt(), _T("Invalid input stream format.") )
TSS_REGISTER_ERROR( eSerializerOutputStreamFmt(), _T("Invalid output stream format.") )
TSS_REGISTER_ERROR( eSerializerInputStremTypeArray(), _T("A bad index was encountered in file.") )
TSS_REGISTER_ERROR( eSerializerArchive(), _T("File read encountered an archive error.") )
TSS_REGISTER_ERROR( eSerializerVersionMismatch(), _T("File version mismatch.") )
TSS_REGISTER_ERROR( eSerializerEncryption(), _T("File encryption error.") )
TSS_REGISTER_ERROR( eSerializer(), _T("File format error.") )
/// Command Line
TSS_REGISTER_ERROR( eCmdLine(), _T("Command line parsing error.") )
TSS_REGISTER_ERROR( eCmdLineInvalidArg(), _T("Invalid argument passed on command line.") )
TSS_REGISTER_ERROR( eCmdLineBadArgParam(), _T("Incorrect number of parameters to a command line argument.") )
TSS_REGISTER_ERROR( eCmdLineBadParam(), _T("Incorrect number of parameters on command line.") )
TSS_REGISTER_ERROR( eCmdLineBadSwitchPos(), _T("Switch appears after final command line parameter.") )
TSS_REGISTER_ERROR( eCmdLineMutEx(), _T("Specified command line switches are mutually exclusive.") )
TSS_REGISTER_ERROR( eCmdLineDependency(), _T("Command line parameter missing.") )
TSS_REGISTER_ERROR( eCmdLineMultiArg(), _T("Command line argument specified more than once.") )
/// TWLocale
TSS_REGISTER_ERROR( eTWLocale(), _T("Localization error.") )
TSS_REGISTER_ERROR( eTWLocaleBadNumFormat(),_T("Bad number format.") )
/// Character Handling (defined in ntmbs.h)
TSS_REGISTER_ERROR( eCharacter(), _T("General Character Handling Error.") )
TSS_REGISTER_ERROR( eCharacterEncoding(), _T("Character Encoding Error.") )
/// Character Conversion Handling (defined in <codeconvert.h>)
TSS_REGISTER_ERROR( eConverter(), _T("General conversion error.") )
TSS_REGISTER_ERROR( eConverterReset(), _T("Converter handle could not be reset.") )
TSS_REGISTER_ERROR( eConverterFatal(), _T("Catastrophic conversion error.") )
TSS_REGISTER_ERROR( eConverterUnsupportedConversion(), _T("Unsupported character conversion.") )
TSS_REGISTER_ERROR( eConverterUnknownCodepage(), _T("Could not identify code page.") )
//
// Display Encoder
//
TSS_REGISTER_ERROR( eEncoder(), _T("Display encoder error.") )
TSS_REGISTER_ERROR( eBadDecoderInput(), _T("Bad input to display encoder.") )
TSS_REGISTER_ERROR( eBadHexConversion(), _T("Bad hex conversion in display encoder.") )
TSS_REGISTER_ERROR( eUnknownEscapeEncoding(), _T("Unknown encoding in display encoder input.") )
TSS_END_ERROR_REGISTRATION()

48
src/core/coreerrors.h Normal file
View File

@ -0,0 +1,48 @@
//
// 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.
//
//
// Name....: coreerrors.h
// Date....: 5/17/99
// Creator.: Matthew Brinkley (brinkley)
//
//
#ifndef __COREERRORS_H
#define __COREERRORS_H
#include "core/errortable.h"
TSS_DECLARE_ERROR_REGISTRATION( core )
#endif//__COREERRORS_H

73
src/core/corestrings.cpp Normal file
View File

@ -0,0 +1,73 @@
//
// 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.
//
//
// Name....: corestrings.cpp
// Date....: 05/06/99
// Creator.: Robert DiFalco (rdifalco)
//
#include "stdcore.h" // for: pch (required by all core source modules)
#include "corestrings.h" // for: cCore and core::STR_IDS
TSS_BeginStringtable( cCore )
TSS_StringEntry( core::STR_ERR2_ARCH_CRYPTO_ERR, _T("File could not be decrypted.") ),
TSS_StringEntry( core::STR_ERR2_BAD_ARG_PARAMS, _T("Argument: ") ),
TSS_StringEntry( core::STR_ERROR_ERROR, _T("### Error") ),
TSS_StringEntry( core::STR_ERROR_WARNING, _T("### Warning") ),
TSS_StringEntry( core::STR_ERROR_COLON, _T(":") ),
TSS_StringEntry( core::STR_ERROR_HEADER, _T("### ") ),
TSS_StringEntry( core::STR_ERROR_EXITING, _T("Exiting...") ),
TSS_StringEntry( core::STR_ERROR_CONTINUING, _T("Continuing...") ),
TSS_StringEntry( core::STR_ERR2_FILENAME, _T("Filename: ") ),
TSS_StringEntry( core::STR_ERROR_FILENAME, _T("Filename: ") ),
TSS_StringEntry( core::STR_UNKNOWN, _T("Unknown") ),
TSS_StringEntry( core::STR_NUMBER_TOO_BIG, _T("Number too big") ),
TSS_StringEntry( core::STR_SIGNAL, _T("Software interrupt forced exit:") ),
TSS_StringEntry( core::STR_NEWLINE, _T("\n") ),
TSS_StringEntry( core::STR_MEMARCHIVE_FILENAME, _T("Error occured in internal memory file") ),
TSS_StringEntry( core::STR_MEMARCHIVE_ERRSTR, _T("") ),
TSS_StringEntry( core::STR_ENDOFTIME, _T("Tripwire is not designed to run past the year 2038.\nNow exiting...") ),
TSS_StringEntry( core::STR_UNKNOWN_TIME, _T("Unknown time") ),
TSS_StringEntry( core::STR_BAD_TEMPDIRECTORY, _T("Solution: Check existence/permissions for directory specified by TEMPDIRECTORY in config file") ),
/// Particularly useful for eCharacter and eCharacterEncoding
TSS_StringEntry( core::STR_ERR_ISNULL, _T("Argument cannot be null.") ),
TSS_StringEntry( core::STR_ERR_OVERFLOW, _T("An overflow has been detected.") ),
TSS_StringEntry( core::STR_ERR_UNDERFLOW, _T("An underflow has been detected.") ),
TSS_StringEntry( core::STR_ERR_BADCHAR, _T("Input contained an invalid character.") )
TSS_EndStringtable( cCore )
// eof: corestrings.cpp

81
src/core/corestrings.h Normal file
View File

@ -0,0 +1,81 @@
//
// 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.
//
//
// Name....: corestrings.h
// Date....: 05/05/99
// Creator.: Robert DiFalco (rdifalco)
//
//
#ifndef __CORESTRINGS_H
#define __CORESTRINGS_H
#include "core.h" // for: STRINGTABLE syntax
//--Message Keys
TSS_BeginStringIds( core )
STR_ERR2_ARCH_CRYPTO_ERR,
STR_ERR2_BAD_ARG_PARAMS,
STR_ERROR_ERROR,
STR_ERROR_WARNING,
STR_ERROR_COLON,
STR_ERROR_HEADER,
STR_ERROR_EXITING,
STR_ERROR_CONTINUING,
STR_ERR2_FILENAME,
STR_ERROR_FILENAME,
STR_NUMBER_TOO_BIG,
STR_UNKNOWN,
STR_SIGNAL,
STR_NEWLINE,
STR_MEMARCHIVE_FILENAME,
STR_MEMARCHIVE_ERRSTR,
STR_ENDOFTIME,
STR_UNKNOWN_TIME,
STR_BAD_TEMPDIRECTORY,
/// Particularly useful for eCharacterSet and eCharacterEncoding
STR_ERR_ISNULL,
STR_ERR_OVERFLOW,
STR_ERR_UNDERFLOW,
STR_ERR_BADCHAR
TSS_EndStringIds( core )
#endif //__CORESTRINGS_H

177
src/core/crc32.cpp Normal file
View File

@ -0,0 +1,177 @@
//
// 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.
//
/* - crc32.cpp
*
*
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* James W. Williams of NASA Goddard Space Flight Center.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
//#include "../../include/config.h"
//#include <stdio.h>
//#include <sys/types.h>
//#ifdef STDLIBH
//#include <stdlib.h>
//#include <unistd.h>
//#endif
//#include "../../include/sigs.h"
#include "stdcore.h"
#include "crc32.h"
#ifndef __ARCHIVE_H
#include "archive.h"
#endif
#define BUFSIZE 4096
static uint32 crctab[] = {
0x0,
0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6,
0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd,
0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 0x5f15adac,
0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f,
0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a,
0x745e66cd, 0x9823b6e0, 0x9ce2ab57, 0x91a18d8e, 0x95609039,
0x8b27c03c, 0x8fe6dd8b, 0x82a5fb52, 0x8664e6e5, 0xbe2b5b58,
0xbaea46ef, 0xb7a96036, 0xb3687d81, 0xad2f2d84, 0xa9ee3033,
0xa4ad16ea, 0xa06c0b5d, 0xd4326d90, 0xd0f37027, 0xddb056fe,
0xd9714b49, 0xc7361b4c, 0xc3f706fb, 0xceb42022, 0xca753d95,
0xf23a8028, 0xf6fb9d9f, 0xfbb8bb46, 0xff79a6f1, 0xe13ef6f4,
0xe5ffeb43, 0xe8bccd9a, 0xec7dd02d, 0x34867077, 0x30476dc0,
0x3d044b19, 0x39c556ae, 0x278206ab, 0x23431b1c, 0x2e003dc5,
0x2ac12072, 0x128e9dcf, 0x164f8078, 0x1b0ca6a1, 0x1fcdbb16,
0x018aeb13, 0x054bf6a4, 0x0808d07d, 0x0cc9cdca, 0x7897ab07,
0x7c56b6b0, 0x71159069, 0x75d48dde, 0x6b93dddb, 0x6f52c06c,
0x6211e6b5, 0x66d0fb02, 0x5e9f46bf, 0x5a5e5b08, 0x571d7dd1,
0x53dc6066, 0x4d9b3063, 0x495a2dd4, 0x44190b0d, 0x40d816ba,
0xaca5c697, 0xa864db20, 0xa527fdf9, 0xa1e6e04e, 0xbfa1b04b,
0xbb60adfc, 0xb6238b25, 0xb2e29692, 0x8aad2b2f, 0x8e6c3698,
0x832f1041, 0x87ee0df6, 0x99a95df3, 0x9d684044, 0x902b669d,
0x94ea7b2a, 0xe0b41de7, 0xe4750050, 0xe9362689, 0xedf73b3e,
0xf3b06b3b, 0xf771768c, 0xfa325055, 0xfef34de2, 0xc6bcf05f,
0xc27dede8, 0xcf3ecb31, 0xcbffd686, 0xd5b88683, 0xd1799b34,
0xdc3abded, 0xd8fba05a, 0x690ce0ee, 0x6dcdfd59, 0x608edb80,
0x644fc637, 0x7a089632, 0x7ec98b85, 0x738aad5c, 0x774bb0eb,
0x4f040d56, 0x4bc510e1, 0x46863638, 0x42472b8f, 0x5c007b8a,
0x58c1663d, 0x558240e4, 0x51435d53, 0x251d3b9e, 0x21dc2629,
0x2c9f00f0, 0x285e1d47, 0x36194d42, 0x32d850f5, 0x3f9b762c,
0x3b5a6b9b, 0x0315d626, 0x07d4cb91, 0x0a97ed48, 0x0e56f0ff,
0x1011a0fa, 0x14d0bd4d, 0x19939b94, 0x1d528623, 0xf12f560e,
0xf5ee4bb9, 0xf8ad6d60, 0xfc6c70d7, 0xe22b20d2, 0xe6ea3d65,
0xeba91bbc, 0xef68060b, 0xd727bbb6, 0xd3e6a601, 0xdea580d8,
0xda649d6f, 0xc423cd6a, 0xc0e2d0dd, 0xcda1f604, 0xc960ebb3,
0xbd3e8d7e, 0xb9ff90c9, 0xb4bcb610, 0xb07daba7, 0xae3afba2,
0xaafbe615, 0xa7b8c0cc, 0xa379dd7b, 0x9b3660c6, 0x9ff77d71,
0x92b45ba8, 0x9675461f, 0x8832161a, 0x8cf30bad, 0x81b02d74,
0x857130c3, 0x5d8a9099, 0x594b8d2e, 0x5408abf7, 0x50c9b640,
0x4e8ee645, 0x4a4ffbf2, 0x470cdd2b, 0x43cdc09c, 0x7b827d21,
0x7f436096, 0x7200464f, 0x76c15bf8, 0x68860bfd, 0x6c47164a,
0x61043093, 0x65c52d24, 0x119b4be9, 0x155a565e, 0x18197087,
0x1cd86d30, 0x029f3d35, 0x065e2082, 0x0b1d065b, 0x0fdc1bec,
0x3793a651, 0x3352bbe6, 0x3e119d3f, 0x3ad08088, 0x2497d08d,
0x2056cd3a, 0x2d15ebe3, 0x29d4f654, 0xc5a92679, 0xc1683bce,
0xcc2b1d17, 0xc8ea00a0, 0xd6ad50a5, 0xd26c4d12, 0xdf2f6bcb,
0xdbee767c, 0xe3a1cbc1, 0xe760d676, 0xea23f0af, 0xeee2ed18,
0xf0a5bd1d, 0xf464a0aa, 0xf9278673, 0xfde69bc4, 0x89b8fd09,
0x8d79e0be, 0x803ac667, 0x84fbdbd0, 0x9abc8bd5, 0x9e7d9662,
0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf,
0xa2f33668, 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4
};
/*
* Compute a POSIX 1003.2 checksum. This routine has been broken out so that
* other programs can use it. It takes a file descriptor to read from and
* locations to store the crc and the number of bytes read. It returns 0 on
* success and 1 on failure. Errno is set on failure.
*/
#define COMPUTE(var, ch) (var) = ((var) << 8) ^ \
crctab[0xff & (unsigned)((var) >> 24 ^ (ch))]
void crcInit( CRC_INFO& crcInfo )
{
crcInfo.cbTotalLen = 0;
crcInfo.crc = 0;
}
void crcUpdate( CRC_INFO& crcInfo, const uint8* pbData, int cbDataLen )
{
for( int i = 0; i < cbDataLen; i++, pbData++ )
{
COMPUTE( crcInfo.crc, *pbData );
}
crcInfo.cbTotalLen += cbDataLen;
}
void crcFinit( CRC_INFO& crcInfo )
{
// include the length
//
uint32 len = crcInfo.cbTotalLen;
for(; len != 0; len >>= 8)
COMPUTE( crcInfo.crc, len & 0xff );
crcInfo.crc = ~(crcInfo.crc) & 0xFFFFFFFF;
}

54
src/core/crc32.h Normal file
View File

@ -0,0 +1,54 @@
//
// 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.
//
//crc32.h - Wimpy header file for crc32.cpp
#ifndef __CRC32_H
#define __CRC32_H
class cArchive;
typedef struct
{
uint32 crc;
uint32 cbTotalLen;
}
CRC_INFO;
// must have 8-bit bytes
void crcInit ( CRC_INFO& crcInfo );
void crcUpdate( CRC_INFO& crcInfo, const uint8* pbData, int cbDataLen );
void crcFinit ( CRC_INFO& crcInfo );
// calculates the crc for len bytes starting at pBuf
//Wrapper function for CRC32 in crc32.cpp
#endif //__CRC32_H

528
src/core/debug.cpp Normal file
View File

@ -0,0 +1,528 @@
//
// 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.
//
// debug.cpp
#include "stdcore.h"
#include "debug.h"
#include "errorutil.h"
#ifdef DEBUG
#ifndef va_start
#include <cstdarg>
#endif
#include <cwchar>
#include <fstream>
#include <cstdio>
int cDebug::mDebugLevel(10);
uint32 cDebug::mOutMask(cDebug::OUT_TRACE);
std::ofstream cDebug::logfile;
//mDebugLevel default == 10, mOutMask default == OUT_TRACE.
///////////////////////////////////////////////////////////////////////////////
// Constructors and Destructor
cDebug::cDebug(const char* label)
{
int cnt = strlen(label);
if (cnt > cDebug::MAX_LABEL)
cnt = cDebug::MAX_LABEL - 1;
memcpy(mLabel, label, cnt);
mLabel[cnt] = '\0';
}
cDebug::cDebug(const cDebug &rhs)
{
strcpy(mLabel, rhs.mLabel);
}
cDebug::~cDebug()
{
if(logfile)
logfile.close();
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Trace -- Outputs a format string only if the passed integer value is <=
// the "global debug level" (indicated by mDebugLevel).
///////////////////////////////////////////////////////////////////////////////
void cDebug::Trace(int levelNum, const char* format, ...)
{
if (levelNum > mDebugLevel)
return;
// create the output buffer
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::Trace(int levelNum, const wchar_t* format, ...)
{
if (levelNum > mDebugLevel)
return;
// create the output buffer
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
///////////////////////////////////////////////////////////////////////////////
// DoTrace()
// internal helper function -- does the actual printing to logfile,
// console, etc...
///////////////////////////////////////////////////////////////////////////////
void cDebug::DoTrace(const char *format, va_list &args)
{
size_t guard1 = 0xBABABABA;
char out[2048];
size_t guard2 = 0xBABABABA;
vsprintf(out, format, args);
ASSERT(guard1 == 0xBABABABA && guard2 == 0xBABABABA); // string was too long
ASSERT(strlen(out) < 1024);
std::ostringstream ostr;
ostr.setf(std::ios::left);
ostr.width(40);
ostr << mLabel;
ostr.width(0);
ostr << out;
if ((mOutMask & OUT_STDOUT) != 0)
{
std::cout << ostr.str().c_str();
std::cout.flush();
}
//
//make it output to log file!
//
if ((mOutMask & OUT_FILE) != 0)
{
// the logfile is narrow chars only...
logfile.setf(std::ios::left);
logfile.width(40);
logfile << mLabel;
logfile.width(0);
logfile << out;
logfile.flush();
}
}
void cDebug::DoTrace(const wchar_t *format, va_list &args)
{
#if IS_UNIX
// we don't support vswprintf on UNIX
ASSERT(false);
THROW_INTERNAL("debug.cpp");
#else
size_t guard1 = 0xBABABABA;
wchar_t out[2048];
size_t guard2 = 0xBABABABA;
vswprintf(out, format, args);
ASSERT(guard1 == 0xBABABABA && guard2 == 0xBABABABA); // string was too long
char nout[1024];
if (wcstombs(nout, out, 1024) == -1)
strcpy(nout, "XXX Unconvertable wide char detected in cDebug::DoTrace()\n");
std::ostringstream ostr;
ostr.setf(std::ios::left);
ostr.width(40);
ostr << mLabel;
ostr.width(0);
ostr << nout;
if ((mOutMask & OUT_STDOUT) != 0)
{
std::cout << ostr.str().c_str();
std::cout.flush();
}
//
//make it output to log file!
//
if ((mOutMask & OUT_FILE) != 0)
{
// the logfile is narrow chars only...
logfile.setf(std::ios::left);
logfile.width(40);
logfile << mLabel;
logfile.width(0);
logfile << out;
logfile.flush();
}
#endif // IS_UNIX
}
#ifdef DEBUG
//
// wrappers around Trace() that requires less typing
// TODO: this is quick and dirty, but lets me check in all these files right away. --ghk
//
void cDebug::TraceAlways(const char *format, ...)
{
if (D_ALWAYS > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceError(const char *format, ...)
{
if (D_ERROR > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceWarning(const char *format, ...)
{
if (D_WARNING > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceDebug(const char *format, ...)
{
if (D_DEBUG > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceDetail(const char *format, ...)
{
if (D_DETAIL > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceNever(const char *format, ...)
{
if (D_NEVER > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceAlways(const wchar_t *format, ...)
{
if (D_ALWAYS > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceError(const wchar_t *format, ...)
{
if (D_ERROR > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceWarning(const wchar_t *format, ...)
{
if (D_WARNING > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceDebug(const wchar_t *format, ...)
{
if (D_DEBUG > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceDetail(const wchar_t *format, ...)
{
if (D_DETAIL > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceNever(const wchar_t *format, ...)
{
if (D_NEVER > mDebugLevel)
return;
// fill up arglist, and pass to printing routine
va_list args;
va_start(args, format);
DoTrace(format, args);
va_end(args);
}
void cDebug::TraceVaArgs( int iDebugLevel, const char *format, va_list &args )
{
if ( iDebugLevel <= mDebugLevel )
DoTrace( format, args);
}
void cDebug::TraceVaArgs( int iDebugLevel, const wchar_t *format, va_list &args )
{
if ( iDebugLevel <= mDebugLevel )
DoTrace( format, args );
}
#endif // DEBUG
///////////////////////////////////////////////////////////////////////////////
// AddOutTarget -- Attempts to add a new target for trace/debug output.
// FAILS ONLY IF caller attempts to SET OUT_FILE via this function.
///////////////////////////////////////////////////////////////////////////////
bool cDebug::AddOutTarget(OutTarget target)
{
if (target == OUT_STDOUT)
mOutMask |= OUT_STDOUT;
if (target == OUT_TRACE)
mOutMask |= OUT_TRACE;
if (target == OUT_FILE) {
mOutMask |= OUT_FILE;
return false;
}
return true;
}
///////////////////////////////////////////////////////////////////////////////
// RemoveOutTarget -- Masks out from mOutMask the value passed.
///////////////////////////////////////////////////////////////////////////////
bool cDebug::RemoveOutTarget(OutTarget target)
{
if (!HasOutTarget(target))
return true;
if (target == OUT_STDOUT)
mOutMask ^= OUT_STDOUT;
if (target == OUT_TRACE)
mOutMask ^= OUT_TRACE;
if (target == OUT_FILE)
mOutMask ^= OUT_FILE;
return true;
}
///////////////////////////////////////////////////////////////////////////////
// HasOutTarget -- Takes target - target must represent a single flagged bit
///////////////////////////////////////////////////////////////////////////////
bool cDebug::HasOutTarget(OutTarget target)
{
if (target == OUT_STDOUT)
return ((mOutMask & OUT_STDOUT) != 0);
else if (target == OUT_TRACE)
return ((mOutMask & OUT_TRACE) != 0);
else if (target == OUT_FILE)
return ((mOutMask & OUT_FILE) != 0);
else //ambiguous input, or too many bits set in target
return false;
}
///////////////////////////////////////////////////////////////////////////////
// SetOutputFile -- Attempts to set the output file for Logfile member to
// the string passed in.
///////////////////////////////////////////////////////////////////////////////
bool cDebug::SetOutputFile(const char* filename)
{
// TODO -- make sure this does the right thing if a log file is
// already open!
// TODO -- make this work with wide chars
if (!logfile)
logfile.open(filename, std::ios_base::out | std::ios_base::ate | std::ios_base::app);
else
logfile.setf(std::ios_base::hex, std::ios_base::basefield);
//make sure info. will not be clobbered.
//Should be open now- if not, abort.
if (!logfile) {
mOutMask ^= OUT_FILE;
return false;
} else
mOutMask |= OUT_FILE;
return true;
}
//////////////////////////////////////////////////////////////////////////////
// DebugOut -- Works just like TRACE. note: there is an internal buffer size
// of 1024; traces larger than that will have unpredictable results.
//////////////////////////////////////////////////////////////////////////////
void cDebug::DebugOut( const char* lpOutputString, ... )
{
char buf[2048];
// create the output buffer
va_list args;
va_start(args, lpOutputString);
vsprintf(buf, lpOutputString, args);
va_end(args);
#ifdef _UNICODE
wchar_t wbuf[2048];
if (mbstowcs(wbuf, buf, strlen(buf)+1) == -1)
wcscpy(wbuf, _T("XXX Unconvertable mb character detected in cDebug::DebugOut()\n") );
#if !USE_OUTPUT_DEBUG_STRING
#ifdef _DEBUG
TCERR << wbuf;
#endif //_DEBUG
#else // USE_OUTPUT_DEBUG_STRING
::OutputDebugString(wbuf);
#endif // USE_OUTPUT_DEBUG_STRING
#else // _UNICODE
#if !USE_OUTPUT_DEBUG_STRING
#ifdef _DEBUG
TCERR << buf;
#endif //_DEBUG
#else // USE_OUTPUT_DEBUG_STRING
::OutputDebugString(buf);
#endif // USE_OUTPUT_DEBUG_STRING
#endif // _UNICODE
TCOUT.flush();
}
void cDebug::DebugOut( const wchar_t* lpOutputString, ... )
{
va_list args;
va_start(args, lpOutputString);
#if IS_UNIX
char mbformatbuf[1024];
char buf[1024];
// if (wcstombs(mbformatbuf, lpOutputString, wcslen(lpOutputString)) == -1)
// strcpy(mbformatbuf, "XXX Unconvertable wide char detected in cDebug::DebugOut()\n");
vsprintf(buf, mbformatbuf, args);
#else
wchar_t buf[1024];
vswprintf(buf, lpOutputString, args);
#endif
va_end(args);
#ifdef _UNICODE
#if !USE_OUTPUT_DEBUG_STRING
#ifdef _DEBUG
TCERR << buf;
#endif //_DEBUG
#else // USE_OUTPUT_DEBUG_STRING
::OutputDebugString(buf);
#endif // USE_OUTPUT_DEBUG_STRING
#else
char nbuf[1024];
#if IS_UNIX
strcpy(nbuf, buf);
#else
if (wcstombs(nbuf, buf, wcslen(buf)+1) == -1)
strcpy(nbuf, "XXX Unconvertable wide char detected in cDebug::DebugOut()\n");
#endif
#if !USE_OUTPUT_DEBUG_STRING
#ifdef _DEBUG
TCERR << nbuf;
#endif //_DEBUG
#else // USE_OUTPUT_DEBUG_STRING
::OutputDebugString(nbuf);
#endif // USE_OUTPUT_DEBUG_STRING
#endif
TCOUT.flush();
}
#endif // DEBUG
//////////////////////////////////////////////////////////////////////////////////
// ASSERT macro support function
//////////////////////////////////////////////////////////////////////////////////

253
src/core/debug.h Normal file
View File

@ -0,0 +1,253 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// debug.h
//
// definitions of debug macros that will vary across platforms
#ifndef __DEBUG_H
#define __DEBUG_H
#include <assert.h>
#include <iostream>
/* Do it in this order, because autoconf checks for <stdarg.h>
* first i.e. if HAVE_VARARGS_H is defined, it is only because
* <stdarg.h> couldn't be found.
*/
#ifdef HAVE_VARARGS_H
# include <varargs.h>
#else
# ifdef HAVE_STDARG_H
# include <stdarg.h>
# endif
#endif
#include "types.h"
//
// NOTE:
// When compiling with MFC, these are already defined and we get error msgs
// every time this file is included. Since these behave the same as the MFC
// version, it is OK to always undef them here....
// -- 20 Aug 99 mdb
//
#undef ASSERT
#undef TRACE
//
// IMPORTANT:
//
// strings outputted as trace statements are printed as narrow characters.
// passing trace messages with wide characters will have odd results, since
// they will be used as arugments to sprintf(), etc...
//
// debug utility class
class cDebug
{
public:
enum OutTarget
{
OUT_STDOUT = 1,
OUT_TRACE = 2,
OUT_FILE = 4
};
enum DebugLevel
{
D_ALWAYS = 0,
D_ERROR = 1,
D_WARNING = 4,
D_DEBUG = 8,
D_DETAIL = 16,
D_NEVER = 1000
};
cDebug(const char* pLabel);
~cDebug();
cDebug(const cDebug& rhs);
// These are the preferred tracing interfaces, because you don't need to know
// the DebugLevel enums.
// Wide/Narrow Chars Issues: If you include a %s in your format string and you
// wish to print out a TCHAR (which might be a natural thing to do) you should
// encompas the format string with a _T("") macro, i.e. make it a TSTRING.
// The wide character overloads of these functions will expect wide strings
// for %s options.
//
void TraceAlways (const char *format, ...);
void TraceError (const char *format, ...);
void TraceWarning (const char *format, ...);
void TraceDebug (const char *format, ...);
void TraceDetail (const char *format, ...);
void TraceNever (const char *format, ...);
void TraceAlways (const wchar_t *format, ...);
void TraceError (const wchar_t *format, ...);
void TraceWarning (const wchar_t *format, ...);
void TraceDebug (const wchar_t *format, ...);
void TraceDetail (const wchar_t *format, ...);
void TraceNever (const wchar_t *format, ...);
// these are of use if you are inside a function with a "..." as an argument
// and you want to trace those args
void TraceVaArgs (int iDebugLevel, const char *format, va_list &args);
void TraceVaArgs (int iDebugLevel, const wchar_t *format, va_list &args);
// ...but you can still choose to use this interface...
void Trace(int levelNum, const char* format, ...);
void Trace(int levelNum, const wchar_t* format, ...);
// Outputs based on levelnum. If levelnum <= global debug, print.
public:
static bool AddOutTarget (OutTarget target);
static bool RemoveOutTarget (OutTarget target);
// used to specify the out target....
static bool HasOutTarget (OutTarget target);
static bool SetOutputFile (const char* filename);
// specifies the output file name used when OUT_FILE is set
static void SetDebugLevel (int level);
static int GetDebugLevel (void);
// gets and sets the global debug level. Trace output at or below this
// level will be output.
static void DebugOut ( const char* lpOutputString, ... );
static void DebugOut ( const wchar_t* lpOutputString, ... );
// Works just like TRACE
// note: there is an internal buffer size of 1024; traces larger
// than that will have unpredictable and probably bad results
private:
#ifdef DEBUG
enum { MAX_LABEL = 128 };
static int mDebugLevel;
static uint32 mOutMask;
static std::ofstream logfile;
char mLabel[MAX_LABEL];
// helper functions
void DoTrace(const char *format, va_list &args);
void DoTrace(const wchar_t *format, va_list &args);
#endif
};
#ifdef _DEBUG
#define TRACE cDebug::DebugOut
#else
#define TRACE 1 ? (void)0 : cDebug::DebugOut
#endif // _DEBUG
//////////////////////////////////////////////////////////////////////////////////
// inline implementation
//////////////////////////////////////////////////////////////////////////////////
// Hopefully this class should do nothing in release mode
#ifdef DEBUG
inline void cDebug::SetDebugLevel(int level)
{
mDebugLevel = level;
}
inline int cDebug::GetDebugLevel()
{
return mDebugLevel;
}
#else // DEBUG
inline cDebug::cDebug (const char *pLabel) {}
inline cDebug::~cDebug () {}
inline cDebug::cDebug (const cDebug& rhs) {}
inline void cDebug::TraceAlways (const char *format, ...) {}
inline void cDebug::TraceError (const char *format, ...) {}
inline void cDebug::TraceWarning (const char *format, ...) {}
inline void cDebug::TraceDebug (const char *format, ...) {}
inline void cDebug::TraceDetail (const char *format, ...) {}
inline void cDebug::TraceNever (const char *format, ...) {}
inline void cDebug::TraceAlways (const wchar_t *format, ...) {}
inline void cDebug::TraceError (const wchar_t *format, ...) {}
inline void cDebug::TraceWarning (const wchar_t *format, ...) {}
inline void cDebug::TraceDebug (const wchar_t *format, ...) {}
inline void cDebug::TraceDetail (const wchar_t *format, ...) {}
inline void cDebug::TraceNever (const wchar_t *format, ...) {}
inline void cDebug::TraceVaArgs (int iDebugLevel, const char *format, va_list &args) {}
inline void cDebug::TraceVaArgs (int iDebugLevel, const wchar_t *format, va_list &args) {}
inline void cDebug::Trace (int levelNum, const char* format, ...) {}
inline void cDebug::Trace (int levelNum, const wchar_t* format, ...) {}
inline bool cDebug::AddOutTarget (OutTarget target) { return false; }
inline bool cDebug::RemoveOutTarget (OutTarget target) { return false; }
inline bool cDebug::HasOutTarget (OutTarget target) { return false; }
inline bool cDebug::SetOutputFile (const char* filename) { return false; }
inline void cDebug::SetDebugLevel (int level) {}
inline int cDebug::GetDebugLevel (void) { return 0; }
inline void cDebug::DebugOut ( const char* lpOutputString, ... ) {}
inline void cDebug::DebugOut ( const wchar_t* lpOutputString, ... ) {}
#endif // DEBUG
//////////////////////////////////////////////////////////////////////////////////
// ASSERT macro
//////////////////////////////////////////////////////////////////////////////////
#if IS_UNIX
#define ASSERTMSG( exp, s ) assert( (exp) != 0 )
#define ASSERT( exp ) assert( (exp) != 0 )
// if we are not windows we will just use the standard assert()
#define TSS_DebugBreak() ASSERT( false );
#endif// IS_UNIX
#ifndef ASSERT
#error ASSERT did not get defined!!!
#endif
#ifndef ASSERTMSG
#error ASSERTMSG did not get defined!!!
#endif
#ifndef TSS_DebugBreak
#error TSS_DebugBreak did not get defined!!!
#endif
#endif //__DEBUG_H

90
src/core/debug_t.cpp Normal file
View File

@ -0,0 +1,90 @@
//
// 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.
//
// debug_t -- debug component test driver
#include "stdcore.h"
#include "debug.h"
#include "test/test.h"
void TestDebug()
{
// it is amusing that we use cDebug to output the results of testing cDebug
// "Are you insane?" ... "No, I am not."
cDebug d("TestDebug()");
d.TraceDebug("Entering...");
// save the current debug level, since we will be altering it.
int oldDebugLevel = cDebug::GetDebugLevel();
// test debug level variation...
d.TraceDebug("Setting debug level to Debug(%d)\n", cDebug::D_DEBUG);
cDebug::SetDebugLevel(cDebug::D_DEBUG);
d.TraceDebug ("You should see this, as well as line 2 below, but not line 3.\n");
d.TraceWarning ("Line 2: Warning(%d)\n", cDebug::D_WARNING);
d.TraceDetail ("Line 3: Detail(%d)\n", cDebug::D_DETAIL);
d.TraceDebug ("Restoring the debug level to %d\n", oldDebugLevel);
cDebug::SetDebugLevel(oldDebugLevel);
// testing the output source
int oldOutTarget = 0;
if(cDebug::HasOutTarget(cDebug::OUT_STDOUT)) oldOutTarget |= cDebug::OUT_STDOUT;
if(cDebug::HasOutTarget(cDebug::OUT_TRACE)) oldOutTarget |= cDebug::OUT_TRACE;
if(cDebug::HasOutTarget(cDebug::OUT_FILE)) oldOutTarget |= cDebug::OUT_FILE;
cDebug::RemoveOutTarget(cDebug::OUT_STDOUT);
cDebug::RemoveOutTarget(cDebug::OUT_TRACE);
cDebug::RemoveOutTarget(cDebug::OUT_FILE);
d.TraceDebug("You should not see this (All out targets removed)\n");
cDebug::AddOutTarget(cDebug::OUT_STDOUT);
d.TraceDebug("You should see this in stdout only.\n");
cDebug::AddOutTarget(cDebug::OUT_TRACE);
d.TraceDebug("You should see this in stdout and trace.\n");
cDebug::RemoveOutTarget(cDebug::OUT_STDOUT);
d.TraceDebug("You should see this in trace only.\n");
// set up an output file...use the temp file in test.h
std::string str = TEMP_DIR_N;
str += "/debug.out";
bool bResult = false;
bResult = cDebug::SetOutputFile(str.c_str());
TEST(bResult);
d.TraceDebug("This should be in trace and the file %s.\n", str.c_str());
// restore the out source...
// TODO -- note that the original output file cannot be restored; this sucks!
if(oldOutTarget & cDebug::OUT_STDOUT) cDebug::AddOutTarget(cDebug::OUT_STDOUT); else cDebug::RemoveOutTarget(cDebug::OUT_STDOUT);
if(oldOutTarget & cDebug::OUT_TRACE) cDebug::AddOutTarget(cDebug::OUT_TRACE); else cDebug::RemoveOutTarget(cDebug::OUT_TRACE);
if(oldOutTarget & cDebug::OUT_FILE) cDebug::AddOutTarget(cDebug::OUT_FILE); else cDebug::RemoveOutTarget(cDebug::OUT_FILE);
d.TraceDebug("Exiting...\n");
}

916
src/core/displayencoder.cpp Normal file
View File

@ -0,0 +1,916 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// displayencoder.cpp
//
//=========================================================================
// INCLUDES
//=========================================================================
#include "stdcore.h"
#include "displayencoder.h"
#include "charutil.h"
#include "debug.h"
#include "twlocale.h"
#include "stringutil.h"
#include "errorutil.h"
#include "ntmbs.h"
#include "codeconvert.h"
//=========================================================================
// STANDARD LIBRARY INCLUDES
//=========================================================================
#include <iomanip>
#include <iterator>
//=========================================================================
// DEFINES AND MACROS
//=========================================================================
// uncomment this to test schema
// #define TSS_DO_SCHEMA_VALIDATION
//////////////////////////////////////////////////////////////////////////////
// ENCODER UTILITIES
//////////////////////////////////////////////////////////////////////////////
inline bool IsSingleTCHAR( TSTRING::const_iterator first,
TSTRING::const_iterator last )
{
return( first + 1 == last );
}
//////////////////////////////////////////////////////////////////////////////
// CHAR ENCODER INTERFACE
//////////////////////////////////////////////////////////////////////////////
// all derived classes should encode a char to "EscapeChar() + Identifier() + Encode( char ) [ + Identifier() ]"
class iCharEncoder
{
public:
virtual bool NeedsEncoding( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const = 0;
// Determines if character identified by [first,last) needs encoding.
// Returns true if it does.
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
TSTRING::const_iterator last ) const = 0;
// Encodes character identified by [first,last) in such a way that it
// can be decoded by Decode(). Returns encoded character sequence.
virtual TSTRING EncodePretty( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const = 0;
// Encodes character identified by [first,last) in a manner that is not roundtrip,
// but looks good. Returns encoded character sequence.
virtual TSTRING Decode( TSTRING::const_iterator* pcur,
const TSTRING::const_iterator end ) const = 0;
// Decodes character sequence beginning with '*pcur' and ending before 'end'.
// Returns decoded character or sequence of characters. Advances *pcur beyond
// the last character decoded.
virtual TCHAR Identifier() const = 0;
static TCHAR EscapeChar() { return char_escape; }
protected:
static TCHAR char_escape;
};
class cNonNarrowableCharEncoder : public iCharEncoder
{
public:
virtual bool NeedsEncoding( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING EncodePretty( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING Decode( TSTRING::const_iterator* cur,
const TSTRING::const_iterator end ) const;
virtual TCHAR Identifier() const;
private:
static TCHAR char_identifier;
static TCHAR char_replace;
};
class cNonPrintableCharEncoder : public iCharEncoder
{
public:
cNonPrintableCharEncoder( bool f_allowWS )
: m_allowWS( f_allowWS ) {};
virtual bool NeedsEncoding( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING EncodePretty( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING Decode( TSTRING::const_iterator* cur,
const TSTRING::const_iterator end ) const;
virtual TCHAR Identifier() const;
private:
static TCHAR char_identifier;
static TCHAR char_replace;
bool m_allowWS;
};
class cQuoteCharEncoder : public iCharEncoder
{
public:
virtual bool NeedsEncoding( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING EncodePretty( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING Decode( TSTRING::const_iterator* cur,
const TSTRING::const_iterator end ) const;
virtual TCHAR Identifier() const;
private:
static TCHAR char_test;
static TCHAR char_identifier;
static TCHAR char_replace;
};
class cBackslashCharEncoder : public iCharEncoder
{
public:
virtual bool NeedsEncoding( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING EncodeRoundtrip(TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING EncodePretty( TSTRING::const_iterator first,
TSTRING::const_iterator last ) const;
virtual TSTRING Decode( TSTRING::const_iterator* cur,
const TSTRING::const_iterator end ) const;
virtual TCHAR Identifier() const;
private:
static TCHAR char_test;
static TCHAR char_identifier;
static TCHAR char_replace;
};
//////////////////////////////////////////////////////////////////////////////
// CHARACTER SPECIALIZATIONS
//////////////////////////////////////////////////////////////////////////////
TCHAR iCharEncoder::char_escape = _T('\\');
TCHAR cNonNarrowableCharEncoder::char_identifier = _T('x');
TCHAR cNonPrintableCharEncoder::char_identifier = _T('x');
TCHAR cQuoteCharEncoder::char_identifier = _T('\"');
TCHAR cBackslashCharEncoder::char_identifier = _T('\\');
TCHAR cBackslashCharEncoder::char_test = cBackslashCharEncoder::char_identifier;
TCHAR cQuoteCharEncoder::char_test = cQuoteCharEncoder::char_identifier;
TCHAR cBackslashCharEncoder::char_replace = cBackslashCharEncoder::char_identifier;
TCHAR cQuoteCharEncoder::char_replace = cQuoteCharEncoder::char_identifier;
TCHAR cNonNarrowableCharEncoder::char_replace = _T('?');
TCHAR cNonPrintableCharEncoder::char_replace = _T('?');
//////////////////////////////////////////////////////////////////////////////
// TESTS
//////////////////////////////////////////////////////////////////////////////
bool cNonNarrowableCharEncoder::NeedsEncoding(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
#ifdef _UNICODE
ASSERT( IsSingleTCHAR( first, last ) );
char amb[ MB_LEN_MAX ];
TCHAR awch[] = { *first, 0 };
// TODO:BAM -- this is not really correct! Convert will not honor nSource!!
// it looks for the first null char!
try
{
int ret = iCodeConverter::GetInstance()->Convert( amb, sizeof( amb ), awch, 1 );
return( -1 == ret );
}
catch( eError& )
{
return true;
}
#else
return false; // all chars are narrow
#endif
}
bool cNonPrintableCharEncoder::NeedsEncoding(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
// TODO:BAM -- handle this with mb chars
// std::isprint<wchar_t> does a wctob() on the wchar!!?!?!
// what's up with that? Maybe ignore this all together and
// just do a isprint like KAI does?
// HYPOTHESIS: all mb characters are printable. only sb ASCII
// chars that would have C isprint() return false actually aren't printable
// So escape chars, and tabs and such are only in sb chars that C isprint() would check.
// HMMMM: true in all locales, though? (LC_CTYPE is checked for C isprint(), though...)
// Sooooo... it should be something like
//
// #ifdef _UNICODE
// char nch = wctob( ch );
// return( nch != EOF && ! isprint( nch ) );
// #else
// return( ! isprint( ch ) );
// #endif
//
// assuming all unprintable chars are one TCHAR long
if( ! IsSingleTCHAR( first, last ) )
return false;
if( m_allowWS && cCharEncoderUtil::IsWhiteSpace( *first ) )
return false;
return cCharEncoderUtil::IsPrintable( *first );
}
bool cQuoteCharEncoder::NeedsEncoding(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
return(
IsSingleTCHAR( first, last )
&&
( *first == char_test )
);
}
bool cBackslashCharEncoder::NeedsEncoding(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
return(
IsSingleTCHAR( first, last )
&&
( *first == char_test )
);
}
//////////////////////////////////////////////////////////////////////////////
// ROUNDTRIP ENCODINGS
//////////////////////////////////////////////////////////////////////////////
TSTRING cNonNarrowableCharEncoder::EncodeRoundtrip(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
TSTRING str;
str += char_escape;
str += char_identifier;
str += cCharEncoderUtil::CharStringToHexValue( TSTRING( first, last ) );
return str;
}
TSTRING cNonPrintableCharEncoder::EncodeRoundtrip(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
ASSERT( IsSingleTCHAR( first, last ) ); // non-prints are single char (see NOTE above)
TSTRING str;
str += char_escape;
str += char_identifier;
str += cCharEncoderUtil::CharStringToHexValue( TSTRING( first, last ) );
return str;
}
TSTRING cQuoteCharEncoder::EncodeRoundtrip(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
// should just be a quote
ASSERT( IsSingleTCHAR( first, last ) );
ASSERT( *first == char_test );
TSTRING str;
str += char_escape;
str += char_identifier;
return str;
}
TSTRING cBackslashCharEncoder::EncodeRoundtrip(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
// should just be a backslash
ASSERT( IsSingleTCHAR( first, last ) );
ASSERT( *first == char_test );
TSTRING str;
str += char_escape;
str += char_identifier;
return str;
}
//////////////////////////////////////////////////////////////////////////////
// NON-ROUNDTRIP ENCODINGS
//////////////////////////////////////////////////////////////////////////////
TSTRING cNonNarrowableCharEncoder::EncodePretty(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
return EncodeRoundtrip( first, last );
}
TSTRING cNonPrintableCharEncoder::EncodePretty(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
return EncodeRoundtrip( first, last );
}
TSTRING cQuoteCharEncoder::EncodePretty(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
// should just be a quote
ASSERT( IsSingleTCHAR( first, last ) );
ASSERT( *first == char_test );
return TSTRING( 1, char_replace );
}
TSTRING cBackslashCharEncoder::EncodePretty(
TSTRING::const_iterator first,
TSTRING::const_iterator last ) const
{
// should just be a backslash
ASSERT( IsSingleTCHAR( first, last ) );
ASSERT( *first == char_test );
return TSTRING( 1, char_replace );
}
//////////////////////////////////////////////////////////////////////////////
// DECODINGS
//////////////////////////////////////////////////////////////////////////////
TSTRING cNonNarrowableCharEncoder::Decode( TSTRING::const_iterator* pcur,
const TSTRING::const_iterator end ) const
{
// check preconditions
if( (*pcur) >= end || *(*pcur) != Identifier() )
ThrowAndAssert( eBadDecoderInput() );
return( cCharEncoderUtil::DecodeHexToChar( pcur, end ) );
}
TSTRING cNonPrintableCharEncoder::Decode( TSTRING::const_iterator* pcur,
const TSTRING::const_iterator end ) const
{
// check preconditions
if( (*pcur) >= end || *(*pcur) != Identifier() )
ThrowAndAssert( eBadDecoderInput() );
return( cCharEncoderUtil::DecodeHexToChar( pcur, end ) );
}
TSTRING cQuoteCharEncoder::Decode( TSTRING::const_iterator* pcur,
const TSTRING::const_iterator end ) const
{
if( (*pcur) >= end || *(*pcur) != Identifier() )
ThrowAndAssert( eBadDecoderInput() );
(*pcur)++; // advance past part decoded
return TSTRING( 1, Identifier() );
}
TSTRING cBackslashCharEncoder::Decode( TSTRING::const_iterator* pcur,
const TSTRING::const_iterator end ) const
{
if( (*pcur) >= end || *(*pcur) != Identifier() )
ThrowAndAssert( eBadDecoderInput() );
(*pcur)++; // advance past part decoded
return TSTRING( 1, Identifier() );
}
//////////////////////////////////////////////////////////////////////////////
// IDENTIFIERS
//////////////////////////////////////////////////////////////////////////////
TCHAR cNonNarrowableCharEncoder::Identifier() const
{
return char_identifier;
}
TCHAR cNonPrintableCharEncoder::Identifier() const
{
return char_identifier;
}
TCHAR cQuoteCharEncoder::Identifier() const
{
return char_identifier;
}
TCHAR cBackslashCharEncoder::Identifier() const
{
return char_identifier;
}
//////////////////////////////////////////////////////////////////////////////
// UTILITIES
//////////////////////////////////////////////////////////////////////////////
bool cCharEncoderUtil::IsWhiteSpace( TCHAR ch )
{
return ( ch == '\r' ||
ch == '\n' ||
ch == '\t' ||
ch == '\v' ||
ch == ' ' );
}
bool cCharEncoderUtil::IsPrintable( TCHAR ch )
{
#if USE_CLIB_LOCALE && !defined(__APPLE__)
return( ! isprint( ch ) ); // kludge for KAI
#else // USE_CLIB_LOCALE
#if IS_UNIX
return( ! std::isprint<TCHAR>( ch, std::locale() ) );
#endif
#endif // USE_CLIB_LOCALE
}
TSTRING cCharEncoderUtil::CharStringToHexValue( const TSTRING& str )
{
TSTRING strOut;
TSTRING::const_iterator at;
for( at = str.begin(); at < str.end(); at++ )
{
strOut += char_to_hex( *at );
}
return strOut;
}
TSTRING cCharEncoderUtil::HexValueToCharString( const TSTRING& str )
{
TSTRING strOut;
TSTRING::const_iterator at;
for( at = str.begin(); at < str.end(); at += TCHAR_AS_HEX__IN_TCHARS )
{
strOut += hex_to_char( at, at + TCHAR_AS_HEX__IN_TCHARS );
}
return strOut;
}
TCHAR cCharEncoderUtil::hex_to_char( TSTRING::const_iterator first,
TSTRING::const_iterator last )
{
static const TCHAR max_char = std::numeric_limits<TCHAR>::max();
static const TCHAR min_char = std::numeric_limits<TCHAR>::min();
if( first + TCHAR_AS_HEX__IN_TCHARS != last )
ThrowAndAssert( eBadHexConversion() );
TISTRINGSTREAM ss( TSTRING( first, last ) );
ss.imbue( std::locale::classic() );
ss.fill ( _T('0') );
ss.setf( std::ios_base::hex, std::ios_base::basefield );
unsigned long ch;
ss >> ch;
if( ss.bad() || ss.fail() )
ThrowAndAssert( eBadHexConversion( TSTRING( first, last ) ) );
if( (TCHAR)ch > max_char || (TCHAR)ch < min_char )
ThrowAndAssert( eBadHexConversion( TSTRING( first, last ) ) );
return (TCHAR)ch;
}
TSTRING cCharEncoderUtil::char_to_hex( TCHAR ch )
{
TOSTRINGSTREAM ss;
ss.imbue( std::locale::classic() );
ss.fill ( _T('0') );
ss.width( TCHAR_AS_HEX__IN_TCHARS );
ss.setf( std::ios_base::hex, std::ios_base::basefield );
ss << tss::util::char_to_size( ch );
if( ss.bad() || ss.fail() ||
ss.str().length() != TCHAR_AS_HEX__IN_TCHARS )
ThrowAndAssert( eBadHexConversion( TSTRING( 1, ch ) ) );
return ss.str();
}
TSTRING cCharEncoderUtil::DecodeHexToChar( TSTRING::const_iterator* pcur,
const TSTRING::const_iterator end )
{
// get hex numbers -- 2 chars
TSTRING str;
size_t n = 0;
for( (*pcur)++;
n < TCHAR_AS_HEX__IN_TCHARS &&
(*pcur) != end;
n++, (*pcur)++ )
{
str += *(*pcur);
}
if( n != TCHAR_AS_HEX__IN_TCHARS )
ThrowAndAssert( eBadDecoderInput() );
// convert hex numbers
return HexValueToCharString( str );
}
//////////////////////////////////////////////////////////////////////////////
// ENCODER MEMBERS
//////////////////////////////////////////////////////////////////////////////
cEncoder::cEncoder( int e, int f )
: m_fFlags( f )
{
// add encodings
if( e & NON_NARROWABLE )
m_encodings.push_back( new cNonNarrowableCharEncoder );
if( e & NON_PRINTABLE )
m_encodings.push_back( new cNonPrintableCharEncoder( AllowWhiteSpace() ) );
if( e & BACKSLASH )
m_encodings.push_back( new cBackslashCharEncoder );
if( e & DBL_QUOTE )
m_encodings.push_back( new cQuoteCharEncoder );
// assert that we weren't passed anything freaky
ASSERT( 0 == ( e & ~( NON_NARROWABLE |
NON_PRINTABLE |
BACKSLASH |
DBL_QUOTE ) ) );
// add flags
ASSERT( ! ( ( m_fFlags & ROUNDTRIP ) &&
( m_fFlags & NON_ROUNDTRIP ) ) );
#ifdef TSS_DO_SCHEMA_VALIDATION
// check assumptions about encodings
ValidateSchema();
#endif
}
cEncoder::~cEncoder()
{
}
bool cEncoder::RoundTrip() const
{
return( 0 != ( m_fFlags & ROUNDTRIP ) );
}
bool cEncoder::AllowWhiteSpace() const
{
return( 0 != ( m_fFlags & ALLOW_WHITESPACE ) );
}
//////////////////////////////////////////////////////////////////////////////
// ENCODER BASIC FUNCTIONALITY
//////////////////////////////////////////////////////////////////////////////
void cEncoder::Encode( TSTRING& strIn ) const
{
// TODO:BAM -- reserve space for strOut as an optimization?
TSTRING strOut; // encoded string we will build up
TSTRING::const_iterator cur = strIn.begin(); // pointer to working position in strIn
const TSTRING::const_iterator end = strIn.end(); // end of strIn
TSTRING::const_iterator first = end; // identifies beginning of current character
TSTRING::const_iterator last = end; // identifies end of current character
// while get next char (updates cur)
while( cCharUtil::PopNextChar( cur, end, first, last ) )
{
bool fCharEncoded = false; // answers: did char need encoding?
sack_type::const_iterator atE;
// for all encoders
for( atE = m_encodings.begin();
atE != m_encodings.end();
atE++ )
{
// does char need encoding?
if( (*atE)->NeedsEncoding( first, last ) )
{
strOut += Encode( first, last, atE );
fCharEncoded = true;
break; // each char should only fail at most one
// encoding test, so it should be cool to quit
}
}
if( ! fCharEncoded )
{
strOut.append( first, last ); // simply add current char to output since it needed no encoding
}
}
// pass back encoded string
strIn = strOut;
}
TSTRING cEncoder::Encode( TSTRING::const_iterator first,
TSTRING::const_iterator last,
sack_type::const_iterator encoding ) const
{
// encode it
if( RoundTrip() )
return (*encoding)->EncodeRoundtrip( first, last );
else
return (*encoding)->EncodePretty( first, last );
}
void cEncoder::Decode( TSTRING& strIn ) const
{
// TODO:BAM -- reserve space for strOut as an optimization?
TSTRING strOut; // decoded string we will build up
TSTRING::const_iterator cur = strIn.begin(); // pointer to working position in strIn
const TSTRING::const_iterator end = strIn.end(); // end of strIn
TSTRING::const_iterator first = end; // identifies beginning of current character
TSTRING::const_iterator last = end; // identifies end of current character
// while get next char (updates cur)
while( cCharUtil::PopNextChar( cur, end, first, last ) )
{
// is this char the escape character?
if( IsSingleTCHAR( first, last ) &&
*first == iCharEncoder::EscapeChar() )
{
// get to identifier
if( ! cCharUtil::PopNextChar( cur, end, first, last ) )
ThrowAndAssert( eBadDecoderInput() );
// this algorithm assumes that all identifiers are single char
// so anything following the escape char should be a
// single-char identifier
if( ! IsSingleTCHAR( first, last ) )
THROW_INTERNAL( "displayencoder.cpp" );
// determine to which encoding the identifier belongs
bool fFoundEncoding = false;
sack_type::const_iterator atE;
for( atE = m_encodings.begin();
atE != m_encodings.end();
atE++ )
{
// is this the right encoding?
if( *first == (*atE)->Identifier() )
{
// this is the correct encoding....
fFoundEncoding = true;
// ...so decode char
strOut += (*atE)->Decode( &first, end ); // should modify cur
cur = first; // advance current char pointer
break; // no need to run other tests after
// this because all identifiers should be unique
}
}
if( ! fFoundEncoding )
ThrowAndAssert( eUnknownEscapeEncoding( TSTRING( 1, *first ) ) );
}
else
{
strOut.append( first, last );
}
}
strIn = strOut;
}
//////////////////////////////////////////////////////////////////////////////
// ENCODER SCHEMA VALIDATION
//////////////////////////////////////////////////////////////////////////////
void cEncoder::ValidateSchema() const
{
ASSERT( OnlyOneCatagoryPerChar() );
ASSERT( AllIdentifiersUnique() );
}
// only tests single TCHAR characters (but of those, tests all of them)
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();
if( ch != std::numeric_limits<TCHAR>::max() )
{
do
{
bool fFailedATest = false;
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( fFailedATest )
return false; // each char can only fail one test
else
fFailedATest = true;
}
}
ch++;
}
while( ch != std::numeric_limits<TCHAR>::max() );
}
return true;
}
bool cEncoder::AllIdentifiersUnique() const
{
TSTRING chars;
for( sack_type::const_iterator atE = m_encodings.begin(); atE != m_encodings.end(); atE++ )
{
TCHAR chID = (*atE)->Identifier();
if( chars.find( chID ) == TSTRING::npos )
chars += chID;
else
return false;
}
return true;
}
bool cEncoder::AllTestsRunOnEncodedString( const TSTRING& s ) const
{
TSTRING::const_iterator cur = s.begin(); // pointer to working position in s
const TSTRING::const_iterator end = s.end(); // end of s
TSTRING::const_iterator first = end; // identifies beginning of current character
TSTRING::const_iterator last = end; // identifies end of current character
// while get next char (updates cur)
while( cCharUtil::PopNextChar( cur, end, first, last ) )
{
sack_type::const_iterator atE;
for( atE = m_encodings.begin();
atE != m_encodings.end();
atE++ )
{
if( (*atE)->NeedsEncoding( first, last ) )
{
return false;
}
}
}
return true;
}
//////////////////////////////////////////////////////////////////////////////
// cDisplayEncoder MEMBERS
//////////////////////////////////////////////////////////////////////////////
cDisplayEncoder::cDisplayEncoder( Flags f )
: cEncoder(
NON_NARROWABLE |
NON_PRINTABLE |
BACKSLASH |
DBL_QUOTE,
f
)
{
}
void cDisplayEncoder::Encode( TSTRING& str ) const
{
cEncoder::Encode( str );
}
bool cDisplayEncoder::Decode( TSTRING& str ) const
{
cEncoder::Decode( str );
return true; // TODO:BAM -- throw error!
}

244
src/core/displayencoder.h Normal file
View File

@ -0,0 +1,244 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// displayencoder.h
//
#ifndef __DISPLAYENCODER_H
#define __DISPLAYENCODER_H
//=========================================================================
// EXCEPTION DECLARATION
//=========================================================================
TSS_EXCEPTION( eEncoder, eError );
TSS_EXCEPTION( eBadDecoderInput, eEncoder );
TSS_EXCEPTION( eBadHexConversion, eEncoder );
TSS_EXCEPTION( eUnknownEscapeEncoding, eEncoder );
//=========================================================================
// DECLARATION OF CLASSES
//=========================================================================
///////////////////////////////////////////////
// cDisplayEncoder
///////////////////////////////////////////////
class iCharEncoder;
// TODO:BAM -- i don't think that the order of encodings is important
// as long as AllIdentifiersUnique and OnlyOneCatagoryPerChar are true
class cEncoder
{
public:
enum Encodings
{
NON_NARROWABLE = 0x01, // WC -> MB, MB alway narrowable:
NON_PRINTABLE = 0x02,
BACKSLASH = 0x04,
DBL_QUOTE = 0x08
};
enum Flags
{
ROUNDTRIP = 0x01,
NON_ROUNDTRIP = 0x02,
ALLOW_WHITESPACE = 0x04
};
cEncoder( int e, int f ); // mask of Encodings
virtual ~cEncoder();
void Encode( TSTRING& str ) const;
void Decode( TSTRING& str ) const; // TODO:BAM -- throw error!
void ValidateSchema() const;
bool OnlyOneCatagoryPerChar() const;
bool AllIdentifiersUnique() const;
bool AllTestsRunOnEncodedString( const TSTRING& str ) const;
private:
typedef std::vector< iCharEncoder* > sack_type;
TSTRING Encode( TSTRING::const_iterator first,
TSTRING::const_iterator last,
sack_type::const_iterator encoding ) const;
bool RoundTrip() const;
bool AllowWhiteSpace() const;
sack_type m_encodings;
int m_fFlags;
};
// encodes ( BACKSLASH | DBL_QUOTE | NON_NARROWABLE | NON_PRINTABLE )
class cDisplayEncoder : public cEncoder
{
public:
cDisplayEncoder( Flags f = NON_ROUNDTRIP );
void Encode( TSTRING& str ) const;
bool Decode( TSTRING& str ) const;
static TSTRING EncodeInline( const TSTRING& sIn )
{
TSTRING sOut = sIn;
cDisplayEncoder e;
e.Encode( sOut );
return sOut;
}
static TSTRING EncodeInlineAllowWS( const TSTRING& sIn )
{
TSTRING sOut = sIn;
cDisplayEncoder e( (Flags)( NON_ROUNDTRIP | ALLOW_WHITESPACE ) );
e.Encode( sOut );
return sOut;
}
};
class cCharEncoderUtil
{
public:
static bool IsPrintable( TCHAR ch );
static bool IsWhiteSpace( TCHAR ch );
static TSTRING CharStringToHexValue( const TSTRING& str );
static TSTRING HexValueToCharString( const TSTRING& str );
static TCHAR hex_to_char( TSTRING::const_iterator first,
TSTRING::const_iterator last );
static TSTRING char_to_hex( TCHAR ch );
static TSTRING DecodeHexToChar( TSTRING::const_iterator* pcur,
const TSTRING::const_iterator end );
enum
{
BYTE_AS_HEX__IN_TCHARS = 2,
BYTES_PER_TCHAR = sizeof( TCHAR ),
TCHAR_AS_HEX__IN_TCHARS = BYTE_AS_HEX__IN_TCHARS * BYTES_PER_TCHAR
};
};
#endif //__DISPLAYENCODER_H
/*
///////////////////////////////////////////////////////////////////////////////
// displayencoder.h
//
#ifndef __DISPLAYENCODER_H
#define __DISPLAYENCODER_H
//=========================================================================
// DECLARATION OF CLASSES
//=========================================================================
///////////////////////////////////////////////
// cDisplayEncoder
///////////////////////////////////////////////
template< class CharT >
class iCharEncoder_;
// TODO:BAM -- i don't think that the order of encodings is important
// as long as AllIdentifiersUnique and OnlyOneCatagoryPerChar are true
template< class CharT >
class cEncoder
{
public:
enum Encodings
{
NON_NARROWABLE = 0x01, // WC -> SB, SB alway narrowable:
NON_PRINTABLE = 0x02,
BACKSLASH = 0x04,
DBL_QUOTE = 0x08,
};
enum Flags
{
ROUNDTRIP = 0x01,
NON_ROUNDTRIP = 0x02,
};
cEncoder( int e, int f ); // mask of Encodings
virtual ~cEncoder();
void Encode( TSTRING& str ) const;
void Decode( TSTRING& str ) const; // TODO:BAM -- throw error!
void ValidateSchema() const;
bool OnlyOneCatagoryPerChar() const;
bool AllIdentifiersUnique() const;
bool AllTestsRunOnEncodedString( const TSTRING& str ) const;
private:
typedef std::vector< iCharEncoder_<CharT>* > sack_type;
sack_type m_encodings;
bool m_fRoundTrip;
};
// encodes ( BACKSLASH | DBL_QUOTE | NON_NARROWABLE | NON_PRINTABLE )
template< class CharT >
class cDisplayEncoder_ : public cEncoder< CharT >
{
public:
cDisplayEncoder_( Flags f = NON_ROUNDTRIP );
void Encode( TSTRING& str ) const;
bool Decode( TSTRING& str ) const;
};
///////////////////////////////////////////////
// cTWLocale
///////////////////////////////////////////////
// to make it easier to use....
///////////////////////////////////////////////
typedef cDisplayEncoder_<TCHAR> cDisplayEncoder;
#endif //__DISPLAYENCODER_H
*/

View File

@ -0,0 +1,367 @@
//
// 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.
//
//
// Name....: displayencoder_t.cpp
// Date....: 10/18/99
// Creator.: Brian McFeely (bmcfeely)
//
#include "stdcore.h"
#ifdef TSS_TEST
#include "test/utx.h"
#include "displayencoder.h"
#include "debug.h"
#include "twlocale.h"
#include "errorbucketimpl.h"
///////////////////////////////////////////////////////////////////////////////
// UTIL
///////////////////////////////////////////////////////////////////////////////
#ifdef _UNICODE
#define TSS_TCHAR_MIN WCHAR_MIN
#define TSS_TCHAR_MAX WCHAR_MAX
#else
#define TSS_TCHAR_MIN CHAR_MIN
#define TSS_TCHAR_MAX CHAR_MAX
#endif
template< class CharT > bool IsPrintable( const std::basic_string< CharT >& str )
{
const std::ctype< CharT > *pct = 0, &ct = tss::GetFacet( std::locale(), pct );
for( std::basic_string< CharT >::const_iterator at = str.begin(); at != str.end(); at++ )
{
if( ! ct.is( std::ctype_base::print, *at ) ) // if not printable
return false;
}
return true;
}
static void util_TestUnprintable( const TSTRING& strCUnprintable )
{
cDisplayEncoder e( cDisplayEncoder::ROUNDTRIP );
TSTRING strEncoded = strCUnprintable;
e.Encode( strEncoded );
TCOUT << strEncoded << std::endl;
TSTRING strOut = strEncoded;
e.Decode( strOut );
ASSERT( strOut == strCUnprintable );
}
///////////////////////////////////////////////////////////////////////////////
// cDisplayEncoderTest
///////////////////////////////////////////////////////////////////////////////
class cDisplayEncoderTest
{
public:
///////////////////////////////////////////////////////////////////////////
// TestCharToHex
///////////////////////////////////////////////////////////////////////////
void TestCharToHex( tss::TestContext& ctx )
{
TCHAR ch;
TSTRING str;
const std::ctype< TCHAR > *pct = 0, &ct = tss::GetFacet( std::locale(), pct );
// only use lowercase strings with this define
#define TSS_CHAR_TO_HEX_TEST( s ) \
ch = 0x ## s; \
str = cCharEncoderUtil::char_to_hex( ch ); \
ct.tolower( str.begin(), str.end() ); \
ASSERT( str == _T( #s ) );
TSS_CHAR_TO_HEX_TEST( fefe );
TSS_CHAR_TO_HEX_TEST( 0000 );
TSS_CHAR_TO_HEX_TEST( 1234 );
TSS_CHAR_TO_HEX_TEST( ffff );
TSS_CHAR_TO_HEX_TEST( 0001 );
TSS_CHAR_TO_HEX_TEST( 543c );
TSS_CHAR_TO_HEX_TEST( cccc );
TSS_CHAR_TO_HEX_TEST( 9999 );
TSS_CHAR_TO_HEX_TEST( abcd );
}
///////////////////////////////////////////////////////////////////////////
// TestHexToChar
///////////////////////////////////////////////////////////////////////////
void TestHexToChar( tss::TestContext& ctx )
{
TCHAR ch;
TSTRING str;
// only use lowercase strings with this define
#define TSS_HEX_TO_CHAR_TEST( s ) \
str = _T( #s ); \
ch = cCharEncoderUtil::hex_to_char( str.begin(), str.end() ); \
ASSERT( ch == 0x ## s );
TSS_HEX_TO_CHAR_TEST( fefe );
TSS_HEX_TO_CHAR_TEST( 0000 );
TSS_HEX_TO_CHAR_TEST( 1234 );
TSS_HEX_TO_CHAR_TEST( ffff );
TSS_HEX_TO_CHAR_TEST( 0001 );
TSS_HEX_TO_CHAR_TEST( 543c );
TSS_HEX_TO_CHAR_TEST( cccc );
TSS_HEX_TO_CHAR_TEST( 9999 );
TSS_HEX_TO_CHAR_TEST( abcd );
}
//////////////////////////////////////////////////////////////////////////
// TestStringToHex -- locale specific test -- only works in ASCII
///////////////////////////////////////////////////////////////////////////
void TestStringToHex( tss::TestContext& ctx )
{
TSTRING str;
const std::ctype< TCHAR > *pct = 0, &ct = tss::GetFacet( std::locale(), pct );
// only use lowercase strings with this define
#define TSS_STRING_TO_HEX_TEST( s, n ) \
str = cCharEncoderUtil::CharStringToHexValue( _T( #s ) ); \
ct.tolower( str.begin(), str.end() ); \
ASSERT( str == _T( #n ) );
TSS_STRING_TO_HEX_TEST( \n, 000a );
TSS_STRING_TO_HEX_TEST( \r, 000d );
TSS_STRING_TO_HEX_TEST( \r\n, 000d000a );
TSS_STRING_TO_HEX_TEST( a\r\nb, 0061000d000a0062 );
}
//////////////////////////////////////////////////////////////////////////
// TestHexToString -- locale specific test -- only works in Unicode
///////////////////////////////////////////////////////////////////////////
void TestHexToString( tss::TestContext& ctx )
{
TSTRING str;
const std::ctype< TCHAR > *pct = 0, &ct = tss::GetFacet( std::locale(), pct );
// only use lowercase strings with this define
#define TSS_HEX_TO_STRING_TEST( s, n ) \
str = cCharEncoderUtil::HexValueToCharString( _T( #n ) ); \
ct.tolower( str.begin(), str.end() ); \
ASSERT( str == _T( #s ) );
TSS_HEX_TO_STRING_TEST( \n, 000a );
TSS_HEX_TO_STRING_TEST( \r, 000d );
TSS_HEX_TO_STRING_TEST( \r\n, 000d000a );
TSS_HEX_TO_STRING_TEST( a\r\nb, 0061000d000a0062 );
}
//////////////////////////////////////////////////////////////////////////
// TestUnconvertable -- locale specific test -- only works in Unicode
///////////////////////////////////////////////////////////////////////////
void TestUnconvertable( tss::TestContext& ctx )
{
cDisplayEncoder e( cDisplayEncoder::ROUNDTRIP );
const std::ctype< TCHAR > *pct = 0, &ct = tss::GetFacet( std::locale(), pct );
TSTRING str;
TCHAR ch;
// only use lowercase strings with this define
#define TSS_UNCONVERTABLE_TEST( n ) \
ch = 0x ## n; \
str = ch; \
e.Encode( str ); \
ct.tolower( str.begin(), str.end() ); \
ASSERT( str == _T("\\x") _T( #n ) _T("x") );
TSS_UNCONVERTABLE_TEST( fefe );
TSS_UNCONVERTABLE_TEST( 1234 );
TSS_UNCONVERTABLE_TEST( ffff );
TSS_UNCONVERTABLE_TEST( 1000 );
TSS_UNCONVERTABLE_TEST( 543c );
TSS_UNCONVERTABLE_TEST( cccc );
TSS_UNCONVERTABLE_TEST( 9999 );
TSS_UNCONVERTABLE_TEST( 0123 );
TSS_UNCONVERTABLE_TEST( 0100 );
}
//////////////////////////////////////////////////////////////////////////
// TestUnprintable -- locale specific test -- only works in Unicode
///////////////////////////////////////////////////////////////////////////
void TestUnprintable( tss::TestContext& ctx )
{
cDisplayEncoder e( cDisplayEncoder::ROUNDTRIP );
const std::ctype< TCHAR > *pct = 0, &ct = tss::GetFacet( std::locale(), pct );
TSTRING str;
TCHAR ch;
// only use lowercase strings with this define
#define TSS_UNPRINTABLE_TEST( n ) \
ch = 0x ## n; \
str = ch; \
e.Encode( str ); \
ct.tolower( str.begin(), str.end() ); \
ASSERT( str == _T("\\x") _T( #n ) _T("x") );
TSS_UNPRINTABLE_TEST( 000a );
TSS_UNPRINTABLE_TEST( 000d );
}
//////////////////////////////////////////////////////////////////////////
// TestQuoteAndBackSlash
///////////////////////////////////////////////////////////////////////////
void TestQuoteAndBackSlash( tss::TestContext& ctx )
{
cDisplayEncoder e( cDisplayEncoder::ROUNDTRIP );
TSTRING str;
str = _T("\\");
e.Encode( str );
ASSERT( str == _T("\\\\") );
str = _T("\"");
e.Encode( str );
ASSERT( str == _T("\\\"") );
}
// TODO:BAM -- try multibyte now.....
///////////////////////////////////////////////////////////////////////////
// Basic
///////////////////////////////////////////////////////////////////////////
void Basic( tss::TestContext& ctx )
{
try
{
//=============================================================
// TEST UNPRINTABLE ENCODING/ROUNDTRIP
//=============================================================
util_TestUnprintable( _T("normal string") );
util_TestUnprintable( _T("return\n") );
util_TestUnprintable( _T("ret\rurn\n") );
util_TestUnprintable( _T("ret\rnurn\n") );
util_TestUnprintable( _T("bell\x08") );
util_TestUnprintable( _T("\x08 bell") );
util_TestUnprintable( _T("be\x08ll") );
util_TestUnprintable( _T("\x1F\x1F\x1F") );
util_TestUnprintable( _T("big\xFF") );
util_TestUnprintable( _T("\xEE big") );
util_TestUnprintable( _T("\xEE\xEEtwo big") );
util_TestUnprintable( _T("small\x01") );
util_TestUnprintable( _T("\x01\x01two small") );
//=============================================================
// TEST UNCONVERTABLE CHARS
//=============================================================
TSTRING strMessWithMe = _T("Mess with me...");
for( size_t c = TSS_TCHAR_MIN;
c < TSS_TCHAR_MAX;
#ifdef _UNICODE
c += ( TSS_TCHAR_MAX / 150 ) )
#else
c++ )
#endif
{
if( ( c != '\0' ) )
{
strMessWithMe += c;
}
}
util_TestUnprintable( strMessWithMe );
//=============================================================
// TEST \\ and \x ENCODING/ROUNDTRIP
//=============================================================
util_TestUnprintable( _T("\\Other \\\\slashes") );
util_TestUnprintable( _T("\\Other slashes\\\\") );
util_TestUnprintable( _T("O\\ther slashes\\\\") );
util_TestUnprintable( _T("\\\\\\") );
util_TestUnprintable( _T("\\xTricky") );
util_TestUnprintable( _T("Tri\\xcky") );
util_TestUnprintable( _T("Tricky\\x") );
util_TestUnprintable( _T("\\Tricky\\\\x") );
//=============================================================
// TEST UNCONVERTABLE, UNPRINTABLE, AND \\ and \" CHARS
//=============================================================
TSTRING strMessWithMe2 = _T("Mess with me...");
for( size_t ch = TSS_TCHAR_MIN;
ch < TSS_TCHAR_MAX;
#ifdef _UNICODE
ch += ( TSS_TCHAR_MAX / 150 ) )
#else
ch++ )
#endif
{
if( ( ch != '\0' ) )
{
strMessWithMe2 += ch;
}
}
strMessWithMe2 += _T("\r\n\t\b\\\"\\\\\\\"\v\"");
util_TestUnprintable( strMessWithMe2 );
// TODO:BAM -- create multibyte tests (create a mb string at random, then test it.
// make sure there are '\' and '"' in it )
}
catch( eError& e )
{
cErrorReporter::PrintErrorMsg( e );
ASSERT(false);
}
}
};
TSS_BeginTestSuiteFrom( cDisplayEncoderTest )
TSS_AddTestCase( Basic );
TSS_AddTestCase( TestHexToChar );
TSS_AddTestCase( TestCharToHex );
TSS_AddTestCase( TestStringToHex );
TSS_AddTestCase( TestHexToString );
TSS_AddTestCase( TestUnconvertable );
TSS_AddTestCase( TestUnprintable );
TSS_AddTestCase( TestQuoteAndBackSlash );
TSS_EndTestSuite( cDisplayEncoderTest )
#endif // TSS_TEST
// eof: displayencoder_t.cpp

100
src/core/displayutil.cpp Normal file
View File

@ -0,0 +1,100 @@
//
// 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.
//
//
// Name....: displayutil.cpp
// Date....: 7/12/99
// Creator.: Brian McFeely (bmcfeely)
//
#include "stdcore.h"
#include "displayutil.h"
#include "ntmbs.h"
#include <iomanip>
TSTRING cDisplayUtil::FormatMultiLineString( const TSTRING& str, int nOffset, int nWidth )
{
TOSTRINGSTREAM sstr;
TSTRING strT;
bool fFirstLine = true;
for( TSTRING::const_iterator i = str.begin(); i != str.end(); i = *i ? i + 1 : i )
{
// return found -- add line to output string
if( _T('\n') == *i )
{
// only do offset for strings after the first
if( fFirstLine )
{
fFirstLine = false;
}
else
{
// add offset
for( int j = 0; j < nOffset; j++ )
sstr << _T(" ");
// set width
sstr << std::setw( nWidth );
}
// add to stringstream
sstr << strT << std::endl;
// erase temp string
strT.erase();
}
else
{
// add char to string
strT.append( i, (TSTRING::const_iterator)(*i ? i + 1 : i) );
}
}
// add last portion -- no endl
// we want our client to be able to say "out << PropAsString() << endl;"
// add offset
if( ! fFirstLine )
{
for( int j = 0; j < nOffset; j++ )
sstr << _T(" ");
}
// set width
sstr << std::setw( nWidth );
// now add last string
sstr << strT;
return( sstr.str() );
}
// eof: displayutil.cpp

101
src/core/displayutil.h Normal file
View File

@ -0,0 +1,101 @@
//
// 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.
//
//
// Name....: displayutil.h
// Date....: 7/12/99
// Creator.: Brian McFeely (bmcfeely)
//
#ifndef __DISPLAYUTIL_H
#define __DISPLAYUTIL_H
class cDisplayUtil
{
public:
static TSTRING FormatMultiLineString( const TSTRING& str, int nOffset, int nWidth );
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Way too verbose here, but it was the best I could do. I know, I know.
// If it's too complicated to explain, there's an easier way to do it.
// Soooo, I'll just put a TODO:BAM here
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//
// So, there's this problem with outputting a string with newlines in it when you want
// to format the output stream. For instance:
//
// TCHAR szTenSpaceMargin[] = { _T(" ") };
// TCHAR szMessage[] = { _T("First Line\nSecond Line\n") };
//
// TCOUT << szTenSpaceMargin << setw(15) << szMessage;
//
// What happens is that you get output like:
// " First Line"
// ^ ^^ ^
// |--10 sp-||---15 width--|
// "Second Line"
// ^
// | 0 sp, 0 width
//
// When you really wanted:
// " First Line"
// ^ ^^ ^
// |--10 sp-||---15 width--|
// " Second Line"
// ^ ^^ ^
// |--10 sp-||---15 width--|
//
//
// Sooooo, what this little beauty does is change the string
// "First Line\nSecond Line\n" into ""First Line\n Second Line\n"
// ( adds nOffset spaces after each '\n', and makes sure that each line is
// in a output width specified by nWidth )
//
// So you can output a multiline string and have each line be formatted
// like the first one was.
//
// So, for the preceeding example,
//
// change:
// TCOUT << szTenSpaceMargin << setw(15) << szMessage;
//
// to:
// TCOUT << szTenSpaceMargin << setw(15)
// << cDisplayUtil::FormatMultiLineString( szMessage, 10, 15 );
//
// Comprende? It's crazy but it works.
//
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#endif // #ifndef __DISPLAYUTIL_H

51
src/core/error.cpp Normal file
View File

@ -0,0 +1,51 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// error.cpp
//
#include "stdcore.h"
#include "error.h"
#include "crc32.h"
///////////////////////////////////////////////////////////////////////////////
// CalcHash
///////////////////////////////////////////////////////////////////////////////
uint32 eError::CalcHash( const char* name )
{
CRC_INFO crc;
crcInit( crc );
crcUpdate( crc, (const uint8*)name, strlen( name ) );
crcFinit( crc );
return crc.crc;
}

303
src/core/error.h Normal file
View File

@ -0,0 +1,303 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// error.h
//
#ifndef __ERROR_H
#define __ERROR_H
//-----------------------------------------------------------------------------
// eError
//-----------------------------------------------------------------------------
class eError
{
public:
//-------------------------------------------------------------------------
// Construction and Assignment
//-------------------------------------------------------------------------
eError( const TSTRING& msg, uint32 flags = 0 );
explicit eError( const eError& rhs );
explicit eError();
void operator=( const eError& rhs );
//-------------------------------------------------------------------------
// Destruction
//-------------------------------------------------------------------------
virtual ~eError();
//-------------------------------------------------------------------------
// Data Access
//-------------------------------------------------------------------------
virtual uint32 GetID() const = 0;
// returns a system wide unique identifier for this exception. See the
// macro below for the typical implementation of this method.
// This is used to associate the error with a string description of the
// error via the global error table.
virtual TSTRING GetMsg() const;
// returns specific information about the error that occured. Provides
// additional information about the error described by GetID(). It should
// not provide any information redundant with GetID().
//
// The string passed to the constructor should be formated properly to
// be displayed as the "Second" part of an error message, or the derived
// class should override GetMsg() and return a string appropriate for display.
uint32 GetFlags() const;
// Flags are defined below. Currently, these only have an impact on how errors are
// displayed.
//-------------------------------------------------------------------------
// Flags
//-------------------------------------------------------------------------
enum Flag
{
NON_FATAL = 0x00000001, // displays "Error" or "Warning" ?
SUPRESS_THIRD_MSG = 0x00000002 // supresses the "continuing" or "exiting" message
};
void SetFlags( uint32 flags );
//-------------------------------------------------------------------------
// Flag Convenience Methods
//-------------------------------------------------------------------------
void SetFatality(bool fatal);
bool IsFatal() const;
// Fatality is set to true by default when eError is constructed. But when an error
// it is put in an cErrorBucket chain it the code doing so may wish to set the fatality
// to non-fatal to indicate that the error is actually a warning and program flow
// is going to continue.
void SetSupressThird(bool supressThird);
bool SupressThird() const;
//-------------------------------------------------------------------------
// Utility Methods
//-------------------------------------------------------------------------
static uint32 CalcHash( const char* name );
// calculates the CRC32 of the string passed in as name. This methods
// asserts that name is non null. This is used to generate unique IDs
// for errors.
//-------------------------------------------------------------------------
// Private Implementation
//-------------------------------------------------------------------------
protected:
TSTRING mMsg;
uint32 mFlags;
};
//-----------------------------------------------------------------------------
// Error Related Macros
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// TSS_BEGIN_EXCEPTION / TSS_END_EXCEPTION
//
// Serves the same purpose as TSS_EXCEPTION but allows custom data and methods
// to be added to the exception class.
///////////////////////////////////////////////////////////////////////////////
#if HAVE_GCC
#define TSS_BEGIN_EXCEPTION_EXPLICIT
#else
#define TSS_BEGIN_EXCEPTION_EXPLICIT explicit
#endif
#define TSS_BEGIN_EXCEPTION( except, base ) \
class except : public base \
{\
public:\
except( const TSTRING& msg, uint32 flags = 0 ) \
: base( msg, flags ) {} \
TSS_BEGIN_EXCEPTION_EXPLICIT except( const except& rhs ) \
: base( rhs ) {} \
explicit except() : base() {} \
\
virtual uint32 GetID() const \
{\
return CalcHash( #except ); \
}\
#define TSS_END_EXCEPTION( ) \
};
///////////////////////////////////////////////////////////////////////////////
// TSS_BEGIN_EXCEPTION_NO_CTOR
//
// Same as TSS_BEGIN_EXCEPTION, but doesn't define any ctors.
///////////////////////////////////////////////////////////////////////////////
#define TSS_BEGIN_EXCEPTION_NO_CTOR( except, base ) \
class except : public base \
{\
public:\
explicit except() : base() {} \
\
virtual uint32 GetID() const \
{\
return CalcHash( #except ); \
}\
///////////////////////////////////////////////////////////////////////////////
// TSS_EXCEPTION
//
// This is a convenience define for quickly defining an exception class. After
// defining a new exception, don't forget to add it to the package's error
// string file!
//
// TODO (mdb) -- do we want to cache the CRC? if we store it in a class static
// variable, then we will need to define it in the cpp file as well ...
///////////////////////////////////////////////////////////////////////////////
#define TSS_EXCEPTION( except, base ) \
TSS_BEGIN_EXCEPTION( except, base ) \
TSS_END_EXCEPTION()
//-----------------------------------------------------------------------------
// Inline Implementation
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
// eError
///////////////////////////////////////////////////////////////////////////////
inline eError::eError( const TSTRING& msg, uint32 flags )
: mMsg ( msg ),
mFlags ( flags )
{
}
///////////////////////////////////////////////////////////////////////////////
// eError
///////////////////////////////////////////////////////////////////////////////
inline eError::eError( const eError& rhs )
: mMsg ( rhs.mMsg ),
mFlags ( rhs.mFlags )
{
}
///////////////////////////////////////////////////////////////////////////////
// eError
///////////////////////////////////////////////////////////////////////////////
inline eError::eError( )
: mMsg ( _T("") ),
mFlags ( 0 )
{
}
///////////////////////////////////////////////////////////////////////////////
// operator=
///////////////////////////////////////////////////////////////////////////////
inline void eError::operator=( const eError& rhs )
{
mMsg = rhs.mMsg;
mFlags = rhs.mFlags;
}
///////////////////////////////////////////////////////////////////////////////
// ~eError
///////////////////////////////////////////////////////////////////////////////
inline eError::~eError()
{
}
///////////////////////////////////////////////////////////////////////////////
// GetMsg
///////////////////////////////////////////////////////////////////////////////
inline TSTRING eError::GetMsg() const
{
return mMsg;
}
///////////////////////////////////////////////////////////////////////////////
// GetFlags
///////////////////////////////////////////////////////////////////////////////
inline uint32 eError::GetFlags() const
{
return mFlags;
}
///////////////////////////////////////////////////////////////////////////////
// SetFlags
///////////////////////////////////////////////////////////////////////////////
inline void eError::SetFlags( uint32 flags )
{
mFlags = flags;
}
///////////////////////////////////////////////////////////////////////////////
// SetFatality
///////////////////////////////////////////////////////////////////////////////
inline void eError::SetFatality(bool fatal)
{
if (fatal)
mFlags &= ~(uint32)NON_FATAL;
else
mFlags |= (uint32)NON_FATAL;
}
///////////////////////////////////////////////////////////////////////////////
// IsFatal
///////////////////////////////////////////////////////////////////////////////
inline bool eError::IsFatal() const
{
return (mFlags & (uint32)NON_FATAL) == 0;
}
///////////////////////////////////////////////////////////////////////////////
// SetSupressThird
///////////////////////////////////////////////////////////////////////////////
inline void eError::SetSupressThird(bool supressThird)
{
if (supressThird)
mFlags |= (uint32)SUPRESS_THIRD_MSG;
else
mFlags &= ~(uint32)SUPRESS_THIRD_MSG;
}
///////////////////////////////////////////////////////////////////////////////
// SupressThird
///////////////////////////////////////////////////////////////////////////////
inline bool eError::SupressThird() const
{
return (mFlags & (uint32)SUPRESS_THIRD_MSG) == 0;
}
#endif //__ERROR_H

73
src/core/error_t.cpp Normal file
View File

@ -0,0 +1,73 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// error_t.h -- the vcc exception test driver
#include "stdcore.h"
#include "error.h"
#include "test/test.h"
#include <iostream>
void TestError()
{
//#pragma message( __FILE__ "(1) : TODO - implement this test file")
/*
try
{
std::cout << "Before Exception" << std::endl;
std::cout << "Line number before throw: " << __LINE__ << std::endl;
THROW_ERROR(53, _T("This is an error!"));
std::cout << "After Exception" << std::endl;
}
catch(eError& e)
{
TEST(e.GetErrorNum() == 53);
TEST(_tcscmp(e.GetMsg().c_str(), _T("This is an error!")) == 0);
TCOUT << _T("Exception caught!\n\tErrorNum=") << e.GetErrorNum() << _T("\n\t") << e.GetMsg() << std::endl;
}
try
{
THROW_INTERNAL("error_t.cpp");
}
catch(eInternal& e)
{
TEST(e.GetErrorNum() == eInternal::ERR_INTERNAL);
TCOUT << _T("Internal error caught!\n\tErrorNum=") << e.GetErrorNum() << _T("\n\t") << e.GetMsg() << std::endl;
}
catch(...)
{
TEST(false);
}
*/
}

102
src/core/errorbucket.h Normal file
View File

@ -0,0 +1,102 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// errorbucket.h
//
#ifndef __ERRORBUCKET_H
#define __ERRORBUCKET_H
#ifndef __TYPES_H
#include "types.h"
#endif
#ifndef __TCHAR_H
#include "core/tchar.h"
#endif
class eError;
///////////////////////////////////////////////////////////////////////////////
// cErrorBucket -- contains an interface that handles error reporting, and
// contains a link to a child bucket. Each concrete implementation of the
// cErrorBucket interface will perform its own specific task related to the
// error's occurence (print to stderr, store in a queue, etc) and then forward
// the error on to its child link. The parent bucket does not own the destruction
// of the pointer to the child bucket.
///////////////////////////////////////////////////////////////////////////////
class cErrorBucket
{
public:
cErrorBucket();
virtual ~cErrorBucket() {}
virtual void AddError(const eError& error);
// add an error to the bucket
cErrorBucket* GetChild();
// returns the bucket that the current bucket is chained to, or
// NULL if nothing is attached to it.
cErrorBucket* SetChild(cErrorBucket* pNewChild);
// sets the child link of this bucket; returns the old link value
protected:
virtual void HandleError(const eError& error) = 0;
// override this to implement error handling functionality specific to
// the derived class
cErrorBucket* mpChild;
};
//#############################################################################
// inline implementation
///////////////////
// cErrorBucket
///////////////////
inline cErrorBucket::cErrorBucket() :
mpChild(0)
{
}
inline cErrorBucket* cErrorBucket::GetChild()
{
return mpChild;
}
inline cErrorBucket* cErrorBucket::SetChild(cErrorBucket* pNewChild)
{
cErrorBucket* pOldChild = mpChild;
mpChild = pNewChild;
return pOldChild;
}
#endif

View File

@ -0,0 +1,307 @@
//
// 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.
//
// errorbucketimpl.cpp
#include "stdcore.h"
#include "errorbucketimpl.h"
#include "errortable.h"
#include "serializer.h"
#include "corestrings.h"
#include "displayencoder.h"
//#############################################################################
// cErrorBucket
//#############################################################################
void cErrorBucket::AddError(const eError& error)
{
HandleError(error);
if(mpChild)
mpChild->AddError(error);
}
//#############################################################################
// cErrorReporter
//#############################################################################
void cErrorReporter::PrintErrorMsg(const eError& error, const TSTRING& strExtra)
{
cDisplayEncoder e(
(cDisplayEncoder::Flags) ( cDisplayEncoder::NON_ROUNDTRIP |
cDisplayEncoder::ALLOW_WHITESPACE ) );
TSTRING errStr;
int len;
//
// if the ID is zero, just return.
// this should only occur at the top level of a program (ie -- twcmdline.cpp) and
// indicates that an error occurred and an error message has already been printed out.
// Therefore, we will do nothing here but return.
//
// TODO: Having an error with an ID of 0 is legacy. The only place it happens at this
// point is when we throw ePoly() with no constructor arguments. At some point we want
// to stop using the mechanism have non-printing errors, thus we leave in the ASSERT below.
// But we don't want to break any release code, thus we return on the next line - June 2, 1999 DMB.
ASSERT( error.GetID() != 0 );
if( error.GetID() == 0 )
return;
// "First Part" header
errStr = TSS_GetString( cCore, error.IsFatal() ? core::STR_ERROR_ERROR
: core::STR_ERROR_WARNING );
if (errStr.empty())
{
TOSTRINGSTREAM strm;
ASSERT( sizeof( uint32 ) == sizeof(unsigned int) ); // for cast on next line
strm << _T("Unknown Error ID ") << (unsigned int)error.GetID();
errStr = strm.str();
}
len = errStr.length(); // save for later
TCERR << errStr;
// "First Part" error string
TSTRING prependToSecond;
// #pragma message("errorbucketimpl.cpp needs a little help in the mb arena, with the findfirst/last and such")
errStr = cErrorTable::GetInstance()->Get( error.GetID() );
if(! errStr.empty())
{
// If the first part has a '\n' in it, we take everything following and prepend it to the
// second part. This was added to allow specifing a verbose string as the second part
// of an error message when building the error table. This change was made on July 27, 1999
TSTRING::size_type firstLF;
if ((firstLF = errStr.find_first_of(_T('\n'))) != TSTRING::npos)
{
prependToSecond = errStr.substr(firstLF + 1); // don't include '\n' in new string
errStr.erase(firstLF);
}
ASSERT(errStr.length() + len + 6 < 80); // line too big for terminal?
// Add 6 to account for "### ' and ': '
TCERR << TSS_GetString( cCore, core::STR_ERROR_COLON ) << _T(" ") << errStr;
TCERR << std::endl;
}
// "Second Part" error string
const int WIDTH = 80 - 4; // allow for "### " prefix to every error line
const TCHAR SPACE = _T(' ');
errStr = prependToSecond + error.GetMsg() + strExtra;
e.Encode( errStr );
if (! errStr.empty())
{
do
{
// look for newline chars
TSTRING::size_type firstNewLine;
TSTRING currentStr = errStr.substr(0, (firstNewLine = errStr.find_first_of(_T('\n'))));
errStr.erase(0, (firstNewLine < errStr.length() ? firstNewLine + 1 : firstNewLine));
// break up the error string in case it is larger than screen width
do
{
if (currentStr.length() <= (unsigned int)WIDTH)
{
TCERR << TSS_GetString( cCore, core::STR_ERROR_HEADER ) << currentStr << std::endl;
break;
}
TSTRING::size_type lastSpace = currentStr.find_last_of(SPACE, currentStr.length() >= WIDTH - 1 ? WIDTH - 1 : TSTRING::npos);
if (lastSpace == TSTRING::npos)
{
// can't find space to break at so this string will just have to be longer than screen width.
// search forward for a space so we break at the next even word boundry.
lastSpace = currentStr.find_first_of(SPACE, 0);
if (lastSpace == TSTRING::npos)
// Well, there is no space before the end of the string.
// So print the whole string out.
lastSpace = currentStr.length();
}
TCERR << TSS_GetString( cCore, core::STR_ERROR_HEADER )
<< currentStr.substr( 0, lastSpace )
<< std::endl;
currentStr.erase( 0, lastSpace + 1 );
}
while ( !currentStr.empty() );
}
while ( !errStr.empty() );
}
// "Third Part" print 'exiting' or 'continuing'
// note that we supress this part if the appropriate flag is set...
//
if( (error.GetFlags() & eError::SUPRESS_THIRD_MSG) == 0 )
{
TCERR << TSS_GetString( cCore, core::STR_ERROR_HEADER)
<< TSS_GetString(
cCore,
error.IsFatal()
? core::STR_ERROR_EXITING
: core::STR_ERROR_CONTINUING ) << std::endl;
}
}
void cErrorReporter::HandleError(const eError& error)
{
PrintErrorMsg(error);
}
//#############################################################################
// cErrorTracer
//#############################################################################
void cErrorTracer::HandleError(const eError& error)
{
cDebug d("cErrorTracer::HandleError");
d.TraceError( _T("%s : %s\n"),
cErrorTable::GetInstance()->Get( error.GetID() ).c_str(),
error.GetMsg().c_str() );
}
//#############################################################################
// cErrorQueue
//#############################################################################
IMPLEMENT_TYPEDSERIALIZABLE(cErrorQueue, _T("cErrorQueue"), 0, 1);
void cErrorQueue::Clear()
{
mList.clear();
}
int cErrorQueue::GetNumErrors() const
{
return mList.size();
}
void cErrorQueue::HandleError(const eError& error)
{
mList.push_back( ePoly( error ) );
}
cErrorQueueIter::cErrorQueueIter(cErrorQueue& queue) :
mList(queue.mList)
{
SeekBegin();
}
cErrorQueueIter::cErrorQueueIter(const cErrorQueue& queue)
: mList( ((cErrorQueue*)&queue)->mList )
{
SeekBegin();
}
void cErrorQueueIter::SeekBegin()
{
mIter = mList.begin();
}
void cErrorQueueIter::Next()
{
++mIter;
}
bool cErrorQueueIter::Done() const
{
return (mIter == mList.end());
}
const ePoly& cErrorQueueIter::GetError() const
{
ASSERT(! Done());
return (*mIter);
}
///////////////////////////////////////////////////////////////////////////////
// Read
///////////////////////////////////////////////////////////////////////////////
void cErrorQueue::Read(iSerializer* pSerializer, int32 version)
{
if (version > Version())
ThrowAndAssert(eSerializerVersionMismatch(_T("ErrorQueue Read")));
int32 size;
mList.clear();
pSerializer->ReadInt32(size);
for(int i = 0; i < size; ++i)
{
int32 errorNumber;
TSTRING errorString;
int32 flags;
pSerializer->ReadInt32 (errorNumber);
pSerializer->ReadString (errorString);
pSerializer->ReadInt32 (flags);
mList.push_back( ePoly( errorNumber, errorString, flags ) );
}
}
///////////////////////////////////////////////////////////////////////////////
// Write
///////////////////////////////////////////////////////////////////////////////
void cErrorQueue::Write(iSerializer* pSerializer) const
{
pSerializer->WriteInt32(mList.size());
ListType::const_iterator i;
for( i = mList.begin(); i != mList.end(); ++i)
{
pSerializer->WriteInt32 ((*i).GetID());
pSerializer->WriteString((*i).GetMsg());
pSerializer->WriteInt32 ((*i).GetFlags());
}
}
///////////////////////////////////////////////////////////////////////////////
// TraceContents
///////////////////////////////////////////////////////////////////////////////
void cErrorQueue::TraceContents(int dl) const
{
if(dl < 0)
dl = cDebug::D_DEBUG;
cDebug d("cFCOErrorQueue::TraceContents");
ListType::const_iterator i;
int counter = 0;
for(i = mList.begin(); i != mList.end(); i++, counter++)
{
d.Trace(dl, _T("Error[%d]: num = %x string = %s\n") , counter, (*i).GetID(), (*i).GetMsg().c_str());
}
}

174
src/core/errorbucketimpl.h Normal file
View File

@ -0,0 +1,174 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// errorbucketimpl.h
//
// This component contains classes derived from cErrorBucket and helper classes.
// They were broken out of errorbucket.h becuase many components will only need to
// know about cErrorBucket, so we reduce system dependencies by keeping these classes
// separate.
#ifndef __ERRORBUCKETIMPL_H
#define __ERRORBUCKETIMPL_H
#ifndef __ERRORBUCKET_H
#include "errorbucket.h"
#endif
#ifndef __DEBUG_H
#include "debug.h"
#endif
#ifndef __ERROR_H
#include "error.h"
#endif
#ifndef __ERRORUTIL_H
#include "errorutil.h"
#endif
#ifndef __SERIALIZABLE_H
#include "serializable.h"
#endif
//////////////////////////////////////////////////////
// cErrorReporter -- sends all error messages to
// stderr
//////////////////////////////////////////////////////
class cErrorReporter : public cErrorBucket
{
public:
static void PrintErrorMsg(const eError& error, const TSTRING& strExtra = _T(""));
// function that HandleError() uses to print the error messages to stderr.
// this function uses the current authoritative format for error reporting, so
// other functions needing to display errors to the user should use this.
//
// NOTE:bam 5/7/99 -- I don't think the below is true anymore?
// NOTE:mdb -- if the error has an ID of zero, nothing will be printed. This
// is a way to throw a fatal error where the error reporting has already
// occurred.
protected:
virtual void HandleError(const eError& error);
};
///////////////////////////////////////////////////////
// cErrorTracer -- traces all errors with the D_ERROR debug
// level
///////////////////////////////////////////////////////
class cErrorTracer : public cErrorBucket
{
protected:
virtual void HandleError(const eError& error);
};
//////////////////////////////////////////////////////
// cErrorQueue -- keeps track of all the errors that
// are reported to it, providing an interface for
// retrieving them at a later time
//////////////////////////////////////////////////////
class cErrorQueue : public cErrorBucket, public iTypedSerializable
{
friend class cErrorQueueIter;
public:
void Clear();
// remove all errors from the queue
int GetNumErrors() const;
// returns how many errors are in the queue
//
// iSerializable interface
//
virtual void Read (iSerializer* pSerializer, int32 version = 0); // throw (eSerializer, eArchive)
virtual void Write(iSerializer* pSerializer) const; // throw (eSerializer, eArchive)
//
// Debugging
//
void TraceContents(int dl = -1) const;
protected:
virtual void HandleError(const eError& error);
private:
typedef std::list<ePoly> ListType;
ListType mList;
DECLARE_TYPEDSERIALIZABLE()
};
class cErrorQueueIter
{
public:
cErrorQueueIter(cErrorQueue& queue);
cErrorQueueIter(const cErrorQueue& queue);
~cErrorQueueIter() {}
// iteration methods
void SeekBegin();
void Next();
bool Done() const;
// access to the error
const ePoly& GetError() const;
// both of these return results are undefined if the iterator
// is not valid (ie - IsDone() == true)
private:
cErrorQueue::ListType& mList;
cErrorQueue::ListType::iterator mIter;
};
//////////////////////////////////////////////////////
// cErrorBucketNull -- an error bucket that plays the
// role of /dev/null
//////////////////////////////////////////////////////
class cErrorBucketNull : public cErrorBucket
{
virtual void AddError(const eError& ) {}
protected:
virtual void HandleError(const eError& ) {}
};
//////////////////////////////////////////////////////
// cErrorBucketPassThru -- does nothing with errors;
// just passes them on to its children
//////////////////////////////////////////////////////
class cErrorBucketPassThru : public cErrorBucket
{
protected:
virtual void HandleError(const eError& ) {}
};
#endif

View File

@ -0,0 +1,142 @@
//
// 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.
//
// errorbucketimpl_t.cpp
#include "stdcore.h"
#include "errorbucketimpl.h"
#include "test/test.h"
#include "debug.h"
#include "archive.h"
#include "errorgeneral.h"
// test option 7
void TestErrorBucketImpl()
{
/*
//This whole function is in sorry shape... TODO: Fix this DRA
d.TraceDebug("Entering...\n");
cErrorReporter er;
cErrorQueue eq;
er.SetChild(&eq);
//These calls to PrintErrorMsg are broken. The code is probably old. -DRA
// Test error reporting
cErrorReporter::PrintErrorMsg(eError(_T("This should have a single line.")));
cErrorReporter::PrintErrorMsg(eError(_T("This should have a mulitiple lines since I have")
_T(" put so much text here. But it does have a lot")
_T(" of spaces so cErrorReporter should have no")
_T(" problem breaking it up.")
));
cErrorReporter::PrintErrorMsg(eError(_T("This has many long words: ")
_T("40chars_________________________________")
_T(" short words ")
_T("50chars___________________________________________")
_T(" short words ")
_T("90chars___________________________________________________________________________________")
_T(" short words short words short words short words ")
_T("90chars___________________________________________________________________________________")
));
cErrorReporter::PrintErrorMsg(eError(_T("The error reporter should handle newlines.\n")
_T("Newlines should break up the text appropriately. Who knows when they will occur. Can't have them getting in the way.\n")
_T("And one last line with a big char strings: 90chars___________________________________________________________________________________ 40chars_________________________________ 50chars___________________________________________")
));
// TODO -- test the error table
// TODO -- test the error filter
// set some errors...
TSS_EXCEPTION( eTestErrorBucketImpl, eError );
eTestErrorBucketImpl error1(_T("Error A")), error2(_T("Error B")), error3(_T("Error C"));
er.AddError(error1); d.TraceDebug("Adding error 0 -- Error A\n");
er.AddError(error2); d.TraceDebug("Adding error 1 -- Error B\n");
er.AddError(error3); d.TraceDebug("Adding error 100 -- Error C\n");
// those should have gone out to stderr; let's check the queue
cErrorQueueIter i(eq);
int counter = 0;
for(i.SeekBegin(); ! i.Done(); i.Next(), counter++)
{
switch(counter)
{
case 0:
TEST(i.GetError().GetID() == error1.GetID());
TEST(i.GetError().GetMsg().compare(_T("Error A")) == 0);
break;
case 1:
TEST(i.GetError().GetID() == error2.GetID());
TEST(i.GetError().GetMsg().compare(_T("Error B")) == 0);
break;
case 2:
TEST(i.GetError().GetID() == error3.GetID());
TEST(i.GetError().GetMsg().compare(_T("Error C")) == 0);
break;
default:
TEST(false);
}
}
TODO - test this stuff that's commented out
TCOUT << _T("Following string should be a cArchive::ERR_OPEN_FAILED error:\n");
TCOUT << cErrorTable::GetErrorString(cArchive::ERR_OPEN_FAILED) << std::endl;
// print out all error strings
#if 1
// Look up all errors.
// Note: our current error printing format limits us to 4 digit errors, so this should work for a while.
int errornum;
for (errornum = 0; errornum <= 9999; ++errornum)
{
TSTRING errorString = cErrorTable::GetErrorString(errornum);
if (errorString.compare(0, 26, _T("**** Invalid Error Number ")) != 0)
{
TCOUT << _T("### Error ");
TCOUT.width(4);
TCHAR oldfill = TCOUT.fill(_T('0'));
TCOUT << errornum;
TCOUT.fill(oldfill);
TCOUT << _T(": ") << errorString << std::endl;
}
}
#endif
d.TraceDebug("Leaving...\n");
*/
}

49
src/core/errorgeneral.h Normal file
View File

@ -0,0 +1,49 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// errorgeneral.h --
//
#ifndef __ERRORGENERAL_H
#define __ERRORGENERAL_H
#include "error.h"
TSS_EXCEPTION( eErrorGeneral, eError );
TSS_EXCEPTION( eOpen, eErrorGeneral );
TSS_EXCEPTION( eOpenRead, eErrorGeneral );
TSS_EXCEPTION( eOpenWrite, eErrorGeneral );
TSS_EXCEPTION( eBadCmdLine, eErrorGeneral );
TSS_EXCEPTION( eBadModeSwitch, eErrorGeneral );
#endif //#ifndef __ERRORGENERAL_H

81
src/core/errortable.cpp Normal file
View File

@ -0,0 +1,81 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// errortable.cpp
//
#include "stdcore.h"
#include "errortable.h"
#ifdef _DEBUG
#include "package.h"
#include "corestrings.h"
#endif
///////////////////////////////////////////////////////////////////////////////
// GetInstance
///////////////////////////////////////////////////////////////////////////////
cErrorTable* cErrorTable::GetInstance()
{
static cErrorTable gErrorTable;
return &gErrorTable;
}
///////////////////////////////////////////////////////////////////////////////
// AssertMsgValidity
///////////////////////////////////////////////////////////////////////////////
#ifdef _DEBUG
void cErrorTable::AssertMsgValidity(const TCHAR* msg)
{
// Check to see that the first part of this error message is not too long.
TSTRING errStr = msg;
// We only need to check up until the first '\n' since error reporter moves everything
// after that to the "second part".
TSTRING::size_type errSize = errStr.find_first_of(_T('\n'));
if (errSize == TSTRING::npos)
errSize = errStr.length();
#if 0 //TODO: Figure out how to do this properly.
TSTRING::size_type errorSize = TSS_GetString( cCore, core::STR_ERROR_ERROR ).length();
TSTRING::size_type warningSize = TSS_GetString( cCore, core::STR_ERROR_WARNING ).length();
TSTRING::size_type maxHeaderSize = (errorSize > warningSize ? errorSize : warningSize) + 6; // Add 6 to account for "### ' and ': '
#else
// Sunpro got stuck in an infinite loop when we called GetString from this func;
TSTRING::size_type errorSize = 9;
TSTRING::size_type warningSize = 10;
TSTRING::size_type maxHeaderSize = (errorSize > warningSize ? errorSize : warningSize) + 6; // Add 6 to account for "### ' and ': '
#endif
ASSERT(maxHeaderSize + errSize < 80);
}
#endif

140
src/core/errortable.h Normal file
View File

@ -0,0 +1,140 @@
//
// 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.
//
///////////////////////////////////////////////////////////////////////////////
// File: errortable.h
// Date: 30 April 99
// Creator: mdb
//
// cErrorTable -- singleton derived from Resource_<> that serves as the global
// error id to string mapping
//
#ifndef __ERRORTABLE_H
#define __ERRORTABLE_H
#ifndef __TSS_RESOURCES_H
#include "resources.h"
#endif
#ifndef __ERROR_H
#include "error.h"
#endif
class eError;
//-----------------------------------------------------------------------------
// cErrorTable
//-----------------------------------------------------------------------------
class cErrorTable : public cMessages_<uint32, TCHAR>
{
public:
typedef cMessages_<uint32, TCHAR> inherited;
//
// Convenience Methods
//
void Put( const eError& e, const TCHAR* msg );
//
// Singleton Interface
//
static cErrorTable* GetInstance();
private:
#ifdef _DEBUG
static void AssertMsgValidity(const TCHAR* msg);
#endif
};
inline void cErrorTable::Put( const eError& e, const TCHAR* msg )
{
#ifdef _DEBUG
AssertMsgValidity(msg);
#endif
inherited::Put( e.GetID(), msg );
}
//-----------------------------------------------------------------------------
// Convenience Macros
//-----------------------------------------------------------------------------
//
// These macros make it easy for a module to register errors with the global
// error table. Them like this:
//
// // animalerrors.h
// //
// TSS_DECLARE_ERROR_REGISTRATION( animal )
//
// // animalerrors.cpp
// //
// TSS_BEGIN_ERROR_REGISTRATION( animal )
// TSS_REGISTER_ERROR( eDog, _T("Dog error") )
// TSS_REGISTER_ERROR( eDogBark, _T("Barking error") )
// TSS_END_ERROR_REGISTRATION()
//
// // pkg.h
// TSS_DeclarePackage( cWorld )
//
// // pkg.cpp
// cWorld::cWorld()
// {
// TSS_REGISTER_PKG_ERRORS( animal )
//
//===================
// cpp file macros
//===================
#define TSS_BEGIN_ERROR_REGISTRATION( pkgName ) \
RegisterErrors##pkgName::RegisterErrors##pkgName() \
{
#define TSS_REGISTER_ERROR( err, str ) \
cErrorTable::GetInstance()->Put \
( err, str );
#define TSS_END_ERROR_REGISTRATION() \
}
//===================
// h file macros
//===================
#define TSS_DECLARE_ERROR_REGISTRATION( pkgName ) \
struct RegisterErrors##pkgName \
{\
RegisterErrors##pkgName(); \
};
//===================
// package init macros
//===================
#define TSS_REGISTER_PKG_ERRORS( pkgName ) \
RegisterErrors##pkgName register##pkgName;
#endif //__ERRORTABLE_H

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