Blame SOURCES/0062-libsepol-Quote-paths-when-generating-policy.conf-fro.patch

71cd55
From ce1025bf9ccd2e34a0c12d9a1d8eee19eb415573 Mon Sep 17 00:00:00 2001
71cd55
From: James Carter <jwcart2@gmail.com>
71cd55
Date: Tue, 15 Jun 2021 16:31:01 -0400
71cd55
Subject: [PATCH] libsepol: Quote paths when generating policy.conf from binary
71cd55
 policy
71cd55
MIME-Version: 1.0
71cd55
Content-Type: text/plain; charset=UTF-8
71cd55
Content-Transfer-Encoding: 8bit
71cd55
71cd55
Christian Göttsche <cgzones@googlemail.com> submitted a similar patch
71cd55
to quote paths when generating CIL policy from a binary policy.
71cd55
71cd55
Since genfscon and devicetreecon rules have paths which are allowed
71cd55
to contain spaces, always quote the path when writing out these rules.
71cd55
71cd55
Signed-off-by: James Carter <jwcart2@gmail.com>
71cd55
Acked-by: Petr Lautrbach <plautrba@redhat.com>
71cd55
---
71cd55
 libsepol/src/kernel_to_conf.c | 4 ++--
71cd55
 1 file changed, 2 insertions(+), 2 deletions(-)
71cd55
71cd55
diff --git a/libsepol/src/kernel_to_conf.c b/libsepol/src/kernel_to_conf.c
71cd55
index 5db47fe4f567..ffdf179a71f3 100644
71cd55
--- a/libsepol/src/kernel_to_conf.c
71cd55
+++ b/libsepol/src/kernel_to_conf.c
71cd55
@@ -2527,7 +2527,7 @@ static int write_genfscon_rules_to_conf(FILE *out, struct policydb *pdb)
71cd55
 				goto exit;
71cd55
 			}
71cd55
 
71cd55
-			rc = strs_create_and_add(strs, "genfscon %s %s %s", 3,
71cd55
+			rc = strs_create_and_add(strs, "genfscon %s \"%s\" %s", 3,
71cd55
 						 fstype, name, ctx);
71cd55
 			free(ctx);
71cd55
 			if (rc != 0) {
71cd55
@@ -2992,7 +2992,7 @@ static int write_xen_devicetree_rules_to_conf(FILE *out, struct policydb *pdb)
71cd55
 			goto exit;
71cd55
 		}
71cd55
 
71cd55
-		sepol_printf(out, "devicetreecon %s %s\n", name, ctx);
71cd55
+		sepol_printf(out, "devicetreecon \"%s\" %s\n", name, ctx);
71cd55
 
71cd55
 		free(ctx);
71cd55
 	}
71cd55
-- 
71cd55
2.32.0
71cd55