Merge pull request #3210 from hardening/env_fix

Don't require HOME env var to be set for server-side code
This commit is contained in:
Martin Fleisz
2016-03-10 08:22:30 +01:00

View File

@@ -493,40 +493,46 @@ rdpSettings* freerdp_settings_new(DWORD flags)
if(!settings->DynamicChannelArray)
goto out_fail;
settings->HomePath = GetKnownPath(KNOWN_PATH_HOME);
if (!settings->HomePath)
goto out_fail;
/* For default FreeRDP continue using same config directory
* as in old releases.
* Custom builds use <Vendor>/<Product> as config folder. */
if (_stricmp(FREERDP_VENDOR_STRING, FREERDP_PRODUCT_STRING))
if (!settings->ServerMode)
{
base = GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME,
FREERDP_VENDOR_STRING);
if (base)
/* these values are used only by the client part */
settings->HomePath = GetKnownPath(KNOWN_PATH_HOME);
if (!settings->HomePath)
goto out_fail;
/* For default FreeRDP continue using same config directory
* as in old releases.
* Custom builds use <Vendor>/<Product> as config folder. */
if (_stricmp(FREERDP_VENDOR_STRING, FREERDP_PRODUCT_STRING))
{
settings->ConfigPath = GetCombinedPath(
base,
FREERDP_PRODUCT_STRING);
base = GetKnownSubPath(KNOWN_PATH_XDG_CONFIG_HOME,
FREERDP_VENDOR_STRING);
if (base)
{
settings->ConfigPath = GetCombinedPath(
base,
FREERDP_PRODUCT_STRING);
}
free (base);
} else {
int i;
char product[sizeof(FREERDP_PRODUCT_STRING)];
memset(product, 0, sizeof(product));
for (i=0; i<sizeof(product); i++)
product[i] = tolower(FREERDP_PRODUCT_STRING[i]);
settings->ConfigPath = GetKnownSubPath(
KNOWN_PATH_XDG_CONFIG_HOME,
product);
}
free (base);
} else {
int i;
char product[sizeof(FREERDP_PRODUCT_STRING)];
memset(product, 0, sizeof(product));
for (i=0; i<sizeof(product); i++)
product[i] = tolower(FREERDP_PRODUCT_STRING[i]);
settings->ConfigPath = GetKnownSubPath(
KNOWN_PATH_XDG_CONFIG_HOME,
product);
if (!settings->ConfigPath)
goto out_fail;
}
if (!settings->ConfigPath)
goto out_fail;
settings_load_hkey_local_machine(settings);
settings->SettingsModified = (BYTE*) calloc(1, sizeof(rdpSettings) / 8 );