#include "common/step/security/step_register_trust_anchor.h"
#include <trust-anchor.h>
-#include <boost/filesystem.hpp>
+#include <filesystem>
#include <string>
#include "common/utils/file_util.h"
namespace common_installer {
namespace security {
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
const char kWgtTrustAnchorPath[] = ".trust-anchor";
const char kWgt[] = "wgt";
-bool RemoveWgtTrustAnchorSymLinks(const bf::path& path) {
- for (bf::directory_iterator file(path);
- file != bf::directory_iterator(); ++file) {
- bf::path current(file->path());
- if (bf::is_symlink(symlink_status(current)) &&
- !bf::remove(current))
+bool RemoveWgtTrustAnchorSymLinks(const fs::path& path) {
+ for (fs::directory_iterator file(path);
+ file != fs::directory_iterator(); ++file) {
+ fs::path current(file->path());
+ if (fs::is_symlink(symlink_status(current)) &&
+ !fs::remove(current))
return false;
}
return true;
Step::Status StepRegisterTrustAnchor::process() {
int ret;
- bf::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
+ fs::path pkg_certs_path = context_->GetPkgPath() / kTpkTrustAnchorPath;
manifest_x* manifest = context_->manifest_data.get();
if (register_type_ == RegisterType::UPDATE) {
if (!context_->partial_rw.get() &&
!context_->pkg_type.get().compare(kWgt)) {
- if (bf::exists(pkg_certs_path) &&
+ if (fs::exists(pkg_certs_path) &&
!RemoveWgtTrustAnchorSymLinks(pkg_certs_path))
return Step::Status::APP_DIR_ERROR;
}
if (!common_installer::CreateDir(pkg_certs_path))
return Step::Status::APP_DIR_ERROR;
- bf::path pkg_certs_src_path =
+ fs::path pkg_certs_src_path =
context_->GetPkgPath() / "res/wgt" / kWgtTrustAnchorPath;
- for (bf::directory_iterator file(pkg_certs_src_path);
- file != bf::directory_iterator(); ++file) {
- bf::path current(file->path());
+ for (fs::directory_iterator file(pkg_certs_src_path);
+ file != fs::directory_iterator(); ++file) {
+ fs::path current(file->path());
try {
- bf::create_symlink(current, pkg_certs_path / current.filename());
- } catch (const bf::filesystem_error& error) {
+ fs::create_symlink(current, pkg_certs_path / current.filename());
+ } catch (const fs::filesystem_error& error) {
LOG(ERROR) << "Failed to make trust anchor symlink : " << error.what();
return Step::Status::APP_DIR_ERROR;
}
}
ret = trust_anchor_install(context_->pkgid.get().c_str(),
- context_->uid.get(), pkg_certs_path.string().c_str(),
+ context_->uid.get(), pkg_certs_path.c_str(),
(strcasecmp(manifest->use_system_certs, "true") == 0) ? true : false);
if (ret != TRUST_ANCHOR_ERROR_NONE) {