From 1b68f71348ecf3983b76b40d7940da8377f049b7 Mon Sep 17 00:00:00 2001 From: Andrey Lihatskiy Date: Mon, 29 Apr 2024 07:43:28 +0300 Subject: #824 Process source files in bulk: replace tabs with spaces, convert CRLF to LF, and trim trailing whitespaces as needed --- indra/newview/llviewernetwork.cpp | 950 +++++++++++++++++++------------------- 1 file changed, 475 insertions(+), 475 deletions(-) (limited to 'indra/newview/llviewernetwork.cpp') diff --git a/indra/newview/llviewernetwork.cpp b/indra/newview/llviewernetwork.cpp index be05ac0d3a..16ddc2f89c 100644 --- a/indra/newview/llviewernetwork.cpp +++ b/indra/newview/llviewernetwork.cpp @@ -79,18 +79,18 @@ const char* DEFAULT_SLURL_BASE = "https://%s/region/"; const char* DEFAULT_APP_SLURL_BASE = "x-grid-location-info://%s/app"; LLGridManager::LLGridManager() -: mIsInProductionGrid(false) +: mIsInProductionGrid(false) { - // by default, we use the 'grids.xml' file in the user settings directory - // this file is an LLSD file containing multiple grid definitions. - // This file does not contain definitions for secondlife.com grids, - // as that would be a security issue when they are overwritten by - // an attacker. Don't want someone snagging a password. - std::string grid_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, - "grids.xml"); - LL_DEBUGS("GridManager")<getExpandedFilename(LL_PATH_USER_SETTINGS, + "grids.xml"); + LL_DEBUGS("GridManager")<first; - LLSD grid = grid_itr->second; - - std::string existingGrid = getGrid(grid); - if (mGridList.has(key_name) || !existingGrid.empty()) - { - LL_WARNS("GridManager") << "Cannot override existing grid '" << key_name << "'; ignoring definition from '"<getSignal()->connect(boost::bind(&LLGridManager::updateIsInProductionGrid, this)); - } - - // since above only triggers on changes, trigger the callback manually to initialize state - updateIsInProductionGrid(); - - setGridChoice(mGrid); + // default grid list. + // Don't move to a modifiable file for security reasons, + mGrid.clear() ; + + // set to undefined + mGridList = LLSD(); + mGridFile = grid_file; + // as we don't want an attacker to override our grid list + // to point the default grid to an invalid grid + addSystemGrid(LLTrans::getString("AgniGridLabel"), + MAINGRID, + MAIN_GRID_LOGIN_URI, + "https://secondlife.com/helpers/", + DEFAULT_LOGIN_PAGE, + SL_UPDATE_QUERY_URL, + MAIN_GRID_WEB_PROFILE_URL, + "Agni"); + addSystemGrid(LLTrans::getString("AditiGridLabel"), + "util.aditi.lindenlab.com", + "https://login.aditi.lindenlab.com/cgi-bin/login.cgi", + "https://secondlife.aditi.lindenlab.com/helpers/", + DEFAULT_LOGIN_PAGE, + SL_UPDATE_QUERY_URL, + "https://my.secondlife-beta.com/", + "Aditi"); + + LLSD other_grids; + llifstream llsd_xml; + if (!grid_file.empty()) + { + LL_INFOS("GridManager")<<"Grid configuration file '"<first; + LLSD grid = grid_itr->second; + + std::string existingGrid = getGrid(grid); + if (mGridList.has(key_name) || !existingGrid.empty()) + { + LL_WARNS("GridManager") << "Cannot override existing grid '" << key_name << "'; ignoring definition from '"<getSignal()->connect(boost::bind(&LLGridManager::updateIsInProductionGrid, this)); + } + + // since above only triggers on changes, trigger the callback manually to initialize state + updateIsInProductionGrid(); + + setGridChoice(mGrid); } LLGridManager::~LLGridManager() @@ -250,432 +250,432 @@ LLGridManager::~LLGridManager() bool LLGridManager::addGrid(LLSD& grid_data) { - bool added = false; - if (grid_data.isMap() && grid_data.has(GRID_VALUE)) - { - std::string grid = utf8str_tolower(grid_data[GRID_VALUE].asString()); - - if ( getGrid(grid_data[GRID_VALUE]).empty() && getGrid(grid).empty() ) - { - std::string grid_id = grid_data.has(GRID_ID_VALUE) ? grid_data[GRID_ID_VALUE].asString() : ""; - if ( getGrid(grid_id).empty() ) - { - // populate the other values if they don't exist - if (!grid_data.has(GRID_LABEL_VALUE)) - { - grid_data[GRID_LABEL_VALUE] = grid; - } - if (!grid_data.has(GRID_ID_VALUE)) - { - grid_data[GRID_ID_VALUE] = grid; - } - - // if the grid data doesn't include any of the URIs, then - // generate them from the grid, which should be a dns address - if (!grid_data.has(GRID_LOGIN_URI_VALUE)) - { - grid_data[GRID_LOGIN_URI_VALUE] = LLSD::emptyArray(); - grid_data[GRID_LOGIN_URI_VALUE].append(std::string("https://") + - grid + "/cgi-bin/login.cgi"); - } - // Populate to the default values - if (!grid_data.has(GRID_LOGIN_PAGE_VALUE)) - { - grid_data[GRID_LOGIN_PAGE_VALUE] = std::string("http://") + grid + "/app/login/"; - } - if (!grid_data.has(GRID_HELPER_URI_VALUE)) - { - grid_data[GRID_HELPER_URI_VALUE] = std::string("https://") + grid + "/helpers/"; - } - if (!grid_data.has(GRID_WEB_PROFILE_VALUE)) - { - grid_data[GRID_WEB_PROFILE_VALUE] = std::string("https://") + grid + "/"; - } - - if (!grid_data.has(GRID_LOGIN_IDENTIFIER_TYPES)) - { - // non system grids and grids that haven't already been configured with values - // get both types of credentials. - grid_data[GRID_LOGIN_IDENTIFIER_TYPES] = LLSD::emptyArray(); - grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_AGENT); - grid_data[GRID_LOGIN_IDENTIFIER_TYPES].append(CRED_IDENTIFIER_TYPE_ACCOUNT); - } - - LL_DEBUGS("GridManager") <asString()<<"\n"; - } - LL_CONT << LL_ENDL; - mGridList[grid] = grid_data; - added = true; - } - else - { - LL_WARNS("GridManager")<<"duplicate grid id'"<asString()<<"\n"; + } + LL_CONT << LL_ENDL; + mGridList[grid] = grid_data; + added = true; + } + else + { + LL_WARNS("GridManager")<<"duplicate grid id'"< grid label mappings for UI purposes std::map LLGridManager::getKnownGrids() { - std::map result; - for(LLSD::map_iterator grid_iter = mGridList.beginMap(); - grid_iter != mGridList.endMap(); - grid_iter++) - { - result[grid_iter->first] = grid_iter->second[GRID_LABEL_VALUE].asString(); - } - - return result; + std::map result; + for(LLSD::map_iterator grid_iter = mGridList.beginMap(); + grid_iter != mGridList.endMap(); + grid_iter++) + { + result[grid_iter->first] = grid_iter->second[GRID_LABEL_VALUE].asString(); + } + + return result; } void LLGridManager::setGridChoice(const std::string& grid) { - // Set the grid choice based on a string. - LL_DEBUGS("GridManager")<<"requested "<second.has(GRID_ID_VALUE)) - { - if (0 == (LLStringUtil::compareInsensitive(grid, - grid_iter->second[GRID_ID_VALUE].asString()))) - { - // found a matching label, return this name - grid_name = grid_iter->first; - } - } - } - } - return grid_name; + std::string grid_name; + + if (mGridList.has(grid)) + { + // the grid was the long name, so we're good, return it + grid_name = grid; + } + else + { + // search the grid list for a grid with a matching id + for(LLSD::map_iterator grid_iter = mGridList.beginMap(); + grid_name.empty() && grid_iter != mGridList.endMap(); + grid_iter++) + { + if (grid_iter->second.has(GRID_ID_VALUE)) + { + if (0 == (LLStringUtil::compareInsensitive(grid, + grid_iter->second[GRID_ID_VALUE].asString()))) + { + // found a matching label, return this name + grid_name = grid_iter->first; + } + } + } + } + return grid_name; } std::string LLGridManager::getGridLabel(const std::string& grid) { - std::string grid_label; - std::string grid_name = getGrid(grid); - if (!grid.empty()) - { - grid_label = mGridList[grid_name][GRID_LABEL_VALUE].asString(); - } - else - { - LL_WARNS("GridManager")<<"invalid grid '"<& uris) { - uris.clear(); - std::string grid_name = getGrid(grid); - if (!grid_name.empty()) - { + uris.clear(); + std::string grid_name = getGrid(grid); + if (!grid_name.empty()) + { if (mGridList[grid_name][GRID_LOGIN_URI_VALUE].isArray()) { - for (LLSD::array_iterator llsd_uri = mGridList[grid_name][GRID_LOGIN_URI_VALUE].beginArray(); - llsd_uri != mGridList[grid_name][GRID_LOGIN_URI_VALUE].endArray(); - llsd_uri++) - { - uris.push_back(llsd_uri->asString()); - } + for (LLSD::array_iterator llsd_uri = mGridList[grid_name][GRID_LOGIN_URI_VALUE].beginArray(); + llsd_uri != mGridList[grid_name][GRID_LOGIN_URI_VALUE].endArray(); + llsd_uri++) + { + uris.push_back(llsd_uri->asString()); + } } else { uris.push_back(mGridList[grid_name][GRID_LOGIN_URI_VALUE].asString()); } - } - else - { - LL_WARNS("GridManager")<<"invalid grid '"<& uris) { - getLoginURIs(mGrid, uris); + getLoginURIs(mGrid, uris); } std::string LLGridManager::getHelperURI(const std::string& grid) { - std::string helper_uri; - std::string grid_name = getGrid(grid); - if (!grid_name.empty()) - { - helper_uri = mGridList[grid_name][GRID_HELPER_URI_VALUE].asString(); - } - else - { - LL_WARNS("GridManager")<<"invalid grid '"< uris; - getLoginURIs(uris); - if (uris.empty()) - { - mIsInProductionGrid = true; - } - else - { - for ( std::vector::iterator uri_it = uris.begin(); - ! mIsInProductionGrid && uri_it != uris.end(); - uri_it++ - ) - { - if( MAIN_GRID_LOGIN_URI == *uri_it ) - { - mIsInProductionGrid = true; - } - } - } + mIsInProductionGrid = false; + + // *NOTE:Mani This used to compare GRID_INFO_AGNI to gGridChoice, + // but it seems that loginURI trumps that. + std::vector uris; + getLoginURIs(uris); + if (uris.empty()) + { + mIsInProductionGrid = true; + } + else + { + for ( std::vector::iterator uri_it = uris.begin(); + ! mIsInProductionGrid && uri_it != uris.end(); + uri_it++ + ) + { + if( MAIN_GRID_LOGIN_URI == *uri_it ) + { + mIsInProductionGrid = true; + } + } + } } bool LLGridManager::isInProductionGrid() { - return mIsInProductionGrid; + return mIsInProductionGrid; } bool LLGridManager::isSystemGrid(const std::string& grid) { - std::string grid_name = getGrid(grid); + std::string grid_name = getGrid(grid); - return ( !grid_name.empty() - && mGridList.has(grid) - && mGridList[grid].has(GRID_IS_SYSTEM_GRID_VALUE) - && mGridList[grid][GRID_IS_SYSTEM_GRID_VALUE].asBoolean() - ); + return ( !grid_name.empty() + && mGridList.has(grid) + && mGridList[grid].has(GRID_IS_SYSTEM_GRID_VALUE) + && mGridList[grid][GRID_IS_SYSTEM_GRID_VALUE].asBoolean() + ); } // build a slurl for the given region within the selected grid std::string LLGridManager::getSLURLBase(const std::string& grid) { - std::string grid_base = ""; - std::string grid_name = getGrid(grid); - if( ! grid_name.empty() && mGridList.has(grid_name) ) - { - if (mGridList[grid_name].has(GRID_SLURL_BASE)) - { - grid_base = mGridList[grid_name][GRID_SLURL_BASE].asString(); - } - else - { - grid_base = llformat(DEFAULT_SLURL_BASE, grid_name.c_str()); - } - } - LL_DEBUGS("GridManager")<<"returning '"<