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

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