[srvx-commits] CVS: services/src nickserv.c,1.188,1.189 nickserv.h,1.35,1.36
Brought to you by:
entrope
|
From: Zoot <zo...@us...> - 2002-08-07 03:02:21
|
Update of /cvsroot/srvx/services/src
In directory usw-pr-cvs1:/tmp/cvs-serv14813/src
Modified Files:
nickserv.c nickserv.h
Log Message:
Assign accounts unique numeric IDs in preparation for P10 ACCOUNT support.
Index: nickserv.c
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.c,v
retrieving revision 1.188
retrieving revision 1.189
diff -C2 -r1.188 -r1.189
*** nickserv.c 7 Aug 2002 02:49:20 -0000 1.188
--- nickserv.c 7 Aug 2002 03:02:18 -0000 1.189
***************
*** 70,73 ****
--- 70,74 ----
#define KEY_ACCOUNTS_PER_EMAIL "accounts_per_email"
+ #define KEY_ID "id"
#define KEY_PASSWD "passwd"
#define KEY_NICKS "nicks"
***************
*** 135,138 ****
--- 136,140 ----
#define NSMSG_USER_IS_SERVICE "$b%s$b is a network service; you can only use that command on real users."
#define NSMSG_HANDLEINFO_ON "Account information for $b%s$b:"
+ #define NSMSG_HANDLEINFO_ID " Account ID: %lu"
#define NSMSG_HANDLEINFO_REGGED " Registered on: %s"
#define NSMSG_HANDLEINFO_LASTSEEN " Last seen: %s"
***************
*** 286,289 ****
--- 288,294 ----
} nickserv_conf;
+ /* We have 2^32 unique account IDs to use. */
+ unsigned long int highest_id = 0;
+
const char *NSMSG_VERSION_ID = "$Id$";
***************
*** 303,310 ****
static struct handle_info *
! register_handle(const char *handle, const char *passwd)
{
struct handle_info *hi;
hi = calloc(1, sizeof(*hi));
hi->userlist_style = HI_DEFAULT_STYLE;
hi->announcements = '?';
--- 308,328 ----
static struct handle_info *
! register_handle(const char *handle, const char *passwd, unsigned long int id)
{
struct handle_info *hi;
+
+ /* Assign a unique account ID to the account. */
+ 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;
+ }
+ }
hi = calloc(1, sizeof(*hi));
+ hi->id = id;
hi->userlist_style = HI_DEFAULT_STYLE;
hi->announcements = '?';
***************
*** 751,755 ****
cryptpass(passwd, crypted);
! hi = register_handle(handle, crypted);
hi->masks = alloc_string_list(1);
hi->users = NULL;
--- 769,773 ----
cryptpass(passwd, crypted);
! hi = register_handle(handle, crypted, 0);
hi->masks = alloc_string_list(1);
hi->users = NULL;
***************
*** 1043,1046 ****
--- 1061,1065 ----
nickserv_notice(user, NSMSG_HANDLEINFO_ON, hi->handle);
+ nickserv_notice(user, NSMSG_HANDLEINFO_ID, hi->id);
nickserv_notice(user, NSMSG_HANDLEINFO_REGGED, ctime(&hi->registered));
***************
*** 2235,2238 ****
--- 2254,2263 ----
/* create the object */
dict_t obj = alloc_object();
+ assert(hi);
+
+ /* set account ID - must have been assigned */
+ assert(hi->id);
+ snprintf(num, sizeof(num), FMT_TIME_T, hi->id);
+ dict_insert(obj, KEY_ID, alloc_record_data_qstring(num));
/* set the password */
dict_insert(obj, KEY_PASSWD, alloc_record_data_qstring(hi->passwd));
***************
*** 2749,2755 ****
--- 2774,2783 ----
struct handle_info *hi;
struct userNode *authed_users;
+ unsigned long int id;
unsigned int ii;
dict_t subdb;
+ str = database_get_data(obj, KEY_ID, RECDB_QSTRING);
+ id = str ? strtoul(str, NULL, 0) : 0;
str = database_get_data(obj, KEY_PASSWD, RECDB_QSTRING);
if (!str) {
***************
*** 2764,2768 ****
authed_users = NULL;
}
! hi = register_handle(handle, str);
if (authed_users) {
hi->users = authed_users;
--- 2792,2796 ----
authed_users = NULL;
}
! hi = register_handle(handle, str, id);
if (authed_users) {
hi->users = authed_users;
Index: nickserv.h
===================================================================
RCS file: /cvsroot/srvx/services/src/nickserv.h,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -r1.35 -r1.36
*** nickserv.h 30 Jul 2002 02:15:11 -0000 1.35
--- nickserv.h 7 Aug 2002 03:02:18 -0000 1.36
***************
*** 73,76 ****
--- 73,77 ----
struct handle_info {
+ unsigned long int id;
struct nick_info *nicks; /* linked list of owned nicks */
struct string_list *masks;
|