Repository navigation
Conversation
grpc-okhttp's channelz support (Utils.getSocketOptions, reached from the client and server transports' getStats()) calls getKeepAlive(), getOOBInline(), getReuseAddress() and getTrafficClass(), and only catches SocketException (logging Level.SEVERE on catch). Returning false / 0 instead of throwing UnsupportedOperationException lets channelz socket queries succeed cleanly on UDS transports.
jdcormie
force-pushed
the
uds-server-builder
branch
6 times, most recently
from
November 10, 2026 19:34
c24b4e3 to
d139f41
Compare
Add the server-side counterpart to UdsChannelBuilder, delegating
reflectively to OkHttpServerBuilder with a package-private
SocketAddress and ServerSocketFactory backed by LocalServerSocket. No
changes to grpc-okhttp or grpc-core are needed. Like UdsChannelBuilder,
only UdsServerBuilder.forPath(String, Namespace) is public and
`@ExperimentalApi` pending a proper unix: address family.
This commit only supports Namespace.ABSTRACT (all LocalServerSocket
itself supports); filesystem sockets and peer-UID authorization may
follow in separate commits. The SELinux reachability tiers documented in
UdsServerBuilder's Javadoc come from AOSP system/sepolicy/private/
{domain.te,app.te,mls} and were verified with SELinux enforcing across
a server/client targetSdk 27 vs. 33 matrix at API 33, adbd (uid 2000),
and cross-app at API 24.
Tested on-device via :grpc-android:connectedDebugAndroidTest against
AOSP emulators at API 24 (minSdk), 26, and 33.
Accept Namespace.FILESYSTEM in UdsServerBuilder.forPath(), binding a 0600 socket file via LocalSocket + LocalServerSocket(FileDescriptor) so a server under an app-private directory gets kernel-enforced same-UID access control across all Android versions. Verified via :grpc-android:connectedDebugAndroidTest against AOSP emulators at API 24 (minSdk), 26, and 33 (confirming 0700 data-dir and 0771 getFilesDir() modes, stale-socket replacement without clobbering non-sockets, and adbd uid 2000 refusal when unrooted).
UdsChannelInteropTest and TesterActivity previously proxied a raw LocalServerSocket through UdsTcpEndpointConnector to a TCP server because grpc-android had no UDS server. Running both directly against an in-process UdsServerBuilder removes UdsTcpEndpointConnector and gives UdsServerBuilder coverage across the 19-case interop matrix on Firebase Test Lab
:grpc-android now has instrumentation tests under src/androidTest that require a real Android kernel and were only compiled in presubmit. Run grpc-android's debug androidTest APK on Firebase Test Lab across API 24-30 alongside grpc-binder.
jdcormie
force-pushed
the
uds-server-builder
branch
from
November 10, 2026 19:55
d139f41 to
f00f22a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Our team uses the okhttp server in our Android apps so our debug/test APIs can be called from an
adb-connected host. But TCP/IP has an access-control problem: Android's app sandbox does not generally restrict traffic to localhost, so any installed app holding the normalINTERNETpermission can connect and call sensitive APIs whenever the server app is listening.Unix domain sockets in Linux' abstract namespace avoid this while remaining reachable via
adb forward tcp:PORT localabstract:NAMEeven on unrooteduserbuilds. On Android 9+ (when the hosting app targets API 28+), SELinux's per-app categories block other apps from connecting to the abstract socket, limiting reachability to the app itself, anadb-authorized host (adbd), and privileged system processes. Listening in the file system restricts access to same-uid even on older Android versions, and prevents access via adbd on unrooted devices.This PR adds only one new public API:
UdsServerBuilder, counterpart to the existingUdsChannelBuilderstopgap.Suggested review order:
UdsServerBuilder,UdsSocketAddressUdsServerSocketFactory,UdsServerSocket,UdsListeningSocket,UdsAbstractListeningSocket,UdsFilesystemListeningSocketUdsSocket,UdsSocketFactory