Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/app_mac/headless.m
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ static BOOL vm_installing(const AsbVmMac *v) {
@"LPT1",@"LPT2",@"LPT3",@"LPT4",@"LPT5",@"LPT6",@"LPT7",@"LPT8",@"LPT9"];
if ([reserved containsObject:user.uppercaseString])
return @"Username is a reserved name.";
/* Windows guests: the VM name becomes the guest ComputerName; a user named
like the machine cannot be added to local groups during the unattend pass
(ERROR_NO_SUCH_MEMBER), so the account ends up group-less and the agent
never installs. */
if (is_win && [user caseInsensitiveCompare:name] == NSOrderedSame)
return @"Username cannot be the same as the VM name.";

/* numeric ranges (0 = unset -> the core fills a default). The even-RAM
rule is kept for interface parity with the GUI/Windows daemon. */
Expand Down
6 changes: 6 additions & 0 deletions src/app_win/headless.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,12 @@ static const char *validate_create(const wchar_t *name, const wchar_t *os,
int r; for (r = 0; r < (int)(sizeof(res)/sizeof(res[0])); r++)
if (_wcsicmp(user, res[r]) == 0) return "Username is a reserved name.";
}
/* The VM name becomes the guest ComputerName; a user named like
the machine cannot be added to local groups during the unattend
pass (ERROR_NO_SUCH_MEMBER), so the account ends up group-less
and the agent never installs. */
if (_wcsicmp(user, name) == 0)
return "Username cannot be the same as the VM name.";
}
if (is_linux) {
if (!pass || !pass[0]) return "Password is required.";
Expand Down
14 changes: 14 additions & 0 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ function revalidateVmName() {
document.getElementById('vm-name-warn').textContent = validateVmName(name) || '';
}
document.getElementById('vm-name').addEventListener('input', revalidateVmName);
/* Username validity depends on the VM name (Windows: username != VM name). */
document.getElementById('vm-name').addEventListener('input', revalidateUsername);

function revalidateUsername() {
var u = document.getElementById('admin-user').value.trim();
Expand Down Expand Up @@ -524,6 +526,18 @@ function validateUsername(name) {
'COM1','COM2','COM3','COM4','COM5','COM6','COM7','COM8','COM9',
'LPT1','LPT2','LPT3','LPT4','LPT5','LPT6','LPT7','LPT8','LPT9'];
if (reserved.indexOf(name.toUpperCase()) >= 0) return 'Username is a reserved name.';
/* Windows guests: the VM name becomes the guest ComputerName, and a user
named like the machine cannot be added to local groups during the
unattend pass (LookupAccountName resolves the machine object first,
NetLocalGroupAddMembers fails with ERROR_NO_SUCH_MEMBER). The account
ends up group-less, OOBE autologs defaultuser0 instead and the agent
never installs. */
if (osType === 'Windows') {
var vmNameEl = document.getElementById('vm-name');
var vmName = vmNameEl ? vmNameEl.value.trim() : '';
if (vmName && name.toLowerCase() === vmName.toLowerCase())
return 'Username cannot be the same as the VM name.';
}
return null;
}

Expand Down