[vbox-dev] Location of VirtualBox configuration file

Klaus Espenlaub klaus.espenlaub at oracle.com
Tue Nov 22 19:14:08 GMT 2016


Hi Malcolm,

On 21.11.2016 23:34, Malcolm Clarke wrote:
>
> Dear Klaus
>
> Thank you for your response.
>
> You have not understood the issue that is being reported. I have made 
> an effort to examine code to understand, but the software is complex, 
> with a multiplicity of "methods" to acquire the directory for the 
> configuration file (eg search for "HOMEDRIVE").
>
I did understand your issue, but I have absolutely no explanation why it 
could possibly happen with a properly configured roaming profile setup.

VirtualBox doesn't use any environment variables for figuring out the 
user's profile directory, it directly asks the Windows API. I don't 
think that makes the situation more complex, in my opinion it makes it a 
lot simpler. All the fallbacks which you investigated are simply not 
relevant (unless you found a way to make the Windows API fail in 
extremely weird patterns).
>
> I repeat the behaviour.
>
> Our students are working on machines using roaming profile with 
> USERPROFILE=c:\user\xxxxxx, HOMEDRIVE=h:, HOMEPATH=\
>
> When the student first uses VirtualBox and opens the manager, it has a 
> totally empty configuration as expected. The student then creates some 
> networks and virtual machines. These machines work correctly when started.
>
> The student exits the manager.
>
> The student restarts the manager but is confronted with an empty 
> configuration, all previous settings are lost.
>
That's the riddle. I don't have the faintest idea why the settings are 
suddenly gone. It's somewhat difficult to investigate, too, as tools 
like procmon don't feel that much at home with situations like user 
logout or roaming profiles. But it is still worth a try, having it 
monitor the activities on logout or when VirtualBox is started again.
>
> It is very frustrating having to create NAT networks and virtual 
> machines every time the manager is restarted.
>
No doubt.
>
> If a single method was used to return the directory, then I would 
> expect the behaviour to be different, and the configuration retained 
> and appear each time the manager is opened, ie the behaviour the same 
> as when installed on a stand alone machine. This is not the case, and 
> so there is an issue.
>
There is only a single method for determining the location of the 
.VirtualBox directory, and it does not depend on environment variables 
which are unreliable.
>
> I would expect this to be an issue for any classroom situation where 
> roaming profiles are used and separate home drives are defined - a 
> common configuration.
>
No, I don't believe that what you're seeing is a generic roaming profile 
issue. Otherwise we'd get complains from a lot more people out there 
operating some non-trivial Windows setups.
>
> I also hope you appreciate Universities introducing and using Virtual 
> Box in teaching, but we require support.
>
We certainly do, otherwise we wouldn't have created the "free ride" 
option for educational purposes.

Regards,
Klaus
>
> Regards
>
> Malcolm
>
>
> On 21/11/2016 11:02, Klaus Espenlaub wrote:
>> Malcolm,
>>
>> there was a lengthy reply to the mailing list 10 days ago sent by me, 
>> explaining what's going on.
>>
>> Your assumption is wrong. VirtualBox on all Windows versions worth 
>> talking about will NOT fall through, it'll use the profile directory 
>> returned by SHGetFolderPath.
>>
>> Klaus
>>
>> On 20.11.2016 19:55, Malcolm Clarke wrote:
>>>
>>> Dear Max
>>>
>>> Still no response.
>>>
>>> Looking at path-win.cpp, the following code is unclear
>>>
>>>
>>> RTDECL(int) RTPathUserHome(char *pszPath, size_t cchPath)
>>> {
>>>     /*
>>>      * Validate input
>>>      */
>>>     AssertPtrReturn(pszPath, VERR_INVALID_POINTER);
>>>     AssertReturn(cchPath, VERR_INVALID_PARAMETER);
>>>
>>>     RTUTF16 wszPath[RTPATH_MAX];
>>>     bool    fValidFolderPath = false;
>>>
>>>     /*
>>>      * Try with Windows XP+ functionality first.
>>>      */
>>>     RTLDRMOD hShell32;
>>>     int rc = RTLdrLoadSystem("Shell32.dll", true /*fNoUnload*/, 
>>> &hShell32);
>>>     if (RT_SUCCESS(rc))
>>>     {
>>>         PFNSHGETFOLDERPATHW pfnSHGetFolderPathW;
>>>         rc = RTLdrGetSymbol(hShell32, "SHGetFolderPathW", 
>>> (void**)&pfnSHGetFolderPathW);
>>>         if (RT_SUCCESS(rc))
>>>         {
>>>             HRESULT hrc = pfnSHGetFolderPathW(0, CSIDL_PROFILE, 
>>> NULL, SHGFP_TYPE_CURRENT, wszPath);
>>>             fValidFolderPath = (hrc == S_OK);
>>>         }
>>>         RTLdrClose(hShell32);
>>>     }
>>>
>>>     DWORD   dwAttr;
>>>     if (    !fValidFolderPath
>>>         ||  (dwAttr = GetFileAttributesW(&wszPath[0])) == 
>>> INVALID_FILE_ATTRIBUTES
>>>         ||  !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
>>>     {
>>>         /*
>>>          * Fall back to Windows specific environment variables. HOME 
>>> is not used.
>>>          */
>>>         if (    !GetEnvironmentVariableW(L"USERPROFILE", 
>>> &wszPath[0], RTPATH_MAX)
>>>             ||  (dwAttr = GetFileAttributesW(&wszPath[0])) == 
>>> INVALID_FILE_ATTRIBUTES
>>>             ||  !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
>>>         {
>>>             /* %HOMEDRIVE%%HOMEPATH% */
>>>             if (!GetEnvironmentVariableW(L"HOMEDRIVE", &wszPath[0], 
>>> RTPATH_MAX))
>>>                 return VERR_PATH_NOT_FOUND;
>>>             size_t const cwc = RTUtf16Len(&wszPath[0]);
>>>             if (    !GetEnvironmentVariableW(L"HOMEPATH", 
>>> &wszPath[cwc], RTPATH_MAX - (DWORD)cwc)
>>>                 ||  (dwAttr = GetFileAttributesW(&wszPath[0])) == 
>>> INVALID_FILE_ATTRIBUTES
>>>                 ||  !(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
>>>                 return VERR_PATH_NOT_FOUND;
>>>         }
>>>     }
>>>
>>> Assuming this falls through to get the environment variable, then 
>>> USERPROFILE is used over %HOMEDRIVE%%HOMEPATH%, however in most 
>>> other places %HOMEDRIVE%%HOMEPATH% alone is used. This appears to 
>>> result in inconsistent behaviour if USERPROFILE is not equal to 
>>> %HOMEDRIVE%%HOMEPATH%.
>>>
>>> This needs to be remedied for people using roaming profiles when 
>>> these environmental variables can be set differently.
>>>
>>> 1. %HOMEDRIVE%%HOMEPATH% is used for location of configuration files 
>>> (create and check location for existence)
>>> 2. USERPROFILE  may be used for temporary files
>>>
>>> Regards
>>>
>>> Malcolm
>>>
>>>
>>>
>>>
>>> On 09/11/2016 14:36, Maxime Dor wrote:
>>>> Hi Malcolm,
>>>>
>>>> While I have extensive knowledge of VBox, I'm not a dev so I can't 
>>>> really answer that question, only the devs can.
>>>> They should answer anytime soon now! If they don't be tomorrow, 
>>>> just let me know and I'll drop them a note.
>>>>
>>>> Max
>>>
>>> -- 
>>>
>>> *Malcolm Clarke *BSc (Hons), PhD
>>>
>>> Reader in Telemedicine and Data Communication Systems
>>>
>>> T+44 (0) 1895 265053
>>>
>>> *Brunel University London*
>>>
>>> College of Engineering, Design and Physical Sciences
>>>
>>> Department of Computer Science
>>>
>>> HNZW010, Heinz Wolff Building, Kingston Lane, Uxbridge, Middlesex, 
>>> UB8 3PH
>>>
>>> *www.brunel.ac.uk <http://www.brunel.ac.uk/>*
>>>
>>> Connect with the university on*Linkedin, Twitter, Facebook*
>>>
>
> -- 
>
> *Malcolm Clarke *BSc (Hons), PhD
>
> Reader in Telemedicine and Data Communication Systems
>
> T+44 (0) 1895 265053
>
> *Brunel University London*
>
> College of Engineering, Design and Physical Sciences
>
> Department of Computer Science
>
> HNZW010, Heinz Wolff Building, Kingston Lane, Uxbridge, Middlesex, UB8 3PH
>
> *www.brunel.ac.uk <http://www.brunel.ac.uk/>*
>
> Connect with the university on*Linkedin, Twitter, Facebook*
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.virtualbox.org/pipermail/vbox-dev/attachments/20161122/987bad2f/attachment.html>


More information about the vbox-dev mailing list