diff options
Diffstat (limited to 'linden/indra/newview/llstartup.cpp')
-rw-r--r-- | linden/indra/newview/llstartup.cpp | 150 |
1 files changed, 145 insertions, 5 deletions
diff --git a/linden/indra/newview/llstartup.cpp b/linden/indra/newview/llstartup.cpp index e29dc5a..66849b1 100644 --- a/linden/indra/newview/llstartup.cpp +++ b/linden/indra/newview/llstartup.cpp | |||
@@ -1004,8 +1004,9 @@ bool idle_startup() | |||
1004 | gDebugInfo["LoginName"] = firstname + " " + lastname; | 1004 | gDebugInfo["LoginName"] = firstname + " " + lastname; |
1005 | 1005 | ||
1006 | // create necessary directories | 1006 | // create necessary directories |
1007 | gDirUtilp->setLindenUserDir(gHippoGridManager->getCurrentGridNick(), firstname, lastname); | 1007 | // *FIX: these mkdir's should error check |
1008 | LLFile::mkdir(gDirUtilp->getLindenUserDir()); | 1008 | gDirUtilp->setViewerUserDir(gHippoGridManager->getCurrentGridNick(), firstname, lastname); |
1009 | LLFile::mkdir(gDirUtilp->getViewerUserDir()); | ||
1009 | } | 1010 | } |
1010 | else | 1011 | else |
1011 | { | 1012 | { |
@@ -1289,7 +1290,7 @@ bool idle_startup() | |||
1289 | 1290 | ||
1290 | char hashed_mac_string[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */ | 1291 | char hashed_mac_string[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */ |
1291 | LLMD5 hashed_mac; | 1292 | LLMD5 hashed_mac; |
1292 | hashed_mac.update( gMACAddress, MAC_ADDRESS_BYTES ); | 1293 | hashed_mac.update( (const unsigned char*) "012345", MAC_ADDRESS_BYTES ); // Nope, LL ain't getting our MAC, and meta7 does not need it. |
1293 | hashed_mac.finalize(); | 1294 | hashed_mac.finalize(); |
1294 | hashed_mac.hex_digest(hashed_mac_string); | 1295 | hashed_mac.hex_digest(hashed_mac_string); |
1295 | 1296 | ||
@@ -2524,7 +2525,7 @@ bool idle_startup() | |||
2524 | } | 2525 | } |
2525 | } | 2526 | } |
2526 | // Either we want to show tutorial because this is the first login | 2527 | // Either we want to show tutorial because this is the first login |
2527 | // to a Linden Help Island or the user quit with the tutorial | 2528 | // to a grid Help Island or the user quit with the tutorial |
2528 | // visible. JC | 2529 | // visible. JC |
2529 | if (show_hud | 2530 | if (show_hud |
2530 | || gSavedSettings.getBOOL("ShowTutorial")) | 2531 | || gSavedSettings.getBOOL("ShowTutorial")) |
@@ -3102,6 +3103,145 @@ void login_callback(S32 option, void *userdata) | |||
3102 | } | 3103 | } |
3103 | 3104 | ||
3104 | 3105 | ||
3106 | // static | ||
3107 | std::string LLStartUp::loadPasswordFromDisk() | ||
3108 | { | ||
3109 | // Only load password if we also intend to save it (otherwise the user | ||
3110 | // wonders what we're doing behind his back). JC | ||
3111 | BOOL remember_password = gSavedSettings.getBOOL("RememberPassword"); | ||
3112 | if (!remember_password) | ||
3113 | { | ||
3114 | return std::string(""); | ||
3115 | } | ||
3116 | |||
3117 | std::string hashed_password(""); | ||
3118 | |||
3119 | // Look for legacy "marker" password from settings.ini | ||
3120 | hashed_password = gSavedSettings.getString("Marker"); | ||
3121 | if (!hashed_password.empty()) | ||
3122 | { | ||
3123 | // Stomp the Marker entry. | ||
3124 | gSavedSettings.setString("Marker", ""); | ||
3125 | |||
3126 | // Return that password. | ||
3127 | return hashed_password; | ||
3128 | } | ||
3129 | |||
3130 | // UUID is 16 bytes, written into ASCII is 32 characters | ||
3131 | // without trailing \0 | ||
3132 | const S32 HASHED_LENGTH = 32; | ||
3133 | |||
3134 | std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, | ||
3135 | "password.dat"); | ||
3136 | LLFILE* fp = LLFile::fopen(filepath, "rb"); /* Flawfinder: ignore */ | ||
3137 | if (!fp) | ||
3138 | { | ||
3139 | #if LL_DARWIN | ||
3140 | UInt32 passwordLength; | ||
3141 | char *passwordData; | ||
3142 | OSStatus stat = SecKeychainFindGenericPassword(NULL, 10, "meta-impy", 0, NULL, &passwordLength, (void**)&passwordData, NULL); | ||
3143 | if (stat == noErr) | ||
3144 | { | ||
3145 | if (passwordLength == HASHED_LENGTH) | ||
3146 | hashed_password.assign(passwordData, HASHED_LENGTH); | ||
3147 | SecKeychainItemFreeContent(NULL, passwordData); | ||
3148 | } | ||
3149 | #endif | ||
3150 | return hashed_password; | ||
3151 | } | ||
3152 | |||
3153 | U8 buffer[HASHED_LENGTH+1]; | ||
3154 | |||
3155 | if (1 != fread(buffer, HASHED_LENGTH, 1, fp)) | ||
3156 | { | ||
3157 | return hashed_password; | ||
3158 | } | ||
3159 | |||
3160 | fclose(fp); | ||
3161 | |||
3162 | // Decipher with MAC address | ||
3163 | LLXORCipher cipher(gMACAddress, 6); // The one and only legitimate use of the users MAC. | ||
3164 | cipher.decrypt(buffer, HASHED_LENGTH); | ||
3165 | |||
3166 | buffer[HASHED_LENGTH] = '\0'; | ||
3167 | |||
3168 | // Check to see if the mac address generated a bad hashed | ||
3169 | // password. It should be a hex-string or else the mac adress has | ||
3170 | // changed. This is a security feature to make sure that if you | ||
3171 | // get someone's password.dat file, you cannot hack their account. | ||
3172 | if(is_hex_string(buffer, HASHED_LENGTH)) | ||
3173 | { | ||
3174 | hashed_password.assign((char*)buffer); | ||
3175 | } | ||
3176 | #if LL_DARWIN | ||
3177 | // we're migrating to the keychain | ||
3178 | LLFile::remove(filepath); | ||
3179 | #endif | ||
3180 | |||
3181 | return hashed_password; | ||
3182 | } | ||
3183 | |||
3184 | |||
3185 | // static | ||
3186 | void LLStartUp::savePasswordToDisk(const std::string& hashed_password) | ||
3187 | { | ||
3188 | #if LL_DARWIN | ||
3189 | SecKeychainItemRef keychainItem; | ||
3190 | OSStatus status = SecKeychainFindGenericPassword(NULL, 10, "meta-impy", 0, NULL, NULL, NULL, &keychainItem); | ||
3191 | if (status == noErr) | ||
3192 | { | ||
3193 | SecKeychainItemModifyAttributesAndData(keychainItem, NULL, hashed_password.length(), hashed_password.c_str()); | ||
3194 | CFRelease(keychainItem); | ||
3195 | } | ||
3196 | else | ||
3197 | { | ||
3198 | SecKeychainAddGenericPassword(NULL, 10, "meta-impy", 0, NULL, hashed_password.length(), hashed_password.c_str(), NULL); | ||
3199 | } | ||
3200 | #else | ||
3201 | std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, | ||
3202 | "password.dat"); | ||
3203 | LLFILE* fp = LLFile::fopen(filepath, "wb"); /* Flawfinder: ignore */ | ||
3204 | if (!fp) | ||
3205 | { | ||
3206 | return; | ||
3207 | } | ||
3208 | |||
3209 | // Encipher with MAC address | ||
3210 | const S32 HASHED_LENGTH = 32; | ||
3211 | U8 buffer[HASHED_LENGTH+1]; | ||
3212 | |||
3213 | LLStringUtil::copy((char*)buffer, hashed_password.c_str(), HASHED_LENGTH+1); | ||
3214 | |||
3215 | LLXORCipher cipher(gMACAddress, 6); // The one and only legitimate use of the users MAC. | ||
3216 | cipher.encrypt(buffer, HASHED_LENGTH); | ||
3217 | |||
3218 | if (fwrite(buffer, HASHED_LENGTH, 1, fp) != 1) | ||
3219 | { | ||
3220 | LL_WARNS("AppInit") << "Short write" << LL_ENDL; | ||
3221 | } | ||
3222 | |||
3223 | fclose(fp); | ||
3224 | #endif | ||
3225 | } | ||
3226 | |||
3227 | |||
3228 | // static | ||
3229 | void LLStartUp::deletePasswordFromDisk() | ||
3230 | { | ||
3231 | #if LL_DARWIN | ||
3232 | SecKeychainItemRef keychainItem; | ||
3233 | OSStatus status = SecKeychainFindGenericPassword(NULL, 10, "meta-impy", 0, NULL, NULL, NULL, &keychainItem); | ||
3234 | if (status == noErr) | ||
3235 | { | ||
3236 | SecKeychainItemDelete(keychainItem); | ||
3237 | CFRelease(keychainItem); | ||
3238 | } | ||
3239 | #endif | ||
3240 | std::string filepath = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, | ||
3241 | "password.dat"); | ||
3242 | LLFile::remove(filepath); | ||
3243 | } | ||
3244 | |||
3105 | void show_first_run_dialog() | 3245 | void show_first_run_dialog() |
3106 | { | 3246 | { |
3107 | LLNotifications::instance().add("FirstRun", LLSD(), LLSD(), first_run_dialog_callback); | 3247 | LLNotifications::instance().add("FirstRun", LLSD(), LLSD(), first_run_dialog_callback); |
@@ -3687,7 +3827,7 @@ void init_start_screen(S32 location_id) | |||
3687 | 3827 | ||
3688 | LL_DEBUGS("AppInit") << "Loading startup bitmap..." << LL_ENDL; | 3828 | LL_DEBUGS("AppInit") << "Loading startup bitmap..." << LL_ENDL; |
3689 | 3829 | ||
3690 | std::string temp_str = gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter(); | 3830 | std::string temp_str = gDirUtilp->getViewerUserDir() + gDirUtilp->getDirDelimiter(); |
3691 | 3831 | ||
3692 | if ((S32)START_LOCATION_ID_LAST == location_id) | 3832 | if ((S32)START_LOCATION_ID_LAST == location_id) |
3693 | { | 3833 | { |