android_system_core/include/cutils
Mark Salyzyn 0b034d9d7b 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
2016-11-03 13:34:20 -07:00
..
android_reboot.h Use fsck.f2fs -a instead of -f for faster boot 2015-07-15 10:13:51 -07:00
ashmem.h libcutils: Add ashmem_valid() function 2016-08-23 15:29:28 -07:00
atomic.h Fix warnings in cutils/atomic.h 2016-09-15 19:22:32 -07:00
bitops.h include: cleanup for -Wsystem-header 2014-05-23 15:09:57 -07:00
compiler.h Add ANDROID_API macro to export symbols 2011-10-12 13:45:59 -07:00
config_utils.h Config utils improvement 2011-05-26 13:57:03 -07:00
debugger.h debuggerd: add libdebuggerd_client. 2016-06-17 13:11:29 -07:00
files.h libcutils: add android_get_control_file() 2016-11-03 13:34:20 -07:00
fs.h Add utility to prepare files in a similar way to directories 2016-05-24 18:19:12 +01:00
hashmap.h auto import from //depot/cupcake/@135843 2009-03-03 19:32:55 -08:00
iosched_policy.h system: Add support for getting/setting i/o priorities and include a userspace tool 2010-02-25 14:02:55 -08:00
jstring.h Do not typedef char16_t if it is a keyword. 2014-07-18 17:53:02 -07:00
klog.h Remove no-op klog_init. 2016-07-19 11:45:36 -07:00
list.h Merge "Fix list_for_each_safe macro" 2014-05-22 22:27:14 +00:00
log.h liblog: restructure log/log.h and android/log.h 2016-10-24 11:03:49 -07:00
memory.h Be more intention-revealing with libcutils' strlcpy. 2015-04-02 15:39:33 -07:00
misc.h Remove dead code that looked like part of debuggerd. 2014-01-31 10:37:18 -08:00
multiuser.h Create profiles folders 2016-02-19 13:42:37 +00:00
native_handle.h Add native_handle_init 2016-10-12 18:04:41 -07:00
open_memstream.h Only the Mac doesn't have open_memstream. 2014-08-20 16:16:24 -07:00
partition_utils.h Remove a declaration for an unimplemented function. 2015-04-20 20:55:43 -07:00
properties.h cutils: don't fortify property_get on clang. 2016-06-02 15:29:11 -07:00
qtaguid.h libcutils: qtaguid: Support new functions, add tag resource tracking. 2011-09-14 15:00:40 -07:00
record_stream.h HACK: cutils: restore record_stream temporarily 2013-06-04 17:40:28 +00:00
sched_policy.h Enable top-app cpuset support. 2016-02-01 15:03:16 -08:00
sockets.h Merge "Remove socket_loopback_client." 2016-10-14 18:21:38 +00:00
str_parms.h Move all libcutils tests into the gtests. 2015-04-02 14:25:55 -07:00
threads.h Fix gettid() on Windows. 2015-05-13 13:43:32 -07:00
trace.h Hide warning in cutils/trace.h 2016-09-21 17:45:31 -07:00
uevent.h Extend to receive NFLOG packets. 2015-01-15 12:50:59 -08:00