authfs: Remove local binder support
Bug: 190851176
Test: atest AuthFsHostTest ComposHostTestCases
Change-Id: I975b53e82d83fcc03b80e26dca886f5f6b724078
diff --git a/authfs/fd_server/src/main.rs b/authfs/fd_server/src/main.rs
index 4f17c83..7e551a3 100644
--- a/authfs/fd_server/src/main.rs
+++ b/authfs/fd_server/src/main.rs
@@ -14,20 +14,17 @@
* limitations under the License.
*/
-//! This program is a constrained file/FD server to serve file requests through a remote[1] binder
+//! This program is a constrained file/FD server to serve file requests through a remote binder
//! service. The file server is not designed to serve arbitrary file paths in the filesystem. On
//! the contrary, the server should be configured to start with already opened FDs, and serve the
//! client's request against the FDs
//!
//! For example, `exec 9</path/to/file fd_server --ro-fds 9` starts the binder service. A client
//! client can then request the content of file 9 by offset and size.
-//!
-//! [1] Since the remote binder is not ready, this currently implementation uses local binder
-//! first.
mod fsverity;
-use anyhow::{bail, Context, Result};
+use anyhow::{bail, Result};
use binder::unstable_api::AsNative;
use log::{debug, error};
use std::cmp::min;
@@ -44,11 +41,9 @@
MAX_REQUESTING_DATA,
};
use authfs_aidl_interface::binder::{
- add_service, BinderFeatures, ExceptionCode, Interface, ProcessState, Result as BinderResult,
- Status, StatusCode, Strong,
+ BinderFeatures, ExceptionCode, Interface, Result as BinderResult, Status, StatusCode, Strong,
};
-const SERVICE_NAME: &str = "authfs_fd_server";
const RPC_SERVICE_PORT: u32 = 3264; // TODO: support dynamic port for multiple fd_server instances
fn new_binder_exception<T: AsRef<str>>(exception: ExceptionCode, message: T) -> Status {
@@ -301,7 +296,7 @@
Ok((fd, FdConfig::ReadWrite(file)))
}
-fn parse_args() -> Result<(bool, BTreeMap<i32, FdConfig>)> {
+fn parse_args() -> Result<BTreeMap<i32, FdConfig>> {
#[rustfmt::skip]
let matches = clap::App::new("fd_server")
.arg(clap::Arg::with_name("ro-fds")
@@ -312,8 +307,6 @@
.long("rw-fds")
.multiple(true)
.number_of_values(1))
- .arg(clap::Arg::with_name("rpc-binder")
- .long("rpc-binder"))
.get_matches();
let mut fd_pool = BTreeMap::new();
@@ -330,8 +323,7 @@
}
}
- let rpc_binder = matches.is_present("rpc-binder");
- Ok((rpc_binder, fd_pool))
+ Ok(fd_pool)
}
fn main() -> Result<()> {
@@ -339,32 +331,22 @@
android_logger::Config::default().with_tag("fd_server").with_min_level(log::Level::Debug),
);
- let (rpc_binder, fd_pool) = parse_args()?;
+ let fd_pool = parse_args()?;
- if rpc_binder {
- let mut service = FdService::new_binder(fd_pool).as_binder();
- debug!("fd_server is starting as a rpc service.");
- // SAFETY: Service ownership is transferring to the server and won't be valid afterward.
- // Plus the binder objects are threadsafe.
- let retval = unsafe {
- binder_rpc_unstable_bindgen::RunRpcServer(
- service.as_native_mut() as *mut binder_rpc_unstable_bindgen::AIBinder,
- RPC_SERVICE_PORT,
- )
- };
- if retval {
- debug!("RPC server has shut down gracefully");
- Ok(())
- } else {
- bail!("Premature termination of RPC server");
- }
+ let mut service = FdService::new_binder(fd_pool).as_binder();
+ debug!("fd_server is starting as a rpc service.");
+ // SAFETY: Service ownership is transferring to the server and won't be valid afterward.
+ // Plus the binder objects are threadsafe.
+ let retval = unsafe {
+ binder_rpc_unstable_bindgen::RunRpcServer(
+ service.as_native_mut() as *mut binder_rpc_unstable_bindgen::AIBinder,
+ RPC_SERVICE_PORT,
+ )
+ };
+ if retval {
+ debug!("RPC server has shut down gracefully");
+ Ok(())
} else {
- ProcessState::start_thread_pool();
- let service = FdService::new_binder(fd_pool).as_binder();
- add_service(SERVICE_NAME, service)
- .with_context(|| format!("Failed to register service {}", SERVICE_NAME))?;
- debug!("fd_server is running as a local service.");
- ProcessState::join_thread_pool();
- bail!("Unexpected exit after join_thread_pool")
+ bail!("Premature termination of RPC server");
}
}