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

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