From ef5693b03bdaad71527014ca87fc2192061689d5 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 | 17 +++++----- src/providers/ldap/ldap_options.c | 66 +++++++++++++++++++++++++++++++++++++++ src/providers/ldap/ldap_opts.c | 8 ++--- 3 files changed, 80 insertions(+), 11 deletions(-) diff --git a/src/man/sssd-ldap.5.xml b/src/man/sssd-ldap.5.xml index a30100408c6e77f9156878cb6ff63dfbf7b041d1..ce2051d9d3c7df51e26e54abf49e8a20bf5ba3d3 100644 --- a/src/man/sssd-ldap.5.xml +++ b/src/man/sssd-ldap.5.xml @@ -2505,7 +2505,8 @@ ldap_access_filter = (employeeType=admin) The object class of an automount map entry in LDAP. - Default: automountMap + Default: nisMap (rfc2307, autofs_provider=ad), + otherwise automountMap @@ -2518,8 +2519,8 @@ 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), otherwise automountMapName @@ -2534,7 +2535,8 @@ ldap_access_filter = (employeeType=admin) point. - Default: automount + Default: nisObject (rfc2307, autofs_provider=ad), + otherwise automount @@ -2548,8 +2550,8 @@ 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), + otherwise automountKey @@ -2563,7 +2565,8 @@ ldap_access_filter = (employeeType=admin) entry usually corresponds to a mount point. - Default: automountInformation + Default: nisMapEntry (rfc2307, + autofs_provider=ad), otherwise automountInformation diff --git a/src/providers/ldap/ldap_options.c b/src/providers/ldap/ldap_options.c index 1180925d67a415c2f84c1b4f2fd067da3d6eec84..018f6c31fb6360952308e44979581790b8477dc3 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.\n"); + 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.\n")); + } + 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