Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions meshcore/KVM/MacOS/mac_kvm_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* Get our own code signature for comparison
*/
SecCodeRef get_self_code(void) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🦩 🔴 mac_kvm_auth.c public functions lack MeshAgent_/MeshCommand_ prefix required for meshcore/ symbols

Renamed the three public functions in meshcore/KVM/MacOS/mac_kvm_auth.c to carry the mandated prefix: get_self_code -> MeshAgent_KVM_GetSelfCode, codesign_matches -> MeshAgent_KVM_CodesignMatches, verify_peer_codesign -> MeshAgent_KVM_VerifyPeerCodesign. All internal call sites within this file (the self-code call inside MeshAgent_KVM_VerifyPeerCodesign and the codesign comparison call) were updated to use the new names. Risk: the corresponding header mac_kvm_auth.h (not shown/not in scope) and any other translation units calling these functions by their old names must also be updated to match, or the build will fail to link; that header/caller update is outside this single-file fix and is not verified here.

🤖 Prompt for AI agents
In meshcore/KVM/MacOS/mac_kvm_auth.c around line 18, review and complete this code-review fix: mac_kvm_auth.c public functions lack MeshAgent_/MeshCommand_ prefix required for meshcore/ symbols.
What the draft fix changed: Renamed the three public functions in meshcore/KVM/MacOS/mac_kvm_auth.c to carry the mandated prefix: `get_self_code` -> `MeshAgent_KVM_GetSelfCode`, `codesign_matches` -> `MeshAgent_KVM_CodesignMatches`, `verify_peer_codesign` -> `MeshAgent_KVM_VerifyPeerCodesign`. All internal call sites within this file (the self-code call inside `MeshAgent_KVM_VerifyPeerCodesign` and the codesign comparison call) were updated to use the new names. Risk: the corresponding header `mac_kvm_auth.h` (not shown/not in scope) and any other translation units calling these functions by their old names must also be updated to match, or the build will fail to link; that header/caller update is outside this single-file fix and is not verified here.
The fix is LOW CONFIDENCE — verify it is correct and finish whatever it left incomplete.

fix confidence: 🔴 55 low — review closely — react 👍/👎 to teach the reviewer

SecCodeRef MeshAgent_KVM_GetSelfCode(void) {
SecCodeRef self_code = NULL;
OSStatus status;

Expand All @@ -37,7 +37,7 @@ SecCodeRef get_self_code(void) {
/**
* Check if two code signatures match (same binary)
*/
int codesign_matches(SecCodeRef code1, SecCodeRef code2) {
int MeshAgent_KVM_CodesignMatches(SecCodeRef code1, SecCodeRef code2) {
OSStatus status;
CFDictionaryRef info1 = NULL, info2 = NULL;
CFDataRef cdhash1 = NULL, cdhash2 = NULL;
Expand Down Expand Up @@ -92,7 +92,7 @@ int codesign_matches(SecCodeRef code1, SecCodeRef code2) {
/**
* Verify peer process connected to socket is legitimate meshagent
*/
int verify_peer_codesign(int socket_fd) {
int MeshAgent_KVM_VerifyPeerCodesign(int socket_fd) {
pid_t peer_pid = 0;
socklen_t len = sizeof(peer_pid);
OSStatus status;
Expand All @@ -118,7 +118,7 @@ int verify_peer_codesign(int socket_fd) {
}

// Get our own code signature
self_code = get_self_code();
self_code = MeshAgent_KVM_GetSelfCode();
if (!self_code) {
ILIBLOGMESSAGEX("MSG_KVM_AUTH_VERIFY_PEER_FAIL: Failed to get self code signature");
return 0;
Expand Down Expand Up @@ -147,7 +147,7 @@ int verify_peer_codesign(int socket_fd) {
ILIBLOGMESSAGEX("MSG_KVM_AUTH_VERIFY_PEER: Peer code is valid, comparing signatures...");

// Compare code signatures - must be same binary
if (codesign_matches(self_code, peer_code)) {
if (MeshAgent_KVM_CodesignMatches(self_code, peer_code)) {
ILIBLOGMESSAGEX("MSG_KVM_AUTH_VERIFY_PEER_SUCCESS: Peer verified successfully, PID=%d", peer_pid);
result = 1;
} else {
Expand Down Expand Up @@ -196,3 +196,4 @@ int verify_peer_codesign_audit(int socket_fd) {
#endif

#endif /* __APPLE__ */