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