- ported trunk commit 2801 into branch

Currently the only way to induce a bug is start rs for an ssl_id which
	which does not have a password saved, then try use an ssl id at start
	dialog  which does or does not have a pword (help_pword:bool enters an
	illegal state) 

	I have fixed it by checking if rsinit::passwd == "" then trying to load for
	that ssl_id, if that fails then i set help_pword to false; does not have
	password and pass flow to gpg to ask for passwd. (problem was rs thought
	user had help/pass file and they didn't).

	i have checked it in and tested for
	1. starting with ssl_id which has saved pword, and switching ids at start
		dialog
	2. secondary id may or may not have saved pword. 

- added check for the result of fscanf



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@2802 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-04-27 18:50:37 +00:00
parent d451adc1a6
commit 502e006352

View File

@ -1131,7 +1131,14 @@ int RsInit::LoadCertificates(bool autoLoginNT)
if(helpFile != NULL){ if(helpFile != NULL){
have_help = true; have_help = true;
fclose(helpFile); fclose(helpFile);
if(RsInitConfig::passwd == ""){ // in case user chooses a different user later in setup
RsInitConfig::havePasswd = RsTryAutoLogin();
have_help = RsInitConfig::havePasswd;
}
} }
/* The SSL / SSL + PGP version requires, SSL init + PGP init. */ /* The SSL / SSL + PGP version requires, SSL init + PGP init. */
@ -1142,7 +1149,7 @@ int RsInit::LoadCertificates(bool autoLoginNT)
//check if password is already in memory //check if password is already in memory
if (((RsInitConfig::havePasswd) && (RsInitConfig::passwd != "")) && !have_help) if (((RsInitConfig::havePasswd) && (RsInitConfig::passwd != "")) && !have_help)
{ {
std::cerr << "RetroShare has a ssl Password" << std::endl; std::cerr << "RetroShare has an ssl Password" << std::endl;
sslPassword = RsInitConfig::passwd.c_str(); sslPassword = RsInitConfig::passwd.c_str();
std::cerr << "let's store the ssl Password into a pgp ecrypted file" << std::endl; std::cerr << "let's store the ssl Password into a pgp ecrypted file" << std::endl;
@ -1576,7 +1583,11 @@ bool RsInit::RsTryAutoLogin()
unsigned char* indata = new unsigned char[DAT_LEN]; unsigned char* indata = new unsigned char[DAT_LEN];
unsigned char* outdata = new unsigned char[DAT_LEN]; unsigned char* outdata = new unsigned char[DAT_LEN];
fscanf(helpFile, "%s", indata); if(fscanf(helpFile, "%s", indata) != 1)
{
std::cerr << "Can't read RSA key in help file " << helpFileName << ". Sorry." << std::endl ;
return false ;
}
RC4_KEY* key = new RC4_KEY; RC4_KEY* key = new RC4_KEY;
RC4_set_key(key, KEY_DAT_LEN, key_data); RC4_set_key(key, KEY_DAT_LEN, key_data);