void AppInstallHelper::createInstallDir() {
create(mkdir, getInstallDir());
+ m_isInstallDirCreated = true;
}
void AppInstallHelper::createTrustedDir(int i) {
m_fileTypeMap.clear();
rmdir(m_installDir.c_str());
+ m_isInstallDirCreated = false;
}
void AppInstallHelper::setInstallPath() {
}
bool AppInstallHelper::create(std::function<int(const char*, mode_t)> &&creatFun, const std::string &path) {
+ if (!m_isInstallDirCreated && path != getInstallDir())
+ createInstallDir();
if (creatFun(path.c_str(), 0751) == 0) {
// Local paths need user change
if (!m_isLocal || chown(path.c_str(), m_uidGid, m_uidGid) == 0)
uid_t uid,
std::string version = std::string())
: m_appName(appNamePrefix), m_pkgName(pkgNamePrefix), m_isLocal(isLocal), m_uidGid(uid), m_version(version),
- m_installType(SM_APP_INSTALL_NONE), m_isHybrid(false), m_creatorPid(getpid())
+ m_installType(SM_APP_INSTALL_NONE), m_isHybrid(false), m_isInstallDirCreated(false), m_creatorPid(getpid())
{
setInstallPath();
}
app_install_type m_installType;
bool m_isHybrid;
std::string m_installDir;
+ bool m_isInstallDirCreated;
TypePathsMap m_dirTypeMap;
TypePathsMap m_fileTypeMap;
std::vector<std::string> m_privileges;
};
AppInstallHelper app("sm_test_02");
- app.createInstallDir();
app.createPrivateDir();
app.createPrivateRODir();
app.createPublicDir();
// gumd
testUser.remove();
-
+
// FIXME - whitebox - db
check_app_after_uninstall(app.getAppId(), app.getPkgId(), true);
check_app_permissions(app.getAppId(), app.getPkgId(), testUser.getUidString(), {}, somePrivs);
std::string childUidStr = normalUser.getUidString();
AppInstallHelper adminApp("sm_test_21_admin", adminUser.getUid());
- adminApp.createInstallDir();
adminApp.addPrivileges(adminRequiredPrivs);
ScopedInstaller adminAppInstall(adminApp);
AppInstallHelper normalApp("sm_test_21_normal", normalUser.getUid());
- normalApp.createInstallDir();
normalApp.addPrivileges(manifestPrivs);
ScopedInstaller normalAppInstall(normalApp);
testUser.create();
AppInstallHelper app("sm_test_25e");
- app.createInstallDir();
change_label("_");
RUNNER_ASSERT_ERRNO_MSG(drop_root_privileges(testUser.getUid(), testUser.getGid()) == 0,
testUser.create();
AppInstallHelper app("sm_test_25f");
- app.createInstallDir();
change_label("_");
RUNNER_ASSERT_ERRNO_MSG(drop_root_privileges(testUser.getUid(), testUser.getGid()) == 0,
testUser.create();
AppInstallHelper app("sm_test_25g", testUser.getUid());
- app.createInstallDir();
app.createPrivateDir();
app.setInstallType(SM_APP_INSTALL_LOCAL);
app.addPrivileges(allowedPrivs);
testUser.create();
AppInstallHelper app("sm_test_25h", testUser.getUid());
- app.createInstallDir();
app.createPrivateDir();
InstallRequest invalidReq;
testUser.create();
AppInstallHelper app("sm_test_25i", testUser.getUid());
- app.createInstallDir();
app.createPrivateDir();
InstallRequest invalidReq;
// This test depends on order of checks in security-manager service implementation
AppInstallHelper owner("installedApp");
owner.revokeRules();
- owner.createInstallDir();
InstallRequest ownerInst;
ownerInst.setAppId(owner.getAppId());
ownerInst.setPkgId(owner.getPkgId());
// This test depends on order of checks in security-manager service implementation
AppInstallHelper owner("installedApp");
owner.revokeRules();
- owner.createInstallDir();
InstallRequest ownerInst = createInstallReq(owner);
Api::install(ownerInst);
AppInstallHelper target("secondInstalledApp");
target.revokeRules();
- target.createInstallDir();
InstallRequest targetInst = createInstallReq(target);
Api::install(targetInst);
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
// cleanup
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
owner.createSharedFile();
// cleanup
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
owner.createSharedFile(0);
// cleanup
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
owner.createSharedFile();
// cleanup
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
owner.createSharedFile(0);
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
// cleanup
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
owner.createSharedFile();
// cleanup
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
}
owner.createPrivateDir();
owner.createSharedFile();
const uid_t OWNER_UID = 5001;
bool appIsLocal = true;
AppInstallHelper appInstallHelper(appName, pkgName, appIsLocal, OWNER_UID, version);
-
- appInstallHelper.createInstallDir();
-
if (isSharedRO)
appInstallHelper.createSharedRODir();
user.create();
AppInstallHelper app("sm_test_54", user.getUid());
- app.createInstallDir();
app.createPrivateDir();
PathsRequest req;
TemporaryTestUser user("sm_test_55_user_name", GUM_USERTYPE_NORMAL, false);
user.create();
AppInstallHelper app("sm_test_55", user.getUid());
- app.createInstallDir();
app.createPrivateDir();
PathsRequest req;
AppInstallHelper app("sm_test_57", user.getUid());
ScopedInstaller appInstall(app);
- app.createInstallDir();
app.createPrivateDir();
PathsRequest preq;
preq.setPkgId(app.getPkgId());
AppInstallHelper app("sm_test_59", user.getUid());
ScopedInstaller appInstall(app);
- app.createInstallDir();
app.createPrivateDir();
PathsRequest preq;
preq.setPkgId(app.getPkgId());
user.create();
AppInstallHelper app("sm_test_60", user.getUid());
- app.createInstallDir();
ScopedInstaller appInstall(app);
RUNNER_ASSERT_ERRNO_MSG(drop_root_privileges(user.getUid(), user.getGid()) == 0,
AppInstallHelper app("sm_test_61", user2.getUid());
ScopedInstaller appInstall(app);
- app.createInstallDir();
app.createPrivateDir();
pid_t pid = fork();
AppInstallHelper app("sm_test_63", user.getUid());
ScopedInstaller appInstall(app);
- app.createInstallDir();
app.createPrivateDir();
int result = drop_root_privileges(user.getUid(), user.getGid());
AppInstallHelper app("sm_test_63", user.getUid());
ScopedInstaller appInstall(app);
- app.createInstallDir();
app.createPrivateDir();
int result = drop_root_privileges(user.getUid(), user.getGid());
user.create();
AppInstallHelper app("sm_test_64", user.getUid());
- app.createInstallDir();
ScopedInstaller appInstall(app);
app.createPrivateDir();
user.create();
AppInstallHelper app("sm_test_64", user.getUid());
- app.createInstallDir();
ScopedInstaller appInstall(app);
app.createPrivateDir();
ScopedInstaller appInstall(app);
- app.createInstallDir();
app.createPrivateDir();
app.createPrivateRODir();
app.createPublicDir();
app.setVersion("3.0");
ScopedInstaller appInstall(app);
- app.createInstallDir();
app.createSharedRODir();
PathsRequest preq;
app.setVersion("2.4");
ScopedInstaller appInstall(app);
- app.createInstallDir();
app.createSharedRODir();
PathsRequest preq;
AppInstallHelper app("sm_test_69", user.getUid());
ScopedInstaller appInstall(app);
- app.createInstallDir();
app.createTrustedDir();
PathsRequest preq;
app.setAuthor("sm_test_70_author");
ScopedInstaller appInstall(app);
- app.createInstallDir();
app.createTrustedDir();
PathsRequest preq;
// cleanup
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
e.createTrustedDir();
}
RUNNER_TEST(security_manager_44_app_install_with_trusted_path_no_author_id)
{
AppInstallHelper help("app44");
- help.createInstallDir();
help.createTrustedDir();
// install app with shared/trusted dir but without authors id
// cleanup
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
e.createTrustedDir();
}
for (auto &e : helper) {
e.revokeRules();
- e.createInstallDir();
e.createTrustedDir();
}