#ifndef _INSTALLER_DEFS_H_
#define _INSTALLER_DEFS_H_
-#define OSP_INSTALLER_VERSION "osp-installer version = [2012/12/27]_RC[1]"
+#define OSP_INSTALLER_VERSION "osp-installer version = [2012/12/27]_RC[2]"
#define DIR_BIN L"/bin"
#define DIR_INFO L"/info"
#define DIR_MEMORYCARD_OSP_APPLICATIONS_TEMP L"/opt/storage/sdcard/apps/__@@osp_tmp@@__"
#define DIR_MEMORYCARD_INSTALLATION L"/opt/storage/sdcard/installtosdcard"
+#define PERM_BASE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) // 0644
+#define PERM_EXECUTE (S_IXUSR | S_IXGRP | S_IXOTH)
+#define PERM_WRITE (S_IWUSR | S_IWGRP | S_IWOTH)
+
static const int BLOCK_SIZE = 4096;
#define OSP_INSTALLER "osp-installer"
pPackageInfoImpl = pContext->GetPackageInfoImpl();
appRootPath = pPackageInfoImpl->GetAppRootPath();
- // appRoot(rx for app)
- InstallerUtil::ChangeOwner(appRootPath);
- InstallerUtil::ChangeMode(appRootPath, S_IRUSR | S_IXUSR);
+ // appRoot
+ // InstallerUtil::ChangeOwner(appRootPath);
+ InstallerUtil::ChangeMode(appRootPath, PERM_BASE | PERM_EXECUTE);
- // appRoot/bin(rx for app)
+ // appRoot/bin
destPath = appRootPath + DIR_BIN;
- InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE);
- // appRoot/info(rx for app)
+ // appRoot/info
destPath = appRootPath + DIR_INFO;
- InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE);
- // appRoot/res(rx for app)
+ // appRoot/res
destPath = appRootPath + DIR_RES;
- InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE);
- // appRoot/lib(rwx for app)
+ // appRoot/lib
destPath = appRootPath + DIR_LIB;
- InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE);
- // appRoot/icons(rx for app)
+ // appRoot/icons
destPath = appRootPath + DIR_SHARED_RES;
if (File::IsFileExist(destPath) == false)
{
String iconPath = appRootPath + DIR_ICONS;
InstallerUtil::CreateSymlink(iconPath, destPath);
}
- InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE);
- // appRoot/contents(rx for app)
+ // appRoot/contents
destPath = appRootPath + DIR_CONTENTS;
- InstallerUtil::ChangeDirectoryPermission(destPath, S_IRUSR | S_IXUSR);
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE);
- // appRoot/setting(rwx for app)
+ // appRoot/setting
destPath = appRootPath + DIR_SETTING;
r = File::GetAttributes(destPath, attribute);
if (r == E_SUCCESS)
InstallerUtil::Remove(settingXmlPath);
InstallerUtil::CreateSymlink(srcPath, settingXmlPath);
- InstallerUtil::ChangeDirectoryPermission(destPath, S_IRWXU);
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_WRITE);
}
- // appRoot/data(rwx for app)
+ // appRoot/data
destPath = appRootPath + DIR_DATA;
if (File::IsFileExist(destPath) == false)
{
r = Directory::Create(destPath, false);
TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "[osp-installer] Directory::Create() failed");
}
- InstallerUtil::ChangeDirectoryPermission(destPath, S_IRWXU);
+ InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
String appId = pContext->GetAppId();
String apiVersion = pPackageInfoImpl->GetAppApiVersion();
}
bool
-InstallerUtil::ChangeDirectoryPermission(const String& filePath, int mode)
+InstallerUtil::ChangeDirectoryPermission(const String& filePath, int mode, bool isOwnerChanged)
{
result r = E_SUCCESS;
bool res = false;
- AppLogTag(OSP_INSTALLER, "+ ChangeDirectoryPermission(): path=[%ls], mode=[%04o]", filePath.GetPointer(), mode);
+ AppLogTag(OSP_INSTALLER, "+ ChangeDirectoryPermission(): path=[%ls], mode=[%04o], isOwnerChanged=[%s]",
+ filePath.GetPointer(), mode, isOwnerChanged?"true":"false");
res = File::IsFileExist(filePath);
if (res == false)
if (entryName == L".")
{
- InstallerUtil::ChangeOwner(entryDir);
- InstallerUtil::ChangeMode(entryDir, mode);
+ if (isOwnerChanged == true)
+ {
+ InstallerUtil::ChangeOwner(entryDir);
+ }
+ InstallerUtil::ChangeMode(entryDir, mode | PERM_EXECUTE);
continue;
}
else if (entryName == L"..")
if (entry.IsDirectory() == false)
{
- InstallerUtil::ChangeOwner(entryDir);
+ if (isOwnerChanged == true)
+ {
+ InstallerUtil::ChangeOwner(entryDir);
+ }
InstallerUtil::ChangeMode(entryDir, mode);
}
else
{
ChangeDirectoryPermission(entryDir, mode);
- InstallerUtil::ChangeMode(entryDir, mode);
+ InstallerUtil::ChangeMode(entryDir, mode | PERM_EXECUTE);
}
}