namespace {
const mode_t PRIVATE_STORAGE_MODE = 0700;
-const mode_t SHARE_MODE = 0705;
+const mode_t SHARED_STORAGE_MODE = 0755;
}
using namespace WrtDB;
return true;
}
-void changeOwnerForDirectory(std::string storagePath) {
+void changeOwnerForDirectory(std::string storagePath, mode_t mode) {
if (euidaccess(storagePath.c_str(), F_OK) != 0) {
- if (!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)) {
- LogError("Failed to create directory for private storage");
+ if (!WrtUtilMakeDir(storagePath, mode)) {
+ LogError("Failed to create directory : " << storagePath);
ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
- "Failed to create directory for private storage");
+ "Failed to create directory : " << storagePath);
}
// '5000' is default uid, gid for applications.
// So installed applications should be launched as process of uid
"Chown to invaild user");
}
} else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) {
- LogInfo("Private storage already exists.");
+ LogInfo(storagePath << " already exists.");
// Even if private directory already is created, private dircetory
// should change owner.
if (chown(storagePath.c_str(),
ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
"Chown to invaild user");
}
- if (chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) {
+ if (chmod(storagePath.c_str(), mode) != 0) {
ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
"chmod to 0700");
}
"Error occurs copy private strage files");
}
}
- changeOwnerForDirectory(storagePath);
+ changeOwnerForDirectory(storagePath, PRIVATE_STORAGE_MODE);
std::string tempStoragePath = m_context.locations->getPrivateTempStorageDir();
LogDebug("Create temp private storage directory : " << tempStoragePath);
- changeOwnerForDirectory(tempStoragePath);
+ changeOwnerForDirectory(tempStoragePath, PRIVATE_STORAGE_MODE);
}
void TaskFileManipulation::StepRenamePath()
ThrowMsg(Exceptions::FileOperationFailed,
"Symbolic link creating is not done.");
}
- changeOwnerForDirectory(dataDir);
+ changeOwnerForDirectory(dataDir, PRIVATE_STORAGE_MODE);
}
if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) {
}
} else {
WrtUtilMakeDir(m_context.locations->getSharedResourceDir());
- WrtUtilMakeDir(m_context.locations->getSharedDataDir());
- WrtUtilMakeDir(m_context.locations->getSharedTrustedDir());
+ changeOwnerForDirectory(m_context.locations->getSharedDataDir(),
+ SHARED_STORAGE_MODE);
+ changeOwnerForDirectory(m_context.locations->getSharedTrustedDir(),
+ SHARED_STORAGE_MODE);
}
}
} //namespace WidgetInstall