Changeset 104275 in vbox
- Timestamp:
- Apr 10, 2024 1:22:11 PM (8 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-global/win/VBoxSDS.cpp
r104152 r104275 105 105 #include <iprt/dir.h> 106 106 #include <iprt/env.h> 107 #include <iprt/err.h> 107 108 #include <iprt/getopt.h> 108 109 #include <iprt/initterm.h> … … 961 962 962 963 /* 963 * Default log location is %ProgramData%\VirtualBox\VBoxSDS.log, falling back 964 * on %_CWD%\VBoxSDS.log (where _CWD typicaly is 'C:\Windows\System32'). 964 * Default log location (LOGDIR) is %APPDATA%\VirtualBox\VBoxSDS.log. 965 965 * 966 * We change the current directory to %ProgramData%\VirtualBox\ if possible. 966 * When running VBoxSDS as a regular user, LOGDIR typically will be 'C:\Users\<User>\AppData\Roaming\VirtualBox\'. 967 * When running VBoxSDS as a service (via SCM), LOGDIR typically will be 'C:\Windows\System32\config\systemprofile\AppData\Roaming\VirtualBox\'. 968 * 969 * We change the current directory to LOGDIR if possible. 970 * 971 * See @bugref{10632}. 967 972 * 968 973 * We only create the log file when running VBoxSDS normally, but not … … 974 979 if (!pszLogFile || !*pszLogFile) 975 980 { 976 WCHAR wsz AppData[MAX_PATH + 16];977 if (SHGetSpecialFolderPathW(NULL, wsz AppData, CSIDL_COMMON_APPDATA, TRUE /*fCreate*/))981 WCHAR wszSpecialFolder[MAX_PATH + 16]; 982 if (SHGetSpecialFolderPathW(NULL, wszSpecialFolder, CSIDL_APPDATA, TRUE /*fCreate*/)) 978 983 { 979 984 char *pszConv = szLogFile; 980 vrc = RTUtf16ToUtf8Ex(wszAppData, RTSTR_MAX, &pszConv, sizeof(szLogFile) - 12, NULL); 981 } 982 else 983 vrc = RTEnvGetUtf8("ProgramData", szLogFile, sizeof(szLogFile) - sizeof("VBoxSDS.log"), NULL); 985 vrc = RTUtf16ToUtf8Ex(wszSpecialFolder, RTSTR_MAX, &pszConv, sizeof(szLogFile) - 12, NULL); 986 } 987 else if (SHGetSpecialFolderPathW(NULL, wszSpecialFolder, CSIDL_SYSTEM, TRUE /*fCreate*/)) 988 { 989 char *pszConv = szLogFile; 990 vrc = RTUtf16ToUtf8Ex(wszSpecialFolder, RTSTR_MAX, &pszConv, sizeof(szLogFile) - 12, NULL); 991 } 992 else /* Note! No fallback to environment variables or such. See @bugref{10632}. */ 993 vrc = VERR_PATH_NOT_FOUND; 984 994 if (RT_SUCCESS(vrc)) 985 995 { … … 992 1002 if (RT_SUCCESS(vrc)) 993 1003 { 994 /* Change into it. */ 995 RTPathSetCurrent(szLogFile); 1004 /* Change into it. 1005 * If this fails, better don't continue, as there might be something fishy. */ 1006 vrc = RTPathSetCurrent(szLogFile); 1007 if (RT_SUCCESS(vrc)) 1008 vrc = RTStrCat(szLogFile, sizeof(szLogFile), "VBoxSDS.log"); 996 1009 } 997 1010 } 998 1011 } 999 if (RT_FAILURE(vrc)) /* ignore any failure above */1000 szLogFile[0] = '\0';1001 vrc = RTStrCat(szLogFile, sizeof(szLogFile), "VBoxSDS.log");1002 1012 if (RT_FAILURE(vrc)) 1003 1013 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Failed to construct release log filename: %Rrc", vrc);
Note:
See TracChangeset
for help on using the changeset viewer.