From 7a1a56860993475d0025e7411547649abf09d32c Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 12 Nov 2013 11:08:12 +0100 Subject: Merge ipa_selinux_common.c and ipa_selinux.c Moved unused functions and merged ipa_selinux_common.c into ipa_selinux.c --- src/providers/ipa/ipa_selinux.c | 47 +++++++++++++++++++++- src/providers/ipa/ipa_selinux_common.c | 73 ---------------------------------- src/providers/ipa/ipa_selinux_common.h | 36 ----------------- 3 files changed, 46 insertions(+), 110 deletions(-) delete mode 100644 src/providers/ipa/ipa_selinux_common.c delete mode 100644 src/providers/ipa/ipa_selinux_common.h (limited to 'src/providers/ipa') diff --git a/src/providers/ipa/ipa_selinux.c b/src/providers/ipa/ipa_selinux.c index c227db937..bb7b40452 100644 --- a/src/providers/ipa/ipa_selinux.c +++ b/src/providers/ipa/ipa_selinux.c @@ -33,7 +33,6 @@ #include "providers/ipa/ipa_hbac_rules.h" #include "providers/ipa/ipa_hbac_private.h" #include "providers/ipa/ipa_access.h" -#include "providers/ipa/ipa_selinux_common.h" #include "providers/ipa/ipa_selinux_maps.h" #include "providers/ipa/ipa_subdomains.h" @@ -153,6 +152,52 @@ fail: be_req_terminate(be_req, DP_ERR_FATAL, PAM_SYSTEM_ERR, NULL); } +static errno_t +ipa_save_user_maps(struct sysdb_ctx *sysdb, + struct sss_domain_info *domain, + size_t map_count, + struct sysdb_attrs **maps) +{ + errno_t ret; + errno_t sret; + bool in_transaction = false; + int i; + + ret = sysdb_transaction_start(sysdb); + if (ret) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to start transaction\n")); + goto done; + } + in_transaction = true; + + for (i = 0; i < map_count; i++) { + ret = sysdb_store_selinux_usermap(sysdb ,domain, maps[i]); + if (ret != EOK) { + DEBUG(SSSDBG_OP_FAILURE, ("Failed to store user map %d. " + "Ignoring.\n", i)); + } else { + DEBUG(SSSDBG_TRACE_FUNC, ("User map %d processed.\n", i)); + } + } + + ret = sysdb_transaction_commit(sysdb); + if (ret) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to commit transaction!\n")); + goto done; + } + in_transaction = false; + ret = EOK; + +done: + if (in_transaction) { + sret = sysdb_transaction_cancel(sysdb); + if (sret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to cancel transaction")); + } + } + return ret; +} + static struct ipa_selinux_op_ctx * ipa_selinux_create_op_ctx(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, struct sss_domain_info *domain, diff --git a/src/providers/ipa/ipa_selinux_common.c b/src/providers/ipa/ipa_selinux_common.c deleted file mode 100644 index 2276d0c98..000000000 --- a/src/providers/ipa/ipa_selinux_common.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - SSSD - - IPA Backend Module -- SELinux common routines - - Authors: - Jan Zeleny - - Copyright (C) 2012 Red Hat - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "db/sysdb_selinux.h" -#include "providers/ldap/sdap_async.h" -#include "providers/ipa/ipa_selinux_common.h" - - -errno_t ipa_save_user_maps(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, - size_t map_count, - struct sysdb_attrs **maps) -{ - errno_t ret; - errno_t sret; - bool in_transaction = false; - int i; - - ret = sysdb_transaction_start(sysdb); - if (ret) { - DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to start transaction\n")); - goto done; - } - in_transaction = true; - - for (i = 0; i < map_count; i++) { - ret = sysdb_store_selinux_usermap(sysdb, domain, maps[i]); - if (ret != EOK) { - DEBUG(SSSDBG_OP_FAILURE, ("Failed to store user map %d. " - "Ignoring.\n", i)); - } else { - DEBUG(SSSDBG_TRACE_FUNC, ("User map %d processed.\n", i)); - } - } - - ret = sysdb_transaction_commit(sysdb); - if (ret) { - DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to commit transaction!\n")); - goto done; - } - in_transaction = false; - ret = EOK; - -done: - if (in_transaction) { - sret = sysdb_transaction_cancel(sysdb); - if (sret != EOK) { - DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to cancel transaction")); - } - } - return ret; -} diff --git a/src/providers/ipa/ipa_selinux_common.h b/src/providers/ipa/ipa_selinux_common.h deleted file mode 100644 index 8a6595566..000000000 --- a/src/providers/ipa/ipa_selinux_common.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - SSSD - - IPA Backend Module -- SELinux common routines - - Authors: - Jan Zeleny - - Copyright (C) 2012 Red Hat - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef IPA_SELINUX_COMMON_H_ -#define IPA_SELINUX_COMMON_H_ - -errno_t ipa_save_host(struct sysdb_ctx *sysdb, - struct sysdb_attrs *host); - -errno_t ipa_save_user_maps(struct sysdb_ctx *sysdb, - struct sss_domain_info *domain, - size_t map_count, - struct sysdb_attrs **maps); - -#endif /* IPA_SELINUX_COMMON_H_ */ -- cgit