From 5765a2c5bf63e3caa33ae73c1e5342869c095758 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 19 Nov 2015 10:40:39 +0100 Subject: [PATCH] LDAP: Change the default rfc2307 autofs attribute mappings Resolves: https://fedorahosted.org/sssd/ticket/2858 The default attribute mappings we used to have: ldap_autofs_map_object_class automountMap ldap_autofs_map_name ou ldap_autofs_entry_object_class automount ldap_autofs_entry_key cn ldap_autofs_entry_value automountInformation Was wrong. Instead, this patch switches to: ldap_autofs_map_object_class nisMap ldap_autofs_map_name nisMapName ldap_autofs_entry_object_class nisObject ldap_autofs_entry_key cn ldap_autofs_entry_value nisMapEntry Which are attributes that are available with servers running the default rfc2307 schema. In addition, this patch adds a syslog and DEBUG message that warns administrators to double-check their configuration. We don't warn when the autofs provider is set to AD, because that one is already correct. --- src/man/sssd-ldap.5.xml | 22 ++++++++----- src/providers/ldap/ldap_options.c | 66 +++++++++++++++++++++++++++++++++++++++ src/providers/ldap/ldap_opts.c | 8 ++--- 3 files changed, 85 insertions(+), 11 deletions(-) diff --git a/src/man/sssd-ldap.5.xml b/src/man/sssd-ldap.5.xml index a30100408c6e77f9156878cb6ff63dfbf7b041d1..48f30a98ebb714bedfd5b595e3115151432810e6 100644 --- a/src/man/sssd-ldap.5.xml +++ b/src/man/sssd-ldap.5.xml @@ -2505,7 +2505,9 @@ ldap_access_filter = (employeeType=admin) The object class of an automount map entry in LDAP. - Default: automountMap + Default: nisMap (rfc2307, autofs_provider=ad), + automountMap (rfc2307bis, ipa, LDAP provider + with AD schema) @@ -2518,8 +2520,9 @@ ldap_access_filter = (employeeType=admin) The name of an automount map entry in LDAP. - Default: ou (rfc2307), automountMapName - (rfc2307bis, ipa, ad) + Default: nisMapName (rfc2307, + autofs_provider=ad), automountMapName + (rfc2307bis, ipa, LDAP provider with AD schema) @@ -2534,7 +2537,9 @@ ldap_access_filter = (employeeType=admin) point. - Default: automount + Default: nisObject (rfc2307, autofs_provider=ad), + automount (rfc2307bis, ipa, LDAP provider with + AD schema) @@ -2548,8 +2553,9 @@ ldap_access_filter = (employeeType=admin) entry usually corresponds to a mount point. - Default: cn (rfc2307), automountKey (rfc2307bis, - ipa, ad) + Default: cn (rfc2307, autofs_provider=ad), + automountKey (rfc2307bis, ipa, LDAP provider + with AD schema) @@ -2563,7 +2569,9 @@ ldap_access_filter = (employeeType=admin) entry usually corresponds to a mount point. - Default: automountInformation + Default: nisMapEntry (rfc2307, + autofs_provider=ad), automountInformation + (rfc2307bis, ipa, LDAP provider with AD schema) diff --git a/src/providers/ldap/ldap_options.c b/src/providers/ldap/ldap_options.c index 1180925d67a415c2f84c1b4f2fd067da3d6eec84..0aa20c8080b2a9a8537bcafa2af1f20a700832de 100644 --- a/src/providers/ldap/ldap_options.c +++ b/src/providers/ldap/ldap_options.c @@ -406,6 +406,58 @@ int ldap_get_sudo_options(struct confdb_ctx *cdb, return EOK; } +static bool has_defaults(struct confdb_ctx *cdb, + const char *conf_path, + const char *attrs[]) +{ + errno_t ret; + TALLOC_CTX *tmp_ctx; + char *val; + bool found_default = false; + tmp_ctx = talloc_new(NULL); + + if (tmp_ctx == NULL) { + return false; + } + + for (size_t i = 0; attrs[i] != NULL; i++) { + ret = confdb_get_string(cdb, tmp_ctx, conf_path, + attrs[i], NULL, &val); + if (ret != EOK) { + continue; + } + + if (val == NULL) { + found_default = true; + break; + } + } + + talloc_free(tmp_ctx); + return found_default; +} + +/* Return true if rfc2307 schema is used and all autofs options use + * defaults. Should be removed in future, see + * https://fedorahosted.org/sssd/ticket/2858 + */ +static bool ldap_rfc2307_autofs_defaults(struct confdb_ctx *cdb, + const char *conf_path) +{ + const char *attrs[] = { + rfc2307_autofs_entry_map[SDAP_OC_AUTOFS_ENTRY].opt_name, + /* SDAP_AT_AUTOFS_ENTRY_KEY missing on purpose, its value was + * the same between the wrong and correct schema + */ + rfc2307_autofs_entry_map[SDAP_AT_AUTOFS_ENTRY_VALUE].opt_name, + rfc2307_autofs_mobject_map[SDAP_OC_AUTOFS_MAP].opt_name, + rfc2307_autofs_mobject_map[SDAP_AT_AUTOFS_MAP_NAME].opt_name, + NULL, + }; + + return has_defaults(cdb, conf_path, attrs); +} + int ldap_get_autofs_options(TALLOC_CTX *memctx, struct confdb_ctx *cdb, const char *conf_path, @@ -438,6 +490,20 @@ int ldap_get_autofs_options(TALLOC_CTX *memctx, "connecting to the LDAP server.\n"); } + if (opts->schema_type == SDAP_SCHEMA_RFC2307 && + ldap_rfc2307_autofs_defaults(cdb, conf_path) == true) { + DEBUG(SSSDBG_IMPORTANT_INFO, + "Your configuration uses the autofs provider " + "with schema set to rfc2307 and default attribute mappings. " + "The default map has changed in this release, please make " + "sure the configuration matches the server attributes."); + sss_log(SSS_LOG_NOTICE, + _("Your configuration uses the autofs provider " + "with schema set to rfc2307 and default attribute mappings. " + "The default map has changed in this release, please make " + "sure the configuration matches the server attributes.")); + } + ret = sdap_parse_search_base(opts, opts->basic, SDAP_AUTOFS_SEARCH_BASE, &opts->sdom->autofs_search_bases); diff --git a/src/providers/ldap/ldap_opts.c b/src/providers/ldap/ldap_opts.c index ff9bf0d8b6d4a8f677e08219e5105e3750b7a4a8..524579d4fcd478f20678bebf2c3ce18f61ed0cb9 100644 --- a/src/providers/ldap/ldap_opts.c +++ b/src/providers/ldap/ldap_opts.c @@ -349,15 +349,15 @@ struct sdap_attr_map service_map[] = { }; struct sdap_attr_map rfc2307_autofs_mobject_map[] = { - { "ldap_autofs_map_object_class", "automountMap", SYSDB_AUTOFS_MAP_OC, NULL }, - { "ldap_autofs_map_name", "ou", SYSDB_AUTOFS_MAP_NAME, NULL }, + { "ldap_autofs_map_object_class", "nisMap", SYSDB_AUTOFS_MAP_OC, NULL }, + { "ldap_autofs_map_name", "nisMapName", SYSDB_AUTOFS_MAP_NAME, NULL }, SDAP_ATTR_MAP_TERMINATOR }; struct sdap_attr_map rfc2307_autofs_entry_map[] = { - { "ldap_autofs_entry_object_class", "automount", SYSDB_AUTOFS_ENTRY_OC, NULL }, + { "ldap_autofs_entry_object_class", "nisObject", SYSDB_AUTOFS_ENTRY_OC, NULL }, { "ldap_autofs_entry_key", "cn", SYSDB_AUTOFS_ENTRY_KEY, NULL }, - { "ldap_autofs_entry_value", "automountInformation", SYSDB_AUTOFS_ENTRY_VALUE, NULL }, + { "ldap_autofs_entry_value", "nisMapEntry", SYSDB_AUTOFS_ENTRY_VALUE, NULL }, SDAP_ATTR_MAP_TERMINATOR }; -- 2.4.11