From ece2cd2eba78088a8cf9d4744aafb3f34dc97c5b Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Tue, 20 Jun 2006 23:48:28 +0200 Subject: xml_save() now stores the password's md5sum too. Kind of ... important.. --- storage_xml.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'storage_xml.c') 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, "\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, "\n", irc->nick, md5_buf ) ) goto write_error; for( set = irc->set; set; set = set->next ) -- cgit v1.2.3