From 3259824617bde0db37c8df533a54c8104cfeb15e Mon Sep 17 00:00:00 2001 From: Dakai Date: Fri, 22 Nov 2024 16:59:50 +0800 Subject: [PATCH 1/5] Update README.md minor typo fix to the sshfs mount command --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d3b0e76..1915055 100644 --- a/README.md +++ b/README.md @@ -246,7 +246,7 @@ The easiest and most secure way is `sshfs` ```bash # on Linux/Windows mkdir ~/mnt/osx -sshfs user@localhost:/ -p 50922 ~/mnt/osx +sshfs user@localhost: -p 50922 ~/mnt/osx # wait a few seconds, and ~/mnt/osx will have full rootfs mounted over ssh, and in userspace # automated: sshpass -p sshfs user@localhost:/ -p 50922 ~/mnt/osx ``` From 69f6e7d0cf7ad3a749856ab364c3708ca23f582c Mon Sep 17 00:00:00 2001 From: akshaynexus Date: Wed, 30 Apr 2025 04:02:02 +0700 Subject: [PATCH 2/5] Update README.md to add troubleshooting steps for Apple ID/iMessage/iCloud login issues in macOS VM. --- README.md | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 62d061a..bbc61a5 100644 --- a/README.md +++ b/README.md @@ -251,7 +251,7 @@ docker run -it \ -p 50922:10022 \ -v "${PWD}/mac_hdd_ng_auto_monterey.img:/image" \ -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0.0}" \ + -e "DISPLAY=${DISPLAY:-:0}" \ -e "USERNAME=user" \ -e "PASSWORD=alpine" \ -e GENERATE_UNIQUE=true \ @@ -1954,3 +1954,125 @@ You may when initialising or booting into a container see errors from the `(qemu `ALSA lib blahblahblah: (function name) returned error: no such file or directory`. These are more or less expected. As long as you are able to boot into the container and everything is working, no reason to worry about these. See also: [here](https://github.com/sickcodes/Docker-OSX/issues/174). + +### Cannot Login to Apple ID / iMessage / iCloud / App Store + +Some users may experience issues logging into Apple services like the App Store, iMessage, or iCloud within the macOS VM. This is often due to Apple identifying the system as a virtual machine and refusing service. You can often resolve this by patching the kernel to hide the VM presence. There are two common methods to apply this patch: + +#### Method 1: Using OCAT (OpenCore Auxiliary Tools) GUI + +If you are using the OCAT GUI to manage your OpenCore configuration: + +1. Navigate to the `Kernel` section. +2. Go to the `Patch` subsection. +3. Add two new patch entries with the following details: + + **Patch 1:** + * **Identifier:** `kernel` + * **Base:** (leave empty) + * **Count:** `1` + * **Find (Hex):** `68696265726E61746568696472656164790068696265726E617465636F756E7400` + * **Limit:** `0` + * **Mask:** (leave empty) + * **Replace (Hex):** `68696265726E61746568696472656164790068765F766D6D5F70726573656E7400` + * **Skip:** `0` + * **Arch:** `x86_64` + * **MinKernel:** `20.4.0` (or appropriate for your macOS version, check OpenCore docs if unsure) + * **MaxKernel:** (leave empty) + * **Enabled:** `True` + * **Comment:** `Sonoma VM BT Enabler - PART 1 of 2 - Patch kern.hv_vmm_present=0` (or similar descriptive comment) + + **Patch 2:** + * **Identifier:** `kernel` + * **Base:** (leave empty) + * **Count:** `1` + * **Find (Hex):** `626F6F742073657373696F6E20555549440068765F766D6D5F70726573656E7400` + * **Limit:** `0` + * **Mask:** (leave empty) + * **Replace (Hex):** `626F6F742073657373696F6E20555549440068696265726E617465636F756E7400` + * **Skip:** `0` + * **Arch:** `x86_64` + * **MinKernel:** `22.0.0` (or appropriate for your macOS version, check OpenCore docs if unsure) + * **MaxKernel:** (leave empty) + * **Enabled:** `True` + * **Comment:** `Sonoma VM BT Enabler - PART 2 of 2 - Patch kern.hv_vmm_present=0` (or similar descriptive comment) + +4. Save the configuration and reboot the VM. + +#### Method 2: Directly Editing `config.plist` + +Alternatively, you can add the patches directly to your `config.plist` file (usually located on the EFI partition). Find the `Kernel` -> `` -> `Patch` -> `` section and add the following two `` entries within the ``: + +```xml + + Arch + x86_64 + Base + + Comment + Sonoma VM BT Enabler - PART 1 of 2 - Patch kern.hv_vmm_present=0 + Count + 1 + Enabled + + Find + aGliZXJuYXRlaGlkcmVhZHkAaGliZXJuYXRlY291bnQA + Identifier + kernel + Limit + 0 + Mask + + MaxKernel + + MinKernel + 20.4.0 + Replace + aGliZXJuYXRlaGlkcmVhZHkAaHZfdm1tX3ByZXNlbnQA + ReplaceMask + + Skip + 0 + + + Arch + x86_64 + Base + + Comment + Sonoma VM BT Enabler - PART 2 of 2 - Patch kern.hv_vmm_present=0 + Count + 1 + Enabled + + Find + Ym9vdCBzZXNzaW9uIFVVSUQAaHZfdm1tX3ByZXNlbnQA + Identifier + kernel + Limit + 0 + Mask + + MaxKernel + + MinKernel + 22.0.0 + Replace + Ym9vdCBzZXNzaW9uIFVVSUQAaGliZXJuYXRlY291bnQA + ReplaceMask + + Skip + 0 + +``` + +Make sure these `` entries are correctly placed within the `` alongside any existing patches. Save the `config.plist` and reboot the VM. + +**Note:** The `MinKernel` values (`20.4.0` and `22.0.0`) might need adjustment depending on the specific macOS version you are running (e.g., Monterey, Ventura, Sonoma). Consult OpenCore documentation or community resources for the appropriate values for your setup if you encounter issues. Applying these patches should allow Apple services to function correctly within the VM. + + +## More Questions and Answers + +Big thank you to our contributors who have worked out almost every conceivable issue so far! + +[https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md](https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md) From b282993a4a3bf6cb379cbcf406cc81c8d7582fe2 Mon Sep 17 00:00:00 2001 From: akshaynexus Date: Thu, 1 May 2025 06:00:47 +0700 Subject: [PATCH 3/5] Add detailed guide for fixing Apple ID login issues in macOS VMs, including kernel patching methods and a new utility script for applying patches. --- FAQ.md | 179 +++++++++++++++++++++++++++ README.md | 122 ------------------ scripts/apply_appleid_kernelpatch.py | 92 ++++++++++++++ 3 files changed, 271 insertions(+), 122 deletions(-) create mode 100644 scripts/apply_appleid_kernelpatch.py diff --git a/FAQ.md b/FAQ.md index 64d21c5..2bb3607 100644 --- a/FAQ.md +++ b/FAQ.md @@ -160,6 +160,185 @@ If you wind up in the installer again after you've installed macOS it means you Congratulations, you got a macOS VM up and running! Now what? +# Fixing Apple ID Login Issues in macOS Virtual Machines + +## Problem Overview + +When running macOS in a virtual machine, you may encounter problems logging into Apple services including: +- Apple ID +- iMessage +- iCloud +- App Store + +This happens because Apple's services can detect that macOS is running in a virtual environment and block access. The solution is to apply a kernel patch that hides the VM presence from Apple's detection mechanism. + +NOTE as per forum post: Unfortunately, this would very possibly break qemu-guest-agent, which is necessary for the host getting VM status or taking hot snapshot while the VM is running. This is because qemu-guest-agent also checks the hv_vmm_present flag, but only works if it is true (=1). + +Use at your own risk. Hope it would help. + +## Solution: Kernel Patching + +This guide provides three methods to apply the necessary kernel patch. All methods implement the same fix originally described in [this forum post](https://forum.proxmox.com/threads/anyone-can-make-bluetooth-work-on-sonoma.153301/#post-697832). + +### Prerequisites + +Before proceeding with any method: +- Make sure you can access your EFI partition +- Locate your OpenCore `config.plist` file (typically in the `EFI/OC` folder) +- Back up your current `config.plist` before making changes + +## Method 1: Using the Utility Script (Simplest Approach) + +This is the fastest and easiest way to apply the patch. + +1. Mount your EFI partition using Clover Configurator or another EFI mounting tool +2. Download the patch script: + ```bash + wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/scripts/apply_appleid_kernelpatch.py + ``` +3. Run the script with your `config.plist` file path: + ```bash + python3 apply_appleid_kernelpatch.py /path/to/config.plist + ``` + +**Pro Tip**: You can drag and drop the `config.plist` file into your terminal after typing `python3 apply_appleid_kernelpatch.py` for an easy path insertion. + +**Note**: If you encounter a "permission denied" error, run the command with `sudo`: +```bash +sudo python3 apply_appleid_kernelpatch.py /path/to/config.plist +``` + +## Method 2: Using OCAT (OpenCore Auxiliary Tools) GUI + +If you prefer a graphical approach: + +1. Open OCAT and load your `config.plist` +2. Navigate to the **Kernel** section +3. Go to the **Patch** subsection +4. Add two new patch entries with the following details: + +### Patch 1 +| Setting | Value | +|---------|-------| +| **Identifier** | `kernel` | +| **Base** | *(leave empty)* | +| **Count** | `1` | +| **Find (Hex)** | `68696265726E61746568696472656164790068696265726E617465636F756E7400` | +| **Limit** | `0` | +| **Mask** | *(leave empty)* | +| **Replace (Hex)** | `68696265726E61746568696472656164790068765F766D6D5F70726573656E7400` | +| **Skip** | `0` | +| **Arch** | `x86_64` | +| **MinKernel** | `20.4.0` | +| **MaxKernel** | *(leave empty)* | +| **Enabled** | `True` | +| **Comment** | `Sonoma VM BT Enabler - PART 1 of 2 - Patch kern.hv_vmm_present=0` | + +### Patch 2 +| Setting | Value | +|---------|-------| +| **Identifier** | `kernel` | +| **Base** | *(leave empty)* | +| **Count** | `1` | +| **Find (Hex)** | `626F6F742073657373696F6E20555549440068765F766D6D5F70726573656E7400` | +| **Limit** | `0` | +| **Mask** | *(leave empty)* | +| **Replace (Hex)** | `626F6F742073657373696F6E20555549440068696265726E617465636F756E7400` | +| **Skip** | `0` | +| **Arch** | `x86_64` | +| **MinKernel** | `22.0.0` | +| **MaxKernel** | *(leave empty)* | +| **Enabled** | `True` | +| **Comment** | `Sonoma VM BT Enabler - PART 2 of 2 - Patch kern.hv_vmm_present=0` | + +5. Save the configuration +6. Reboot your VM + +## Method 3: Direct `config.plist` Editing + +For users who prefer to manually edit the configuration file: + +1. Mount your EFI partition +2. Locate and open your `config.plist` file in a text editor +3. Find the `Kernel` → `` → `Patch` → `` section +4. Add these two `` entries within the ``: + +```xml + + Arch + x86_64 + Base + + Comment + Sonoma VM BT Enabler - PART 1 of 2 - Patch kern.hv_vmm_present=0 + Count + 1 + Enabled + + Find + aGliZXJuYXRlaGlkcmVhZHkAaGliZXJuYXRlY291bnQA + Identifier + kernel + Limit + 0 + Mask + + MaxKernel + + MinKernel + 20.4.0 + Replace + aGliZXJuYXRlaGlkcmVhZHkAaHZfdm1tX3ByZXNlbnQA + ReplaceMask + + Skip + 0 + + + Arch + x86_64 + Base + + Comment + Sonoma VM BT Enabler - PART 2 of 2 - Patch kern.hv_vmm_present=0 + Count + 1 + Enabled + + Find + Ym9vdCBzZXNzaW9uIFVVSUQAaHZfdm1tX3ByZXNlbnQA + Identifier + kernel + Limit + 0 + Mask + + MaxKernel + + MinKernel + 22.0.0 + Replace + Ym9vdCBzZXNzaW9uIFVVSUQAaGliZXJuYXRlY291bnQA + ReplaceMask + + Skip + 0 + +``` + +5. Save the file +6. Reboot your VM + +## Important Notes + +- The `MinKernel` values (`20.4.0` and `22.0.0`) may need adjustment depending on your specific macOS version (Monterey, Ventura, Sonoma, etc.) +- If you encounter issues, consult the [OpenCore documentation](https://dortania.github.io/docs/) for appropriate values for your setup +- Always back up your configuration before making changes +- After applying the patch and rebooting, try signing into Apple services again + +## What This Patch Does + +This patch tricks macOS into believing it's running on physical hardware by redirecting the `hv_vmm_present` kernel variable, which normally indicates VM presence. After applying the patch, Apple services should function normally within your virtual environment. ### Slow UI The macOS UI expects and relies on GPU acceleration, and there is (currently) no way to provide GPU acceleration in the virtual hardware. See [osx-optimizer](https://github.com/sickcodes/osx-optimizer) for macOS configuration to speed things up. diff --git a/README.md b/README.md index bbc61a5..b77967e 100644 --- a/README.md +++ b/README.md @@ -1954,125 +1954,3 @@ You may when initialising or booting into a container see errors from the `(qemu `ALSA lib blahblahblah: (function name) returned error: no such file or directory`. These are more or less expected. As long as you are able to boot into the container and everything is working, no reason to worry about these. See also: [here](https://github.com/sickcodes/Docker-OSX/issues/174). - -### Cannot Login to Apple ID / iMessage / iCloud / App Store - -Some users may experience issues logging into Apple services like the App Store, iMessage, or iCloud within the macOS VM. This is often due to Apple identifying the system as a virtual machine and refusing service. You can often resolve this by patching the kernel to hide the VM presence. There are two common methods to apply this patch: - -#### Method 1: Using OCAT (OpenCore Auxiliary Tools) GUI - -If you are using the OCAT GUI to manage your OpenCore configuration: - -1. Navigate to the `Kernel` section. -2. Go to the `Patch` subsection. -3. Add two new patch entries with the following details: - - **Patch 1:** - * **Identifier:** `kernel` - * **Base:** (leave empty) - * **Count:** `1` - * **Find (Hex):** `68696265726E61746568696472656164790068696265726E617465636F756E7400` - * **Limit:** `0` - * **Mask:** (leave empty) - * **Replace (Hex):** `68696265726E61746568696472656164790068765F766D6D5F70726573656E7400` - * **Skip:** `0` - * **Arch:** `x86_64` - * **MinKernel:** `20.4.0` (or appropriate for your macOS version, check OpenCore docs if unsure) - * **MaxKernel:** (leave empty) - * **Enabled:** `True` - * **Comment:** `Sonoma VM BT Enabler - PART 1 of 2 - Patch kern.hv_vmm_present=0` (or similar descriptive comment) - - **Patch 2:** - * **Identifier:** `kernel` - * **Base:** (leave empty) - * **Count:** `1` - * **Find (Hex):** `626F6F742073657373696F6E20555549440068765F766D6D5F70726573656E7400` - * **Limit:** `0` - * **Mask:** (leave empty) - * **Replace (Hex):** `626F6F742073657373696F6E20555549440068696265726E617465636F756E7400` - * **Skip:** `0` - * **Arch:** `x86_64` - * **MinKernel:** `22.0.0` (or appropriate for your macOS version, check OpenCore docs if unsure) - * **MaxKernel:** (leave empty) - * **Enabled:** `True` - * **Comment:** `Sonoma VM BT Enabler - PART 2 of 2 - Patch kern.hv_vmm_present=0` (or similar descriptive comment) - -4. Save the configuration and reboot the VM. - -#### Method 2: Directly Editing `config.plist` - -Alternatively, you can add the patches directly to your `config.plist` file (usually located on the EFI partition). Find the `Kernel` -> `` -> `Patch` -> `` section and add the following two `` entries within the ``: - -```xml - - Arch - x86_64 - Base - - Comment - Sonoma VM BT Enabler - PART 1 of 2 - Patch kern.hv_vmm_present=0 - Count - 1 - Enabled - - Find - aGliZXJuYXRlaGlkcmVhZHkAaGliZXJuYXRlY291bnQA - Identifier - kernel - Limit - 0 - Mask - - MaxKernel - - MinKernel - 20.4.0 - Replace - aGliZXJuYXRlaGlkcmVhZHkAaHZfdm1tX3ByZXNlbnQA - ReplaceMask - - Skip - 0 - - - Arch - x86_64 - Base - - Comment - Sonoma VM BT Enabler - PART 2 of 2 - Patch kern.hv_vmm_present=0 - Count - 1 - Enabled - - Find - Ym9vdCBzZXNzaW9uIFVVSUQAaHZfdm1tX3ByZXNlbnQA - Identifier - kernel - Limit - 0 - Mask - - MaxKernel - - MinKernel - 22.0.0 - Replace - Ym9vdCBzZXNzaW9uIFVVSUQAaGliZXJuYXRlY291bnQA - ReplaceMask - - Skip - 0 - -``` - -Make sure these `` entries are correctly placed within the `` alongside any existing patches. Save the `config.plist` and reboot the VM. - -**Note:** The `MinKernel` values (`20.4.0` and `22.0.0`) might need adjustment depending on the specific macOS version you are running (e.g., Monterey, Ventura, Sonoma). Consult OpenCore documentation or community resources for the appropriate values for your setup if you encounter issues. Applying these patches should allow Apple services to function correctly within the VM. - - -## More Questions and Answers - -Big thank you to our contributors who have worked out almost every conceivable issue so far! - -[https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md](https://github.com/sickcodes/Docker-OSX/blob/master/CREDITS.md) diff --git a/scripts/apply_appleid_kernelpatch.py b/scripts/apply_appleid_kernelpatch.py new file mode 100644 index 0000000..58feb7e --- /dev/null +++ b/scripts/apply_appleid_kernelpatch.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +import plistlib +import base64 +import os +import sys + +def add_kernel_patches(config_path): + # Make a backup of the original file + backup_path = config_path + '.backup' + os.system(f'cp "{config_path}" "{backup_path}"') + print(f"Backup created at {backup_path}") + + # Read the plist file + with open(config_path, 'rb') as f: + config = plistlib.load(f) + + # Prepare the patch entries + patch1 = { + 'Arch': 'x86_64', + 'Base': '', + 'Comment': 'Sonoma VM BT Enabler - PART 1 of 2 - Patch kern.hv_vmm_present=0', + 'Count': 1, + 'Enabled': True, + 'Find': base64.b64decode('aGliZXJuYXRlaGlkcmVhZHkAaGliZXJuYXRlY291bnQA'), + 'Identifier': 'kernel', + 'Limit': 0, + 'Mask': b'', + 'MaxKernel': '', + 'MinKernel': '20.4.0', + 'Replace': base64.b64decode('aGliZXJuYXRlaGlkcmVhZHkAaHZfdm1tX3ByZXNlbnQA'), + 'ReplaceMask': b'', + 'Skip': 0, + } + + patch2 = { + 'Arch': 'x86_64', + 'Base': '', + 'Comment': 'Sonoma VM BT Enabler - PART 2 of 2 - Patch kern.hv_vmm_present=0', + 'Count': 1, + 'Enabled': True, + 'Find': base64.b64decode('Ym9vdCBzZXNzaW9uIFVVSUQAaHZfdm1tX3ByZXNlbnQA'), + 'Identifier': 'kernel', + 'Limit': 0, + 'Mask': b'', + 'MaxKernel': '', + 'MinKernel': '22.0.0', + 'Replace': base64.b64decode('Ym9vdCBzZXNzaW9uIFVVSUQAaGliZXJuYXRlY291bnQA'), + 'ReplaceMask': b'', + 'Skip': 0, + } + + # Add patches to the kernel patch section + if 'Kernel' in config and 'Patch' in config['Kernel']: + # Check if patches already exist + patch_exists = False + for patch in config['Kernel']['Patch']: + if isinstance(patch, dict) and 'Comment' in patch: + if 'Sonoma VM BT Enabler' in patch['Comment']: + patch_exists = True + print(f"Patch already exists: {patch['Comment']}") + + if not patch_exists: + config['Kernel']['Patch'].append(patch1) + config['Kernel']['Patch'].append(patch2) + print("Added both Sonoma VM BT Enabler patches to config.plist") + + else: + print("Error: Could not find Kernel -> Patch section in config.plist") + return False + + # Write the updated plist file + with open(config_path, 'wb') as f: + plistlib.dump(config, f) + + print(f"Successfully updated {config_path}") + return True + +if __name__ == "__main__": + if len(sys.argv) != 2: + print("Usage: python apply_appleid_kernelpatch.py /path/to/config.plist") + sys.exit(1) + + config_path = sys.argv[1] + if not os.path.exists(config_path): + print(f"Error: File {config_path} does not exist") + sys.exit(1) + + success = add_kernel_patches(config_path) + if success: + print("Patches applied successfully. Please reboot to apply changes.") + else: + print("Failed to apply patches.") \ No newline at end of file From 74d8498ea679f7122635846d1c0f67ec587a6c75 Mon Sep 17 00:00:00 2001 From: akshaynexus Date: Thu, 1 May 2025 06:01:42 +0700 Subject: [PATCH 4/5] fix: remove unecessary change added --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b77967e..62d061a 100644 --- a/README.md +++ b/README.md @@ -251,7 +251,7 @@ docker run -it \ -p 50922:10022 \ -v "${PWD}/mac_hdd_ng_auto_monterey.img:/image" \ -v /tmp/.X11-unix:/tmp/.X11-unix \ - -e "DISPLAY=${DISPLAY:-:0}" \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ -e "USERNAME=user" \ -e "PASSWORD=alpine" \ -e GENERATE_UNIQUE=true \ From fa7baa5fc8be0e6c37b82885fa8cec5f8963169e Mon Sep 17 00:00:00 2001 From: akshaynexus Date: Thu, 1 May 2025 20:59:41 +0700 Subject: [PATCH 5/5] fix: use curl instead of wget --- FAQ.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FAQ.md b/FAQ.md index 2bb3607..804fec4 100644 --- a/FAQ.md +++ b/FAQ.md @@ -194,7 +194,7 @@ This is the fastest and easiest way to apply the patch. 1. Mount your EFI partition using Clover Configurator or another EFI mounting tool 2. Download the patch script: ```bash - wget https://raw.githubusercontent.com/sickcodes/Docker-OSX/scripts/apply_appleid_kernelpatch.py + curl -o apply_appleid_kernelpatch.py https://raw.githubusercontent.com/sickcodes/Docker-OSX/scripts/apply_appleid_kernelpatch.py ``` 3. Run the script with your `config.plist` file path: ```bash