From: Lukasz Kostyra Date: Mon, 13 Oct 2014 12:02:40 +0000 (+0200) Subject: Allow SCS to launch without any container X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7ce7abac455827aef85ae5a8f369c25ba5331d4f;p=platform%2Fcore%2Fsecurity%2Fvasum.git Allow SCS to launch without any container [Bug] SCS segfaulted when launching without any containers provided in config. [Cause] Some functions assumed that certain config fields should never be empty [Solution] Additional checks to avoid segfault. [Verification] Build, install, run tests, launch SCS without any predefined containers. Try to switch between containers when less than two containers are present. Change-Id: I58a69d55807f686fb168057dfb1b447707351a46 --- diff --git a/server/containers-manager.cpp b/server/containers-manager.cpp index d8858ab..c9c7ff8 100644 --- a/server/containers-manager.cpp +++ b/server/containers-manager.cpp @@ -112,7 +112,7 @@ ContainersManager::ContainersManager(const std::string& managerConfigPath): mDet } // check if default container exists, throw ContainerOperationException if not found - if (mContainers.find(mConfig.defaultId) == mContainers.end()) { + if (!mConfig.defaultId.empty() && mContainers.find(mConfig.defaultId) == mContainers.end()) { LOGE("Provided default container ID " << mConfig.defaultId << " is invalid."); throw ContainerOperationException("Provided default container ID " + mConfig.defaultId + " is invalid."); @@ -219,9 +219,11 @@ void ContainersManager::startAll() return c1.second->getPrivilege() < c2.second->getPrivilege(); }); - mConfig.foregroundId = foregroundIterator->second->getId(); - LOGI(mConfig.foregroundId << ": no foreground container configured, setting one with highest priority"); - foregroundIterator->second->goForeground(); + if (foregroundIterator != mContainers.end()) { + mConfig.foregroundId = foregroundIterator->second->getId(); + LOGI(mConfig.foregroundId << ": no foreground container configured, setting one with highest priority"); + foregroundIterator->second->goForeground(); + } } } @@ -269,7 +271,10 @@ void ContainersManager::switchingSequenceMonitorNotify() LOGI("switchingSequenceMonitorNotify() called"); auto nextContainerId = getNextToForegroundContainerId(); - focus(nextContainerId); + + if (!nextContainerId.empty()) { + focus(nextContainerId); + } }