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:
- Can a sandboxed Mac App Store app create or delete VLAN interfaces in any supported way, through SystemConfiguration or another API?
- 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. - 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?
- 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!
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"