Merge branch 'dev/next' of https://github.com/Tripwire/tripwire-open-source into dev/next

This commit is contained in:
Brian Cox 2017-08-25 19:02:30 -07:00
commit dbc48d0326
46 changed files with 338 additions and 537 deletions

View File

@ -14,5 +14,6 @@ uninstall-hook:
check: check:
rm -Rf $(top_srcdir)/src/test-harness/twtest rm -Rf $(top_srcdir)/src/test-harness/twtest
rm -Rf $(top_srcdir)/bin/TWTestData
cd $(top_srcdir)/src/test-harness && perl ./twtest.pl cd $(top_srcdir)/src/test-harness && perl ./twtest.pl
$(top_srcdir)/bin/twtest all cd $(top_srcdir)/bin && ./twtest all

View File

@ -809,8 +809,9 @@ uninstall-hook:
check: check:
rm -Rf $(top_srcdir)/src/test-harness/twtest rm -Rf $(top_srcdir)/src/test-harness/twtest
rm -Rf $(top_srcdir)/bin/TWTestData
cd $(top_srcdir)/src/test-harness && perl ./twtest.pl cd $(top_srcdir)/src/test-harness && perl ./twtest.pl
$(top_srcdir)/bin/twtest all cd $(top_srcdir)/bin && ./twtest all
# Tell versions [3.59,3.63) of GNU make to not export all variables. # 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. # Otherwise a system limit (for SysV at least) may be exceeded.

View File

@ -653,6 +653,9 @@ cEncoder::cEncoder( int e, int f )
cEncoder::~cEncoder() cEncoder::~cEncoder()
{ {
sack_type::iterator itr;
for( itr = m_encodings.begin(); itr != m_encodings.end(); ++itr)
delete *itr;
} }
bool cEncoder::RoundTrip() const bool cEncoder::RoundTrip() const

View File

@ -290,8 +290,6 @@ class iFSServices
virtual bool Rename( const TSTRING& strOldName, const TSTRING& strNewName, bool fOverWrite = true ) const = 0; virtual bool Rename( const TSTRING& strOldName, const TSTRING& strNewName, bool fOverWrite = true ) const = 0;
// rename a file // rename a file
virtual bool GetOwnerForFile( const TSTRING& tstrFilename, TSTRING& tstrUser ) const = 0;
virtual bool GetGroupForFile( const TSTRING& tstrFilename, TSTRING& tstrGroup ) const = 0;
virtual bool GetUserName( uid_t user_id, TSTRING& tstrUser ) const = 0; virtual bool GetUserName( uid_t user_id, TSTRING& tstrUser ) const = 0;
virtual bool GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const = 0; virtual bool GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const = 0;

View File

@ -316,6 +316,7 @@ cHashTable<KEY_TYPE, VAL_TYPE, COMPARE_OP, CONVERTER>::~cHashTable()
} }
} }
} }
delete [] mTable;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////

View File

@ -275,6 +275,7 @@ static uint8 padding[128] = { /* constants for padding */
} \ } \
} }
#if 0 //unused in OST
/* hash a string */ /* hash a string */
void haval_string (char *string, uint8 fingerprint[FPTLEN >> 3]) void haval_string (char *string, uint8 fingerprint[FPTLEN >> 3])
@ -330,6 +331,7 @@ void haval_stdin ()
putchar(fingerprint[i]); putchar(fingerprint[i]);
} }
} }
#endif
/* initialization */ /* initialization */
void haval_start (haval_state *state) void haval_start (haval_state *state)

View File

@ -117,10 +117,12 @@ typedef struct {
#define P_(s) s #define P_(s) s
//Old prototyping stuff... I will ignore it for now. //Old prototyping stuff... I will ignore it for now.
#if 0 //unused in OST
void haval_string P_((char *, uint8 *)); /* hash a string */ void haval_string P_((char *, uint8 *)); /* hash a string */
int haval_file P_((char *, uint8 *)); /* hash a file */ int haval_file P_((char *, uint8 *)); /* hash a file */
void haval_stdin P_((void)); /* filter -- hash input from stdin */ void haval_stdin P_((void)); /* filter -- hash input from stdin */
#endif
void haval_start P_((haval_state *)); /* initialization */ void haval_start P_((haval_state *)); /* initialization */
void haval_hash P_((haval_state* state, uint8* str, int str_len)); void haval_hash P_((haval_state* state, uint8* str, int str_len));
void haval_end P_((haval_state *, uint8 *)); /* finalization */ void haval_end P_((haval_state *, uint8 *)); /* finalization */

View File

@ -80,6 +80,7 @@
#define OS_MINT 0x0507 #define OS_MINT 0x0507
#define OS_AROS 0x0508 #define OS_AROS 0x0508
#define OS_RTEMS 0x0509 #define OS_RTEMS 0x0509
#define OS_RISCOS 0x050A
#define COMP_UNKNOWN 0 #define COMP_UNKNOWN 0
#define COMP_GCC 0x0001 #define COMP_GCC 0x0001
@ -214,9 +215,10 @@
#define OS OS_RTEMS #define OS OS_RTEMS
#define IS_RTEMS 1 #define IS_RTEMS 1
#else #elif defined(__riscos__)
// OK for OS not to resolve, it's being phased out. #define OS OS_RISCOS
// #error Unknown OS #define IS_RISCOS 1
#endif #endif
@ -300,7 +302,7 @@
#define SUPPORTS_ST_BLOCKS (!IS_DOS_DJGPP) #define SUPPORTS_ST_BLOCKS (!IS_DOS_DJGPP)
#define SUPPORTS_POSIX_SIGNALS (!IS_DOS_DJGPP) #define SUPPORTS_POSIX_SIGNALS (!IS_DOS_DJGPP)
#define SUPPORTS_NETWORKING (!IS_SORTIX && !IS_DOS_DJGPP) #define SUPPORTS_NETWORKING (!IS_SORTIX && !IS_DOS_DJGPP)
#define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS) #define SUPPORTS_SYSLOG (HAVE_SYSLOG_H && !IS_SKYOS && !IS_RISCOS)
#define NEEDS_SWAB_IMPL (IS_SYLLABLE || IS_ANDROID || IS_SORTIX) #define NEEDS_SWAB_IMPL (IS_SYLLABLE || IS_ANDROID || IS_SORTIX)
#define USES_MBLEN (!IS_ANDROID && !IS_AROS) #define USES_MBLEN (!IS_ANDROID && !IS_AROS)
#define USES_DEVICE_PATH (IS_AROS || IS_DOS_DJGPP) #define USES_DEVICE_PATH (IS_AROS || IS_DOS_DJGPP)

View File

@ -368,7 +368,7 @@ void cUnixFSServices::Stat( const TSTRING& strNameC, cFSStatArgs& stat) const
#ifdef S_IFDOOR #ifdef S_IFDOOR
else if(S_ISDOOR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_DOOR; else if(S_ISDOOR(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_DOOR;
#endif #endif
#ifdef S_IFPORT #ifdef S_ISPORT
else if(S_ISPORT(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_PORT; else if(S_ISPORT(statbuf.st_mode)) stat.mFileType = cFSStatArgs::TY_PORT;
#endif #endif
@ -497,43 +497,6 @@ void cUnixFSServices::SetResolveNames(bool resolve)
mResolveNames=resolve; mResolveNames=resolve;
} }
bool cUnixFSServices::GetOwnerForFile( const TSTRING& tstrFilename, TSTRING& tstrUser ) const
{
bool fSuccess = true;
struct stat statbuf;
int ret = lstat(tstrFilename.c_str(), &statbuf);
if(ret < 0)
{
fSuccess = false;
}
else
{
fSuccess = GetUserName(statbuf.st_uid, tstrUser);
}
return( fSuccess );
}
bool cUnixFSServices::GetGroupForFile( const TSTRING& tstrFilename, TSTRING& tstrGroup ) const
{
bool fSuccess = true;
struct stat statbuf;
int ret = lstat(tstrFilename.c_str(), &statbuf);
if(ret < 0)
{
fSuccess = false;
}
else
{
fSuccess = GetGroupName(statbuf.st_gid, tstrGroup);
}
return( fSuccess );
}
bool cUnixFSServices::GetUserName( uid_t user_id, TSTRING& tstrUser ) const bool cUnixFSServices::GetUserName( uid_t user_id, TSTRING& tstrUser ) const
{ {
@ -636,7 +599,7 @@ void cUnixFSServices::ConvertModeToString( uint64 perm, TSTRING& tstrPerm ) cons
szPerm[0] = _T('D'); szPerm[0] = _T('D');
break; break;
#endif #endif
#ifdef S_IFPORT #ifdef S_ISPORT
case S_IFPORT: case S_IFPORT:
szPerm[0] = _T('P'); szPerm[0] = _T('P');
break; break;

View File

@ -132,8 +132,6 @@ class cUnixFSServices : public iFSServices
virtual bool Rename( const TSTRING& strOldName, const TSTRING& strNewName, bool fOverWrite = true ) const; virtual bool Rename( const TSTRING& strOldName, const TSTRING& strNewName, bool fOverWrite = true ) const;
// rename a file // rename a file
virtual bool GetOwnerForFile( const TSTRING& tstrFilename, TSTRING& tstrUser ) const;
virtual bool GetGroupForFile( const TSTRING& tstrFilename, TSTRING& tstrGroup ) const;
virtual bool GetUserName( uid_t user_id, TSTRING& tstrUser ) const; virtual bool GetUserName( uid_t user_id, TSTRING& tstrUser ) const;
virtual bool GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const; virtual bool GetGroupName( gid_t group_id, TSTRING& tstrGroup ) const;

View File

@ -83,6 +83,11 @@ bool cFSParserUtil::MapStringToProperty( const TSTRING& str, int& propIndex ) co
default: fMappedChar = false; break; default: fMappedChar = false; break;
} }
} }
else
fMappedChar = false;
/* Leaving this here in case we ever want to implement long property names
else else
{ {
if( 0 == str.compare( TSS_GetString( cFS, fs::STR_PARSER_PROP_MODE ) ) ) if( 0 == str.compare( TSS_GetString( cFS, fs::STR_PARSER_PROP_MODE ) ) )
@ -122,6 +127,7 @@ bool cFSParserUtil::MapStringToProperty( const TSTRING& str, int& propIndex ) co
else else
fMappedChar = false; fMappedChar = false;
} }
*/
return( fMappedChar ); return( fMappedChar );
} }

View File

@ -85,20 +85,32 @@ static bool NeedsStat(const cFCOPropVector& v)
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
static bool GetSymLinkStr(const TSTRING& strName, cArchive& arch) bool cFSPropCalc::GetSymLinkStr(const TSTRING& strName, cArchive& arch, size_t size)
{ {
char buf[1024]; // TODO: is this big enough? std::vector<char> data(size+1);
char* buf = &data[0];
#if defined(O_PATH) #if defined(O_PATH)
int fd = open(strName.c_str(), (O_PATH | O_NOFOLLOW | O_NOATIME)); int fd = open(strName.c_str(), (O_PATH | O_NOFOLLOW | O_NOATIME));
int rtn = readlinkat(fd, 0, buf, 1024); int rtn = readlinkat(fd, 0, buf, size);
close(fd); close(fd);
#else #else
int rtn = readlink( strName.c_str(), buf, 1024 ); int rtn = readlink( strName.c_str(), buf, size );
#endif #endif
if(rtn == -1) if(rtn == -1)
return false; return false;
//Sadly if buf isn't big enough readlink 'succeeds' by truncating the string, so the only
// clue your buffer might be too small is if you maxed it out. So we try again, within reason.
if((size_t)rtn == size)
{
if(size < 128*TW_PATH_SIZE)
return GetSymLinkStr(strName, arch, size*2);
return false;
}
// the return value is the number of characters written. // the return value is the number of characters written.
arch.WriteBlob(buf, rtn); arch.WriteBlob(buf, rtn);

View File

@ -53,6 +53,12 @@
#include "core/archive.h" #include "core/archive.h"
#include "fspropset.h" #include "fspropset.h"
#ifdef PATH_MAX
# define TW_PATH_SIZE PATH_MAX
#else
# define TW_PATH_SIZE 1024
#endif
TSS_FILE_EXCEPTION( eFSPropCalc, eFileError ) TSS_FILE_EXCEPTION( eFSPropCalc, eFileError )
//TSS_EXCEPTION( eFSPropCalcResetAccessTime, eFSPropCalc ) // this was never used //TSS_EXCEPTION( eFSPropCalcResetAccessTime, eFSPropCalc ) // this was never used
@ -80,6 +86,8 @@ public:
virtual int GetCalcFlags() const; virtual int GetCalcFlags() const;
virtual void SetCalcFlags( int i ); virtual void SetCalcFlags( int i );
static bool GetSymLinkStr(const TSTRING& strName, cArchive& arch, size_t size = TW_PATH_SIZE);
private: private:
cFSPropCalc( const cFSPropCalc& ); cFSPropCalc( const cFSPropCalc& );
void operator =( const cFSPropCalc& ); void operator =( const cFSPropCalc& );

View File

@ -74,7 +74,8 @@ TSS_BeginStringtable( cFS )
TSS_StringEntry( fs::STR_PROP_HAVAL, _T("HAVAL") ), TSS_StringEntry( fs::STR_PROP_HAVAL, _T("HAVAL") ),
TSS_StringEntry( fs::STR_PROP_ACL, _T("ACL Placeholder -- Not Implemented") ), TSS_StringEntry( fs::STR_PROP_ACL, _T("ACL Placeholder -- Not Implemented") ),
// TODO: get actual strings /* Leaving these here in case we ever implement long property names
TSS_StringEntry( fs::STR_PARSER_PROP_DEV, _T("unimplemented") ), TSS_StringEntry( fs::STR_PARSER_PROP_DEV, _T("unimplemented") ),
TSS_StringEntry( fs::STR_PARSER_PROP_RDEV, _T("unimplemented") ), TSS_StringEntry( fs::STR_PARSER_PROP_RDEV, _T("unimplemented") ),
TSS_StringEntry( fs::STR_PARSER_PROP_INODE, _T("unimplemented") ), TSS_StringEntry( fs::STR_PARSER_PROP_INODE, _T("unimplemented") ),
@ -94,7 +95,7 @@ TSS_BeginStringtable( cFS )
TSS_StringEntry( fs::STR_PARSER_PROP_MD5, _T("unimplemented") ), TSS_StringEntry( fs::STR_PARSER_PROP_MD5, _T("unimplemented") ),
TSS_StringEntry( fs::STR_PARSER_PROP_SHA, _T("unimplemented") ), TSS_StringEntry( fs::STR_PARSER_PROP_SHA, _T("unimplemented") ),
TSS_StringEntry( fs::STR_PARSER_PROP_HAVAL, _T("unimplemented") ), TSS_StringEntry( fs::STR_PARSER_PROP_HAVAL, _T("unimplemented") ),
*/
TSS_StringEntry( fs::STR_PARSER_READONLY, _T("ReadOnly")), TSS_StringEntry( fs::STR_PARSER_READONLY, _T("ReadOnly")),
TSS_StringEntry( fs::STR_PARSER_DYNAMIC, _T("Dynamic")), TSS_StringEntry( fs::STR_PARSER_DYNAMIC, _T("Dynamic")),
TSS_StringEntry( fs::STR_PARSER_GROWING, _T("Growing")), TSS_StringEntry( fs::STR_PARSER_GROWING, _T("Growing")),

View File

@ -78,6 +78,7 @@ TSS_BeginStringIds( fs )
STR_PROP_HAVAL, STR_PROP_HAVAL,
STR_PROP_ACL, STR_PROP_ACL,
/* Leaving these here in case we ever implement long property names
STR_PARSER_PROP_DEV, STR_PARSER_PROP_DEV,
STR_PARSER_PROP_RDEV, STR_PARSER_PROP_RDEV,
STR_PARSER_PROP_INODE, STR_PARSER_PROP_INODE,
@ -97,7 +98,7 @@ TSS_BeginStringIds( fs )
STR_PARSER_PROP_MD5, STR_PARSER_PROP_MD5,
STR_PARSER_PROP_SHA, STR_PARSER_PROP_SHA,
STR_PARSER_PROP_HAVAL, STR_PARSER_PROP_HAVAL,
*/
STR_PARSER_READONLY, STR_PARSER_READONLY,
STR_PARSER_DYNAMIC, STR_PARSER_DYNAMIC,
STR_PARSER_GROWING, STR_PARSER_GROWING,

View File

@ -168,7 +168,11 @@ sub RunBasicTest
# do the database update... # do the database update...
# #
twtools::UpdateDatabase(); if (0 != twtools::UpdateDatabase())
{
twtools::logStatus("FAILED -- db update did not succeed\n");
return 0;
}
# do another IC and make sure there are no violations # do another IC and make sure there are no violations
# #
@ -195,10 +199,6 @@ sub RunSecureModeTest
twtools::logStatus("*** Beginning dbupdate.secure-mode test\n"); twtools::logStatus("*** Beginning dbupdate.secure-mode test\n");
printf("%-30s", "-- dbupdate.secure-mode test"); printf("%-30s", "-- dbupdate.secure-mode test");
++$twtools::twskippedtests;
print "SKIPPED - this test needs further investigation\n";
return 1;
PrepareForTest(); PrepareForTest();
# make a violation and generate a report # make a violation and generate a report
@ -226,10 +226,20 @@ sub RunSecureModeTest
# #
twtools::UpdateDatabase( { report => $report1 } ); twtools::UpdateDatabase( { report => $report1 } );
# Try to update the database with report 1 again ... this should fail
# in secure-mode == high because the db can't accept same changes again.
#
if( 0 == twtools::UpdateDatabase(
{ report => $report1, secure-mode => "high" } ) )
{
twtools::logStatus("FAILED ... Secure-mode high didn't catch a bad update\n");
return 0;
}
# Try to update the database with report 2 ... this should fail # Try to update the database with report 2 ... this should fail
# in secure-mode == high because the "old" values don't match. # in secure-mode == high because the "old" values don't match.
# #
if( twtools::UpdateDatabase( if( 0 == twtools::UpdateDatabase(
{ report => $report2, secure-mode => "high" } ) ) { report => $report2, secure-mode => "high" } ) )
{ {
twtools::logStatus("FAILED ... Secure-mode high didn't catch a bad update\n"); twtools::logStatus("FAILED ... Secure-mode high didn't catch a bad update\n");
@ -239,7 +249,7 @@ sub RunSecureModeTest
# do a high severity update with report3 -- this should # do a high severity update with report3 -- this should
# succeed # succeed
# #
if( ! twtools::UpdateDatabase( if( 0 != twtools::UpdateDatabase(
{ report => $report3, secure-mode => "high" } ) ) { report => $report3, secure-mode => "high" } ) )
{ {
twtools::logStatus("FAILED ... Update with report 3 failed\n"); twtools::logStatus("FAILED ... Update with report 3 failed\n");
@ -250,14 +260,14 @@ sub RunSecureModeTest
# doesn't exist in the database at all. This should # doesn't exist in the database at all. This should
# succeed in low but fail in high. # succeed in low but fail in high.
# #
if( twtools::UpdateDatabase( if( 0 == twtools::UpdateDatabase(
{ report => $report2, secure-mode => "high" } ) ) { report => $report2, secure-mode => "high" } ) )
{ {
twtools::logStatus("FAILED ... Update with report 2 after 3 succeeded in high mode\n"); twtools::logStatus("FAILED ... Update with report 2 after 3 succeeded in high mode\n");
return 0; return 0;
} }
if( ! twtools::UpdateDatabase( if( 0 != twtools::UpdateDatabase(
{ report => $report2, secure-mode => "low" } ) ) { report => $report2, secure-mode => "low" } ) )
{ {
twtools::logStatus("FAILED ... Update with report 2 after 3 failed in low mode\n"); twtools::logStatus("FAILED ... Update with report 2 after 3 failed in low mode\n");

View File

@ -273,9 +273,13 @@ sub GeneratePolicyFile {
print "generating policy file...\n" if $verbose; print "generating policy file...\n" if $verbose;
logStatus(`$twrootdir/bin/twadmin -m P -c $twrootdir/$twcfgloc -Q $twsitepass -p $twrootdir/$twpolfileloc $twrootdir/$twpolicyloc 2>&1`); my (@out) = `$twrootdir/bin/twadmin -m P -c $twrootdir/$twcfgloc -Q $twsitepass -p $twrootdir/$twpolfileloc $twrootdir/$twpolicyloc 2>&1`;
return ($? == 0); my ($result) = ${^CHILD_ERROR_NATIVE};
logStatus(@out);
return $result;
} }
@ -291,9 +295,13 @@ sub CreatePolicy {
print "generating policy file...\n" if $verbose; print "generating policy file...\n" if $verbose;
logStatus(`$twrootdir/bin/twadmin -m P -c $twrootdir/$twcfgloc -Q $twsitepass -p $twrootdir/$twpolfileloc $params{policy-text} 2>&1`); my (@out) = `$twrootdir/bin/twadmin -m P -c $twrootdir/$twcfgloc -Q $twsitepass -p $twrootdir/$twpolfileloc $params{policy-text} 2>&1`;
return ($? == 0); my ($result) = ${^CHILD_ERROR_NATIVE};
logStatus(@out);
return $result;
} }
@ -305,9 +313,13 @@ sub InitializeDatabase {
my ($twmsg) = @_; my ($twmsg) = @_;
print "initializing database for '$twmsg' test...\n" if $verbose; print "initializing database for '$twmsg' test...\n" if $verbose;
logStatus(`$twrootdir/bin/tripwire -m i -P $twsitepass -p $twrootdir/$twpolfileloc -c $twrootdir/$twcfgloc 2>&1`); my (@out) = `$twrootdir/bin/tripwire -m i -P $twsitepass -p $twrootdir/$twpolfileloc -c $twrootdir/$twcfgloc 2>&1`;
return ($? == 0); my ($result) = ${^CHILD_ERROR_NATIVE};
logStatus(@out);
return $result;
} }
@ -317,13 +329,17 @@ sub InitializeDatabase {
sub UpdateDatabase { sub UpdateDatabase {
my (%params) = %{$_[0]}; my (%params) = %{$_[0]};
$params{'report'} = $reportloc if( ! defined($params{'report'}) ); $params{report} = $reportloc if( ! defined($params{report}) );
$params{'secure-mode'} = "low" if( ! defined($params{'secure-mode'}) ); $params{secure-mode} = "low" if( ! defined($params{secure-mode}) );
print "updating database for '$twmsg' test...\n" if $verbose; print "updating database for '$twmsg' test...\n" if $verbose;
logStatus(`$twrootdir/bin/tripwire -m u -a -P $twsitepass -Z $params{'secure-mode'} -p $twrootdir/$twpolfileloc -c $twrootdir/$twcfgloc -r $params{'report'} 2>&1`); my (@out) = `$twrootdir/bin/tripwire -m u -a -P $twsitepass -Z $params{secure-mode} -p $twrootdir/$twpolfileloc -c $twrootdir/$twcfgloc -r $params{report} 2>&1`;
return ($? == 0); my ($result) = ${^CHILD_ERROR_NATIVE};
logStatus(@out);
return $result;
} }
###################################################################### ######################################################################
@ -332,10 +348,10 @@ sub UpdateDatabase {
sub UpdatePolicy { sub UpdatePolicy {
my (%params) = %{$_[0]}; my (%params) = %{$_[0]};
$params{'secure-mode'} = "low" if( ! defined($params{'secure-mode'}) ); $params{secure-mode} = "low" if( ! defined($params{secure-mode}) );
print "updating policy for '$twmsg' test...\n" if $verbose; print "updating policy for '$twmsg' test...\n" if $verbose;
logStatus(`$twrootdir/bin/tripwire -m p -P $twsitepass -Q $twlocalpass -Z $params{'secure-mode'} -p $twrootdir/$twpolfileloc -c $twrootdir/$twcfgloc $twrootdir/$twpolicyloc 2>&1`); logStatus(`$twrootdir/bin/tripwire -m p -P $twsitepass -Q $twlocalpass -Z $params{secure-mode} -p $twrootdir/$twpolfileloc -c $twrootdir/$twcfgloc $twrootdir/$twpolicyloc 2>&1`);
return ($? == 0); return ($? == 0);
} }

View File

@ -332,61 +332,6 @@ bool cTWUtil::IsObjectEncrypted( const TCHAR* objFileName, const cFileHeaderID&
return( fEncrypted ); return( fEncrypted );
} }
bool cTWUtil::IsObjectEncrypted( cArchive &arch, const cFileHeaderID& fhid, const TSTRING& errorMsg )
{
bool fEncrypted = false;
cDebug d("IsObjectEncrypted");
d.TraceDebug(_T("Reading from archive\n"));
try
{
cFileHeader fileHeader;
cSerializerImpl fhSer(arch, cSerializerImpl::S_READ, TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME).c_str());
fileHeader.Read(&fhSer);
// check for a mismatched header
if (fileHeader.GetID() != fhid)
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME).c_str(), eSerializer::TY_FILE));
// switch on the type of encoding...
if(fileHeader.GetEncoding() == cFileHeader::ASYM_ENCRYPTION)
{
fEncrypted = true;
}
else if(fileHeader.GetEncoding() == cFileHeader::COMPRESSED)
{
fEncrypted = false;
}
else
// unknown encoding...
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME).c_str(), eSerializer::TY_FILE));
}
catch(eArchive& e)
{
// Note: Output to TCERR is O.K. here, it is documented that this is what this function does
TSTRING msg = e.GetMsg();
if( ! msg.empty() )
msg += _T("\n");
msg += errorMsg;
cTWUtil::PrintErrorMsg(ePoly(e.GetID(), msg, e.GetFlags() ));
ThrowAndAssert(ePoly());
}
catch(eSerializer& e)
{
// Note: Output to TCERR is O.K. here, it is documented that this is what this function does
TSTRING msg = e.GetMsg();
if( ! msg.empty() )
msg += _T("\n");
msg += errorMsg;
cTWUtil::PrintErrorMsg(ePoly(e.GetID(), msg, e.GetFlags() ));
ThrowAndAssert(ePoly());
}
return( fEncrypted );
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// WriteDatabase // WriteDatabase
@ -452,20 +397,6 @@ void cTWUtil::WriteReport(const TCHAR* filename, const cFCOReportHeader& reportH
} }
void cTWUtil::WriteReport(cArchive &archive, const cFCOReportHeader& reportHeader, const cFCOReport& r, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey)
{
cFileHeader fileHeader;
fileHeader.SetID(cFCOReport::GetFileHeaderID());
TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME);
WriteObjectToArchive(archive, filename.c_str(), &reportHeader, r, fileHeader, bEncrypt, pPrivateKey);
iUserNotify::GetInstance()->Notify( iUserNotify::V_NORMAL, _T("%s%s\n"),
TSS_GetString( cTW, tw::STR_WRITE_REPORT_FILE).c_str(),
cDisplayEncoder::EncodeInline( filename ).c_str() );
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// ReadReport // ReadReport
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
@ -478,16 +409,6 @@ void cTWUtil::ReadReport(const TCHAR* reportFileName, cFCOReportHeader& reportHe
ReadObject(reportFileName, &reportHeader, r, cFCOReport::GetFileHeaderID(), pPublicKey, bEncrypted); ReadObject(reportFileName, &reportHeader, r, cFCOReport::GetFileHeaderID(), pPublicKey, bEncrypted);
} }
void cTWUtil::ReadReport(cArchive &archive, cFCOReportHeader& reportHeader, cFCOReport& r, const cElGamalSigPublicKey* pPublicKey, bool silent, bool& bEncrypted)
{
TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME);
iUserNotify::GetInstance()->Notify( iUserNotify::V_VERBOSE, _T("%s%s\n"),
TSS_GetString( cTW, tw::STR_OPEN_REPORT_FILE).c_str(),
cDisplayEncoder::EncodeInline( filename ).c_str());
ReadObjectFromArchive(archive, filename.c_str(), &reportHeader, r, cFCOReport::GetFileHeaderID(), pPublicKey, bEncrypted);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// UpdatePolicyFile // UpdatePolicyFile
@ -598,38 +519,6 @@ void cTWUtil::WriteConfigText(const TCHAR* filename, const TSTRING configText, b
cDisplayEncoder::EncodeInline( filename ).c_str() ); cDisplayEncoder::EncodeInline( filename ).c_str() );
} }
void cTWUtil::WriteConfigText(cArchive &archive, const TSTRING configText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey)
{
cSerializableNString nstring;
nstring.mString = CONFIG_FILE_MAGIC_8BYTE;
TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME);
std::string ns;
cStringUtil::Convert( ns, configText );
nstring.mString += ns;
cFileHeader fileHeader;
fileHeader.SetID(cConfigFile::GetFileHeaderID());
fileHeader.SetVersion(CURRENT_FIXED_VERSION);
if (bEncrypt)
{
ASSERT(pPrivateKey != 0);
cElGamalSigPublicKey publicKey(*pPrivateKey);
fileHeader.GetBaggage().MapArchive(0, publicKey.GetWriteLen());
publicKey.Write(fileHeader.GetBaggage().GetMap());
}
WriteObjectToArchive(archive, filename.c_str(), NULL, nstring, fileHeader, bEncrypt, pPrivateKey);
iUserNotify::GetInstance()->Notify( iUserNotify::V_NORMAL, _T("%s%s\n"),
TSS_GetString( cTW, tw::STR_WRITE_CONFIG_FILE).c_str(),
cDisplayEncoder::EncodeInline( filename ).c_str());
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// ReadConfigText // ReadConfigText
@ -742,111 +631,6 @@ void cTWUtil::ReadConfigText(const TCHAR* filename, TSTRING& configText, cArchiv
} }
void cTWUtil::ReadConfigText(cArchive &arch, TSTRING& configText, cArchive* pBaggage)
{
// TODO -- neat up this function; try to use LoadObject() above...
cSerializableNString nstring;
TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME);
// This was coppied from ReadObject(). We need to use the baggage of the
// file header to obtain the public key, thus the special casing.
cDebug d("ReadConfigText");
d.TraceDebug(_T("Reading %s from file %s\n"), nstring.GetType().AsString(), filename.c_str());
iUserNotify::GetInstance()->Notify( iUserNotify::V_VERBOSE, _T("%s%s\n"),
TSS_GetString( cTW, tw::STR_OPEN_CONFIG_FILE).c_str(),
cDisplayEncoder::EncodeInline( filename ).c_str());
cFileHeader fileHeader;
try
{
cSerializerImpl fhSer(arch, cSerializerImpl::S_READ);
fileHeader.Read(&fhSer);
}
catch (eError&)
{
throw eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE);
}
#if 0 // XXX: This is broken, how can you convert a class to an int??? -PH
d.TraceDebug("Found a file header of type %d.\n", fileHeader.GetEncoding());
#endif
// check for a mismatched header
if (fileHeader.GetID() != cConfigFile::GetFileHeaderID())
throw eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE);
// check the version
if (fileHeader.GetVersion() != CURRENT_FIXED_VERSION)
throw eSerializerVersionMismatch(_T(""), filename.c_str(), eSerializer::TY_FILE);
// switch on the type of encoding...
if(fileHeader.GetEncoding() == cFileHeader::ASYM_ENCRYPTION)
{
d.TraceDebug("Config file is compressed, public key len %d.\n", fileHeader.GetBaggage().Length());
// tell the user the db is encrypted
iUserNotify::GetInstance()->Notify( iUserNotify::V_VERBOSE, TSS_GetString(cTW, tw::STR_FILE_ENCRYPTED).c_str());
iUserNotify::GetInstance()->Notify( iUserNotify::V_VERBOSE, TSS_GetString(cTW, tw::STR_NEWLINE).c_str());
ASSERT(fileHeader.GetBaggage().Length() > 0);
if (fileHeader.GetBaggage().Length() <= 0)
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE));
fileHeader.GetBaggage().MapArchive(0, fileHeader.GetBaggage().Length());
cElGamalSigPublicKey publicKey(fileHeader.GetBaggage().GetMap());
cElGamalSigArchive cryptoArchive;
cryptoArchive.SetRead(&arch, &publicKey);
cSerializerImpl ser(cryptoArchive, cSerializerImpl::S_READ);
ser.Init();
ser.ReadObject(&nstring);
ser.Finit();
// copy the baggage into the archive, if it was passed in
// Note: We rely in VerifySiteKey that we only fill out pBaggage if
// the config file is encrypted.
//
if( pBaggage )
{
fileHeader.GetBaggage().Seek( 0, cBidirArchive::BEGINNING );
pBaggage->Copy( &fileHeader.GetBaggage(), fileHeader.GetBaggage().Length() );
}
}
else if(fileHeader.GetEncoding() == cFileHeader::COMPRESSED)
{
d.TraceDebug("Config file is not compressed.\n");
//not encrypted db...
cNullCryptoArchive cryptoArchive;
cryptoArchive.Start(&arch);
cSerializerImpl ser(cryptoArchive, cSerializerImpl::S_READ);
ser.Init();
ser.ReadObject(&nstring);
ser.Finit();
}
else
// unknown encoding...
throw eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE);
// check 8 byte header
if (nstring.mString.compare(0, 8*sizeof(byte), CONFIG_FILE_MAGIC_8BYTE) != 0)
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE));
// remove 8 byte header
nstring.mString.assign(nstring.mString.substr(8));
cStringUtil::Convert( configText, nstring.mString );
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Given a filename and the text of a policy file, write an encrypted version // Given a filename and the text of a policy file, write an encrypted version
// of the policy file text to disk. // of the policy file text to disk.
@ -871,26 +655,6 @@ void cTWUtil::WritePolicyText(const TCHAR* filename, const std::string& polText,
cDisplayEncoder::EncodeInline( filename ).c_str() ); cDisplayEncoder::EncodeInline( filename ).c_str() );
} }
void cTWUtil::WritePolicyText(cArchive &archive, const std::string& polText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey)
{
cSerializableNString nstring;
TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME);
// add a 8 byte header we can use to verify decryption
nstring.mString = POLICY_FILE_MAGIC_8BYTE;
nstring.mString += polText;
cFileHeader fileHeader;
fileHeader.SetID(cPolicyFile::GetFileHeaderID());
WriteObjectToArchive(archive, filename.c_str(), NULL, nstring, fileHeader, bEncrypt, pPrivateKey);
iUserNotify::GetInstance()->Notify( iUserNotify::V_NORMAL, _T("%s%s\n"),
TSS_GetString( cTW, tw::STR_WRITE_POLICY_FILE).c_str(),
cDisplayEncoder::EncodeInline( filename ).c_str());
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// ReadPolicyText // ReadPolicyText
@ -917,24 +681,6 @@ void cTWUtil::ReadPolicyText(const TCHAR* filename, std::string& polText, const
polText = nstring.mString; polText = nstring.mString;
} }
void cTWUtil::ReadPolicyText(cArchive &archive, std::string& polText, const cElGamalSigPublicKey* pPublicKey)
{
cSerializableNString nstring;
TSTRING filename = TSS_GetString( cTW, tw::STR_MEMORY_MAPPED_FILENAME);
bool bEncrypted;
ReadObjectFromArchive(archive, filename.c_str(), NULL, nstring, cPolicyFile::GetFileHeaderID(), pPublicKey, bEncrypted);
// check 8 byte header
if (nstring.mString.compare(0, 8*sizeof(byte), POLICY_FILE_MAGIC_8BYTE) != 0)
ThrowAndAssert(eSerializerInputStreamFmt(_T(""), filename.c_str(), eSerializer::TY_FILE));
// remove 8 byte header
nstring.mString.assign(nstring.mString.substr(8));
polText = nstring.mString;
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// OpenKeyFile // OpenKeyFile

View File

@ -106,16 +106,16 @@ public:
// if an error occurs, this will print the error message to stderr and throw eError. // if an error occurs, this will print the error message to stderr and throw eError.
static void WriteReport (const TCHAR* filename, const cFCOReportHeader& reportHeader, const cFCOReport& r, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); // throw eError static void WriteReport (const TCHAR* filename, const cFCOReportHeader& reportHeader, const cFCOReport& r, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); // throw eError
static void WriteReport (cArchive &archive, const cFCOReportHeader& reportHeader, const cFCOReport& r, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); // throw eError
static void ReadReport (const TCHAR* reportFileName, cFCOReportHeader& reportHeader, cFCOReport& r, const cElGamalSigPublicKey* pPublicKey, bool silent, bool& bEncrypted); // throw eError static void ReadReport (const TCHAR* reportFileName, cFCOReportHeader& reportHeader, cFCOReport& r, const cElGamalSigPublicKey* pPublicKey, bool silent, bool& bEncrypted); // throw eError
static void ReadReport (cArchive &archive, cFCOReportHeader& reportHeader, cFCOReport& r, const cElGamalSigPublicKey* pPublicKey, bool silent, bool& bEncrypted); // throw eError
// same as Read/WriteDatabase above, except it operates on reports // same as Read/WriteDatabase above, except it operates on reports
// if an error occurs, this will print the error message to stderr and throw eError. // if an error occurs, this will print the error message to stderr and throw eError.
static void WriteConfigText(const TCHAR* filename, const TSTRING configText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); // throw (eArchive()) static void WriteConfigText(const TCHAR* filename, const TSTRING configText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); // throw (eArchive())
static void WriteConfigText(cArchive &archive, const TSTRING configText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); // throw (eArchive())
static void ReadConfigText(const TCHAR* filename, TSTRING& configText, cArchive* pBaggage = 0); static void ReadConfigText(const TCHAR* filename, TSTRING& configText, cArchive* pBaggage = 0);
static void ReadConfigText(cArchive &archive, TSTRING& configText, cArchive* pBaggage = 0);
// read and write config file text to and from disk. // read and write config file text to and from disk.
// if pBaggage is non-NULL, the contents of the baggage( ie -- the public key ) is copied to the archive. // if pBaggage is non-NULL, the contents of the baggage( ie -- the public key ) is copied to the archive.
// eArchive is thrown if filename can not be opened // eArchive is thrown if filename can not be opened
@ -123,9 +123,9 @@ public:
// eConfigFile is thrown if config file does not parse correctly during reading // eConfigFile is thrown if config file does not parse correctly during reading
static void WritePolicyText(const TCHAR* filename, const std::string& policyText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey); static void WritePolicyText(const TCHAR* filename, const std::string& policyText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey);
static void WritePolicyText(cArchive &archive, const std::string& policyText, bool bEncrypt, const cElGamalSigPrivateKey* pPrivateKey);
static void ReadPolicyText(const TCHAR* filename, std::string& policyText, const cElGamalSigPublicKey* pPublicKey); static void ReadPolicyText(const TCHAR* filename, std::string& policyText, const cElGamalSigPublicKey* pPublicKey);
static void ReadPolicyText(cArchive &archive, std::string& policyText, const cElGamalSigPublicKey* pPublicKey);
// read and write policy file to and from disk // read and write policy file to and from disk
// eError() will be thrown on error // eError() will be thrown on error

View File

@ -614,10 +614,10 @@ yy_scan::~yy_scan()
{ {
if (mustfree) { if (mustfree) {
mustfree = 0; mustfree = 0;
delete(yytext); delete [] yytext;
delete(state); delete [] state;
#ifdef YY_PRESERVE #ifdef YY_PRESERVE
delete(save); delete [] save;
#endif #endif
} }
} }

View File

@ -419,12 +419,12 @@ yy_parse::yy_parse(int sz)
yy_parse::~yy_parse() yy_parse::~yy_parse()
{ {
if (mustfree) { if (mustfree) {
delete stateStack; delete [] stateStack;
delete valueStack; delete [] valueStack;
} }
stateStack = (short *) 0; stateStack = (short *) 0;
#if YYDEBUG #if YYDEBUG
delete typeStack; delete [] typeStack;
#endif #endif
} }

View File

@ -104,8 +104,8 @@ void TestArchive()
// cLockedTemporaryFileArchive // cLockedTemporaryFileArchive
TSTRING lockedFileName = TEMP_DIR; TSTRING lockedFileName = TwTestPath("inaccessable_file.bin");
lockedFileName += _T("/inaccessable_file.bin"); // lockedFileName += _T("/inaccessable_file.bin");
cLockedTemporaryFileArchive lockedArch; cLockedTemporaryFileArchive lockedArch;
@ -130,8 +130,8 @@ void TestArchive()
lockedArch.Close(); lockedArch.Close();
// cFileArchive // cFileArchive
TSTRING fileName = TEMP_DIR; TSTRING fileName = TwTestPath("archive_test.bin");
fileName += _T("/archive_test.bin"); //fileName += _T("/archive_test.bin");
cFileArchive filearch; cFileArchive filearch;
filearch.OpenReadWrite(fileName.c_str()); filearch.OpenReadWrite(fileName.c_str());

View File

@ -41,11 +41,11 @@ void TestBlockFile()
{ {
cDebug d( "TestBlockFile" ); cDebug d( "TestBlockFile" );
static const TCHAR fileName[] = _T("test.bf"); std::string fileName = TwTestPath("test.bf");
// truncate the file I am going to use... // truncate the file I am going to use...
// //
cFileArchive a; cFileArchive a;
a.OpenReadWrite( fileName ); a.OpenReadWrite( fileName.c_str() );
a.Close(); a.Close();
// //
// open up the block file... // open up the block file...

View File

@ -41,7 +41,7 @@ void TestBlockRecordArray()
{ {
cDebug d( "TestBlockRecordArray" ); cDebug d( "TestBlockRecordArray" );
static const TCHAR fileName[] = _T("test.bf"); std::string fileName = TwTestPath("test2.bf");
cBlockFile bf; cBlockFile bf;
bf.Open( fileName, 2, true ); // opened up with two pages bf.Open( fileName, 2, true ); // opened up with two pages

View File

@ -128,9 +128,6 @@ void TestConfigFile2(void)
//Define some test values for <name, value> pairs to be //Define some test values for <name, value> pairs to be
//stored in a test config. module. I'm going to use the //stored in a test config. module. I'm going to use the
//values specified in the install doc. -DA //values specified in the install doc. -DA
TSTRING currpath;
pFSServices->GetCurrentDir(currpath);
const TSTRING testTWROOT = currpath;
//TODO maybe also test read failure when mandatory config values aren't set //TODO maybe also test read failure when mandatory config values aren't set
@ -145,7 +142,7 @@ void TestConfigFile2(void)
write_cfgmod.Insert( _T("LOCALKEYFILE"), "local.key"); write_cfgmod.Insert( _T("LOCALKEYFILE"), "local.key");
//Filename for writing/reading some value pairs: //Filename for writing/reading some value pairs:
const TSTRING testfile = testTWROOT + _T("/tripwire.cfg"); const TSTRING testfile = TwTestPath("tripwire.cfg");
//Store these values on disk. //Store these values on disk.
TSTRING configText; TSTRING configText;

View File

@ -70,7 +70,7 @@ void TestCryptoArchive()
d.TraceDetail("Encrypting using symmetric key\n"); d.TraceDetail("Encrypting using symmetric key\n");
cFileArchive outFile; cFileArchive outFile;
outFile.OpenReadWrite(TEMP_DIR _T("/crypted.bin")); outFile.OpenReadWrite(TwTestPath("crypted.bin"));
idea.SetKey(iCipher::ENCRYPT, ideaKey); idea.SetKey(iCipher::ENCRYPT, ideaKey);
cCryptoArchive outCrypt; cCryptoArchive outCrypt;
@ -90,7 +90,7 @@ void TestCryptoArchive()
d.TraceDetail("Decrypting using symmetric key\n"); d.TraceDetail("Decrypting using symmetric key\n");
cFileArchive inFile; cFileArchive inFile;
inFile.OpenRead(TEMP_DIR _T("/crypted.bin")); inFile.OpenRead(TwTestPath("crypted.bin"));
idea.SetKey(iCipher::DECRYPT, ideaKey); idea.SetKey(iCipher::DECRYPT, ideaKey);
cCryptoArchive inCrypt; cCryptoArchive inCrypt;
@ -129,7 +129,7 @@ void TestCryptoArchive()
d.TraceDetail("Signing using asymmetric key\n"); d.TraceDetail("Signing using asymmetric key\n");
cFileArchive outFile; cFileArchive outFile;
outFile.OpenReadWrite(TEMP_DIR _T("/rsacrypted.bin")); outFile.OpenReadWrite(TwTestPath("rsacrypted.bin").c_str());
cElGamalSigArchive outCrypt; cElGamalSigArchive outCrypt;
outCrypt.SetWrite(&outFile, privateKey); outCrypt.SetWrite(&outFile, privateKey);
@ -149,7 +149,7 @@ void TestCryptoArchive()
d.TraceDetail("Verifying using asymmetric key\n"); d.TraceDetail("Verifying using asymmetric key\n");
cFileArchive inFile; cFileArchive inFile;
inFile.OpenRead(TEMP_DIR _T("/rsacrypted.bin")); inFile.OpenRead(TwTestPath("rsacrypted.bin").c_str());
cElGamalSigArchive inCrypt; cElGamalSigArchive inCrypt;
inCrypt.SetRead(&inFile, publicKey); inCrypt.SetRead(&inFile, publicKey);
@ -206,7 +206,7 @@ void TestCryptoArchive()
d.TraceDetail("Encrypting using asymmetric key\n"); d.TraceDetail("Encrypting using asymmetric key\n");
cFileArchive outFile; cFileArchive outFile;
outFile.OpenReadWrite(TEMP_DIR _T("/rsacrypted.bin")); outFile.OpenReadWrite(TwTestPath("rsacrypted.bin").c_str());
cRSAArchive outCrypt; cRSAArchive outCrypt;
outCrypt.SetWrite(&outFile, publicKey); outCrypt.SetWrite(&outFile, publicKey);
@ -226,7 +226,7 @@ void TestCryptoArchive()
d.TraceDetail("Decrypting using asymmetric key\n"); d.TraceDetail("Decrypting using asymmetric key\n");
cFileArchive inFile; cFileArchive inFile;
inFile.OpenRead(TEMP_DIR _T("/rsacrypted.bin")); inFile.OpenRead(TwTestPath("rsacrypted.bin").c_str());
cRSAArchive inCrypt; cRSAArchive inCrypt;
inCrypt.SetRead(&inFile, privateKey); inCrypt.SetRead(&inFile, privateKey);
@ -252,7 +252,7 @@ void TestCryptoArchive()
d.TraceDetail("Signing using asymmetric key\n"); d.TraceDetail("Signing using asymmetric key\n");
cFileArchive outFile; cFileArchive outFile;
outFile.OpenReadWrite(TEMP_DIR _T("/rsacrypted.bin")); outFile.OpenReadWrite(TwTestPath("rsacrypted.bin").c_str());
cRSAArchive outCrypt; cRSAArchive outCrypt;
outCrypt.SetWrite(&outFile, privateKey); outCrypt.SetWrite(&outFile, privateKey);
@ -272,7 +272,7 @@ void TestCryptoArchive()
d.TraceDetail("Verifying using asymmetric key\n"); d.TraceDetail("Verifying using asymmetric key\n");
cFileArchive inFile; cFileArchive inFile;
inFile.OpenRead(TEMP_DIR _T("/rsacrypted.bin")); inFile.OpenRead(TwTestPath("rsacrypted.bin").c_str());
cRSAArchive inCrypt; cRSAArchive inCrypt;
inCrypt.SetRead(&inFile, publicKey); inCrypt.SetRead(&inFile, publicKey);

View File

@ -407,6 +407,8 @@ void TestCrypto()
delete pPublic; delete pPublic;
delete pPrivate; delete pPrivate;
delete pPublic2;
delete pPrivate2;
} }
} }

View File

@ -173,7 +173,8 @@ static void AssertChildren(cDbDataSourceIter& iter, const TSTRING& filename, boo
void TestDbDataSourceBasic() void TestDbDataSourceBasic()
{ {
cHierDatabase db; cHierDatabase db;
db.Open( _T("test.db"), 5, true); std::string dbpath = TwTestPath("test.db");
db.Open( dbpath, 5, true);
cDbDataSourceIter iter(&db); cDbDataSourceIter iter(&db);
AddFile(iter, "file1", true); AddFile(iter, "file1", true);

View File

@ -73,8 +73,7 @@ void TestDebug()
// set up an output file...use the temp file in test.h // set up an output file...use the temp file in test.h
std::string str = TEMP_DIR_N; std::string str = TwTestPath("debug.out");
str += "/debug.out";
#ifdef DEBUG #ifdef DEBUG
TEST(cDebug::SetOutputFile(str.c_str())); TEST(cDebug::SetOutputFile(str.c_str()));

View File

@ -62,18 +62,17 @@ static void PrintProps(const iFCO* pFCO)
void TestFCOCompare() void TestFCOCompare()
{ {
const TCHAR* FILE_NAME = TEMP_DIR _T("/dog.txt"); std::string filename = TwTestPath("dog.txt");
const char* FILE_NAME_N = TEMP_DIR_N "/dog.txt";
cDebug d("TestFCOCompare"); cDebug d("TestFCOCompare");
d.TraceDebug("Entering...\n"); d.TraceDebug("Entering...\n");
// first, create an fco to compare with... // first, create an fco to compare with...
TOFSTREAM fstr(FILE_NAME_N); TOFSTREAM fstr(filename.c_str());
if(fstr.bad()) if(fstr.bad())
{ {
d.TraceError("Unable to create test file %s!\n", FILE_NAME); d.TraceError("Unable to create test file %s!\n", filename.c_str());
TEST(false); TEST(false);
return; return;
} }
@ -83,7 +82,7 @@ void TestFCOCompare()
// create the test FCO // create the test FCO
cFSDataSourceIter ds; cFSDataSourceIter ds;
ds.SeekToFCO(cFCOName(FILE_NAME), false); ds.SeekToFCO(cFCOName(filename), false);
iFCO* pFCO = ds.CreateFCO(); iFCO* pFCO = ds.CreateFCO();
TEST(pFCO); TEST(pFCO);
@ -110,10 +109,10 @@ void TestFCOCompare()
// change the file... // change the file...
d.TraceDebug("Changing the file...\n"); d.TraceDebug("Changing the file...\n");
fstr.open(FILE_NAME); fstr.open(filename.c_str());
if(fstr.bad()) if(fstr.bad())
{ {
d.TraceError("Unable to reopen %s!\n", FILE_NAME_N); d.TraceError("Unable to reopen %s!\n", filename.c_str());
TEST(false); TEST(false);
return; return;
} }
@ -123,7 +122,7 @@ void TestFCOCompare()
//need a new data source iter, otherwise the existing FCO gets updated & you get a ref to it, //need a new data source iter, otherwise the existing FCO gets updated & you get a ref to it,
// and the resulting FCOs always match. // and the resulting FCOs always match.
cFSDataSourceIter ds2; cFSDataSourceIter ds2;
ds2.SeekToFCO(cFCOName(FILE_NAME), false); ds2.SeekToFCO(cFCOName(filename), false);
iFCO* pFCO2 = ds2.CreateFCO(); iFCO* pFCO2 = ds2.CreateFCO();
TEST(pFCO2); TEST(pFCO2);
pFCO2->AcceptVisitor(&propCalc); pFCO2->AcceptVisitor(&propCalc);
@ -137,7 +136,7 @@ void TestFCOCompare()
//result.mPropVector.TraceContents(); //result.mPropVector.TraceContents();
cFSDataSourceIter ds3; cFSDataSourceIter ds3;
ds3.SeekToFCO(cFCOName(FILE_NAME), false); ds3.SeekToFCO(cFCOName(filename), false);
// try testing properties that weren't calculated... // try testing properties that weren't calculated...
d.TraceDebug("Comparing FCOs with different properties calculated\n"); d.TraceDebug("Comparing FCOs with different properties calculated\n");
iFCO* pFCO3 = ds3.CreateFCO(); iFCO* pFCO3 = ds3.CreateFCO();

View File

@ -130,8 +130,9 @@ void TestFCOReport()
d.TraceDebug("Before serializing report:\n"); d.TraceDebug("Before serializing report:\n");
TraceReport(report, d); TraceReport(report, d);
{ {
std::string filepath = TwTestPath("tmp.twr");
cFileArchive outFile; cFileArchive outFile;
outFile.OpenReadWrite(_T("tmp.twr")); outFile.OpenReadWrite(filepath.c_str());
cSerializerImpl outSer(outFile, cSerializerImpl::S_WRITE); cSerializerImpl outSer(outFile, cSerializerImpl::S_WRITE);
outSer.Init(); outSer.Init();
@ -141,7 +142,7 @@ void TestFCOReport()
outFile.Close(); outFile.Close();
cFileArchive inFile; cFileArchive inFile;
inFile.OpenRead(_T("tmp.twr")); inFile.OpenRead(filepath.c_str());
cSerializerImpl inSer(inFile, cSerializerImpl::S_READ); cSerializerImpl inSer(inFile, cSerializerImpl::S_READ);
cFCOReport inReport; cFCOReport inReport;

View File

@ -39,8 +39,7 @@
void TestFile() void TestFile()
{ {
TSTRING fileName = TEMP_DIR; TSTRING fileName = TwTestPath("file_test.bin");
fileName += _T("/file_test.bin");
//Create a temporary file for testing: //Create a temporary file for testing:
FILE* testStream; FILE* testStream;

View File

@ -49,8 +49,7 @@ using namespace std;
void TestFileUtil() void TestFileUtil()
{ {
TSTRING source = TEMP_DIR; TSTRING source = TwTestPath("copy_src");
source += _T("/copy_src");
//Create a temporary file for testing: //Create a temporary file for testing:
FILE* testStream; FILE* testStream;
@ -64,8 +63,7 @@ void TestFileUtil()
fwrite( testString.c_str(), sizeof(TCHAR), iTestStringLength, testStream ); fwrite( testString.c_str(), sizeof(TCHAR), iTestStringLength, testStream );
fclose( testStream ); fclose( testStream );
TSTRING dest = TEMP_DIR; TSTRING dest = TwTestPath("copy_dest");
dest += "/copy_dest";
TEST(cFileUtil::Copy(source, dest)); TEST(cFileUtil::Copy(source, dest));

View File

@ -43,6 +43,8 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <unistd.h>
#include <fcntl.h>
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// PrintProps -- prints out all the valid property names and values as pairs... // PrintProps -- prints out all the valid property names and values as pairs...
@ -67,8 +69,7 @@ void TestFSPropCalc()
{ {
cDebug d("TestFSPropCalc"); cDebug d("TestFSPropCalc");
cFSDataSourceIter ds; cFSDataSourceIter ds;
TSTRING foo_bin = TEMP_DIR; TSTRING foo_bin = TwTestPath("foo.bin");
foo_bin.append("/foo.bin");
//iFSServices* pFSServices = iFSServices::GetInstance(); //iFSServices* pFSServices = iFSServices::GetInstance();
@ -138,3 +139,20 @@ void TestFSPropCalc()
return; return;
} }
void TestGetSymLinkStr()
{
std::string file = TwTestPath("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
std::string link = TwTestPath("linky");
int fd = creat(file.c_str(), 0777);
close(fd);
symlink(file.c_str(), link.c_str());
cMemoryArchive arch(1024*1024);
TEST(cFSPropCalc::GetSymLinkStr(link, arch, 8));
TEST(arch.Length() == (int64)file.size());
}

View File

@ -127,6 +127,8 @@ void cTestFSPropDisplayer::Test()
d.TraceDebug("\n"); d.TraceDebug("\n");
} }
delete pPD;
delete pPDNew;
return; return;
} }

View File

@ -73,9 +73,9 @@ void TestFCOSpecImpl()
cFSDataSourceIter dataSrc; cFSDataSourceIter dataSrc;
// test AllChildStopPoint fcos... // test AllChildStopPoint fcos...
d.TraceDebug("Now testing a spec whose start point is the only thing it maps to (%s)\n", TEMP_DIR); d.TraceDebug("Now testing a spec whose start point is the only thing it maps to (%s)\n", TwTestDir().c_str());
cFCOSpecImpl* pSpec2 = new cFCOSpecImpl(TEMP_DIR, &dataSrc, new cFCOSpecNoChildren); cFCOSpecImpl* pSpec2 = new cFCOSpecImpl(TwTestDir(), &dataSrc, new cFCOSpecNoChildren);
pSpec2->SetStartPoint(cFCOName(TEMP_DIR)); pSpec2->SetStartPoint(cFCOName(TwTestDir()));
dataSrc.SeekToFCO(pSpec2->GetStartPoint(), false); dataSrc.SeekToFCO(pSpec2->GetStartPoint(), false);
iFCO* pFCO = dataSrc.CreateFCO(); iFCO* pFCO = dataSrc.CreateFCO();
TEST(pFCO); TEST(pFCO);

View File

@ -109,16 +109,17 @@ void TestKeyFile()
elGamal.ProcessBlock(ciphertext, recovered_text); elGamal.ProcessBlock(ciphertext, recovered_text);
TEST(memcmp(recovered_text, plaintext, elGamal.GetBlockSizePlain()) == 0); TEST(memcmp(recovered_text, plaintext, elGamal.GetBlockSizePlain()) == 0);
delete [] pMem;
} }
// save to and read from disk // save to and read from disk
d.TraceDebug("Read/Write to file...\n"); d.TraceDebug("Read/Write to file...\n");
{ {
keyfile.WriteFile(TEMP_DIR _T("/keyfile.key")); keyfile.WriteFile(TwTestPath("keyfile.key").c_str());
cKeyFile keyfile2; cKeyFile keyfile2;
TEST(!keyfile2.KeysLoaded()); TEST(!keyfile2.KeysLoaded());
keyfile2.ReadFile(TEMP_DIR _T("/keyfile.key")); keyfile2.ReadFile(TwTestPath("keyfile.key").c_str());
TEST(keyfile2.KeysLoaded()); TEST(keyfile2.KeysLoaded());
cElGamalSig elGamal(*keyfile2.GetPublicKey()); cElGamalSig elGamal(*keyfile2.GetPublicKey());

View File

@ -66,7 +66,7 @@ cRefCountTestObj::~cRefCountTestObj()
mChildren.pop_front(); mChildren.pop_front();
} }
delete mpSomeMem; delete [] mpSomeMem;
} }
void cRefCountTestObj::AddChild(cRefCountTestObj* pChild) void cRefCountTestObj::AddChild(cRefCountTestObj* pChild)

View File

@ -119,7 +119,7 @@ void TestSerializerImpl()
// writing // writing
{ {
cFileArchive file; cFileArchive file;
file.OpenReadWrite(TEMP_DIR _T("/tmp.bin")); file.OpenReadWrite(TwTestPath("tmp.bin").c_str());
cSerializerImpl serializer(file, cSerializerImpl::S_WRITE); cSerializerImpl serializer(file, cSerializerImpl::S_WRITE);
serializer.Init(); serializer.Init();
@ -127,16 +127,16 @@ void TestSerializerImpl()
cSerializerTestObject testobj; cSerializerTestObject testobj;
testobj.Write(&serializer); testobj.Write(&serializer);
db.TraceAlways(" Writeing object 1...\n"); db.TraceAlways(" Writing object 1...\n");
serializer.WriteObject(&testobj); serializer.WriteObject(&testobj);
db.TraceAlways(" Writeing object 2...\n"); db.TraceAlways(" Writing object 2...\n");
serializer.WriteObject(&testobj); serializer.WriteObject(&testobj);
db.TraceAlways(" Writeing object 3...\n"); db.TraceAlways(" Writing object 3...\n");
serializer.WriteObject(&testobj); serializer.WriteObject(&testobj);
db.TraceAlways(" Writeing object 4...\n"); db.TraceAlways(" Writing object 4...\n");
serializer.WriteObject(&testobj); serializer.WriteObject(&testobj);
serializer.Finit(); serializer.Finit();
@ -145,7 +145,7 @@ void TestSerializerImpl()
// reading // reading
{ {
cFileArchive file; cFileArchive file;
file.OpenRead(TEMP_DIR _T("/tmp.bin")); file.OpenRead(TwTestPath("tmp.bin").c_str());
cSerializerImpl serializer(file, cSerializerImpl::S_READ); cSerializerImpl serializer(file, cSerializerImpl::S_READ);
serializer.Init(); serializer.Init();

View File

@ -87,8 +87,7 @@ void TestSignature()
//sha : Oia1aljHD793tfj7M55tND+3OG/ //sha : Oia1aljHD793tfj7M55tND+3OG/
//haval : BL6bFSo0EP5zf8lGSueeed //haval : BL6bFSo0EP5zf8lGSueeed
TSTRING sigFileName = TEMP_DIR; TSTRING sigFileName = TwTestPath("signature_test.bin");
sigFileName += TSTRING( _T("/signature_test.bin") );
cFileArchive fileArc; cFileArchive fileArc;
fileArc.OpenReadWrite(sigFileName.c_str()); fileArc.OpenReadWrite(sigFileName.c_str());

View File

@ -39,6 +39,8 @@
#include "core/debug.h" #include "core/debug.h"
#endif #endif
#include "test.h"
TSTRING test_wost(int, const TSTRING&); TSTRING test_wost(int, const TSTRING&);
void test_wist(const TSTRING&, cDebug& d); void test_wist(const TSTRING&, cDebug& d);
@ -87,21 +89,21 @@ void TestTCHAR()
//Testing file streams //Testing file streams
//explict constructors of 'TIFSTREAM' and "TOFSTREAM' take char* //explict constructors of 'TIFSTREAM' and "TOFSTREAM' take char*
const char* inputfile = "fun"; std::string inputfile = TwTestPath("fun");
const char* outputfile = "mo'fun"; std::string outputfile = TwTestPath("mo'fun");
//Set up the input file. //Set up the input file.
TOFSTREAM out; TOFSTREAM out;
out.open(inputfile, std::ios_base::out); out.open(inputfile.c_str(), std::ios_base::out);
out<<"Unicode is fun\n"; out<<"Unicode is fun\n";
out.close(); out.close();
TIFSTREAM from; TIFSTREAM from;
from.open(inputfile, std::ios_base::in); from.open(inputfile.c_str(), std::ios_base::in);
if(!from) if(!from)
d.TraceDetail("error opening input file\n"); d.TraceDetail("error opening input file\n");
TOFSTREAM to(outputfile, std::ios_base::trunc); TOFSTREAM to(outputfile.c_str(), std::ios_base::trunc);
if(!to) if(!to)
d.TraceDetail("error opening output file\n"); d.TraceDetail("error opening output file\n");

View File

@ -42,8 +42,6 @@
#include "twparser/twparser.h" #include "twparser/twparser.h"
#include "tw/tw.h" #include "tw/tw.h"
#include "fco/fco.h" #include "fco/fco.h"
#include "fs/fs.h" #include "fs/fs.h"
#include "util/util.h" #include "util/util.h"
@ -51,6 +49,7 @@
#include "core/debug.h" #include "core/debug.h"
#include "core/error.h" #include "core/error.h"
#include "core/twlocale.h" #include "core/twlocale.h"
#include "core/fsservices.h"
#include "test.h" #include "test.h"
#include "core/errorbucketimpl.h" #include "core/errorbucketimpl.h"
#include "tw/twinit.h" #include "tw/twinit.h"
@ -62,6 +61,8 @@
#include "db/blockrecordarray.h" #include "db/blockrecordarray.h"
#include "db/hierdatabase.h" #include "db/hierdatabase.h"
#include <unistd.h>
#include <sys/stat.h>
// the test routines // the test routines
void TestFCOName(); void TestFCOName();
@ -99,7 +100,7 @@ void TestTextReportViewer();
void TestFCONameTbl(); void TestFCONameTbl();
void TestConfigFile(); void TestConfigFile();
void TestResources(); void TestResources();
void TestGetSymLinkStr();
void TestPolicyParser(); void TestPolicyParser();
void TestFCOSpecHelper(); void TestFCOSpecHelper();
@ -187,7 +188,7 @@ static void Test(int testID)
case 14: TestFCOPropVector(); break; case 14: TestFCOPropVector(); break;
case 15: TestFCOPropImpl(); break; case 15: TestFCOPropImpl(); break;
case 16: TestFCOReport(); break; case 16: TestFCOReport(); break;
case 17: TestGetSymLinkStr(); break;
case 18: TestFCOSetImpl(); break; case 18: TestFCOSetImpl(); break;
case 19: TestFCOSpec(); break; case 19: TestFCOSpec(); break;
case 20: TestFCOSpecAttr(); break; case 20: TestFCOSpecAttr(); break;
@ -294,6 +295,31 @@ static void Test(int testID)
TCERR << std::endl << "=== test ID #" << testID << " currently unused ===" << std::endl; TCERR << std::endl << "=== test ID #" << testID << " currently unused ===" << std::endl;
} }
std::string TwTestDir()
{
static std::string dir;
if(dir.empty())
{
iFSServices::GetInstance()->GetCurrentDir(dir);
dir.append("/TWTestData");
TCERR << "Using test directory: " << dir << std::endl;
mkdir(dir.c_str(), 0777);
}
return dir;
}
std::string TwTestPath(const std::string& child)
{
std::stringstream sstr;
sstr << TwTestDir();
if (child[0] != '/')
sstr << '/';
sstr << child;
return sstr.str();
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// cTest // cTest
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////

View File

@ -75,9 +75,9 @@ TSS_EndPackage( cTest )
} }
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Platform dependancies
#define TEMP_DIR _T("/tmp") std::string TwTestDir();
#define TEMP_DIR_N "/tmp" std::string TwTestPath(const std::string& child);
#endif // __TEST_H #endif // __TEST_H

View File

@ -380,7 +380,7 @@ void TestTextReportViewer()
d.TraceDebug("Read in serialized report:\n"); d.TraceDebug("Read in serialized report:\n");
//TraceReport(inReport, d); //TraceReport(inReport, d);
trv.PrintTextReport(TSTRING( TEMP_DIR _T( "/test2.txt" ) ) ); trv.PrintTextReport(TSTRING( TwTestPath("test2.txt" ) ) );
//TODO: this does not work any more //TODO: this does not work any more
//trv.LaunchEditorOnFile( TSTRING( TEMP_DIR _T("/test2.txt") ), _T("") ); //trv.LaunchEditorOnFile( TSTRING( TEMP_DIR _T("/test2.txt") ), _T("") );

View File

@ -58,10 +58,8 @@ void TestTWUtil()
// assuming the current dir is writable, this test should succeed // assuming the current dir is writable, this test should succeed
TEST(cFileUtil::FileWritable(_T("afilethatdoesnotexist.tmp")) == true); TEST(cFileUtil::FileWritable(_T("afilethatdoesnotexist.tmp")) == true);
TSTRING tmpDir = TEMP_DIR; TSTRING tmpDir = TwTestPath("fileexistdir");
tmpDir += _T("/fileexistdir"); TSTRING tmpFN = TwTestPath("fileexiststest.tmp");
TSTRING tmpFN = tmpDir;
tmpFN += _T("/fileexiststest.tmp");
// make a subdir in the TEMP_DIR // make a subdir in the TEMP_DIR
mkdir(tmpDir.c_str(), 0700); mkdir(tmpDir.c_str(), 0700);
@ -77,14 +75,14 @@ void TestTWUtil()
TEST(cFileUtil::FileWritable(tmpFN) == true) TEST(cFileUtil::FileWritable(tmpFN) == true)
TEST(cFileUtil::FileExists(tmpFN) == false); TEST(cFileUtil::FileExists(tmpFN) == false);
// make the dir read only and make sure write tests false
// windows fails this test, perhaps because I am an administrator?
chmod(tmpDir.c_str(), 0500);
bool is_root = (0 == getuid()); bool is_root = (0 == getuid());
TEST(cFileUtil::FileWritable(tmpFN) == is_root); // make the dir read only and make sure write tests false
// windows fails this test, perhaps because I am an administrator?
chmod(tmpDir.c_str(), 0700); // chmod(tmpDir.c_str(), 0500);
// TODO - is this valid now that we don't use /tmp?
// TEST(cFileUtil::FileWritable(tmpFN) == is_root);
// chmod(tmpDir.c_str(), 0700);
// create the file // create the file
{ {

View File

@ -54,9 +54,9 @@ void TestUnixFSServices()
iFSServices* pFSServices = iFSServices::GetInstance(); iFSServices* pFSServices = iFSServices::GetInstance();
// working primarily with the temp dir. // working primarily with the temp dir.
cFCOName name(_T("/tmp")); cFCOName name(TwTestDir());
// Check to make sure /tmp is a dir // Check to make sure test dir is a dir
//TEST(pFSServices->GetFileType(name) == cFSStatArgs::TY_DIR); //TEST(pFSServices->GetFileType(name) == cFSStatArgs::TY_DIR);
// get directory contents (test readdir) // get directory contents (test readdir)
@ -80,7 +80,7 @@ void TestUnixFSServices()
cFSStatArgs stat; cFSStatArgs stat;
//TO DO: use archive to create this file //TO DO: use archive to create this file
TSTRING testfile = "/tmp/tmp.tmp"; TSTRING testfile = TwTestPath("tmp.tmp");
cFileArchive filearch; cFileArchive filearch;
filearch.OpenReadWrite(testfile.c_str()); filearch.OpenReadWrite(testfile.c_str());
filearch.Seek(0, cBidirArchive::BEGINNING); filearch.Seek(0, cBidirArchive::BEGINNING);
@ -150,21 +150,9 @@ void TestUnixFSServices()
// test Rename // test Rename
d.TraceDetail("Testing Rename:\n"); d.TraceDetail("Testing Rename:\n");
TSTRING newtestfile = _T("/tmp/new.tmp"); TSTRING newtestfile = TwTestPath("new.tmp");
TEST( pFSServices->Rename( testfile, newtestfile ) ); TEST( pFSServices->Rename( testfile, newtestfile ) );
// test GetOwnerForFile
d.TraceDetail("Testing GetOwnerForFile:\n");
TSTRING ownername;
TEST( pFSServices->GetOwnerForFile( newtestfile, ownername ) );
d.TraceDetail("GetOwnerForFile returned owner %s.\n", ownername.c_str());
// test GetGroupForFile
d.TraceDetail("Testing GetGroupForFile:\n");
TSTRING groupname;
TEST( pFSServices->GetGroupForFile( newtestfile, groupname ) );
d.TraceDetail("GetGroupForFile returned group %s.\n", groupname.c_str());
// test FileDelete // test FileDelete
d.TraceDetail("Testing FileDelete:\n"); d.TraceDetail("Testing FileDelete:\n");
TEST( pFSServices->FileDelete( newtestfile ) ); TEST( pFSServices->FileDelete( newtestfile ) );