From patchwork Fri Mar 25 18:04:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Carter X-Patchwork-Id: 8672691 Return-Path: X-Original-To: patchwork-selinux@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ACEA69F44D for ; Fri, 25 Mar 2016 18:08:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19DFD202F0 for ; Fri, 25 Mar 2016 18:08:05 +0000 (UTC) Received: from emvm-gh1-uea08.nsa.gov (unknown [63.239.67.9]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D1B852026D for ; Fri, 25 Mar 2016 18:08:03 +0000 (UTC) X-TM-IMSS-Message-ID: Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.193]) with ESMTP (TREND IMSS SMTP Service 7.1) id d20b6f260000fc00 ; Fri, 25 Mar 2016 14:05:36 -0400 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 u2PI6AUr000749; Fri, 25 Mar 2016 14:06:11 -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 u2PI3jIn065829 for ; Fri, 25 Mar 2016 14:03:45 -0400 Received: from moss-lions.infosec.tycho.ncsc.mil (moss-lions [192.168.25.4]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u2PI3jdJ032616 for ; Fri, 25 Mar 2016 14:03:45 -0400 From: James Carter To: selinux@tycho.nsa.gov Subject: [PATCH 3/3] checkpolicy: Warn if module name different than filenames Date: Fri, 25 Mar 2016 14:04:55 -0400 Message-Id: <1458929095-25819-4-git-send-email-jwcart2@tycho.nsa.gov> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1458929095-25819-1-git-send-email-jwcart2@tycho.nsa.gov> References: <1458929095-25819-1-git-send-email-jwcart2@tycho.nsa.gov> 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: MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-TM-AS-MML: disable X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RDNS_NONE, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since the usual convention is for the module name to be same as the base filename of the module, provide a warning message if they are different. Also warn if the output filename is different than the module name. Signed-off-by: James Carter --- checkpolicy/checkmodule.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/checkpolicy/checkmodule.c b/checkpolicy/checkmodule.c index 5957d29..5d1e219 100644 --- a/checkpolicy/checkmodule.c +++ b/checkpolicy/checkmodule.c @@ -258,6 +258,19 @@ int main(int argc, char **argv) } } + if (policy_type != POLICY_BASE) { + sepol_policydb_t *module = (sepol_policydb_t *)&modpolicydb; + if (sepol_module_check_name_matches_filename(module, file)) { + fprintf(stderr, "Module name %s does not match input file %s\n", + sepol_module_get_name(module), file); + } + if (outfile) { + if (sepol_module_check_name_matches_filename(module, outfile)) { + fprintf(stderr, "Module name %s does not match output file %s\n", sepol_module_get_name(module), outfile); + } + } + } + if (modpolicydb.policy_type == POLICY_BASE && !cil) { /* Verify that we can successfully expand the base module. */ policydb_t kernpolicydb;