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") {
]
configs += [ "//content:content_implementation" ]
+ if (tizen_product_tv) {
+ configs += [ "//tizen_src/build:cynara-creds-self" ]
+ }
}
} else {
group("zygote") {
#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
return;
#if BUILDFLAG(IS_TIZEN_TV)
- std::string smack_label;
- if (!base::ReadFileToString(base::FilePath("/proc/self/attr/current"),
- &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) << "Fail to get smack label";
} else {
- if (smack_label.compare("System::Privileged") != 0) {
+ std::string smack_label_str(smack_label_holder.get());
+ if (smack_label_str.compare("System::Privileged") != 0) {
LOG(INFO) << app_id << " is Already app process "
- << ", smack_label " << smack_label;
+ << ", smack_label " << smack_label_str;
return;
}
}
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)
}
}
+tizen_pkg_config("cynara-creds-self") {
+ packages = []
+ if (is_tizen) {
+ packages = [ "cynara-creds-self" ]
+ }
+}
+
tizen_pkg_config("pkgmgr-info") {
packages = []
if (is_tizen) {
}
if (tizen_product_tv) {
configs += [ "//tizen_src/build:privileged-service" ]
+ configs += [ "//tizen_src/build:cynara-creds-self" ]
libs += [ "lwipc", "vconf" ]
}
}
// 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>
#include <iostream>
#include <string>
+#include "base/memory/free_deleter.h"
#include "chromium_impl/build/tizen_version.h"
#define FILE_LOG_OUT
static int mount(bool mount, const char* args, bool use_system = false) {
#define DEBUG_LOG_SMACK_LABEL 0
#if DEBUG_LOG_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);
+ 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;
}
#endif
#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>
return result == "found";
}
- static constexpr char kSmackLabelFilePath[] = "/proc/self/attr/current";
-
int ret;
cynara* p_cynara = nullptr;
ret = cynara_initialize(&p_cynara, 0);
auto cynara_holder = std::unique_ptr<cynara, decltype(cynara_deleter)>{
p_cynara, cynara_deleter};
- std::string uid = std::to_string(getuid());
-
// Get smack label
- std::ifstream file(kSmackLabelFilePath);
- if (!file.is_open()) {
- LOG(ERROR) << "Failed to open " << kSmackLabelFilePath;
+ 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;
}
- 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;
return false;
}
+ std::string uid = std::to_string(getuid());
+
for (const auto& str : privilege_mapping) {
- ret = cynara_check(p_cynara, smack_label.c_str(), "", uid.c_str(),
+ ret = cynara_check(p_cynara, smack_label_holder.get(), "", uid.c_str(),
str.c_str());
if (ret != CYNARA_API_ACCESS_ALLOWED) {
return false;
"//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",
#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 {
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";
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);
return false;
}
- std::string uid = std::to_string(getuid());
- std::string smack_label{std::istreambuf_iterator<char>(file),
- std::istreambuf_iterator<char>()};
+ // 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;
- ret = cynara_check(
- cynara_h, smack_label.c_str(), "", uid.c_str(), privilege_name.c_str());
+ std::string uid = std::to_string(getuid());
+
+ ret = cynara_check(cynara_h, smack_label_holder.get(), "", uid.c_str(),
+ privilege_name.c_str());
if (ret != CYNARA_API_ACCESS_ALLOWED) {
LOG(ERROR) << "Access denied. The result of cynara_check() : " << ret;
} else {