X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconn.c;h=e57aa2423a3eea2bbdacea0500fe9e3452ddb0bf;hp=28a0341e0a28e1485c077393671b51702b1e6141;hb=bcefdef1eaed14d3156b7fb5b9ad6d3b7078efcf;hpb=360a254be0e55e975998d0f3a5ff301ac3346f72 diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 28a0341e..e57aa242 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -918,6 +918,30 @@ va_dcl return ok; } /* Conn_WriteStr */ +GLOBAL char* +Conn_Password( CONN_ID Idx ) +{ + assert( Idx > NONE ); + if (My_Connections[Idx].pwd == NULL) + return (char*)"\0"; + else + return My_Connections[Idx].pwd; +} /* Conn_Password */ + +GLOBAL void +Conn_SetPassword( CONN_ID Idx, const char *Pwd ) +{ + assert( Idx > NONE ); + + if (My_Connections[Idx].pwd) + free(My_Connections[Idx].pwd); + + My_Connections[Idx].pwd = strdup(Pwd); + if (My_Connections[Idx].pwd == NULL) { + Log(LOG_EMERG, "Can't allocate memory! [Conn_SetPassword]"); + exit(1); + } +} /* Conn_SetPassword */ /** * Append Data to the outbound write buffer of a connection. @@ -1146,6 +1170,8 @@ Conn_Close( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClie array_free(&My_Connections[Idx].rbuf); array_free(&My_Connections[Idx].wbuf); + if (My_Connections[Idx].pwd != NULL) + free(My_Connections[Idx].pwd); /* Clean up connection structure (=free it) */ Init_Conn_Struct( Idx );