} while (0)
#define mc_info(fmt, arg...) do { \
- LOGI(FONT_COLOR_GREEN""fmt"", ##arg); \
+ LOGI(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg); \
} while (0)
#define mc_error(fmt, arg...) do { \
- LOGE(FONT_COLOR_RED""fmt"", ##arg); \
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
} while (0)
#define mc_debug_fenter() do { \
#define mc_retm_if(expr, fmt, arg...) do { \
if (expr) { \
- LOGE(FONT_COLOR_RED""fmt"", ##arg); \
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
return; \
} \
} while (0)
#define mc_retvm_if(expr, val, fmt, arg...) do { \
if (expr) { \
- LOGE(FONT_COLOR_RED""fmt"", ##arg); \
+ LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
return (val); \
} \
} while (0)
{
char result_psswd[MC_FILE_PATH_LEN_MAX] = {0, };
char *result_psswd_rtn = NULL;
- struct group *grpinfo = NULL;
char * dir = NULL;
memset(result_psswd, 0, sizeof(result_psswd));
- struct passwd *userinfo = getpwuid(uid);
- if (userinfo == NULL) {
- mc_error("getpwuid(%d) returns NULL !", uid);
+ struct passwd pwd;
+ struct passwd *pwd_result = NULL;
+ char buf_pw[MC_FILE_PATH_LEN_MAX];
+ int ret = getpwuid_r(uid, &pwd, buf_pw, MC_FILE_PATH_LEN_MAX, &pwd_result);
+ if (ret != 0 || pwd_result == NULL) {
+ mc_error("getpwuid_r(%d) returns NULL !", uid);
return NULL;
}
- grpinfo = getgrnam("users");
- if (grpinfo == NULL) {
- mc_error("getgrnam(users) returns NULL !");
+
+ struct group grp;
+ struct group *grp_result = NULL;
+ char buf_gr[MC_FILE_PATH_LEN_MAX];
+ ret = getgrnam_r("users", &grp, buf_gr, MC_FILE_PATH_LEN_MAX, &grp_result);
+ if (ret != 0 || grp_result == NULL) {
+ mc_error("getgrnam_r(users) returns NULL !");
return NULL;
}
/* Compare git_t type and not group name */
- if (grpinfo->gr_gid != userinfo->pw_gid) {
+ if (grp_result->gr_gid != pwd_result->pw_gid) {
mc_error("UID [%d] does not belong to 'users' group!", uid);
return NULL;
}
- snprintf(result_psswd, sizeof(result_psswd), "%s/.applications/dbspace/%s", userinfo->pw_dir, MC_DB_NAME);
+ snprintf(result_psswd, sizeof(result_psswd), "%s/.applications/dbspace/%s", pwd_result->pw_dir, MC_DB_NAME);
dir = strrchr(result_psswd, '/');
if (!dir)