mirror of
https://github.com/pbatard/rufus.git
synced 2026-10-24 02:28:58 +03:00
[wue] re-instate the use of . as part of a local username
* Closes #3057. * Also don't dedup the account name sanitizing and keep it in wue.c. This also fixes the display of the warning on account name sanitization in the log, which got broken in a previous commit. * Also switch to using WIMLIB_WRITE_FLAG_UNSAFE_COMPACT for boot.wim alteration to work around fragmentation and the AMI NTFS driver bug with MD5 validation and add an extra call to CreatePreallocatedFile() where needed.
This commit is contained in:
@@ -2543,8 +2543,8 @@ void UpdateMD5Sum(const char* dest_dir, const char* md5sum_name)
|
||||
continue;
|
||||
}
|
||||
uprintf("Renamed: %s → %s", path1, path2);
|
||||
hFile = CreateFileA(path1, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
hFile = CreatePreallocatedFile(path1, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL,
|
||||
CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, res_size);
|
||||
if ((hFile == NULL) || (hFile == INVALID_HANDLE_VALUE)) {
|
||||
uprintf("Could not create '%s': %s.", path1, WindowsErrorString());
|
||||
MoveFileU(path2, path1);
|
||||
|
||||
@@ -152,9 +152,8 @@
|
||||
#define DEFAULT_ESP_MOUNT_POINT "S:\\"
|
||||
// Per https://learn.microsoft.com/en-us/windows-hardware/customize/desktop/unattend/microsoft-windows-shell-setup-useraccounts-localaccounts-localaccount-name
|
||||
// and https://learn.microsoft.com/en-us/previous-versions/cc722458(v=technet.10)#user-name-policies
|
||||
// Add '.' to the list because some folks also reported an issue with local accounts that have dots.
|
||||
// Also add '&', even as it could be escaped, as it's just not worth the trouble...
|
||||
#define USERNAME_INVALID_CHARS "/\\[]:;|=.,+*?<>%@&\""
|
||||
#define USERNAME_INVALID_CHARS "/\\[]:;|=,+*?<>%@&\""
|
||||
#define IS_POWER_OF_2(x) ((x != 0) && (((x) & ((x) - 1)) == 0))
|
||||
#define IGNORE_RETVAL(expr) do { (void)(expr); } while(0)
|
||||
#ifndef ARRAYSIZE
|
||||
@@ -715,12 +714,12 @@ typedef struct {
|
||||
#define LIST_DIR_TYPE_RECURSIVE 0x80
|
||||
|
||||
/* Hash tables */
|
||||
typedef struct htab_entry {
|
||||
typedef struct {
|
||||
uint32_t used;
|
||||
char* str;
|
||||
void* data;
|
||||
} htab_entry;
|
||||
typedef struct htab_table {
|
||||
typedef struct {
|
||||
htab_entry* table;
|
||||
uint32_t size;
|
||||
uint32_t filled;
|
||||
|
||||
10
src/rufus.rc
10
src/rufus.rc
@@ -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 4.16.2414"
|
||||
CAPTION "Rufus 4.16.2415"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
@@ -409,8 +409,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,16,2414,0
|
||||
PRODUCTVERSION 4,16,2414,0
|
||||
FILEVERSION 4,16,2415,0
|
||||
PRODUCTVERSION 4,16,2415,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -428,13 +428,13 @@ BEGIN
|
||||
VALUE "Comments", "https://rufus.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "4.16.2414"
|
||||
VALUE "FileVersion", "4.16.2415"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2026 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||
VALUE "OriginalFilename", "rufus-4.16.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "4.16.2414"
|
||||
VALUE "ProductVersion", "4.16.2415"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
||||
11
src/stdlg.c
11
src/stdlg.c
@@ -862,7 +862,6 @@ static INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam
|
||||
{
|
||||
// This "Mooo" is designed to give us enough space for a regular username length
|
||||
static const char* base_username = "MOOOOOOOOOOO"; // 🐮
|
||||
static const char* username_invalid_chars = USERNAME_INVALID_CHARS;
|
||||
// Prevent resizing
|
||||
static const LRESULT disabled[9] = { HTLEFT, HTRIGHT, HTTOP, HTBOTTOM, HTSIZE,
|
||||
HTTOPLEFT, HTTOPRIGHT, HTBOTTOMLEFT, HTBOTTOMRIGHT };
|
||||
@@ -1098,16 +1097,8 @@ static INT_PTR CALLBACK SelectionCallback(HWND hDlg, UINT message, WPARAM wParam
|
||||
if (Button_GetCheck(GetDlgItem(hDlg, IDC_SELECTION_CHOICE1 + i)) == BST_CHECKED &&
|
||||
IsWindowVisible(GetDlgItem(hDlg, IDC_SELECTION_CHOICE1 + i)))
|
||||
r += m;
|
||||
if (selection_data[s].options->username_index > 0) {
|
||||
if (selection_data[s].options->username_index > 0)
|
||||
GetWindowTextU(GetDlgItem(hDlg, IDC_SELECTION_USERNAME), unattend_username, MAX_USERNAME_LENGTH);
|
||||
// Perform string sanitization (NB: GetWindowTextU always terminates the string)
|
||||
for (i = 0; unattend_username[i] != 0; i++) {
|
||||
if (strchr(username_invalid_chars, unattend_username[i]) != NULL)
|
||||
unattend_username[i] = '_';
|
||||
}
|
||||
// Also remove leading and trailing whitespaces (https://github.com/pbatard/rufus/issues/2950)
|
||||
trim(unattend_username);
|
||||
}
|
||||
if (selection_data[s].options->edition_index > 0)
|
||||
unattend_edition_index = (int)ComboBox_GetCurItemData(GetDlgItem(hDlg, IDC_SELECTION_EDITION));
|
||||
// Fall through
|
||||
|
||||
@@ -3084,10 +3084,10 @@ overwrite_wim_inplace(WIMStruct *wim, int write_flags, unsigned num_threads)
|
||||
|
||||
/* In-place compaction */
|
||||
|
||||
WARNING("The WIM file \"%"TS"\" is being compacted in place.\n"
|
||||
" Do *not* interrupt the operation, or else "
|
||||
"the WIM file will be\n"
|
||||
" corrupted!", wim->filename);
|
||||
// WARNING("The WIM file \"%"TS"\" is being compacted in place.\n"
|
||||
// " Do *not* interrupt the operation, or else "
|
||||
// "the WIM file will be\n"
|
||||
// " corrupted!", wim->filename);
|
||||
wim->being_compacted = 1;
|
||||
old_wim_end = WIM_HEADER_DISK_SIZE;
|
||||
|
||||
|
||||
12
src/wue.c
12
src/wue.c
@@ -342,6 +342,8 @@ char* CreateUnattendXml(int arch, int flags)
|
||||
}
|
||||
}
|
||||
if (flags & UNATTEND_SET_USER) {
|
||||
// Remove leading and trailing whitespaces (https://github.com/pbatard/rufus/issues/2950)
|
||||
trim(unattend_username);
|
||||
for (i = 0; (i < ARRAYSIZE(unallowed_account_names)) && (stricmp(unattend_username, unallowed_account_names[i]) != 0); i++);
|
||||
if (i < ARRAYSIZE(unallowed_account_names)) {
|
||||
uprintf("WARNING: '%s' is not allowed as local account name - Option ignored", unattend_username);
|
||||
@@ -350,7 +352,7 @@ char* CreateUnattendXml(int arch, int flags)
|
||||
filter_chars(unattend_username, USERNAME_INVALID_CHARS, '_');
|
||||
uprintf("• Use '%s' for local account name", unattend_username);
|
||||
if (strcmp(org_username, unattend_username) != 0)
|
||||
uprintf("WARNING: Local account name contained unallowed characters and has been sanitized");
|
||||
uprintf("WARNING: Local account name '%s' contained unallowed characters and has been sanitized", org_username);
|
||||
free(org_username);
|
||||
// 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.
|
||||
@@ -1432,7 +1434,13 @@ out:
|
||||
if (update_boot_wim) {
|
||||
uprintf("Updating '%s[%d]'...", boot_wim_path, wim_index);
|
||||
if (wimlib_update_image(wim, wim_index, wuc, wuc_index, 0) != 0 ||
|
||||
wimlib_overwrite(wim, WIMLIB_WRITE_FLAG_RECOMPRESS, 0) != 0) {
|
||||
// We use WIMLIB_WRITE_FLAG_UNSAFE_COMPACT unconditionally because, due to the
|
||||
// AMI NTFS driver bug that may produce false positives for MD5, we want to
|
||||
// have an unfragmented boot.wim after it is updated (one VNC), just as the
|
||||
// original boot.wim was written to disk, and our changes are such that wimlib
|
||||
// should be able to carry them all out within the existing file cluster area,
|
||||
// without needing to allocate new cluster ranges (and thus break our file).
|
||||
wimlib_overwrite(wim, WIMLIB_WRITE_FLAG_UNSAFE_COMPACT, 0) != 0) {
|
||||
uprintf("Error: Failed to update %s", boot_wim_path);
|
||||
r = FALSE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user