From c65d2a614b19130c5eef968783c5010e2e9c80f4 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 12 Mar 2024 14:34:08 +0100 Subject: [run-virt] Try removing trailing (back)slash from UNC names on failure --- .../data/opt/openslx/vmchooser/data/openslx.exe | Bin 62976 -> 62976 bytes core/modules/run-virt/winres/src/winres.c | 24 +++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) (limited to 'core') diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe b/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe index d70a8bab..7a9e5e6c 100755 Binary files a/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe and b/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe differ diff --git a/core/modules/run-virt/winres/src/winres.c b/core/modules/run-virt/winres/src/winres.c index 325c7ab6..e8e03947 100644 --- a/core/modules/run-virt/winres/src/winres.c +++ b/core/modules/run-virt/winres/src/winres.c @@ -36,7 +36,7 @@ DEFINE_GUID(ID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0xC4, #define BUFLEN (200) typedef struct { - const char* path; + char* path; const char* pathIp; const char* letter; const char* shortcut; @@ -94,7 +94,7 @@ static int optimizeForRemote(); static int muteSound(BOOL bMute); static int setShutdownText(); static void readShareFile(); -static BOOL mountNetworkShares(int attemptNo); +static BOOL mountNetworkShares(void); static int queryPasswordDaemon(); static BOOL fileExists(wchar_t* szPath); static BOOL folderExists(wchar_t* szPath); @@ -192,7 +192,7 @@ static void CALLBACK setupNetworkDrives(HWND hWnd, UINT uMsg, UINT_PTR idEvent, goto exit_func; alog("queryPasswordDaemon returned %d", ret); } else { - if (!mountNetworkShares(attempts)) { + if (!mountNetworkShares()) { if (GetTickCount() - _startTime < 30000 && ++attempts < 15) goto exit_func; } @@ -1204,7 +1204,7 @@ static void udpReceived(SOCKET sock) // Success spass = xorString(buffer + 2, len, bkey2); closesocket(sock); - mountNetworkShares(0); + mountNetworkShares(); } static DWORD mount(LPNETRESOURCEW share, LPWSTR pass, LPWSTR user) @@ -1384,21 +1384,33 @@ static BOOL mountNetworkShare(const netdrive_t *d, BOOL useIp) return FALSE; } -static BOOL mountNetworkShares(int attemptNo) +static BOOL mountNetworkShares(void) { - BOOL withPrinters = attemptNo > 4; + static int attemptNo = 0; int failCount = 0; + BOOL withPrinters; if (!shareFileOk) return TRUE; if (spass == NULL) return FALSE; + attemptNo++; + withPrinters = attemptNo > 4; + for (int i = 0; i < DRIVEMAX; ++i) { if (drives[i].path == NULL) break; if (drives[i].success) continue; + if (attemptNo == 2) { + // Strip any trailing slashes or backslashes + // See #3955 + int p = strlen(drives[i].path) - 1; + while (p > 0 && (drives[i].path[p] == '/' || drives[i].path[p] == '\\')) { + drives[i].path[p--] = '\0'; + } + } if (!withPrinters && drives[i].letter != NULL && strcmp(drives[i].letter, "PRINTER") == 0) { // Delay connecting printers a bit, might need a resource share or other setup -- cgit v1.2.3-55-g7522