diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-06-20 23:48:28 +0200 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-06-20 23:48:28 +0200 | 
| commit | ece2cd2eba78088a8cf9d4744aafb3f34dc97c5b (patch) | |
| tree | b49c2ed4e9c9a5c94483c4b352a22a0a386ac195 /storage_xml.c | |
| parent | 2befb95e3bdaf5306b55342c175abca174e40ffb (diff) | |
xml_save() now stores the password's md5sum too. Kind of ... important..
Diffstat (limited to 'storage_xml.c')
| -rw-r--r-- | storage_xml.c | 20 | 
1 files changed, 17 insertions, 3 deletions
| diff --git a/storage_xml.c b/storage_xml.c index 57388f67..87fbb693 100644 --- a/storage_xml.c +++ b/storage_xml.c @@ -342,11 +342,19 @@ static int xml_printf( int fd, char *fmt, ... )  static storage_status_t xml_save( irc_t *irc, int overwrite )  { -	char path[512], *path2; +	char path[512], *path2, md5_buf[33];  	set_t *set;  	nick_t *nick;  	account_t *acc; -	int fd; +	int fd, i; +	md5_byte_t pass_md5[16]; +	md5_state_t md5_state; +	 +	if( irc->password == NULL ) +	{ +		irc_usermsg( irc, "Please register yourself if you want to save your settings." ); +		return STORAGE_OTHER_ERROR; +	}  	g_snprintf( path, sizeof( path ) - 2, "%s%s%s", global.conf->configdir, irc->nick, ".xml" ); @@ -360,7 +368,13 @@ static storage_status_t xml_save( irc_t *irc, int overwrite )  		return STORAGE_OTHER_ERROR;  	} -	if( !xml_printf( fd, "<user nick=\"%s\" password=\"%s\">\n", irc->nick, irc->password ) ) +	md5_init( &md5_state ); +	md5_append( &md5_state, (md5_byte_t*) irc->password, strlen( irc->password ) ); +	md5_finish( &md5_state, pass_md5 ); +	for( i = 0; i < 16; i ++ ) +		g_snprintf( md5_buf + i * 2, 3, "%02x", pass_md5[i] ); +	 +	if( !xml_printf( fd, "<user nick=\"%s\" password=\"%s\">\n", irc->nick, md5_buf ) )  		goto write_error;  	for( set = irc->set; set; set = set->next ) | 
