diff options
authorMark Salyzyn2016-10-27 10:04:48 -0500
committerMark Salyzyn2016-11-03 15:34:20 -0500
commit0b034d9d7b1af4e2f608ddf2dc2a0e08773e69ac (patch)
treee2c9188ed7cf1bf51ae707c505658c32b93a78db /libcutils/Android.bp
parent547e0dc45a6f2eca161b29b34a7f5ebbbc8d4b01 (diff)
libcutils: add android_get_control_file()
Solve one more issue where privilege is required to open a file and we do not want to grant such to the service. This is the client side of the picture, init is the server. The file's descriptor was placed into the environment as "ANDROID_FILE_<path>" where non-alpha and non-numeric characters in the <path> are replaced with _ and this function picks the file descriptor up. Added definition ANDROID_FILE_ENV_PREFIX ("ANDROID_FILE_") and android_get_control_file() prototype in a new include <cutils/files.h> android_get_control_file() checks if the resulting file descriptor is valid, open and matches the name reference, which on purpose will fail if a symbolic link is in the path rather than using a fully qualified path. Add gTest unit test for both. Test: gTest libcutils_test --gtest_filter=FileTest.android_get_control_file Bug: 32450474 Change-Id: I2d0310a1727f1e393a00d9fc7e6cf5d028f27905
Diffstat (limited to 'libcutils/Android.bp')
1 files changed, 1 insertions, 0 deletions
diff --git a/libcutils/Android.bp b/libcutils/Android.bp
index 943926b9b..f7b497d9d 100644
--- a/libcutils/Android.bp
+++ b/libcutils/Android.bp
@@ -34,6 +34,7 @@ cc_library {
34 host_supported: true, 34 host_supported: true,
35 srcs: [ 35 srcs: [
36 "config_utils.c", 36 "config_utils.c",
37 "files.cpp",
37 "fs_config.c", 38 "fs_config.c",
38 "canned_fs_config.c", 39 "canned_fs_config.c",
39 "hashmap.c", 40 "hashmap.c",