Skip to content

Fix 'Operation not permitted' on USB drives + verbose log (supersedes #3) - #4

Merged
Hashim1999164 merged 6 commits into
mainfrom
fix/disk-access-verbose-log
Oct 17, 2026
Merged

Hashim1999164 merged 6 commits into
mainfrom
fix/disk-access-verbose-log

Conversation

@Hashim1999164

@Hashim1999164 Hashim1999164 commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Supersedes #3: it contains #3's commits plus the fixes below.

The bug

Pressing START with a Windows ISO (GPT / UEFI non-CSM / FAT32) failed with "Could not open /dev/rdisk9: Operation not permitted".

Cause: on main the helper was started as root through osascript … with administrator privileges and opened /dev/rdisk9 with plain open(). Since macOS 10.15, a raw disk open is refused with EPERM, even for root, unless the responsible app has Full Disk Access, so the very first step (writing the partition table in DiskPreparer.partition) failed. Running the app from the Desktop makes authorization even less reliable.

What changed

Disk access (from #3, reviewed and fixed)

  • Every /dev/diskN / /dev/rdiskN[sM] open in the pipeline goes through RawDevice. That covers partitioning, the re-probe, formatting, PBR, Syslinux, bad blocks, DD and save-image. On EPERM/EACCES it falls back to Apple's /usr/libexec/authopen, as balenaEtcher and Raspberry Pi Imager do. You get one password dialog per job and don't need Full Disk Access. The helper now runs as the user; only macOS installer jobs still run as root.
  • FAT12/16/32 and exFAT are formatted in-process, because newfs_* can't use the authorized descriptor. Unmounting, mounting and ejecting use diskutil, which needs no raw device access. Copying and splitting install.wim with wimlib write to the mounted volume, not the raw device.
  • Fixed: Fix 'Operation not permitted' on real drives; in-process FAT/exFAT #3 didn't compile (FATFormatter.dosDateTime: "unable to type-check this expression in reasonable time"), so its CI was red.
  • Fixed: the authorization environment item names were dangling C pointers. The compiler warned about this, and it was undefined behaviour.

Clear permission errors

  • New BootKitError.permissionDenied replaces the raw EPERM/EACCES text with numbered steps: move the app to /Applications, enter the password, grant Full Disk Access, close other apps using the drive. authopen exit statuses are mapped: EBUSY gets its own message.
  • AppLocation detects when the app runs from Desktop, Documents, Downloads, /Volumes or an App Translocation path. The main window then shows an orange banner with Show in Finder, and the warning is also logged.
  • If newfs_udf, mkntfs or mke2fs hit a permission error, the message suggests FAT32/exFAT. File-copy EPERM errors point to Files and Folders › Removable Volumes.
  • On failure, an alert shows the full multi-line explanation, and the log pane opens.
  • diskutil mount falls back to the default mount point if the private one is refused for a non-root user.

Verbose log

  • A new Log pane at the bottom of the main window has a Verbose switch, live auto-scroll, Copy, Save…, a folder button (shows the log file in Finder) and a pop-out window button. The Log window has the same switch and buttons.
  • The helper always logs at debug level:
    • the job parameters, plus uid/euid and the app location
    • every open() with its errno, the device geometry, and authopen invocations with exit status and fd
    • AuthorizationCreate / AuthorizationCopyRights OSStatus values
    • every diskutil / hdiutil / wimlib command with its exit status and stdout/stderr (all of it on failure, the last 6 lines on success)
    • one progress line per 10% of each phase, with bytes and speed
  • The helper process's own stdout/stderr go to helper-output.log and are tailed into the log as [helper output]. Timestamps now have millisecond precision; JobEvent dates use milliseconds.
  • Every entry is also written to ~/Library/Logs/RufusAdvanced/RufusAdvanced-<date>.log. The last 20 launches are kept, with full detail whatever the switch says.

Testing

  • CI on macOS 15 builds the package and the app bundle. Unit tests: 42 passed, including the new LoggingTests (log format, ms round-trip, shell exit/stdout/stderr logging, permission messages, EACCES mapping, log file, DOS date, authopen right names). Disk-image end-to-end tests: 8 passed.
  • Not tested: the authopen path on a real USB stick. CI test disks are user-owned disk images, so they never need authopen. The SwiftUI changes compile but haven't been looked at on screen. NTFS/UDF/ext4 formatting as a normal user is untested; those tools may still be refused by macOS, but the error now explains why.
  • Note: the disk-image test steps sometimes fail when DiskEngineTests and JobEndToEndTests run in parallel and grab the same diskN. This was already the case before this PR; the step is continue-on-error.

How to test on a Mac

git fetch origin && git checkout fix/disk-access-verbose-log
ARCHS=arm64 scripts/build-app.sh                 # or ARCHS=x86_64 on Intel
rm -rf /Applications/RufusAdvanced.app && ditto dist/RufusAdvanced.app /Applications/RufusAdvanced.app
open /Applications/RufusAdvanced.app

Turn on Verbose in the Log pane, pick the USB stick and the Windows ISO, choose GPT / UEFI (non CSM) / FAT32, then START. Enter your Mac password when asked. If it fails, click Save… in the log pane, or send the newest file in ~/Library/Logs/RufusAdvanced/.

Follow-up: show the finished drive in Finder

  • Eject the drive when finished is now off by default, both in the app setting and in JobSpec. The stored setting is reset to off once, through the ejectDefaultOffMigrated flag.
  • When eject is off, the helper releases any private or nobrowse mounts after the job. It then runs diskutil mountDisk diskN and retries for up to 20 s, until a volume is mounted under /Volumes without MNT_DONTBROWSE.
    • The mount point is logged at INFO; failed attempts are logged at DEBUG.
    • If remounting fails, the job still succeeds and shows a warning.
  • The status bar shows "Ready: mounted at /Volumes/…" with a Show in Finder button. When eject is on, it says "The drive was ejected and is safe to remove."
  • A new JobEvent.driveState(ejected:mountPoints:) event reports this to the app.
  • CLI: --eject ejects the drive, --no-mount leaves it unmounted.
  • New end-to-end test finishedDriveIsMountedForFinder, plus unit tests for the new defaults. CI: 44 unit and 9 disk-image tests pass.

Hashim1999164 and others added 5 commits October 17, 2026 19:49
macOS refuses raw opens of /dev/rdiskN (even as root) unless the app has
Full Disk Access. Raw disk access now goes through Apple's authopen with
one pre-authorized AuthorizationRef for the disk and its partitions, so a
single password dialog covers the whole job and no Full Disk Access is
needed. The helper runs as the user; only macOS installer jobs still use
a root helper.

- CBootKit: authopen descriptor passing (SCM_RIGHTS)
- DiskAuthorization: one dialog per disk, actionable error when the app
  runs from a privacy-protected folder
- FATFormatter: FAT12/16/32 and exFAT written in-process (newfs_* cannot
  open authopen devices), validated with fsck_msdos / fsck_exfat
- HFS+ via diskutil eraseVolume

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Hashim Khan <sardarhashim30@gmail.com>
@Hashim1999164
Hashim1999164 merged commit e775f94 into main Oct 17, 2026
1 check passed
@Hashim1999164
Hashim1999164 deleted the fix/disk-access-verbose-log branch October 17, 2026 18:03
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.

1 participant