From patchwork Mon May 15 20:42:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Jurgens X-Patchwork-Id: 9727965 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8A0B76028A for ; Mon, 15 May 2017 20:44:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A4CE2899F for ; Mon, 15 May 2017 20:44:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DA8D289A7; Mon, 15 May 2017 20:44:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from emsm-gh1-uea11.nsa.gov (emsm-gh1-uea11.nsa.gov [8.44.101.9]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D335289A3 for ; Mon, 15 May 2017 20:44:19 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.38,346,1491264000"; d="scan'208";a="5797441" IronPort-PHdr: =?us-ascii?q?9a23=3AAtAopRdH+ZSTWtfvrtjqPIhblGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxcq7YxaN2/xhgRfzUJnB7Loc0qyN4v+mADdLuMvb+Fk5M7V0Hycfjs?= =?us-ascii?q?sXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aFRrwLxd6?= =?us-ascii?q?KfroEYDOkcu3y/qy+5rOaAlUmTaxe71/IRG0oAnLq8Ubj4RuJrsxxxfXv3BFZ/?= =?us-ascii?q?lYyWR0KFyJgh3y/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ascii?q?pKtlK2neWltHfy/zL25+SKSwraaCb9RJ6Jw2rSVdSP68bkyCSr7hvxsa1DvuH2?= =?us-ascii?q?1fxDA/czGlpI75kgdgh22DNnZzq2DVecZqxRfQ/NbcX+Je3iIaRClkjjnaHka8?= =?us-ascii?q?P9i18tWIkJfDqPqyWH6hVp1UdynrwpiNtC+65W1sGxK/hfezlsfgEQgg3i/xz8?= =?us-ascii?q?NqWjnQrBbgfonr0Ly3MeZmfklzGF/w8tF6FZ96kosxgpEQxHcbi46O/XofkGfz?= =?us-ascii?q?N9Rb1r7lbHYXQz4E3cLV6hD/2EJ/NnKJ2575VnKFz8t7YNm6ZmcW1Twn789WD6?= =?us-ascii?q?eV4qdJnTBoolWktgLde/99ni0SyfE28n4Vn/kJuBYxziWaGr0SBVNXPTHolxiS?= =?us-ascii?q?9d+ytr5YZGGrcbis00p+m8usDLSergFaX3b2Zo0uHSlu4cVjKFjMymH86pn4eN?= =?us-ascii?q?nMatIerh6UnAnGj+hOM58xleQFhSx8OWL7o3Il1/Q3jRt03ZG1pIKHMXli/Lql?= =?us-ascii?q?Ah5EMT34f90T+jfwgqtFgMaW2Z2gHpV7FjUNQpToUeqiECgOuvT/KwaODDo8p2?= =?us-ascii?q?+DGbXFAA+f7FxroG7OE5C3N3CbPXcZws9kRBWHI0xfmg8UVi0gnpElDgCq2NDh?= =?us-ascii?q?cEBh6zAJ/FH4tx9MxfxwNxblVGffuBmnai0vRZiCNxpZ8BtC51zPPcyF6eJzAj?= =?us-ascii?q?tY8YG/owyDLWybfQtIAn8TVkyCGV/jIqGk5cPc/OiAGuq+M/zObK2AqeNEUfeI?= =?us-ascii?q?2ZWv0o598jaCKMqAI35iD+ch1UpbR3B5HMbZlCsTRCwLjS7NaNSbpBik8C1tss?= =?us-ascii?q?+/6OjrWB7o5YaXDrtdK9Fv+xSojqefK+6fnjx2JC1e1pwS2X/I06QQ00QKiy5w?= =?us-ascii?q?bTWtF6oPtTLVRqLKhqBXFwIbaz90NMZQ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TLscWfbxammaTCR6kFacPyXyx5CuRLmllmBbO?= =?us-ascii?q?3AzuTm6o8F/5tyl4QTDLz9v5lEpaSKW3D19IXyW1IU94rC+PPA3wudrxvaQ490?= =?us-ascii?q?A2MmrhtN6XlWuhPr1XH9flK9yHPSk0vk8Xg4EtRtyyw4AUB8CxINAL8HFxdvHe?= =?us-ascii?q?8X+kkzddo6dbgIrT+seV+vTLEnmni62Vsa6NyCpZyng/ulE/8cugO+rL59CFTP?= =?us-ascii?q?WkzWERTz1wuwHZRR66tqTbr0wIOUyMyErEhJYFPtVH0nkjykHn5O8jTcko9ApC?= =?us-ascii?q?F4bPefUCpSzyODTu21qfZcw4VjWG2TtNAl31CUV4GLQ72G/ouMLJjnLQ9l0zS4?= =?us-ascii?q?l+aUPomBt3D58iJkI18lgXxSgDHhYRZhCHFr2oAl7lLYQcX0gZdRuHxKS6ersw?= =?us-ascii?q?3UBrwLOv5erTYPd5B6UTNvdSkBSOnFldGpIZq6EeRqxze0NF/q7NugfiE5TnX+?= =?us-ascii?q?ThlXcoNP20Q9pV/toFuHY5+QawWQag5olf4LoBj5CIbKFEa4DWvM9g90dn+SIP?= =?us-ascii?q?ditVjRdkjhO5Su4dq/rh4tjarJqo8vyhVLspR+gM6xc0AHlxgIXqj1A+u9HX0P?= =?us-ascii?q?1cRZfPhYT46gBNLGaAuJzG3BlkNeoON4Wrca5493odOygRO3IOPNSRa/km4C9h?= =?us-ascii?q?KS7T6EJGAsMNY9MYIcXMlBtMikLzRLFc6srbG1GfC4dpdMAk9Wn3xy4v8Zs6TO?= =?us-ascii?q?ng7CW6JZfF71FCJ/lDljljlMrepOgJxvrfEDQX4WOHZBhx2CyCzYeCBu3t8uWN?= =?us-ascii?q?x9HUVk8GETQtU4hHPjqC5BarRuyrm5X1SgmU8NP8gIoidEKMQXy8hKsFvbxWEe?= =?us-ascii?q?FeliX73iNTFoT0h/KJrdWs6HFYtkBcEIpp6x3KBrlfNI1hORvkjsmrWlR8Bizn?= =?us-ascii?q?dcHbaBUuvvaWxuAL4+l5LEvxe4sbIhMCy7Ln5ntYVQ9uR6DsvleZR+0dft1mR+?= =?us-ascii?q?3YrnpN84JvN7cPPESBpJzttjpHtFI2DxU1Z7IrsjNacU3OnAlUW6nqor4AlhUT?= =?us-ascii?q?XsJ5uUNWHmKwIm0+7SLdVatJlKmRFOAV8jKLQ6wLVEVoND9+Qxyr15h1frupnO?= =?us-ascii?q?pIsmVYkSNhrvkq1CZmRBinuSH2oaICxy4g8qmitDodoXxFUvmekyDQBFVM0PsK?= =?us-ascii?q?lrwcB2//51KzZncDbY3y4KRoJMn7+okh5m4wYRM9cCEcWuSgES7whbuSAoOTqN?= =?us-ascii?q?JcmAKNuMLWYL+xKigSNrI9xQj/SHh91gjegQtn8WoKQjWm998kJ4S9NN07xiqp?= =?us-ascii?q?B2jUblIM7b5IsMfrs14EUvc2Y0t7wGp/ysiHWjENRMvXFmY0kAgrc2NEfYlH6R?= =?us-ascii?q?8HCqYogzGIvrJc8gETejfUHZyv+pPMksfQxXk9UdBqy3rUpqKbiJMq3nlllsh6?= =?us-ascii?q?7yGUvnQdafDYX9VqAnftyodV0fb+aOm1suAbVItmz6ysUPAGMsmk92q5xpFqWk?= =?us-ascii?q?u+y7QFGFq5Nu4DyavBXyejV2KYRfyBc3KQkDYhLk7y+R6oI0U1aMdKr049KuzC?= =?us-ascii?q?hppdlw39T7x5XSCQpV7HzGw5L+wWbQU2uJ2oewYSVu4ee/CcJfQywP05EFYMc3?= =?us-ascii?q?7JHS5tBu+qsF6igIt7NGtk4UngZ+Ti7BzmOsOIGhYYCY7asoJx+fuiS2KEOH9g?= =?us-ascii?q?zx5yPE5v+ufdDVsxtehcc5CPktjWndh71/AKd+t1Oy0nptETgp5j6ZWT0MqSah?= =?us-ascii?q?7e0JDyJc3Or/iDB/3fyFgqen1EUrUHfAz5/YI6PsQ2W7fLB7tWoQwcBbQmQJwm?= =?us-ascii?q?L2rx7KZ0LAdpfQ7LarW0hc3qpuyQa5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+MlvcyOYK?= =?us-ascii?q?Y=3D?= X-IPAS-Result: =?us-ascii?q?A2FXDgCREhpZ/wHyM5BcHAEBBAEBCgEBFwEBBAEBCgEBgwE?= =?us-ascii?q?pYoEMjnaOWIIVcoEaAZV0JAOBd1OIblcBAQEBAQEBAQIBAmgFI4IzJIErWzwGA?= =?us-ascii?q?QIXAQxVAwkBARcIGQEPCAMBUxkFiFCBTgSuUjomAosEiD2CZ4IDgwBcAYUpAQS?= =?us-ascii?q?BFY8NgQGMGU6HHIZQhTGCAlWIQIZSiH+LRFgCVzFPIRVGA4QkCwEBAUIcGYFNc?= =?us-ascii?q?4YwAQ0XB4IQAQEB?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 15 May 2017 20:44:17 +0000 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id v4FKiGB3021733; Mon, 15 May 2017 16:44:16 -0400 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id v4FKhnq7276883 for ; Mon, 15 May 2017 16:43:49 -0400 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id v4FKhjS2021297 for ; Mon, 15 May 2017 16:43:49 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1CQAwCREhpZf4GlL8FcHAEBBAEBCgEBgyyBC4EMjnaOWAGCFHKXEiSCSoM2AoYNAQIBAQEBAQITAQEhXYUZAwMaAQxSEBgIGQEXVxmIVYFSrlI6inoyiD2CZ4IDgwBcAYUpBYEVjw2BAYwZTocchlCFMYICVY8SiH+LRFYDVzFPIRVGA4R0HIFmPTaGMAENFweCEAEBAQ X-IPAS-Result: A1CQAwCREhpZf4GlL8FcHAEBBAEBCgEBgyyBC4EMjnaOWAGCFHKXEiSCSoM2AoYNAQIBAQEBAQITAQEhXYUZAwMaAQxSEBgIGQEXVxmIVYFSrlI6inoyiD2CZ4IDgwBcAYUpBYEVjw2BAYwZTocchlCFMYICVY8SiH+LRFYDVzFPIRVGA4R0HIFmPTaGMAENFweCEAEBAQ X-IronPort-AV: E=Sophos;i="5.38,346,1491278400"; d="scan'208";a="6053072" Received: from emsm-gh1-uea11.corp.nsa.gov (HELO emsm-gh1-uea11.nsa.gov) ([10.208.41.37]) by goalie.tycho.ncsc.mil with ESMTP; 15 May 2017 16:43:47 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3A8wPi/RdU5DSqX8MqPyHM/jmYlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxcu9ZR7h7PlgxGXEQZ/co6odzbGH7Oa5AidZvMzJmUtBWaQEbwUCh8?= =?us-ascii?q?QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYdFRrlKAV6?= =?us-ascii?q?OPn+FJLMgMSrzeCy/IDYbxlViDanb75/KBe7oR/MusQYjoduN6Y8xgXUqXZUZu?= =?us-ascii?q?pawn9lK0iOlBjm/Mew+5Bj8yVUu/0/8sNLTLv3caclQ7FGFToqK2866tHluhnF?= =?us-ascii?q?VguP+2ATUn4KnRpSAgjK9w/1U5HsuSbnrOV92S2aPcrrTbAoXDmp8qlmRAP0hC?= =?us-ascii?q?oBKjU063/chNBug61HoRKhvx1/zJDSYIGJL/p1Y6fRccoHSWZdQspdUipMCZ6+?= =?us-ascii?q?YYQSFeoMJeZWoZfgqVUArhWwAgujBO30xzNUmnP7x7E23v49HQ3a2gErAtIAsG?= =?us-ascii?q?7TrNXwLKocX/q6zK/VxjvHcvNWwzj955bOchA6vPqBWq9/ftDXyUkuCQzFileQ?= =?us-ascii?q?pJfgPzyL0uQNt3KU7+xnVeOgkWIotwZxoj22y8oql4LHiIUVylXe+iV4xoY4Pd?= =?us-ascii?q?y4R1Vlbt6iDZRQryaaN5FqQs84Xm5npjg6x7sbspC4ZCgH0IkryhrRZvCdfIWF?= =?us-ascii?q?4AjvWPuQLDp4nn5pZayzihK0/EO90OPzTNO030xPriddktnDqHQN1xvL58iCVP?= =?us-ascii?q?R9+kOh1iyJ1wDU5eBIO1w7la3BJ54gxr48jpsTsULdES/qgEj6kaube0s+9uWn?= =?us-ascii?q?6enreKjqq56cOoNulw3yLKAjltS6AesiMwgOW2ab+f671L3m5UD2Xa9Fjvs3kq?= =?us-ascii?q?bHtJDaJ98WpqunDA9R1oYs8RC/DzCp0dgCgXYHK1dFdAqdj4f1I1HOPOz4DfCn?= =?us-ascii?q?jlS3jjhrw/HGPrv8ApTCNXXDjLfgcqp9605b0gYzy8tf6IhOBrEOJ/LzRBy5iN?= =?us-ascii?q?uNFRI9Mgqp0877Gd590cUYQmvJDaiHY43Itlrdyuspa8uRfoAYvi21f/Qs4f/j?= =?us-ascii?q?iX0RnFIZeaCv2otRY3e9SKc1a36FaGbh149SWVwBuRAzGamz0AWP?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0E2DgCREhpZf4GlL8FcHAEBBAEBCgEBF?= =?us-ascii?q?wEBBAEBCgEBgwGBC4EMjnaOWAGCFHKBG5V3JIF3U4M2AoYNAQEBAQEBAQECAQI?= =?us-ascii?q?QAQEhXYIzJAGBKls8AwMaAQxSEBgIGQEXVxmIVYFSrlI6inoyiD2CZ4IDgwBcA?= =?us-ascii?q?YUpBYEVjw2BAYwZTocchlCFMYICVY8SiH+LRFYEVzFPIRVGA4R0HIFmPTaGMAE?= =?us-ascii?q?NFweCEAEBAQ?= X-IPAS-Result: =?us-ascii?q?A0E2DgCREhpZf4GlL8FcHAEBBAEBCgEBFwEBBAEBCgEBgwG?= =?us-ascii?q?BC4EMjnaOWAGCFHKBG5V3JIF3U4M2AoYNAQEBAQEBAQECAQIQAQEhXYIzJAGBK?= =?us-ascii?q?ls8AwMaAQxSEBgIGQEXVxmIVYFSrlI6inoyiD2CZ4IDgwBcAYUpBYEVjw2BAYw?= =?us-ascii?q?ZTocchlCFMYICVY8SiH+LRFYEVzFPIRVGA4R0HIFmPTaGMAENFweCEAEBAQ?= X-IronPort-AV: E=Sophos;i="5.38,346,1491264000"; d="scan'208";a="5797363" X-IronPort-Outbreak-Status: No, level 0, Unknown - Unknown Received: from mail-il-dmz.mellanox.com (HELO mellanox.co.il) ([193.47.165.129]) by emsm-gh1-uea11.nsa.gov with ESMTP; 15 May 2017 20:43:28 +0000 Received: from Internal Mail-Server by MTLPINE1 (envelope-from danielj@mellanox.com) with ESMTPS (AES256-SHA encrypted); 15 May 2017 23:43:25 +0300 Received: from x-vnc01.mtx.labs.mlnx. (x-vnc01.mtx.labs.mlnx [10.12.150.16]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id v4FKglb7005032; Mon, 15 May 2017 23:43:24 +0300 From: Dan Jurgens To: selinux@tycho.nsa.gov Subject: [PATCH v1 8/9] semanage: Update semanage to allow runtime labeling of ibendports Date: Mon, 15 May 2017 23:42:40 +0300 Message-Id: <1494880961-73481-9-git-send-email-danielj@mellanox.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1494880961-73481-1-git-send-email-danielj@mellanox.com> References: <1494880961-73481-1-git-send-email-danielj@mellanox.com> X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP From: Daniel Jurgens Update libsepol and libsemanage to work with ibendport records. Add local storage for new and modified ibendport records in ibendports.local. Update semanage to parse the ibendport command options to add, modify, and delete them. Signed-off-by: Daniel Jurgens Acked-by: Jason Zaman --- v1: Jason Zaman: - Use SETools directly to query types in seobject.py Signed-off-by: Daniel Jurgens --- libsemanage/include/semanage/ibendport_record.h | 62 +++++ libsemanage/include/semanage/ibendports_local.h | 36 +++ libsemanage/include/semanage/ibendports_policy.h | 28 +++ libsemanage/include/semanage/semanage.h | 3 + libsemanage/src/direct_api.c | 40 ++- libsemanage/src/handle.h | 38 ++- libsemanage/src/ibendport_internal.h | 48 ++++ libsemanage/src/ibendport_record.c | 154 ++++++++++++ libsemanage/src/ibendports_file.c | 157 ++++++++++++ libsemanage/src/ibendports_local.c | 153 ++++++++++++ libsemanage/src/ibendports_policy.c | 55 +++++ libsemanage/src/ibendports_policydb.c | 62 +++++ libsemanage/src/libsemanage.map | 1 + libsemanage/src/policy_components.c | 4 + libsemanage/src/semanage_store.c | 1 + libsemanage/src/semanage_store.h | 1 + libsemanage/src/semanageswig.i | 3 + libsemanage/src/semanageswig_python.i | 43 ++++ libsemanage/utils/semanage_migrate_store | 3 +- libsepol/include/sepol/ibendport_record.h | 68 ++++++ libsepol/include/sepol/ibendports.h | 45 ++++ libsepol/include/sepol/sepol.h | 2 + libsepol/src/ibendport_internal.h | 18 ++ libsepol/src/ibendport_record.c | 298 +++++++++++++++++++++++ libsepol/src/ibendports.c | 255 +++++++++++++++++++ python/semanage/semanage | 58 ++++- python/semanage/seobject.py | 239 ++++++++++++++++++ 27 files changed, 1854 insertions(+), 21 deletions(-) create mode 100644 libsemanage/include/semanage/ibendport_record.h create mode 100644 libsemanage/include/semanage/ibendports_local.h create mode 100644 libsemanage/include/semanage/ibendports_policy.h create mode 100644 libsemanage/src/ibendport_internal.h create mode 100644 libsemanage/src/ibendport_record.c create mode 100644 libsemanage/src/ibendports_file.c create mode 100644 libsemanage/src/ibendports_local.c create mode 100644 libsemanage/src/ibendports_policy.c create mode 100644 libsemanage/src/ibendports_policydb.c create mode 100644 libsepol/include/sepol/ibendport_record.h create mode 100644 libsepol/include/sepol/ibendports.h create mode 100644 libsepol/src/ibendport_internal.h create mode 100644 libsepol/src/ibendport_record.c create mode 100644 libsepol/src/ibendports.c diff --git a/libsemanage/include/semanage/ibendport_record.h b/libsemanage/include/semanage/ibendport_record.h new file mode 100644 index 0000000..153eea0 --- /dev/null +++ b/libsemanage/include/semanage/ibendport_record.h @@ -0,0 +1,62 @@ +/*Copyright (C) 2005 Red Hat, Inc. */ + +#ifndef _SEMANAGE_IBENDPORT_RECORD_H_ +#define _SEMANAGE_IBENDPORT_RECORD_H_ + +#include +#include +#include + +#ifndef _SEMANAGE_IBENDPORT_DEFINED_ +struct semanage_ibendport; +struct semanage_ibendport_key; +typedef struct semanage_ibendport semanage_ibendport_t; +typedef struct semanage_ibendport_key semanage_ibendport_key_t; +#define _SEMANAGE_IBENDPORT_DEFINED_ +#endif + +extern int semanage_ibendport_compare(const semanage_ibendport_t *ibendport, + const semanage_ibendport_key_t *key); + +extern int semanage_ibendport_compare2(const semanage_ibendport_t *ibendport, + const semanage_ibendport_t *ibendport2); + +extern int semanage_ibendport_key_create(semanage_handle_t *handle, + const char *ibdev_name, + int port, + semanage_ibendport_key_t **key_ptr); + +extern int semanage_ibendport_key_extract(semanage_handle_t *handle, + const semanage_ibendport_t *ibendport, + semanage_ibendport_key_t **key_ptr); + +extern void semanage_ibendport_key_free(semanage_ibendport_key_t *key); + +extern int semanage_ibendport_get_ibdev_name(semanage_handle_t *handle, + const semanage_ibendport_t *ibendport, + char **ibdev_name_ptr); + +extern int semanage_ibendport_set_ibdev_name(semanage_handle_t *handle, + semanage_ibendport_t *ibendport, + const char *ibdev_name); + +extern int semanage_ibendport_get_port(const semanage_ibendport_t *ibendport); + +extern void semanage_ibendport_set_port(semanage_ibendport_t *ibendport, int port); + +extern semanage_context_t *semanage_ibendport_get_con(const semanage_ibendport_t *ibendport); + +extern int semanage_ibendport_set_con(semanage_handle_t *handle, + semanage_ibendport_t *ibendport, + semanage_context_t *con); + +extern int semanage_ibendport_create(semanage_handle_t *handle, + semanage_ibendport_t **ibendport_ptr); + +extern int semanage_ibendport_clone(semanage_handle_t *handle, + const semanage_ibendport_t *ibendport, + semanage_ibendport_t **ibendport_ptr); + +extern void semanage_ibendport_free(semanage_ibendport_t *ibendport); + +#endif diff --git a/libsemanage/include/semanage/ibendports_local.h b/libsemanage/include/semanage/ibendports_local.h new file mode 100644 index 0000000..641dd35 --- /dev/null +++ b/libsemanage/include/semanage/ibendports_local.h @@ -0,0 +1,36 @@ +/* Copyright (C) 2017 Mellanox Technologies Inc */ + +#ifndef _SEMANAGE_IBENDPORTS_LOCAL_H_ +#define _SEMANAGE_IBENDPORTS_LOCAL_H_ + +#include +#include + +extern int semanage_ibendport_modify_local(semanage_handle_t *handle, + const semanage_ibendport_key_t *key, + const semanage_ibendport_t *data); + +extern int semanage_ibendport_del_local(semanage_handle_t *handle, + const semanage_ibendport_key_t *key); + +extern int semanage_ibendport_query_local(semanage_handle_t *handle, + const semanage_ibendport_key_t *key, + semanage_ibendport_t **response); + +extern int semanage_ibendport_exists_local(semanage_handle_t *handle, + const semanage_ibendport_key_t *key, + int *response); + +extern int semanage_ibendport_count_local(semanage_handle_t *handle, + unsigned int *response); + +extern int semanage_ibendport_iterate_local(semanage_handle_t *handle, + int (*handler)(const semanage_ibendport_t *record, + void *varg), + void *handler_arg); + +extern int semanage_ibendport_list_local(semanage_handle_t *handle, + semanage_ibendport_t ***records, + unsigned int *count); + +#endif diff --git a/libsemanage/include/semanage/ibendports_policy.h b/libsemanage/include/semanage/ibendports_policy.h new file mode 100644 index 0000000..3fc1976 --- /dev/null +++ b/libsemanage/include/semanage/ibendports_policy.h @@ -0,0 +1,28 @@ +/* Copyright (C) 2017 Mellanox Techonologies Inc */ + +#ifndef _SEMANAGE_IBENDPORTS_POLICY_H_ +#define _SEMANAGE_IBENDPORTS_POLICY_H_ + +#include +#include + +extern int semanage_ibendport_query(semanage_handle_t *handle, + const semanage_ibendport_key_t *key, + semanage_ibendport_t **response); + +extern int semanage_ibendport_exists(semanage_handle_t *handle, + const semanage_ibendport_key_t *key, int *response); + +extern int semanage_ibendport_count(semanage_handle_t *handle, + unsigned int *response); + +extern int semanage_ibendport_iterate(semanage_handle_t *handle, + int (*handler)(const semanage_ibendport_t *record, + void *varg), + void *handler_arg); + +extern int semanage_ibendport_list(semanage_handle_t *handle, + semanage_ibendport_t ***records, + unsigned int *count); + +#endif diff --git a/libsemanage/include/semanage/semanage.h b/libsemanage/include/semanage/semanage.h index cebf3f4..0489014 100644 --- a/libsemanage/include/semanage/semanage.h +++ b/libsemanage/include/semanage/semanage.h @@ -34,6 +34,7 @@ #include #include #include +#include #include /* Dbase */ @@ -49,6 +50,8 @@ #include #include #include +#include +#include #include #include #include diff --git a/libsemanage/src/direct_api.c b/libsemanage/src/direct_api.c index 436e334..68c1868 100644 --- a/libsemanage/src/direct_api.c +++ b/libsemanage/src/direct_api.c @@ -41,6 +41,7 @@ #include "seuser_internal.h" #include "port_internal.h" #include "ibpkey_internal.h" +#include "ibendport_internal.h" #include "iface_internal.h" #include "boolean_internal.h" #include "fcontext_internal.h" @@ -226,11 +227,19 @@ int semanage_direct_connect(semanage_handle_t * sh) goto err; if (ibpkey_file_dbase_init(sh, - semanage_path(SEMANAGE_ACTIVE, - SEMANAGE_IBPKEYS_LOCAL), - semanage_path(SEMANAGE_TMP, - SEMANAGE_IBPKEYS_LOCAL), - semanage_ibpkey_dbase_local(sh)) < 0) + semanage_path(SEMANAGE_ACTIVE, + SEMANAGE_IBPKEYS_LOCAL), + semanage_path(SEMANAGE_TMP, + SEMANAGE_IBPKEYS_LOCAL), + semanage_ibpkey_dbase_local(sh)) < 0) + goto err; + + if (ibendport_file_dbase_init(sh, + semanage_path(SEMANAGE_ACTIVE, + SEMANAGE_IBENDPORTS_LOCAL), + semanage_path(SEMANAGE_TMP, + SEMANAGE_IBENDPORTS_LOCAL), + semanage_ibendport_dbase_local(sh)) < 0) goto err; /* Object databases: local modifications + policy */ @@ -260,6 +269,9 @@ int semanage_direct_connect(semanage_handle_t * sh) if (ibpkey_policydb_dbase_init(sh, semanage_ibpkey_dbase_policy(sh)) < 0) goto err; + if (ibendport_policydb_dbase_init(sh, semanage_ibendport_dbase_policy(sh)) < 0) + goto err; + if (iface_policydb_dbase_init(sh, semanage_iface_dbase_policy(sh)) < 0) goto err; @@ -333,6 +345,7 @@ static int semanage_direct_disconnect(semanage_handle_t * sh) user_join_dbase_release(semanage_user_dbase_local(sh)); port_file_dbase_release(semanage_port_dbase_local(sh)); ibpkey_file_dbase_release(semanage_ibpkey_dbase_local(sh)); + ibendport_file_dbase_release(semanage_ibendport_dbase_local(sh)); iface_file_dbase_release(semanage_iface_dbase_local(sh)); bool_file_dbase_release(semanage_bool_dbase_local(sh)); fcontext_file_dbase_release(semanage_fcontext_dbase_local(sh)); @@ -345,6 +358,7 @@ static int semanage_direct_disconnect(semanage_handle_t * sh) user_join_dbase_release(semanage_user_dbase_policy(sh)); port_policydb_dbase_release(semanage_port_dbase_policy(sh)); ibpkey_policydb_dbase_release(semanage_ibpkey_dbase_policy(sh)); + ibendport_policydb_dbase_release(semanage_ibendport_dbase_policy(sh)); iface_policydb_dbase_release(semanage_iface_dbase_policy(sh)); bool_policydb_dbase_release(semanage_bool_dbase_policy(sh)); fcontext_file_dbase_release(semanage_fcontext_dbase_policy(sh)); @@ -1158,7 +1172,8 @@ static int semanage_direct_commit(semanage_handle_t * sh) int do_rebuild, do_write_kernel, do_install; int fcontexts_modified, ports_modified, seusers_modified, - disable_dontaudit, preserve_tunables, ibpkeys_modified; + disable_dontaudit, preserve_tunables, ibpkeys_modified, + ibendports_modified; dbase_config_t *users = semanage_user_dbase_local(sh); dbase_config_t *users_base = semanage_user_base_dbase_local(sh); dbase_config_t *pusers_base = semanage_user_base_dbase_policy(sh); @@ -1167,6 +1182,8 @@ static int semanage_direct_commit(semanage_handle_t * sh) dbase_config_t *pports = semanage_port_dbase_policy(sh); dbase_config_t *ibpkeys = semanage_ibpkey_dbase_local(sh); dbase_config_t *pibpkeys = semanage_ibpkey_dbase_policy(sh); + dbase_config_t *ibendports = semanage_ibendport_dbase_local(sh); + dbase_config_t *pibendports = semanage_ibendport_dbase_policy(sh); dbase_config_t *bools = semanage_bool_dbase_local(sh); dbase_config_t *pbools = semanage_bool_dbase_policy(sh); dbase_config_t *ifaces = semanage_iface_dbase_local(sh); @@ -1181,6 +1198,7 @@ static int semanage_direct_commit(semanage_handle_t * sh) /* Modified flags that we need to use more than once. */ ports_modified = ports->dtable->is_modified(ports->dbase); ibpkeys_modified = ibpkeys->dtable->is_modified(ibpkeys->dbase); + ibendports_modified = ibendports->dtable->is_modified(ibendports->dbase); seusers_modified = seusers->dtable->is_modified(seusers->dbase); fcontexts_modified = fcontexts->dtable->is_modified(fcontexts->dbase); @@ -1303,6 +1321,7 @@ rebuild: * will be modified. */ do_write_kernel = do_rebuild | ports_modified | ibpkeys_modified | + ibendports_modified | bools->dtable->is_modified(bools->dbase) | ifaces->dtable->is_modified(ifaces->dbase) | nodes->dtable->is_modified(nodes->dbase) | @@ -1449,6 +1468,7 @@ rebuild: dbase_policydb_attach((dbase_policydb_t *) pusers_base->dbase, out); dbase_policydb_attach((dbase_policydb_t *) pports->dbase, out); dbase_policydb_attach((dbase_policydb_t *) pibpkeys->dbase, out); + dbase_policydb_attach((dbase_policydb_t *) pibendports->dbase, out); dbase_policydb_attach((dbase_policydb_t *) pifaces->dbase, out); dbase_policydb_attach((dbase_policydb_t *) pbools->dbase, out); dbase_policydb_attach((dbase_policydb_t *) pnodes->dbase, out); @@ -1503,6 +1523,13 @@ rebuild: if (retval < 0) goto cleanup; } + + /* Validate local ibendports */ + if (do_rebuild || ibendports_modified) { + retval = semanage_ibendport_validate_local(sh); + if (retval < 0) + goto cleanup; + } /* ================== Write non-policydb components ========= */ /* Commit changes to components */ @@ -1583,6 +1610,7 @@ cleanup: dbase_policydb_detach((dbase_policydb_t *) pusers_base->dbase); dbase_policydb_detach((dbase_policydb_t *) pports->dbase); dbase_policydb_detach((dbase_policydb_t *) pibpkeys->dbase); + dbase_policydb_detach((dbase_policydb_t *) pibendports->dbase); dbase_policydb_detach((dbase_policydb_t *) pifaces->dbase); dbase_policydb_detach((dbase_policydb_t *) pnodes->dbase); dbase_policydb_detach((dbase_policydb_t *) pbools->dbase); diff --git a/libsemanage/src/handle.h b/libsemanage/src/handle.h index 306727a..889871d 100644 --- a/libsemanage/src/handle.h +++ b/libsemanage/src/handle.h @@ -79,7 +79,7 @@ struct semanage_handle { struct semanage_policy_table *funcs; /* Object databases */ -#define DBASE_COUNT 21 +#define DBASE_COUNT 23 /* Local modifications */ #define DBASE_LOCAL_USERS_BASE 0 @@ -92,21 +92,23 @@ struct semanage_handle { #define DBASE_LOCAL_SEUSERS 7 #define DBASE_LOCAL_NODES 8 #define DBASE_LOCAL_IBPKEYS 9 +#define DBASE_LOCAL_IBENDPORTS 10 /* Policy + Local modifications */ -#define DBASE_POLICY_USERS_BASE 10 -#define DBASE_POLICY_USERS_EXTRA 11 -#define DBASE_POLICY_USERS 12 -#define DBASE_POLICY_PORTS 13 -#define DBASE_POLICY_INTERFACES 14 -#define DBASE_POLICY_BOOLEANS 15 -#define DBASE_POLICY_FCONTEXTS 16 -#define DBASE_POLICY_SEUSERS 17 -#define DBASE_POLICY_NODES 18 -#define DBASE_POLICY_IBPKEYS 19 +#define DBASE_POLICY_USERS_BASE 11 +#define DBASE_POLICY_USERS_EXTRA 12 +#define DBASE_POLICY_USERS 13 +#define DBASE_POLICY_PORTS 14 +#define DBASE_POLICY_INTERFACES 15 +#define DBASE_POLICY_BOOLEANS 16 +#define DBASE_POLICY_FCONTEXTS 17 +#define DBASE_POLICY_SEUSERS 18 +#define DBASE_POLICY_NODES 19 +#define DBASE_POLICY_IBPKEYS 20 +#define DBASE_POLICY_IBENDPORTS 21 /* Active kernel policy */ -#define DBASE_ACTIVE_BOOLEANS 20 +#define DBASE_ACTIVE_BOOLEANS 22 dbase_config_t dbase[DBASE_COUNT]; }; @@ -142,6 +144,12 @@ static inline } static inline + dbase_config_t * semanage_ibendport_dbase_local(semanage_handle_t * handle) +{ + return &handle->dbase[DBASE_LOCAL_IBENDPORTS]; +} + +static inline dbase_config_t * semanage_iface_dbase_local(semanage_handle_t * handle) { return &handle->dbase[DBASE_LOCAL_INTERFACES]; @@ -204,6 +212,12 @@ static inline } static inline + dbase_config_t * semanage_ibendport_dbase_policy(semanage_handle_t * handle) +{ + return &handle->dbase[DBASE_POLICY_IBENDPORTS]; +} + +static inline dbase_config_t * semanage_iface_dbase_policy(semanage_handle_t * handle) { return &handle->dbase[DBASE_POLICY_INTERFACES]; diff --git a/libsemanage/src/ibendport_internal.h b/libsemanage/src/ibendport_internal.h new file mode 100644 index 0000000..970fbdb --- /dev/null +++ b/libsemanage/src/ibendport_internal.h @@ -0,0 +1,48 @@ +#ifndef _SEMANAGE_IBENDPORT_INTERNAL_H_ +#define _SEMANAGE_IBENDPORT_INTERNAL_H_ + +#include +#include +#include +#include "database.h" +#include "handle.h" +#include "dso.h" + +hidden_proto(semanage_ibendport_create) +hidden_proto(semanage_ibendport_compare) +hidden_proto(semanage_ibendport_compare2) +hidden_proto(semanage_ibendport_clone) +hidden_proto(semanage_ibendport_free) +hidden_proto(semanage_ibendport_key_extract) +hidden_proto(semanage_ibendport_key_free) +hidden_proto(semanage_ibendport_get_port) +hidden_proto(semanage_ibendport_set_port) +hidden_proto(semanage_ibendport_get_con) +hidden_proto(semanage_ibendport_set_con) +hidden_proto(semanage_ibendport_list_local) +hidden_proto(semanage_ibendport_get_ibdev_name) +hidden_proto(semanage_ibendport_set_ibdev_name) + +/* IBENDPORT RECORD: method table */ +extern record_table_t SEMANAGE_IBENDPORT_RTABLE; + +extern int ibendport_file_dbase_init(semanage_handle_t *handle, + const char *path_ro, + const char *path_rw, + dbase_config_t *dconfig); + +extern void ibendport_file_dbase_release(dbase_config_t *dconfig); + +extern int ibendport_policydb_dbase_init(semanage_handle_t *handle, + dbase_config_t *dconfig); + +extern void ibendport_policydb_dbase_release(dbase_config_t *dconfig); + +extern int hidden semanage_ibendport_validate_local(semanage_handle_t *handle); + +/* ==== Internal (to ibendports) API === */ + +hidden int semanage_ibendport_compare2_qsort(const semanage_ibendport_t **ibendport, + const semanage_ibendport_t **ibendport2); + +#endif diff --git a/libsemanage/src/ibendport_record.c b/libsemanage/src/ibendport_record.c new file mode 100644 index 0000000..955067e --- /dev/null +++ b/libsemanage/src/ibendport_record.c @@ -0,0 +1,154 @@ +/*Copyright (C) 2005 Red Hat, Inc. */ + +/*Object: semanage_ibendport_t (Infiniband Pkey) + *Object: semanage_ibendport_key_t (Infiniband Pkey Key) + *Implements: record_t (Database Record) + *Implements: record_key_t (Database Record Key) + */ + +#include +#include + +typedef sepol_context_t semanage_context_t; +typedef sepol_ibendport_t semanage_ibendport_t; +typedef sepol_ibendport_key_t semanage_ibendport_key_t; +#define _SEMANAGE_IBENDPORT_DEFINED_ +#define _SEMANAGE_CONTEXT_DEFINED_ + +typedef semanage_ibendport_t record_t; +typedef semanage_ibendport_key_t record_key_t; +#define DBASE_RECORD_DEFINED + +#include "ibendport_internal.h" +#include "handle.h" +#include "database.h" + +int semanage_ibendport_compare(const semanage_ibendport_t *ibendport, + const semanage_ibendport_key_t *key) +{ + return sepol_ibendport_compare(ibendport, key); +} + +hidden_def(semanage_ibendport_compare) + +int semanage_ibendport_compare2(const semanage_ibendport_t *ibendport, + const semanage_ibendport_t *ibendport2) +{ + return sepol_ibendport_compare2(ibendport, ibendport2); +} + +hidden_def(semanage_ibendport_compare2) + +hidden int semanage_ibendport_compare2_qsort(const semanage_ibendport_t **ibendport, + const semanage_ibendport_t **ibendport2) +{ + return sepol_ibendport_compare2(*ibendport, *ibendport2); +} + +int semanage_ibendport_key_create(semanage_handle_t *handle, + const char *ibdev_name, + int port, + semanage_ibendport_key_t **key_ptr) +{ + return sepol_ibendport_key_create(handle->sepolh, ibdev_name, port, key_ptr); +} + +int semanage_ibendport_key_extract(semanage_handle_t *handle, + const semanage_ibendport_t *ibendport, + semanage_ibendport_key_t **key_ptr) +{ + return sepol_ibendport_key_extract(handle->sepolh, ibendport, key_ptr); +} + +hidden_def(semanage_ibendport_key_extract) + +void semanage_ibendport_key_free(semanage_ibendport_key_t *key) +{ + sepol_ibendport_key_free(key); +} + +hidden_def(semanage_ibendport_key_free) + +int semanage_ibendport_get_ibdev_name(semanage_handle_t *handle, + const semanage_ibendport_t *ibendport, + char **ibdev_name_ptr) +{ + return sepol_ibendport_get_ibdev_name(handle->sepolh, ibendport, ibdev_name_ptr); +} + +hidden_def(semanage_ibendport_get_ibdev_name) + +int semanage_ibendport_set_ibdev_name(semanage_handle_t *handle, + semanage_ibendport_t *ibendport, + const char *ibdev_name) +{ + return sepol_ibendport_set_ibdev_name(handle->sepolh, ibendport, ibdev_name); +} + +hidden_def(semanage_ibendport_set_ibdev_name) + +int semanage_ibendport_get_port(const semanage_ibendport_t *ibendport) +{ + return sepol_ibendport_get_port(ibendport); +} + +hidden_def(semanage_ibendport_get_port) + +void semanage_ibendport_set_port(semanage_ibendport_t *ibendport, int port) +{ + sepol_ibendport_set_port(ibendport, port); +} + +hidden_def(semanage_ibendport_set_port) + +semanage_context_t *semanage_ibendport_get_con(const semanage_ibendport_t *ibendport) +{ + return sepol_ibendport_get_con(ibendport); +} + +hidden_def(semanage_ibendport_get_con) + +int semanage_ibendport_set_con(semanage_handle_t *handle, + semanage_ibendport_t *ibendport, + semanage_context_t *con) +{ + return sepol_ibendport_set_con(handle->sepolh, ibendport, con); +} + +hidden_def(semanage_ibendport_set_con) + +int semanage_ibendport_create(semanage_handle_t *handle, + semanage_ibendport_t **ibendport_ptr) +{ + return sepol_ibendport_create(handle->sepolh, ibendport_ptr); +} + +hidden_def(semanage_ibendport_create) + +int semanage_ibendport_clone(semanage_handle_t *handle, + const semanage_ibendport_t *ibendport, + semanage_ibendport_t **ibendport_ptr) +{ + return sepol_ibendport_clone(handle->sepolh, ibendport, ibendport_ptr); +} + +hidden_def(semanage_ibendport_clone) + +void semanage_ibendport_free(semanage_ibendport_t *ibendport) +{ + sepol_ibendport_free(ibendport); +} + +hidden_def(semanage_ibendport_free) + +/*key base functions */ +record_table_t SEMANAGE_IBENDPORT_RTABLE = { + .create = semanage_ibendport_create, + .key_extract = semanage_ibendport_key_extract, + .key_free = semanage_ibendport_key_free, + .clone = semanage_ibendport_clone, + .compare = semanage_ibendport_compare, + .compare2 = semanage_ibendport_compare2, + .compare2_qsort = semanage_ibendport_compare2_qsort, + .free = semanage_ibendport_free, +}; diff --git a/libsemanage/src/ibendports_file.c b/libsemanage/src/ibendports_file.c new file mode 100644 index 0000000..402c7a5 --- /dev/null +++ b/libsemanage/src/ibendports_file.c @@ -0,0 +1,157 @@ +/* Copyright (C) 2017 Mellanox Technologies Inc. */ + +struct semanage_ibendport; +struct semanage_ibendport_key; +typedef struct semanage_ibendport record_t; +typedef struct semanage_ibendport_key record_key_t; +#define DBASE_RECORD_DEFINED + +struct dbase_file; +typedef struct dbase_file dbase_t; +#define DBASE_DEFINED + +#include +#include +#include +#include +#include "ibendport_internal.h" +#include "context_internal.h" +#include "database_file.h" +#include "parse_utils.h" +#include "debug.h" + +static int ibendport_print(semanage_handle_t *handle, + semanage_ibendport_t *ibendport, + FILE *str) +{ + char *con_str = NULL; + char *ibdev_name_str = NULL; + int port = semanage_ibendport_get_port(ibendport); + + if (semanage_ibendport_get_ibdev_name(handle, ibendport, &ibdev_name_str) != 0) + goto err; + + semanage_context_t *con = semanage_ibendport_get_con(ibendport); + + if (fprintf(str, "ibendportcon %s ", ibdev_name_str) < 0) + goto err; + + if (fprintf(str, "%d ", port) < 0) + goto err; + + if (semanage_context_to_string(handle, con, &con_str) < 0) + goto err; + if (fprintf(str, "%s\n", con_str) < 0) + goto err; + + free(ibdev_name_str); + free(con_str); + return STATUS_SUCCESS; + +err: + ERR(handle, "could not print ibendport (%s) %u to stream", + ibdev_name_str, port); + free(ibdev_name_str); + free(con_str); + return STATUS_ERR; +} + +static int ibendport_parse(semanage_handle_t *handle, + parse_info_t *info, + semanage_ibendport_t *ibendport) +{ + int port; + char *str = NULL; + semanage_context_t *con = NULL; + + if (parse_skip_space(handle, info) < 0) + goto err; + if (!info->ptr) + goto last; + + /* Header */ + if (parse_assert_str(handle, info, "ibendportcon") < 0) + goto err; + if (parse_assert_space(handle, info) < 0) + goto err; + + /* IB Device Name */ + if (parse_fetch_string(handle, info, &str, ' ') < 0) + goto err; + if (semanage_ibendport_set_ibdev_name(handle, ibendport, str) < 0) + goto err; + free(str); + str = NULL; + + /* Port */ + if (parse_assert_space(handle, info) < 0) + goto err; + if (parse_fetch_int(handle, info, &port, ' ') < 0) + goto err; + semanage_ibendport_set_port(ibendport, port); + + /* context */ + if (parse_assert_space(handle, info) < 0) + goto err; + if (parse_fetch_string(handle, info, &str, ' ') < 0) + goto err; + if (semanage_context_from_string(handle, str, &con) < 0) { + ERR(handle, "invalid security context \"%s\" (%s: %u)\n%s", + str, info->filename, info->lineno, info->orig_line); + goto err; + } + if (!con) { + ERR(handle, "<> context is not valid for ibendport (%s: %u):\n%s", + info->filename, info->lineno, info->orig_line); + goto err; + } + free(str); + str = NULL; + + if (semanage_ibendport_set_con(handle, ibendport, con) < 0) + goto err; + + if (parse_assert_space(handle, info) < 0) + goto err; + + semanage_context_free(con); + return STATUS_SUCCESS; + +last: + parse_dispose_line(info); + return STATUS_NODATA; + +err: + ERR(handle, "could not parse ibendport record"); + free(str); + semanage_context_free(con); + parse_dispose_line(info); + return STATUS_ERR; +} + +/* IBENDPORT RECORD: FILE extension: method table */ +record_file_table_t SEMANAGE_IBENDPORT_FILE_RTABLE = { + .parse = ibendport_parse, + .print = ibendport_print, +}; + +int ibendport_file_dbase_init(semanage_handle_t *handle, + const char *path_ro, + const char *path_rw, + dbase_config_t *dconfig) +{ + if (dbase_file_init(handle, + path_ro, + path_rw, + &SEMANAGE_IBENDPORT_RTABLE, + &SEMANAGE_IBENDPORT_FILE_RTABLE, &dconfig->dbase) < 0) + return STATUS_ERR; + + dconfig->dtable = &SEMANAGE_FILE_DTABLE; + return STATUS_SUCCESS; +} + +void ibendport_file_dbase_release(dbase_config_t *dconfig) +{ + dbase_file_release(dconfig->dbase); +} diff --git a/libsemanage/src/ibendports_local.c b/libsemanage/src/ibendports_local.c new file mode 100644 index 0000000..8b5567d --- /dev/null +++ b/libsemanage/src/ibendports_local.c @@ -0,0 +1,153 @@ +/* Copyright (C) 2017 Mellanox Technologies Inc */ + +struct semanage_ibendport; +struct semanage_ibendport_key; +typedef struct semanage_ibendport_key record_key_t; +typedef struct semanage_ibendport record_t; +#define DBASE_RECORD_DEFINED + +#include +#include +#include +#include "ibendport_internal.h" +#include "debug.h" +#include "handle.h" +#include "database.h" + +int semanage_ibendport_modify_local(semanage_handle_t *handle, + const semanage_ibendport_key_t *key, + const semanage_ibendport_t *data) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_local(handle); + + return dbase_modify(handle, dconfig, key, data); +} + +int semanage_ibendport_del_local(semanage_handle_t *handle, + const semanage_ibendport_key_t *key) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_local(handle); + + return dbase_del(handle, dconfig, key); +} + +int semanage_ibendport_query_local(semanage_handle_t *handle, + const semanage_ibendport_key_t *key, + semanage_ibendport_t **response) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_local(handle); + + return dbase_query(handle, dconfig, key, response); +} + +int semanage_ibendport_exists_local(semanage_handle_t *handle, + const semanage_ibendport_key_t *key, + int *response) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_local(handle); + + return dbase_exists(handle, dconfig, key, response); +} + +int semanage_ibendport_count_local(semanage_handle_t *handle, + unsigned int *response) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_local(handle); + + return dbase_count(handle, dconfig, response); +} + +int semanage_ibendport_iterate_local(semanage_handle_t *handle, + int (*handler)(const semanage_ibendport_t *record, + void *varg), void *handler_arg) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_local(handle); + return dbase_iterate(handle, dconfig, handler, handler_arg); +} + +int semanage_ibendport_list_local(semanage_handle_t *handle, + semanage_ibendport_t ***records, + unsigned int *count) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_local(handle); + + return dbase_list(handle, dconfig, records, count); +} + +hidden_def(semanage_ibendport_list_local) + +int hidden semanage_ibendport_validate_local(semanage_handle_t *handle) +{ + semanage_ibendport_t **ibendports = NULL; + unsigned int nibendports = 0; + unsigned int i = 0, j = 0; + char *ibdev_name; + char *ibdev_name2; + int port; + int port2; + + /* List and sort the ibendports */ + if (semanage_ibendport_list_local(handle, &ibendports, &nibendports) < 0) + goto err; + + qsort(ibendports, nibendports, sizeof(semanage_ibendport_t *), + (int (*)(const void *, const void *)) + &semanage_ibendport_compare2_qsort); + + /* Test each ibendport */ + while (i < nibendports) { + int stop = 0; + + if (STATUS_SUCCESS != + semanage_ibendport_get_ibdev_name(handle, + ibendports[i], + &ibdev_name)) { + ERR(handle, "Couldn't get IB device name"); + goto err; + } + + port = semanage_ibendport_get_port(ibendports[i]); + + /* Find the first ibendport with matching + * ibdev_name to compare against + */ + do { + if (j == nibendports - 1) + goto next; + j++; + if (STATUS_SUCCESS != + semanage_ibendport_get_ibdev_name(handle, + ibendports[j], + &ibdev_name2)) { + ERR(handle, "Couldn't get IB device name."); + goto err; + } + port2 = semanage_ibendport_get_port(ibendports[j]); + + stop = !strcmp(ibdev_name, ibdev_name2); + } while (!stop); + + if (port == port2) { + ERR(handle, "ibendport %s/%u already exists.", + ibdev_name2, port2); + goto invalid; + } +next: + i++; + j = i; + } + + for (i = 0; i < nibendports; i++) + semanage_ibendport_free(ibendports[i]); + free(ibendports); + return STATUS_SUCCESS; + +err: + ERR(handle, "could not complete ibendports validity check"); + +invalid: + for (i = 0; i < nibendports; i++) + semanage_ibendport_free(ibendports[i]); + free(ibendports); + return STATUS_ERR; +} diff --git a/libsemanage/src/ibendports_policy.c b/libsemanage/src/ibendports_policy.c new file mode 100644 index 0000000..1347b67 --- /dev/null +++ b/libsemanage/src/ibendports_policy.c @@ -0,0 +1,55 @@ +/* Copyright (C) 2017 Mellanox Technologies Inc */ + +struct semanage_ibendport; +struct semanage_ibendport_key; +typedef struct semanage_ibendport_key record_key_t; +typedef struct semanage_ibendport record_t; +#define DBASE_RECORD_DEFINED + +#include "ibendport_internal.h" +#include "handle.h" +#include "database.h" + +int semanage_ibendport_query(semanage_handle_t *handle, + const semanage_ibendport_key_t *key, + semanage_ibendport_t **response) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_policy(handle); + + return dbase_query(handle, dconfig, key, response); +} + +int semanage_ibendport_exists(semanage_handle_t *handle, + const semanage_ibendport_key_t *key, + int *response) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_policy(handle); + + return dbase_exists(handle, dconfig, key, response); +} + +int semanage_ibendport_count(semanage_handle_t *handle, + unsigned int *response) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_policy(handle); + + return dbase_count(handle, dconfig, response); +} + +int semanage_ibendport_iterate(semanage_handle_t *handle, + int (*handler)(const semanage_ibendport_t *record, + void *varg), void *handler_arg) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_policy(handle); + + return dbase_iterate(handle, dconfig, handler, handler_arg); +} + +int semanage_ibendport_list(semanage_handle_t *handle, + semanage_ibendport_t ***records, + unsigned int *count) +{ + dbase_config_t *dconfig = semanage_ibendport_dbase_policy(handle); + + return dbase_list(handle, dconfig, records, count); +} diff --git a/libsemanage/src/ibendports_policydb.c b/libsemanage/src/ibendports_policydb.c new file mode 100644 index 0000000..1029810 --- /dev/null +++ b/libsemanage/src/ibendports_policydb.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2017 Mellanox Technologies Inc + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + */ + +struct semanage_ibendport; +struct semanage_ibendport_key; +typedef struct semanage_ibendport record_t; +typedef struct semanage_ibendport_key record_key_t; +#define DBASE_RECORD_DEFINED + +struct dbase_policydb; +typedef struct dbase_policydb dbase_t; +#define DBASE_DEFINED + +#include +#include +#include "ibendport_internal.h" +#include "debug.h" +#include "database_policydb.h" +#include "semanage_store.h" + +/* IBENDPORT RECORD (SEPOL): POLICYDB extension : method table */ +record_policydb_table_t SEMANAGE_IBENDPORT_POLICYDB_RTABLE = { + .add = NULL, + .modify = (record_policydb_table_modify_t)sepol_ibendport_modify, + .set = NULL, + .query = (record_policydb_table_query_t)sepol_ibendport_query, + .count = (record_policydb_table_count_t)sepol_ibendport_count, + .exists = (record_policydb_table_exists_t)sepol_ibendport_exists, + .iterate = (record_policydb_table_iterate_t)sepol_ibendport_iterate, +}; + +int ibendport_policydb_dbase_init(semanage_handle_t *handle, + dbase_config_t *dconfig) +{ + if (dbase_policydb_init(handle, + semanage_path(SEMANAGE_ACTIVE, SEMANAGE_STORE_KERNEL), + semanage_path(SEMANAGE_TMP, SEMANAGE_STORE_KERNEL), + &SEMANAGE_IBENDPORT_RTABLE, + &SEMANAGE_IBENDPORT_POLICYDB_RTABLE, + &dconfig->dbase) < 0) + return STATUS_ERR; + + dconfig->dtable = &SEMANAGE_POLICYDB_DTABLE; + + return STATUS_SUCCESS; +} + +void ibendport_policydb_dbase_release(dbase_config_t *dconfig) +{ + dbase_policydb_release(dconfig->dbase); +} diff --git a/libsemanage/src/libsemanage.map b/libsemanage/src/libsemanage.map index 041b1ce..0203669 100644 --- a/libsemanage/src/libsemanage.map +++ b/libsemanage/src/libsemanage.map @@ -19,6 +19,7 @@ LIBSEMANAGE_1.0 { semanage_user_*; semanage_bool_*; semanage_seuser_*; semanage_iface_*; semanage_port_*; semanage_context_*; semanage_ibpkey_*; + semanage_ibendport_*; semanage_node_*; semanage_fcontext_*; semanage_access_check; semanage_set_create_store; semanage_is_connected; semanage_get_disable_dontaudit; semanage_set_disable_dontaudit; diff --git a/libsemanage/src/policy_components.c b/libsemanage/src/policy_components.c index 136c5a7..896ac51 100644 --- a/libsemanage/src/policy_components.c +++ b/libsemanage/src/policy_components.c @@ -140,6 +140,9 @@ int semanage_base_merge_components(semanage_handle_t * handle) {semanage_ibpkey_dbase_local(handle), semanage_ibpkey_dbase_policy(handle), MODE_MODIFY}, + + {semanage_ibendport_dbase_local(handle), + semanage_ibendport_dbase_policy(handle), MODE_MODIFY}, }; const unsigned int CCOUNT = sizeof(components) / sizeof(components[0]); @@ -221,6 +224,7 @@ int semanage_commit_components(semanage_handle_t * handle) semanage_bool_dbase_active(handle), semanage_node_dbase_local(handle), semanage_ibpkey_dbase_local(handle), + semanage_ibendport_dbase_local(handle), }; const int CCOUNT = sizeof(components) / sizeof(components[0]); diff --git a/libsemanage/src/semanage_store.c b/libsemanage/src/semanage_store.c index f61f3b2..5642772 100644 --- a/libsemanage/src/semanage_store.c +++ b/libsemanage/src/semanage_store.c @@ -100,6 +100,7 @@ static const char *semanage_sandbox_paths[SEMANAGE_STORE_NUM_PATHS] = { "/file_contexts.template", "/commit_num", "/pkeys.local", + "/ibendports.local", "/ports.local", "/interfaces.local", "/nodes.local", diff --git a/libsemanage/src/semanage_store.h b/libsemanage/src/semanage_store.h index c7bcf44..fcaa505 100644 --- a/libsemanage/src/semanage_store.h +++ b/libsemanage/src/semanage_store.h @@ -45,6 +45,7 @@ enum semanage_sandbox_defs { SEMANAGE_FC_TMPL, SEMANAGE_COMMIT_NUM_FILE, SEMANAGE_IBPKEYS_LOCAL, + SEMANAGE_IBENDPORTS_LOCAL, SEMANAGE_PORTS_LOCAL, SEMANAGE_INTERFACES_LOCAL, SEMANAGE_NODES_LOCAL, diff --git a/libsemanage/src/semanageswig.i b/libsemanage/src/semanageswig.i index d3ca795..ebf39cf 100644 --- a/libsemanage/src/semanageswig.i +++ b/libsemanage/src/semanageswig.i @@ -42,6 +42,9 @@ %include "../include/semanage/ibpkey_record.h" %include "../include/semanage/ibpkeys_local.h" %include "../include/semanage/ibpkeys_policy.h" +%include "../include/semanage/ibendport_record.h" +%include "../include/semanage/ibendports_local.h" +%include "../include/semanage/ibendports_policy.h" %include "../include/semanage/fcontext_record.h" %include "../include/semanage/fcontexts_local.h" %include "../include/semanage/fcontexts_policy.h" diff --git a/libsemanage/src/semanageswig_python.i b/libsemanage/src/semanageswig_python.i index 40932d8..8604b8a 100644 --- a/libsemanage/src/semanageswig_python.i +++ b/libsemanage/src/semanageswig_python.i @@ -480,6 +480,49 @@ $1 = &temp; } +/** ibendport typemaps **/ + +/* the wrapper will setup this parameter for passing... the resulting python functions + will not take the semanage_ibendport_t *** parameter */ +%typemap(in, numinputs=0) semanage_ibendport_t ***(semanage_ibendport_t **temp=NULL) { + $1 = &temp; +} + +%typemap(argout) ( + semanage_handle_t* handle, + semanage_ibendport_t*** records, + unsigned int* count) { + + if ($result) { + int value; + SWIG_AsVal_int($result, &value); + if (value >= 0) { + PyObject* plist = NULL; + if (semanage_array2plist($1, (void**) *$2, *$3, SWIGTYPE_p_semanage_ibendport, + (void (*) (void*)) &semanage_ibendport_free, &plist) < 0) + $result = SWIG_From_int(STATUS_ERR); + else + $result = SWIG_Python_AppendOutput($result, plist); + } + } +} + +%typemap(in, numinputs=0) semanage_ibendport_t **(semanage_ibendport_t *temp=NULL) { + $1 = &temp; +} + +%typemap(argout) semanage_ibendport_t ** { + $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(*$1, $*1_descriptor, 0)); +} + +%typemap(argout) semanage_ibendport_key_t ** { + $result = SWIG_Python_AppendOutput($result, SWIG_NewPointerObj(*$1, $*1_descriptor, 0)); +} + +%typemap(in, numinputs=0) semanage_ibendport_key_t **(semanage_ibendport_key_t *temp=NULL) { + $1 = &temp; +} + /** node typemaps **/ /* the wrapper will setup this parameter for passing... the resulting python functions diff --git a/libsemanage/utils/semanage_migrate_store b/libsemanage/utils/semanage_migrate_store index 325de47..9a9fac2 100755 --- a/libsemanage/utils/semanage_migrate_store +++ b/libsemanage/utils/semanage_migrate_store @@ -254,7 +254,8 @@ if __name__ == "__main__": "policy.kern", "file_contexts", "homedir_template", - "pkeys.local"] + "pkeys.local", + "ibendports.local"] create_dir(newroot_path(), 0o755) diff --git a/libsepol/include/sepol/ibendport_record.h b/libsepol/include/sepol/ibendport_record.h new file mode 100644 index 0000000..e30b252 --- /dev/null +++ b/libsepol/include/sepol/ibendport_record.h @@ -0,0 +1,68 @@ +#ifndef _SEPOL_IBENDPORT_RECORD_H_ +#define _SEPOL_IBENDPORT_RECORD_H_ + +#include +#include +#include +#include + +__BEGIN_DECLS + +struct sepol_ibendport; +struct sepol_ibendport_key; +typedef struct sepol_ibendport sepol_ibendport_t; +typedef struct sepol_ibendport_key sepol_ibendport_key_t; + +extern int sepol_ibendport_compare(const sepol_ibendport_t *ibendport, + const sepol_ibendport_key_t *key); + +extern int sepol_ibendport_compare2(const sepol_ibendport_t *ibendport, + const sepol_ibendport_t *ibendport2); + +extern int sepol_ibendport_key_create(sepol_handle_t *handle, + const char *ibdev_name, + int port, + sepol_ibendport_key_t **key_ptr); + +extern void sepol_ibendport_key_unpack(const sepol_ibendport_key_t *key, + const char **ibdev_name, + int *port); + +extern int sepol_ibendport_alloc_ibdev_name(sepol_handle_t *handle, + char **ibdev_name); + +extern int sepol_ibendport_key_extract(sepol_handle_t *handle, + const sepol_ibendport_t *ibendport, + sepol_ibendport_key_t **key_ptr); + +extern void sepol_ibendport_key_free(sepol_ibendport_key_t *key); + +extern void sepol_ibendport_set_port(sepol_ibendport_t *ibendport, int port); + +extern int sepol_ibendport_get_port(const sepol_ibendport_t *ibendport); + +extern int sepol_ibendport_get_ibdev_name(sepol_handle_t *handle, + const sepol_ibendport_t *ibendport, + char **ibdev_name); + +extern int sepol_ibendport_set_ibdev_name(sepol_handle_t *handle, + sepol_ibendport_t *ibendport, + const char *ibdev_name); + +extern sepol_context_t *sepol_ibendport_get_con(const sepol_ibendport_t *ibendport); + +extern int sepol_ibendport_set_con(sepol_handle_t *handle, + sepol_ibendport_t *ibendport, + sepol_context_t *con); + +extern int sepol_ibendport_create(sepol_handle_t *handle, + sepol_ibendport_t **ibendport_ptr); + +extern int sepol_ibendport_clone(sepol_handle_t *handle, + const sepol_ibendport_t *ibendport, + sepol_ibendport_t **ibendport_ptr); + +extern void sepol_ibendport_free(sepol_ibendport_t *ibendport); + +__END_DECLS +#endif diff --git a/libsepol/include/sepol/ibendports.h b/libsepol/include/sepol/ibendports.h new file mode 100644 index 0000000..4a89e0c --- /dev/null +++ b/libsepol/include/sepol/ibendports.h @@ -0,0 +1,45 @@ +#ifndef _SEPOL_IBENDPORTS_H_ +#define _SEPOL_IBENDPORTS_H_ + +#include +#include +#include +#include + +__BEGIN_DECLS + +/* Return the number of ibendports */ +extern int sepol_ibendport_count(sepol_handle_t *handle, + const sepol_policydb_t *p, + unsigned int *response); + +/* Check if a ibendport exists */ +extern int sepol_ibendport_exists(sepol_handle_t *handle, + const sepol_policydb_t *policydb, + const sepol_ibendport_key_t *key, int *response); + +/* Query a ibendport - returns the ibendport, or NULL if not found */ +extern int sepol_ibendport_query(sepol_handle_t *handle, + const sepol_policydb_t *policydb, + const sepol_ibendport_key_t *key, + sepol_ibendport_t **response); + +/* Modify a ibendport, or add it, if the key is not found */ +extern int sepol_ibendport_modify(sepol_handle_t *handle, + sepol_policydb_t *policydb, + const sepol_ibendport_key_t *key, + const sepol_ibendport_t *data); + +/* Iterate the ibendports + * The handler may return: + * -1 to signal an error condition, + * 1 to signal successful exit + * 0 to signal continue + */ +extern int sepol_ibendport_iterate(sepol_handle_t *handle, + const sepol_policydb_t *policydb, + int (*fn)(const sepol_ibendport_t *ibendport, + void *fn_arg), void *arg); + +__END_DECLS +#endif diff --git a/libsepol/include/sepol/sepol.h b/libsepol/include/sepol/sepol.h index 540f01d..540609a 100644 --- a/libsepol/include/sepol/sepol.h +++ b/libsepol/include/sepol/sepol.h @@ -12,6 +12,7 @@ extern "C" { #include #include #include +#include #include #include #include @@ -19,6 +20,7 @@ extern "C" { #include #include #include +#include #include #include #include diff --git a/libsepol/src/ibendport_internal.h b/libsepol/src/ibendport_internal.h new file mode 100644 index 0000000..ed8f9b4 --- /dev/null +++ b/libsepol/src/ibendport_internal.h @@ -0,0 +1,18 @@ +#ifndef _SEPOL_IBENDPORT_INTERNAL_H_ +#define _SEPOL_IBENDPORT_INTERNAL_H_ + +#include +#include +#include "dso.h" + +hidden_proto(sepol_ibendport_create) +hidden_proto(sepol_ibendport_free) +hidden_proto(sepol_ibendport_get_con) +hidden_proto(sepol_ibendport_get_port) +hidden_proto(sepol_ibendport_key_create) +hidden_proto(sepol_ibendport_key_unpack) +hidden_proto(sepol_ibendport_set_con) +hidden_proto(sepol_ibendport_set_port) +hidden_proto(sepol_ibendport_get_ibdev_name) +hidden_proto(sepol_ibendport_set_ibdev_name) +#endif diff --git a/libsepol/src/ibendport_record.c b/libsepol/src/ibendport_record.c new file mode 100644 index 0000000..912aeb5 --- /dev/null +++ b/libsepol/src/ibendport_record.c @@ -0,0 +1,298 @@ +#include +#include +#include +#include +#include + +#include "sepol/policydb/policydb.h" +#include "ibendport_internal.h" +#include "context_internal.h" +#include "debug.h" + +struct sepol_ibendport { + /* Device Name */ + char *ibdev_name; + + /* Port number */ + int port; + + /* Context */ + sepol_context_t *con; +}; + +struct sepol_ibendport_key { + /* Device Name */ + char *ibdev_name; + + /* Port number */ + int port; +}; + +/* Allocates a sufficiently large string (ibdev_name) */ +int sepol_ibendport_alloc_ibdev_name(sepol_handle_t *handle, + char **ibdev_name) +{ + char *tmp_ibdev_name = NULL; + + tmp_ibdev_name = calloc(1, IB_DEVICE_NAME_MAX); + + if (!tmp_ibdev_name) + goto omem; + + *ibdev_name = tmp_ibdev_name; + return STATUS_SUCCESS; + +omem: + ERR(handle, "out of memory"); + ERR(handle, "could not allocate string buffer for ibdev_name"); + return STATUS_ERR; +} + +/* Key */ +int sepol_ibendport_key_create(sepol_handle_t *handle, + const char *ibdev_name, + int port, + sepol_ibendport_key_t **key_ptr) +{ + sepol_ibendport_key_t *tmp_key = + (sepol_ibendport_key_t *)malloc(sizeof(sepol_ibendport_key_t)); + + if (!tmp_key) { + ERR(handle, "out of memory, could not create ibendport key"); + goto omem; + } + + if (sepol_ibendport_alloc_ibdev_name(handle, &tmp_key->ibdev_name) < 0) + goto err; + + strncpy(tmp_key->ibdev_name, ibdev_name, IB_DEVICE_NAME_MAX); + tmp_key->port = port; + + *key_ptr = tmp_key; + return STATUS_SUCCESS; + +omem: + ERR(handle, "out of memory"); + +err: + sepol_ibendport_key_free(tmp_key); + ERR(handle, "could not create ibendport key for IB device %s, port %u", + ibdev_name, port); + return STATUS_ERR; +} + +hidden_def(sepol_ibendport_key_create) + +void sepol_ibendport_key_unpack(const sepol_ibendport_key_t *key, + const char **ibdev_name, int *port) +{ + *ibdev_name = key->ibdev_name; + *port = key->port; +} + +hidden_def(sepol_ibendport_key_unpack) + +int sepol_ibendport_key_extract(sepol_handle_t *handle, + const sepol_ibendport_t *ibendport, + sepol_ibendport_key_t **key_ptr) +{ + if (sepol_ibendport_key_create + (handle, ibendport->ibdev_name, ibendport->port, key_ptr) < 0) { + ERR(handle, "could not extract key from ibendport device %s port %d", + ibendport->ibdev_name, + ibendport->port); + + return STATUS_ERR; + } + + return STATUS_SUCCESS; +} + +void sepol_ibendport_key_free(sepol_ibendport_key_t *key) +{ + if (!key) + return; + free(key->ibdev_name); + free(key); +} + +int sepol_ibendport_compare(const sepol_ibendport_t *ibendport, const sepol_ibendport_key_t *key) +{ + int rc; + + rc = strcmp(ibendport->ibdev_name, key->ibdev_name); + + if ((ibendport->port == key->port) && !rc) + return 0; + + if (ibendport->port < key->port) + return -1; + else if (key->port < ibendport->port) + return 1; + else + return rc; +} + +int sepol_ibendport_compare2(const sepol_ibendport_t *ibendport, const sepol_ibendport_t *ibendport2) +{ + int rc; + + rc = strcmp(ibendport->ibdev_name, ibendport2->ibdev_name); + + if ((ibendport->port == ibendport2->port) && !rc) + return 0; + + if (ibendport->port < ibendport2->port) + return -1; + else if (ibendport2->port < ibendport->port) + return 1; + else + return rc; +} + +int sepol_ibendport_get_port(const sepol_ibendport_t *ibendport) +{ + return ibendport->port; +} + +hidden_def(sepol_ibendport_get_port) + +void sepol_ibendport_set_port(sepol_ibendport_t *ibendport, int port) +{ + ibendport->port = port; +} + +hidden_def(sepol_ibendport_set_port) + +int sepol_ibendport_get_ibdev_name(sepol_handle_t *handle, + const sepol_ibendport_t *ibendport, + char **ibdev_name) +{ + char *tmp_ibdev_name = NULL; + + if (sepol_ibendport_alloc_ibdev_name(handle, &tmp_ibdev_name) < 0) + goto err; + + strncpy(tmp_ibdev_name, ibendport->ibdev_name, IB_DEVICE_NAME_MAX); + *ibdev_name = tmp_ibdev_name; + return STATUS_SUCCESS; + +err: + free(tmp_ibdev_name); + ERR(handle, "could not get ibendport ibdev_name"); + return STATUS_ERR; +} + +hidden_def(sepol_ibendport_get_ibdev_name) + +int sepol_ibendport_set_ibdev_name(sepol_handle_t *handle, + sepol_ibendport_t *ibendport, + const char *ibdev_name) +{ + char *tmp = NULL; + + if (sepol_ibendport_alloc_ibdev_name(handle, &tmp) < 0) + goto err; + + strncpy(tmp, ibdev_name, IB_DEVICE_NAME_MAX); + free(ibendport->ibdev_name); + ibendport->ibdev_name = tmp; + return STATUS_SUCCESS; + +err: + free(tmp); + ERR(handle, "could not set ibendport subnet prefix to %s", ibdev_name); + return STATUS_ERR; +} + +hidden_def(sepol_ibendport_set_ibdev_name) + +/* Create */ +int sepol_ibendport_create(sepol_handle_t *handle, sepol_ibendport_t **ibendport) +{ + sepol_ibendport_t *tmp_ibendport = (sepol_ibendport_t *)malloc(sizeof(sepol_ibendport_t)); + + if (!tmp_ibendport) { + ERR(handle, "out of memory, could not create ibendport record"); + return STATUS_ERR; + } + + tmp_ibendport->ibdev_name = NULL; + tmp_ibendport->port = 0; + tmp_ibendport->con = NULL; + *ibendport = tmp_ibendport; + + return STATUS_SUCCESS; +} + +hidden_def(sepol_ibendport_create) + +/* Deep copy clone */ +int sepol_ibendport_clone(sepol_handle_t *handle, + const sepol_ibendport_t *ibendport, + sepol_ibendport_t **ibendport_ptr) +{ + sepol_ibendport_t *new_ibendport = NULL; + + if (sepol_ibendport_create(handle, &new_ibendport) < 0) + goto err; + + if (sepol_ibendport_alloc_ibdev_name(handle, &new_ibendport->ibdev_name) < 0) + goto omem; + + strncpy(new_ibendport->ibdev_name, ibendport->ibdev_name, IB_DEVICE_NAME_MAX); + new_ibendport->port = ibendport->port; + + if (ibendport->con && + (sepol_context_clone(handle, ibendport->con, &new_ibendport->con) < 0)) + goto err; + + *ibendport_ptr = new_ibendport; + return STATUS_SUCCESS; + +omem: + ERR(handle, "out of memory"); + +err: + ERR(handle, "could not clone ibendport record"); + sepol_ibendport_free(new_ibendport); + return STATUS_ERR; +} + +/* Destroy */ +void sepol_ibendport_free(sepol_ibendport_t *ibendport) +{ + if (!ibendport) + return; + + free(ibendport->ibdev_name); + sepol_context_free(ibendport->con); + free(ibendport); +} + +hidden_def(sepol_ibendport_free) + +/* Context */ +sepol_context_t *sepol_ibendport_get_con(const sepol_ibendport_t *ibendport) +{ + return ibendport->con; +} + +hidden_def(sepol_ibendport_get_con) + +int sepol_ibendport_set_con(sepol_handle_t *handle, + sepol_ibendport_t *ibendport, sepol_context_t *con) +{ + sepol_context_t *newcon; + + if (sepol_context_clone(handle, con, &newcon) < 0) { + ERR(handle, "out of memory, could not set ibendport context"); + return STATUS_ERR; + } + + sepol_context_free(ibendport->con); + ibendport->con = newcon; + return STATUS_SUCCESS; +} + +hidden_def(sepol_ibendport_set_con) diff --git a/libsepol/src/ibendports.c b/libsepol/src/ibendports.c new file mode 100644 index 0000000..0438093 --- /dev/null +++ b/libsepol/src/ibendports.c @@ -0,0 +1,255 @@ +#include +#include + +#include "debug.h" +#include "context.h" +#include "handle.h" + +#include +#include "ibendport_internal.h" + +/* Create a low level ibendport structure from + * a high level representation + */ +static int ibendport_from_record(sepol_handle_t *handle, + const policydb_t *policydb, + ocontext_t **ibendport, + const sepol_ibendport_t *data) +{ + ocontext_t *tmp_ibendport = NULL; + context_struct_t *tmp_con = NULL; + char *ibdev_name = NULL; + int port = sepol_ibendport_get_port(data); + + tmp_ibendport = (ocontext_t *)calloc(1, sizeof(ocontext_t)); + if (!tmp_ibendport) + goto omem; + + if (sepol_ibendport_alloc_ibdev_name(handle, + &tmp_ibendport->u.ibendport.dev_name) < 0) + goto omem; + + if (sepol_ibendport_get_ibdev_name(handle, + data, + &ibdev_name) < 0) + goto err; + + strncpy(tmp_ibendport->u.ibendport.dev_name, ibdev_name, IB_DEVICE_NAME_MAX); + + free(ibdev_name); + ibdev_name = NULL; + + tmp_ibendport->u.ibendport.port = port; + + /* Context */ + if (context_from_record(handle, policydb, &tmp_con, + sepol_ibendport_get_con(data)) < 0) + goto err; + context_cpy(&tmp_ibendport->context[0], tmp_con); + context_destroy(tmp_con); + free(tmp_con); + tmp_con = NULL; + + *ibendport = tmp_ibendport; + return STATUS_SUCCESS; + +omem: + ERR(handle, "out of memory"); + +err: + if (tmp_ibendport) { + context_destroy(&tmp_ibendport->context[0]); + free(tmp_ibendport); + } + context_destroy(tmp_con); + free(tmp_con); + free(ibdev_name); + ERR(handle, "could not create ibendport structure"); + return STATUS_ERR; +} + +static int ibendport_to_record(sepol_handle_t *handle, + const policydb_t *policydb, + ocontext_t *ibendport, + sepol_ibendport_t **record) +{ + int port = ibendport->u.ibendport.port; + context_struct_t *con = &ibendport->context[0]; + + sepol_context_t *tmp_con = NULL; + sepol_ibendport_t *tmp_record = NULL; + + if (sepol_ibendport_create(handle, &tmp_record) < 0) + goto err; + + if (sepol_ibendport_set_ibdev_name(handle, tmp_record, + ibendport->u.ibendport.dev_name) < 0) + goto err; + + sepol_ibendport_set_port(tmp_record, port); + + if (context_to_record(handle, policydb, con, &tmp_con) < 0) + goto err; + + if (sepol_ibendport_set_con(handle, tmp_record, tmp_con) < 0) + goto err; + + sepol_context_free(tmp_con); + *record = tmp_record; + return STATUS_SUCCESS; + +err: + ERR(handle, "could not convert ibendport to record"); + sepol_context_free(tmp_con); + sepol_ibendport_free(tmp_record); + return STATUS_ERR; +} + +/* Return the number of ibendports */ +extern int sepol_ibendport_count(sepol_handle_t *handle __attribute__ ((unused)), + const sepol_policydb_t *p, unsigned int *response) +{ + unsigned int count = 0; + ocontext_t *c, *head; + const policydb_t *policydb = &p->p; + + head = policydb->ocontexts[OCON_IBENDPORT]; + for (c = head; c; c = c->next) + count++; + + *response = count; + + handle = NULL; + return STATUS_SUCCESS; +} + +/* Check if a ibendport exists */ +int sepol_ibendport_exists(sepol_handle_t *handle __attribute__ ((unused)), + const sepol_policydb_t *p, + const sepol_ibendport_key_t *key, int *response) +{ + const policydb_t *policydb = &p->p; + ocontext_t *c, *head; + int port; + const char *ibdev_name; + + sepol_ibendport_key_unpack(key, &ibdev_name, &port); + + head = policydb->ocontexts[OCON_IBENDPORT]; + for (c = head; c; c = c->next) { + const char *ibdev_name2 = c->u.ibendport.dev_name; + int port2 = c->u.ibendport.port; + + if (port2 == port && + (!strcmp(ibdev_name, ibdev_name2))) { + *response = 1; + return STATUS_SUCCESS; + } + } + + *response = 0; + return STATUS_SUCCESS; +} + +int sepol_ibendport_query(sepol_handle_t *handle, + const sepol_policydb_t *p, + const sepol_ibendport_key_t *key, + sepol_ibendport_t **response) +{ + const policydb_t *policydb = &p->p; + ocontext_t *c, *head; + int port; + const char *ibdev_name; + + sepol_ibendport_key_unpack(key, &ibdev_name, &port); + + head = policydb->ocontexts[OCON_IBENDPORT]; + for (c = head; c; c = c->next) { + const char *ibdev_name2 = c->u.ibendport.dev_name; + int port2 = c->u.ibendport.port; + + if (port2 == port && + (!strcmp(ibdev_name, ibdev_name2))) { + if (ibendport_to_record(handle, policydb, c, response) < 0) + goto err; + return STATUS_SUCCESS; + } + } + + *response = NULL; + return STATUS_SUCCESS; + +err: + ERR(handle, "could not query ibendport, IB device: %s port %u", + ibdev_name, port); + return STATUS_ERR; +} + +/* Load a ibendport into policy */ +int sepol_ibendport_modify(sepol_handle_t *handle, + sepol_policydb_t *p, + const sepol_ibendport_key_t *key, + const sepol_ibendport_t *data) +{ + policydb_t *policydb = &p->p; + ocontext_t *ibendport = NULL; + int port; + const char *ibdev_name; + + sepol_ibendport_key_unpack(key, &ibdev_name, &port); + + if (ibendport_from_record(handle, policydb, &ibendport, data) < 0) + goto err; + + /* Attach to context list */ + ibendport->next = policydb->ocontexts[OCON_IBENDPORT]; + policydb->ocontexts[OCON_IBENDPORT] = ibendport; + + return STATUS_SUCCESS; + +err: + ERR(handle, "could not load ibendport %s/%d", + ibdev_name, port); + if (ibendport) { + context_destroy(&ibendport->context[0]); + free(ibendport); + } + return STATUS_ERR; +} + +int sepol_ibendport_iterate(sepol_handle_t *handle, + const sepol_policydb_t *p, + int (*fn)(const sepol_ibendport_t *ibendport, + void *fn_arg), void *arg) +{ + const policydb_t *policydb = &p->p; + ocontext_t *c, *head; + sepol_ibendport_t *ibendport = NULL; + + head = policydb->ocontexts[OCON_IBENDPORT]; + for (c = head; c; c = c->next) { + int status; + + if (ibendport_to_record(handle, policydb, c, &ibendport) < 0) + goto err; + + /* Invoke handler */ + status = fn(ibendport, arg); + if (status < 0) + goto err; + + sepol_ibendport_free(ibendport); + ibendport = NULL; + + /* Handler requested exit */ + if (status > 0) + break; + } + + return STATUS_SUCCESS; + +err: + ERR(handle, "could not iterate over ibendports"); + sepol_ibendport_free(ibendport); + return STATUS_ERR; +} diff --git a/python/semanage/semanage b/python/semanage/semanage index 11b56e2..313537c 100644 --- a/python/semanage/semanage +++ b/python/semanage/semanage @@ -61,6 +61,9 @@ usage_port_dict = {' --add': ('-t TYPE', '-p PROTOCOL', '-r RANGE', '(', 'port_n usage_ibpkey = "semanage ibpkey [-h] [-n] [-N] [-s STORE] [" usage_ibpkey_dict = {' --add': ('-t TYPE', '-x SUBNET_PREFIX', '-r RANGE', '(', 'ibpkey_name', '|', 'pkey_range', ')'), ' --modify': ('-t TYPE', '-x SUBNET_PREFIX', '-r RANGE', '(', 'ibpkey_name', '|', 'pkey_range', ')'), ' --delete': ('-x SUBNET_PREFIX', '(', 'ibpkey_name', '|', 'pkey_range', ')'), ' --list': ('-C',), ' --extract': ('',), ' --deleteall': ('',)} +usage_ibendport = "semanage ibendport [-h] [-n] [-N] [-s STORE] [" +usage_ibendport_dict = {' --add': ('-t TYPE', '-z IBDEV_NAME', '-r RANGE', '(', 'port', ')'), ' --modify': ('-t TYPE', '-z IBDEV_NAME', '-r RANGE', '(', 'port', ')'), ' --delete': ('-z IBDEV_NAME', '-r RANGE''(', 'port', ')'), ' --list': ('-C',), ' --extract': ('',), ' --deleteall': ('',)} + usage_node = "semanage node [-h] [-n] [-N] [-S STORE] [" usage_node_dict = {' --add': ('-M NETMASK', '-p PROTOCOL', '-t TYPE', '-r RANGE', 'node'), ' --modify': ('-M NETMASK', '-p PROTOCOL', '-t TYPE', '-r RANGE', 'node'), ' --delete': ('-M NETMASK', '-p PROTOCOL', 'node'), ' --list': ('-C',), ' --extract': ('',), ' --deleteall': ('',)} @@ -152,6 +155,10 @@ def ibpkey_ini(): OBJECT = seobject.ibpkeyRecords(store) return OBJECT +def ibendport_ini(): + OBJECT = seobject.ibendportRecords(store) + return OBJECT + def module_ini(): OBJECT = seobject.moduleRecords(store) return OBJECT @@ -187,8 +194,7 @@ def dontaudit_ini(): return OBJECT # define dictonary for seobject OBEJCTS -object_dict = {'login': login_ini, 'user': user_ini, 'port': port_ini, 'module': module_ini, 'interface': interface_ini, 'node': node_ini, 'fcontext': fcontext_ini, 'boolean': boolean_ini, 'permissive': permissive_ini, 'dontaudit': dontaudit_ini, 'ibpkey': ibpkey_ini} - +object_dict = {'login': login_ini, 'user': user_ini, 'port': port_ini, 'module': module_ini, 'interface': interface_ini, 'node': node_ini, 'fcontext': fcontext_ini, 'boolean': boolean_ini, 'permissive': permissive_ini, 'dontaudit': dontaudit_ini, 'ibpkey': ibpkey_ini, 'ibendport': ibendport_ini} def generate_custom_usage(usage_text, usage_dict): # generate custom usage from given text and dictonary @@ -303,6 +309,10 @@ def parser_add_subnet_prefix(parser, name): Subnet prefix for the specified infiniband ibpkey. ''')) +def parser_add_ibdev_name(parser, name): + parser.add_argument('-z', '--ibdev_name', help=_(''' + Name for the specified infiniband end port. +''')) def parser_add_modify(parser, name): parser.add_argument('-m', '--modify', dest='action', action='store_const', const='modify', help=_("Modify a record of the %s object type") % name) @@ -567,6 +577,49 @@ def setupPkeyParser(subparsers): ibpkeyParser.add_argument('ibpkey', nargs='?', default=None, help=_('pkey | pkey_range')) ibpkeyParser.set_defaults(func=handlePkey) +def handleIbendport(args): + ibendport_args = {'list': [('ibendport', 'type', 'ibdev_name'), ('')], 'add': [('locallist'), ('type', 'ibendport', 'ibdev_name'), ('')], 'modify': [('localist'), ('ibendport', 'ibdev_name')], 'delete': [('locallist'), ('ibendport', 'ibdev_name')], 'extract': [('locallist', 'ibendport', 'type', 'ibdev_name'), ('')], 'deleteall': [('locallist'), ('')]} + + handle_opts(args, ibendport_args, args.action) + + OBJECT = object_dict['ibendport']() + OBJECT.set_reload(args.noreload) + + if args.action is "add": + OBJECT.add(args.ibendport, args.ibdev_name, args.range, args.type) + if args.action is "modify": + OBJECT.modify(args.ibendport, args.ibdev_name, args.range, args.type) + if args.action is "delete": + OBJECT.delete(args.ibendport, args.ibdev_name) + if args.action is "list": + OBJECT.list(args.noheading, args.locallist) + if args.action is "deleteall": + OBJECT.deleteall() + if args.action is "extract": + for i in OBJECT.customized(): + print("ibendport %s" % str(i)) + + +def setupIbendportParser(subparsers): + generated_usage = generate_custom_usage(usage_ibendport, usage_ibendport_dict) + ibendportParser = subparsers.add_parser('ibendport', usage=generated_usage, help=_('Manage infiniband end port type definitions')) + parser_add_locallist(ibendportParser, "ibendport") + parser_add_noheading(ibendportParser, "ibendport") + parser_add_noreload(ibendportParser, "ibendport") + parser_add_store(ibendportParser, "ibendport") + + ibendport_action = ibendportParser.add_mutually_exclusive_group(required=True) + parser_add_add(ibendport_action, "ibendport") + parser_add_delete(ibendport_action, "ibendport") + parser_add_modify(ibendport_action, "ibendport") + parser_add_list(ibendport_action, "ibendport") + parser_add_extract(ibendport_action, "ibendport") + parser_add_deleteall(ibendport_action, "ibendport") + parser_add_type(ibendportParser, "ibendport") + parser_add_range(ibendportParser, "ibendport") + parser_add_ibdev_name(ibendportParser, "ibendport") + ibendportParser.add_argument('ibendport', nargs='?', default=None, help=_('ibendport')) + ibendportParser.set_defaults(func=handleIbendport) def handleInterface(args): interface_args = {'list': [('interface'), ('')], 'add': [('locallist'), ('type', 'interface')], 'modify': [('locallist'), ('type', 'interface')], 'delete': [('locallist'), ('interface')], 'extract': [('locallist', 'interface', 'type'), ('')], 'deleteall': [('locallist'), ('')]} @@ -907,6 +960,7 @@ def createCommandParser(): setupUserParser(subparsers) setupPortParser(subparsers) setupPkeyParser(subparsers) + setupIbendportParser(subparsers) setupInterfaceParser(subparsers) setupModuleParser(subparsers) setupNodeParser(subparsers) diff --git a/python/semanage/seobject.py b/python/semanage/seobject.py index 41b0aca..037c9ae 100644 --- a/python/semanage/seobject.py +++ b/python/semanage/seobject.py @@ -1565,6 +1565,245 @@ class ibpkeyRecords(semanageRecords): rec += ", %s" % p print rec +class ibendportRecords(semanageRecords): + try: + q = setools.TypeQuery(setools.SELinuxPolicy(sepolicy.get_installed_policy()), attrs=["ibendport_type"]) + valid_types = sorted(str(t) for t in q.results()) + except RuntimeError: + valid_types = [] + + def __init__(self, store=""): + semanageRecords.__init__(self, store) + + def __genkey(self, ibendport, ibdev_name): + if ibdev_name == "": + raise ValueError(_("IB device name is required")) + + port = int(ibendport) + + if port > 255 or port < 1: + raise ValueError(_("Invalid Port Number")) + + (rc, k) = semanage_ibendport_key_create(self.sh, ibdev_name, port) + if rc < 0: + raise ValueError(_("Could not create a key for ibendport %s/%s") % (ibdev_name, ibendport)) + return (k, ibdev_name, port) + + def __add(self, ibendport, ibdev_name, serange, type): + if is_mls_enabled == 1: + if serange == "": + serange = "s0" + else: + serange = untranslate(serange) + + if type == "": + raise ValueError(_("Type is required")) + + if type not in self.valid_types: + raise ValueError(_("Type %s is invalid, must be an ibendport type") % type) + (k, ibendport, port) = self.__genkey(ibendport, ibdev_name) + + (rc, exists) = semanage_ibendport_exists(self.sh, k) + if rc < 0: + raise ValueError(_("Could not check if ibendport %s/%s is defined") % (ibdev_name, port)) + if exists: + raise ValueError(_("ibendport %s/%s already defined") % (ibdev_name, port)) + + (rc, p) = semanage_ibendport_create(self.sh) + if rc < 0: + raise ValueError(_("Could not create ibendport for %s/%s") % (ibdev_name, port)) + + semanage_ibendport_set_ibdev_name(self.sh, p, ibdev_name) + semanage_ibendport_set_port(p, port) + (rc, con) = semanage_context_create(self.sh) + if rc < 0: + raise ValueError(_("Could not create context for %s/%s") % (ibdev_name, port)) + + rc = semanage_context_set_user(self.sh, con, "system_u") + if rc < 0: + raise ValueError(_("Could not set user in ibendport context for %s/%s") % (ibdev_name, port)) + + rc = semanage_context_set_role(self.sh, con, "object_r") + if rc < 0: + raise ValueError(_("Could not set role in ibendport context for %s/%s") % (ibdev_name, port)) + + rc = semanage_context_set_type(self.sh, con, type) + if rc < 0: + raise ValueError(_("Could not set type in ibendport context for %s/%s") % (ibdev_name, port)) + + if (is_mls_enabled == 1) and (serange != ""): + rc = semanage_context_set_mls(self.sh, con, serange) + if rc < 0: + raise ValueError(_("Could not set mls fields in ibendport context for %s/%s") % (ibdev_name, port)) + + rc = semanage_ibendport_set_con(self.sh, p, con) + if rc < 0: + raise ValueError(_("Could not set ibendport context for %s/%s") % (ibdev_name, port)) + + rc = semanage_ibendport_modify_local(self.sh, k, p) + if rc < 0: + raise ValueError(_("Could not add ibendport %s/%s") % (ibdev_name, port)) + + semanage_context_free(con) + semanage_ibendport_key_free(k) + semanage_ibendport_free(p) + + def add(self, ibendport, ibdev_name, serange, type): + self.begin() + self.__add(ibendport, ibdev_name, serange, type) + self.commit() + + def __modify(self, ibendport, ibdev_name, serange, setype): + if serange == "" and setype == "": + if is_mls_enabled == 1: + raise ValueError(_("Requires setype or serange")) + else: + raise ValueError(_("Requires setype")) + + if setype and setype not in self.valid_types: + raise ValueError(_("Type %s is invalid, must be an ibendport type") % setype) + + (k, ibdev_name, port) = self.__genkey(ibendport, ibdev_name) + + (rc, exists) = semanage_ibendport_exists(self.sh, k) + if rc < 0: + raise ValueError(_("Could not check if ibendport %s/%s is defined") % (ibdev_name, ibendport)) + if not exists: + raise ValueError(_("ibendport %s/%s is not defined") % (ibdev_name, ibendport)) + + (rc, p) = semanage_ibendport_query(self.sh, k) + if rc < 0: + raise ValueError(_("Could not query ibendport %s/%s") % (ibdev_name, ibendport)) + + con = semanage_ibendport_get_con(p) + + if (is_mls_enabled == 1) and (serange != ""): + semanage_context_set_mls(self.sh, con, untranslate(serange)) + if setype != "": + semanage_context_set_type(self.sh, con, setype) + + rc = semanage_ibendport_modify_local(self.sh, k, p) + if rc < 0: + raise ValueError(_("Could not modify ibendport %s/%s") % (ibdev_name, ibendport)) + + semanage_ibendport_key_free(k) + semanage_ibendport_free(p) + + def modify(self, ibendport, ibdev_name, serange, setype): + self.begin() + self.__modify(ibendport, ibdev_name, serange, setype) + self.commit() + + def deleteall(self): + (rc, plist) = semanage_ibendport_list_local(self.sh) + if rc < 0: + raise ValueError(_("Could not list the ibendports")) + + self.begin() + + for ibendport in plist: + (rc, ibdev_name) = semanage_ibendport_get_ibdev_name(self.sh, ibendport) + port = semanage_ibendport_get_port(ibendport) + (k, ibdev_name, port) = self.__genkey(str(port), ibdev_name) + if rc < 0: + raise ValueError(_("Could not create a key for %s/%d") % (ibdevname, port)) + + rc = semanage_ibendport_del_local(self.sh, k) + if rc < 0: + raise ValueError(_("Could not delete the ibendport %s/%d") % (ibdev_name, port)) + semanage_ibendport_key_free(k) + + self.commit() + + def __delete(self, ibendport, ibdev_name): + (k, ibdev_name, port) = self.__genkey(ibendport, ibdev_name) + (rc, exists) = semanage_ibendport_exists(self.sh, k) + if rc < 0: + raise ValueError(_("Could not check if ibendport %s/%s is defined") % (ibdev_name, ibendport)) + if not exists: + raise ValueError(_("ibendport %s/%s is not defined") % (ibdev_name, ibendport)) + + (rc, exists) = semanage_ibendport_exists_local(self.sh, k) + if rc < 0: + raise ValueError(_("Could not check if ibendport %s/%s is defined") % (ibdev_name, ibendport)) + if not exists: + raise ValueError(_("ibendport %s/%s is defined in policy, cannot be deleted") % (ibdev_name, ibendport)) + + rc = semanage_ibendport_del_local(self.sh, k) + if rc < 0: + raise ValueError(_("Could not delete ibendport %s/%s") % (ibdev_name, ibendport)) + + semanage_ibendport_key_free(k) + + def delete(self, ibendport, ibdev_name): + self.begin() + self.__delete(ibendport, ibdev_name) + self.commit() + + def get_all(self, locallist=0): + ddict = {} + if locallist: + (rc, self.plist) = semanage_ibendport_list_local(self.sh) + else: + (rc, self.plist) = semanage_ibendport_list(self.sh) + if rc < 0: + raise ValueError(_("Could not list ibendports")) + + for ibendport in self.plist: + con = semanage_ibendport_get_con(ibendport) + ctype = semanage_context_get_type(con) + if ctype == "reserved_ibendport_t": + continue + level = semanage_context_get_mls(con) + (rc, ibdev_name) = semanage_ibendport_get_ibdev_name(self.sh, ibendport) + port = semanage_ibendport_get_port(ibendport) + ddict[(port, ibdev_name)] = (ctype, level) + return ddict + + def get_all_by_type(self, locallist=0): + ddict = {} + if locallist: + (rc, self.plist) = semanage_ibendport_list_local(self.sh) + else: + (rc, self.plist) = semanage_ibendport_list(self.sh) + if rc < 0: + raise ValueError(_("Could not list ibendports")) + + for ibendport in self.plist: + con = semanage_ibendport_get_con(ibendport) + ctype = semanage_context_get_type(con) + (rc, ibdev_name) = semanage_ibendport_get_ibdev_name(self.sh, ibendport) + port = semanage_ibendport_get_port(ibendport) + if (ctype, ibdev_name) not in ddict.keys(): + ddict[(ctype, ibdev_name)] = [] + ddict[(ctype, ibdev_name)].append("0x%x" % port) + return ddict + + def customized(self): + l = [] + ddict = self.get_all(True) + keys = ddict.keys() + keys.sort() + for k in keys: + l.append("-a -t %s -x %s %s" % (ddict[k][0], k[2], k[0])) + return l + + def list(self, heading=1, locallist=0): + ddict = self.get_all_by_type(locallist) + keys = ddict.keys() + if len(keys) == 0: + return + keys.sort() + + if heading: + print "%-30s %-18s %s\n" % (_("SELinux IB End Port Type"), _("IB Device Name"), _("Port Number")) + for i in keys: + rec = "%-30s %-18s " % i + rec += "%s" % ddict[i][0] + for p in ddict[i][1:]: + rec += ", %s" % p + print rec + class nodeRecords(semanageRecords): try: valid_types = list(list(sepolicy.info(sepolicy.ATTRIBUTE, "node_type"))[0]["types"])