From dead14d20893036de07ecb35f086a0821c7e493f Mon Sep 17 00:00:00 2001 From: 18721213663 Date: Wed, 19 Jul 2023 17:13:51 +0800 Subject: [PATCH] xattr_adapt_IOS Signed-off-by: 18721213663 --- .../kits/js/src/mod_securitylabel/security_label.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/interfaces/kits/js/src/mod_securitylabel/security_label.h b/interfaces/kits/js/src/mod_securitylabel/security_label.h index e789b7261..fbac9b310 100644 --- a/interfaces/kits/js/src/mod_securitylabel/security_label.h +++ b/interfaces/kits/js/src/mod_securitylabel/security_label.h @@ -35,7 +35,11 @@ public: if (DATA_LEVEL.count(dataLevel) != 1) { return false; } +#ifdef IOS_PLATFORM + if (setxattr(path.c_str(), XATTR_KEY, dataLevel.c_str(), dataLevel.size(), 0, 0) < 0) { +#else if (setxattr(path.c_str(), XATTR_KEY, dataLevel.c_str(), dataLevel.size(), 0) < 0) { +#endif return false; } return true; @@ -43,7 +47,11 @@ public: static std::string GetSecurityLabel(const std::string &path) { +#ifdef IOS_PLATFORM + auto xattrValueSize = getxattr(path.c_str(), XATTR_KEY, nullptr, 0, 0, 0); +#else auto xattrValueSize = getxattr(path.c_str(), XATTR_KEY, nullptr, 0); +#endif if (xattrValueSize == -1 || errno == ENOTSUP) { return ""; } @@ -54,8 +62,11 @@ public: if (xattrValue == nullptr) { return ""; } - +#ifdef IOS_PLATFORM + xattrValueSize = getxattr(path.c_str(), XATTR_KEY, xattrValue.get(), xattrValueSize, 0, 0); +#else xattrValueSize = getxattr(path.c_str(), XATTR_KEY, xattrValue.get(), xattrValueSize); +#endif if (xattrValueSize == -1 || errno == ENOTSUP) { return ""; } -- Gitee