#define TTS_GLOBAL_ENGINE_BASE "/etc/skel/share/.voice/tts/1.0"
#define TTS_GLOBAL_ENGINE_INFO "/etc/skel/share/.voice/tts/1.0/engine-info"
+#define TTS_METADATA_NAME "http://tizen.org/metadata/tts-engine/name"
#define TTS_METADATA_LANGUAGE "http://tizen.org/metadata/tts-engine/language"
#define TTS_METADATA_CREDENTIAL_REQUIRED "http://tizen.org/metadata/tts-engine/credential-required"
-
+#define TTS_METADATA_SETTING "http://tizen.org/metadata/tts-engine/setting"
typedef struct metadata {
const char *key;
static xmlDocPtr g_doc;
GumUser *g_guser = NULL;
-uid_t g_uid = 5001;
+uid_t g_uid = 301; // app_fw
+gid_t g_gid = 301; // app_fw
GumUserType g_ut = GUM_USERTYPE_NONE;
gchar *g_user_type = NULL;
return 0;
}
-static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid)
+static int __save_engine_info_xml(const char *pkgid, gchar *ut, uid_t uid, gid_t gid)
{
LOGD("=== Save engine info doc");
char *dir_config_base = NULL;
}
uid_t globalapp_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+ uid_t tmp_uid = 0;
+ gid_t tmp_gid = 0;
LOGD("uid(%d)", uid);
dir_home = strdup(TTS_GLOBAL_HOME);
dir_engine_base = strdup(TTS_GLOBAL_ENGINE_BASE);
dir_engine_info = strdup(TTS_GLOBAL_ENGINE_INFO);
+ tmp_uid = 301; // app_fw
+ tmp_gid = 301; // app_fw
} else {
/* User app, Guest app, Security app */
if (NULL != g_dir_config_base)
dir_engine_base = strdup(g_dir_engine_base);
if (NULL != g_dir_engine_info)
dir_engine_info = strdup(g_dir_engine_info);
+ tmp_uid = uid;
+ tmp_gid = gid;
}
if (NULL == dir_config_base || NULL == dir_home || NULL == dir_engine_base || NULL == dir_engine_info) {
return -1;
} else {
LOGD("Success to make directory : %s", dir_config_base);
+ if (0 != chown(dir_config_base, tmp_uid, tmp_gid)) {
+ LOGD("[ERROR] Fail to change user and group");
+ } else {
+ LOGD("[DEBUG] Success to change user and group");
+ }
}
}
return -1;
} else {
LOGD("Success to make directory : %s", dir_home);
+ if (0 != chown(dir_home, tmp_uid, tmp_gid)) {
+ LOGD("[ERROR] Fail to change user and group");
+ } else {
+ LOGD("[DEBUG] Success to change user and group");
+ }
}
}
return -1;
} else {
LOGD("Success to make directory : %s", dir_engine_base);
+ if (0 != chown(dir_engine_base, tmp_uid, tmp_gid)) {
+ LOGD("[ERROR] Fail to change user and group");
+ } else {
+ LOGD("[DEBUG] Success to change user and group");
+ }
}
}
return -1;
} else {
LOGD("Success to make directory : %s", dir_engine_info);
+ if (0 != chown(dir_engine_info, tmp_uid, tmp_gid)) {
+ LOGD("[ERROR] Fail to change user and group");
+ } else {
+ LOGD("[DEBUG] Success to change user and group");
+ }
}
}
snprintf(path, 256, "%s/%s.xml", dir_engine_info, pkgid);
int ret = xmlSaveFormatFile(path, g_doc, 1);
LOGD("xmlSaveFile (%d)", ret);
+ if (0 == ret) {
+ if (0 != chown(path, tmp_uid, tmp_gid)) {
+ LOGD("[ERROR] Fail to change user and group");
+ } else {
+ LOGD("[DEBUG] Success to change user and group");
+ }
+ }
free(dir_config_base);
dir_config_base = NULL;
xmlDocSetRootElement(g_doc, root);
/* Save name */
- cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_NAME);
- xmlNodeSetContent(cur, (const xmlChar*)pkgid);
- xmlAddChild(root, cur);
+// cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_NAME);
+// xmlNodeSetContent(cur, (const xmlChar*)pkgid);
+// xmlAddChild(root, cur);
iter = g_list_first(list);
cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_CREDENTIAL);
xmlNodeSetContent(cur, (const xmlChar*)md->value);
xmlAddChild(root, cur);
+ } else if (!strcmp(md->key, TTS_METADATA_SETTING)) {
+ cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_SETTING);
+ xmlNodeSetContent(cur, (const xmlChar*)md->value);
+ xmlAddChild(root, cur);
+ } else if (!strcmp(md->key, TTS_METADATA_NAME)) {
+ cur = xmlNewNode(NULL, (const xmlChar*)TTS_TAG_ENGINE_NAME);
+ xmlNodeSetContent(cur, (const xmlChar*)md->value);
+ xmlAddChild(root, cur);
} else {
LOGW("[WARNING] Unknown metadata type");
}
return -1;
}
+ g_object_get(G_OBJECT(g_guser), "gid", &g_gid, NULL);
g_object_get(G_OBJECT(g_guser), "usertype", &g_ut, NULL);
g_user_type = g_strdup(gum_user_type_to_string(g_ut));
}
return -1;
}
- if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid)) {
+ if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) {
LOGE("[ERROR] Fail to make engine info file");
xmlFreeDoc(g_doc);
g_free(g_user_type);
gchar *user_type = NULL;
uid_t uid;
+ gid_t gid;
gchar *home_dir = NULL;
gus = gum_user_service_create_sync(TRUE);
free(home_dir);
home_dir = NULL;
}
+ g_object_get(G_OBJECT(user), "gid", &gid, NULL);
g_object_get(G_OBJECT(user), "homedir", &home_dir, NULL);
g_object_get(G_OBJECT(user), "usertype", &gumut, NULL);
user_type = g_strdup(gum_user_type_to_string(gumut));
LOGD("[DEBUG] user info");
if (NULL != home_dir) {
- LOGD("[DEBUG] uid(%d), user_type(%s), home_dir(%s)", uid, user_type, home_dir);
+ LOGD("[DEBUG] uid(%d), gid(%d), user_type(%s), home_dir(%s)", uid, gid, user_type, home_dir);
g_dir_config_base = (char*)calloc(strlen(home_dir) + 14, sizeof(char));
g_dir_home = (char*)calloc(strlen(home_dir) + 18, sizeof(char));
LOGD("[DEBUG] g_dir_engine_info(%s)", g_dir_engine_info);
- if (0 != __save_engine_info_xml(pkgid, user_type, uid)) {
+ if (0 != __save_engine_info_xml(pkgid, user_type, uid, gid)) {
LOGE("[ERROR] Fail to make engine info file");
}
return -1;
}
- if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid)) {
+ if (0 != __save_engine_info_xml(pkgid, g_user_type, g_uid, g_gid)) {
LOGE("[ERROR] Fail to make engine info file");
xmlFreeDoc(g_doc);
if (NULL != g_guser) {