Fix service persistence bug in patch-47
authorMichael Poole <mdpoole@troilus.org>
Fri, 9 Apr 2004 22:18:21 +0000 (22:18 +0000)
committerMichael Poole <mdpoole@troilus.org>
Fri, 9 Apr 2004 22:18:21 +0000 (22:18 +0000)
patch-47 attempted to fix a previously reported error where srvx would
create NickServ, ChanServ, OpServ and Global even if the "nick" entry
was omitted from srvx.conf.  This broke persistence of all service
bots added by the modcmd.service\ add comand.  (Closes: #932566)
git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-48

ChangeLog
src/modcmd.c

index 89a969e9212b0c951e15f0e5134025255d6bc251..29394ebb429df905b557d62d8b5709b8a05ca90f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,22 @@
 # arch-tag: automatic-ChangeLog--srvx@srvx.net--2004-srvx/srvx--devo--1.3
 #
 
+2004-04-09 22:18:21 GMT        Michael Poole <mdpoole@troilus.org>     patch-48
+
+    Summary:
+      Fix service persistence bug in patch-47
+    Revision:
+      srvx--devo--1.3--patch-48
+
+    patch-47 attempted to fix a previously reported error where srvx would
+    create NickServ, ChanServ, OpServ and Global even if the "nick" entry
+    was omitted from srvx.conf.  This broke persistence of all service
+    bots added by the modcmd.service\ add comand.  (Closes: #932566)
+
+    modified files:
+     ChangeLog src/modcmd.c
+
+
 2004-04-09 20:08:58 GMT        Michael Poole <mdpoole@troilus.org>     patch-47
 
     Summary:
index 027c06f94acf2a70424b5c3f1c91f8081e0e1e3b..ba5f40ea10db471675c4ac9ce6a1467281db68b1 100644 (file)
@@ -2024,7 +2024,7 @@ modcmd_expand(const char *variable) {
 }
 
 static void
-modcmd_load_bots(struct dict *db) {
+modcmd_load_bots(struct dict *db, int default_nick) {
     dict_iterator_t it;
 
     for (it = dict_first(db); it; it = iter_next(it)) {
@@ -2038,8 +2038,12 @@ modcmd_load_bots(struct dict *db) {
             continue;
         }
         nick = database_get_data(rd->d.object, "nick", RECDB_QSTRING);
-        if (!nick)
-            continue;
+        if (!nick) {
+            if (default_nick)
+                nick = iter_key(it);
+            else
+                continue;
+        }
         svc = service_find(nick);
         desc = database_get_data(rd->d.object, "description", RECDB_QSTRING);
         hostname = database_get_data(rd->d.object, "hostname", RECDB_QSTRING);
@@ -2060,7 +2064,7 @@ modcmd_load_bots(struct dict *db) {
 
 static void
 modcmd_conf_read(void) {
-    modcmd_load_bots(conf_get_data("services", RECDB_OBJECT));
+    modcmd_load_bots(conf_get_data("services", RECDB_OBJECT), 0);
 }
 
 void
@@ -2204,7 +2208,7 @@ modcmd_saxdb_read(struct dict *db) {
     struct record_data *rd, *rd2;
     struct service *service;
 
-    modcmd_load_bots(database_get_data(db, "bots", RECDB_OBJECT));
+    modcmd_load_bots(database_get_data(db, "bots", RECDB_OBJECT), 1);
     db2 = database_get_data(db, "services", RECDB_OBJECT);
     if (!db2) {
         log_module(MAIN_LOG, LOG_ERROR, "Missing section 'services' in modcmd db.");