summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2012-02-03 22:41:30 +0100
committerJakub Hrozek <jhrozek@redhat.com>2012-02-07 00:26:57 +0100
commit1a7d1977037864e52858058777af8ff8401547dd (patch)
tree414005d5758301a810cd8240ab533eb09a81851e /src
parent74505b09d056883741e90cac45838c844365cae5 (diff)
downloadsssd-1a7d1977037864e52858058777af8ff8401547dd.tar.gz
sssd-1a7d1977037864e52858058777af8ff8401547dd.tar.bz2
sssd-1a7d1977037864e52858058777af8ff8401547dd.zip
IPA: Add host info handler
Diffstat (limited to 'src')
-rw-r--r--src/config/etc/sssd.api.d/sssd-ipa.conf1
-rw-r--r--src/db/sysdb_ssh.c114
-rw-r--r--src/db/sysdb_ssh.h45
-rw-r--r--src/man/sssd-ipa.5.xml12
-rw-r--r--src/providers/ipa/ipa_access.c2
-rw-r--r--src/providers/ipa/ipa_common.c1
-rw-r--r--src/providers/ipa/ipa_common.h1
-rw-r--r--src/providers/ipa/ipa_hostid.c345
-rw-r--r--src/providers/ipa/ipa_hostid.h33
-rw-r--r--src/providers/ipa/ipa_hosts.c13
-rw-r--r--src/providers/ipa/ipa_hosts.h2
-rw-r--r--src/providers/ipa/ipa_init.c49
-rw-r--r--src/providers/ipa/ipa_session.c3
13 files changed, 616 insertions, 5 deletions
diff --git a/src/config/etc/sssd.api.d/sssd-ipa.conf b/src/config/etc/sssd.api.d/sssd-ipa.conf
index 00a71ab4..88c33f8b 100644
--- a/src/config/etc/sssd.api.d/sssd-ipa.conf
+++ b/src/config/etc/sssd.api.d/sssd-ipa.conf
@@ -105,6 +105,7 @@ ldap_service_search_base = str, None, false
ldap_service_entry_usn = str, None, false
ipa_host_object_class = str, None, false
ipa_host_fqdn = str, None, false
+ipa_host_ssh_public_key = str, None, false
[provider/ipa/auth]
krb5_ccachedir = str, None, false
diff --git a/src/db/sysdb_ssh.c b/src/db/sysdb_ssh.c
new file mode 100644
index 00000000..c2ea35b0
--- /dev/null
+++ b/src/db/sysdb_ssh.c
@@ -0,0 +1,114 @@
+/*
+ Authors:
+ Jan Cholasta <jcholast@redhat.com>
+
+ Copyright (C) 2012 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <talloc.h>
+
+#include "db/sysdb_ssh.h"
+#include "db/sysdb_private.h"
+
+errno_t
+sysdb_save_ssh_host(struct sysdb_ctx *sysdb_ctx,
+ const char *name,
+ struct sysdb_attrs *attrs)
+{
+ errno_t ret;
+ TALLOC_CTX *tmp_ctx;
+
+ DEBUG(SSSDBG_TRACE_FUNC, ("Adding host %s\n", name));
+
+ tmp_ctx = talloc_new(NULL);
+ if (!tmp_ctx) {
+ return ENOMEM;
+ }
+
+ if (!attrs) {
+ attrs = sysdb_new_attrs(tmp_ctx);
+ if (!attrs) {
+ ret = ENOMEM;
+ goto done;
+ }
+ }
+
+ ret = sysdb_store_custom(sysdb_ctx, name, SSH_HOSTS_SUBDIR, attrs);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, ("sysdb_store_custom failed [%d]: %s\n",
+ ret, strerror(ret)));
+ goto done;
+ }
+
+ ret = EOK;
+done:
+ talloc_free(tmp_ctx);
+ return ret;
+}
+
+errno_t
+sysdb_delete_ssh_host(struct sysdb_ctx *sysdb_ctx,
+ const char *name)
+{
+ DEBUG(SSSDBG_TRACE_FUNC, ("Deleting host %s\n", name));
+ return sysdb_delete_custom(sysdb_ctx, name, SSH_HOSTS_SUBDIR);
+}
+
+errno_t
+sysdb_search_ssh_hosts(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *sysdb,
+ const char *name,
+ const char **attrs,
+ struct ldb_message ***hosts,
+ size_t *host_count)
+{
+ errno_t ret;
+ TALLOC_CTX *tmp_ctx;
+ const char *filter;
+ size_t count;
+ struct ldb_message **msgs;
+
+ tmp_ctx = talloc_new(NULL);
+ if (!tmp_ctx) return ENOMEM;
+
+ filter = talloc_asprintf(tmp_ctx, "(%s=%s)", SYSDB_NAME, name);
+ if (!filter) {
+ ret = ENOMEM;
+ goto done;
+ }
+
+ ret = sysdb_search_custom(tmp_ctx, sysdb, filter, SSH_HOSTS_SUBDIR, attrs,
+ &count, &msgs);
+ if (ret != EOK && ret != ENOENT) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Error looking up host [%s]", name));
+ goto done;
+ } if (ret == ENOENT) {
+ DEBUG(SSSDBG_TRACE_FUNC, ("No such host\n"));
+ *hosts = NULL;
+ *host_count = 0;
+ goto done;
+ }
+
+ *hosts = talloc_steal(mem_ctx, msgs);
+ *host_count = count;
+ ret = EOK;
+
+done:
+ talloc_free(tmp_ctx);
+
+ return ret;
+}
diff --git a/src/db/sysdb_ssh.h b/src/db/sysdb_ssh.h
new file mode 100644
index 00000000..f9d8d6ec
--- /dev/null
+++ b/src/db/sysdb_ssh.h
@@ -0,0 +1,45 @@
+/*
+ Authors:
+ Jan Cholasta <jcholast@redhat.com>
+
+ Copyright (C) 2012 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SYSDB_SSH_H_
+#define _SYSDB_SSH_H_
+
+#include "db/sysdb.h"
+
+#define SSH_HOSTS_SUBDIR "ssh_hosts"
+
+errno_t
+sysdb_save_ssh_host(struct sysdb_ctx *sysdb_ctx,
+ const char *name,
+ struct sysdb_attrs *attrs);
+
+errno_t
+sysdb_delete_ssh_host(struct sysdb_ctx *sysdb_ctx,
+ const char *name);
+
+errno_t
+sysdb_search_ssh_hosts(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *sysdb,
+ const char *name,
+ const char **attrs,
+ struct ldb_message ***hosts,
+ size_t *host_count);
+
+#endif /* _SYSDB_SSH_H_ */
diff --git a/src/man/sssd-ipa.5.xml b/src/man/sssd-ipa.5.xml
index 547fee55..bddd3db1 100644
--- a/src/man/sssd-ipa.5.xml
+++ b/src/man/sssd-ipa.5.xml
@@ -508,6 +508,18 @@
</para>
</listitem>
</varlistentry>
+ <varlistentry condition="with_ssh">
+ <term>ipa_host_ssh_public_key (string)</term>
+ <listitem>
+ <para>
+ The LDAP attribute that contains the host's SSH
+ public keys.
+ </para>
+ <para>
+ Default: ipaSshPubKey
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</para>
</refsect1>
diff --git a/src/providers/ipa/ipa_access.c b/src/providers/ipa/ipa_access.c
index 03945f72..1eed86c3 100644
--- a/src/providers/ipa/ipa_access.c
+++ b/src/providers/ipa/ipa_access.c
@@ -301,7 +301,7 @@ static int hbac_get_host_info_step(struct hbac_ctx *hbac_ctx)
hbac_ctx_sysdb(hbac_ctx),
sdap_id_op_handle(hbac_ctx->sdap_op),
hbac_ctx_sdap_id_ctx(hbac_ctx)->opts,
- hostname, hbac_ctx->host_attrs, true,
+ hostname, hbac_ctx->host_attrs, NULL, 0, true,
hbac_ctx->access_ctx->host_search_bases);
if (req == NULL) {
DEBUG(1, ("Could not get host info\n"));
diff --git a/src/providers/ipa/ipa_common.c b/src/providers/ipa/ipa_common.c
index 2f987c20..3620c35d 100644
--- a/src/providers/ipa/ipa_common.c
+++ b/src/providers/ipa/ipa_common.c
@@ -183,6 +183,7 @@ struct sdap_attr_map ipa_host_map[] = {
{ "ipa_host_object_class", "ipaHost", SYSDB_HOST_CLASS, NULL },
{ "ipa_host_fqdn", "fqdn", SYSDB_NAME, NULL },
{ "ipa_host_member_of", "memberOf", SYSDB_MEMBEROF, NULL },
+ { "ipa_host_ssh_public_key", "ipaSshPubKey", SYSDB_SSH_PUBKEY, NULL }
};
static struct sdap_attr_map ipa_selinux_user_map[] = {
diff --git a/src/providers/ipa/ipa_common.h b/src/providers/ipa/ipa_common.h
index 3c32b178..2d0e0e1d 100644
--- a/src/providers/ipa/ipa_common.h
+++ b/src/providers/ipa/ipa_common.h
@@ -79,6 +79,7 @@ enum ipa_host_attrs {
IPA_OC_HOST = 0,
IPA_AT_HOST_FQDN,
IPA_AT_HOST_MEMBER_OF,
+ IPA_AT_HOST_SSH_PUBLIC_KEY,
IPA_OPTS_HOST /* attrs counter */
};
diff --git a/src/providers/ipa/ipa_hostid.c b/src/providers/ipa/ipa_hostid.c
new file mode 100644
index 00000000..873cc529
--- /dev/null
+++ b/src/providers/ipa/ipa_hostid.c
@@ -0,0 +1,345 @@
+/*
+ Authors:
+ Jan Cholasta <jcholast@redhat.com>
+
+ Copyright (C) 2012 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "util/util.h"
+#include "util/crypto/sss_crypto.h"
+#include "db/sysdb_ssh.h"
+#include "providers/ldap/ldap_common.h"
+#include "providers/ipa/ipa_common.h"
+#include "providers/ipa/ipa_hostid.h"
+#include "providers/ipa/ipa_hosts.h"
+
+struct hosts_get_state {
+ struct tevent_context *ev;
+ struct ipa_hostid_ctx *ctx;
+ struct sdap_id_op *op;
+ struct sysdb_ctx *sysdb;
+ struct sss_domain_info *domain;
+ const char *name;
+ const char **attrs;
+
+ size_t count;
+ struct sysdb_attrs **hosts;
+ int dp_error;
+};
+
+struct tevent_req *
+hosts_get_send(TALLOC_CTX *memctx,
+ struct tevent_context *ev,
+ struct ipa_hostid_ctx *hostid_ctx,
+ const char *name,
+ int attrs_type);
+static errno_t
+hosts_get_recv(struct tevent_req *req,
+ int *dp_error_out);
+
+static void
+ipa_host_info_hosts_done(struct tevent_req *req);
+
+void
+ipa_host_info_handler(struct be_req *breq)
+{
+ struct ipa_hostid_ctx *hostid_ctx;
+ struct sdap_id_ctx *ctx;
+ struct be_acct_req *ar;
+ struct tevent_req *req;
+ int dp_error = DP_ERR_FATAL;
+ errno_t ret = EOK;
+ const char *err = "Unknown Error";
+
+ hostid_ctx = talloc_get_type(breq->be_ctx->bet_info[BET_HOSTID].pvt_bet_data, struct ipa_hostid_ctx);
+ ctx = hostid_ctx->sdap_id_ctx;
+
+ if (be_is_offline(ctx->be)) {
+ dp_error = DP_ERR_OFFLINE;
+ ret = EAGAIN;
+ err = "Offline";
+ goto done;
+ }
+
+ ar = talloc_get_type(breq->req_data, struct be_acct_req);
+
+ if (ar->filter_type != BE_FILTER_NAME) {
+ ret = EINVAL;
+ err = "Invalid filter type";
+ goto done;
+ }
+
+ req = hosts_get_send(breq, breq->be_ctx->ev, hostid_ctx,
+ ar->filter_value,
+ ar->attr_type);
+ if (!req) {
+ ret = ENOMEM;
+ err = "Out of memory";
+ goto done;
+ }
+
+ tevent_req_set_callback(req, ipa_host_info_hosts_done, breq);
+
+ ret = EOK;
+
+done:
+ if (ret != EOK) return sdap_handler_done(breq, dp_error, ret, err);
+}
+
+static void
+ipa_host_info_complete(struct be_req *breq, int dp_error,
+ errno_t ret, const char *default_error_text)
+{
+ const char* error_text;
+
+ if (dp_error == DP_ERR_OK) {
+ if (ret == EOK) {
+ error_text = NULL;
+ } else {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Bug: dp_error is OK on failed request"));
+ dp_error = DP_ERR_FATAL;
+ error_text = default_error_text;
+ }
+ } else if (dp_error == DP_ERR_OFFLINE) {
+ error_text = "Offline";
+ } else if (dp_error == DP_ERR_FATAL && ret == ENOMEM) {
+ error_text = "Out of memory";
+ } else {
+ error_text = default_error_text;
+ }
+
+ sdap_handler_done(breq, dp_error, ret, error_text);
+}
+
+static void
+ipa_host_info_hosts_done(struct tevent_req *req)
+{
+ struct be_req *breq = tevent_req_callback_data(req, struct be_req);
+ int ret, dp_error;
+
+ ret = hosts_get_recv(req, &dp_error);
+ talloc_zfree(req);
+
+ ipa_host_info_complete(breq, dp_error, ret, "Host lookup failed");
+}
+
+static errno_t
+hosts_get_retry(struct tevent_req *req);
+static void
+hosts_get_connect_done(struct tevent_req *subreq);
+static void
+hosts_get_done(struct tevent_req *subreq);
+
+struct tevent_req *
+hosts_get_send(TALLOC_CTX *memctx,
+ struct tevent_context *ev,
+ struct ipa_hostid_ctx *hostid_ctx,
+ const char *name,
+ int attrs_type)
+{
+ struct tevent_req *req;
+ struct hosts_get_state *state;
+ struct sdap_id_ctx *ctx;
+ errno_t ret;
+
+ ctx = hostid_ctx->sdap_id_ctx;
+
+ req = tevent_req_create(memctx, &state, struct hosts_get_state);
+ if (!req) return NULL;
+
+ state->ev = ev;
+ state->ctx = hostid_ctx;
+ state->dp_error = DP_ERR_FATAL;
+
+ state->op = sdap_id_op_create(state, ctx->conn_cache);
+ if (!state->op) {
+ DEBUG(SSSDBG_OP_FAILURE, ("sdap_id_op_create failed\n"));
+ ret = ENOMEM;
+ goto fail;
+ }
+
+ state->sysdb = ctx->be->sysdb;
+ state->domain = ctx->be->domain;
+ state->name = name;
+
+ /* TODO: handle attrs_type */
+ ret = build_attrs_from_map(state, ctx->opts->host_map,
+ IPA_OPTS_HOST, &state->attrs);
+ if (ret != EOK) goto fail;
+
+ ret = hosts_get_retry(req);
+ if (ret != EOK) {
+ goto fail;
+ }
+
+ return req;
+
+fail:
+ tevent_req_error(req, ret);
+ tevent_req_post(req, ev);
+ return req;
+}
+
+static errno_t
+hosts_get_retry(struct tevent_req *req)
+{
+ struct hosts_get_state *state = tevent_req_data(req,
+ struct hosts_get_state);
+ struct tevent_req *subreq;
+ errno_t ret = EOK;
+
+ subreq = sdap_id_op_connect_send(state->op, state, &ret);
+ if (!subreq) {
+ return ret;
+ }
+
+ tevent_req_set_callback(subreq, hosts_get_connect_done, req);
+ return EOK;
+}
+
+static void
+hosts_get_connect_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(subreq,
+ struct tevent_req);
+ struct hosts_get_state *state = tevent_req_data(req,
+ struct hosts_get_state);
+ int dp_error = DP_ERR_FATAL;
+ errno_t ret;
+ struct sdap_id_ctx *ctx = state->ctx->sdap_id_ctx;
+
+ ret = sdap_id_op_connect_recv(subreq, &dp_error);
+ talloc_zfree(subreq);
+
+ if (ret != EOK) {
+ state->dp_error = dp_error;
+ tevent_req_error(req, ret);
+ return;
+ }
+
+ subreq = ipa_host_info_send(state, state->ev, state->sysdb,
+ sdap_id_op_handle(state->op),
+ ctx->opts, state->name,
+ state->attrs, ctx->opts->host_map,
+ IPA_OPTS_HOST, false,
+ state->ctx->host_search_bases);
+ if (!subreq) {
+ tevent_req_error(req, ENOMEM);
+ return;
+ }
+ tevent_req_set_callback(subreq, hosts_get_done, req);
+}
+
+static void
+hosts_get_done(struct tevent_req *subreq)
+{
+ struct tevent_req *req = tevent_req_callback_data(subreq,
+ struct tevent_req);
+ struct hosts_get_state *state = tevent_req_data(req,
+ 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,
+ NULL, NULL);
+ talloc_zfree(subreq);
+
+ ret = sdap_id_op_done(state->op, ret, &dp_error);
+ if (dp_error == DP_ERR_OK && ret != EOK) {
+ /* retry */
+ ret = hosts_get_retry(req);
+ if (ret != EOK) {
+ goto done;
+ }
+ return;
+ }
+
+ if (ret != EOK && ret != ENOENT) {
+ 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));
+ ret = EINVAL;
+ goto done;
+ }
+
+ if (state->count > 1) {
+ DEBUG(SSSDBG_CRIT_FAILURE,
+ ("Found more than one host with name [%s].\n", state->name));
+ ret = EINVAL;
+ goto done;
+ }
+
+ ret = sysdb_save_ssh_host(state->sysdb,
+ state->name, 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:
+ state->dp_error = dp_error;
+ if (ret == EOK) {
+ tevent_req_done(req);
+ } else {
+ if (in_transaction) {
+ sysdb_transaction_cancel(state->sysdb);
+ }
+ tevent_req_error(req, ret);
+ }
+}
+
+static errno_t
+hosts_get_recv(struct tevent_req *req,
+ int *dp_error_out)
+{
+ struct hosts_get_state *state = tevent_req_data(req,
+ struct hosts_get_state);
+
+ if (dp_error_out) {
+ *dp_error_out = state->dp_error;
+ }
+
+ TEVENT_REQ_RETURN_ON_ERROR(req);
+
+ return EOK;
+}
diff --git a/src/providers/ipa/ipa_hostid.h b/src/providers/ipa/ipa_hostid.h
new file mode 100644
index 00000000..40ad6bc4
--- /dev/null
+++ b/src/providers/ipa/ipa_hostid.h
@@ -0,0 +1,33 @@
+/*
+ Authors:
+ Jan Cholasta <jcholast@redhat.com>
+
+ Copyright (C) 2012 Red Hat
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _IPA_HOSTID_H_
+#define _IPA_HOSTID_H_
+
+struct ipa_hostid_ctx {
+ struct sdap_id_ctx *sdap_id_ctx;
+ struct dp_option *ipa_options;
+
+ struct sdap_search_base **host_search_bases;
+};
+
+void ipa_host_info_handler(struct be_req *be_req);
+
+#endif /* _IPA_HOSTID_H_ */
diff --git a/src/providers/ipa/ipa_hosts.c b/src/providers/ipa/ipa_hosts.c
index 04ce9adf..e939ab7f 100644
--- a/src/providers/ipa/ipa_hosts.c
+++ b/src/providers/ipa/ipa_hosts.c
@@ -33,6 +33,8 @@ struct ipa_host_state {
struct sdap_handle *sh;
struct sdap_options *opts;
const char **attrs;
+ struct sdap_attr_map *map;
+ int map_num_attrs;
struct sdap_search_base **search_bases;
int search_base_iter;
@@ -82,6 +84,8 @@ ipa_host_info_send(TALLOC_CTX *mem_ctx,
struct sdap_options *opts,
const char *hostname,
const char **attrs,
+ struct sdap_attr_map *map,
+ int map_num_attrs,
bool fetch_hostgroups,
struct sdap_search_base **search_bases)
{
@@ -103,6 +107,8 @@ ipa_host_info_send(TALLOC_CTX *mem_ctx,
state->search_base_iter = 0;
state->cur_filter = NULL;
state->attrs = attrs;
+ state->map = map;
+ state->map_num_attrs = map_num_attrs;
state->fetch_hostgroups = fetch_hostgroups;
if (hostname == NULL) {
@@ -160,7 +166,8 @@ static errno_t ipa_host_info_next(struct tevent_req *req,
subreq = sdap_get_generic_send(state, state->ev, state->opts,
state->sh, base->basedn,
base->scope, state->cur_filter,
- state->attrs, NULL, 0,
+ state->attrs, state->map,
+ state->map_num_attrs,
dp_opt_get_int(state->opts->basic,
SDAP_ENUM_SEARCH_TIMEOUT));
if (subreq == NULL) {
@@ -442,8 +449,8 @@ errno_t ipa_host_info_recv(struct tevent_req *req,
talloc_steal(state->hosts, state->hosts[c]);
}
- *hostgroup_count = state->hostgroup_count;
- *hostgroups = talloc_steal(mem_ctx, state->hostgroups);
+ if (hostgroup_count) *hostgroup_count = state->hostgroup_count;
+ if (hostgroups) *hostgroups = talloc_steal(mem_ctx, state->hostgroups);
return EOK;
}
diff --git a/src/providers/ipa/ipa_hosts.h b/src/providers/ipa/ipa_hosts.h
index cc658f0d..53cabbb7 100644
--- a/src/providers/ipa/ipa_hosts.h
+++ b/src/providers/ipa/ipa_hosts.h
@@ -31,6 +31,8 @@ ipa_host_info_send(TALLOC_CTX *mem_ctx,
struct sdap_options *opts,
const char *hostname,
const char **attrs,
+ struct sdap_attr_map *map,
+ int map_num_attrs,
bool fetch_hostgroups,
struct sdap_search_base **search_bases);
diff --git a/src/providers/ipa/ipa_init.c b/src/providers/ipa/ipa_init.c
index 0484200c..1165048b 100644
--- a/src/providers/ipa/ipa_init.c
+++ b/src/providers/ipa/ipa_init.c
@@ -33,6 +33,7 @@
#include "providers/ipa/ipa_id.h"
#include "providers/ipa/ipa_auth.h"
#include "providers/ipa/ipa_access.h"
+#include "providers/ipa/ipa_hostid.h"
#include "providers/ipa/ipa_dyndns.h"
#include "providers/ipa/ipa_session.h"
@@ -65,6 +66,13 @@ struct bet_ops ipa_session_ops = {
.finalize = NULL
};
+#ifdef BUILD_SSH
+struct bet_ops ipa_hostid_ops = {
+ .handler = ipa_host_info_handler,
+ .finalize = NULL
+};
+#endif
+
int common_ipa_init(struct be_ctx *bectx)
{
const char *ipa_servers;
@@ -435,3 +443,44 @@ done:
}
return ret;
}
+
+#ifdef BUILD_SSH
+int sssm_ipa_hostid_init(struct be_ctx *bectx,
+ struct bet_ops **ops,
+ void **pvt_data)
+{
+ int ret;
+ struct ipa_hostid_ctx *hostid_ctx;
+ struct ipa_id_ctx *id_ctx;
+
+ hostid_ctx = talloc_zero(bectx, struct ipa_hostid_ctx);
+ if (hostid_ctx == NULL) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("talloc_zero failed.\n"));
+ return ENOMEM;
+ }
+
+ ret = sssm_ipa_id_init(bectx, ops, (void **) &id_ctx);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("sssm_ipa_id_init failed.\n"));
+ goto done;
+ }
+ hostid_ctx->sdap_id_ctx = id_ctx->sdap_id_ctx;
+ hostid_ctx->host_search_bases = id_ctx->ipa_options->host_search_bases;
+
+ ret = dp_copy_options(hostid_ctx, ipa_options->basic,
+ IPA_OPTS_BASIC, &hostid_ctx->ipa_options);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_CRIT_FAILURE, ("dp_copy_options failed.\n"));
+ goto done;
+ }
+
+ *ops = &ipa_hostid_ops;
+ *pvt_data = hostid_ctx;
+
+done:
+ if (ret != EOK) {
+ talloc_free(hostid_ctx);
+ }
+ return ret;
+}
+#endif
diff --git a/src/providers/ipa/ipa_session.c b/src/providers/ipa/ipa_session.c
index 40e8c186..6b7fc8ef 100644
--- a/src/providers/ipa/ipa_session.c
+++ b/src/providers/ipa/ipa_session.c
@@ -264,7 +264,8 @@ static void ipa_get_selinux_connect_done(struct tevent_req *subreq)
sdap_id_op_handle(state->op),
id_ctx->sdap_id_ctx->opts,
state->hostname,
- state->attrs, false, state->session_ctx->host_search_bases);
+ state->attrs, NULL, 0,
+ false, state->session_ctx->host_search_bases);
if (subreq == NULL) {
ret = ENOMEM;
goto fail;