From 9e896dc45792ea7d2f267b4fbd49542d10339c63 Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Fri, 24 Feb 2012 12:48:08 -0500 Subject: SSH: Save SSH host name aliases --- src/providers/data_provider_be.c | 4 +++- src/providers/ipa/ipa_hostid.c | 37 ++++++++----------------------------- 2 files changed, 11 insertions(+), 30 deletions(-) (limited to 'src/providers') diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c index 2cea1933c..7e27ceacd 100644 --- a/src/providers/data_provider_be.c +++ b/src/providers/data_provider_be.c @@ -1182,7 +1182,9 @@ static int be_host_handler(DBusMessage *message, struct sbus_connection *conn) if (filter) { if (strncmp(filter, "name=", 5) == 0) { req->filter_type = BE_FILTER_NAME; - req->filter_value = &filter[5]; + ret = split_service_name_filter(req, &filter[5], + &req->filter_value, + &req->extra_value); } else { err_maj = DP_ERR_FATAL; err_min = EINVAL; diff --git a/src/providers/ipa/ipa_hostid.c b/src/providers/ipa/ipa_hostid.c index 6121f15a3..8fcc59ed2 100644 --- a/src/providers/ipa/ipa_hostid.c +++ b/src/providers/ipa/ipa_hostid.c @@ -33,6 +33,7 @@ struct hosts_get_state { struct sysdb_ctx *sysdb; struct sss_domain_info *domain; const char *name; + const char *alias; size_t count; struct sysdb_attrs **hosts; @@ -44,6 +45,7 @@ hosts_get_send(TALLOC_CTX *memctx, struct tevent_context *ev, struct ipa_hostid_ctx *hostid_ctx, const char *name, + const char *alias, int attrs_type); static errno_t hosts_get_recv(struct tevent_req *req, @@ -82,7 +84,7 @@ ipa_host_info_handler(struct be_req *breq) } req = hosts_get_send(breq, breq->be_ctx->ev, hostid_ctx, - ar->filter_value, + ar->filter_value, ar->extra_value, ar->attr_type); if (!req) { ret = ENOMEM; @@ -148,6 +150,7 @@ hosts_get_send(TALLOC_CTX *memctx, struct tevent_context *ev, struct ipa_hostid_ctx *hostid_ctx, const char *name, + const char *alias, int attrs_type) { struct tevent_req *req; @@ -174,6 +177,7 @@ hosts_get_send(TALLOC_CTX *memctx, state->sysdb = ctx->be->sysdb; state->domain = ctx->be->domain; state->name = name; + state->alias = alias; ret = hosts_get_retry(req); if (ret != EOK) { @@ -227,8 +231,7 @@ hosts_get_connect_done(struct tevent_req *subreq) subreq = ipa_host_info_send(state, state->ev, state->sysdb, sdap_id_op_handle(state->op), state->ctx->sdap_id_ctx->opts, state->name, - state->ctx->ipa_opts->host_map, - state->ctx->ipa_opts->hostgroup_map, + state->ctx->ipa_opts->host_map, NULL, state->ctx->host_search_bases); if (!subreq) { tevent_req_error(req, ENOMEM); @@ -246,7 +249,6 @@ hosts_get_done(struct tevent_req *subreq) struct hosts_get_state); int dp_error = DP_ERR_FATAL; errno_t ret; - bool in_transaction = false; ret = ipa_host_info_recv(subreq, state, &state->count, &state->hosts, @@ -267,20 +269,6 @@ hosts_get_done(struct tevent_req *subreq) goto done; } - ret = sysdb_transaction_start(state->sysdb); - if (ret != EOK) { - DEBUG(SSSDBG_CRIT_FAILURE, - ("Failed to start update transaction\n")); - goto done; - } - - in_transaction = true; - - ret = sysdb_delete_ssh_host(state->sysdb, state->name); - if (ret != EOK && ret != ENOENT) { - goto done; - } - if (state->count == 0) { DEBUG(SSSDBG_CRIT_FAILURE, ("No host with name [%s] found.\n", state->name)); @@ -295,18 +283,12 @@ hosts_get_done(struct tevent_req *subreq) goto done; } - ret = sysdb_save_ssh_host(state->sysdb, - state->name, state->hosts[0]); + ret = sysdb_store_ssh_host(state->sysdb, state->name, state->alias, + state->hosts[0]); if (ret != EOK) { goto done; } - ret = sysdb_transaction_commit(state->sysdb); - if (ret != EOK) { - goto done; - } - - in_transaction = false; dp_error = DP_ERR_OK; done: @@ -314,9 +296,6 @@ done: if (ret == EOK) { tevent_req_done(req); } else { - if (in_transaction) { - sysdb_transaction_cancel(state->sysdb); - } tevent_req_error(req, ret); } } -- cgit