Change file log behavior 58/265958/1
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 2 Nov 2021 10:35:39 +0000 (19:35 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 2 Nov 2021 10:36:13 +0000 (19:36 +0900)
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 <jungh.yeon@samsung.com>
packaging/app-installers.spec
src/common/utils/file_logbackend.cc

index dfc5ddf..f1d2d98 100644 (file)
@@ -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
 
index a30d5f6..e3513d1 100644 (file)
 #include <string>
 #include <utility>
 
+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() {