NetFSMountURLSync call fails on Apple Silicon

I have an application that mounts network shares and for this I use NetFSMountURLSync. Nothing special here, just a plain application calling this. The application is not running as root, and not using launchd and/or a privileged helper or anything that elevates priviliges.

On Intel hardware, a Mac Pro trashcan and a 2016 MBP, both running Monterey (12.6), this works flawless and has been for several years now with different macOS versions (obviously).

Now I'm trying to build an Apple Silicon version on a MBP M1 Max also with Monterey 12.6.

  • I recompiled this as an Apple Silicon binary, however mounting failed.
  • Next I ran the Intel binary on Apple Silicon, but mounting fails here as well.

In both cases I get these error messages in Console (I'm not a Console expert):

<Applicationname> (loginsupport)
GetNetAuthAuthAgentPort: Calling bootstrap_look_up3() for com.apple.netauth.user.auth; uid = 501, euid = 501

<Applicationname> (loginsupport)
GetNetAuthAuthAgentPort: gNetAuthAuthAgentPort = 51463

<Applicationname> (launchservices)
LSExceptions shared instance invalidated for timeout.

Note: Running either binary (Intel/ARM) as sudo didn't make a difference either.

I'm at a point where I can just guess that for some reason the login isn't working, even though it work just fine on an Intel Mac. I've even tried calling NetFSMountURLSync with and without username/password - it didn't make a difference.

Note: I develop my application in Lazarus Pascal (latest trunk release), so I'm not sure how useful posting the code is.

Being a newbie at this and not being able to find anything useful online, I finally resorted to asking the questions here. Can anyone explain what I'm looking at? Just pointing towards documentation would already be helpful 😊

I develop my application in Lazarus Pascal

Nice! Somewhere out on the ’net there’s a photo of me wearing a “Friends don’t let friends do C” T-shirt (-:

I can’t think of any reason that NetFSMountURLSync would fail on Apple silicon. Some questions…

You wrote:

Nothing special here, just a plain application calling this.

An application you can double click to launch in the Finder?

I've even tried calling NetFSMountURLSync with and without username/password

What does that URL look like? Specifically, what scheme are you using? smb? afp?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Haha, that's funny - now you made me look for that T-Shirt 😜

Just kidding though. I do not dislike C ... I just liking Pascal better 😁

Thank you for replying! To answer your questions:

  • Yes, this is an GUI app, started from Finder with double click (not a command line application).

  • Scheme used for testing: smb

Some additional testing on my end:

I took the effort this morning to write a tiny dedicated test application to test the NetFSMountURLSync parameter variations.

And all these variations work on the Intel Mac (macOS 12.6):

URL: smb://username:password@serverip/sharename

  • username null, password null, mount path null, kNAUIOptionNoUI enabled, kNetFSMountAtMountDirKey enabled

URL: smb://serverip/sharename

  • username set, password set, mount path null, kNAUIOptionNoUI enabled, kNetFSMountAtMountDirKey enabled

URL: smb://serverip/sharename

  • username set, password set, mount path /Users/username/mountpoint, kNAUIOptionNoUI enabled, kNetFSMountAtMountDirKey enabled

URL: smb://username:password@serverip/sharename

  • username null, password null, mount path /Users/username/mountpoint, kNAUIOptionNoUI enabled, kNetFSMountAtMountDirKey enabled

I tried all of these additionally with kNetFSMountAtMountDirKey disabled (mount options null), with open_options null, with kNAUIOptionForceUI instead kNAUIOptionNoUI and the possible combinations with these as well. All of these work on both my Intel Mac's (running 12.6, 2016 MBP and 2013 MacPro).

Testing this on the 16" MBP M1 Max (also running 12.6):

ALL tests fail and make the application freeze, both Intel binary and ARM64 (AARCH64) binary fail all tests.

Initially the GUI freezes, then promptly the beach ball appears (not entirely unexpected when using Sync instead of ASync), then the beachball even freezes frequently and the application is just "on hold" and any sign of live from the application stops (in Console) ...

For each test I get an error like the ones below (the number behind gNetAuthAuthAgentPort changes with each new test).

default	13:10:02.167473+0200	project1	GetNetAuthAuthAgentPort: Calling bootstrap_look_up3() for com.apple.netauth.user.auth; uid = 501, euid = 501
default	13:10:02.167576+0200	project1	GetNetAuthAuthAgentPort: gNetAuthAuthAgentPort = 51459

I do not dislike C

Oh, I actively dislike C and all its descendents. I was very happy when Apple announced Swift.

Speaking of Swift, this code is working for me on both Intel and Apple silicon:

let url = URL(string: "smb://virtual-mont.local./mrgumby")!
let err = NetFSMountURLSync(
    url as NSURL,           // url
    nil,                    // mountpath
    "mrgumby" as NSString,  // user
    "opendoor" as NSString, // passwd
    nil,                    // open_options
    nil,                    // mount_options,
    nil                     // mountpoints
)
print(err)

Both machines running macOS 12.6. If you do the equivalent your setup, do you still see the problem? If not, please explain the tweaks I need to bring it more inline with your code.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I looked at Swift a few times ... I think not liking XCode is not helping 😉

Cool thing about Lazarus: cross platform development works great (most of the time).

OK, coming back to the real (other) issue; So I grabbed you Swift code and that worked on both Intel and Arm - as expected.

Now comes the kicker, which makes me feel a little stupid, ... I ran my own code again and guess what ... it works without modification (did a full shutdown last night). I don't know what to tell you ... I either goofed up (not impossible), or the reboot helped ...

Either way; I guess that solves that ... thanks Quinn! Very much appreciate you chiming in 👍🏻

Just for other non-Swift developers, add these imports to the beginning of Quinn's code. Took me a second to realize this - thanks again Quinn! 😊

import Foundation
import NetFS
NetFSMountURLSync call fails on Apple Silicon
 
 
Q