From be318ce89f88a5012ceece5e5893f2269467cba6 Mon Sep 17 00:00:00 2001 From: Sunmin Lee Date: Mon, 24 Jul 2017 10:44:18 +0900 Subject: [PATCH] Make SS_FSUpdate feature valid After get the SS_FSUpdate from tota-ua, the feature which is determined in build time doesn't work any longer. To make it valid, use flag variable instead of preprocessor defined value. Change-Id: I7d2531dde17798f1b0c21612c83600f5f409f22f Signed-off-by: Sunmin Lee --- ss_engine/SS_Common.c | 2 +- ss_engine/SS_FSUpdate.c | 199 ++++++++++++++++++++------------------ ss_engine/SS_FSUpdate.h | 22 ++++- ss_engine/SS_MultiProcessUpdate.h | 4 +- 4 files changed, 127 insertions(+), 100 deletions(-) diff --git a/ss_engine/SS_Common.c b/ss_engine/SS_Common.c index 876fb21..adbc49b 100755 --- a/ss_engine/SS_Common.c +++ b/ss_engine/SS_Common.c @@ -45,7 +45,7 @@ void SS_Progress(void *pbUserData, SS_UINT32 uPercent) SS_UINT32 SS_Trace(void *pUser, const char *aFormat, ...) { #if 0 - LOGL(LOG_REDBEND, aFormat); + LOGL(LOG_SSENGINE, aFormat); #else char temp[4096]; va_list list; diff --git a/ss_engine/SS_FSUpdate.c b/ss_engine/SS_FSUpdate.c index cb03e4c..7dd75db 100755 --- a/ss_engine/SS_FSUpdate.c +++ b/ss_engine/SS_FSUpdate.c @@ -37,6 +37,8 @@ #include "fota_common.h" #include "ua.h" +static int feature_support_capability; + /************************************************************ * common functions ************************************************************/ @@ -208,7 +210,7 @@ long SS_DeleteFolderEmpty(void *pbUserData, const char *strPath) char path[MAX_PATH] = { '\0' }; SS_unicode_to_char((const char *)strPath, (char *)path); - //LOGL(LOG_REDBEND, "%s\n", path); + //LOGL(LOG_SSENGINE, "%s\n", path); ret = rmdir(path); if ((ret == 0) || ((ret < 0) && ((errno == ENOENT) || (errno == ENOTEMPTY)))) { @@ -761,8 +763,8 @@ void SS_chtoa(int value, char *str) * The file attributes token (\a ui8pAttribs) is defined at generation time. * If attributes are not defined explicitly, they are given the following, * OS-dependent values: - * \li Windows: _redbend_ro_ for R/O files, _redbend_rw_ for R/W files - * \li Linux: _redbend_oooooo:xxxx:yyyy indicating the file mode, uid, and gid + * \li Windows: _foo_ro_ for R/O files, _foo_rw_ for R/W files + * \li Linux: _foo_oooooo:xxxx:yyyy indicating the file mode, uid, and gid * (uid and gid use capitalized hex digits as required) * * \param pbUserData Optional opaque data-structure to pass to IPL @@ -793,7 +795,6 @@ long SS_SetFileAttributes(const char *ui16pFilePath, struct stat sbuf; int ret = 0; char *smack_attr_pos = NULL; -#if defined(FEATURE_SUPPORT_CAPABILITY) int has_cap = 0; char cap_raw[100]; int cap_len; @@ -802,7 +803,6 @@ long SS_SetFileAttributes(const char *ui16pFilePath, char acl_raw[256]; int acl_len; -#endif if (NULL == ui16pFilePath) { LOGL(LOG_SSENGINE, "ui16pFilePath NULL [error]\n"); return E_SS_BAD_PARAMS; @@ -865,91 +865,92 @@ long SS_SetFileAttributes(const char *ui16pFilePath, smack_attr_pos++; setGroupID = (gid_t) strtol(tp, &endstr, 10); } -#if defined(FEATURE_SUPPORT_CAPABILITY) - // Get Capability - has_cap = 0; - if (*smack_attr_pos != '\0') { - char *cap_mark = "capability=0x"; - int cap_mark_len = strlen(cap_mark); - psmack = strstr(smack_attr_pos, cap_mark); - if(psmack) { - int cap_hex_len; - int i; - char ch1, ch2; - int raw1, raw2; - tp = strstr(psmack, ":"); - smack_attr_pos = tp + 1; - memset(tmpSmackAttribs, 0x0, sizeof(tmpSmackAttribs)); - memcpy(tmpSmackAttribs, psmack+cap_mark_len, - (int)tp - (int)psmack - cap_mark_len); - - // convert hexadecimal into raw data - cap_hex_len = strlen(tmpSmackAttribs); - cap_len = cap_hex_len/2; - memset(cap_raw, 0x00, sizeof(cap_raw)); - for (i=0; i= '0')&&(ch1 <= '9')) raw1 = ch1 - '0'; - else if ((ch1 >= 'a')&&(ch1 <= 'f')) raw1 = ch1 - 'a' + 10; - else if ((ch1 >= 'A')&&(ch1 <= 'F')) raw1 = ch1 - 'A' + 10; - else raw1 = 0; - if ((ch2 >= '0')&&(ch2 <= '9')) raw2 = ch2 - '0'; - else if ((ch2 >= 'a')&&(ch2 <= 'f')) raw2 = ch2 - 'a' + 10; - else if ((ch2 >= 'A')&&(ch2 <= 'F')) raw2 = ch2 - 'A' + 10; - else raw2 = 0; - - cap_raw[i] = raw1*16 + raw2; + if (feature_support_capability) { + // Get Capability + has_cap = 0; + if (*smack_attr_pos != '\0') { + char *cap_mark = "capability=0x"; + int cap_mark_len = strlen(cap_mark); + psmack = strstr(smack_attr_pos, cap_mark); + if(psmack) { + int cap_hex_len; + int i; + char ch1, ch2; + int raw1, raw2; + + tp = strstr(psmack, ":"); + smack_attr_pos = tp + 1; + memset(tmpSmackAttribs, 0x0, sizeof(tmpSmackAttribs)); + memcpy(tmpSmackAttribs, psmack+cap_mark_len, + (int)tp - (int)psmack - cap_mark_len); + + // convert hexadecimal into raw data + cap_hex_len = strlen(tmpSmackAttribs); + cap_len = cap_hex_len/2; + memset(cap_raw, 0x00, sizeof(cap_raw)); + for (i=0; i= '0')&&(ch1 <= '9')) raw1 = ch1 - '0'; + else if ((ch1 >= 'a')&&(ch1 <= 'f')) raw1 = ch1 - 'a' + 10; + else if ((ch1 >= 'A')&&(ch1 <= 'F')) raw1 = ch1 - 'A' + 10; + else raw1 = 0; + if ((ch2 >= '0')&&(ch2 <= '9')) raw2 = ch2 - '0'; + else if ((ch2 >= 'a')&&(ch2 <= 'f')) raw2 = ch2 - 'a' + 10; + else if ((ch2 >= 'A')&&(ch2 <= 'F')) raw2 = ch2 - 'A' + 10; + else raw2 = 0; + + cap_raw[i] = raw1*16 + raw2; + } + LOGL(LOG_SSENGINE, "[Cap] %s (cap_len=%d)\n", tmpSmackAttribs, cap_len); + has_cap = 1; } - LOGL(LOG_SSENGINE, "[Cap] %s (cap_len=%d)\n", tmpSmackAttribs, cap_len); - has_cap = 1; - } - } - // Get ACL - has_acl = 0; - if (*smack_attr_pos != '\0') { - char *acl_mark = "acl_access=0x"; - int acl_mark_len = strlen(acl_mark); - psmack = strstr(smack_attr_pos, acl_mark); - if(psmack) { - int acl_hex_len; - int i; - char ch1, ch2; - int raw1, raw2; - - tp = strstr(psmack, ":"); - smack_attr_pos = tp + 1; - memset(tmpSmackAttribs, 0x0, sizeof(tmpSmackAttribs)); - memcpy(tmpSmackAttribs, psmack+acl_mark_len, - (int)tp - (int)psmack - acl_mark_len); - - // convert hexadecimal into raw data - acl_hex_len = strlen(tmpSmackAttribs); - acl_len = acl_hex_len/2; - memset(acl_raw, 0x00, sizeof(acl_raw)); - for (i=0; i= '0')&&(ch1 <= '9')) raw1 = ch1 - '0'; - else if ((ch1 >= 'a')&&(ch1 <= 'f')) raw1 = ch1 - 'a' + 10; - else if ((ch1 >= 'A')&&(ch1 <= 'F')) raw1 = ch1 - 'A' + 10; - else raw1 = 0; - if ((ch2 >= '0')&&(ch2 <= '9')) raw2 = ch2 - '0'; - else if ((ch2 >= 'a')&&(ch2 <= 'f')) raw2 = ch2 - 'a' + 10; - else if ((ch2 >= 'A')&&(ch2 <= 'F')) raw2 = ch2 - 'A' + 10; - else raw2 = 0; - - acl_raw[i] = raw1*16 + raw2; - } - LOG("[ACL] %s (acl_len=%d)\n", tmpSmackAttribs, acl_len); - has_acl = 1; } + // Get ACL + has_acl = 0; + if (*smack_attr_pos != '\0') { + char *acl_mark = "acl_access=0x"; + int acl_mark_len = strlen(acl_mark); + psmack = strstr(smack_attr_pos, acl_mark); + if(psmack) { + int acl_hex_len; + int i; + char ch1, ch2; + int raw1, raw2; + + tp = strstr(psmack, ":"); + smack_attr_pos = tp + 1; + memset(tmpSmackAttribs, 0x0, sizeof(tmpSmackAttribs)); + memcpy(tmpSmackAttribs, psmack+acl_mark_len, + (int)tp - (int)psmack - acl_mark_len); + + // convert hexadecimal into raw data + acl_hex_len = strlen(tmpSmackAttribs); + acl_len = acl_hex_len/2; + memset(acl_raw, 0x00, sizeof(acl_raw)); + for (i=0; i= '0')&&(ch1 <= '9')) raw1 = ch1 - '0'; + else if ((ch1 >= 'a')&&(ch1 <= 'f')) raw1 = ch1 - 'a' + 10; + else if ((ch1 >= 'A')&&(ch1 <= 'F')) raw1 = ch1 - 'A' + 10; + else raw1 = 0; + if ((ch2 >= '0')&&(ch2 <= '9')) raw2 = ch2 - '0'; + else if ((ch2 >= 'a')&&(ch2 <= 'f')) raw2 = ch2 - 'a' + 10; + else if ((ch2 >= 'A')&&(ch2 <= 'F')) raw2 = ch2 - 'A' + 10; + else raw2 = 0; + + acl_raw[i] = raw1*16 + raw2; + } + LOG("[ACL] %s (acl_len=%d)\n", tmpSmackAttribs, acl_len); + has_acl = 1; + } + } } -#endif // Get Smack value -> Set Smack value if (*smack_attr_pos != '\0') { smack_lsetlabel(setFilePath, NULL, SMACK_LABEL_ACCESS); @@ -1045,20 +1046,21 @@ long SS_SetFileAttributes(const char *ui16pFilePath, LOGL(LOG_SSENGINE, "%s chmod error\n", __func__); return E_SS_FAILURE; } -#if defined(FEATURE_SUPPORT_CAPABILITY) - if (has_cap) { - if (setxattr(setFilePath, "security.capability", (void*)cap_raw, cap_len, 0) < 0) { - LOGL(LOG_SSENGINE, "cap setxattr() failed: %s\n", strerror(errno)); + + if (feature_support_capability) { + if (has_cap) { + if (setxattr(setFilePath, "security.capability", (void*)cap_raw, cap_len, 0) < 0) { + LOGL(LOG_SSENGINE, "cap setxattr() failed: %s\n", strerror(errno)); + } } - } - if (has_acl) { - if (setxattr(setFilePath, "system.posix_acl_access", (void*)acl_raw, acl_len, 0) < 0) { - LOGL(LOG_SSENGINE, "Acl setxattr() failed: %s\n", strerror(errno)); + if (has_acl) { + if (setxattr(setFilePath, "system.posix_acl_access", (void*)acl_raw, acl_len, 0) < 0) { + LOGL(LOG_SSENGINE, "Acl setxattr() failed: %s\n", strerror(errno)); + } + //LOG("Acl setxattr() :")asfd } - //LOG("Acl setxattr() :")asfd } -#endif //LOGL(LOG_SSENGINE, "%s SUCCESS\n", __func__); @@ -1205,7 +1207,7 @@ void* SS_RunProcess(void *pbUserData, int argc, char* argv[]) if (child_pid == 0) { #ifdef _NOEXEC_ - #ifdef _TIZEN_REDBEND//bota + #ifdef _TIZEN_SSENGINE//bota SS_HandleProcessRequest(pbUserData, argc, argv); #endif LOGL(LOG_SSENGINE, "SS_RunProcess was called - SS_HandleProcessRequest\n"); @@ -1240,5 +1242,12 @@ void* SS_RunProcess(void *pbUserData, int argc, char* argv[]) } } +int SS_get_feature_support_capability(void) +{ + return feature_support_capability; +} - +void SS_set_feature_support_capability(int val) +{ + feature_support_capability = val; +} diff --git a/ss_engine/SS_FSUpdate.h b/ss_engine/SS_FSUpdate.h index b221582..3bc4e88 100755 --- a/ss_engine/SS_FSUpdate.h +++ b/ss_engine/SS_FSUpdate.h @@ -306,8 +306,8 @@ extern "C" { * The file attributes token (\a ui8pAttribs) is defined at generation time. * If attributes are not defined explicitly, they are given the following, * OS-dependent values: - * \li Windows: _redbend_ro_ for R/O files, _redbend_rw_ for R/W files - * \li Linux: _redbend_oooooo:xxxx:yyyy indicating the file mode, uid, and gid + * \li Windows: _foo_ro_ for R/O files, _foo_rw_ for R/W files + * \li Linux: _foo_oooooo:xxxx:yyyy indicating the file mode, uid, and gid * (uid and gid use capitalized hex digits as required) * * \param pbUserData Optional opaque data-structure to pass to IPL @@ -363,6 +363,24 @@ extern "C" { */ void SS_Free(void *pMemBlock); +/** + ******************************************************************************* + * Get capability feature flag value + * + * \return The value of feature_support_capability + ******************************************************************************* + */ + int SS_get_feature_support_capability(void); + +/** + ******************************************************************************* + * Set capability feature flag + * + * \param val The value to set feature_support_capability + ******************************************************************************* + */ + void SS_set_feature_support_capability(int val); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/ss_engine/SS_MultiProcessUpdate.h b/ss_engine/SS_MultiProcessUpdate.h index 7b85830..73a0d75 100755 --- a/ss_engine/SS_MultiProcessUpdate.h +++ b/ss_engine/SS_MultiProcessUpdate.h @@ -66,8 +66,8 @@ * You must implement this functionality. ******************************************************************************* */ -#ifndef _REDBEND_MULTIPROCESS_UPDATE_H_ -#define _REDBEND_MULTIPROCESS_UPDATE_H_ +#ifndef _SSENGINE_MULTIPROCESS_UPDATE_H_ +#define _SSENGINE_MULTIPROCESS_UPDATE_H_ #include "SS_Engine_Update.h" #include "SS_Engine_Errors.h" -- 2.7.4