bool DSAccessFile::CheckGroupMembership(const char* inUsername, const char* inGroupName) { // In Tiger, group membership is painfully simple: we ask memberd for it! struct passwd *user = NULL; struct group *group = NULL; uuid_t userID; uuid_t groupID; int isMember = 0; // Look up the user using the POSIX APIs: only care about the UID. user = getpwnam(inUsername); if ( user == NULL ) return false; uuid_clear(userID); if ( mbr_uid_to_uuid(user->pw_uid, userID) ) return false; // Look up the group using the POSIX APIs: only care about the GID. group = getgrnam(inGroupName); endgrent(); if ( group == NULL ) return false; uuid_clear(groupID); if ( mbr_gid_to_uuid(group->gr_gid, groupID) ) return false; // mbr_check_membership() returns 0 on success and error code on failure. if ( mbr_check_membership(userID, groupID, &isMember) ) return false; return (bool)isMember; }
void plUUID::Clear() { uuid_t g; plUUIDHelper::CopyToNative( g, this ); uuid_clear( g ); plUUIDHelper::CopyToPlasma( this, g ); }
int main(int argc, char **argv) { Octstr *os; char id[UUID_STR_LEN + 1]; uuid_t uid; gwlib_init(); debug("uuid",0,"Creating UUID"); uuid_generate(uid); debug("uuid",0,"Parse into char"); uuid_unparse(uid, id); debug("uuid",0,"Create Octstr"); os = octstr_create(id); debug("uuid",0,"UUID is: %s", octstr_get_cstr(os)); debug("uuid",0,"Removing dashes"); octstr_replace(os, octstr_imm("-"), octstr_imm("")); debug("uuid",0,"UUID is: %s", octstr_get_cstr(os)); octstr_destroy(os); uuid_clear(uid); gwlib_shutdown(); return 0; }
/*@ To avoid having to create all the overhead for a bunch of debug functions * just roll everything into one debug method and provide an enum to select * which one to do */ static void handle_bptree_debug(tcp_client* c, struct evbuffer* buffer) { int rv; bptree_session *bps; int16_t field_num; int16_t field_sz; enum bptree_debug_option debug_opt; static uuid_t failed_node; struct evbuffer* b = evbuffer_copy(buffer); transaction_set_get_cb(c->t, on_bptree_debug, c); if (bptree_message_incomplete(b)) return; bps = retrieve_bptree_session(c,b); if (bps == NULL) { printf("Couldn't find bptree_session in bptree_debug!\n"); rv = -1; } else { evbuffer_remove(b,&debug_opt, sizeof(enum bptree_debug_option)); rv = bptree_debug(bps, debug_opt, failed_node); if (rv == BPTREE_OP_TAPIOCA_NOT_READY) return; } uuid_clear(failed_node); evbuffer_free(b); evbuffer_drain(buffer, evbuffer_get_length(buffer)); send_result(c->buffer_ev, rv); }
CID CID::FromString(const std::string &cid) { uuid_t uuid; int ret = uuid_parse(cid.data(), uuid); if (ret == -1) uuid_clear(uuid); return CID(uuid); }
static void _os_get_image_uuid(void *hdr, uuid_t uuid) { #if __LP64__ struct mach_header_64 *hdr32or64 = (struct mach_header_64 *)hdr; #else struct mach_header *hdr32or64 = (struct mach_header *)hdr; #endif /* __LP64__ */ size_t i = 0; size_t next = sizeof(*hdr32or64); struct load_command *cur = NULL; for (i = 0; i < hdr32or64->ncmds; i++) { cur = (struct load_command *)((uintptr_t)hdr32or64 + next); if (cur->cmd == LC_UUID) { struct uuid_command *cmd = (struct uuid_command *)cur; uuid_copy(uuid, cmd->uuid); break; } next += cur->cmdsize; } if (i == hdr32or64->ncmds) { uuid_clear(uuid); } }
static void setting_init (Setting *setting) { uuid_t uuid; uuid_generate (uuid); uuid_unparse (uuid, setting->uuid); uuid_clear (uuid); }
int jack_uuid_empty (const jack_uuid_t u) { jack_uuid_t empty; VALGRIND_MEMSET(&empty, 0, sizeof(empty)); uuid_clear (empty); if (jack_uuid_compare (u, empty) == 0) { return 1; } return 0; }
void cl_uuid_clear(cl_uuid_t* uu) { if (uu == NULL) { cl_log(LOG_ERR, "cl_uuid_clear: " "wrong argument (uu is NULL)"); assert(0); } uuid_clear(uu->uuid); }
int main (int argc, char**argv) { char buffer[37]; uuid_t out; uuid_clear (out); uuid_generate_time (out); uuid_unparse (out, buffer); return 0; }
static void reset_session(plugin_data *p) { if (p->state.fd != -1) { close(p->state.fd); p->state.fd = -1; } free(p->state.vhd.bat.bat); p->state.vhd.bat.bat = NULL; free(p->state.curr_bitmap); p->state.curr_bitmap = NULL; reset_state(&p->state); uuid_clear(p->session_id); }
/* Unlock an heartbeat */ int vmfs_heartbeat_unlock(vmfs_fs_t *fs,vmfs_heartbeat_t *hb) { DECL_ALIGNED_BUFFER(buf,VMFS_HB_SIZE); if (!vmfs_heartbeat_active(hb)) return(-1); hb->magic = VMFS_HB_MAGIC_OFF; hb->seq++; uuid_clear(hb->uuid); vmfs_heartbeat_write(hb,buf); return((vmfs_device_write(fs->dev,hb->pos,buf,buf_len) == buf_len) ? 0 : -1); }
void gfalt_params_handle_init(gfalt_params_t p, GError ** err){ p->callback = NULL; p->lock = false; p->nb_data_streams = GFALT_DEFAULT_NB_STREAM; p->timeout = GFALT_DEFAULT_TRANSFERT_TIMEOUT; p->start_offset = 0; p->tcp_buffer_size=0; p->replace_existing = false; p->local_transfers=true; p->strict_mode = false; p->parent_dir_create = false; uuid_clear(p->uuid); p->event_callback = NULL; }
//send message bool activemq_sync_producer::send_message(const std::string& request, std::string& response, int time) { try { char uuid_str[37]; uuid_str[36] = 0; uuid_clear(_uuid); uuid_generate_time_safe(_uuid); uuid_unparse(_uuid, uuid_str); //发送消息 std::auto_ptr<cms::TextMessage> ptr_message(_ptr_session->createTextMessage(request)); ptr_message->setCMSReplyTo(_ptr_recv_queue.get()); ptr_message->setCMSCorrelationID(uuid_str); _ptr_send_message->send(ptr_message.get()); bool recv_data = false; while (1) { std::auto_ptr<cms::TextMessage> recv_message(dynamic_cast<cms::TextMessage*>(_ptr_recv_message->receive(time))); if (NULL != recv_message.get()) { if (recv_message->getCMSCorrelationID().compare(uuid_str) == 0) { response = recv_message->getText(); recv_data = true; break; } else { } } else { break; } } return recv_data; } catch (cms::CMSException& e) { printf("Producer run() CMSException \n"); e.printStackTrace(); return false; } }
static void queue_jlog_dispose(fq_rk *qname, fqd_queue_impl_data f) { struct queue_jlog *d = (struct queue_jlog *)f; uuid_t exist; (void)qname; uuid_clear(exist); read_sig(d, exist); if(uuid_compare(d->uuid, exist) == 0) { /* This is my jlog queue ... I can delete it */ fq_debug(FQ_DEBUG_IO, "jlog: removing %s\n", d->qpath); nftw(d->qpath, multi_unlink, 2, FTW_DEPTH); rmdir(d->qpath); } free(d); }
static int check_session(server *srv, connection *con, plugin_data *p, bits_packet_t packet_type) { int err; buffer *req_session_id; uuid_t req_session_uuid; char uuid_str[UUID_STR_LEN]; if (packet_type == BITS_PING || packet_type == BITS_CREATE_SESSION) { return 0; } if (uuid_is_null(p->session_id)) { LOG("s", "ERROR: No-one is logged in."); return -EINVAL; } uuid_clear(req_session_uuid); req_session_id = get_bits_session_id(srv, con); if (!req_session_id) { LOG("s", "ERROR: No session ID provided in request"); return -EINVAL; } if (strlen(req_session_id->ptr) != UUID_IN_BRACES_STR_LEN -1) { LOG("ss", "ERROR: session ID invalid:", req_session_id->ptr); return -EINVAL; } strncpy(uuid_str, req_session_id->ptr + 1, UUID_STR_LEN - 1); uuid_str[UUID_STR_LEN - 1] = '\0'; err = uuid_parse(uuid_str, req_session_uuid); if (err) { LOG("ss", "ERROR: session ID not a valid UUID:", uuid_str); return -EINVAL; } if (uuid_compare(p->session_id, req_session_uuid)) { char uuid_str2[UUID_STR_LEN]; uuid_unparse(p->session_id, uuid_str2); LOG("ssss", "ERROR: Wrong session ID:", req_session_id->ptr, "expect:", uuid_str2); return -EINVAL; } return 0; }
void reset() { this->valid = false; uuid_clear(this->uuid); memset(this->name, 0, sizeof(this->name)); this->durability = NULL_DURABILITY; this->stack_size = NULL_STACK_SIZE; memset(this->location_name, 0, sizeof(this->location_name)); this->location_id = NULL_LOCATION; this->container_slot = NULL_SLOT; this->item_type = NULL_ITEM_TYPE; this->item_location = IL_NOWHERE; this->item_container_type = NULL_CONTAINER_TYPE; }
// FIXME - most of this should be factored out into boilerplate code static void got_add_inv_item_resp(SoupSession *session, SoupMessage *msg, gpointer user_data) { //USER_PRIV_DEF(user_data); //GRID_PRIV_DEF(sim); uuid_t u; char* s; add_inv_item_req *req = (add_inv_item_req*)user_data; user_grid_glue* user_glue = req->user_glue; xmlDocPtr doc; xmlNodePtr node; user_grid_glue_deref(user_glue); if(msg->status_code != 200) { printf("Inventory request failed: got %i %s\n",(int)msg->status_code,msg->reason_phrase); goto fail; } printf("DEBUG: inventory item add resp {{%s}}\n", msg->response_body->data); doc = xmlReadMemory(msg->response_body->data, msg->response_body->length, "inventory_resp.xml", NULL, 0); if(doc == NULL) { printf("ERROR: inventory XML response parse failed\n"); goto fail; } node = xmlDocGetRootElement(doc); if(strcmp((char*)node->name, "boolean") != 0) { printf("ERROR: unexpected root node %s\n",(char*)node->name); goto free_fail; } s = (char*)xmlNodeListGetString(doc, node->children, 1); req->cb(req->cb_priv, s != NULL && strcmp(s, "true") == 0, req->item_id); xmlFree(s); xmlFreeDoc(doc); delete req; return; free_fail: xmlFreeDoc(doc); fail: uuid_clear(u); req->cb(req->cb_priv, FALSE, u); delete req; printf("ERROR: add inventory item response parse failure\n"); return; }
static void read_uuid(BANG_peer *self,uuid_t uuid) { uuid_t *uuid_ptr = (uuid_t*) read_message(self,sizeof(uuid_t)); if (uuid_ptr) { uuid_copy(uuid,*uuid_ptr); #ifdef BDEBUG_1 char unparsed[37]; uuid_unparse(uuid,unparsed); fprintf(stderr,"READ-THREAD:\tRead uuid %s.\n",unparsed); #endif free(uuid_ptr); } else { uuid_clear(uuid); } }
void tiz_uuid_str (const OMX_U8 *ap_uuid, OMX_STRING ap_str) { uuid_t uid = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' }; assert (NULL != ap_uuid); assert (NULL != ap_str); uuid_clear (uid); memcpy (uid, ap_uuid, 16); /* Khronos uuid type is 128 bytes length !! */ (void)tiz_mem_set (ap_str, 0, 128); uuid_unparse (uid, ap_str); }
static errcode_t parse_uuid(struct super_set_info *info, char *arg) { unsigned char * p = (unsigned char *) info->ptr; if ((strcasecmp(arg, "null") == 0) || (strcasecmp(arg, "clear") == 0)) { uuid_clear(p); } else if (strcasecmp(arg, "time") == 0) { uuid_generate_time(p); } else if (strcasecmp(arg, "random") == 0) { uuid_generate(p); } else if (uuid_parse(arg, p)) { fprintf(stderr, "Invalid UUID format: %s\n", arg); return EINVAL; } return 0; }
/* Unlock metadata */ int vmfs_metadata_unlock(vmfs_fs_t *fs,vmfs_metadata_hdr_t *mdh) { DECL_ALIGNED_BUFFER(buf,VMFS_METADATA_HDR_SIZE); mdh->hb_lock = 0; uuid_clear(mdh->hb_uuid); vmfs_metadata_hdr_write(mdh,buf); /* Rewrite the metadata header only */ if (vmfs_device_write(fs->dev,mdh->pos,buf,buf_len) != buf_len) { fprintf(stderr,"VMFS: unable to write metadata header.\n"); return(-1); } return(vmfs_heartbeat_release(fs)); }
int main(int argc, char *argv) { uuid_t buf, tst; char str[100]; unsigned char *cp; int i; int failed = 0; uuid_generate(buf); uuid_unparse(buf, str); printf("UUID string = %s\n", str); printf("UUID: "); for (i=0, cp = (unsigned char *) &buf; i < 16; i++) { printf("%02x", *cp++); } printf("\n"); uuid_parse(str, tst); if (uuid_compare(buf, tst)) printf("UUID parse and compare succeeded.\n"); else { printf("UUID parse and compare failed!\n"); failed++; } uuid_clear(tst); if (uuid_is_null(tst)) printf("UUID clear and is null succeeded.\n"); else { printf("UUID clear and is null failed!\n"); failed++; } uuid_copy(buf, tst); if (uuid_compare(buf, tst)) printf("UUID copy and compare succeeded.\n"); else { printf("UUID copy and compare failed!\n"); failed++; } if (failed) { printf("%d failures.\n", failed); exit(1); } return 0; }
void tiz_str_uuid (const char *ap_str, OMX_UUIDTYPE *ap_uuid) { uuid_t uid = { '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' }; int parse_result = 0; assert (NULL != ap_str); assert (NULL != ap_uuid); uuid_clear (uid); /* Khronos uuid type is 128 bytes length !! */ (void)tiz_mem_set (ap_uuid, 0, 128); parse_result = uuid_parse (ap_str, uid); assert (parse_result == 0); memcpy (ap_uuid, uid, 16); }
RemoteServiceJob *CreateRemoteServiceJobFromResultsJSON (const json_t *results_p, Service *service_p, const char *name_s, const char *description_s, OperationStatus status) { RemoteServiceJob *job_p = (RemoteServiceJob *) AllocMemory (sizeof (RemoteServiceJob)); if (job_p) { if (InitServiceJobFromResultsJSON (& (job_p -> rsj_job), results_p, service_p, name_s, description_s, status)) { job_p -> rsj_job.sj_free_fn = FreeRemoteServiceJob; uuid_clear (job_p -> rsj_job_id); job_p -> rsj_service_name_s = NULL; job_p -> rsj_uri_s = NULL; return job_p; } FreeMemory (job_p); } /* if (job_p) */ return NULL; }
int main(void) { List *list; char id[UUID_STR_LEN + 1]; int i; gwlib_init(); debug("",0,"List performance test."); list = gwlist_create(); /* generate UUIDs and populate the list */ debug("", 0, "Creating %d UUIDs for the list.", HUGE_SIZE); for (i = 0; i < HUGE_SIZE; i++) { Octstr *os; uuid_t uid; uuid_generate(uid); uuid_unparse(uid, id); os = octstr_create(id); gwlist_append(list, os); uuid_clear(uid); } debug("",0,"Objects in the list: %ld", gwlist_len(list)); /* try to sort */ debug("",0,"Sorting."); gwlist_sort(list, my_sort_cmp); debug("",0,"Sorting done."); for (i = 0; i < HUGE_SIZE; i++) { Octstr *os = gwlist_get(list, i); debug("",0,"After sort: %s %d", octstr_get_cstr(os), i); } gwlist_destroy(list, octstr_destroy_item); gwlib_shutdown(); return 0; }
static void queue_jlog_dispose(fq_rk *qname, fqd_queue_impl_data f) { struct queue_jlog *d = (struct queue_jlog *)f; uuid_t exist; (void)qname; if (d == NULL) { /* there was likely a total failure to init this queue type due to file system permissions, bail */ return; } uuid_clear(exist); read_sig(d, exist); if(uuid_compare(d->uuid, exist) == 0) { /* This is my jlog queue ... I can delete it */ fq_debug(FQ_DEBUG_IO, "jlog: removing %s\n", d->qpath); nftw(d->qpath, multi_unlink, 2, FTW_DEPTH); rmdir(d->qpath); } free(d); }
void rrwrk_connect_to_broker(rrwrk_t *self) { self->worker = _rrwrk_create_socket(self->ctx, self->worker, ZMQ_DEALER); //** Recreate uuid for each new connection if (self->uuid_str) { free(self->uuid_str); uuid_clear(self->uuid); } uuid_generate(self->uuid); self->uuid_str = rr_uuid_str(self->uuid); zsocket_set_identity(self->worker, self->uuid_str); zsocket_connect(self->worker, self->broker); //** Tell broker we are ready for work rrwrk_send_to_broker(self, RRWRK_READY, NULL); //** If liveness hits zero, queue is considered disconnected self->liveness = HEARTBEAT_LIVENESS; self->heartbeat_at = zclock_time() + self->heartbeat; }
resrc_flow_t *resrc_flow_new_from_json (json_t *o, resrc_flow_t *parent) { json_t *jhierarchyo = NULL; /* json hierarchy object */ const char *basename = NULL; const char *name = NULL; const char *hierarchy = NULL; const char *path = NULL; const char *hierarchy_path = NULL; const char *tmp = NULL; const char *type = NULL; int64_t id; int64_t ssize; resrc_flow_t *resrc_flow = NULL; resrc_t *flow_resrc; resrc_t *resrc = NULL; size_t size = 1; uuid_t uuid; if (!Jget_str (o, "type", &type)) goto ret; Jget_str (o, "basename", &basename); Jget_str (o, "name", &name); if (!(Jget_int64 (o, "id", &id))) id = -1; if (Jget_str (o, "uuid", &tmp)) uuid_parse (tmp, uuid); else uuid_clear(uuid); if (Jget_int64 (o, "size", &ssize)) size = (size_t) ssize; if ((jhierarchyo = Jobj_get (o, "hierarchy"))) { /* Get first key and value from hierarchy object */ const char *key = json_object_iter_key (json_object_iter (jhierarchyo)); if (key) { hierarchy = key; Jget_str (jhierarchyo, key, &hierarchy_path); } } if (!Jget_str (o, "path", &path)) { if (hierarchy_path) path = xstrdup (hierarchy_path); } if (!path) { if (parent) path = xasprintf ("%s/%s", resrc_path (parent->flow_resrc), name); else path = xasprintf ("/%s", name); } if (!(flow_resrc = resrc_new_resource (type, path, basename, name, NULL, id, uuid, size))) goto ret; if (!strncmp (type, "node", 5)) { resrc = resrc_lookup (name); } if ((resrc_flow = resrc_flow_new (parent, flow_resrc, resrc))) { /* add time window if we are given a start time */ int64_t starttime; if (Jget_int64 (o, "starttime", &starttime)) { json_t * w = Jnew (); char *json_str; int64_t endtime; int64_t wall_time; Jadd_int64 (w, "starttime", starttime); if (!Jget_int64 (o, "endtime", &endtime)) { if (Jget_int64 (o, "walltime", &wall_time)) endtime = starttime + wall_time; else endtime = TIME_MAX; } Jadd_int64 (w, "endtime", endtime); json_str = xstrdup (Jtostr (w)); resrc_twindow_insert (resrc_flow->flow_resrc, "0", (void *) json_str); Jput (w); } } if (resrc) resrc_graph_insert (resrc, hierarchy, resrc_flow); ret: return resrc_flow; }
void add_inventory_item(simgroup_ctx *sgrp, user_ctx *user, void *user_priv, inventory_item *inv, void(*cb)(void* priv, int success, uuid_t item_id), void *cb_priv) { uuid_t u, user_id; char tmp[40]; char uri[256]; GRID_PRIV_DEF_SGRP(sgrp); USER_PRIV_DEF(user_priv); xmlTextWriterPtr writer; xmlBufferPtr buf; SoupMessage *msg; add_inv_item_req *req; struct os_inv_item invitem; assert(grid->inventory_server != NULL); buf = xmlBufferCreate(); if(buf == NULL) goto fail; writer = xmlNewTextWriterMemory(buf, 0); if(writer == NULL) goto free_fail_1; if(xmlTextWriterStartDocument(writer,NULL,"UTF-8",NULL) < 0) goto free_fail; if(xmlTextWriterStartElement(writer, BAD_CAST "RestSessionObjectOfInventoryItemBase") < 0) goto free_fail; user_get_session_id(user, u); uuid_unparse(u, tmp); if(xmlTextWriterWriteFormatElement(writer,BAD_CAST "SessionID", "%s",tmp) < 0) goto free_fail; user_get_uuid(user, user_id); uuid_unparse(user_id, tmp); if(xmlTextWriterWriteFormatElement(writer,BAD_CAST "AvatarID", "%s",tmp) < 0) goto free_fail; if(xmlTextWriterStartElement(writer,BAD_CAST "Body") < 0) goto free_fail; inv_item_to_opensim(inv, invitem); osglue_serialise_xml(writer, deserialise_inv_item, &invitem); if(xmlTextWriterEndElement(writer) < 0) goto free_fail; if(xmlTextWriterEndElement(writer) < 0) goto free_fail; if(xmlTextWriterEndDocument(writer) < 0) { printf("DEBUG: couldn't end XML document\n"); goto fail; } // FIXME - don't use fixed-length buffer, and handle missing trailing / // (note: not AddNewItem, as that's not meant for sim use!) snprintf(uri, 256, "%sNewItem/", grid->inventory_server); printf("DEBUG: sending inventory add request to %s\n", uri); msg = soup_message_new ("POST", uri); // FIXME - avoid unnecessary strlen soup_message_set_request (msg, "text/xml", SOUP_MEMORY_COPY, (char*)buf->content, strlen ((char*)buf->content)); req = new add_inv_item_req(); req->user_glue = user_glue; req->cb = cb; req->cb_priv = cb_priv; uuid_copy(req->item_id, inv->item_id); user_grid_glue_ref(user_glue); caj_queue_soup_message(sgrp, SOUP_MESSAGE(msg), got_add_inv_item_resp, req); xmlFreeTextWriter(writer); xmlBufferFree(buf); return; free_fail: xmlFreeTextWriter(writer); free_fail_1: xmlBufferFree(buf); fail: printf("DEBUG: ran into issues sending inventory NewItem request\n"); uuid_clear(u); cb(cb_priv, FALSE, u); }