This post applies to Apple Virtualization framework feature to setup a user account during VM setup (VZMacGuestProvisioningOptions) introduced in macOS 27:
Issue:
Creating a user via VZMacGuestProvisioningOptions during VM setup, results in a user which is not returned by CSidentityQueryExecute(). Same code executed on a macOS 26 VM or a macOS 27 VM where the user was created by hand within the VM (so without VZMacGuestProvisioningOptions) returns the user.
How to reproduce:
Create an VM via the Apple Virtualization framework and use the VZMacGuestProvisioningOptions to create the user during VM setup. I actually used Virtual Buddy and Tart to do this.
Then run the following code:
internal enum MyLogger {
static let info = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "Utils-\(getuid())")
}
public struct Identity {
public let posixUID: id_t
public let posixName: String
init?(posixUID: id_t, posixName: String) {
self.posixUID = posixUID
self.posixName = posixName
}
}
class Utils {
public static func userIdentities() -> [Identity] {
let defaultAuthority = CSGetLocalIdentityAuthority().takeUnretainedValue()
let query = CSIdentityQueryCreate(nil, kCSIdentityClassUser, defaultAuthority).takeRetainedValue()
guard
CSIdentityQueryExecute(query, 0, nil),
let identities = CSIdentityQueryCopyResults(query).takeRetainedValue() as? [CSIdentity]
else { return [] }
for ident in identities {
MyLogger.info.log("CSIdentity: \(ident.hashValue, privacy: .public)")
}
let idents = identities
.compactMap {
Identity(
posixUID: CSIdentityGetPosixID($0),
posixName: CSIdentityGetPosixName($0).takeUnretainedValue() as String
)
}
.sorted { $0.posixName.localizedStandardCompare($1.posixName) == .orderedAscending }
for ident in idents {
MyLogger.info.log("Identity: \(ident.posixName, privacy: .public), \(ident.posixUID, privacy: .public)")
}
return idents
}
}
Expected behavior:
The code returns the user account created via VZMacGuestProvisioningOptions.
Actual behavior:
I get no user account
When you test the same on a macOS 27 VM where the user is created via the traditional way (Setup assistant), the app shows the account. This also applies to all additional user accounts created after VM setup via System Settings.app.
The bug also still exists on a VM created with macOS 27 beta 4.
Is anybody having the same issue? Is that a bug in macOS 27?
I already created a Feedback for this: FB23716201
2
0
109