From patchwork Wed May 4 20:41:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Carter X-Patchwork-Id: 9018711 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 782669F39D for ; Wed, 4 May 2016 20:40:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7539B203A5 for ; Wed, 4 May 2016 20:40:39 +0000 (UTC) Received: from emsm-gh1-uea10.nsa.gov (emsm-gh1-uea10.nsa.gov [8.44.101.8]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 871F120397 for ; Wed, 4 May 2016 20:40:38 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.24,578,1454976000"; d="scan'208";a="13364064" IronPort-PHdr: =?us-ascii?q?9a23=3AhUIMFBx3MZPpbiHXCy+O+j09IxM/srCxBDY+r6Qd?= =?us-ascii?q?0e8eIJqq85mqBkHD//Il1AaPBtWKraoewLOL6ujJYi8p39WoiDg6aptCVhsI24?= =?us-ascii?q?09vjcLJ4q7M3D9N+PgdCcgHc5PBxdP9nC/NlVJSo6lPwWB6kO74TNaIBjjLw09?= =?us-ascii?q?fr2zQd6DyZztnLnvotX6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO?= =?us-ascii?q?9MxGlldhq5lhf44dqsrtY4q3wD888784Z8dYmyP+FiFf0LRAghZns44MztqAnr?= =?us-ascii?q?URqE5nxaVH4f1BVPHVvr9hb/C7X4tybh/sF0wjWXJ4WiT68/UC6+tY93WRToj2?= =?us-ascii?q?EBLDd//2bJ3J8jxJlHqQ6s8kQsi7XfZ5uYYb8kJq4=3D?= X-IPAS-Result: =?us-ascii?q?A2EhBQDlXCpX/wHyM5BeHAGDG4FBD7thJIc2TAEBAQEBAQI?= =?us-ascii?q?CYieCLYIVAgQBAiQTFCAOAwkBARcpCAgDAS0VEQ4LBRgEiAm+Go5+EQFohHEcB?= =?us-ascii?q?ZgZjhgCiVCFQY80YoIFG4FnUIcHgTUBAQE?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea10.nsa.gov with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 May 2016 20:40:36 +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 u44KdTbr014898; Wed, 4 May 2016 16:39:39 -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 u44KdQ6a015126 for ; Wed, 4 May 2016 16:39:26 -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 u44KdQa2014889 for ; Wed, 4 May 2016 16:39:26 -0400 From: James Carter To: selinux@tycho.nsa.gov Subject: [PATCH 2/6 v2] libsepol/cil: Store CIL filename in parse tree and AST Date: Wed, 4 May 2016 16:41:02 -0400 Message-Id: <1462394466-25076-3-git-send-email-jwcart2@tycho.nsa.gov> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1462394466-25076-1-git-send-email-jwcart2@tycho.nsa.gov> References: <1462394466-25076-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-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 a92e3bb..451014a 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) {