Blame SOURCES/0044-policycoreutils-Improve-error-message-when-selabel_o.patch

ab37b6
From 69da6239d8505a9d6ca547187f71a351df17f157 Mon Sep 17 00:00:00 2001
ab37b6
From: Vit Mojzis <vmojzis@redhat.com>
ab37b6
Date: Mon, 10 Jan 2022 18:35:27 +0100
ab37b6
Subject: [PATCH] policycoreutils: Improve error message when selabel_open
ab37b6
 fails
ab37b6
ab37b6
When selabel_open fails to locate file_context files and
ab37b6
selabel_opt_path is not specified (e.g. when the policy type is
ab37b6
missconfigured in /etc/selinux/config), perror only prints
ab37b6
"No such file or directory".
ab37b6
This can be confusing in case of "restorecon" since it's
ab37b6
not apparent that the issue is in policy store.
ab37b6
ab37b6
Before:
ab37b6
  \# restorecon -v /tmp/foo.txt
ab37b6
  No such file or directory
ab37b6
After:
ab37b6
  \# restorecon -v /tmp/foo.txt
ab37b6
  /etc/selinux/yolo/contexts/files/file_contexts: No such file or directory
ab37b6
ab37b6
Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
ab37b6
---
ab37b6
 policycoreutils/setfiles/restore.c | 2 +-
ab37b6
 1 file changed, 1 insertion(+), 1 deletion(-)
ab37b6
ab37b6
diff --git a/policycoreutils/setfiles/restore.c b/policycoreutils/setfiles/restore.c
ab37b6
index d3335d1a..ba2668b3 100644
ab37b6
--- a/policycoreutils/setfiles/restore.c
ab37b6
+++ b/policycoreutils/setfiles/restore.c
ab37b6
@@ -29,7 +29,7 @@ void restore_init(struct restore_opts *opts)
ab37b6
 
ab37b6
 	opts->hnd = selabel_open(SELABEL_CTX_FILE, selinux_opts, 3);
ab37b6
 	if (!opts->hnd) {
ab37b6
-		perror(opts->selabel_opt_path);
ab37b6
+		perror(opts->selabel_opt_path ? opts->selabel_opt_path : selinux_file_context_path());
ab37b6
 		exit(1);
ab37b6
 	}
ab37b6
 
ab37b6
-- 
ab37b6
2.30.2
ab37b6