ipa_rules_common.c revision d2a0b4a6a220bf9a58c7306c3f673891efc419eb
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen Stephen Gallagher <sgallagh@redhat.com>
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen Copyright (C) 2011 Red Hat
abf015c9682f0f723db87a7c97bc284ef814818fTimo Sirainen This program is free software; you can redistribute it and/or modify
70afae43cc78ea6ecca83f6c587072c442a15ec1Timo Sirainen it under the terms of the GNU General Public License as published by
fa2a11210f20fb8998ed656f75e163191c8047e6Timo Sirainen the Free Software Foundation; either version 3 of the License, or
fa2a11210f20fb8998ed656f75e163191c8047e6Timo Sirainen (at your option) any later version.
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen This program is distributed in the hope that it will be useful,
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen GNU General Public License for more details.
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen You should have received a copy of the GNU General Public License
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenipa_common_save_list(struct sss_domain_info *domain,
13b063ba3ea51256fd97d7fa883f14cb08842b0dTimo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "talloc_new failed.\n");
13b063ba3ea51256fd97d7fa883f14cb08842b0dTimo Sirainen base_dn = sysdb_custom_subtree_dn(tmp_ctx, domain, subdir);
1388b590dbd85245b591346f860bc1319953318aTimo Sirainen ret = sysdb_delete_recursive(domain->sysdb, base_dn, true);
49621bf0ef1d55aaaa2dc7d76011cbfeabdcfbe1Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_delete_recursive failed.\n");
5d03d9f439e41c90215a3c938ffebe4c2a8ae257Timo Sirainen for (c = 0; c < count; c++) {
5d03d9f439e41c90215a3c938ffebe4c2a8ae257Timo Sirainen ret = sysdb_attrs_get_el(list[c], naming_attribute, &el);
3482fee0e3733456512ba110780824e6daa7ff9fTimo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_attrs_get_el failed.\n");
12797080b552a3c1727b73b61cc7427bec0c7472Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "[%s] not found.\n", naming_attribute);
4da8c6cdefabd31262318c32da3c13de1d9ea953Timo Sirainen object_name = talloc_strndup(tmp_ctx, (const char *)el->values[0].data,
d1fff80640050631b06bfab904a34b2ad24601e8Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "talloc_strndup failed.\n");
ab90f702ceedb7ba445a9a592be0b213b27cbafaStephan Bosch DEBUG(SSSDBG_TRACE_ALL, "Object name: [%s].\n", object_name);
f3e17726502b6cf1912f30aae7e283b5d31ea69cTimo Sirainen ret = sysdb_store_custom(domain, object_name, subdir, list[c]);
2fb9ae42f9e36388ec6db24188b9108434043fd0Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_store_custom failed.\n");
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainenipa_common_entries_and_groups_sysdb_save(struct sss_domain_info *domain,
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen /* There always has to be at least one
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen * primary entry.
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen /* Save the entries and groups to the cache */
367e28a16854ee9f7247b2518f36f5e9163fcc10Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Failed to start transaction\n");
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen /* First, save the specific entries */
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen ret = ipa_common_save_list(domain, true, primary_subdir,
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Could not save %s. [%d][%s]\n",
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen /* Second, save the groups */
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen ret = ipa_common_save_list(domain, true, group_subdir,
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Could not save %s. [%d][%s]\n",
7af5f78e9fee296e42430d94ef252ff0333d8024Timo Sirainen ret = sysdb_transaction_commit(domain->sysdb);
47569a4b2b4d3cc55e786177798c922c3c44233dTimo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Failed to commit transaction\n");
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen sret = sysdb_transaction_cancel(domain->sysdb);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen DEBUG(SSSDBG_FATAL_FAILURE, "Could not cancel sysdb transaction\n");
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen DEBUG(SSSDBG_MINOR_FAILURE, "Error [%d][%s]\n", ret, strerror(ret));
47569a4b2b4d3cc55e786177798c922c3c44233dTimo Sirainenipa_common_get_cached_rules(TALLOC_CTX *mem_ctx,
1f5597beba229acd914e30a6da3c0e62d83b6e8fTimo Sirainen const char **attrs,
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen filter = talloc_asprintf(tmp_ctx, "(objectClass=%s)", rule);
c07d7eb3ca9754367697c98f5e66a3982a45d142Timo Sirainen ret = sysdb_search_custom(tmp_ctx, domain, filter,
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Error looking up HBAC rules\n");
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen ret = sysdb_msg2attrs(tmp_ctx, rule_count, msgs, &rules);
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainen "Could not convert ldb message to sysdb_attrs\n");
8d3278a82b964217d95c340ec6f82037cdc59d19Timo Sirainenipa_common_purge_rules(struct sss_domain_info *domain,
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainen base_dn = sysdb_custom_subtree_dn(tmp_ctx, domain, subtree_name);
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainen ret = sysdb_delete_recursive(domain->sysdb, base_dn, true);
002179a890bf4f1942cad6463787719eaa9fd6c0Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_delete_recursive failed.\n");