Add a remote binder service for executing commands
To summarize, three binaries are involved to run a command remotely:
- pvm_exec: the client executable on the host side to wrap the
executable command with hints of FD passing
- compsvc: listen to requests, spin off and sandbox a worker for
execution setup
- compsvc_worker: set up authfs, prepare the fds and exec the actual
task
Please see the code documentation for details.
Bug: 171316742
Test: [shell 1] adb shell compsvc /system/bin/sleep
[shell 2] adb shell exec 8</dev/zero 7<>/dev/null pvm_exec
--in-fd 8 --out-fd 7 -- sleep 300
# Saw FDs in /proc/${sleep_pid}/fd
Change-Id: I4758a4dc7bc70b6e5cce79e151c84c9990d9bc89
diff --git a/compos/Android.bp b/compos/Android.bp
new file mode 100644
index 0000000..ac69a52
--- /dev/null
+++ b/compos/Android.bp
@@ -0,0 +1,41 @@
+rust_binary {
+ name: "pvm_exec",
+ srcs: ["src/pvm_exec.rs"],
+ rustlibs: [
+ "compos_aidl_interface-rust",
+ "libanyhow",
+ "libclap",
+ "liblibc",
+ "liblog_rust",
+ "libminijail_rust",
+ "libnix",
+ "libscopeguard",
+ ],
+}
+
+rust_binary {
+ name: "compsvc",
+ srcs: ["src/compsvc.rs"],
+ rustlibs: [
+ "compos_aidl_interface-rust",
+ "libandroid_logger",
+ "libanyhow",
+ "libclap",
+ "liblog_rust",
+ "libminijail_rust",
+ ],
+}
+
+rust_binary {
+ name: "compsvc_worker",
+ srcs: ["src/compsvc_worker.rs"],
+ rustlibs: [
+ "libandroid_logger",
+ "libanyhow",
+ "libclap",
+ "liblog_rust",
+ "libminijail_rust",
+ "libnix",
+ "libscopeguard",
+ ],
+}