[AROS] hide interactive passphrases; delete temp files after use; validate temp dir even if config value isn't set.

This commit is contained in:
Brian Cox 2016-06-12 17:27:14 -07:00
parent c7b83c88d8
commit bb863522f2
3 changed files with 44 additions and 13 deletions

View File

@ -89,6 +89,7 @@ struct cFile_i
FILE* mpCurrStream; //currently defined file stream FILE* mpCurrStream; //currently defined file stream
TSTRING mFileName; //the name of the file we are currently referencing. TSTRING mFileName; //the name of the file we are currently referencing.
uint32 mFlags; //Flags used to open the file
}; };
//Ctor //Ctor
@ -103,6 +104,17 @@ cFile_i::~cFile_i()
fclose( mpCurrStream ); fclose( mpCurrStream );
mpCurrStream = NULL; mpCurrStream = NULL;
#ifdef __AROS__
if( mFlags & cFile::OPEN_LOCKED_TEMP )
{
// unlink this file
if( 0 != unlink(mFileName.c_str()))
{
throw( eFileOpen( mFileName, iFSServices::GetInstance()->GetErrString() ) );
}
}
#endif
mFileName.empty(); mFileName.empty();
} }
@ -143,6 +155,8 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
if (mpData->mpCurrStream != NULL) if (mpData->mpCurrStream != NULL)
Close(); Close();
mpData->mFlags = flags;
// //
// set up the open permissions // set up the open permissions
// //
@ -275,6 +289,8 @@ void cFile::Close() //throw(eFile)
fclose( mpData->mpCurrStream ); fclose( mpData->mpCurrStream );
mpData->mpCurrStream = NULL; mpData->mpCurrStream = NULL;
} }
mpData->mFileName.empty(); mpData->mFileName.empty();
} }

View File

@ -292,37 +292,40 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
pModeInfo->mfLooseDirs = true; pModeInfo->mfLooseDirs = true;
} }
if (cf.Lookup(TSTRING(_T("TEMPDIRECTORY")), str)) { TSTRING temp_directory;
cf.Lookup(TSTRING(_T("TEMPDIRECTORY")), temp_directory);
if (str.length() == 0) if (temp_directory.length() == 0) {
str = "/tmp/"; #ifdef __AROS__
temp_directory = "T:";
#else
temp_directory = "/tmp/";
#endif
}
// make sure we have a trailing slash -- thanks Jarno... // make sure we have a trailing slash -- thanks Jarno...
// //
if (str[_tcslen(str.c_str())-1] != '/') { if (temp_directory[_tcslen(str.c_str())-1] != '/') {
str += '/'; temp_directory += '/';
} }
// make sure it exists... // make sure it exists...
// //
#ifdef __AROS__ #ifdef __AROS__
str = cArosPath::AsNative(str); temp_directory = cArosPath::AsNative(temp_directory);
#endif #endif
if (access(str.c_str(), F_OK) != 0) { if (access(temp_directory.c_str(), F_OK) != 0) {
TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY ); TSTRING errStr = TSS_GetString( cCore, core::STR_BAD_TEMPDIRECTORY );
TSTRING tmpStr = _T("Directory: "); TSTRING tmpStr = _T("Directory: ");
tmpStr += (str + _T("\n")); tmpStr += (temp_directory + _T("\n"));
tmpStr += errStr; tmpStr += errStr;
throw eTWInvalidTempDirectory(tmpStr); throw eTWInvalidTempDirectory(tmpStr);
} }
else { else {
iFSServices::GetInstance()->SetTempDirName(str); iFSServices::GetInstance()->SetTempDirName(temp_directory);
} }
}
if (cf.Lookup(TSTRING(_T("GLOBALEMAIL")), str)) { if (cf.Lookup(TSTRING(_T("GLOBALEMAIL")), str)) {

View File

@ -1143,6 +1143,12 @@ void cTWUtil::GetString(wc16_string& ret)
#error We depend on Unix not being Unicode #error We depend on Unix not being Unicode
#endif #endif
// tcsetattr doesn't seem to work on AROS, so tweak ANSI terminal settings to hide passphrases.
#ifdef __AROS__
printf("\e[8m"); // set the 'concealed' flag
fflush(stdout);
#endif
// get the string // get the string
const int MAX_STRING = 1024; const int MAX_STRING = 1024;
char buf[MAX_STRING]; char buf[MAX_STRING];
@ -1151,6 +1157,11 @@ void cTWUtil::GetString(wc16_string& ret)
TCOUT.flush(); TCOUT.flush();
len = read( 0, buf, MAX_STRING ); len = read( 0, buf, MAX_STRING );
#ifdef __AROS__
printf("\e[0m"); // reset back to normal text
fflush(stdout);
#endif
// TODO:BAM -- mb-enable this! // TODO:BAM -- mb-enable this!
if (len < MAX_STRING - 1) if (len < MAX_STRING - 1)
buf[len] = 0; buf[len] = 0;
@ -1184,7 +1195,8 @@ cTWUtil::NoEcho::NoEcho()
} }
} }
cTWUtil::NoEcho::~NoEcho() { cTWUtil::NoEcho::~NoEcho()
{
tcsetattr( 0, TCSAFLUSH, &Otty); tcsetattr( 0, TCSAFLUSH, &Otty);
tw_signal(SIGINT, old_SIGINT); tw_signal(SIGINT, old_SIGINT);
tw_signal(SIGQUIT, old_SIGQUIT); tw_signal(SIGQUIT, old_SIGQUIT);