Revert "Use cynara API to get smack label" 45/319245/1 accepted/tizen/unified/20250207.071325 accepted/tizen/unified/x/20250212.043825 submit/tizen/20250206.160020
authorSatyaveer Singh <satyaveer.s@samsung.com>
Thu, 6 Feb 2025 08:04:15 +0000 (08:04 +0000)
committerGerrit Code Review <gerrit@localhost>
Thu, 6 Feb 2025 08:04:15 +0000 (08:04 +0000)
This reverts commit f9bdbc9857325c837ef4b47d6059365129194739.

Reason for revert: This patch causes multiple TCT crash.

Change-Id: I790fe9559fd3c70246727bada2a1aed1faebe15e

content/zygote/BUILD.gn
content/zygote/zygote_linux.cc
packaging/chromium-efl.spec
tizen_src/build/BUILD.gn
tizen_src/downloadable/BUILD.gn
tizen_src/downloadable/chromium_efl_install.cc
tizen_src/ewk/efl_integration/ewk_privilege_checker.cc
wrt/BUILD.gn
wrt/src/common/privilege.cc [changed mode: 0644->0755]

index f8aca98c4cb013f499ef287c930bc1a6da2a1bd0..577cce14277cc4202057cefbfdbf481f3c60e140 100644 (file)
@@ -4,7 +4,6 @@
 
 import("//build/config/nacl/config.gni")
 import("//content/public/common/zygote/features.gni")
-import("//tizen_src/build/config/tizen_features.gni")
 
 if (is_linux || is_tizen || is_chromeos) {
   source_set("zygote") {
@@ -27,9 +26,6 @@ if (is_linux || is_tizen || is_chromeos) {
     ]
 
     configs += [ "//content:content_implementation" ]
-    if (tizen_product_tv) {
-      configs += [ "//tizen_src/build:cynara-creds-self" ]
-    }
   }
 } else {
   group("zygote") {
index bddb4bacd0940e565c14533a8a61b5ef3ebba26f..32b1023b01370882e04d73debd61fe7e7a00caa1 100644 (file)
 #include <security-manager/security-manager.h>
 #endif
 
-#if BUILDFLAG(IS_TIZEN_TV)
-#include <cynara-creds-self.h>
-#include "base/memory/free_deleter.h"
-#endif
-
 // See
 // https://chromium.googlesource.com/chromium/src/+/main/docs/linux/zygote.md
 
@@ -777,16 +772,14 @@ void Zygote::HandleDropProcessPrivileges(int fd, base::PickleIterator iter) {
     return;
 
 #if BUILDFLAG(IS_TIZEN_TV)
-  char* smack_label = nullptr;
-  int ret = cynara_creds_self_get_client(CLIENT_METHOD_SMACK, &smack_label);
-  std::unique_ptr<char, base::FreeDeleter> smack_label_holder(smack_label);
-  if (ret != CYNARA_API_SUCCESS) {
+  std::string smack_label;
+  if (!base::ReadFileToString(base::FilePath("/proc/self/attr/current"),
+                              &smack_label)) {
     LOG(ERROR) << "Fail to get smack label";
   } else {
-    std::string smack_label_str(smack_label_holder.get());
-    if (smack_label_str.compare("System::Privileged") != 0) {
+    if (smack_label.compare("System::Privileged") != 0) {
       LOG(INFO) << app_id << " is Already app process "
-                << ", smack_label " << smack_label_str;
+                << ", smack_label " << smack_label;
       return;
     }
   }
index a190fa23330b05136d413f8cb373dc75020c95ae..028ff426844c533c7a093370ac8458e37b971f70 100644 (file)
@@ -193,7 +193,6 @@ BuildRequires: pkgconfig(capi-system-system-settings)
 BuildRequires: pkgconfig(capi-ui-autofill)
 BuildRequires: pkgconfig(capi-ui-autofill-common)
 BuildRequires: pkgconfig(capi-ui-autofill-service)
-BuildRequires: pkgconfig(cynara-creds-self)
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(ecore)
 BuildRequires: pkgconfig(ecore-evas)
index cdc40a2bea26fbe13927a12b2d8a3301d2bd784f..d79fa2fac7440afd4eb20eddc10c1ebe0c4aeead 100644 (file)
@@ -452,13 +452,6 @@ tizen_pkg_config("cynara-client") {
   }
 }
 
-tizen_pkg_config("cynara-creds-self") {
-  packages = []
-  if (is_tizen) {
-    packages = [ "cynara-creds-self" ]
-  }
-}
-
 tizen_pkg_config("pkgmgr-info") {
   packages = []
   if (is_tizen) {
index 311949bb63ad00ac317b58580c108baa6faae631..44723dccd4f72ad3cbcdd2ed58790e6526de201c 100644 (file)
@@ -102,7 +102,6 @@ executable("chromium-efl-install") {
   }
   if (tizen_product_tv) {
     configs += [ "//tizen_src/build:privileged-service" ]
-    configs += [ "//tizen_src/build:cynara-creds-self" ]
     libs += [ "lwipc", "vconf" ]
   }
 }
index 036d39f455026ef3eb3bd1503d715f7dfd897cf1..a382e4fbb15a4470c8c7390dbe5cd4b3a62c8bd4 100644 (file)
@@ -2,7 +2,6 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include <cynara-creds-self.h>
 #include <dirent.h>
 #include <fcntl.h>
 #include <glib.h>
@@ -18,7 +17,6 @@
 #include <iostream>
 #include <string>
 
-#include "base/memory/free_deleter.h"
 #include "chromium_impl/build/tizen_version.h"
 
 #define FILE_LOG_OUT
@@ -125,13 +123,12 @@ static void RequestColdBoot() {
 static int mount(bool mount, const char* args, bool use_system = false) {
 #define DEBUG_LOG_SMACK_LABEL 0
 #if DEBUG_LOG_SMACK_LABEL
-  char* smack_label = nullptr;
-  int ret = cynara_creds_self_get_client(CLIENT_METHOD_SMACK, &smack_label);
-  std::unique_ptr<char, base::FreeDeleter> smack_label_holder(smack_label);
-  if (ret != CYNARA_API_SUCCESS) {
-    LOG(ERROR) << "failed to get smack label";
-  } else {
-    LOG(INFO) << "SMACK Label:" << smack_label;
+  FILE* fd = fopen("/proc/self/attr/current", "r");
+  if (fd) {
+    char line[100];
+    if (fgets(line, sizeof(line), fd))
+      LOG(INFO) << "SMACK Label:" << line;
+    fclose(fd);
   }
 #endif
 
index fcec45db8723937abbf2417f59ca6367306a9383..05efdf21997a4044f8d6abb0d07244efcdaba69f 100644 (file)
@@ -7,11 +7,9 @@
 #if BUILDFLAG(IS_TIZEN)
 #include <app_manager.h>
 #include <cynara-client.h>
-#include <cynara-creds-self.h>
 #include <pkgmgr-info.h>
 #include <privilege_manager.h>
 #include <unistd.h>
-#include "base/memory/free_deleter.h"
 #endif  // BUILDFLAG(IS_TIZEN)
 
 #include <fstream>
@@ -139,6 +137,8 @@ bool EwkPrivilegeChecker::CheckPrivilege(
       return result == "found";
   }
 
+  static constexpr char kSmackLabelFilePath[] = "/proc/self/attr/current";
+
   int ret;
   cynara* p_cynara = nullptr;
   ret = cynara_initialize(&p_cynara, 0);
@@ -151,15 +151,18 @@ bool EwkPrivilegeChecker::CheckPrivilege(
   auto cynara_holder = std::unique_ptr<cynara, decltype(cynara_deleter)>{
       p_cynara, cynara_deleter};
 
+  std::string uid = std::to_string(getuid());
+
   // Get smack label
-  char* smack_label = nullptr;
-  ret = cynara_creds_self_get_client(CLIENT_METHOD_SMACK, &smack_label);
-  std::unique_ptr<char, base::FreeDeleter> smack_label_holder(smack_label);
-  if (ret != CYNARA_API_SUCCESS) {
-    LOG(ERROR) << " failed to get smack label";
+  std::ifstream file(kSmackLabelFilePath);
+  if (!file.is_open()) {
+    LOG(ERROR) << "Failed to open " << kSmackLabelFilePath;
     return false;
   }
 
+  std::string smack_label{std::istreambuf_iterator<char>(file),
+                          std::istreambuf_iterator<char>()};
+
   // Get widget api version, which is needed to resolve older privileges from
   // previous platforms. Api version is set inside of config.xml in widget.
   std::string api_version;
@@ -177,10 +180,8 @@ bool EwkPrivilegeChecker::CheckPrivilege(
     return false;
   }
 
-  std::string uid = std::to_string(getuid());
-
   for (const auto& str : privilege_mapping) {
-    ret = cynara_check(p_cynara, smack_label_holder.get(), "", uid.c_str(),
+    ret = cynara_check(p_cynara, smack_label.c_str(), "", uid.c_str(),
                        str.c_str());
     if (ret != CYNARA_API_ACCESS_ALLOWED) {
       return false;
index 5f83d1e0aa6f4c2b6035c14c91552cf8766c4352..4094d71d4c6aba6b2a877698b20b8d61c84dbb6c 100644 (file)
@@ -253,7 +253,6 @@ config("wrt_config") {
     "//tizen_src/build:appsvc",
     "//tizen_src/build:aul",
     "//tizen_src/build:cynara-client",
-    "//tizen_src/build:cynara-creds-self",
     "//tizen_src/build:capi-appfw-package-manager",
     "//tizen_src/build:capi-appfw-service-application",
     "//tizen_src/build:libefl-extension",
old mode 100644 (file)
new mode 100755 (executable)
index c0f6e09..5adc7c1
 #include "wrt/src/common/privilege.h"
 
 #include <cynara-client.h>
-#include <cynara-creds-self.h>
 #include <cynara-error.h>
 #include <pkgmgr-info.h>
 #include <fstream>
 #include <memory>
 
 #include "base/logging.h"
-#include "base/memory/free_deleter.h"
 #include "wrt/src/common/application_data.h"
 
 namespace wrt {
@@ -38,6 +36,7 @@ enum {
   KEEP_PRIVILEGE_SEARCH = 0
 };
 
+static constexpr char kSmackLabelFilePath[] = "/proc/self/attr/current";
 static constexpr auto hostedapp_privilege =
     "http://developer.samsung.com/privilege/hostedapp_deviceapi_allow";
 
@@ -54,6 +53,12 @@ bool CheckHostedAppPrivilege() {
 
 bool FindPrivilegeFromCynara(const std::string& privilege_name) {
   LOG(INFO) << "Finding privilege from cynara db";
+  std::ifstream file(kSmackLabelFilePath);
+  if (!file.is_open()) {
+    LOG(ERROR) << "Failed to open " << kSmackLabelFilePath;
+    return false;
+  }
+
   int ret;
   cynara* cynara_h = nullptr;
   ret = cynara_initialize(&cynara_h, 0);
@@ -62,20 +67,13 @@ bool FindPrivilegeFromCynara(const std::string& privilege_name) {
     return false;
   }
 
-  // Get smack label
-  char* smack_label = nullptr;
-  ret = cynara_creds_self_get_client(CLIENT_METHOD_SMACK, &smack_label);
-  std::unique_ptr<char, base::FreeDeleter> smack_label_holder(smack_label);
-  if (ret != CYNARA_API_SUCCESS) {
-    LOG(ERROR) << " failed to get smack label";
-    return false;
-  }
-
-  bool result = false;
   std::string uid = std::to_string(getuid());
+  std::string smack_label{std::istreambuf_iterator<char>(file),
+                          std::istreambuf_iterator<char>()};
 
-  ret = cynara_check(cynara_h, smack_label_holder.get(), "", uid.c_str(),
-                     privilege_name.c_str());
+  bool result = false;
+  ret = cynara_check(
+      cynara_h, smack_label.c_str(), "", uid.c_str(), privilege_name.c_str());
   if (ret != CYNARA_API_ACCESS_ALLOWED) {
     LOG(ERROR) << "Access denied. The result of cynara_check() : " << ret;
   } else {