#include <common/step/configuration/step_parse_manifest.h>
#include <common/step/configuration/step_parse_preload.h>
#include <common/step/filesystem/step_acquire_external_storage.h>
+#include <common/step/filesystem/step_change_owner.h>
#include <common/step/filesystem/step_clear_data.h>
#include <common/step/filesystem/step_copy.h>
#include <common/step/filesystem/step_copy_storage_directories.h>
ci::Plugin::ActionType::Install);
AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
AddStep<ci::filesystem::StepCreateLegacyDirectories>();
+ AddStep<ci::filesystem::StepChangeOwner>();
}
void TpkInstaller::UpdateSteps() {
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<ci::pkgmgr::StepUpdateApplication>();
AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepChangeOwner>();
}
void TpkInstaller::UninstallSteps() {
AddStep<tpk::pkgmgr::StepManifestAdjustment>();
AddStep<ci::pkgmgr::StepUpdateApplication>();
AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepChangeOwner>();
}
void TpkInstaller::DeltaSteps() {
AddStep<tpk::pkgmgr::StepConvertXml>();
AddStep<ci::pkgmgr::StepUpdateApplication>();
AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepChangeOwner>();
}
void TpkInstaller::MoveSteps() {
ci::Plugin::ActionType::Install);
AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
AddStep<ci::filesystem::StepCreateLegacyDirectories>();
+ AddStep<ci::filesystem::StepChangeOwner>();
}
void TpkInstaller::MountUpdateSteps() {
AddStep<ci::pkgmgr::StepUpdateApplication>();
AddStep<tpk::filesystem::StepTpkGrantPermission>();
AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepChangeOwner>();
}
void TpkInstaller::ManifestDirectInstallSteps() {
AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Install);
AddStep<ci::filesystem::StepCreatePerUserStorageDirectories>();
AddStep<ci::filesystem::StepCreateLegacyDirectories>();
+ AddStep<ci::filesystem::StepChangeOwner>();
}
void TpkInstaller::ManifestDirectUpdateSteps() {
AddStep<ci::pkgmgr::StepUpdateApplication>();
AddStep<tpk::filesystem::StepTpkGrantPermission>();
AddStep<ci::pkgmgr::StepRunParserPlugin>(ci::Plugin::ActionType::Upgrade);
+ AddStep<ci::filesystem::StepChangeOwner>();
}
void TpkInstaller::ClearSteps() {
class ScopedTzipInterface {
public:
explicit ScopedTzipInterface(const std::string& pkgid)
- : pkg_path_(bf::path(ci::GetRootAppPath(false)) / pkgid),
+ : pkg_path_(bf::path(ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER))) / pkgid),
interface_(ci::GetMountLocation(pkg_path_)) {
interface_.MountZip(ci::GetZipPackageLocation(pkg_path_, pkgid));
}
};
void RemoveAllRecoveryFiles() {
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
if (!bf::exists(root_path))
return;
for (auto& dir_entry : boost::make_iterator_range(
}
bf::path FindRecoveryFile() {
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
for (auto& dir_entry : boost::make_iterator_range(
bf::directory_iterator(root_path), bf::directory_iterator())) {
if (bf::is_regular_file(dir_entry)) {
bool ValidateFileContentInPackage(const std::string& pkgid,
const std::string& relative,
const std::string& expected) {
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
bf::path file_path = root_path / pkgid / relative;
if (!bf::exists(file_path)) {
LOG(ERROR) << file_path << " doesn't exist";
}
void ValidatePackageFS(const std::string& pkgid, const std::string& appid) {
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
bf::path package_path = root_path / pkgid;
bf::path binary_path = package_path / "bin" / appid;
bf::path data_path = package_path / "data";
ASSERT_TRUE(bf::exists(cache_path));
bf::path manifest_path =
- bf::path(getUserManifestPath(getuid(), false)) / (pkgid + ".xml");
+ bf::path(getUserManifestPath(
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER), false)) / (pkgid + ".xml");
ASSERT_TRUE(bf::exists(manifest_path));
// backups should not exist
}
void PackageCheckCleanup(const std::string& pkgid, const std::string&) {
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
bf::path package_path = root_path / pkgid;
ASSERT_FALSE(bf::exists(package_path));
bf::path manifest_path =
- bf::path(getUserManifestPath(getuid(), false)) / (pkgid + ".xml");
+ bf::path(getUserManifestPath(
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER), false)) / (pkgid + ".xml");
ASSERT_FALSE(bf::exists(manifest_path));
// backups should not exist
}
void ValidatePackage(const std::string& pkgid, const std::string& appid) {
- ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ASSERT_TRUE(ci::QueryIsPackageInstalled(
+ pkgid, ci::GetRequestMode(tzplatform_getuid(TZ_SYS_DEFAULT_USER)),
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER)));
ValidatePackageFS(pkgid, appid);
}
void CheckPackageNonExistance(const std::string& pkgid,
const std::string& appid) {
- ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ASSERT_FALSE(ci::QueryIsPackageInstalled(
+ pkgid, ci::GetRequestMode(tzplatform_getuid(TZ_SYS_DEFAULT_USER)),
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER)));
PackageCheckCleanup(pkgid, appid);
}
ValidatePackage(pkgid, appid);
// Check delta modifications
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
ASSERT_FALSE(bf::exists(root_path / pkgid / "DELETED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "ADDED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "bin" / "native"));
ValidatePackage(pkgid, appid);
// Check rds modifications
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
ASSERT_FALSE(bf::exists(root_path / pkgid / "DELETED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "ADDED"));
ASSERT_TRUE(bf::exists(root_path / pkgid / "bin" / "native"));
ASSERT_EQ(Install(path), ci::AppInstaller::Result::OK);
ASSERT_EQ(DisablePackage(pkgid), ci::AppInstaller::Result::OK);
ASSERT_EQ(EnablePackage(pkgid), ci::AppInstaller::Result::OK);
- ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ASSERT_TRUE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode(
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER)),
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER)));
}
TEST_F(SmokeTest, DisablePkg) {
std::string appid = "smokeapp23.DisablePkg";
ASSERT_EQ(Install(path), ci::AppInstaller::Result::OK);
ASSERT_EQ(DisablePackage(pkgid), ci::AppInstaller::Result::OK);
- ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode()));
+ ASSERT_FALSE(ci::QueryIsPackageInstalled(pkgid, ci::GetRequestMode(
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER)),
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER)));
ValidatePackageFS(pkgid, {appid});
}
std::string pkgid = "smokeapp21";
std::string appid = "smokeapp21.ClearModeTpk";
ASSERT_EQ(Install(path), ci::AppInstaller::Result::OK);
- bf::path root_path = ci::GetRootAppPath(false);
+ bf::path root_path = ci::GetRootAppPath(false,
+ tzplatform_getuid(TZ_SYS_DEFAULT_USER));
bs::error_code error;
bf::create_directory(root_path / pkgid / "data" / "dir", error);
ASSERT_FALSE(error);