src/Manager/CompatibilityManager.cpp
src/Manager/ConfigurationManager.cpp
src/Manager/DatabaseManager.cpp
+ src/Manager/DeviceManager.cpp
src/Manager/InstallerManager.cpp
src/Manager/PermissionManager.cpp
src/Manager/SignatureManager.cpp
#include "InstallerUtil.h"
-#define OSP_INSTALLER_VERSION "version=[20130806.1]"
+#define OSP_INSTALLER_VERSION "version=[20130807.1]"
#define DIR_BIN L"/bin"
#define DIR_INFO L"/info"
INSTALLER_ERROR_FATAL_ERROR = 61,
INSTALLER_ERROR_OUT_OF_STORAGE = 62,
INSTALLER_ERROR_OUT_OF_MEMORY = 63,
+ INSTALLER_ERROR_DISABLED = 65,
+ INSTALLER_ERROR_PRIVILEGE_BLACKLIST = 66,
+ INSTALLER_ERROR_SIGNATURE_BLACKLIST = 67,
INSTALLER_ERROR_USER_CANCEL = 141,
INSTALLER_ERROR_UNMOUNT_FAILED = 142,
// data
srcPath = backupPath + DIR_DATA;
destPath = rootPath + DIR_DATA;
- InstallerUtil::CopyDirectory(srcPath, destPath);
+ InstallerUtil::CopyDirectory(srcPath, destPath, true);
InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
// setting
srcPath = backupPath + DIR_SETTING;
destPath = rootPath + DIR_SETTING;
- InstallerUtil::CopyDirectory(srcPath, destPath);
+ InstallerUtil::CopyDirectory(srcPath, destPath, true);
InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_WRITE, false);
smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_SETTINGS_RW);
// shared/data
srcPath = backupPath + DIR_SHARED_DATA;
destPath = rootPath + DIR_SHARED_DATA;
- InstallerUtil::CopyDirectory(srcPath, destPath);
+ InstallerUtil::CopyDirectory(srcPath, destPath, true);
InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PUBLIC_RO);
// shared/trust
srcPath = backupPath + DIR_SHARED_TRUSTED;
destPath = rootPath + DIR_SHARED_TRUSTED;
- InstallerUtil::CopyDirectory(srcPath, destPath);
+ InstallerUtil::CopyDirectory(srcPath, destPath, true);
InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_GROUP_RW);
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file DeviceManager.cpp
+ * @brief This is the implementation file for %DeviceManager class.
+ */
+
+#include <dlfcn.h>
+#include <unique_ptr.h>
+
+#include <FIoRegistry.h>
+#include <FBase_StringConverter.h>
+
+#include "DeviceManager.h"
+#include "InstallerDefs.h"
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Collection;
+using namespace Tizen::Io;
+
+DeviceManager::DeviceManager(void)
+:__pContext(null)
+,__isMdmEnable(false)
+{
+ if (IsMdmEnable() == true)
+ {
+ __isMdmEnable = true;
+ }
+}
+
+DeviceManager::~DeviceManager(void)
+{
+ if (__isMdmEnable == true)
+ {
+ ReleaseService();
+ }
+}
+
+bool
+DeviceManager::Construct(InstallationContext* pContext)
+{
+ __pContext = pContext;
+
+ return true;
+}
+
+bool
+DeviceManager::IsInstallationDisabled() const
+{
+ if (__isMdmEnable == false)
+ {
+ return false;
+ }
+
+ TryReturn(__pContext, false, "__pContext is null.");
+ TryReturn(__pContext->__packageId.IsEmpty() == false, false, "packageId is empty.");
+
+ std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(__pContext->__packageId));
+ TryReturn(pPackageId, false, "pPackageId is null.");
+
+ int res = IsInstallationDisabled(pPackageId.get());
+ if (res == 1)
+ {
+ AppLog("[%s] can't be installed.", pPackageId.get());
+ return true;
+ }
+ else
+ {
+ AppLog("[%s] can be installed.", pPackageId.get());
+ return false;
+ }
+}
+
+bool
+DeviceManager::IsUninstallationDisabled() const
+{
+ if (__isMdmEnable == false)
+ {
+ return false;
+ }
+
+ TryReturn(__pContext, false, "__pContext is null.");
+ TryReturn(__pContext->__packageId.IsEmpty() == false, false, "packageId is empty.");
+
+ std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(__pContext->__packageId));
+ TryReturn(pPackageId, false, "pPackageId is null.");
+
+ int res = IsUninstallationDisabled(pPackageId.get());
+ if (res == 1)
+ {
+ AppLog("[%s] can't be uninstalled.", pPackageId.get());
+ return true;
+ }
+ else
+ {
+ AppLog("[%s] can be uninstalled.", pPackageId.get());
+ return false;
+ }
+}
+
+bool
+DeviceManager::IsPrivilegeBlacklist() const
+{
+ if (__isMdmEnable == false)
+ {
+ return true;
+ }
+
+ TryReturn(__pContext, false, "__pContext is null.");
+ TryReturn(__pContext->__pPrivilegeList, false, "pPrivilegeList is null.");
+
+ return IsPrivilegeBlacklist(__pContext->__pPrivilegeList);
+}
+
+bool
+DeviceManager::IsSignatureBlacklist() const
+{
+ if (__isMdmEnable == false)
+ {
+ return true;
+ }
+
+ TryReturn(__pContext, false, "__pContext is null.");
+ TryReturn(__pContext->__pAuthorCertList, false, "pAuthorCertList is null.");
+
+ return IsSignatureBlacklist(__pContext->__pAuthorCertList);
+}
+
+bool
+DeviceManager::IsMdmEnable() const
+{
+ result r;
+ Registry reg;
+ String section(L"feature");
+ String entry(L"mdm");
+ String value;
+
+ r = reg.Construct(CONFIG_PATH, "r");
+ TryReturn(!IsFailed(r), false, "CONFIG file is not found.");
+
+ r = reg.GetValue(section, entry, value);
+ TryReturn(!IsFailed(r), false, "GetValue is failed. entry = [%ls]", entry.GetPointer());
+
+ AppLog("[%ls is %ls.]", entry.GetPointer(), value.GetPointer());
+
+ if (value == L"on")
+ {
+ if (GetService() == 0)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+int
+DeviceManager::GetService() const
+{
+ int ret = 0;
+ void* pHandle = null;
+ char* pErrorMsg = null;
+ int (*mdm_get_service)(void) = null;
+
+ pHandle = dlopen("/usr/lib/libmdm.so.1", RTLD_LAZY | RTLD_GLOBAL);
+ if (!pHandle)
+ {
+ AppLog("dlopen() failed. [%s]", dlerror());
+ return -1;
+ }
+
+ mdm_get_service = reinterpret_cast <int (*)(void)>(dlsym(pHandle, "mdm_get_service"));
+ pErrorMsg = dlerror();
+ if ((pErrorMsg != null) || (mdm_get_service == null))
+ {
+ AppLog("dlsym() failed. [%s]", pErrorMsg);
+ dlclose(pHandle);
+ return -1;
+ }
+
+ AppLog("[mdm] mdm_get_service()");
+ ret = mdm_get_service();
+ AppLog("[mdm] mdm_get_service, result = [%d]", ret);
+
+ dlclose(pHandle);
+
+ return ret;
+}
+
+int
+DeviceManager::ReleaseService() const
+{
+ int ret = 0;
+ void* pHandle = null;
+ char* pErrorMsg = null;
+ int (*mdm_release_service)(void) = null;
+
+ pHandle = dlopen("/usr/lib/libmdm.so.1", RTLD_LAZY | RTLD_GLOBAL);
+ if (!pHandle)
+ {
+ AppLog("dlopen() failed. [%s]", dlerror());
+ return -1;
+ }
+
+ mdm_release_service = reinterpret_cast <int (*)(void)>(dlsym(pHandle, "mdm_release_service"));
+ pErrorMsg = dlerror();
+ if ((pErrorMsg != null) || (mdm_release_service == null))
+ {
+ AppLog("dlsym() failed. [%s]", pErrorMsg);
+ dlclose(pHandle);
+ return -1;
+ }
+
+ AppLog("[mdm] mdm_release_service()");
+ ret = mdm_release_service();
+ AppLog("[mdm] mdm_release_service, result = [%d]", ret);
+
+ dlclose(pHandle);
+
+ return ret;
+}
+
+int
+DeviceManager::IsInstallationDisabled(const char* pPackageId) const
+{
+ int ret = 0;
+ void* pHandle = null;
+ char* pErrorMsg = null;
+ int (*mdm_get_application_installation_disabled)(const char*) = null;
+
+ pHandle = dlopen("/usr/lib/libmdm.so.1", RTLD_LAZY | RTLD_GLOBAL);
+ if (!pHandle)
+ {
+ AppLog("dlopen() failed. [%s]", dlerror());
+ return -1;
+ }
+
+ mdm_get_application_installation_disabled = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "mdm_get_application_installation_disabled"));
+ pErrorMsg = dlerror();
+ if ((pErrorMsg != null) || (mdm_get_application_installation_disabled == null))
+ {
+ AppLog("dlsym() failed. [%s]", pErrorMsg);
+ dlclose(pHandle);
+ return -1;
+ }
+
+ AppLog("[mdm] mdm_get_application_installation_disabled(%s)", pPackageId);
+ ret = mdm_get_application_installation_disabled(pPackageId);
+ AppLog("[mdm] mdm_get_application_installation_disabled(%s), result = [%d]", pPackageId, ret);
+
+ dlclose(pHandle);
+
+ return ret;
+}
+
+int
+DeviceManager::IsUninstallationDisabled(const char* pPackageId) const
+{
+ int ret = 0;
+ void* pHandle = null;
+ char* pErrorMsg = null;
+ int (*mdm_get_application_uninstallation_disabled)(const char*) = null;
+
+ pHandle = dlopen("/usr/lib/libmdm.so.1", RTLD_LAZY | RTLD_GLOBAL);
+ if (!pHandle)
+ {
+ AppLog("dlopen() failed. [%s]", dlerror());
+ return -1;
+ }
+
+ mdm_get_application_uninstallation_disabled = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "mdm_get_application_uninstallation_disabled"));
+ pErrorMsg = dlerror();
+ if ((pErrorMsg != null) || (mdm_get_application_uninstallation_disabled == null))
+ {
+ AppLog("dlsym() failed. [%s]", pErrorMsg);
+ dlclose(pHandle);
+ return -1;
+ }
+
+ AppLog("[mdm] mdm_get_application_uninstallation_disabled(%s)", pPackageId);
+ ret = mdm_get_application_uninstallation_disabled(pPackageId);
+ AppLog("[mdm] mdm_get_application_uninstallation_disabled(%s), result = [%d]", pPackageId, ret);
+
+ dlclose(pHandle);
+
+ return ret;
+}
+
+bool
+DeviceManager::IsPrivilegeBlacklist(ArrayList* pPrivilegeList) const
+{
+ //mdm_data_t *mdm_get_app_privilege_blacklist(void);
+ return true;
+}
+
+bool
+DeviceManager::IsSignatureBlacklist(IListT<String *>* pSignatureList) const
+{
+ //mdm_data_t *mdm_get_app_signature_blacklist(void);
+ return true;
+}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+/**
+ * @file DeviceManager.h
+ * @brief This is the header file for the %DeviceManager class.
+ *
+ * This header file contains the declarations of the %DeviceManager class.
+ */
+#ifndef _DEVICE_MANAGER_H_
+#define _DEVICE_MANAGER_H_
+
+#include "InstallationContext.h"
+
+class DeviceManager
+{
+public:
+ DeviceManager(void);
+ virtual ~DeviceManager(void);
+ bool Construct(InstallationContext* pContext);
+
+ bool IsInstallationDisabled() const;
+ bool IsUninstallationDisabled() const;
+ bool IsPrivilegeBlacklist() const;
+ bool IsSignatureBlacklist() const;
+
+private:
+ bool IsMdmEnable() const;
+ int GetService() const;
+ int ReleaseService() const;
+
+ int IsInstallationDisabled(const char* pPackageId) const;
+ int IsUninstallationDisabled(const char* pPackageId) const;
+ bool IsPrivilegeBlacklist(Tizen::Base::Collection::ArrayList* pPrivilegeList) const;
+ bool IsSignatureBlacklist(Tizen::Base::Collection::IListT<Tizen::Base::String *>* pSignatureList) const;
+
+private:
+ InstallationContext* __pContext;
+ bool __isMdmEnable;
+
+
+}; // DeviceManager
+
+#endif // _DEVICE_MANAGER_H_
#include "SystemCheckStep.h"
#include "ConfigurationManager.h"
#include "DatabaseManager.h"
+#include "DeviceManager.h"
using namespace Tizen::App;
using namespace Tizen::App::Package;
using namespace Tizen::Base::Collection;
SystemCheckStep::SystemCheckStep(void)
-:__state(STATE_VERSION_CHECK)
+:__state(STATE_POLICY_CHECK)
,__pContext(null)
{
}
{
switch (__state)
{
+ case STATE_POLICY_CHECK:
+ error = OnStatePolicyCheck();
+ break;
+
case STATE_VERSION_CHECK:
error = OnStateVersionCheck();
break;
error = OnStateBackup();
break;
- case STATE_AGENT_TIMER:
- error = OnStateAgentTimer();
- break;
-
case STATE_DONE:
error = OnStateDone();
break;
}
InstallerError
+SystemCheckStep::OnStatePolicyCheck(void)
+{
+ InstallerError error = INSTALLER_ERROR_NONE;
+
+ DeviceManager deviceManager;
+ deviceManager.Construct(__pContext);
+
+ bool res = deviceManager.IsInstallationDisabled();
+ TryReturn(res == false, INSTALLER_ERROR_DISABLED, "IsInstallationDisabled() failed.");
+
+ GoNextState();
+ return error;
+}
+
+InstallerError
SystemCheckStep::OnStateVersionCheck(void)
{
InstallerError error = INSTALLER_ERROR_NONE;
}
InstallerError
-SystemCheckStep::OnStateAgentTimer(void)
-{
- InstallerError error = INSTALLER_ERROR_NONE;
-
- GoNextState();
- return error;
-}
-
-InstallerError
SystemCheckStep::OnStateDone(void)
{
InstallerError error = INSTALLER_ERROR_NONE;
private:
enum
{
+ STATE_POLICY_CHECK,
STATE_VERSION_CHECK,
STATE_BACKUP,
- STATE_AGENT_TIMER,
STATE_DONE
};
};
void GoNextState(void);
+ InstallerError OnStatePolicyCheck(void);
InstallerError OnStateVersionCheck(void);
InstallerError OnStateBackup(void);
- InstallerError OnStateAgentTimer(void);
InstallerError OnStateDone(void);
int CompareVersion(const Tizen::Base::String& oldVersion, const Tizen::Base::String& newVersion);
#include "UninstallStep.h"
#include "InstallerUtil.h"
#include "CompatibilityManager.h"
+#include "DeviceManager.h"
using namespace Tizen::Base;
using namespace Tizen::Base::Collection;
error = OnStateGetPackageInfo();
break;
- case STATE_CHECK_APP_RUNNING:
- AppLog("[STATE_CHECK_APP_RUNNING]");
- error = OnStateCheckAppRunning();
+ case STATE_POLICY_CHECK:
+ AppLog("[STATE_POLICY_CHECK]");
+ error = OnStatePolicyCheck();
break;
case STATE_TERMINATE_APP:
}
delete pList;
- __state = STATE_TERMINATE_APP;
-
+ GoNextState();
return error;
}
-
InstallerError
-UninstallStep::OnStateCheckAppRunning(void)
+UninstallStep::OnStatePolicyCheck(void)
{
InstallerError error = INSTALLER_ERROR_NONE;
+ DeviceManager deviceManager;
+ deviceManager.Construct(__pContext);
+
+ bool res = deviceManager.IsUninstallationDisabled();
+ TryReturn(res == false, INSTALLER_ERROR_DISABLED, "IsUninstallationDisabled() failed.");
+
GoNextState();
return error;
}
enum
{
STATE_GET_PACKAGEINFO,
- STATE_CHECK_APP_RUNNING,
+ STATE_POLICY_CHECK,
STATE_TERMINATE_APP,
STATE_START_TIMER,
STATE_DELETE_DIR,
void GoNextState(void);
InstallerError OnStateGetPackageInfo(void);
- InstallerError OnStateCheckAppRunning(void);
+ InstallerError OnStatePolicyCheck(void);
InstallerError OnStateTerminateApp(void);
InstallerError OnStateStartTimer(void);
InstallerError OnStateRemoveDir(void);
}
bool
-InstallerUtil::Copy(const String& srcFilePath, const String& destFilePath)
+InstallerUtil::Copy(const String& srcFilePath, const String& destFilePath, bool failIfExist)
{
int bufSize = 4096;
int readBytes = 0;
result r = E_SUCCESS;
- // AppLog("+ Copy(): src=[%ls], dest=[%ls]", srcFilePath.GetPointer(), destFilePath.GetPointer());
+ if (failIfExist == true)
+ {
+ if (File::IsFileExist(destFilePath) == true)
+ {
+ AppLog("Copy(): des=[%ls]: skip", destFilePath.GetPointer());
+ return true;
+ }
+ }
File srcFile;
File destFile;
}
bool
-InstallerUtil::CopyDirectory(const String& srcFilePath, const String& destFilePath)
+InstallerUtil::CopyDirectory(const String& srcFilePath, const String& destFilePath, bool failIfExist)
{
result r = E_SUCCESS;
bool res = false;
{
// file
Directory::Create(destFilePath, true);
- InstallerUtil::Copy(srcEntryDir, destEntryDir);
+ InstallerUtil::Copy(srcEntryDir, destEntryDir, failIfExist);
}
else
{
Directory::Create(destEntryDir, true);
- CopyDirectory(srcEntryDir, destEntryDir);
+ CopyDirectory(srcEntryDir, destEntryDir, failIfExist);
}
}
virtual ~InstallerUtil(void);
static bool Remove(const Tizen::Base::String& filePath);
- static bool Copy(const Tizen::Base::String& srcFilePath, const Tizen::Base::String& destFilePath);
- static bool CopyDirectory(const Tizen::Base::String& srcFilePath, const Tizen::Base::String& destFilePath);
+ static bool Copy(const Tizen::Base::String& srcFilePath, const Tizen::Base::String& destFilePath, bool failIfExist = false);
+ static bool CopyDirectory(const Tizen::Base::String& srcFilePath, const Tizen::Base::String& destFilePath, bool failIfExist = false);
static bool IsSymlink(const Tizen::Base::String& filePath);
static bool GetRealPath(const Tizen::Base::String& filePath, Tizen::Base::String& realPath);