|
|
9df909 |
From d263ce2f95fcf6ec8afa5c9528182cce00f57da6 Mon Sep 17 00:00:00 2001
|
|
|
9df909 |
From: Alexander Bokovoy <abokovoy@redhat.com>
|
|
|
9df909 |
Date: Wed, 15 Jun 2016 12:15:46 +0300
|
|
|
9df909 |
Subject: [PATCH 3/4] slapi-nis: resolve IPA groups with fully qualified suffix
|
|
|
9df909 |
|
|
|
9df909 |
With SSSD 1.14+ there is a logic change to handling of a default domain
|
|
|
9df909 |
suffix.
|
|
|
9df909 |
|
|
|
9df909 |
SSSD has two different formats to handle: the input and output. The
|
|
|
9df909 |
input format is parsed into (name,domain) tuples with the re_expression
|
|
|
9df909 |
option and the output is formatted with the full_name_format option.
|
|
|
9df909 |
|
|
|
9df909 |
Because of the way SSSD used to store the usernames in sysdb, it was
|
|
|
9df909 |
tied to the full_name_format option, just changing the output format
|
|
|
9df909 |
changed the way the names are stored internally. SSSD changed the cache
|
|
|
9df909 |
to always store names in a unified format (foo@bar) and use the
|
|
|
9df909 |
full_name_format only for output, as it should be.
|
|
|
9df909 |
|
|
|
9df909 |
This changed a logic of use_fully_qualified_names=True. It now mandates
|
|
|
9df909 |
that the /input/ contains both the name and the domain part and then
|
|
|
9df909 |
SSSD formats the output using the full_name_format option. The
|
|
|
9df909 |
default_domain_suffix is a hack that just appends its value to an
|
|
|
9df909 |
unqualified input, making all queries for "foo" into "foo@bar".
|
|
|
9df909 |
|
|
|
9df909 |
In new SSSD if configuration contains:
|
|
|
9df909 |
default_domain_suffix = win.domain
|
|
|
9df909 |
full_name_format = $1 # only name
|
|
|
9df909 |
|
|
|
9df909 |
then a request for "foo" will internally turn into "foo@win.domain" but
|
|
|
9df909 |
return "foo" on the output. However, queries for IPA's foo will have to
|
|
|
9df909 |
be qualified by the admin manually like "foo@ipa.domain" otherwise sssd
|
|
|
9df909 |
doesn't know which foo you meant.
|
|
|
9df909 |
|
|
|
9df909 |
Support this logic by querying associatedDomain attribute of the
|
|
|
9df909 |
restricted bases of the data set. IPA stores this information in the
|
|
|
9df909 |
$SUFFIX base dn (dc=example,dc=com) and configures slapi-nis with
|
|
|
9df909 |
restricted base set to $SUFFIX (and the plugin config). While
|
|
|
9df909 |
associatedDomain attribute is multivalued, the $SUFFIX object always has
|
|
|
9df909 |
a single value corresponding to the IPA domain name that is the same as
|
|
|
9df909 |
SSSD domain suffix.
|
|
|
9df909 |
---
|
|
|
9df909 |
src/back-sch.c | 41 +++++++++++++++++++++++++++++++++++++++++
|
|
|
9df909 |
src/back-sch.h | 1 +
|
|
|
9df909 |
2 files changed, 42 insertions(+)
|
|
|
9df909 |
|
|
|
9df909 |
diff --git a/src/back-sch.c b/src/back-sch.c
|
|
|
9df909 |
index bb2aa74..cdd2b3c 100644
|
|
|
9df909 |
--- a/src/back-sch.c
|
|
|
9df909 |
+++ b/src/back-sch.c
|
|
|
9df909 |
@@ -98,6 +98,7 @@ backend_set_config_free_config_contents(void *data)
|
|
|
9df909 |
slapi_sdn_free(&set_data->container_sdn);
|
|
|
9df909 |
free(set_data->rdn_format);
|
|
|
9df909 |
backend_shr_free_strlist(set_data->attribute_format);
|
|
|
9df909 |
+ slapi_ch_free_string(&set_data->associated_domain);
|
|
|
9df909 |
}
|
|
|
9df909 |
}
|
|
|
9df909 |
void
|
|
|
9df909 |
@@ -149,6 +150,7 @@ backend_copy_set_config(const struct backend_set_data *data)
|
|
|
9df909 |
ret->check_access = data->check_access;
|
|
|
9df909 |
ret->check_nsswitch = data->check_nsswitch;
|
|
|
9df909 |
ret->nsswitch_min_id = data->nsswitch_min_id;
|
|
|
9df909 |
+ ret->associated_domain = data->associated_domain ? slapi_ch_strdup(data->associated_domain) : NULL;
|
|
|
9df909 |
|
|
|
9df909 |
if ((ret->common.group == NULL) ||
|
|
|
9df909 |
(ret->common.set == NULL) ||
|
|
|
9df909 |
@@ -266,6 +268,39 @@ backend_set_config_read_config(struct plugin_state *state, Slapi_Entry *e,
|
|
|
9df909 |
free(nsswitch_min_id);
|
|
|
9df909 |
}
|
|
|
9df909 |
|
|
|
9df909 |
+ ret.associated_domain = NULL;
|
|
|
9df909 |
+ if (ret.common.restrict_subtrees != NULL) {
|
|
|
9df909 |
+ Slapi_PBlock *pb = NULL;
|
|
|
9df909 |
+ int result = 0;
|
|
|
9df909 |
+ Slapi_Entry **entries = NULL;
|
|
|
9df909 |
+ int i,j;
|
|
|
9df909 |
+ for (i=0; ret.common.restrict_subtrees[i] != NULL; i++) {
|
|
|
9df909 |
+ pb = wrap_pblock_new(NULL);
|
|
|
9df909 |
+ if (pb != NULL) {
|
|
|
9df909 |
+ slapi_search_internal_set_pb_ext(pb, (Slapi_DN*) ret.common.restrict_subtrees[i], LDAP_SCOPE_BASE,
|
|
|
9df909 |
+ "(&(objectclass=domainRelatedObject)(associatedDomain=*))",
|
|
|
9df909 |
+ NULL, 0, NULL, NULL, state->plugin_identity, 0);
|
|
|
9df909 |
+ result = slapi_search_internal_pb(pb);
|
|
|
9df909 |
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &result);
|
|
|
9df909 |
+ if (result == 0) {
|
|
|
9df909 |
+ slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, &entries);
|
|
|
9df909 |
+ slapi_pblock_set(pb, SLAPI_PLUGIN_INTOP_SEARCH_ENTRIES, NULL);
|
|
|
9df909 |
+ for (j=0; entries[j] != NULL; j++) {
|
|
|
9df909 |
+ ret.associated_domain = slapi_entry_attr_get_charptr(entries[j], "associatedDomain");
|
|
|
9df909 |
+ slapi_entry_free(entries[i]);
|
|
|
9df909 |
+ if (ret.associated_domain != NULL)
|
|
|
9df909 |
+ break;
|
|
|
9df909 |
+ }
|
|
|
9df909 |
+ slapi_ch_free((void**)&entries);
|
|
|
9df909 |
+ }
|
|
|
9df909 |
+ }
|
|
|
9df909 |
+ slapi_pblock_destroy(pb);
|
|
|
9df909 |
+ pb = NULL;
|
|
|
9df909 |
+ if (ret.associated_domain != NULL)
|
|
|
9df909 |
+ break;
|
|
|
9df909 |
+ }
|
|
|
9df909 |
+ }
|
|
|
9df909 |
+
|
|
|
9df909 |
*pret = backend_copy_set_config(&ret;;
|
|
|
9df909 |
if (*pret == NULL) {
|
|
|
9df909 |
if (strlen(container) > 0) {
|
|
|
9df909 |
@@ -437,6 +472,7 @@ backend_set_process_external_members(Slapi_PBlock *pb,
|
|
|
9df909 |
struct backend_staged_search staged = {0, };
|
|
|
9df909 |
struct backend_search_cbdata cbdata = {0, };
|
|
|
9df909 |
char *plugin_id = state->plugin_desc->spd_id;
|
|
|
9df909 |
+ char *gname = NULL;
|
|
|
9df909 |
|
|
|
9df909 |
is_attr_exists = slapi_entry_attr_find(e, IPA_ATTR_EXTERNAL_MEMBER, &attr) == 0;
|
|
|
9df909 |
|
|
|
9df909 |
@@ -448,6 +484,11 @@ backend_set_process_external_members(Slapi_PBlock *pb,
|
|
|
9df909 |
* and update entry's memberUid attribute */
|
|
|
9df909 |
|
|
|
9df909 |
staged.name = slapi_entry_attr_get_charptr(e, "cn");
|
|
|
9df909 |
+ if (data->associated_domain != NULL) {
|
|
|
9df909 |
+ gname = slapi_ch_smprintf("%s@%s", staged.name, data->associated_domain);
|
|
|
9df909 |
+ slapi_ch_free_string(&staged.name);
|
|
|
9df909 |
+ staged.name = gname;
|
|
|
9df909 |
+ }
|
|
|
9df909 |
staged.type = SCH_NSSWITCH_GROUP;
|
|
|
9df909 |
staged.search_members = FALSE;
|
|
|
9df909 |
staged.is_id = FALSE;
|
|
|
9df909 |
diff --git a/src/back-sch.h b/src/back-sch.h
|
|
|
9df909 |
index 72ba641..c15d1ed 100644
|
|
|
9df909 |
--- a/src/back-sch.h
|
|
|
9df909 |
+++ b/src/back-sch.h
|
|
|
9df909 |
@@ -38,6 +38,7 @@ struct backend_set_data {
|
|
|
9df909 |
bool_t check_access;
|
|
|
9df909 |
enum sch_search_nsswitch_t check_nsswitch;
|
|
|
9df909 |
unsigned long nsswitch_min_id;
|
|
|
9df909 |
+ char *associated_domain;
|
|
|
9df909 |
};
|
|
|
9df909 |
|
|
|
9df909 |
struct backend_entry_data {
|
|
|
9df909 |
--
|
|
|
9df909 |
2.7.4
|
|
|
9df909 |
|