[wue] prevent 'Administrator' and 'Guest' from being set as username

* These are reserved usernames that are created by default, so we should not use them.
* Also fix missing format specifier in ApplyWindowsCustomization() and make sure we
  print wim_index for both mount and unmount.
* Closes #2067 (with thanks to marcosfrm)
This commit is contained in:
Pete Batard 2022-10-15 12:20:49 +01:00
parent 76ff620714
commit cee21b1981
No known key found for this signature in database
GPG Key ID: 38E0CF5E69EDD671
2 changed files with 10 additions and 7 deletions

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 3.21.1939"
CAPTION "Rufus 3.21.1940"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@ -395,8 +395,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 3,21,1939,0
PRODUCTVERSION 3,21,1939,0
FILEVERSION 3,21,1940,0
PRODUCTVERSION 3,21,1940,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -414,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "3.21.1939"
VALUE "FileVersion", "3.21.1940"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.21.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "3.21.1939"
VALUE "ProductVersion", "3.21.1940"
END
END
BLOCK "VarFileInfo"

View File

@ -143,6 +143,9 @@ char* CreateUnattendXml(int arch, int flags)
char username[128] = { 0 };
DWORD size = sizeof(username);
if (GetUserNameU(username, &size) && username[0] != 0) {
// Administrator and Guest are default accounts that we shouldn't touch
if ((stricmp(username, "Administrator") == 0) || (stricmp(username, "Guest") == 0))
static_strcpy(username, "User");
// If we create a local account in unattend.xml, then we can get Windows 11
// 22H2 to skip MSA even if the network is connected during installation.
fprintf(fd, " <UserAccounts>\n");
@ -757,7 +760,7 @@ BOOL ApplyWindowsCustomization(char drive_letter, int flags)
// We only need to mount boot.wim if we have windowsPE data to deal with. If
// not, we can just copy our unattend.xml in \sources\$OEM$\$$\Panther\.
if (flags & UNATTEND_WINPE_SETUP_MASK) {
uprintf("Mounting '%s'...", boot_wim_path);
uprintf("Mounting '%s[%d]'...", boot_wim_path, wim_index);
// Some "unofficial" ISOs have a modified boot.wim that doesn't have Windows Setup at index 2...
if (!WimIsValidIndex(boot_wim_path, wim_index)) {
uprintf("WARNING: This image appears to be an UNOFFICIAL Windows ISO!");
@ -869,7 +872,7 @@ out:
UpdateProgressWithInfoForce(OP_PATCH, MSG_325, 104, PATCH_PROGRESS_TOTAL);
}
if (mount_path) {
uprintf("Unmounting '%s'...", boot_wim_path, wim_index);
uprintf("Unmounting '%s[%d]'...", boot_wim_path, wim_index);
WimUnmountImage(boot_wim_path, wim_index);
UpdateProgressWithInfo(OP_PATCH, MSG_325, PATCH_PROGRESS_TOTAL, PATCH_PROGRESS_TOTAL);
}