PKG_CHECK_MODULES(TRUST_ANCHOR_DEPS REQUIRED tanchor)
PKG_CHECK_MODULES(GUM_DEPS REQUIRED libgum)
-FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem program_options)
+FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem program_options iostreams)
FIND_PACKAGE(GTest REQUIRED)
ADD_SUBDIRECTORY(src)
#include "common/signature.h"
#include <tzplatform_config.h>
+#include <unistd.h>
#include <string>
#include <regex>
#include "common/utils/file_util.h"
namespace bf = boost::filesystem;
+namespace bi = boost::iostreams;
namespace ci = common_installer;
namespace common_installer {
return true;
}
-bool Signature::StoreSignature(std::ofstream* ofs,
+bool Signature::StoreSignature(bi::stream<bi::file_descriptor_sink> *ofs,
const ValidationCore::CertificatePtr& cert,
const ValidationCore::CertificatePtr& im_cert,
const ValidationCore::CertificatePtr& root_cert) {
if (!ofs)
return false;
-
*ofs << ((cert) ? cert->getBase64().c_str() : "") << std::endl;
*ofs << ((im_cert) ? im_cert->getBase64().c_str() : "") << std::endl;
*ofs << ((root_cert) ? root_cert->getBase64().c_str() : "") << std::endl;
bool Signature::Store() {
bool ret = true;
- std::ofstream ofs(file_path_.c_str(),
- std::ios::out | std::ios::trunc);
+ bi::stream<bi::file_descriptor_sink> ofs(file_path_);
if (!StoreSignature(&ofs,
cert_info_->dist2_cert.get(),
cert_info_->dist2_im_cert.get(),
cert_info_->dist_im_cert.get(),
cert_info_->dist_root_cert.get()))
ret = false;
+ ofs.flush();
+ ::fsync(ofs->handle());
ofs.close();
return ret;
}
#include <pkgmgrinfo_basic.h>
+#include <boost/iostreams/stream.hpp>
+#include <boost/iostreams/device/file_descriptor.hpp>
+
#include <string>
#include "common/installer_context.h"
namespace bf = boost::filesystem;
+namespace bi = boost::iostreams;
namespace common_installer {
std::string* error_message);
bool CheckSignatureMismatch(std::string* error_message);
bool SetPath();
- bool StoreSignature(std::ofstream* ofs,
+ bool StoreSignature(bi::stream<bi::file_descriptor_sink> *ofs,
const ValidationCore::CertificatePtr& cert,
const ValidationCore::CertificatePtr& im_cert,
const ValidationCore::CertificatePtr& root_cert);