From e4a1a1666dc907563d1cf7de712477916fd869b7 Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Fri, 20 Sep 2019 05:58:34 +0000 Subject: [PATCH] Fix another annoying buildsys issue; add mini-setup script as a n aid to dev & testing --- mini-setup.sh | 72 ++++++++++++++++++++++++++++++++++++++++ src/core/fixups.h | 2 +- src/core/msystem.cpp | 2 +- src/core/platform.h | 2 +- src/mini-setup/twcfg.txt | 6 ++++ src/mini-setup/twpol.txt | 2 ++ 6 files changed, 83 insertions(+), 3 deletions(-) create mode 100755 mini-setup.sh create mode 100644 src/mini-setup/twcfg.txt create mode 100644 src/mini-setup/twpol.txt diff --git a/mini-setup.sh b/mini-setup.sh new file mode 100755 index 0000000..cc8b80c --- /dev/null +++ b/mini-setup.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +# Configures a minimal OST setup in the build directory, as a dev/test aid. +# This script isn't meant for use in production, and intentionally uses +# terrible hardcoded passphrases to try to discourage that. + +cp src/mini-setup/twcfg.txt bin/twcfg.txt +cp src/mini-setup/twpol.txt bin/twpol.txt +chdir bin + +if [ ! -f "l" ] || [ ! -f "s" ]; then + echo "***** Generating Keys *****" + if ./twadmin --generate-keys --site-keyfile s --local-keyfile l --site-passphrase s --local-passphrase l --verbose + then + echo "***** Keys Generated *****" + else + echo "***** Key Generation Failed *****" + exit 1 + fi +else + echo "***** Keys already generated, skipping this step *****" +fi + +if [ ! -f "tw.cfg" ]; then + echo "***** Creating Config File *****" + if ./twadmin --create-cfgfile --site-keyfile s --site-passphrase s --verbose --cfgfile ./tw.cfg ./twcfg.txt + then + echo "***** Config File Created *****" + else + echo "***** Config File Creation Failed *****" + exit 1 + fi +else + echo "***** Config file already exists, skipping this step *****" +fi + +if [ ! -f "test.pol" ]; then + echo "***** Creating Policy File *****" + if ./twadmin --create-polfile --site-passphrase s --verbose --cfgfile ./tw.cfg ./twpol.txt + then + echo "***** Policy File Created *****" + else + echo "***** Policy File Creation Failed *****" + exit 1 + fi +else + echo "***** Policy file already exists, skipping this step *****" +fi + +if [ ! -d "/tmp/tw-test" ]; then + mkdir /tmp/tw-test +fi + +if [ ! -f "test.twd" ]; then + echo "***** Initializing Database *****" + if ./tripwire --init --local-passphrase l --verbose --cfgfile ./tw.cfg + then + echo "***** Database Initialized *****" + else + echo "***** Database Initialization Failed *****" + exit 1 + fi +else + echo "***** Database already initialized, skipping this step *****" +fi + +touch /tmp/tw-test/hello.txt + +echo "***** Running a Check *****" +./tripwire --check --verbose --cfgfile ./tw.cfg + +echo "***** Setup Completed *****" diff --git a/src/core/fixups.h b/src/core/fixups.h index 317853c..606c596 100644 --- a/src/core/fixups.h +++ b/src/core/fixups.h @@ -51,7 +51,7 @@ #if defined(__VXWORKS__) || defined(__vxworks) #undef HAVE__EXIT #undef HAVE_CHOWN - #undef HAVE_EXEC + #undef HAVE_EXECVE #undef HAVE_FORK #undef HAVE_GETHOSTID #undef HAVE_GETUID diff --git a/src/core/msystem.cpp b/src/core/msystem.cpp index f03e9a2..800b76e 100644 --- a/src/core/msystem.cpp +++ b/src/core/msystem.cpp @@ -99,7 +99,7 @@ #define setgid(x) sleep(0) #endif -#if SUPPORTS_POSIX_FORK_EXEC +#if USES_MSYSTEM /* * signal type */ diff --git a/src/core/platform.h b/src/core/platform.h index ba691df..a95bd72 100644 --- a/src/core/platform.h +++ b/src/core/platform.h @@ -370,7 +370,7 @@ # define WCHAR_IS_32_BITS IS_UNIX # define WCHAR_REP_IS_UCS2 IS_WIN32 -# define SUPPORTS_POSIX_FORK_EXEC (HAVE_FORK && HAVE_EXEC) +# define SUPPORTS_POSIX_FORK_EXEC (HAVE_FORK && HAVE_EXECVE) // msystem+mpopen fail on Syllable, so use the libc equivalents until we figure out why. // TODO: Figure out why. # define USES_MPOPEN (SUPPORTS_POSIX_FORK_EXEC && !IS_SYLLABLE) diff --git a/src/mini-setup/twcfg.txt b/src/mini-setup/twcfg.txt new file mode 100644 index 0000000..1b70e64 --- /dev/null +++ b/src/mini-setup/twcfg.txt @@ -0,0 +1,6 @@ +SITEKEYFILE=s +LOCALKEYFILE=l +POLFILE=test.pol +DBFILE=test.twd +REPORTFILE=test.twr + diff --git a/src/mini-setup/twpol.txt b/src/mini-setup/twpol.txt new file mode 100644 index 0000000..e449520 --- /dev/null +++ b/src/mini-setup/twpol.txt @@ -0,0 +1,2 @@ +/tmp/tw-test -> $(IgnoreNone); +