// Read src file on local disk and send a put message to remote host (size of message = size of src file) static int hsm_put(const char *remote_host, const char *src, const char *dest){ // Read local src file, and return the size that was actually read sg_size_t read_size = read_local_file(src); // Send file XBT_INFO("%s sends %llu to %s",MSG_host_get_name(MSG_host_self()),read_size,remote_host); msg_task_t to_execute = MSG_task_create((const char*)"hsm_put", 0, (double) read_size, (void*)dest); MSG_task_send(to_execute, remote_host); MSG_process_sleep(.4); return 1; }
void init_local_data(const UAPP_GAME_INFO *pGameInfo, LOCAL_DATA_TAG *pLocalData) { char fileName[256]; iU16 file[256]; char dir[256]; memset((void *)fileName, 0, sizeof(fileName)); memset((void *)file, 0, sizeof(file)); memset((void *)pLocalData, 0, sizeof(LOCAL_DATA_TAG)); sprintf(fileName, "%d_%d",pGameInfo->game_id,pGameInfo->user_id); sprintf(dir, "%s\\%d_%d",(char*)APP_NAME,pGameInfo->game_id,pGameInfo->user_id); find_create_local_dir(dir); i51AdeStdWSprintf(file, 256, "%s\\%s\\%s.dat",APP_NAME,fileName,fileName); read_local_file(pGameInfo, (unsigned short *)file,pLocalData); }
int replace_secret_params(char *rsc_id, GHashTable* params) { char local_file[FILENAME_MAX+1], *start_pname; char hash_file[FILENAME_MAX+1], *hash; GList *secret_params = NULL, *l; char *key, *pvalue, *secret_value; int rc = 0; /* secret_params could be cached with the resource; * there are also parameters sent with operations * which cannot be cached */ g_hash_table_foreach(params, add_secret_params, &secret_params); if (!secret_params) /* none found? */ return 0; lrmd_debug(LOG_DEBUG , "%s:%d: replace secret parameters for resource %s" , __FUNCTION__, __LINE__, rsc_id); if (snprintf(local_file, FILENAME_MAX, LRM_CIBSECRETS "/%s/", rsc_id) > FILENAME_MAX) { lrmd_log(LOG_ERR , "%s:%d: filename size exceeded for resource %s" , __FUNCTION__, __LINE__, rsc_id); return -1; } start_pname = local_file + strlen(local_file); for (l = g_list_first(secret_params); l; l = g_list_next(l)) { key = (char *)(l->data); pvalue = g_hash_table_lookup(params, key); if (!pvalue) { /* this cannot really happen */ lrmd_log(LOG_ERR , "%s:%d: odd, no parameter %s for rsc %s found now" , __FUNCTION__, __LINE__, key, rsc_id); continue; } if ((strlen(key) + strlen(local_file)) >= FILENAME_MAX-2) { lrmd_log(LOG_ERR , "%s:%d: parameter name %s too big" , __FUNCTION__, __LINE__, key); rc = -1; continue; } strcpy(start_pname, key); secret_value = read_local_file(local_file); if (!secret_value) { lrmd_log(LOG_ERR , "%s:%d: secret for rsc %s parameter %s " "not found in " LRM_CIBSECRETS , __FUNCTION__, __LINE__, rsc_id, key); rc = -1; continue; } strcpy(hash_file, local_file); if (strlen(hash_file) + 5 > FILENAME_MAX) { lrmd_log(LOG_ERR , "%s:%d: cannot build such a long name " "for the sign file: %s.sign" , __FUNCTION__, __LINE__, hash_file); } else { strncat(hash_file, ".sign", 5); hash = read_local_file(hash_file); if (!check_md5_hash(hash, secret_value)) { lrmd_log(LOG_ERR , "%s:%d: md5 sum for rsc %s parameter %s " "does not match" , __FUNCTION__, __LINE__, rsc_id, key); g_free(secret_value); g_free(hash); rc = -1; continue; } g_free(hash); } g_hash_table_replace(params, g_strdup(key), secret_value); } g_list_free(secret_params); return rc; }