const char * password_scheme_detect(const char *plain_password, const char *crypted_password, const struct password_generate_params *params) { struct hash_iterate_context *ctx; const char *key; const struct password_scheme *scheme; const unsigned char *raw_password; size_t raw_password_size; const char *error; ctx = hash_table_iterate_init(password_schemes); while (hash_table_iterate(ctx, password_schemes, &key, &scheme)) { if (password_decode(crypted_password, scheme->name, &raw_password, &raw_password_size, &error) <= 0) continue; if (password_verify(plain_password, params, scheme->name, raw_password, raw_password_size, &error) > 0) break; key = NULL; } hash_table_iterate_deinit(&ctx); return key; }
void auth_request_handler_abort_requests(struct auth_request_handler *handler) { struct hash_iterate_context *iter; void *key; struct auth_request *auth_request; iter = hash_table_iterate_init(handler->requests); while (hash_table_iterate(iter, handler->requests, &key, &auth_request)) { switch (auth_request->state) { case AUTH_REQUEST_STATE_NEW: case AUTH_REQUEST_STATE_MECH_CONTINUE: case AUTH_REQUEST_STATE_FINISHED: auth_request_unref(&auth_request); hash_table_remove(handler->requests, key); break; case AUTH_REQUEST_STATE_PASSDB: case AUTH_REQUEST_STATE_USERDB: /* can't abort a pending passdb/userdb lookup */ break; case AUTH_REQUEST_STATE_MAX: i_unreached(); } } hash_table_iterate_deinit(&iter); }
void db_passwd_file_unref(struct db_passwd_file **_db) { struct db_passwd_file *db = *_db; struct db_passwd_file **p; struct hash_iterate_context *iter; char *path; struct passwd_file *file; *_db = NULL; i_assert(db->refcount >= 0); if (--db->refcount > 0) return; for (p = &passwd_files; *p != NULL; p = &(*p)->next) { if (*p == db) { *p = db->next; break; } } if (db->default_file != NULL) passwd_file_free(db->default_file); else { iter = hash_table_iterate_init(db->files); while (hash_table_iterate(iter, db->files, &path, &file)) passwd_file_free(file); hash_table_iterate_deinit(&iter); hash_table_destroy(&db->files); } i_free(db->path); i_free(db); }
void id_table_show_all_items() { struct scopes *tmp; tmp = scopes; printf("getting info about id_items...\n"); while (tmp != NULL) { id_item_t *item; struct hash_table_iter *iter; void *key; iter = hash_table_iterate_init(tmp->scope); while (hash_table_iterate(iter, &key, (void **)&item) == TRUE) { printf("name = %s, type = %d\n", item->name, item->type); } hash_table_iterate_deinit(&iter); tmp = tmp->prev; } printf("finishing...\n"); }
static void replicator_abort_all_requests(struct replicator_connection *conn) { struct hash_iterate_context *iter; void *key, *value; iter = hash_table_iterate_init(conn->requests); while (hash_table_iterate(iter, conn->requests, &key, &value)) conn->callback(FALSE, value); hash_table_iterate_deinit(&iter); hash_table_clear(conn->requests, TRUE); }
static void stats_drop_stale(struct top_context *ctx) { struct hash_iterate_context *iter; char *id; struct top_line *line; iter = hash_table_iterate_init(ctx->sessions); while (hash_table_iterate(iter, ctx->sessions, &id, &line)) { if (line->flip != ctx->flip) hash_table_remove(ctx->sessions, id); } hash_table_iterate_deinit(&iter); }
void id_table_free(struct hash_table *table) { void *key, *data; struct hash_table_iter *iter; iter = hash_table_iterate_init(table); while (hash_table_iterate(iter, &key, &data) != FALSE) id_table_destroy_cb((id_table_item_t*)data); hash_table_iterate_deinit(&iter); hash_table_destroy(&table); }
void str_table_deinit(struct str_table **_table) { struct str_table *table = *_table; struct hash_iterate_context *iter; char *key; void *value; *_table = NULL; iter = hash_table_iterate_init(table->hash); while (hash_table_iterate(iter, table->hash, &key, &value)) i_free(key); hash_table_iterate_deinit(&iter); hash_table_destroy(&table->hash); i_free(table); }
static void checkpassword_deinit(struct userdb_module *_module) { struct checkpassword_userdb_module *module = (struct checkpassword_userdb_module *)_module; struct hash_iterate_context *iter; void *key, *value; iter = hash_table_iterate_init(module->clients); while (hash_table_iterate(iter, &key, &value)) { checkpassword_request_finish(value, USERDB_RESULT_INTERNAL_FAILURE); } hash_table_iterate_deinit(&iter); hash_table_destroy(&module->clients); if (checkpassword_userdb_children != NULL) child_wait_free(&checkpassword_userdb_children); }
void hash_ctx_table_destroy() { void *key, *data; struct hash_table_iter *iter; iter = hash_table_iterate_init(ctx_table->hash); while (hash_table_iterate(iter, &key, &data) != FALSE) hash_ctx_destroy_cb((struct hash_ctx *)data); hash_table_iterate_deinit(&iter); hash_table_destroy(&ctx_table->hash); ufree(ctx_table); ctx_table = NULL; }
static void auth_server_connection_remove_requests(struct auth_server_connection *conn) { static const char *const temp_failure_args[] = { "temp", NULL }; struct hash_iterate_context *iter; void *key, *value; iter = hash_table_iterate_init(conn->requests); while (hash_table_iterate(iter, &key, &value)) { struct auth_client_request *request = value; auth_client_request_server_input(request, AUTH_REQUEST_STATUS_FAIL, temp_failure_args); } hash_table_iterate_deinit(&iter); hash_table_clear(conn->requests, FALSE); }
void login_proxy_state_deinit(struct login_proxy_state **_state) { struct login_proxy_state *state = *_state; struct hash_iterate_context *iter; struct login_proxy_record *rec; *_state = NULL; /* sanity check: */ iter = hash_table_iterate_init(state->hash); while (hash_table_iterate(iter, state->hash, &rec, &rec)) i_assert(rec->num_waiting_connections == 0); hash_table_iterate_deinit(&iter); timeout_remove(&state->to_reopen); login_proxy_state_close(state); hash_table_destroy(&state->hash); pool_unref(&state->pool); i_free(state); }
static void auth_server_connection_remove_requests(struct auth_server_connection *conn, const char *disconnect_reason) { static const char *const temp_failure_args[] = { "temp", NULL }; struct hash_iterate_context *iter; void *key; struct auth_client_request *request; time_t created, oldest = 0; unsigned int request_count = 0; if (hash_table_count(conn->requests) == 0) return; iter = hash_table_iterate_init(conn->requests); while (hash_table_iterate(iter, conn->requests, &key, &request)) { if (!auth_client_request_is_aborted(request)) { request_count++; created = auth_client_request_get_create_time(request); if (oldest > created || oldest == 0) oldest = created; } auth_client_request_server_input(request, AUTH_REQUEST_STATUS_INTERNAL_FAIL, temp_failure_args); } hash_table_iterate_deinit(&iter); hash_table_clear(conn->requests, FALSE); if (request_count > 0) { i_warning("Auth connection closed with %u pending requests " "(max %u secs, pid=%s, %s)", request_count, (unsigned int)(ioloop_time - oldest), my_pid, disconnect_reason); } }
static uint32_t get_uint32(const unsigned char *data) { return data[0] | (data[1] << 8) | (data[2] << 16) | ((unsigned int)data[3] << 24); } void dsync_mailbox_states_export(const HASH_TABLE_TYPE(dsync_mailbox_state) states, string_t *output) { struct hash_iterate_context *iter; struct dsync_mailbox_state *state; uint8_t *guid; buffer_t *buf = buffer_create_dynamic(pool_datastack_create(), 128); uint32_t crc = 0; iter = hash_table_iterate_init(states); while (hash_table_iterate(iter, states, &guid, &state)) { buffer_append(buf, state->mailbox_guid, sizeof(state->mailbox_guid)); put_uint32(buf, state->last_uidvalidity); put_uint32(buf, state->last_common_uid); put_uint32(buf, state->last_common_modseq & 0xffffffffU); put_uint32(buf, state->last_common_modseq >> 32); put_uint32(buf, state->last_common_pvt_modseq & 0xffffffffU); put_uint32(buf, state->last_common_pvt_modseq >> 32); if (buf->used % 3 == 0) { crc = crc32_data_more(crc, buf->data, buf->used); base64_encode(buf->data, buf->used, output); buffer_set_used_size(buf, 0); } }