mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-30 09:07:32 -04:00
Added multiple security tests to pgp keyring against disk full and exceeded quota.
- copy files to tmp before appending new keys, then rename back to original. - always check for disk full before syncing keyrings - use tmp file to sync keyring - new RsDirUtil::fileExists() method - check system for disk space in pgp directory - added RsPGPDirectory() method to RsInit git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6541 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d6104c0aa7
commit
b84930b157
7 changed files with 94 additions and 10 deletions
|
@ -291,6 +291,11 @@ int RsDirUtil::breakupDirList(const std::string& path,
|
|||
return 1;
|
||||
}
|
||||
|
||||
/**** Copied and Tweaked from ftcontroller ***/
|
||||
bool RsDirUtil::fileExists(const std::string& filename)
|
||||
{
|
||||
return ( access( filename.c_str(), F_OK ) != -1 );
|
||||
}
|
||||
|
||||
/**** Copied and Tweaked from ftcontroller ***/
|
||||
bool RsDirUtil::copyFile(const std::string& source,const std::string& dest)
|
||||
|
|
|
@ -81,6 +81,7 @@ bool crc32File(FILE *f,uint64_t file_size,uint32_t chunk_size,CRC32Map& map) ;
|
|||
int breakupDirList(const std::string& path, std::list<std::string> &subdirs);
|
||||
|
||||
bool copyFile(const std::string& source,const std::string& dest);
|
||||
bool fileExists(const std::string& file);
|
||||
bool checkFile(const std::string& filename,bool disallow_empty_file = false);
|
||||
bool checkDirectory(const std::string& dir);
|
||||
bool checkCreateDirectory(const std::string& dir);
|
||||
|
|
|
@ -130,7 +130,7 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc)
|
|||
{
|
||||
RsStackMutex m(_mtx) ; // Locked
|
||||
|
||||
if(_partials_path == "" || _download_path == "")
|
||||
if(_partials_path == "" && loc == RS_PARTIALS_DIRECTORY || _download_path == "" && loc == RS_DOWNLOAD_DIRECTORY)
|
||||
throw std::runtime_error("Download path and partial path not properly set in RsDiscSpace. Please call RsDiscSpace::setPartialsPath() and RsDiscSpace::setDownloadPath()") ;
|
||||
|
||||
time_t now = time(NULL) ;
|
||||
|
@ -160,6 +160,12 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc)
|
|||
case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(RsInit::RsConfigDirectory().c_str(),free_blocks,block_size) ;
|
||||
#ifdef DEBUG_RSDISCSPACE
|
||||
std::cerr << " path = " << RsInit::RsConfigDirectory() << std::endl ;
|
||||
#endif
|
||||
break ;
|
||||
|
||||
case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(RsInit::RsPGPDirectory().c_str(),free_blocks,block_size) ;
|
||||
#ifdef DEBUG_RSDISCSPACE
|
||||
std::cerr << " path = " << RsInit::RsPGPDirectory() << std::endl ;
|
||||
#endif
|
||||
break ;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue