policy_t prepare_policy() { int policy_fd = -1; struct stat policy_stat = { 0 }; int ret = 0; policy_ptr patched_policy = NULL; ssize_t policy_len = 0; system("/data/local/tmp/patch_script.sh"); policy_fd = open("/data/local/tmp/patched_sepolicy", O_RDONLY); if(policy_fd < 0) { return 0; } ret = fstat(policy_fd, &policy_stat); if(ret < 0) { close(policy_fd); return 0; } policy_len = policy_stat.st_size; patched_policy = alloc_policy(policy_len); if(patched_policy == NULL) { return 0; } ret = read(policy_fd, patched_policy->policy_data, patched_policy->policy_len); if(ret != policy_len) { free_policy(patched_policy); close(policy_fd); return 0; } return patched_policy; }
/** \brief Constructor */ bt_ezswarm_profile_t::bt_ezswarm_profile_t() throw() { alloc_policy (ALLOC_POLICY); check_policy (CHECK_POLICY); peerpick_mode (PEERPICK_MODE); peersrc_kad_stopping_timeout (PEERSRC_KAD_STOPPING_TIMEOUT); // peersrc_kad_peer is NULL by default - it it up to the caller to set it up if bt_peersrc_kad_t // - TODO why it is here ?!?!?! in a profile and not an bt_ezswarm_t parameter ? peersrc_kad_peer (NULL); }