mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added permission check for friends to see shared files or not
This commit is contained in:
parent
1290aa8403
commit
4b00d47d3a
@ -385,6 +385,14 @@ public:
|
||||
|
||||
// Low level stuff. Should normally not be used externally.
|
||||
|
||||
const FileStorageNode *getNode(DirectoryStorage::EntryIndex indx) const
|
||||
{
|
||||
if(checkIndex(indx,FileStorageNode::TYPE_FILE | FileStorageNode::TYPE_DIR))
|
||||
return mNodes[indx] ;
|
||||
else
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
const DirEntry *getDirEntry(DirectoryStorage::EntryIndex indx) const
|
||||
{
|
||||
if(!checkIndex(indx,FileStorageNode::TYPE_DIR))
|
||||
@ -450,7 +458,7 @@ public:
|
||||
hits[0] = 1 ; // because 0 is never the child of anyone
|
||||
|
||||
for(uint32_t i=0;i<mNodes.size();++i)
|
||||
if(mNodes[i]->type() == FileStorageNode::TYPE_DIR)
|
||||
if(mNodes[i] != NULL && mNodes[i]->type() == FileStorageNode::TYPE_DIR)
|
||||
{
|
||||
// stamp the kids
|
||||
const DirEntry& de = *static_cast<DirEntry*>(mNodes[i]) ;
|
||||
@ -942,12 +950,24 @@ bool LocalDirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
|
||||
|
||||
// here we should update the file sharing flags
|
||||
|
||||
d.flags.clear() ;
|
||||
d.parent_groups.clear();
|
||||
return getFileSharingPermissions(indx,d.flags,d.parent_groups) ;
|
||||
}
|
||||
|
||||
bool LocalDirectoryStorage::getFileSharingPermissions(const EntryIndex& indx,FileStorageFlags& flags,std::list<std::string>& parent_groups)
|
||||
{
|
||||
RS_STACK_MUTEX(mDirStorageMtx) ;
|
||||
|
||||
flags.clear() ;
|
||||
parent_groups.clear();
|
||||
|
||||
std::string base_dir;
|
||||
|
||||
for(DirectoryStorage::EntryIndex i=((d.type==DIR_TYPE_FILE)?((intptr_t)d.parent):((intptr_t)d.ref));;)
|
||||
const InternalFileHierarchyStorage::FileStorageNode *n = mFileHierarchy->getNode(indx) ;
|
||||
|
||||
if(n == NULL)
|
||||
return false ;
|
||||
|
||||
for(DirectoryStorage::EntryIndex i=((n->type()==InternalFileHierarchyStorage::FileStorageNode::TYPE_FILE)?((intptr_t)n->parent_index):indx);;)
|
||||
{
|
||||
const InternalFileHierarchyStorage::DirEntry *e = mFileHierarchy->getDirEntry(i) ;
|
||||
|
||||
@ -972,8 +992,8 @@ bool LocalDirectoryStorage::extractData(const EntryIndex& indx,DirDetails& d)
|
||||
return false ;
|
||||
}
|
||||
#warning we should use a NodeGroupId here
|
||||
d.flags = it->second.shareflags;
|
||||
d.parent_groups = it->second.parent_groups;
|
||||
flags = it->second.shareflags;
|
||||
parent_groups = it->second.parent_groups;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -164,6 +164,18 @@ public:
|
||||
*/
|
||||
bool getFileInfo(DirectoryStorage::EntryIndex i,FileInfo& info) ;
|
||||
|
||||
/*!
|
||||
* \brief getFileSharingPermissions
|
||||
* Computes the flags and parent groups for any index.
|
||||
* \param indx index of the entry to compute the flags for
|
||||
* \param flags computed flags
|
||||
* \param parent_groups computed parent groups
|
||||
* \return
|
||||
* false if the index is not valid
|
||||
* false otherwise
|
||||
*/
|
||||
bool getFileSharingPermissions(const EntryIndex& indx, FileStorageFlags &flags, std::list<std::string>& parent_groups);
|
||||
|
||||
virtual bool extractData(const EntryIndex& indx,DirDetails& d) ;
|
||||
|
||||
/*!
|
||||
|
@ -756,10 +756,17 @@ void p3FileDatabase::handleDirSyncRequest(RsFileListsSyncRequestItem *item)
|
||||
ritem->request_id = item->request_id;
|
||||
ritem->entry_index = item->entry_index ;
|
||||
|
||||
std::list<std::string> node_groups;
|
||||
FileStorageFlags node_flags;
|
||||
|
||||
if(entry_type != DIR_TYPE_DIR)
|
||||
{
|
||||
P3FILELISTS_DEBUG() << " Directory does not exist anymore, or is not a directory. Answering with proper flags." << std::endl;
|
||||
|
||||
P3FILELISTS_DEBUG() << " Directory does not exist anymore, or is not a directory, or permission denied. Answering with proper flags." << std::endl;
|
||||
ritem->flags = RsFileListsItem::FLAGS_SYNC_RESPONSE | RsFileListsItem::FLAGS_ENTRY_WAS_REMOVED ;
|
||||
}
|
||||
else if(item->entry_index != 0 && (!mLocalSharedDirs->getFileSharingPermissions(item->entry_index,node_flags,node_groups) || !(rsPeers->computePeerPermissionFlags(item->PeerId(),node_flags,node_groups) & RS_FILE_HINTS_BROWSABLE)))
|
||||
{
|
||||
std::cerr << "(EE) cannot get file permissions for entry index " << (void*)(intptr_t)item->entry_index << ", or permission denied." << std::endl;
|
||||
ritem->flags = RsFileListsItem::FLAGS_SYNC_RESPONSE | RsFileListsItem::FLAGS_ENTRY_WAS_REMOVED ;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user