Implement xpc_dictionary_get_audit_token; remove _od_rpc_call

It's in libinfo now, where it belongs
This commit is contained in:
Ariel Abreu 2021-11-28 23:45:34 -05:00
parent 84e29f89ba
commit 95ff731415
No known key found for this signature in database
GPG Key ID: D67AE16CCEA85B70
5 changed files with 33 additions and 10 deletions

View File

@ -53,8 +53,6 @@ XPC_TYPE(_xpc_type_file_transfer);
int _xpc_runtime_is_app_sandboxed(); int _xpc_runtime_is_app_sandboxed();
xpc_object_t _od_rpc_call(const char *procname, xpc_object_t payload, xpc_pipe_t (*get_pipe)(bool));
xpc_object_t xpc_create_with_format(const char * format, ...); xpc_object_t xpc_create_with_format(const char * format, ...);
xpc_object_t xpc_create_reply_with_format(xpc_object_t original, const char * format, ...); xpc_object_t xpc_create_reply_with_format(xpc_object_t original, const char * format, ...);

View File

@ -44,6 +44,7 @@ struct xpc_dictionary_s {
XPC_CLASS(connection)* associatedConnection; XPC_CLASS(connection)* associatedConnection;
mach_port_t incoming_port; mach_port_t incoming_port;
mach_port_t outgoing_port; mach_port_t outgoing_port;
audit_token_t associated_audit_token;
}; };
@interface XPC_CLASS_INTERFACE(dictionary) @interface XPC_CLASS_INTERFACE(dictionary)
@ -90,6 +91,9 @@ struct xpc_dictionary_s {
// useful extensions: // useful extensions:
- (XPC_CLASS(string)*)stringForKey: (const char*)key; - (XPC_CLASS(string)*)stringForKey: (const char*)key;
- (void)setAssociatedAuditToken: (audit_token_t*)auditToken;
- (void)copyAssociatedAuditTokenTo: (audit_token_t*)auditToken;
@end @end
#endif // _XPC_OBJECTS_DICTIONARY_H_ #endif // _XPC_OBJECTS_DICTIONARY_H_

View File

@ -225,6 +225,9 @@ static void dispatch_mach_handler(void* context, dispatch_mach_reason_t reason,
[message retain]; // because the deserializer consumes a reference on the message [message retain]; // because the deserializer consumes a reference on the message
dict = [XPC_CLASS(deserializer) process: message]; dict = [XPC_CLASS(deserializer) process: message];
dict.associatedConnection = self; dict.associatedConnection = self;
if (token) {
[dict setAssociatedAuditToken: token];
}
this->event_handler(dict); this->event_handler(dict);
} }

View File

@ -134,6 +134,7 @@ XPC_CLASS_HEADER(dictionary);
if (self = [super init]) { if (self = [super init]) {
XPC_THIS_DECL(dictionary); XPC_THIS_DECL(dictionary);
LIST_INIT(&this->head); LIST_INIT(&this->head);
memset(&this->associated_audit_token, 0xff, sizeof(audit_token_t));
} }
return self; return self;
} }
@ -299,6 +300,28 @@ XPC_CLASS_HEADER(dictionary);
return result; return result;
} }
- (void)setAssociatedAuditToken: (audit_token_t*)auditToken
{
XPC_THIS_DECL(dictionary);
if (!auditToken) {
return;
}
memcpy(&this->associated_audit_token, auditToken, sizeof(audit_token_t));
}
- (void)copyAssociatedAuditTokenTo: (audit_token_t*)auditToken
{
XPC_THIS_DECL(dictionary);
if (!auditToken) {
return;
}
memcpy(auditToken, &this->associated_audit_token, sizeof(audit_token_t));
}
@end @end
@implementation XPC_CLASS(dictionary) (XPCSerialization) @implementation XPC_CLASS(dictionary) (XPCSerialization)
@ -504,7 +527,9 @@ xpc_connection_t xpc_dictionary_get_remote_connection(xpc_object_t xdict) {
XPC_EXPORT XPC_EXPORT
void xpc_dictionary_get_audit_token(xpc_object_t xdict, audit_token_t* token) { void xpc_dictionary_get_audit_token(xpc_object_t xdict, audit_token_t* token) {
TO_OBJC_CHECKED(dictionary, xdict, dict) {
[dict copyAssociatedAuditTokenTo: token];
}
}; };
// //

View File

@ -814,13 +814,6 @@ xpc_pipe_t xpc_pipe_create_from_port(mach_port_t port, uint64_t flags) {
return [[XPC_CLASS(pipe) alloc] initWithPort: port flags: flags]; return [[XPC_CLASS(pipe) alloc] initWithPort: port flags: flags];
}; };
// actually belongs in libsystem_info
XPC_EXPORT
xpc_object_t _od_rpc_call(const char* procname, xpc_object_t payload, xpc_pipe_t (*get_pipe)(bool)) {
xpc_stub();
return NULL;
};
XPC_EXPORT XPC_EXPORT
int xpc_pipe_routine_reply(xpc_object_t xdict) { int xpc_pipe_routine_reply(xpc_object_t xdict) {
TO_OBJC_CHECKED(dictionary, xdict, dict) { TO_OBJC_CHECKED(dictionary, xdict, dict) {