Commit Graph

103 Commits

Author SHA1 Message Date
Ariel Abreu
6a52941087
Fix absolute dates 2021-04-21 11:55:56 -04:00
Ariel Abreu
b91537684e
Implement some stubs and store remote credentials for connections
Also uncomment some code for pipes (I had commented it out during testing)
2021-04-11 09:38:30 -04:00
Ariel Abreu
90b934b336
Implement pipes...
...also, add stub messages everywhere.

launchd now works again as of this commit.
2021-04-10 20:25:39 -04:00
Ariel Abreu
86a317edbf
Remove -Werror from CMakeLists 2021-04-07 13:59:09 -04:00
Ariel Abreu
07ae92b98b
Implement XPC connections on top of dispatch_mach
Also includes a serialization overhaul to be more object-oriented (each XPC object class worries about its own (de)serialization). The new serialization code also includes Mach port serialization (which we didn't have before).

The "test" service is not really a test; it's more of a sample. You have to test it out manually.
2021-04-07 13:53:02 -04:00
Ariel Abreu
675120a197
Initial rewrite commit
This commit is the first in the rewrite of libxpc. It implements the basic API (that is, the XPC object system and the most basic objects and collections). It also adds some tests for the basic API.

The current test suite uses ctest as the testing framework, but for future tests (such as for connections), it may be necessary to find something a little more robust (or roll our own).

Future commits will implement the rewritten connection system based on top of libdispatch's private Mach API, which is made specifically for this purpose (it even has certain methods marked as `4libxpc`).
2021-03-27 15:14:08 -04:00
Ariel Abreu
3382d940fd
Many fixes (mainly in connections)
This is probably the last update to the current libxpc codebase I'll be doing. The entire codebase is going to be rewritten soon.
2021-03-17 23:14:47 -04:00
Ariel Abreu
b7cbe133c8
Implement os_system_version_get_current_version 2021-02-22 23:07:51 -05:00
Ariel Abreu
8596b6c39a
Restrucure project and rewrite serialization logic
This commit reorganizes the project to be a little more... organized ;)

It's a matter of preference, but I personally think separating sources and headers is more orderly. Various unnecessary sources that we inherited from NextBSD have also been removed.

We now use an exported symbols list to make our exported symbols match Apple's official libxpc (with the exception of those that we haven't stubbed/defined yet).

And finally, the {de,}serialization logic has been completely rewritten to match Apple's serialization format. The only possible issue there are doubles, which like the old code, we assume the double format is identical between the source machine and the receiving machine (which is probably a safe assumption, but should be avoided if possible).

Oh, and it also various little fixes, the most important of which is that creating a non-empty dictionary now works properly (we were previously doubling the entry count).
2021-01-07 00:19:52 -05:00
Ariel Abreu
22713a1c0f
Replace uses of syslog with debugf
aslmanager uses libxpc, and using syslog causes a sort of deadlock because syslogd is waiting for aslmanager to respond, but aslmanager (via libxpc) is trying to talk to syslogd.

Unfortunately, syslogd still doesn't work as expected.
2020-11-17 23:19:32 -05:00
Ariel Abreu
a5bdf2f177
Use __simple_kprintf and fix os_transaction declaration type 2020-11-07 00:14:39 -05:00
Ariel Abreu
183f5ccf20
Include launchd.h in private.h
This fixes an error in libnotify that was making syslogd crash. `notify_client.c` was including `xpc/private.h` and trying to use `xpc_copy_entitlement_for_token`, which is declared in `launchd.h` and the compiler assumed a default return type of `int`, leading to the pointer returned by it being truncated and causing segfaults when it was used.
2020-11-06 14:47:27 -05:00
Ariel Abreu
8df31b5db6
Fix os_transaction and make bools and nulls into globals
XPC bools and nulls were made into global to match their behavior in Apple's libxpc; users are allowed to compare XPC object pointers with the global XPC_BOOL_{TRUE,FALSE} constants, which are pointers to global variables, so this now allows that to work as expected.
2020-11-03 11:45:00 -05:00
Ariel Abreu
33b6bf1ce8
Stub/implement(?) xpc_transaction_exit_clean
I say "implement(?)" because it *does* technically do the job (it seems) it's supposed to
2020-08-27 22:09:21 -04:00
Ariel Abreu
a5afd7a370
Stub launch_activate_socket 2020-07-29 18:49:53 -04:00
Ariel Abreu
96d94ab0d0 Stub xpc_connection_copy_entitlement_value 2020-07-23 22:18:24 -04:00
Ariel Abreu
d6992c77e9 Stub +xpc_connection_activate 2020-07-23 14:55:30 -04:00
Ariel Abreu
4802015f7d
Add xpc_dictionary_get_dictionary and new xpc_pointer type
xpc_pointer isn't documented *anywhere*, but it's used in Security. My best guess is that's it's just a pretty container for a pointer, which is fine for now, but I'll have to check the exact semantics later.
2020-07-16 14:32:32 -04:00
Ariel Abreu
3c456b6db0
Add stubs for transaction_private 2020-07-02 21:05:24 -04:00
Ariel Abreu
edac36c44d
Remove the JETSAM_PRIORITY_* enum in launchd_defs.h
These are already defined in <sys/kern_memorystatus.h>
2020-07-01 22:42:48 -04:00
Ariel Abreu
814e55abd7
Merge remote-tracking branch 'origin/master' into update-sources 2020-06-15 14:32:20 -04:00
Ariel Abreu
5a644a2867
Move launchd_defs.h from the main repo into libxpc 2020-06-14 23:40:20 -04:00
Ariel Abreu
3416b3d19f
Fix up definition/declaration of xpc_pipe_create and add some flag definitions 2020-06-10 10:01:53 -04:00
Thomas A
542a107926 Include libkern/OSAtomic.h
Unlike x86, there isn't an ARM specific implementation. Therefore, we need to rely on the generic implementation of OSAtomic. Since I have decided to rely on `libkern/OSAtomicDeprecated.h` for the time being, this header must be exposed to any function that uses (directly on indirectly) OSAtomic functions.
2020-05-14 18:33:08 -07:00
Ariel Abreu
79a8161e63
Initial update to clean up include directories
"initial" because there might some additional modifications necessary later on
2020-05-14 12:57:42 -04:00
Ariel Abreu
f1ec0d634c
Add xpc/availability.h
Copied over from darling/platform-include/xpc
2020-05-14 12:51:17 -04:00
Luboš Doležel
9b767f9ebe
Merge pull request #7 from facekapow/implement-dict-setters
Implement a few XPC dictionary getters and setters
2020-04-19 12:44:53 +02:00
Luboš Doležel
5e02bdd435
Merge pull request #6 from facekapow/remove-nv
Reimplement XPC packing/unpacking without `nvlist`/`nvpair`
2020-04-19 12:44:37 +02:00
Ariel Abreu
69cc197766
Implement a few XPC dictionary setters 2020-04-16 09:33:59 -04:00
Ariel Abreu
49f351dda3
xpc_double_create, not xpc_uint64_create 2020-04-16 09:30:12 -04:00
Ariel Abreu
3532d84d70
Fix algorithm explanation note in xpc_misc.c 2020-04-14 23:06:05 -04:00
Ariel Abreu
debabdb6be
Increment xo_size when appending to arrays 2020-04-14 21:20:41 -04:00
Ariel Abreu
8253dd79a8
Fix up the new implementation of the new packing algorithm 2020-04-14 21:20:03 -04:00
Ariel Abreu
e4fa5b7a15
Add back subr_sbuf.c
I accidentally deleted it thinking it was part of the `nv` implementation (since it started with `subr_` just like the `nv` files)
2020-04-14 21:18:44 -04:00
Ariel Abreu
9f3cbc2a66
Initial rewrite of XPC encoding/decoding code 2020-04-13 19:05:18 -04:00
Luboš Doležel
0564f3dad4
Merge pull request #5 from facekapow/fix-dict-getters
Return default values from xpc_dictionary getters when key isn't found
2020-04-11 08:41:31 +02:00
Ariel Abreu
6754295346
Return default values from xpc_dictionary getters when key isn't found 2020-04-10 16:35:36 -04:00
Luboš Doležel
fc8c48b5f6
Merge pull request #4 from facekapow/fix-msg-packing-and-handling
Fix message handling race condition and remove unnecessary checks in nvlist/nvpair
2020-04-10 20:10:55 +02:00
Ariel Abreu
1cbf7e4e75
Don't check for peer->xc_handler before it can be set; and...
...remove unnecessary checks in nvpair/nvlist
2020-04-10 10:10:27 -04:00
Luboš Doležel
087a54b95a
Merge pull request #3 from facekapow/xpc_create-and-misc-fixes
Implement a few more XPC functions and fix `xpc_connection_create_mach_service`
2020-04-09 08:52:06 +02:00
Ariel Abreu
d93f539811
Implement xpc_create_* and xpc_dictionary_get_double and...
...fix `xpc_connection_create_mach_service`; XPC connections must be resumed before they can be released
2020-04-08 19:43:14 -04:00
Luboš Doležel
404333b15e
Merge pull request #2 from facekapow/fix-xpc-object-behavior
Fix behavior of some XPC object functions
2020-04-07 16:08:00 +02:00
Ariel Abreu
7d8c664778
Fix behavior of some XPC object functions
In particular:
  * `xpc_string_create` needs to copy its input
  * `xpc_data_create` needs to do the same
  * `xpc_object_destroy` needs to free the memory copied into `xpc_string`s and `xpc_data`s
  * `xpc_dictionary_set_value` needs to copy the key given to it
  * `xpc_dictionary_destroy` needs to free the keys it copied

There's probably a few more, but these are the ones that popped up when I was fixing another library
2020-04-07 08:44:15 -04:00
Thomas A
b9301ffde6 Add xpc_dictionary_get_uuid stub 2020-04-01 08:56:45 -07:00
Lubos Dolezel
206faca6f3 Quick fix for a launchd crash 2020-02-28 23:38:01 +01:00
Andrew Hyatt
c2d653aa36
Merge pull request #1 from CuriousTommy/CFOpenDirectory_Fix
Add xpc_connection stubs for CFOpenDirectory
2019-09-02 01:14:51 -04:00
Thomas A
b64a02d94c Add xpc_connection stubs for CFOpenDirectory 2019-08-30 06:12:01 -07:00
Sergey Bugaev
ab2c970b0a Fix crashes in xpc_connection_recv_message() 2019-02-23 15:00:20 +03:00
Andrew Hyatt
d6a7cefd72 Correct xpc function paramater types 2019-01-15 23:49:58 -05:00
Andrew Hyatt
695e0d5e33 XPC stubs for securityd 2019-01-15 11:57:14 -05:00