[vbox-dev] Location of VirtualBox configuration file

Malcolm Clarke Malcolm.Clarke at brunel.ac.uk
Mon Nov 21 22:34:40 GMT 2016


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 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.

It is very frustrating having to create NAT networks and virtual machines every time the manager is restarted.

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.

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.

I also hope you appreciate Universities introducing and using Virtual Box in teaching, but we require support.

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/20161121/60c51721/attachment.html>


More information about the vbox-dev mailing list