Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 515893E9F96 for ; Tue, 2 Jun 2026 14:48:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411721; cv=none; b=lLz8Cxl2fsSEf4Yx64fCWB5dTdp5hdlAmPgB3AZ1hS+757kGWCNeu/6NvCteH8zPxM7LtYZ5B5FPwjQJHfDMp+MHo2V45YuWeTS0V3Li4RYY6BpxR2RWtDKPrxwDNbcMexMZhDQKXyi5TnvQaJem05HSTWvXKCOuYOAWzKE1enw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411721; c=relaxed/simple; bh=23tio2kDiT6TzawtjXWIYMYKD3Nc/ta1ZwP8qNyeDOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t74F+blHsfgYYAd592PLZ1ED1Y0nTkpKxZIVPszmzniUc4Gff2KyiZ1P2mBgn1GgFBkQvgv0WrVT38OhKNUzdcgxtu+fehb6q0LaVUGfHvuBcEULd9xpeRuCZdH2xWB74mDBXs2mJD1LWQ85PDVLNSZEnPdhS5oanm4e9LkOiW4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZwoNnlgi; arc=none smtp.client-ip=209.85.222.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZwoNnlgi" Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-914ae4101b4so1448773185a.2 for ; Tue, 02 Jun 2026 07:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780411716; x=1781016516; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=utgfDgxYX4ggGpf7AbipM3Ry4gTJokW2mnJSBTkJdWM=; b=ZwoNnlgigQt6rBMaMWo7hZRLW0jtVE+NSb5auBQzjfH73PsJBb9zaOzuFi+uc2P6fT xjaiR/BG0j3kzCeZO2lfJTSsoy/AYxvj5RwT7Fcde8Jf4vvePEMREHwCPrRlCXk2cH9f TGrLkJT0euKfXSswrgcIeLpLeQl7CEiHFhulUgm3YnAGDBl+WZfDsjb9+T4JlXmuuA/m HCuLIFQAVjgyiS6+/Mmotho5o8OiV0VwaetO4OfrehUFhs/Q4EMi50gacd+VC5uc2Lag vWAaZJlJxUs95wYENgZQ9A/y4+WzJSgXNH8oH2Ng8R1QsJYEkmWyn45IhUdH8QRyeXIm GDqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780411716; x=1781016516; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=utgfDgxYX4ggGpf7AbipM3Ry4gTJokW2mnJSBTkJdWM=; b=HNK/C4BGgr1oRLogLC6ANFzuux/V6T5GHryhI46DgRdzSfHJ62XiqYMWcQIyD5WUl2 BcOXFjsLa1BHaW+XlSxsyYzI7y+dNqXUXtCrOEpsPI0F1YoS2P1YzBbH+GEVEGj6dbRV +cnbiMWOo2SCwaOjGfve4K+ir3yhTlfQ0I11rrAjOK6oTnU96gR+s88G4GWOYIz4FJgT 9urierTbk0XViRofiiLjVbDmH0DmF0zPV3MHKXGNE0Vu/VH2o+wbC9N4OP2AkUGn5lAX z3/PxkQTrHNsquByzYRO0O6VPQurirrvA9tO0eLTaPwwBGY1fcOyh5lAbZBcrZvjFr0J nHXA== X-Gm-Message-State: AOJu0Ywrv3r0QCH6VI7YpSdqjEOiagwsiVbCe1gIGJOEz0KLzRstFEbk 4MMnRzGWRN8cA97rXWzpEk8urnwZuqXOH8J27/obMfjRnhyaS57Z9PAqQdEMog== X-Gm-Gg: Acq92OEtRPdy7zWSY1gG/ECtywmj3NwSkIlX+uP7dqyAuQTE6sbits5pe1SbxVTefHe eZHQ/xGl9WwMyh3ObQVjJdRIO4Qe1uAQ2snAbh+fO/DXLx2+fi8Qe9dVLPnEdVCtHyXwqJBlkh2 LFugs8QtU0mxdIep4UDe6H6EZcJ2DFD6hen33J2LJpdFzY4doAu+Xvy3PM8MdJTL7M8heg+osiX iXot6B+zRjaov3iHrtM9Qv1eSxHh6EWq0tepNEUTqIlBWfyJLJ94jvob5w3AGmrUZIUi/p0l76B Oo8GLdT6AbaYMqMkq2z8gm45mqIkAH8jJt1jYrcl/8ehHB4JVyfRDJrUFeYW3JSyzhtQ78NYCUu R30FitGLGlgOb/e9cwecs2WFEdLNu9MHB6nKPj/sW+QrYtzglmJyfSPL1VEQYhd52Vh+t2eX9CV bDeojW3WlHUf4SuofBi+JP8bpPJ914CKHUWCRDyI9qSso/NCxn/Kxyq/BR X-Received: by 2002:a05:620a:284a:b0:915:673a:6175 with SMTP id af79cd13be357-915673a62bemr1080944385a.23.1780411715879; Tue, 02 Jun 2026 07:48:35 -0700 (PDT) Received: from Fedora43-SELinux ([144.51.8.27]) by smtp.gmail.com with ESMTPSA id af79cd13be357-9153244de53sm1344015285a.8.2026.06.02.07.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jun 2026 07:48:35 -0700 (PDT) From: James Carter To: selinux@vger.kernel.org Cc: tweek@google.com, stephen.smalley.work@gmail.com, James Carter Subject: [PATCH 2/3 v3] libsepol: Add a function to output CIL declarations from a binary policy Date: Tue, 2 Jun 2026 10:48:19 -0400 Message-ID: <20260602144820.147382-2-jwcart2@gmail.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260602144820.147382-1-jwcart2@gmail.com> References: <20260602144820.147382-1-jwcart2@gmail.com> Precedence: bulk X-Mailing-List: selinux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the function sepol_kernel_policydb_decls_to_cil() that takes a binary policy as input and outputs the declarations in CIL format. Also move the checks for a supported policy to a new common function and use that function in kernel_to_conf and kernel_to_cil. In the near-term this will be used get the declarations from a policydb so they can be used along with neverallows written in CIL to check for neverallow and neverallowx violations in the binary policy. Suggested-by: ThiƩbaud Weksteen Signed-off-by: James Carter --- v3: Split out less common functionality to keep the same order for the rules to prevent breaking existing tests (even though CIL is not dependent on order.) v2: Added more explanation to the commit msg Split out common functionality libselinux/src/selinuxswig_python_exception.i | 1224 ---------- .../src/semanageswig_python_exception.i | 2128 ----------------- libsepol/include/sepol/kernel_to_cil.h | 3 +- libsepol/src/kernel_to_cil.c | 97 +- libsepol/src/kernel_to_common.c | 26 + libsepol/src/kernel_to_common.h | 2 + libsepol/src/kernel_to_conf.c | 29 +- libsepol/src/libsepol.map.in | 1 + 8 files changed, 109 insertions(+), 3401 deletions(-) delete mode 100644 libselinux/src/selinuxswig_python_exception.i delete mode 100644 libsemanage/src/semanageswig_python_exception.i diff --git a/libselinux/src/selinuxswig_python_exception.i b/libselinux/src/selinuxswig_python_exception.i deleted file mode 100644 index e5e55a79..00000000 --- a/libselinux/src/selinuxswig_python_exception.i +++ /dev/null @@ -1,1224 +0,0 @@ - -%exception is_selinux_enabled { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception is_selinux_mls_enabled { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getcon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getcon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setcon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setcon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getpidcon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getpidcon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getprevcon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getprevcon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getpidprevcon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getpidprevcon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getexeccon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getexeccon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setexeccon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setexeccon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getfscreatecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getfscreatecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setfscreatecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setfscreatecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getkeycreatecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getkeycreatecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setkeycreatecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setkeycreatecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getsockcreatecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getsockcreatecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setsockcreatecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setsockcreatecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getfilecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getfilecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception lgetfilecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception lgetfilecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception fgetfilecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception fgetfilecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setfilecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setfilecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception lsetfilecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception lsetfilecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception fsetfilecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception fsetfilecon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getpeercon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getpeercon_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_av { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_av_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_av_flags { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_av_flags_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_create_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_create_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_create_name_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_relabel { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_relabel_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_member { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_member_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_user { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_compute_user_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_validatetrans { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_validatetrans_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_load_policy { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_get_initial_context { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_get_initial_context_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_mkload_policy { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_init_load_policy { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_set_boolean_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_load_booleans { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_check_context { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_check_context_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_canonicalize_context { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_canonicalize_context_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_getenforce { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_setenforce { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_reject_unknown { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_deny_unknown { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_get_checkreqprot { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_disable { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_policyvers { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_get_boolean_names { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_get_boolean_pending { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_get_boolean_active { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_set_boolean { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_commit_booleans { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_set_mapping { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception security_av_string { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception matchpathcon_init { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception matchpathcon_init_prefix { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception realpath_not_final { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception matchpathcon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception matchpathcon_index { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception matchpathcon_filespec_add { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception matchmediacon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_getenforcemode { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_getpolicytype { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_set_policy_root { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_check_access { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_check_passwd_access { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception checkPasswdAccess { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_check_securetty_context { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinuxfs_exists { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception setexecfilecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception rpm_execcon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception is_context_customizable { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_trans_to_raw_context { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_raw_to_trans_context { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_raw_context_to_color { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getseuserbyname { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception getseuser { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_file_context_verify { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_lsetfilecon_default { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_sid_to_context { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_sid_to_context_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_context_to_sid { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_context_to_sid_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception sidget { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception sidput { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_get_initial_sid { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_init { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_open { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_reset { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_has_perm_noaudit { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_has_perm { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_compute_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_compute_member { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_add_callback { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_netlink_open { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_netlink_acquire_fd { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception avc_netlink_check_nb { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_status_open { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_status_updated { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_status_getenforce { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_status_policyload { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_status_deny_unknown { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception context_type_set { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception context_range_set { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception context_role_set { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception context_user_set { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception get_ordered_context_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception get_ordered_context_list_with_level { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception get_default_context { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception get_default_context_with_level { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception get_default_context_with_role { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception get_default_context_with_rolelevel { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception query_user_context { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception manual_user_enter_context { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception get_default_type { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selabel_lookup { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selabel_lookup_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selabel_lookup_best_match { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selabel_lookup_best_match_raw { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selabel_digest { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_restorecon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_restorecon_parallel { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_restorecon_set_alt_rootpath { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception selinux_restorecon_xattr { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} diff --git a/libsemanage/src/semanageswig_python_exception.i b/libsemanage/src/semanageswig_python_exception.i deleted file mode 100644 index 0df8bbc3..00000000 --- a/libsemanage/src/semanageswig_python_exception.i +++ /dev/null @@ -1,2128 +0,0 @@ - -%exception semanage_reload_policy { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_get_hll_compiler_path { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_get_disable_dontaudit { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_set_default_priority { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_is_managed { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_connect { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_disconnect { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_begin_transaction { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_commit { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_access_check { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_is_connected { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_mls_enabled { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_set_root { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_get_preserve_tunables { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_get_ignore_module_cache { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception select { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception pselect { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_install { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_install_file { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_remove { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_extract { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_info_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_info_destroy { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_info_get_priority { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_info_get_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_info_get_lang_ext { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_info_get_enabled { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_info_set_priority { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_info_set_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_info_set_lang_ext { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_info_set_enabled { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_key_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_key_destroy { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_key_get_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_key_get_priority { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_key_set_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_key_set_priority { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_set_enabled { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_get_module_info { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_list_all { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_install_info { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_remove_key { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_get_enabled { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_module_compute_checksum { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_msg_get_level { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_key_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_key_extract { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_compare { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_compare2 { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_set_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_get_value { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_clone { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_key_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_key_extract { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_compare { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_compare2 { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_set_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_set_prefix { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_set_mlslevel { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_set_mlsrange { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_get_num_roles { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_add_role { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_has_role { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_get_roles { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_set_roles { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_clone { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_key_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_key_extract { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_compare { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_compare2 { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_set_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_set_sename { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_set_mlsrange { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_clone { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_context_set_user { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_context_set_role { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_context_set_type { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_context_set_mls { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_context_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_context_clone { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_context_from_string { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_context_to_string { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_compare { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_compare2 { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_key_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_key_extract { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_set_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_set_ifcon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_set_msgcon { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_clone { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_compare { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_compare2 { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_key_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_key_extract { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_get_proto { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_get_low { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_get_high { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_set_con { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_clone { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_compare { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_compare2 { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_key_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_key_extract { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_get_subnet_prefix { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_set_subnet_prefix { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_get_low { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_get_high { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_set_con { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_clone { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_compare { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_compare2 { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_key_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_key_extract { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_get_ibdev_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_set_ibdev_name { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_get_port { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_set_con { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_clone { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_compare { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_compare2 { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_key_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_key_extract { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_get_addr { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_get_addr_bytes { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_set_addr { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_set_addr_bytes { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_get_mask { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_get_mask_bytes { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_set_mask { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_set_mask_bytes { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_get_proto { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_set_con { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_clone { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_modify_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_del_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_query_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_exists_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_count_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_iterate_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_list_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_query { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_exists { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_count { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_iterate { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_set_active { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_query_active { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_exists_active { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_count_active { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_iterate_active { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_bool_list_active { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_modify_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_del_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_query_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_exists_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_count_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_iterate_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_list_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_query { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_exists { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_count { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_iterate { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_user_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_compare { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_compare2 { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_key_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_key_extract { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_set_expr { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_get_type { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_set_con { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_create { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_clone { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_modify_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_del_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_query_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_exists_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_count_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_iterate_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_list_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_query { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_exists { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_count { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_iterate { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_fcontext_list_homedirs { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_modify_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_del_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_query_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_exists_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_count_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_iterate_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_list_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_query { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_exists { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_count { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_iterate { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_seuser_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_modify_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_del_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_query_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_exists_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_count_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_iterate_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_list_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_query { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_exists { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_count { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_iterate { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_port_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_modify_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_del_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_query_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_exists_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_count_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_iterate_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_list_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_modify_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_del_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_query_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_exists_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_count_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_iterate_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_list_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_query { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_exists { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_count { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_iterate { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibendport_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_query { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_exists { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_count { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_iterate { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_ibpkey_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_modify_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_del_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_query_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_exists_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_count_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_iterate_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_list_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_query { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_exists { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_count { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_iterate { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_iface_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_modify_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_del_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_query_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_exists_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_count_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_iterate_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_list_local { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_query { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_exists { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_count { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_iterate { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} - -%exception semanage_node_list { - $action - if (result < 0) { - PyErr_SetFromErrno(PyExc_OSError); - SWIG_fail; - } -} diff --git a/libsepol/include/sepol/kernel_to_cil.h b/libsepol/include/sepol/kernel_to_cil.h index 60346ad1..1db0383a 100644 --- a/libsepol/include/sepol/kernel_to_cil.h +++ b/libsepol/include/sepol/kernel_to_cil.h @@ -2,4 +2,5 @@ #include -int sepol_kernel_policydb_to_cil(FILE *fp, struct policydb *pdb); +int sepol_kernel_policydb_to_cil(FILE *out, struct policydb *pdb); +int sepol_kernel_policydb_decls_to_cil(FILE *out, struct policydb *pdb); diff --git a/libsepol/src/kernel_to_cil.c b/libsepol/src/kernel_to_cil.c index 49040ae4..db63ac3f 100644 --- a/libsepol/src/kernel_to_cil.c +++ b/libsepol/src/kernel_to_cil.c @@ -3262,6 +3262,11 @@ int sepol_kernel_policydb_to_cil(FILE *out, struct policydb *pdb) struct strs *non_mls_validatetrans = NULL; int rc = 0; + rc = check_for_supported_policy(pdb); + if (rc != 0) { + return rc; + } + rc = strs_init(&mls_constraints, 32); if (rc != 0) { goto exit; @@ -3282,30 +3287,6 @@ int sepol_kernel_policydb_to_cil(FILE *out, struct policydb *pdb) goto exit; } - if (pdb == NULL) { - ERR(NULL, "No policy"); - rc = -1; - goto exit; - } - - if (pdb->policy_type != SEPOL_POLICY_KERN) { - ERR(NULL, "Policy is not a kernel policy"); - rc = -1; - goto exit; - } - - if (pdb->policyvers >= POLICYDB_VERSION_AVTAB && pdb->policyvers <= POLICYDB_VERSION_PERMISSIVE) { - /* - * For policy versions between 20 and 23, attributes exist in the policy, - * but only in the type_attr_map. This means that there are gaps in both - * the type_val_to_struct and p_type_val_to_name arrays and policy rules - * can refer to those gaps. - */ - ERR(NULL, "Writing policy versions between 20 and 23 as CIL is not supported"); - rc = -1; - goto exit; - } - rc = constraint_rules_to_strs(pdb, mls_constraints, non_mls_constraints); if (rc != 0) { goto exit; @@ -3533,3 +3514,71 @@ exit: return rc; } + +int sepol_kernel_policydb_decls_to_cil(FILE *out, struct policydb *pdb) +{ + int rc = 0; + + rc = check_for_supported_policy(pdb); + if (rc != 0) { + return rc; + } + + rc = write_sid_decl_rules_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + + rc = write_class_decl_rules_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + + rc = write_mls_rules_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + + rc = write_boolean_decl_rules_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + + rc = write_type_decl_rules_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + + rc = write_type_alias_rules_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + + rc = write_type_attributes_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + + rc = write_type_attribute_sets_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + + rc = write_role_decl_rules_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + + rc = write_role_attributes_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + + rc = write_user_decl_rules_to_cil(out, pdb); + if (rc != 0) { + goto exit; + } + +exit: + return rc; +} diff --git a/libsepol/src/kernel_to_common.c b/libsepol/src/kernel_to_common.c index 99e46865..b267b5d7 100644 --- a/libsepol/src/kernel_to_common.c +++ b/libsepol/src/kernel_to_common.c @@ -751,3 +751,29 @@ exit: return rc; } + +int check_for_supported_policy(struct policydb *pdb) +{ + if (pdb == NULL) { + ERR(NULL, "No policy"); + return -1; + } + + if (pdb->policy_type != SEPOL_POLICY_KERN) { + ERR(NULL, "Policy is not a kernel policy"); + return -1; + } + + if (pdb->policyvers >= POLICYDB_VERSION_AVTAB && pdb->policyvers <= POLICYDB_VERSION_PERMISSIVE) { + /* + * For policy versions between 20 and 23, attributes exist in the policy, + * but only in the type_attr_map. This means that there are gaps in both + * the type_val_to_struct and p_type_val_to_name arrays and policy rules + * can refer to those gaps. + */ + ERR(NULL, "Writing out CIL or policy.conf from policy versions between 20 and 23 is not supported"); + return -1; + } + + return 0; +} diff --git a/libsepol/src/kernel_to_common.h b/libsepol/src/kernel_to_common.h index d3283658..53f398b7 100644 --- a/libsepol/src/kernel_to_common.h +++ b/libsepol/src/kernel_to_common.h @@ -117,3 +117,5 @@ int strs_stack_empty(const struct strs *stack); struct strs *isids_to_strs(const char *const *sid_to_str, unsigned num_sids, struct ocontext *isids); int sort_ocontexts(struct policydb *pdb); + +int check_for_supported_policy(struct policydb *pdb); diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c index a8126d58..628a792e 100644 --- a/libsepol/src/kernel_to_conf.c +++ b/libsepol/src/kernel_to_conf.c @@ -3116,6 +3116,11 @@ int sepol_kernel_policydb_to_conf(FILE *out, struct policydb *pdb) struct strs *non_mls_validatetrans = NULL; int rc = 0; + rc = check_for_supported_policy(pdb); + if (rc != 0) { + return rc; + } + rc = strs_init(&mls_constraints, 32); if (rc != 0) { goto exit; @@ -3136,30 +3141,6 @@ int sepol_kernel_policydb_to_conf(FILE *out, struct policydb *pdb) goto exit; } - if (pdb == NULL) { - ERR(NULL, "No policy"); - rc = -1; - goto exit; - } - - if (pdb->policy_type != SEPOL_POLICY_KERN) { - ERR(NULL, "Policy is not a kernel policy"); - rc = -1; - goto exit; - } - - if (pdb->policyvers >= POLICYDB_VERSION_AVTAB && pdb->policyvers <= POLICYDB_VERSION_PERMISSIVE) { - /* - * For policy versions between 20 and 23, attributes exist in the policy, - * but only in the type_attr_map. This means that there are gaps in both - * the type_val_to_struct and p_type_val_to_name arrays and policy rules - * can refer to those gaps. - */ - ERR(NULL, "Writing policy versions between 20 and 23 as a policy.conf is not supported"); - rc = -1; - goto exit; - } - rc = constraint_rules_to_strs(pdb, mls_constraints, non_mls_constraints); if (rc != 0) { goto exit; diff --git a/libsepol/src/libsepol.map.in b/libsepol/src/libsepol.map.in index 2b103993..8785cff1 100644 --- a/libsepol/src/libsepol.map.in +++ b/libsepol/src/libsepol.map.in @@ -297,5 +297,6 @@ LIBSEPOL_3.6 { LIBSEPOL_3.11 { global: + sepol_kernel_policydb_decls_to_cil; cil_check_neverallows_against_pdb; } LIBSEPOL_3.6; -- 2.54.0