diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 22:55:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-16 22:55:46 +0000 |
commit | 96647a898d62d699808316238dfb933d960413f2 (patch) | |
tree | 0138491ada40b7b3fcb80d4b219fa7922ae8f512 /src/VBox/Main/src-global | |
parent | Adding debian version 7.0.14-dfsg-4. (diff) | |
download | virtualbox-96647a898d62d699808316238dfb933d960413f2.tar.xz virtualbox-96647a898d62d699808316238dfb933d960413f2.zip |
Merging upstream version 7.0.16-dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Main/src-global')
-rw-r--r-- | src/VBox/Main/src-global/win/VBoxSDS.cpp | 36 | ||||
-rw-r--r-- | src/VBox/Main/src-global/win/VirtualBoxSDSImpl.cpp | 2 |
2 files changed, 24 insertions, 14 deletions
diff --git a/src/VBox/Main/src-global/win/VBoxSDS.cpp b/src/VBox/Main/src-global/win/VBoxSDS.cpp index 6bc7506f..e89bfd7a 100644 --- a/src/VBox/Main/src-global/win/VBoxSDS.cpp +++ b/src/VBox/Main/src-global/win/VBoxSDS.cpp @@ -104,6 +104,7 @@ #include <iprt/buildconfig.h> #include <iprt/dir.h> #include <iprt/env.h> +#include <iprt/err.h> #include <iprt/getopt.h> #include <iprt/initterm.h> #include <iprt/path.h> @@ -911,10 +912,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine } /* - * Default log location is %ProgramData%\VirtualBox\VBoxSDS.log, falling back - * on %_CWD%\VBoxSDS.log (where _CWD typicaly is 'C:\Windows\System32'). + * Default log location (LOGDIR) is %APPDATA%\VirtualBox\VBoxSDS.log. * - * We change the current directory to %ProgramData%\VirtualBox\ if possible. + * When running VBoxSDS as a regular user, LOGDIR typically will be 'C:\Users\<User>\AppData\Roaming\VirtualBox\'. + * When running VBoxSDS as a service (via SCM), LOGDIR typically will be 'C:\Windows\System32\config\systemprofile\AppData\Roaming\VirtualBox\'. + * + * We change the current directory to LOGDIR if possible. + * + * See @bugref{10632}. * * We only create the log file when running VBoxSDS normally, but not * when registering/unregistering, at least for now. @@ -924,14 +929,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine char szLogFile[RTPATH_MAX]; if (!pszLogFile || !*pszLogFile) { - WCHAR wszAppData[MAX_PATH + 16]; - if (SHGetSpecialFolderPathW(NULL, wszAppData, CSIDL_COMMON_APPDATA, TRUE /*fCreate*/)) + WCHAR wszSpecialFolder[MAX_PATH + 16]; + if (SHGetSpecialFolderPathW(NULL, wszSpecialFolder, CSIDL_APPDATA, TRUE /*fCreate*/)) { char *pszConv = szLogFile; - vrc = RTUtf16ToUtf8Ex(wszAppData, RTSTR_MAX, &pszConv, sizeof(szLogFile) - 12, NULL); + vrc = RTUtf16ToUtf8Ex(wszSpecialFolder, RTSTR_MAX, &pszConv, sizeof(szLogFile) - 12, NULL); } - else - vrc = RTEnvGetUtf8("ProgramData", szLogFile, sizeof(szLogFile) - sizeof("VBoxSDS.log"), NULL); + else if (SHGetSpecialFolderPathW(NULL, wszSpecialFolder, CSIDL_SYSTEM, TRUE /*fCreate*/)) + { + char *pszConv = szLogFile; + vrc = RTUtf16ToUtf8Ex(wszSpecialFolder, RTSTR_MAX, &pszConv, sizeof(szLogFile) - 12, NULL); + } + else /* Note! No fallback to environment variables or such. See @bugref{10632}. */ + vrc = VERR_PATH_NOT_FOUND; if (RT_SUCCESS(vrc)) { vrc = RTPathAppend(szLogFile, sizeof(szLogFile), "VirtualBox\\"); @@ -942,14 +952,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine vrc = RTDirCreate(szLogFile, 0755, RTDIRCREATE_FLAGS_NOT_CONTENT_INDEXED_DONT_SET); if (RT_SUCCESS(vrc)) { - /* Change into it. */ - RTPathSetCurrent(szLogFile); + /* Change into it. + * If this fails, better don't continue, as there might be something fishy. */ + vrc = RTPathSetCurrent(szLogFile); + if (RT_SUCCESS(vrc)) + vrc = RTStrCat(szLogFile, sizeof(szLogFile), "VBoxSDS.log"); } } } - if (RT_FAILURE(vrc)) /* ignore any failure above */ - szLogFile[0] = '\0'; - vrc = RTStrCat(szLogFile, sizeof(szLogFile), "VBoxSDS.log"); if (RT_FAILURE(vrc)) return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to construct release log filename: %Rrc", vrc); pszLogFile = szLogFile; diff --git a/src/VBox/Main/src-global/win/VirtualBoxSDSImpl.cpp b/src/VBox/Main/src-global/win/VirtualBoxSDSImpl.cpp index 1b98c629..1db8fa61 100644 --- a/src/VBox/Main/src-global/win/VirtualBoxSDSImpl.cpp +++ b/src/VBox/Main/src-global/win/VirtualBoxSDSImpl.cpp @@ -609,7 +609,7 @@ STDMETHODIMP VirtualBoxSDS::LaunchVMProcess(IN_BSTR aMachine, IN_BSTR aComment, else { hrc = VBOX_E_IPRT_ERROR; - LogRel(("VirtualBoxSDS::LaunchVMProcess: launchVM failed: %Rhrc (%Rrc)\n", hrc)); + LogRel(("VirtualBoxSDS::LaunchVMProcess: launchVM failed: %Rhrc (%Rrc)\n", hrc, vrc)); } } catch (...) |