From f3007e9fd4a5dc94b9acd4e3059c434b0686c271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thi=C3=A9baud=20Weksteen?= Date: Wed, 28 Feb 2024 13:26:57 +1100 Subject: Add selabel_get_digests_all_partial_matches binary Add build rule for selabel_get_digests_all_partial_matches. It is not included by default in the system image, but can be useful to debug the computation of security.sehash. Bug: 317296680 Test: adb remount; adb push selabel_get_digests_all_partial_matches /system/bin; selabel_get_digests_all_partial_matches -r /data/data Change-Id: I2b7e8d994f15539849d69ded5695293c4f2cf8b2 --- libselinux/Android.bp | 12 ++++++++++++ libselinux/utils/selabel_get_digests_all_partial_matches.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/libselinux/Android.bp b/libselinux/Android.bp index ff7dc3d3..766c90ed 100644 --- a/libselinux/Android.bp +++ b/libselinux/Android.bp @@ -222,6 +222,18 @@ cc_binary_host { stl: "", } +cc_binary { + name: "selabel_get_digests_all_partial_matches", + defaults: ["libselinux_defaults"], + srcs: ["utils/selabel_get_digests_all_partial_matches.c"], + + static_libs: [ + "libselinux", + ], + + stl: "", +} + rust_bindgen { name: "libselinux_bindgen", wrapper_src: "rust/selinux.h", diff --git a/libselinux/utils/selabel_get_digests_all_partial_matches.c b/libselinux/utils/selabel_get_digests_all_partial_matches.c index c4e0f836..fc518439 100644 --- a/libselinux/utils/selabel_get_digests_all_partial_matches.c +++ b/libselinux/utils/selabel_get_digests_all_partial_matches.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include @@ -71,10 +72,14 @@ int main(int argc, char **argv) paths[0] = argv[optind]; +#ifdef ANDROID + hnd = selinux_android_file_context_handle(); +#else selabel_option[0].value = file; selabel_option[1].value = validate; hnd = selabel_open(SELABEL_CTX_FILE, selabel_option, 2); +#endif if (!hnd) { fprintf(stderr, "ERROR: selabel_open - Could not obtain " "handle: %s\n", -- cgit v1.2.3