summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-18 15:26:18 +0000
committerrburchell <rburchell@5417fbe8-f217-4b02-8779-1006273d7864>2008-11-18 15:26:18 +0000
commit16321e7638a0202345ac88e4c6af1982859d9111 (patch)
tree9d017dd068271834431e36d28a2b9014060627ee /src
parenta7e4a8e0fc23c03d177499a718ab27594175bf3a (diff)
Remove an insane amount of backwards compatibility from database loading, this means that only latest DB versions will load, others will print an error.
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@1750 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src')
-rw-r--r--src/chanserv.c43
-rw-r--r--src/hostserv.c70
-rw-r--r--src/nickserv.c269
-rw-r--r--src/operserv.c272
4 files changed, 73 insertions, 581 deletions
diff --git a/src/chanserv.c b/src/chanserv.c
index 3327f5b06..f42248098 100644
--- a/src/chanserv.c
+++ b/src/chanserv.c
@@ -555,49 +555,6 @@ void load_cs_dbase(void)
delchan(ci);
continue;
}
- if (ver < 13) {
- ChanAccess *access, *access2;
- AutoKick *akick, *akick2;
- int k;
-
- if (ci->flags & CI_VERBOTEN)
- continue;
- /* Need to regenerate the channel count for the founder */
- ci->founder->channelcount++;
- /* Check for eventual double entries in access/akick lists. */
- for (j = 0, access = ci->access; j < ci->accesscount;
- j++, access++) {
- if (!access->in_use)
- continue;
- for (k = 0, access2 = ci->access; k < j;
- k++, access2++) {
- if (access2->in_use && access2->nc == access->nc) {
- alog("%s: deleting %s channel access entry of %s because it is already in the list (this is OK).", s_ChanServ, access->nc->display, ci->name);
- memset(access, 0, sizeof(ChanAccess));
- break;
- }
- }
- }
- for (j = 0, akick = ci->akick; j < ci->akickcount;
- j++, akick++) {
- if (!(akick->flags & AK_USED)
- || !(akick->flags & AK_ISNICK))
- continue;
- for (k = 0, akick2 = ci->akick; k < j; k++, akick2++) {
- if ((akick2->flags & AK_USED)
- && (akick2->flags & AK_ISNICK)
- && akick2->u.nc == akick->u.nc) {
- alog("%s: deleting %s channel akick entry of %s because it is already in the list (this is OK).", s_ChanServ, akick->u.nc->display, ci->name);
- if (akick->reason)
- free(akick->reason);
- if (akick->creator)
- free(akick->creator);
- memset(akick, 0, sizeof(AutoKick));
- break;
- }
- }
- }
- }
}
}
}
diff --git a/src/hostserv.c b/src/hostserv.c
index d34a611a6..de3960273 100644
--- a/src/hostserv.c
+++ b/src/hostserv.c
@@ -18,9 +18,7 @@
#define HASH(nick) ((tolower((nick)[0])&31)<<5 | (tolower((nick)[1])&31))
-void load_hs_dbase_v1(dbFILE * f);
-void load_hs_dbase_v2(dbFILE * f);
-void load_hs_dbase_v3(dbFILE * f);
+void load_hs_dbase(dbFILE * f);
HostCore *head = NULL; /* head of the HostCore list */
@@ -377,69 +375,17 @@ void load_hs_dbase(void)
}
ver = get_file_version(f);
- if (ver == 1) {
- load_hs_dbase_v1(f);
- } else if (ver == 2) {
- load_hs_dbase_v2(f);
- } else if (ver == 3) {
- load_hs_dbase_v3(f);
- }
- close_db(f);
-}
-
-void load_hs_dbase_v1(dbFILE * f)
-{
- int c;
- int failed = 0;
- int32 tmp;
-
- char *nick;
- char *vHost;
-
- tmp = time(NULL);
-
- while (!failed && (c = getc_db(f)) == 1) {
-
- if (c == 1) {
- SAFE(read_string(&nick, f));
- SAFE(read_string(&vHost, f));
- addHostCore(nick, NULL, vHost, "Unknown", tmp); /* could get a speed increase by not searching the list */
- free(nick); /* as we know the db is in alphabetical order... */
- free(vHost);
- } else {
- fatal("Invalid format in %s %d", HostDBName, c);
- }
+ if (ver != 3) {
+ close_db(f);
+ fatal("DB %s is too old", HostDBName);
+ return;
}
-}
-void load_hs_dbase_v2(dbFILE * f)
-{
- int c;
- int failed = 0;
-
- char *nick;
- char *vHost;
- char *creator;
- uint32 time;
-
- while (!failed && (c = getc_db(f)) == 1) {
-
- if (c == 1) {
- SAFE(read_string(&nick, f));
- SAFE(read_string(&vHost, f));
- SAFE(read_string(&creator, f));
- SAFE(read_int32(&time, f));
- addHostCore(nick, NULL, vHost, creator, time); /* could get a speed increase by not searching the list */
- free(nick); /* as we know the db is in alphabetical order... */
- free(vHost);
- free(creator);
- } else {
- fatal("Invalid format in %s %d", HostDBName, c);
- }
- }
+ load_hs_dbase(f);
+ close_db(f);
}
-void load_hs_dbase_v3(dbFILE * f)
+void load_hs_dbase(dbFILE * f)
{
int c;
int failed = 0;
diff --git a/src/nickserv.c b/src/nickserv.c
index f1a9e818d..deab9545b 100644
--- a/src/nickserv.c
+++ b/src/nickserv.c
@@ -165,252 +165,6 @@ void nickserv(User * u, char *buf)
} \
} while (0)
-/* Loads NickServ database versions 5 to 11 (<= 4 is not supported) */
-
-void load_old_ns_dbase(void)
-{
- dbFILE *f;
- int ver, i, j, c;
- NickAlias *na, *na2, *next;
- NickCore *nc;
- int failed = 0;
-
- uint16 tmp16;
- uint32 tmp32;
-
- char bufn[NICKMAX], bufp[PASSMAX];
- char *email, *greet, *url, *forbidby, *forbidreason;
- uint32 icq;
-
- if (!(f = open_db(s_NickServ, NickDBName, "r", NICK_VERSION)))
- return;
-
- ver = get_file_version(f);
- if (ver <= 4) {
- fatal("Unsupported version number (%d) on %s", ver, NickDBName);
- close_db(f);
- return;
- }
-
- for (i = 0; i < 256 && !failed; i++) {
- while ((c = getc_db(f)) == 1) {
- if (c != 1)
- fatal("Invalid format in %s", NickDBName);
-
- na = new NickAlias();
-
- SAFE(read_buffer(bufn, f));
- na->nick = sstrdup(bufn);
- SAFE(read_buffer(bufp, f)); /* Will be used later if needed */
-
- SAFE(read_string(&url, f));
- SAFE(read_string(&email, f));
- if (ver >= 10)
- SAFE(read_int32(&icq, f));
- else
- icq = 0;
- if (ver >= 9)
- SAFE(read_string(&greet, f));
- else
- greet = NULL;
-
- SAFE(read_string(&na->last_usermask, f));
- SAFE(read_string(&na->last_realname, f));
- SAFE(read_string(&na->last_quit, f));
-
- SAFE(read_int32(&tmp32, f));
- na->time_registered = tmp32;
- SAFE(read_int32(&tmp32, f));
- na->last_seen = tmp32;
-
- SAFE(read_int16(&na->status, f));
- na->status &= ~NS_TEMPORARY;
-
- if (ver >= 9) {
- SAFE(read_string(&forbidby, f));
- SAFE(read_string(&forbidreason, f));
- /* Cleanup */
- if (forbidby && *forbidby == '@') {
- free(forbidby);
- forbidby = NULL;
- }
- if (forbidreason && *forbidreason == 0) {
- free(forbidreason);
- forbidreason = NULL;
- }
- } else {
- forbidby = NULL;
- forbidreason = NULL;
- }
-
- if (na->status & NS_VERBOTEN) {
- if (na->last_usermask)
- free(na->last_usermask);
- if (na->last_realname)
- free(na->last_realname);
-
- na->last_usermask = forbidby;
- na->last_realname = forbidreason;
- } else {
- if (!na->last_usermask)
- na->last_usermask = sstrdup("");
- if (!na->last_realname)
- na->last_realname = sstrdup("");
- }
-
- /* Store the reference for later resolving */
- SAFE(read_string((char **) &na->nc, f));
- SAFE(read_int16(&tmp16, f)); /* Was linkcount */
-
- if (na->nc) {
- SAFE(read_int16(&tmp16, f)); /* Was channelcount */
- } else {
- /* This nick was a master nick, so it also has all the
- * core info! =)
- */
- nc = new NickCore();
- slist_init(&nc->aliases);
-
- /* The initial display is what used to be the master nick */
- nc->display = sstrdup(na->nick);
-
- /* We grabbed info before; fill the appropriate fields now */
- if (*bufp)
- memcpy(nc->pass, bufp, PASSMAX);
- else
- memset(nc->pass, 0, PASSMAX); /* Which may be the case for forbidden nicks .. */
-
- nc->email = email;
- nc->greet = greet;
- nc->icq = icq;
- nc->url = url;
-
- /* We check whether the e-mail is valid because it was not tested
- * in older versions.
- */
- if (ver <= 10 && nc->email && !MailValidate(nc->email)) {
- free(nc->email);
- nc->email = NULL;
- }
-
- SAFE(read_int32(&nc->flags, f));
- if (!NSAllowKillImmed)
- nc->flags &= ~NI_KILL_IMMED;
-
- /* Status flags cleanup */
- if (na->status & NS_OLD_ENCRYPTEDPW) {
- nc->flags |= NI_ENCRYPTEDPW;
- na->status &= ~NS_OLD_ENCRYPTEDPW;
- }
-
- /* Add services opers and admins to the appropriate list, but
- only if the database version is equal to or more than 10. */
- if (ver >= 10) {
- if (nc->flags & NI_SERVICES_ADMIN)
- slist_add(&servadmins, nc);
- if (nc->flags & NI_SERVICES_OPER)
- slist_add(&servopers, nc);
- }
-
- /* Add the Services root flag if needed. */
- if (nc)
- for (j = 0; j < RootNumber; j++)
- if (!stricmp(ServicesRoots[j], na->nick))
- nc->flags |= NI_SERVICES_ROOT;
-
- SAFE(read_int16(&nc->accesscount, f));
- if (nc->accesscount) {
- char **access;
- access = (char **)scalloc(sizeof(char *) * nc->accesscount, 1);
- nc->access = access;
- for (j = 0; j < nc->accesscount; j++, access++)
- SAFE(read_string(access, f));
- }
-
- SAFE(read_int16(&tmp16, f));
- nc->memos.memocount = (int16) tmp16;
- SAFE(read_int16(&tmp16, f));
- nc->memos.memomax = (int16) tmp16;
- if (nc->memos.memocount) {
- Memo *memos;
- memos = (Memo *)scalloc(sizeof(Memo) * nc->memos.memocount, 1);
- nc->memos.memos = memos;
-
- for (j = 0; j < nc->memos.memocount; j++, memos++) {
- SAFE(read_int32(&memos->number, f));
- SAFE(read_int16(&memos->flags, f));
- SAFE(read_int32(&tmp32, f));
- memos->time = tmp32;
- SAFE(read_buffer(memos->sender, f));
- SAFE(read_string(&memos->text, f));
- }
- }
-
- /* We read the channel count, but don't take care of it.
- load_cs_dbase will regenerate it correctly. */
- SAFE(read_int16(&tmp16, f));
-
- /* formerly nc->channelmax, RIP */
- SAFE(read_int16(&tmp16, f));
- SAFE(read_int16(&nc->language, f));
-
- if (ver >= 11 && ver < 13) {
- char *s;
-
- SAFE(read_int16(&tmp16, f));
- SAFE(read_int32(&tmp32, f));
- SAFE(read_int16(&tmp16, f));
- SAFE(read_string(&s, f));
- }
-
- /* Set us as being a master nick; fill the nc field also.
- The NS_MASTER flag will not be cleared in this function. */
- na->status |= NS_MASTER;
- na->nc = nc;
- slist_add(&nc->aliases, na);
-
- /* Insert our new core in the core list */
- insert_core(nc);
- }
-
- alpha_insert_alias(na);
-
- } /* while (getc_db(f) != 0) */
- } /* for (i) */
-
- /* Now resolve what were called links */
- for (i = 0; i < 1024; i++) {
- for (na = nalists[i]; na; na = next) {
- next = na->next;
-
- /* Master nicks are already resolved */
- if (na->status & NS_MASTER)
- continue;
-
- na2 = na;
- /* While the reference resolves and it's not a master nick */
- while ((na2 = findnick((char *) na2->nc))
- && !(na2->status & NS_MASTER));
-
- /* It didn't resolve. This is problematic since there is no core. :/
- We delete the nick. */
- if (!na2) {
- alog("%s: while loading database: %s was linked to inexistant %s", s_NickServ, na->nick, (char *) na->nc);
- delnick(na);
- continue;
- }
-
- /* OK we have information on the core. We mark the current alias
- as a master nick because it now contains a valid core. */
- na->nc = na2->nc;
- na->status |= NS_MASTER;
- slist_add(&na->nc->aliases, na);
- }
- }
-
- close_db(f);
-}
-
void load_ns_req_db(void)
{
dbFILE *f;
@@ -463,9 +217,9 @@ void load_ns_dbase(void)
ver = get_file_version(f);
- if (ver <= 11) {
+ if (ver != 14) {
close_db(f);
- load_old_ns_dbase();
+ fatal("DB %s is too old", NickDBName);
return;
}
@@ -487,15 +241,7 @@ void load_ns_dbase(void)
slist_init(&nc->aliases);
SAFE(read_string(&nc->display, f));
- if (ver < 14) {
- SAFE(read_string(&pass, f));
- if (pass) {
- memset(nc->pass, 0, PASSMAX);
- memcpy(nc->pass, pass, strlen(pass));
- } else
- memset(nc->pass, 0, PASSMAX);
- } else
- SAFE(read_buffer(nc->pass, f));
+ SAFE(read_buffer(nc->pass, f));
SAFE(read_string(&nc->email, f));
SAFE(read_string(&nc->greet, f));
@@ -543,15 +289,6 @@ void load_ns_dbase(void)
SAFE(read_int16(&nc->channelcount, f));
SAFE(read_int16(&tmp16, f));
-
- if (ver < 13) {
- /* Used to be dead authentication system */
- SAFE(read_int16(&tmp16, f));
- SAFE(read_int32(&tmp32, f));
- SAFE(read_int16(&tmp16, f));
- SAFE(read_string(&s, f));
- }
-
} /* while (getc_db(f) != 0) */
*nclast = NULL;
} /* for (i) */
diff --git a/src/operserv.c b/src/operserv.c
index 20e63a41b..76c8d014d 100644
--- a/src/operserv.c
+++ b/src/operserv.c
@@ -138,118 +138,6 @@ void operserv(User * u, char *buf)
/**************************** Privilege checks ***************************/
/*************************************************************************/
-/* Load old AKILL data. */
-
-#define SAFE(x) do { \
- if ((x) < 0) { \
- if (!forceload) \
- fatal("Read error on %s", AutokillDBName); \
- break; \
- } \
-} while (0)
-
-static void load_old_akill(void)
-{
- dbFILE *f;
- int i, j;
- uint16 tmp16;
- uint32 tmp32;
- char buf[NICKMAX], mask2[BUFSIZE], *mask, *s;
- Akill *ak, *entry;
-
- if (!
- (f =
- open_db("AKILL", AutokillDBName ? AutokillDBName : "akill.db",
- "r", 9)))
- return;
-
- get_file_version(f);
-
- read_int16(&tmp16, f);
- slist_setcapacity(&akills, tmp16);
-
- for (j = 0; j < akills.capacity; j++) {
- ak = (Akill *)scalloc(sizeof(Akill), 1);
-
- SAFE(read_string(&mask, f));
- s = strchr(mask, '@');
- *s = 0;
- s++;
- ak->user = sstrdup(mask);
- ak->host = sstrdup(s);
- SAFE(read_string(&ak->reason, f));
- SAFE(read_buffer(buf, f));
- if (!*buf)
- ak->by = sstrdup("<unknown>");
- else
- ak->by = sstrdup(buf);
- SAFE(read_int32(&tmp32, f));
- ak->seton = tmp32 ? tmp32 : time(NULL);
- SAFE(read_int32(&tmp32, f));
- ak->expires = tmp32;
-
- /* Sanity checks *sigh* */
-
- /* No nicknames allowed! */
- if (strchr(ak->user, '!')) {
- ircdproto->SendAkillDel(ak->user, ak->host);
- free(ak);
- continue;
- }
-
- snprintf(mask2, sizeof(mask2), "%s@%s", ak->user, ak->host);
-
- /* Is the mask already in the AKILL list? */
- if (slist_indexof(&akills, mask2) != -1) {
- free(ak);
- continue;
- }
-
- /* Checks whether there is an AKILL that already covers
- * the one we want to add, and whether there are AKILLs
- * that would be covered by this one. Expiry time
- * does *also* matter.
- */
-
- if (akills.count > 0) {
-
- for (i = akills.count - 1; i >= 0; i--) {
-
- char amask[BUFSIZE];
-
- entry = (Akill *)akills.list[i];
-
- if (!entry)
- continue;
-
- snprintf(amask, sizeof(amask), "%s@%s", entry->user,
- entry->host);
-
- if (match_wild_nocase(amask, mask2)
- && (entry->expires >= ak->expires
- || entry->expires == 0)) {
- ircdproto->SendAkillDel(ak->user, ak->host);
- free(ak);
- ak = NULL;
- break;
- }
-
- if (match_wild_nocase(mask2, amask)
- && (entry->expires <= ak->expires || ak->expires == 0))
- slist_delete(&akills, i);
- }
-
- }
-
- if (ak)
- slist_add(&akills, ak);
- }
-
- close_db(f);
-}
-
-#undef SAFE
-
/* Load OperServ data. */
#define SAFE(x) do { \
@@ -274,124 +162,88 @@ void load_os_dbase(void)
return;
ver = get_file_version(f);
-
- if (ver <= 9) {
- NickAlias *na;
-
- SAFE(read_int16(&n, f));
- for (i = 0; i < n && !failed; i++) {
- SAFE(read_string(&s, f));
- if (s) {
- na = findnick(s);
- if (na) {
- na->nc->flags |= NI_SERVICES_ADMIN;
- if (slist_indexof(&servadmins, na) == -1)
- slist_add(&servadmins, na);
- }
- free(s);
- }
- }
- if (!failed)
- SAFE(read_int16(&n, f));
- for (i = 0; i < n && !failed; i++) {
- SAFE(read_string(&s, f));
- if (s) {
- na = findnick(s);
- if (na) {
- na->nc->flags |= NI_SERVICES_OPER;
- if (slist_indexof(&servopers, na) == -1)
- slist_add(&servopers, na);
- }
- free(s);
- }
- }
- }
-
- if (ver >= 7) {
- SAFE(read_int32(&maxusercnt, f));
- SAFE(read_int32(&tmp32, f));
- maxusertime = tmp32;
+ if (ver != 13)
+ {
+ close_db(f);
+ fatal("Read error on %s", ChanDBName);
+ return;
}
+
+ SAFE(read_int32(&maxusercnt, f));
+ SAFE(read_int32(&tmp32, f));
+ maxusertime = tmp32;
- if (ver <= 10)
- load_old_akill();
- else {
- Akill *ak;
+ Akill *ak;
- read_int16(&tmp16, f);
- slist_setcapacity(&akills, tmp16);
+ read_int16(&tmp16, f);
+ slist_setcapacity(&akills, tmp16);
- for (i = 0; i < akills.capacity; i++) {
- ak = (Akill *)scalloc(sizeof(Akill), 1);
+ for (i = 0; i < akills.capacity; i++) {
+ ak = (Akill *)scalloc(sizeof(Akill), 1);
- SAFE(read_string(&ak->user, f));
- SAFE(read_string(&ak->host, f));
- SAFE(read_string(&ak->by, f));
- SAFE(read_string(&ak->reason, f));
- SAFE(read_int32(&tmp32, f));
- ak->seton = tmp32;
- SAFE(read_int32(&tmp32, f));
- ak->expires = tmp32;
+ SAFE(read_string(&ak->user, f));
+ SAFE(read_string(&ak->host, f));
+ SAFE(read_string(&ak->by, f));
+ SAFE(read_string(&ak->reason, f));
+ SAFE(read_int32(&tmp32, f));
+ ak->seton = tmp32;
+ SAFE(read_int32(&tmp32, f));
+ ak->expires = tmp32;
- slist_add(&akills, ak);
- }
+ slist_add(&akills, ak);
}
- if (ver >= 11) {
- SXLine *sx;
+ SXLine *sx;
- read_int16(&tmp16, f);
- slist_setcapacity(&sglines, tmp16);
+ read_int16(&tmp16, f);
+ slist_setcapacity(&sglines, tmp16);
- for (i = 0; i < sglines.capacity; i++) {
- sx = (SXLine *)scalloc(sizeof(SXLine), 1);
+ for (i = 0; i < sglines.capacity; i++) {
+ sx = (SXLine *)scalloc(sizeof(SXLine), 1);
- SAFE(read_string(&sx->mask, f));
- SAFE(read_string(&sx->by, f));
- SAFE(read_string(&sx->reason, f));
- SAFE(read_int32(&tmp32, f));
- sx->seton = tmp32;
- SAFE(read_int32(&tmp32, f));
- sx->expires = tmp32;
+ SAFE(read_string(&sx->mask, f));
+ SAFE(read_string(&sx->by, f));
+ SAFE(read_string(&sx->reason, f));
+ SAFE(read_int32(&tmp32, f));
+ sx->seton = tmp32;
+ SAFE(read_int32(&tmp32, f));
+ sx->expires = tmp32;
- slist_add(&sglines, sx);
- }
+ slist_add(&sglines, sx);
+ }
- if (ver >= 13) {
- read_int16(&tmp16, f);
- slist_setcapacity(&sqlines, tmp16);
+ read_int16(&tmp16, f);
+ slist_setcapacity(&sqlines, tmp16);
- for (i = 0; i < sqlines.capacity; i++) {
- sx = (SXLine *)scalloc(sizeof(SXLine), 1);
+ for (i = 0; i < sqlines.capacity; i++) {
+ sx = (SXLine *)scalloc(sizeof(SXLine), 1);
- SAFE(read_string(&sx->mask, f));
- SAFE(read_string(&sx->by, f));
- SAFE(read_string(&sx->reason, f));
- SAFE(read_int32(&tmp32, f));
- sx->seton = tmp32;
- SAFE(read_int32(&tmp32, f));
- sx->expires = tmp32;
+ SAFE(read_string(&sx->mask, f));
+ SAFE(read_string(&sx->by, f));
+ SAFE(read_string(&sx->reason, f));
+ SAFE(read_int32(&tmp32, f));
+ sx->seton = tmp32;
+ SAFE(read_int32(&tmp32, f));
+ sx->expires = tmp32;
- slist_add(&sqlines, sx);
- }
- }
+ slist_add(&sqlines, sx);
+ }
- read_int16(&tmp16, f);
- slist_setcapacity(&szlines, tmp16);
+ read_int16(&tmp16, f);
+ slist_setcapacity(&szlines, tmp16);
- for (i = 0; i < szlines.capacity; i++) {
- sx = (SXLine *)scalloc(sizeof(SXLine), 1);
+ for (i = 0; i < szlines.capacity; i++) {
+ sx = (SXLine *)scalloc(sizeof(SXLine), 1);
- SAFE(read_string(&sx->mask, f));
- SAFE(read_string(&sx->by, f));
- SAFE(read_string(&sx->reason, f));
- SAFE(read_int32(&tmp32, f));
- sx->seton = tmp32;
- SAFE(read_int32(&tmp32, f));
- sx->expires = tmp32;
+ SAFE(read_string(&sx->mask, f));
+ SAFE(read_string(&sx->by, f));
+ SAFE(read_string(&sx->reason, f));
+ SAFE(read_int32(&tmp32, f));
+ sx->seton = tmp32;
+ SAFE(read_int32(&tmp32, f));
+ sx->expires = tmp32;
- slist_add(&szlines, sx);
- }
+ slist_add(&szlines, sx);
}
close_db(f);