From 64952b6d074211cf5303f7592bb5ec74a106490e Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 2 Nov 2021 19:35:39 +0900 Subject: [PATCH] Change file log behavior Adjust permission and SMACK label to let platform privileged applications could access it. Also, create empty installer history log file to apply proper SMACK label to it. Change-Id: Icb85e3fbb2f0e69ae5b8e8ad6e1a94eedee576da Signed-off-by: Junghyun Yeon --- packaging/app-installers.spec | 7 ++++++- src/common/utils/file_logbackend.cc | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packaging/app-installers.spec b/packaging/app-installers.spec index dfc5ddf..f1d2d98 100644 --- a/packaging/app-installers.spec +++ b/packaging/app-installers.spec @@ -101,7 +101,12 @@ mkdir -p %{buildroot}%{logdir} %post chsmack -a System %{unpackdir} -chsmack -a System %{logdir} +chsmack -t -a User::Home %{logdir} +chown -R app_fw:priv_platform %{logdir} +chmod 755 %{logdir} +touch %{logdir}/installation-history.log +chown app_fw:priv_platform %{logdir}/installation-history.log +chsmack -a User::Home %{logdir}/installation-history.log %postun diff --git a/src/common/utils/file_logbackend.cc b/src/common/utils/file_logbackend.cc index a30d5f6..e3513d1 100644 --- a/src/common/utils/file_logbackend.cc +++ b/src/common/utils/file_logbackend.cc @@ -15,6 +15,12 @@ #include #include +namespace { + +constexpr mode_t kDefaultMode640 = S_IRUSR | S_IWUSR | S_IRGRP; + +} // namespace + namespace utils { FileLogBackend::FileLogBackend(std::string file_name, int rotation_size, @@ -47,6 +53,8 @@ void FileLogBackend::WriteLogToFile() { // clean the log stream log_stream_->str(""); log_stream_->clear(); + + chmod(file_name_.c_str(), kDefaultMode640); } bool FileLogBackend::Rotate() { -- 2.7.4