Commit Graph

124 Commits

Author SHA1 Message Date
Ariel Abreu
394e033333
Add various XPC_ACTIVITY key declarations
Required by `secd`
2023-09-20 21:16:55 -04:00
Ariel Abreu
d908c3c6be
Add more missing declarations 2023-07-05 13:34:05 -04:00
CuriousTommy
8aae80f2bd
Merge pull request #8 from darlinghq/fedora_38_fix
Fix Building For Fedora 38
2023-06-28 09:49:13 -07:00
Thomas A
b52d51e118 Replace xpc Header Files 2023-06-25 09:20:14 -07:00
Thomas A
0fc9e15167 Fix implicit-function-declaration
`launch_activate_socket` will be relocated into `launch.h` header file.
2023-06-19 17:51:00 -07:00
Thomas A
887ba9589a Add xpc_connection_get_audit_token in header file 2023-01-24 10:49:58 -08:00
Thomas A
b4880a260e Only call release if message is not NULL
For some reason, launchd seems to stall when `[message release]` is called when message is NULL.

This only seems to be an issue with the newer source. The older source doesn't require this check. I'm worried that I might be overlooking an underlying issue...
2022-05-30 17:05:16 -07:00
Thomas A
1e6fc31277 Add xpc_event_publisher stubs 2022-04-29 16:47:03 -07:00
Ariel Abreu
95ff731415
Implement xpc_dictionary_get_audit_token; remove _od_rpc_call
It's in libinfo now, where it belongs
2021-11-28 23:45:34 -05:00
Ariel Abreu
84e29f89ba
Fix up serialization format to match macOS
* The XPC magic has changed to "@XPC" (at least on Catalina)
  * Container entry counts are included in their content lengths
  * When there are no descriptors to send (i.e. when the message is not complex), the XPC data appears immediately after the header (no descriptor count)
2021-05-19 00:19:57 -04:00
Ariel Abreu
90b1aba9fa
handle_send_result should be able to handle DISPATCH_MACH_MESSAGE_NOT_SENT 2021-05-12 09:37:40 -04:00
Ariel Abreu
c4b1593a0a
Many fixes
First, make xpc_log into a small wrapper over os_log; all it does differently is check whether to enable or disable XPC logging (based on whether we're in syslogd or something else that would cause a deadlock/loop).

Second, add xpc_assumes (and friends) for verifying assumptions for both debug and release builds and logging a message when one fails.

Third, make sure to unset the associatedConnection weak reference when deallocating dictionaries.

Another fix: use objc release instead of os_object_release_internal for releasing server peers (this way, if a user retains the connection, they can release it even after the server has released it).

Also, DISPATCH_MACH_DISCONNECTED is not the right place to release our internal reference. It can be called multiple times, once for each outstanding port and is not guaranteed to be called after DISPATCH_MACH_CANCELED. DISPATCH_MACH_CANCELED is actually the right place for this.

Finally, DISPATCH_MACH_NO_SENDERS should not release the old send port (that's what DISPATCH_MACH_DISCONNECTED is for).
2021-05-11 21:13:46 -04:00
Ariel Abreu
ac0c9fd435
Handle empty messages when peers crash 2021-05-06 22:53:59 -04:00
Ariel Abreu
2dac15634f
Implement os_system_version_get_current_version 2021-05-05 15:42:26 -04:00
Ariel Abreu
e60a45a711
Invoke the event handler for invalidation at the proper time
Also make sure to release the event handler; it might have a reference on the connection.
2021-05-05 15:39:07 -04:00
Ariel Abreu
b71a0e24cd
Use os_log for logging 2021-05-05 15:38:42 -04:00
Ariel Abreu
deaf74952c
Merge branch 'rewrite' 2021-04-22 23:38:53 -04:00
Ariel Abreu
efee6f689e
Add license headers everywhere and fix small issues 2021-04-22 09:18:09 -04:00
Ariel Abreu
0ec7a91082
Implement xpc_main
However, bundled XPC services still don't work properly.

The problem is that bundled XPC service support needs to be implemented in launchd.
The open-source launchd sources are severely outdated, much like CoreFoundation.
The new launchd is based on libxpc and is closed-source.
We probably don't want to completely rewrite launchd, but at the very least, we do need to add support for new XPC-based features.
2021-04-21 17:30:34 -04:00
Ariel Abreu
96434fd2f1
Implement bundles and property list parsing
As noted in `plist.m`, the XML parsing implemented here is NOT robust, but it's good enough for the vast majority of files.

This commit also adds many new String methods. It also fixes an issue where syslogd would get stuck trying to send a message to itself due to our logging.
2021-04-21 12:02:02 -04:00
Ariel Abreu
6a52941087
Fix absolute dates 2021-04-21 11:55:56 -04:00
Thomas A
6108389dbe Update CMake Minimum Version To 3.10 2021-04-11 14:11:02 -07: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