[AROS] hide interactive passphrases; delete temp files after use; validate temp dir even if config value isn't set.
This commit is contained in:
parent
c7b83c88d8
commit
bb863522f2
|
@ -89,6 +89,7 @@ struct cFile_i
|
|||
|
||||
FILE* mpCurrStream; //currently defined file stream
|
||||
TSTRING mFileName; //the name of the file we are currently referencing.
|
||||
uint32 mFlags; //Flags used to open the file
|
||||
};
|
||||
|
||||
//Ctor
|
||||
|
@ -103,6 +104,17 @@ cFile_i::~cFile_i()
|
|||
fclose( mpCurrStream );
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -143,6 +155,8 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags )
|
|||
if (mpData->mpCurrStream != NULL)
|
||||
Close();
|
||||
|
||||
mpData->mFlags = flags;
|
||||
|
||||
//
|
||||
// set up the open permissions
|
||||
//
|
||||
|
@ -275,6 +289,8 @@ void cFile::Close() //throw(eFile)
|
|||
fclose( mpData->mpCurrStream );
|
||||
mpData->mpCurrStream = NULL;
|
||||
}
|
||||
|
||||
|
||||
mpData->mFileName.empty();
|
||||
}
|
||||
|
||||
|
|
|
@ -292,37 +292,40 @@ static void FillOutConfigInfo(cTWModeCommon* pModeInfo, const cConfigFile& cf)
|
|||
pModeInfo->mfLooseDirs = true;
|
||||
}
|
||||
|
||||
if (cf.Lookup(TSTRING(_T("TEMPDIRECTORY")), str)) {
|
||||
TSTRING temp_directory;
|
||||
cf.Lookup(TSTRING(_T("TEMPDIRECTORY")), temp_directory);
|
||||
|
||||
if (str.length() == 0)
|
||||
str = "/tmp/";
|
||||
if (temp_directory.length() == 0) {
|
||||
#ifdef __AROS__
|
||||
temp_directory = "T:";
|
||||
#else
|
||||
temp_directory = "/tmp/";
|
||||
#endif
|
||||
}
|
||||
|
||||
// make sure we have a trailing slash -- thanks Jarno...
|
||||
//
|
||||
if (str[_tcslen(str.c_str())-1] != '/') {
|
||||
str += '/';
|
||||
if (temp_directory[_tcslen(str.c_str())-1] != '/') {
|
||||
temp_directory += '/';
|
||||
}
|
||||
|
||||
// make sure it exists...
|
||||
//
|
||||
|
||||
|
||||
#ifdef __AROS__
|
||||
str = cArosPath::AsNative(str);
|
||||
temp_directory = cArosPath::AsNative(temp_directory);
|
||||
#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 tmpStr = _T("Directory: ");
|
||||
tmpStr += (str + _T("\n"));
|
||||
tmpStr += (temp_directory + _T("\n"));
|
||||
tmpStr += errStr;
|
||||
throw eTWInvalidTempDirectory(tmpStr);
|
||||
}
|
||||
else {
|
||||
iFSServices::GetInstance()->SetTempDirName(str);
|
||||
iFSServices::GetInstance()->SetTempDirName(temp_directory);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (cf.Lookup(TSTRING(_T("GLOBALEMAIL")), str)) {
|
||||
|
||||
|
|
|
@ -1143,6 +1143,12 @@ void cTWUtil::GetString(wc16_string& ret)
|
|||
#error We depend on Unix not being Unicode
|
||||
#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
|
||||
const int MAX_STRING = 1024;
|
||||
char buf[MAX_STRING];
|
||||
|
@ -1151,6 +1157,11 @@ void cTWUtil::GetString(wc16_string& ret)
|
|||
TCOUT.flush();
|
||||
len = read( 0, buf, MAX_STRING );
|
||||
|
||||
#ifdef __AROS__
|
||||
printf("\e[0m"); // reset back to normal text
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
// TODO:BAM -- mb-enable this!
|
||||
if (len < MAX_STRING - 1)
|
||||
buf[len] = 0;
|
||||
|
@ -1184,7 +1195,8 @@ cTWUtil::NoEcho::NoEcho()
|
|||
}
|
||||
}
|
||||
|
||||
cTWUtil::NoEcho::~NoEcho() {
|
||||
cTWUtil::NoEcho::~NoEcho()
|
||||
{
|
||||
tcsetattr( 0, TCSAFLUSH, &Otty);
|
||||
tw_signal(SIGINT, old_SIGINT);
|
||||
tw_signal(SIGQUIT, old_SIGQUIT);
|
||||
|
|
Loading…
Reference in New Issue