Can a Mac App Store (sandboxed) app create and delete VLAN interfaces with SCVLANInterfaceCreate?

We make a Mac App Store app that runs virtual machines with the Virtualization framework. It has the com.apple.vm.networking entitlement and already bridges VMs to physical interfaces through VZBridgedNetworkDeviceAttachment. We'd like users to manage 802.1Q VLAN interfaces from inside the app, so they can create a VLAN on an Ethernet port and bridge a VM to it.

The SystemConfiguration API for this is:

var auth: AuthorizationRef?
var item = AuthorizationItem(name: "system.services.systemconfiguration.network",
valueLength: 0, value: nil, flags: 0)
var rights = AuthorizationRights(count: 1, items: &item)
AuthorizationCreate(&rights, nil, [.interactionAllowed, .extendRights, .preAuthorize], &auth)

let prefs = SCPreferencesCreateWithAuthorization(nil, "MyApp" as CFString, nil, auth!)!
SCPreferencesLock(prefs, true) // fails in the sandbox
let vlan = SCVLANInterfaceCreate(prefs, physicalInterface, 100 as CFNumber)
SCPreferencesCommitChanges(prefs)
SCPreferencesApplyChanges(prefs)
SCPreferencesUnlock(prefs)

What we see on macOS 27:

  • Without the sandbox, SCPreferencesLock on preferences created with SCPreferencesCreateWithAuthorization succeeds.
  • With com.apple.security.app-sandbox, the same call fails with kSCStatusAccessError ("Permission denied").
  • Read-only calls work in the sandbox: SCVLANInterfaceCopyAll, ACVLANInterfaceCopyAvailablePhysicalInterfaces and SCNetworkInterfaceCopyAll
    all return the expected results.

Our questions:

  1. Can a sandboxed Mac App Store app create or delete VLAN interfaces in any supported way, through SystemConfiguration or another API?
  2. If not, is there an entitlement we could request for this, similar to com.apple.vm.networking? Or is a privileged helper
    (SMAppService.daemon) the only way? As we understand it, the Mac App Store doesn't allow a privileged helper.
  3. Are VLAN interfaces (vlanN) meant to appear in VZBridgedNetworkInterface.networkInterfaces(update: it appears i create vlan interface using mac settings network settings) so a VM can be bridged to one? Does vmnet's bridged mode support them?
  4. If a VM is bridged to the physical Ethernet port and tags its own frames inside the guest, do the 802.1Q tags pass through the bridge unchanged?

If creating VLANs isn't possible from the sandbox, our fallback is to list the existing VLANs and send users to System Settings › Network › Manage Virtual Interfaces. We'd like to confirm that before building it.

Thanks!


Answered by DTS Engineer in 916794022
Written by rbmanian75 in 857706021

1- Can a sandboxed Mac App Store app create or delete VLAN interfaces in any supported way … ?

No.

You’ve found the correct way to set this up, that is, using System Configuration framework. But that authorises the request using Authorization Services, and that’s blocked by the App Sandbox.

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

Written by rbmanian75 in 857706021

1- Can a sandboxed Mac App Store app create or delete VLAN interfaces in any supported way … ?

No.

You’ve found the correct way to set this up, that is, using System Configuration framework. But that authorises the request using Authorization Services, and that’s blocked by the App Sandbox.

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

So if i understand correctly there is no way i can do this with appstore sandboxed app. I have to guide the user to use System Settings -> Network Settings to create VLAN? Is that right?

Written by rbmanian75 in 916798022

there is no way i can do this with appstore sandboxed app. I

Correct.

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

It would be nich addition if i could allow the user to creat/delete VLAN in the app itself this avoid the user to get out of the app and dig into systen settings. It would be very powerful feature for virutalization application to provide this option in the app itself.

should i file a feedback or we can expect to have this available in the upcoming versions?

Written by rbmanian75 in 917142022

should i file a feedback … ?

Yes.

Please be specific about the user-level problem you’re trying to solve here. Historically, App Sandbox has prevented the app from making system-wide changes, even with the approval of the user. That restriction has been somewhat relaxed recently — although the user still has to approve such changes, obviously — so there might be some scope for accommodating your requirements. However, it pays to be specific. A bug requesting the ability to make arbitrary network changes is less likely to get traction than a bug requesting a solution to a specific user-level problem.

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