[srvx-commits] CVS: services/src nickserv.c,1.208,1.209
Brought to you by:
entrope
|
From: Zoot <zo...@us...> - 2002-10-16 03:36:13
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv10052/src
Modified Files:
nickserv.c
Log Message:
Make account ID assignment more robust: check for duplicates even when debug mode is off.
Index: nickserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.c,v
retrieving revision 1.208
retrieving revision 1.209
diff -C2 -r1.208 -r1.209
*** nickserv.c 11 Oct 2002 03:07:10 -0000 1.208
--- nickserv.c 16 Oct 2002 03:36:10 -0000 1.209
***************
*** 322,346 ****
char id_base64[IDLEN + 1];
! /* Assign a unique account ID to the account; note that 0 is
! an invalid account ID. 1 is therefore the first account ID. */
! if (!id) {
! id = 1 + highest_id++;
! } else {
! /* highest_id is always the highest ID, so if we're seeing an ID
! again, panic. */
! assert(id != highest_id);
! if(id > highest_id) {
! highest_id = id;
! }
! }
! inttobase64(id_base64, id, IDLEN);
!
! #ifndef NDEBUG
! /* Make sure an account with the same ID doesn't exist. This is
! truly impossible, but it never hurts to expect it. */
! if ((hi = dict_find(nickserv_id_dict, id_base64, NULL))) {
! log(NS_LOG, LOG_WARNING, "Duplicated account ID %lu (%s) found belonging to %s while inserting %s.\n", id, id_base64, hi->handle, handle);
! }
! #endif
hi = calloc(1, sizeof(*hi));
--- 322,347 ----
char id_base64[IDLEN + 1];
! do
! {
! /* Assign a unique account ID to the account; note that 0 is
! an invalid account ID. 1 is therefore the first account ID. */
! if (!id) {
! id = 1 + highest_id++;
! } else {
! /* Note: highest_id is and must always be the highest ID. */
! if(id > highest_id) {
! highest_id = id;
! }
! }
! inttobase64(id_base64, id, IDLEN);
!
! /* Make sure an account with the same ID doesn't exist. If a
! duplicate is found, log some details and assign a new one.
! This should be impossible, but it never hurts to expect it. */
! if ((hi = dict_find(nickserv_id_dict, id_base64, NULL))) {
! log(NS_LOG, LOG_WARNING, "Duplicated account ID %lu (%s) found belonging to %s while inserting %s.\n", id, id_base64, hi->handle, handle);
! id = 0;
! }
! } while(!id);
hi = calloc(1, sizeof(*hi));
***************
*** 786,796 ****
if (stamp) {
! #ifdef WITH_PROTOCOL_P10
! char *id = hi->handle;
! #else
char id[IDLEN + 1];
-
- /* Stamp the user with an account ID. */
inttobase64(id, hi->id, IDLEN);
#endif
StampUser(user, id);
--- 787,797 ----
if (stamp) {
! #ifndef WITH_PROTOCOL_P10
! /* Stamp users with their account ID. */
char id[IDLEN + 1];
inttobase64(id, hi->id, IDLEN);
+ #else
+ /* Stamp users with their account name. */
+ char *id = hi->handle;
#endif
StampUser(user, id);
|