diff --git a/MOLXPCConnection.podspec b/MOLXPCConnection.podspec index feb921e..7a81e34 100644 --- a/MOLXPCConnection.podspec +++ b/MOLXPCConnection.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'MOLXPCConnection' - s.version = '1.1' + s.version = '1.2' s.platform = :osx, '10.8' s.license = { :type => 'Apache 2.0', :file => 'LICENSE' } s.homepage = 'https://github.com/google/macops-molxpcconnection' diff --git a/README.md b/README.md index f059482..85e3a10 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # MOLXPCConnection -A wrapper around NSXPCListener and NSXPCConnection to provide client multiplexing, signature validation of connecting clients and forced connection establishment. +A wrapper around NSXPCListener and NSXPCConnection to provide client multiplexing, +signature validation of connecting clients, forced connection establishment and +different exported interfaces for privileged/unprivileged clients. ## Installation @@ -16,7 +18,7 @@ Example server started by `launchd` where the `launchd` job has a `MachServices` ```objc MOLXPCConnection *conn = [[MOLXPCConnection alloc] initServerWithName:@"MyServer"]; -conn.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MyServerProtocol)]; +conn.privilegedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MyServerProtocol)]; conn.exportedObject = myObject; [conn resume]; ``` diff --git a/Source/MOLXPCConnection/MOLXPCConnection.h b/Source/MOLXPCConnection/MOLXPCConnection.h index 112e127..489cc30 100644 --- a/Source/MOLXPCConnection/MOLXPCConnection.h +++ b/Source/MOLXPCConnection/MOLXPCConnection.h @@ -22,8 +22,8 @@ @code MOLXPCConnection *conn = [[MOLXPCConnection alloc] initServerWithName:@"MyServer"]; - conn.privilegedExportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MyPriamryServerProtocol)]; - conn.unprivilegedExportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MySecondaryServerProtocol)]; + conn.privilegedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MyPriamryServerProtocol)]; + conn.unprivilegedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MySecondaryServerProtocol)]; conn.exportedObject = myObject; [conn resume]; @endcode @@ -119,13 +119,14 @@ @property(retain, nullable) NSXPCInterface *privilegedInterface; /** - The unprivileged interface this object exports. (server) + The unprivileged interface this object exports. (server) */ @property(retain, nullable) NSXPCInterface *unprivilegedInterface; /** - Old interface property, please update to use privilegedExportedInterface and/or unprivilegedExportedInterface instead. -*/ + Old interface property, please update to use privilegedExportedInterface and/or + unprivilegedExportedInterface instead. + */ @property(retain, nullable) NSXPCInterface *exportedInterface __attribute__(( deprecated("Use privilegedExportedInterface and / or unprivilegedExportedInterface instead."))); diff --git a/Source/MOLXPCConnection/MOLXPCConnection.m b/Source/MOLXPCConnection/MOLXPCConnection.m index 3d14bd4..46b4d3c 100644 --- a/Source/MOLXPCConnection/MOLXPCConnection.m +++ b/Source/MOLXPCConnection/MOLXPCConnection.m @@ -61,7 +61,7 @@ - (instancetype)initServerWithListener:(NSXPCListener *)listener { if (self) { _listenerObject = listener; _validationInterface = - [NSXPCInterface interfaceWithProtocol:@protocol(MOLXPCConnectionProtocol)]; + [NSXPCInterface interfaceWithProtocol:@protocol(MOLXPCConnectionProtocol)]; } return self; } @@ -154,7 +154,7 @@ - (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConne // Fail this connection if it's from an unprivileged user and we have been // configured to only allow root/admins NSXPCInterface *interface; - if ([connection effectiveUserIdentifier] == 0) { + if (connection.effectiveUserIdentifier == 0) { interface = self.privilegedInterface; } else { interface = self.unprivilegedInterface;