To verify, run smoke tests.
Change-Id: I8385063372281fe26d67a558bf2f54e48394de3b
context_->pkg_type.set(package_type);
context_->installation_mode.set(pkgmgr->GetInstallationMode());
- if (pkgmgr->ShouldCreateSignal()) {
- if (context_->installation_mode.get() == InstallationMode::ONLINE) {
- // pkgmgr signal should work only for online mode
- // there is no one to receive it in offline mode
- pi_.reset(new PkgmgrSignal(pkgmgr.get()->GetRawPi(),
- pkgmgr->GetRequestType()));
- }
+ // pkgmgr signal should work only for online mode
+ // there is no one to receive it in offline mode
+ if (context_->installation_mode.get() == InstallationMode::ONLINE) {
+ pi_ = pkgmgr->CreatePkgmgrSignal();
}
}
#include <fstream>
#include "common/app_query_interface.h"
+#include "common/pkgmgr_signal.h"
namespace bf = boost::filesystem;
true:false;
}
+std::unique_ptr<PkgmgrSignal> PkgMgrInterface::CreatePkgmgrSignal() const {
+ if (!pkgmgr_installer_interface_->ShouldCreateSignal())
+ return nullptr;
+ return std::unique_ptr<PkgmgrSignal>(new PkgmgrSignal(pi_, GetRequestType()));
+}
+
bool PkgMgrInterface::GetIsForceRemoval() {
// root only
return (getuid() == 0 && pkgmgr_installer_get_force_removal(pi_) == 1);
OFFLINE
};
+class PkgmgrSignal;
class PkgMgrInterface;
typedef std::shared_ptr<PkgMgrInterface> PkgMgrPtr;
class PkgmgrInstaller : public PkgmgrInstallerInterface {
public:
bool CreatePkgMgrInstaller(pkgmgr_installer** installer,
- InstallationMode* mode);
- bool ShouldCreateSignal() const;
+ InstallationMode* mode) override;
+ bool ShouldCreateSignal() const override;
};
/**
InstallationMode GetInstallationMode() const { return install_mode_; }
/**
- * @brief ShouldCreateSignal
+ * @brief CreatePkgmgrSignal
*
- *
- * @return true if pkgmgr signal should be created
+ * @return creates pkgmgr signal
*/
- bool ShouldCreateSignal() const {
- return pkgmgr_installer_interface_->ShouldCreateSignal();
- }
+ std::unique_ptr<PkgmgrSignal> CreatePkgmgrSignal() const;
/** PkgMgrInstance destructor. */
~PkgMgrInterface();
}
if (sec_install_type != ci::SecurityAppInstallType::None) {
- app_install_type type;
+ app_install_type type = SM_APP_INSTALL_NONE;
switch (sec_install_type) {
case ci::SecurityAppInstallType::Local:
case ci::SecurityAppInstallType::Global:
type = SM_APP_INSTALL_GLOBAL;
break;
+ case ci::SecurityAppInstallType::None:
+ break;
+ default:
+ break;
}
LOG(INFO) << "install_type(" << type << ")";
bool CreateDirectories(const bf::path& app_dir, const std::string& pkgid,
const std::string& author_id,
- const std::string& api_version,
uid_t uid, gid_t gid, const bool set_permissions) {
bf::path base_dir = app_dir / pkgid;
if (bf::exists(base_dir)) {
}
bool CreateUserDirectories(uid_t user, const std::string& pkgid,
- const std::string& author_id, const std::string& api_version,
+ const std::string& author_id,
const std::string& apps_prefix, const bool set_permissions) {
struct passwd* pwd = getpwuid(user); // NOLINT
<< pwd->pw_gid;
bf::path apps_rw = GetDirectoryPathForStorage(user, apps_prefix);
- if (!CreateDirectories(apps_rw, pkgid, author_id, api_version,
+ if (!CreateDirectories(apps_rw, pkgid, author_id,
pwd->pw_uid, pwd->pw_gid, set_permissions)) {
return false;
}
bool PerformInternalDirectoryCreationForUser(uid_t user,
const std::string& pkgid,
- const std::string& author_id,
- const std::string& api_version) {
+ const std::string& author_id) {
const char* internal_storage_prefix = tzplatform_getenv(TZ_SYS_HOME);
const bool set_permissions = true;
- if (!CreateUserDirectories(user, pkgid, author_id, api_version,
+ if (!CreateUserDirectories(user, pkgid, author_id,
internal_storage_prefix, set_permissions))
return false;
return true;
bool PerformExternalDirectoryCreationForUser(uid_t user,
const std::string& pkgid,
- const std::string& author_id,
- const std::string& api_version) {
+ const std::string& author_id) {
const char* storage_path = tzplatform_mkpath(TZ_SYS_MEDIA,
kExternalStorageDirPrefix);
const bool set_permissions = false;
return false;
}
- if (CreateUserDirectories(user, pkgid, author_id, api_version,
+ if (CreateUserDirectories(user, pkgid, author_id,
storage_path, set_permissions)) {
}
return true;
}
bool PerformInternalDirectoryCreationForAllUsers(const std::string& pkgid,
- const std::string& author_id,
- const std::string& api_ver) {
+ const std::string& author_id) {
for (bf::directory_iterator iter(tzplatform_getenv(TZ_SYS_HOME));
iter != bf::directory_iterator();
++iter) {
if (!PerformInternalDirectoryCreationForUser(pwd->pw_uid,
pkgid,
- author_id,
- api_ver))
+ author_id))
LOG(ERROR) << "Could not create internal storage directories for user: "
<< user.c_str();
}
}
bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid,
- const std::string& author_id,
- const std::string& api_ver) {
+ const std::string& author_id) {
for (bf::directory_iterator iter(tzplatform_getenv(TZ_SYS_HOME));
iter != bf::directory_iterator();
++iter) {
-
try {
if (!bf::is_directory(iter->path())) continue;
}
if (!PerformExternalDirectoryCreationForUser(pwd->pw_uid,
pkgid,
- author_id,
- api_ver))
+ author_id))
LOG(WARNING) << "Could not create external storage directories for user: "
<< user.c_str();
}
*
* \param pkgid id of package
* \param author_id id of author
- * \param api_version api version
* \param create_skel_directories flag
*
* \return true if succeed, false otherwise
*/
bool PerformInternalDirectoryCreationForUser(uid_t uid,
const std::string& pkgid,
- const std::string& author_id,
- const std::string& api_version);
+ const std::string& author_id);
/**
* \brief Performs a creation of directories for specific user in external storage
*
* \param pkgid id of package
* \param author_id id of author
- * \param api_version api version
* \param create_skel_directories flag
*
* \return true if succeed, false otherwise
*/
bool PerformExternalDirectoryCreationForUser(uid_t uid,
const std::string& pkgid,
- const std::string& author_id,
- const std::string& api_version);
+ const std::string& author_id);
/**
* \brief Performs a creation of directories in internal storage
*
* \param pkgid id of package
* \param author_id id of author
- * \param api_version api version
* \param create_skel_directories flag
*
* \return true if succeed, false otherwise
*
*/
bool PerformInternalDirectoryCreationForAllUsers(const std::string& pkgid,
- const std::string& author_id,
- const std::string& apiversion);
+ const std::string& author_id);
/**
* \brief Performs a creation of directories in external storage (eg. SD card)
*
* \param pkgid id of package
* \param author_id id of author
- * \param api_version api version
* \param create_skel_directories flag
*
* \return true if succeed, false otherwise
*
*/
bool PerformExternalDirectoryCreationForAllUsers(const std::string& pkgid,
- const std::string& author_id,
- const std::string& apiversion);
+ const std::string& author_id);
/**
* \brief Performs deletion of directories
case RequestMode::GLOBAL: {
LOG(DEBUG) << "Creating external directories for all users";
PerformExternalDirectoryCreationForAllUsers(pkg.pkg_id,
- pkg.author_id,
- pkg.api_version);
+ pkg.author_id);
}
break;
case RequestMode::USER: {
LOG(DEBUG) << "Creating external directories for user: "
<< context_->uid.get();
PerformExternalDirectoryCreationForUser(context_->uid.get(),
- pkg.pkg_id,
- pkg.author_id,
- pkg.api_version);
+ pkg.pkg_id,
+ pkg.author_id);
}
break;
}
#include <app_manager.h>
#include <app_manager_extension.h>
+#include <sys/time.h>
#include <string>
-#include <sys/time.h>
#include "common/utils/glist_range.h"
LOG(DEBUG) << "kill waiting count (" << i << ")";
break;
}
- usleep(100000); // 100msec
+ usleep(100000); // 100msec
if (i == 10)
LOG(ERROR) << "kill timeout";
}
// Use of this source code is governed by a apache 2.0 license that can be
// found in the LICENSE file.
-#ifndef COMMON_RDS_STEP_RDS_MODIFY_H_
-#define COMMON_RDS_STEP_RDS_MODIFY_H_
+#ifndef COMMON_STEP_RDS_STEP_RDS_MODIFY_H_
+#define COMMON_STEP_RDS_STEP_RDS_MODIFY_H_
#include <boost/filesystem.hpp>
#include <common/step/step.h>
} // namespace rds
} // namespace common_installer
-#endif // COMMON_RDS_STEP_RDS_MODIFY_H_
+#endif // COMMON_STEP_RDS_STEP_RDS_MODIFY_H_
// Use of this source code is governed by a apache 2.0 license that can be
// found in the LICENSE file.
-#ifndef COMMON_RDS_STEP_RDS_PARSE_H_
-#define COMMON_RDS_STEP_RDS_PARSE_H_
+#ifndef COMMON_STEP_RDS_STEP_RDS_PARSE_H_
+#define COMMON_STEP_RDS_STEP_RDS_PARSE_H_
#include <common/step/step.h>
} // namespace rds
} // namespace common_installer
-#endif // COMMON_RDS_STEP_RDS_PARSE_H_
+#endif // COMMON_STEP_RDS_STEP_RDS_PARSE_H_
auto dir_operation = ParseDirectoryOptions(opt_map);
auto pkgs = GetPackageListFromArgs(opt_map);
- auto create_skel_dirs = true;
for (auto& p : pkgs) {
switch (dir_operation) {
case DirectoryOperation::CREATE_INTERNAL: {
LOG(DEBUG) << "Running directory creation for package id: " << p.pkg_id;
ci::PerformInternalDirectoryCreationForAllUsers(p.pkg_id,
- p.api_version,
p.author_id);
const std::string pkg_path = ci::GetDirectoryPathForInternalStorage();
ci::SetPackageDirectorySmackRulesForAllUsers(pkg_path,
PrivilegeLevel level = PrivilegeLevel::UNTRUSTED;
common_installer::CertificateInfo cert_info;
std::string error;
- EXPECT_EQ(ValidateSignatures(*signature_file, &level, &cert_info, true, &error),
- Step::Status::OK);
+ EXPECT_EQ(ValidateSignatures(*signature_file, &level, &cert_info, true,
+ &error), Step::Status::OK);
}
// Tests signature verifier with signature directory containing bad signatures
PrivilegeLevel level = PrivilegeLevel::UNTRUSTED;
common_installer::CertificateInfo cert_info;
std::string error;
- EXPECT_EQ(ValidateSignatures(*signature_file, &level, &cert_info, true, &error),
- Step::Status::ERROR);
+ EXPECT_EQ(ValidateSignatures(*signature_file, &level, &cert_info, true,
+ &error), Step::Status::ERROR);
}
} // namespace security