From b193250ca7b71e4f07f3016e0addbc4ba521c6a5 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 | 34 +++++++--------------------------- 2 files changed, 10 insertions(+), 28 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 873cc5296..8ab24fe5a 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; const char **attrs; size_t count; @@ -45,6 +46,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, @@ -83,7 +85,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; @@ -149,6 +151,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; @@ -175,6 +178,7 @@ hosts_get_send(TALLOC_CTX *memctx, state->sysdb = ctx->be->sysdb; state->domain = ctx->be->domain; state->name = name; + state->alias = alias; /* TODO: handle attrs_type */ ret = build_attrs_from_map(state, ctx->opts->host_map, @@ -253,7 +257,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, @@ -274,20 +277,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)); @@ -302,18 +291,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: @@ -321,9 +304,6 @@ done: if (ret == EOK) { tevent_req_done(req); } else { - if (in_transaction) { - sysdb_transaction_cancel(state->sysdb); - } tevent_req_error(req, ret); } } -- cgit