static void key_add_continue(struct adns_continuation *ac, err_t ugh) { struct key_add_continuation *kc = (void *) ac; struct key_add_common *oc = kc->common; passert(whack_log_fd == NULL_FD); whack_log_fd = oc->whack_fd; if (ugh != NULL) { oc->diag[kc->lookingfor] = clone_str(ugh); } else { oc->success = TRUE; transfer_to_public_keys(kc->ac.gateways_from_dns #ifdef USE_KEYRR , &kc->ac.keys_from_dns #endif /* USE_KEYRR */ ); } oc->refCount--; key_add_merge(oc, ac->id); whack_log_fd = NULL_FD; }
static void key_add_request(const struct whack_message *msg) { struct id keyid; err_t ugh = atoid(msg->keyid, &keyid, FALSE, FALSE); if (ugh != NULL) { loglog(RC_BADID, "bad --keyid \"%s\": %s", msg->keyid, ugh); } else { if (!msg->whack_addkey) delete_public_keys(&pluto_pubkeys, &keyid, msg->pubkey_alg); if (msg->keyval.len == 0) { struct key_add_common *oc = alloc_thing(struct key_add_common, "key add common things"); enum key_add_attempt kaa; /* initialize state shared by queries */ oc->refCount = 0; oc->whack_fd = dup_any(whack_log_fd); oc->success = FALSE; for (kaa = ka_TXT; kaa != ka_roof; kaa++) { struct key_add_continuation *kc = alloc_thing( struct key_add_continuation, "key add continuation"); oc->diag[kaa] = NULL; oc->refCount++; kc->common = oc; kc->lookingfor = kaa; switch (kaa) { case ka_TXT: ugh = start_adns_query(&keyid, &keyid, /* same */ ns_t_txt, key_add_continue, &kc->ac); break; #ifdef USE_KEYRR case ka_KEY: ugh = start_adns_query(&keyid, NULL, ns_t_key, key_add_continue, &kc->ac); break; #endif /* USE_KEYRR */ default: bad_case(kaa); /* suppress gcc warning */ } if (ugh != NULL) { oc->diag[kaa] = clone_str(ugh, "early key add failure"); oc->refCount--; } } /* Done launching queries. * Handle total failure case. */ key_add_merge(oc, &keyid); } else { ugh = add_public_key(&keyid, DAL_LOCAL, msg->pubkey_alg, &msg->keyval, &pluto_pubkeys); if (ugh != NULL) loglog(RC_LOG_SERIOUS, "%s", ugh); } }
static void key_add_request(const whack_message_t *msg) { identification_t *key_id; key_id = identification_create_from_string(msg->keyid); if (!msg->whack_addkey) { delete_public_keys(key_id, msg->pubkey_alg, NULL, chunk_empty); } if (msg->keyval.len == 0) { struct key_add_common *oc = malloc_thing(struct key_add_common); enum key_add_attempt kaa; err_t ugh; /* initialize state shared by queries */ oc->refCount = 0; oc->whack_fd = dup_any(whack_log_fd); oc->success = FALSE; for (kaa = ka_TXT; kaa != ka_roof; kaa++) { struct key_add_continuation *kc; oc->diag[kaa] = NULL; oc->refCount++; kc = malloc_thing(struct key_add_continuation); kc->common = oc; kc->lookingfor = kaa; switch (kaa) { case ka_TXT: ugh = start_adns_query(key_id , key_id /* same */ , T_TXT , key_add_continue , &kc->ac); break; #ifdef USE_KEYRR case ka_KEY: ugh = start_adns_query(key_id , NULL , T_KEY , key_add_continue , &kc->ac); break; #endif /* USE_KEYRR */ default: bad_case(kaa); /* suppress gcc warning */ } if (ugh) { oc->diag[kaa] = clone_str(ugh); oc->refCount--; } } /* Done launching queries. Handle total failure case. */ key_add_merge(oc, key_id); } else { if (!add_public_key(key_id, DAL_LOCAL, msg->pubkey_alg, msg->keyval,