/* 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) { char **services = NULL; errno_t ret; bool has_autofs_defaults = false; 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, }; ret = confdb_get_string_as_list(cdb, cdb, CONFDB_MONITOR_CONF_ENTRY, CONFDB_MONITOR_ACTIVE_SERVICES, &services); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, "Unable to read from confdb [%d]: %s\n", ret, sss_strerror(ret)); goto done; } if (string_in_list("autofs", services, true) == false) { goto done; } has_autofs_defaults = has_defaults(cdb, conf_path, attrs); done: talloc_free(services); return has_autofs_defaults; }
errno_t sss_ncache_prepopulate(struct sss_nc_ctx *ncache, struct confdb_ctx *cdb, struct resp_ctx *rctx) { errno_t ret; bool filter_set = false; char **filter_list = NULL; char *name = NULL; struct sss_domain_info *dom = NULL; struct sss_domain_info *domain_list = rctx->domains; char *domainname = NULL; char *conf_path = NULL; TALLOC_CTX *tmpctx = talloc_new(NULL); int i; /* Populate domain-specific negative cache entries */ for (dom = domain_list; dom; dom = get_next_domain(dom, false)) { conf_path = talloc_asprintf(tmpctx, CONFDB_DOMAIN_PATH_TMPL, dom->name); if (!conf_path) { ret = ENOMEM; goto done; } talloc_zfree(filter_list); ret = confdb_get_string_as_list(cdb, tmpctx, conf_path, CONFDB_NSS_FILTER_USERS, &filter_list); if (ret == ENOENT) continue; if (ret != EOK) goto done; filter_set = true; for (i = 0; (filter_list && filter_list[i]); i++) { ret = sss_parse_name_for_domains(tmpctx, domain_list, rctx->default_domain, filter_list[i], &domainname, &name); if (ret != EOK) { DEBUG(1, ("Invalid name in filterUsers list: [%s] (%d)\n", filter_list[i], ret)); continue; } if (domainname && strcmp(domainname, dom->name)) { DEBUG(1, ("Mismatch between domain name (%s) and name " "set in FQN (%s), skipping user %s\n", dom->name, domainname, name)); continue; } ret = sss_ncache_set_user(ncache, true, dom, name); if (ret != EOK) { DEBUG(1, ("Failed to store permanent user filter for [%s]" " (%d [%s])\n", filter_list[i], ret, strerror(ret))); continue; } } } ret = confdb_get_string_as_list(cdb, tmpctx, CONFDB_NSS_CONF_ENTRY, CONFDB_NSS_FILTER_USERS, &filter_list); if (ret == ENOENT) { if (!filter_set) { filter_list = talloc_array(tmpctx, char *, 2); if (!filter_list) { ret = ENOMEM; goto done; } filter_list[0] = talloc_strdup(tmpctx, "root"); if (!filter_list[0]) { ret = ENOMEM; goto done; } filter_list[1] = NULL; } }