return req_ != NULL;
}
bool PrepareBasic(const std::string& pkg_id, uid_t uid,
- const std::string& type = "" ) {
+ const std::string& type) {
if (pkg_id.empty() || type.empty()) {
LOG(ERROR) << "Invalid parameter";
return false;
return result;
}
-static bool UnregisterSecurityContext(const std::string& pkg_id, uid_t uid,
+static bool UnregisterSecurityContext(const std::string& pkg_id,
+ const std::string& pkg_type, uid_t uid,
const std::vector<std::string>& appids, std::string* error_message) {
SecurityContextRequest req;
if (!req.IsValid()) {
*error_message = req.ErrorMessage();
return false;
}
- if (!req.PrepareBasic(pkg_id, uid)) {
+ if (!req.PrepareBasic(pkg_id, uid, pkg_type)) {
*error_message = req.ErrorMessage();
return false;
}
}
bool UnregisterSecurityContextForManifest(const std::string& pkg_id,
- uid_t uid, manifest_x* manifest, std::string* error_message) {
+ const std::string& pkg_type, uid_t uid, manifest_x* manifest,
+ std::string* error_message) {
std::vector<std::string> appids;
for (application_x* app : GListRange<application_x*>(manifest->application)) {
if (!app->appid) {
}
appids.emplace_back(app->appid);
}
- return UnregisterSecurityContext(pkg_id, uid, appids, error_message);
+ return UnregisterSecurityContext(pkg_id, pkg_type, uid,
+ appids, error_message);
}
bool UnregisterSecurityContextForPkgId(const std::string &pkg_id,
- uid_t uid, std::string* error_message, bool ignore_data_absence) {
+ const std::string& pkg_type, uid_t uid, std::string* error_message, bool ignore_data_absence) {
std::vector<std::string> appids;
ci::PkgQueryInterface pkg_query(pkg_id, uid);
if (!pkg_query.AppidsForPkgId(&appids))
return ignore_data_absence;
- return UnregisterSecurityContext(pkg_id, uid, appids, error_message);
+ return UnregisterSecurityContext(pkg_id, pkg_type, uid,
+ appids, error_message);
}
bool RegisterSecurityContextForPath(const std::string &pkg_id,
* package from security context
*
* \param pkg_id pkgid of given package
+ * \param pkg_type type of given package*
* \param uid uid
* \param manifest pointer to manifest structure
* \param error_message extra/detailed error message
*
* \return true if success
*/
-bool UnregisterSecurityContextForManifest(const std::string& pkg_id, uid_t uid,
- manifest_x* manifest, std::string* error_message);
+bool UnregisterSecurityContextForManifest(const std::string& pkg_id,
+ const std::string& pkg_type, uid_t uid, manifest_x* manifest,
+ std::string* error_message);
/**
* Adapter interface for external Security module.
* package from security context
*
* \param pkg_id pkgid of given package
+ * \param pkg_type type of given package
* \param uid uid
* \param error_message extra/detailed error message
* \param ignore_data_absence optional, default set to false, indicate if
*
* \return true if success
*/
-bool UnregisterSecurityContextForPkgId(const std::string& pkg_id, uid_t uid,
- std::string* error_message, bool ignore_data_absence = false);
+bool UnregisterSecurityContextForPkgId(const std::string& pkg_id,
+ const std::string& pkg_type, uid_t uid, std::string* error_message,
+ bool ignore_data_absence = false);
/**
* Adapter interface for external Security module.
std::string error_message;
if (!context_->manifest_data.get()) {
if (!UnregisterSecurityContextForPkgId(context_->pkgid.get(),
- context_->uid.get(), &error_message, true)) {
+ context_->pkg_type.get(), context_->uid.get(), &error_message, true)) {
LOG(ERROR) << "Unsuccessful install";
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;
return Status::RECOVERY_ERROR;
}
} else if (!UnregisterSecurityContextForManifest(
- context_->pkgid.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->pkg_type.get(), context_->uid.get(),
context_->manifest_data.get(), &error_message)) {
LOG(ERROR) << "Unsuccessful install";
if (!error_message.empty()) {
Step::Status StepRevokeSecurity::clean() {
std::string error_message;
if (!UnregisterSecurityContextForManifest(
- context_->pkgid.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->pkg_type.get(), context_->uid.get(),
context_->manifest_data.get(),
&error_message)) {
LOG(ERROR) << "Failure on unregistering security context for app "
Step::Status StepRollbackInstallationSecurity::undo() {
std::string error_message;
if (!UnregisterSecurityContextForManifest(
- context_->pkgid.get(), context_->uid.get(),
+ context_->pkgid.get(), context_->pkg_type.get(), context_->uid.get(),
context_->manifest_data.get(), &error_message)) {
if (!error_message.empty()) {
LOG(ERROR) << "error_message: " << error_message;