Skip to content

Conversation

@klobucar
Copy link

@klobucar klobucar commented Nov 24, 2025

Make the macOS code in obj-c with some changes to modernize

  • Replace [dict objectForKey:] with modern subscripting syntax dict[key]

  • Replace NSAutoreleasePool with @autoreleasepool blocks

  • Replace deprecated AudioDeviceGetProperty with AudioObjectGetPropertyData

  • Remove obsolete macOS version checks for < 10.15

  • Remove dead 32-bit code (LP64 guards)

  • Remove unnecessary respondsToSelector: checks for APIs available in 10.15+

  • Fix potential crash in dumpEventTaps when process name is nil

  • Fix memory leak in query_language by adding proper CFRelease calls

  • Add defensive null checks in query_language for CFPreferencesCopyAppValue

  • Fix unused variable warning in AppNap.mm

  • Remove duplicate [reason release] call

  • Remove deprecated API warning suppressions from CoreAudio.mm and Overlay_macx.mm

  • Comment out deprecated AuthorizationExecuteWithPrivileges with migration note

Checks

@coderabbitai
Copy link

coderabbitai bot commented Nov 24, 2025

Walkthrough

Replaces manual NSAutoreleasePool usage with @autoreleasepool blocks in src/mumble/GlobalShortcut_macx.mm, src/mumble/Overlay_macx.mm, and src/mumble/os_macx.mm, moving related calls and logging into the pool scopes and adjusting control flow for early returns. Consolidates and reorders event-tap logging. Removes version-guard conditionals in AppNap.mm, simplifies reason string construction and activation calls. In CoreAudio.mm switches one property query from AudioDeviceGetProperty to AudioObjectGetPropertyData. In TextToSpeech_macx.mm removes the respondsToSelector: guard and always calls setVolume:. No public signatures changed.

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main objective: modernizing macOS Objective-C code and updating it for macOS 10.15 minimum requirements.
Description check ✅ Passed The pull request description thoroughly covers all major changes, including modernization efforts, bug fixes, and deprecation handling with clear bullet points.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/mumble/GlobalShortcut_macx.mm (1)

205-235: Strengthen dumpEventTaps logging around processName while using the new pool

Wrapping dumpEventTaps() in @autoreleasepool is appropriate for scoping NSRunningApplication and NSString usage during logging. One improvement worth making in this touched block: processName can remain nil if runningApplicationWithProcessIdentifier: fails, but it’s passed directly to %s via [processName UTF8String]. Consider guarding this and substituting a fallback string (e.g. "?" or "<unknown>") when processName is nil to avoid relying on implementation‑defined handling of a null char * in the logging backend. This is a preexisting edge case but easy to fix while you’re modifying the function.

After applying a guard, re-run the Ctrl+Alt+Cmd dump to confirm all event taps log correctly, including those where NSRunningApplication returns nil.

src/mumble/os_macx.mm (1)

24-36: query_language(): consider CF safety checks and releasing cfaLangs

The new @autoreleasepool wrapper is fine here and doesn’t change behavior, but inside this block there are a couple of CoreFoundation details worth tightening up:

  • CFPreferencesCopyAppValue follows the “Create/Copy” rule, so cfaLangs should be CFReleased once you’re done with it.
  • cfaLangs is assumed to be a non‑null CFArrayRef with at least one element; if that assumption ever fails (unexpected prefs state), CFArrayGetValueAtIndex((CFArrayRef)cfaLangs, 0) could crash.

Consider adding:

  • A null/type check (and, ideally, CFArrayGetCount(...) > 0) before CFArrayGetValueAtIndex.
  • A corresponding CFRelease(cfaLangs) before every return path that uses it.

These are preexisting issues but easy to address in this touched function without changing its external behavior.

After adjusting, please test startup on macOS with normal and customized language settings to ensure os_lang is still set as expected and no new crashes occur in query_language().

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3eac307 and 719c377.

📒 Files selected for processing (3)
  • src/mumble/GlobalShortcut_macx.mm (2 hunks)
  • src/mumble/Overlay_macx.mm (1 hunks)
  • src/mumble/os_macx.mm (1 hunks)
🔇 Additional comments (2)
src/mumble/Overlay_macx.mm (1)

80-128: Autorelease pool migration in appLaunched: keeps behavior intact

Using @autoreleasepool here is correct in this MRC file: all Objective‑C objects created in the block stay scoped to the pool, and the early return when the launched app is the main bundle will still drain the pool on exit. The exclusion‑mode logic and overlayEnabled handling are preserved as before, with no new lifetime issues introduced.

Please rerun the overlay‑injection path on app launch (including the self‑bundle early‑return case) to confirm behavior matches pre‑change.

src/mumble/GlobalShortcut_macx.mm (1)

115-121: Overlay forwarding path: @autoreleasepool conversion looks correct

The new @autoreleasepool around creating and queuing NSEvent *evt preserves the previous semantics: autoreleased intermediates are drained, while the explicit retain/release pair for evt still governs its lifetime across the queued connection. Returning nullptr immediately after the block maintains the original behavior of consuming events when forward && Global::get().ocIntercept is true.

Please verify via manual testing that forwarded mouse/keyboard events still reach forwardEvent and are no longer passed back to the system when the overlay is active, matching prior behavior.

@klobucar klobucar force-pushed the jk-autorelese-macos branch from 719c377 to 873ca6a Compare November 25, 2025 01:46
@klobucar klobucar changed the title fix(macos): Use @autoreleasepool vs NSAutoreleasePool FIXmacos): Use @autoreleasepool vs NSAutoreleasePool Nov 25, 2025
@klobucar klobucar force-pushed the jk-autorelese-macos branch from 873ca6a to e27d277 Compare November 25, 2025 01:47
@klobucar
Copy link
Author

@coderabbitai help

@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@klobucar
Copy link
Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@klobucar
Copy link
Author

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Nov 25, 2025

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/mumble/os_macx.mm (1)

23-36: query_language autorelease pool change preserves behavior; consider tightening CFPreferences handling

The switch to @autoreleasepool here looks fine: static char lang[16]; inside the block still has static storage duration, so os_lang = lang; remains valid after the pool drains, and the control flow is unchanged.

While you’re touching this code, there are a couple of long‑standing robustness gaps that would be good to fix (not introduced by this PR):

  • CFPreferencesCopyAppValue can return nullptr or a non‑array; CFArrayGetValueAtIndex((CFArrayRef)cfaLangs, 0) on that would be undefined.
  • The CFPropertyListRef returned by CFPreferencesCopyAppValue is never CFRelease’d (minor one‑shot leak from os_init()).

If you want to harden this, something along these lines would be safer:

-        cfaLangs = CFPreferencesCopyAppValue(CFSTR("AppleLanguages"), kCFPreferencesCurrentApplication);
-        cfsLang = (CFStringRef) CFArrayGetValueAtIndex((CFArrayRef)cfaLangs, 0);
-
-        if (! CFStringGetCString(cfsLang, lang, 16, kCFStringEncodingUTF8))
-            return;
-
-        os_lang = lang;
+        cfaLangs = CFPreferencesCopyAppValue(CFSTR("AppleLanguages"), kCFPreferencesCurrentApplication);
+        if (cfaLangs && CFGetTypeID(cfaLangs) == CFArrayGetTypeID()
+            && CFArrayGetCount((CFArrayRef)cfaLangs) > 0) {
+            cfsLang = (CFStringRef) CFArrayGetValueAtIndex((CFArrayRef)cfaLangs, 0);
+            if (CFStringGetCString(cfsLang, lang, sizeof(lang), kCFStringEncodingUTF8)) {
+                os_lang = lang;
+            }
+        }
+        if (cfaLangs) {
+            CFRelease(cfaLangs);
+        }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 719c377 and e27d277.

📒 Files selected for processing (3)
  • src/mumble/GlobalShortcut_macx.mm (2 hunks)
  • src/mumble/Overlay_macx.mm (1 hunks)
  • src/mumble/os_macx.mm (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: PR (Docs)
  • GitHub Check: PR (macOS)
  • GitHub Check: PR (Translations)
  • GitHub Check: PR (Windows_x64)
  • GitHub Check: PR (Linux)
🔇 Additional comments (2)
src/mumble/GlobalShortcut_macx.mm (1)

115-121: Autorelease pool usage around forwarded NSEvent looks correct

The new @autoreleasepool around the overlay forwarding path is fine in a non‑ARC, manual retain/release setup:

  • eventWithCGEvent: returns an autoreleased NSEvent; the explicit retain keeps it alive past the pool drain.
  • forwardEvent eventually calls [event release];, so there’s no leak.
  • Returning nullptr when forward && ocIntercept is true preserves the early‑exit behavior for intercepted events.

No changes needed here.

src/mumble/Overlay_macx.mm (1)

80-129: appLaunched: refactor to @autoreleasepool and reformatted switch looks safe

The new @autoreleasepool around the active branch, plus moving userInfo/bundleId/SBApplication usage inside it, matches the previous lifetime expectations and keeps all Cocoa objects scoped to the pool.

The rewritten switch (Global::get().s.os.oemOverlayExcludeMode):

  • Still enables the overlay unconditionally for LauncherFilterExclusionMode (with the same log).
  • Enables only when the bundle is whitelisted for WhitelistExclusionMode.
  • Enables only when the bundle is not blacklisted for BlacklistExclusionMode.
  • Uses explicit braces and breaks, so there’s no fall‑through risk.

Early return when launching the main bundle is preserved, just inside the pool now. Overall, behavior and memory management look correct.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
src/mumble/GlobalShortcut_macx.mm (1)

205-235: Still a potential crash when processName is nil in dumpEventTaps

processName is initialized to nil and only set when NSRunningApplication *app is found. If app is nil, [processName UTF8String] yields a null pointer and the %s in qWarning can dereference it and crash. The new @autoreleasepool doesn’t change this.

You can guard it like this:

-				NSString *processName = nil;
-				NSRunningApplication *app = [NSRunningApplication runningApplicationWithProcessIdentifier: info->processBeingTapped];
-				if (app) {
-					processName = [app localizedName];
-				}
+				NSString *processName = nil;
+				NSRunningApplication *app =
+				    [NSRunningApplication runningApplicationWithProcessIdentifier:info->processBeingTapped];
+				if (app) {
+					processName = [app localizedName];
+				}
@@
-				qWarning("  tappingProcess = %i (%s)", info->tappingProcess, [processName UTF8String]);
+				const char *processNameUtf8 = processName ? [processName UTF8String] : "unknown";
+				qWarning("  tappingProcess = %i (%s)", info->tappingProcess, processNameUtf8);

This keeps the logging detail but guarantees a non-null %s argument.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3eac307 and e27d277.

📒 Files selected for processing (3)
  • src/mumble/GlobalShortcut_macx.mm (2 hunks)
  • src/mumble/Overlay_macx.mm (1 hunks)
  • src/mumble/os_macx.mm (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: PR (Docs)
  • GitHub Check: PR (macOS)
  • GitHub Check: PR (Translations)
  • GitHub Check: PR (Windows_x64)
  • GitHub Check: PR (Linux)
🔇 Additional comments (2)
src/mumble/Overlay_macx.mm (1)

83-128: appLaunched: pool and exclusion-mode switch look good

Using @autoreleasepool here is appropriate for the Cocoa/SBApplication objects, and the refactored oemOverlayExcludeMode switch (with explicit breaks and per‑mode blocks) preserves the previous logic while improving readability. No functional issues spotted.

src/mumble/GlobalShortcut_macx.mm (1)

115-121: Overlay event forwarding pool is correct

Wrapping the NSEvent creation and QMetaObject::invokeMethod in @autoreleasepool keeps Cocoa allocations bounded, while the explicit retain and later release in forwardEvent() preserve the lifetime across the queued connection. Returning nullptr to swallow the event when forwarding to the overlay matches the intended behavior.

@klobucar klobucar changed the title FIXmacos): Use @autoreleasepool vs NSAutoreleasePool FIX(macos): Use @autoreleasepool vs NSAutoreleasePool Nov 25, 2025
@klobucar
Copy link
Author

Do you want me to add these suggestions in?

- Replace [dict objectForKey:] with modern subscripting syntax dict[key]
- Replace NSAutoreleasePool with @autoreleasepool blocks
- Replace deprecated AudioDeviceGetProperty with AudioObjectGetPropertyData
- Remove obsolete macOS version checks for < 10.15
- Remove dead 32-bit code (__LP64__ guards)
- Remove unnecessary respondsToSelector: checks for APIs available in 10.15+

- Fix potential crash in dumpEventTaps when process name is nil
- Fix memory leak in query_language by adding proper CFRelease calls
- Add defensive null checks in query_language for CFPreferencesCopyAppValue
- Fix unused variable warning in AppNap.mm
- Remove duplicate [reason release] call

- Remove deprecated API warning suppressions from CoreAudio.mm and Overlay_macx.mm
- Comment out deprecated AuthorizationExecuteWithPrivileges with migration note
@klobucar klobucar force-pushed the jk-autorelese-macos branch from e27d277 to ff23d2c Compare November 26, 2025 01:54
@klobucar klobucar changed the title FIX(macos): Use @autoreleasepool vs NSAutoreleasePool FIX(macos): Update some of macOS obj-c code for 10.15 minimum Nov 26, 2025
@klobucar
Copy link
Author

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

✅ Actions performed

Full review triggered.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/mumble/Overlay_macx.mm (1)

320-336: Make authExec explicitly a disabled stub instead of doing a dummy wait()

With AuthorizationExecuteWithPrivileges removed, authExec now waits on a non‑existent child and always returns false, and argv is unused. That’s functionally a no‑op, but the remaining wait()/status logic is misleading.

You could simplify this to a clear stub that documents that privileged uninstall is disabled on 10.15+:

 static bool authExec(AuthorizationRef ref, const char **argv) {
-    OSStatus err = noErr;
-    int pid = 0, status = 0;
-
-    // Deprecated: AuthorizationExecuteWithPrivileges removed. Consider using SMJobBless or a helper tool for privileged operations.
-    if (err == errAuthorizationSuccess) {
-        do {
-            pid = wait(&status);
-        } while (pid == -1 && errno == EINTR);
-        return (pid != -1 && WIFEXITED(status) && WEXITSTATUS(status) == 0);
-    }
-
-    qWarning("Overlay_macx: Failed to AuthorizeExecuteWithPrivileges. (err=%i)", err);
-    qWarning("Overlay_macx: Status: (pid=%i, exited=%u, exitStatus=%u)", pid, WIFEXITED(status), WEXITSTATUS(status));
-
-    return false;
+    Q_UNUSED(ref);
+    Q_UNUSED(argv);
+
+    qWarning("Overlay_macx: authExec is disabled because AuthorizationExecuteWithPrivileges is "
+             "deprecated/removed on macOS 10.15+. Uninstall must be handled by a new helper (e.g. SMJobBless) "
+             "or manually.");
+    return false;
 }

This makes it obvious to future readers that uninstall is intentionally disabled until a new privileged helper is implemented.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3eac307 and ff23d2c.

📒 Files selected for processing (6)
  • src/mumble/AppNap.mm (1 hunks)
  • src/mumble/CoreAudio.mm (3 hunks)
  • src/mumble/GlobalShortcut_macx.mm (3 hunks)
  • src/mumble/Overlay_macx.mm (3 hunks)
  • src/mumble/TextToSpeech_macx.mm (1 hunks)
  • src/mumble/os_macx.mm (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: PR (Windows_x64)
  • GitHub Check: PR (Translations)
  • GitHub Check: PR (Docs)
  • GitHub Check: PR (Linux)
  • GitHub Check: PR (macOS)
  • GitHub Check: freebsd
🔇 Additional comments (11)
src/mumble/CoreAudio.mm (2)

16-17: Good: Removed blanket deprecation warning suppression.

Removing the file-wide #pragma clang diagnostic ignored "-Wdeprecated-declarations" is the right approach. This ensures any remaining deprecated API usage will be flagged during compilation.


719-720: LGTM: Correct migration from deprecated AudioDeviceGetProperty to AudioObjectGetPropertyData.

The new call correctly uses the already-defined propertyAddress structure (set to kAudioDevicePropertyBufferFrameSize on line 714) and follows the same pattern used elsewhere in the file.

src/mumble/TextToSpeech_macx.mm (1)

135-137: LGTM: Safe removal of respondsToSelector: check.

setVolume: has been available on NSSpeechSynthesizer since macOS 10.5, so the runtime check is unnecessary with a 10.15 minimum target. The volume scaling from 0-100 to 0.0-1.0 is correct.

src/mumble/os_macx.mm (1)

23-48: LGTM: Properly addresses memory leak and crash potential.

The implementation now:

  • Validates cfaLangs is non-null, is actually a CFArray, and has at least one element before accessing
  • Correctly releases cfaLangs on all code paths (early returns and success)
  • Uses sizeof(lang) instead of hardcoded 16 for the buffer size

This addresses the concerns raised in the previous review.

src/mumble/AppNap.mm (2)

21-22: LGTM: Cleaner NSString construction.

Using initWithCharacters:length: with QString::unicode() is a direct and correct way to create an NSString from a QString's UTF-16 data.


24-29: LGTM: Safe removal of version guards.

disableAutomaticTermination: and enableAutomaticTermination: have been available since macOS 10.7, so they can be called unconditionally with a 10.15 minimum target.

src/mumble/GlobalShortcut_macx.mm (3)

115-121: LGTM: Proper autoreleasepool scoping for NSEvent.

Wrapping the NSEvent creation in @autoreleasepool ensures any temporary autorelease objects are cleaned up promptly. The retain on line 117 ensures the event survives past the pool for later use in forwardEvent. Moving return nullptr inside the block is correct—the pool drains before the return executes.


193-224: LGTM: Crash fix for nil processName and proper autoreleasepool usage.

The previous review identified a crash when processName is nil. Line 213 now correctly handles this:

const char *processNameUtf8 = processName ? [processName UTF8String] : "unknown";

The @autoreleasepool block appropriately scopes the NSRunningApplication lookups, ensuring their associated autorelease objects are released promptly.


174-176: LGTM: Simplified keyboard layout initialization.

Removal of version-specific fallback guards aligns with the 10.15 minimum requirement.

src/mumble/Overlay_macx.mm (2)

78-126: Autorelease pool migration and overlay selection logic look good

The move to @autoreleasepool and dictionary subscripting is correct, and the whitelist/blacklist handling now clearly matches the exclusion mode semantics. No functional issues spotted here.


305-315: Keyed subscripting for MumbleOverlayVersion is fine

Using infoPlist[@"MumbleOverlayVersion"] with unsignedIntegerValue is an idiomatic drop‑in replacement for the old objectForKey: usage; this block looks good.

Copy link
Member

@Krzmbrzl Krzmbrzl left a comment

Choose a reason for hiding this comment

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

@maxer137 would you mind having a look at this as well? I don't know Objective C and hence am somewhat poorly qualified to review this PR xD
If you don't have the time/motivation, please let me know and I'll merge as-is.


// Ignore deprecation warnings for the whole file, for now.
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"

Copy link
Member

Choose a reason for hiding this comment

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

The comment above should be removed as well

Copy link
Author

Choose a reason for hiding this comment

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

Yeah, definitely can do

int pid = 0, status = 0;

err = AuthorizationExecuteWithPrivileges(ref, argv[0], kAuthorizationFlagDefaults, const_cast<char * const *>(&argv[1]), nullptr);
// Deprecated: AuthorizationExecuteWithPrivileges removed. Consider using SMJobBless or a helper tool for privileged operations.
Copy link
Member

Choose a reason for hiding this comment

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

It seems like this effectively removes the entire functionality of authExec - in that case, we should return false (with a log message stating that this needs to be reimplemented.

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of removing the functionality entirely, we can replace it with a supported approach.
From what I can gather, the main action in the uninstallFiles function is running the command

/bin/mv /Library/ScriptingAdditions/MumbleOverlay.osax /tmp/%1_Uninstalled_MumbleOverlay.osax

We can achieve the same effect using AppleScript.
NSAppleScript provides the command do shell script ... with administrator privileges. Where ... is the command we want to run. This way, we could remove the authExec function entirely and update the rest of uninstallFiles to use the modern API.

From the AppleScript documentation under do shell script:

Execute the command as the administrator. Once a script is correctly authenticated, it will not ask for authentication again for five minutes. The elevated privileges and the grace period do not extend to any other scripts or to the rest of the system.

We can use the NSAppleScript class to create the commands and execute them. This should keep the functionality the same but use the supported Apple API.

@maxer137
Copy link
Contributor

@maxer137 would you mind having a look at this as well?

Sure! I’ve been quite busy with university, so I apologise on my recent absence. But I’ll take a look at this PR today!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants