diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-05-23 12:23:55 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-05-23 12:23:55 +0000 |
commit | 029fd83551338ea01613c54ddbc4906c09227c60 (patch) | |
tree | df5e77cbb88f29def748393baf98d88d172cb7ba /cpp/src | |
parent | fix test for recent slice change (diff) | |
download | ice-029fd83551338ea01613c54ddbc4906c09227c60.tar.bz2 ice-029fd83551338ea01613c54ddbc4906c09227c60.tar.xz ice-029fd83551338ea01613c54ddbc4906c09227c60.zip |
Added support for Glacier2 filters.
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/IceGrid/ObjectCache.cpp | 29 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerCache.cpp | 35 | ||||
-rw-r--r-- | cpp/src/IceGrid/ServerI.cpp | 3 | ||||
-rw-r--r-- | cpp/src/IceGrid/SessionI.cpp | 54 | ||||
-rw-r--r-- | cpp/src/IceGrid/SessionI.h | 1 |
5 files changed, 118 insertions, 4 deletions
diff --git a/cpp/src/IceGrid/ObjectCache.cpp b/cpp/src/IceGrid/ObjectCache.cpp index d1eb882e2ef..95f98c99742 100644 --- a/cpp/src/IceGrid/ObjectCache.cpp +++ b/cpp/src/IceGrid/ObjectCache.cpp @@ -10,6 +10,7 @@ #include <IceUtil/Random.h> #include <Ice/Communicator.h> #include <Ice/LoggerUtil.h> +#include <Ice/LocalException.h> #include <IceGrid/ObjectCache.h> #include <IceGrid/NodeSessionI.h> #include <IceGrid/ServerCache.h> @@ -365,6 +366,20 @@ ObjectEntry::allocated(const SessionIPtr& session) out << "object `" << _cache.communicator()->identityToString(id) << "' allocated by `" << session->getId() << "' (" << _count << ")"; } + + Glacier2::SessionControlPrx ctl = session->getSessionControl(); + if(ctl) + { + try + { + Ice::IdentitySeq seq(1); + seq.push_back(_info.proxy->ice_getIdentity()); + ctl->objectIdFilter()->addAccept(seq); + } + catch(const Ice::ObjectNotExistException&) + { + } + } } void @@ -375,6 +390,20 @@ ObjectEntry::released(const SessionIPtr& session) // session->removeAllocation(this); + Glacier2::SessionControlPrx ctl = session->getSessionControl(); + if(ctl) + { + try + { + Ice::IdentitySeq seq(1); + seq.push_back(_info.proxy->ice_getIdentity()); + ctl->objectIdFilter()->removeAccept(seq); + } + catch(const Ice::ObjectNotExistException&) + { + } + } + TraceLevelsPtr traceLevels = _cache.getTraceLevels(); if(traceLevels && traceLevels->object > 1) { diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp index b328fa5a3b3..5b68c70bc5a 100644 --- a/cpp/src/IceGrid/ServerCache.cpp +++ b/cpp/src/IceGrid/ServerCache.cpp @@ -9,6 +9,7 @@ #include <Ice/LoggerUtil.h> #include <Ice/Communicator.h> +#include <Ice/LocalException.h> #include <IceGrid/ServerCache.h> #include <IceGrid/NodeCache.h> #include <IceGrid/AdapterCache.h> @@ -787,6 +788,23 @@ ServerEntry::allocated(const SessionIPtr& session) _session = session; } } + + Glacier2::SessionControlPrx ctl = session->getSessionControl(); + if(ctl) + { + try + { + Ice::StringSeq seq(_adapters.size()); + for(AdapterPrxDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p) + { + seq.push_back(p->first); + } + ctl->adapterIdFilter()->addAccept(seq); + } + catch(const Ice::ObjectNotExistException&) + { + } + } } void @@ -817,6 +835,23 @@ ServerEntry::released(const SessionIPtr& session) } } + Glacier2::SessionControlPrx ctl = session->getSessionControl(); + if(ctl) + { + try + { + Ice::StringSeq seq(_adapters.size()); + for(AdapterPrxDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p) + { + seq.push_back(p->first); + } + ctl->adapterIdFilter()->removeAccept(seq); + } + catch(const Ice::ObjectNotExistException&) + { + } + } + TraceLevelsPtr traceLevels = _cache.getTraceLevels(); if(traceLevels && traceLevels->server > 1) { diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 2f20d322179..f8b44a878a8 100644 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -57,6 +57,7 @@ chownRecursive(const string& path, uid_t uid, gid_t gid) { string name = namelist[i]->d_name; assert(!name.empty()); + free(namelist[i]); if(name != ".." && name != ".") { @@ -77,8 +78,6 @@ chownRecursive(const string& path, uid_t uid, gid_t gid) chownRecursive(name, uid, gid); } } - - free(namelist[i]); } free(namelist); diff --git a/cpp/src/IceGrid/SessionI.cpp b/cpp/src/IceGrid/SessionI.cpp index f096ee3ff4f..21b10bc90f4 100644 --- a/cpp/src/IceGrid/SessionI.cpp +++ b/cpp/src/IceGrid/SessionI.cpp @@ -300,7 +300,32 @@ ClientSessionManagerI::ClientSessionManagerI(const DatabasePtr& database, int ti Glacier2::SessionPrx ClientSessionManagerI::create(const string& user, const Glacier2::SessionControlPrx& ctl, const Ice::Current& current) { - return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(create(user, ctl))); + Glacier2::SessionPrx s = Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(create(user, ctl))); + if(ctl) + { + try + { + // + // Restrict the objects the session is allowed to access to the session object itself, + // the query and registry objects. + // + Ice::IdentitySeq ids; + Ice::Identity id; + id.category = "IceGrid"; + id.name = "Query"; + ids.push_back(id); + id.name = "Registry"; + ids.push_back(id); + ids.push_back(s->ice_getIdentity()); + ctl->objectIdFilter()->addAccept(ids); + } + catch(const Ice::LocalException&) + { + s->destroy(); + return 0; + } + } + return s; } SessionIPtr @@ -338,5 +363,30 @@ ClientSSLSessionManagerI::create(const Glacier2::SSLInfo& info, const Glacier2:: } SessionIPtr session = new SessionI(userDN, _database, _timeout, _waitQueue, ctl); - return Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(session)); + Glacier2::SessionPrx s = Glacier2::SessionPrx::uncheckedCast(current.adapter->addWithUUID(session)); + if(ctl) + { + try + { + // + // Restrict the objects the session is allowed to access to the session object itself, + // the query and registry objects. + // + Ice::IdentitySeq ids; + Ice::Identity id; + id.category = "IceGrid"; + id.name = "Query"; + ids.push_back(id); + id.name = "Registry"; + ids.push_back(id); + ids.push_back(s->ice_getIdentity()); + ctl->objectIdFilter()->addAccept(ids); + } + catch(const Ice::LocalException&) + { + s->destroy(); + return 0; + } + } + return s; } diff --git a/cpp/src/IceGrid/SessionI.h b/cpp/src/IceGrid/SessionI.h index 927f1e8a026..b4a4f4967c2 100644 --- a/cpp/src/IceGrid/SessionI.h +++ b/cpp/src/IceGrid/SessionI.h @@ -84,6 +84,7 @@ public: int getAllocationTimeout() const; const WaitQueuePtr& getWaitQueue() const { return _waitQueue; } const std::string& getId() const { return _id; } + Glacier2::SessionControlPrx getSessionControl() const { return _sessionControl; } bool addAllocationRequest(const AllocationRequestPtr&); void removeAllocationRequest(const AllocationRequestPtr&); |