From patchwork Tue Apr 19 14:26:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Carter X-Patchwork-Id: 8880761 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 9BD659F1C1 for ; Tue, 19 Apr 2016 14:29:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 060A92026F for ; Tue, 19 Apr 2016 14:29:45 +0000 (UTC) Received: from emvm-gh1-uea09.nsa.gov (emvm-gh1-uea09.nsa.gov [8.44.101.9]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0D6E120279 for ; Tue, 19 Apr 2016 14:29:43 +0000 (UTC) X-TM-IMSS-Message-ID: <9de026520005b576@nsa.gov> Received: from tarius.tycho.ncsc.mil ([144.51.242.1]) by nsa.gov ([10.208.42.194]) with ESMTP (TREND IMSS SMTP Service 7.1) id 9de026520005b576 ; Tue, 19 Apr 2016 10:27:32 -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 u3JERrSO005757; Tue, 19 Apr 2016 10:27:53 -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 u3JEOYUB054973 for ; Tue, 19 Apr 2016 10:24:34 -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 u3JEOYFJ005142 for ; Tue, 19 Apr 2016 10:24:34 -0400 From: James Carter To: selinux@tycho.nsa.gov Subject: [PATCH 2/6] libsepol/cil: Store CIL filename in parse tree and AST Date: Tue, 19 Apr 2016 10:26:01 -0400 Message-Id: <1461075965-17161-3-git-send-email-jwcart2@tycho.nsa.gov> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1461075965-17161-1-git-send-email-jwcart2@tycho.nsa.gov> References: <1461075965-17161-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=-2.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, 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 Use some of the functionality recently added to support high-level language line marking to track the CIL filename. The goal is to eventually remove the path field from the tree node struct and offset the addtion of the hll_line field. Signed-off-by: James Carter --- libsepol/cil/src/cil_parser.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/libsepol/cil/src/cil_parser.c b/libsepol/cil/src/cil_parser.c index 23d1466..bf1c213 100644 --- a/libsepol/cil/src/cil_parser.c +++ b/libsepol/cil/src/cil_parser.c @@ -179,6 +179,24 @@ exit: return SEPOL_ERR; } +static void add_cil_path(struct cil_tree_node **current, char *path) +{ + struct cil_tree_node *node; + + create_node(&node, *current, 0, 0, path, NULL); + insert_node(node, *current); + *current = node; + + create_node(&node, *current, 0, 0, path, CIL_KEY_SRC_INFO); + insert_node(node, *current); + + create_node(&node, *current, 0, 0, path, CIL_KEY_SRC_CIL); + insert_node(node, *current); + + create_node(&node, *current, 0, 0, path, path); + insert_node(node, *current); +} + int cil_parser(char *_path, char *buffer, uint32_t size, struct cil_tree **parse_tree) { @@ -205,6 +223,8 @@ int cil_parser(char *_path, char *buffer, uint32_t size, struct cil_tree **parse tree = *parse_tree; current = tree->root; + add_cil_path(¤t, path); + do { cil_lexer_next(&tok); switch (tok.type) {