diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/anoperc.in | 8 | ||||
-rw-r--r-- | src/botserv.c | 15 | ||||
-rw-r--r-- | src/chanserv.c | 75 | ||||
-rw-r--r-- | src/hostserv.c | 18 | ||||
-rw-r--r-- | src/mysql.c | 5 | ||||
-rw-r--r-- | src/news.c | 15 | ||||
-rw-r--r-- | src/nickserv.c | 95 | ||||
-rw-r--r-- | src/operserv.c | 53 | ||||
-rw-r--r-- | src/sessions.c | 15 | ||||
-rw-r--r-- | src/users.c | 5 |
10 files changed, 233 insertions, 71 deletions
diff --git a/src/bin/anoperc.in b/src/bin/anoperc.in index 012e4db78..2b187d382 100644 --- a/src/bin/anoperc.in +++ b/src/bin/anoperc.in @@ -98,8 +98,9 @@ elif [ "$1" = "status" ] ; then elif [ "$1" = "restart" ] ; then isAnopeRunning echo "Restarting Anope" - kill -1 `cat $ANOPEPID` + kill -15 `cat $ANOPEPID` sleep 1 + shift $ANOPROG $* elif [ "$1" = "rehash" ] ; then @@ -119,10 +120,13 @@ elif [ "$1" = "help" ] ; then echo "$0 start Start Anope" echo " Additional parameters may be passed" echo " (e.g. $0 start -nofork)" - echo " For a list of type $0 $1 paramlist" + echo " For a list type $0 $1 paramlist" echo "$0 stop Shutdown Anope" echo "$0 status Show Anope's Status" echo "$0 restart Restart Anope (Databases will be saved)" + echo " Additional parameters may be passed" + echo " (e.g. $0 restart -logchan)" + echi " For a list type $0 $1 paramlist" echo "$0 rehash Rehash Configuration and Save Databases" echo "$0 version Return Anope Version and Build Information" echo "$0 help Show this help menu" diff --git a/src/botserv.c b/src/botserv.c index e416be46f..ae02dfd42 100644 --- a/src/botserv.c +++ b/src/botserv.c @@ -540,15 +540,24 @@ void save_bs_rdb_dbase(void) if (!rdb_open()) return; - rdb_tag_table("anope_bs_core"); + if (rdb_tag_table("anope_bs_core") == 0) { + alog("Unable to tag table 'anope_bs_core' - BotServ RDB save failed."); + return; + } for (i = 0; i < 256; i++) { for (bi = botlists[i]; bi; bi = bi->next) { - rdb_save_bs_core(bi); + if (rdb_save_bs_core(bi) == 0) { + alog("Unable to save BotInfo for %s - BotServ RDB save failed.", bi->nick); + return; + } } } - rdb_clean_table("anope_bs_core"); + if (rdb_clean_table("anope_bs_core") == 0) { + alog("Unable to clean table 'anope_bs_core' - BotServ RDB save failed."); + return; + } rdb_close(); #endif diff --git a/src/chanserv.c b/src/chanserv.c index 32c8a33cf..6add49727 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -998,27 +998,72 @@ void save_cs_rdb_dbase(void) if (!rdb_open()) return; - rdb_tag_table("anope_cs_info"); - rdb_tag_table("anope_cs_access"); - rdb_tag_table("anope_cs_levels"); - rdb_tag_table("anope_cs_akicks"); - rdb_tag_table("anope_cs_badwords"); - rdb_tag_table("anope_cs_ttb"); - rdb_tag_table_where("anope_ms_info", "serv='CHAN'"); + if (rdb_tag_table("anope_cs_info") == 0) { + alog("Unable to tag table 'anope_cs_info' - ChanServ RDB save failed."); + return; + } + if (rdb_tag_table("anope_cs_access") == 0) { + alog("Unable to tag table 'anope_cs_access' - ChanServ RDB save failed."); + return; + } + if (rdb_tag_table("anope_cs_levels") == 0) { + alog("Unable to tag table 'anope_cs_levels' - ChanServ RDB save failed."); + return; + } + if (rdb_tag_table("anope_cs_akicks") == 0) { + alog("Unable to tag table 'anope_cs_akicks' - ChanServ RDB save failed."); + return; + } + if (rdb_tag_table("anope_cs_badwords") == 0) { + alog("Unable to tag table 'anope_cs_badwords' - ChanServ RDB save failed."); + return; + } + if (rdb_tag_table("anope_cs_ttb") == 0) { + alog("Unable to tag table 'anope_cs_ttb' - ChanServ RDB save failed."); + return; + } + if (rdb_tag_table_where("anope_ms_info", "serv='CHAN'") == 0) { + alog("Unable to tag table 'anope_ms_info' - ChanServ RDB save failed."); + return; + } for (i = 0; i < 256; i++) { for (ci = chanlists[i]; ci; ci = ci->next) { - rdb_save_cs_info(ci); + if (rdb_save_cs_info(ci) == 0) { + alog("Unable to save ChanInfo for %s - ChanServ RDB save failed.", ci->name); + return; + } } /* for (chanlists[i]) */ } /* for (i) */ - rdb_clean_table("anope_cs_info"); - rdb_clean_table("anope_cs_access"); - rdb_clean_table("anope_cs_levels"); - rdb_clean_table("anope_cs_akicks"); - rdb_clean_table("anope_cs_badwords"); - rdb_clean_table("anope_cs_ttb"); - rdb_clean_table_where("anope_ms_info", "serv='CHAN'"); + if (rdb_clean_table("anope_cs_info") == 0) { + alog("Unable to clean table 'anope_cs_info' - ChanServ RDB save failed."); + return; + } + if (rdb_clean_table("anope_cs_access") == 0) { + alog("Unable to clean table 'anope_cs_access' - ChanServ RDB save failed."); + return; + } + if (rdb_clean_table("anope_cs_levels") == 0) { + alog("Unable to clean table 'anope_cs_levels' - ChanServ RDB save failed."); + return; + } + if (rdb_clean_table("anope_cs_akicks") == 0) { + alog("Unable to clean table 'anope_cs_akicks' - ChanServ RDB save failed."); + return; + } + if (rdb_clean_table("anope_cs_badwords") == 0) { + alog("Unable to clean table 'anope_cs_badwords' - ChanServ RDB save failed."); + return; + } + if (rdb_clean_table("anope_cs_ttb") == 0) { + alog("Unable to clean table 'anope_cs_ttb' - ChanServ RDB save failed."); + return; + } + if (rdb_clean_table_where("anope_ms_info", "serv='CHAN'") == 0) { + alog("Unable to clean table 'anope_ms_info' - ChanServ RDB save failed."); + return; + } rdb_close(); #endif diff --git a/src/hostserv.c b/src/hostserv.c index 365a5d091..331f386d7 100644 --- a/src/hostserv.c +++ b/src/hostserv.c @@ -331,7 +331,8 @@ void delHostCore(char *nick) if (rdb_open()) { q_nick = rdb_quote(nick); snprintf(clause, sizeof(clause), "nick='%s'", q_nick); - rdb_scrub_table("anope_hs_core", clause); + if (rdb_scrub_table("anope_hs_core", clause) == 0) + alog("Unable to scrub table 'anope_hs_core' - HostServ RDB update failed."); rdb_close(); free(q_nick); } @@ -506,15 +507,24 @@ void save_hs_rdb_dbase(void) if (!rdb_open()) return; - rdb_tag_table("anope_hs_core"); + if (rdb_tag_table("anope_hs_core") == 0) { + alog("Unable to tag table 'anope_hs_core' - HostServ RDB save failed."); + return; + } current = head; while (current != NULL) { - rdb_save_hs_core(current); + if (rdb_save_hs_core(current) == 0) { + alog("Unable to save HostCore for %s - HostServ RDB save failed.", current->nick); + return; + } current = current->next; } - rdb_clean_table("anope_hs_core"); + if (rdb_clean_table("anope_hs_core") == 0) { + alog("Unable to clean table 'anope_hs_core' - HostServ RDB save failed."); + return; + } rdb_close(); #endif diff --git a/src/mysql.c b/src/mysql.c index 99f147bff..62e316010 100644 --- a/src/mysql.c +++ b/src/mysql.c @@ -1406,7 +1406,10 @@ int db_mysql_load_cs_dbase(void) /* Name, founder, successor, password */ snprintf(ci->name, CHANMAX, "%s", mysql_row[0]); ci->founder = findcore(mysql_row[1]); - ci->successor = findcore(mysql_row[2]); + if (mysql_row[2] && *(mysql_row[2])) + ci->successor = findcore(mysql_row[2]); + else + ci->successor = NULL; snprintf(ci->founderpass, PASSMAX, "%s", mysql_row[3]); /* Description, URL, email -- scalloc() initializes to 0/NULL */ diff --git a/src/news.c b/src/news.c index 69a884064..773b6104f 100644 --- a/src/news.c +++ b/src/news.c @@ -241,14 +241,23 @@ void save_rdb_news() if (!rdb_open()) return; - rdb_tag_table("anope_os_news"); + if (rdb_tag_table("anope_os_news") == 0) { + alog("Unable to tag table 'anope_os_news' - News RDB save failed."); + return; + } for (i = 0; i < nnews; i++) { ni = &news[i]; - rdb_save_news(ni); + if (rdb_save_news(ni) == 0) { + alog("Unable to save NewsItem %d - News RDB save failed.", ni->num); + return; + } } - rdb_clean_table("anope_os_news"); + if (rdb_clean_table("anope_os_news") == 0) { + alog("Unable to clean table 'anope_os_news' - News RDB save failed."); + return; + } rdb_close(); #endif diff --git a/src/nickserv.c b/src/nickserv.c index 7193fc9e9..88e686bbd 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -844,29 +844,57 @@ void save_ns_rdb_dbase(void) if (!rdb_open()) return; - rdb_tag_table("anope_ns_core"); - rdb_tag_table("anope_ns_alias"); - rdb_tag_table("anope_ns_access"); - rdb_tag_table_where("anope_ms_info", "serv='NICK'"); + if (rdb_tag_table("anope_ns_core") == 0) { + alog("Unable to tag 'anope_ns_core' - NickServ RDB save failed."); + return; + } + if (rdb_tag_table("anope_ns_alias") == 0) { + alog("Unable to tag 'anope_ns_alias' - NickServ RDB save failed."); + return; + } + if (rdb_tag_table("anope_ns_access") == 0) { + alog("Unable to tag 'anope_ns_access' - NickServ RDB save failed."); + return; + } + if (rdb_tag_table_where("anope_ms_info", "serv='NICK'") == 0) { + alog("Unable to tag 'anope_ms_info' - NickServ RDB save failed."); + return; + } for (i = 0; i < 1024; i++) { for (nc = nclists[i]; nc; nc = nc->next) { - rdb_save_ns_core(nc); - + if (rdb_save_ns_core(nc) == 0) { + alog("Unable to save NickCore for '%s' - NickServ RDB save failed.", nc->display); + return; + } } /* for (nc) */ } /* for (i) */ for (i = 0; i < 1024; i++) { for (na = nalists[i]; na; na = na->next) { - rdb_save_ns_alias(na); - + if (rdb_save_ns_alias(na) == 0) { + alog("Unable to save NickAlias for '%s' - NickServ RDB save failed.", na->nick); + return; + } } /* for (na) */ } /* for (i) */ - rdb_clean_table("anope_ns_core"); - rdb_clean_table("anope_ns_alias"); - rdb_clean_table("anope_ns_access"); - rdb_clean_table_where("anope_ms_info", "serv='NICK'"); + if (rdb_clean_table("anope_ns_core") == 0) { + alog("Unable to clean table 'anope_ns_core' - NickServ RDB save failed."); + return; + } + if (rdb_clean_table("anope_ns_alias") == 0) { + alog("Unable to clean table 'anope_ns_alias' - NickServ RDB save failed."); + return; + } + if (rdb_clean_table("anope_ns_access") == 0) { + alog("Unable to clean table 'anope_ns_access' - NickServ RDB save failed."); + return; + } + if (rdb_clean_table_where("anope_ms_info", "serv='NICK'") == 0) { + alog("Unable to clean table 'anope_ms_info' - NickServ RDB save failed."); + return; + } rdb_close(); #endif @@ -881,19 +909,25 @@ void save_ns_req_rdb_dbase(void) if (!rdb_open()) return; - rdb_tag_table("anope_ns_request"); + if (rdb_tag_table("anope_ns_request") == 0) { + alog("Unable to tag table 'anope_ns_request' - NickServ Request RDB save failed."); + return; + } for (i = 0; i < 1024; i++) { for (nr = nrlists[i]; nr; nr = nr->next) { - if (!rdb_save_ns_req(nr)) { + if (rdb_save_ns_req(nr) == 0) { /* Something went wrong - abort saving */ - alog("Unable to save NickRequest (nick '%s')", nr->nick); + alog("Unable to save NickRequest (nick '%s') - NickServ Request RDB save failed.", nr->nick); return; } } } - rdb_clean_table("anope_ns_request"); + if (rdb_clean_table("anope_ns_request") == 0) { + alog("Unable to clean table 'anope_ns_request' - NickServ Request RDB save failed."); + return; + } rdb_close(); #endif @@ -1346,7 +1380,9 @@ void change_core_display(NickCore * nc, char *newdisplay) * on the next /OS UPDATE might need it on /NS DROP too... */ if (rdb_open()) { - rdb_ns_set_display(newdisplay, nc->display); + if (rdb_ns_set_display(newdisplay, nc->display) == 0) { + alog("Unable to update display for %s - Nick Display RDB update failed.", nc->display); + } rdb_close(); } #endif @@ -1399,14 +1435,20 @@ static int delcore(NickCore * nc) if (rdb_open()) { q_display = rdb_quote(nc->display); snprintf(clause, sizeof(clause), "display='%s'", q_display); - rdb_scrub_table("anope_ns_access", clause); - rdb_scrub_table("anope_ns_core", clause); - rdb_scrub_table("anope_cs_access", clause); - /* I'm unsure how to clean up the OS ADMIN/OPER list on the db */ - /* I wish the "display" primary key would be the same on all tables */ - snprintf(clause, sizeof(clause), "receiver='%s' AND serv='NICK'", - q_display); - rdb_scrub_table("anope_ms_info", clause); + if (rdb_scrub_table("anope_ns_access", clause) == 0) + alog("Unable to scrub table 'anope_ns_access' - RDB update failed."); + else if (rdb_scrub_table("anope_ns_core", clause) == 0) + alog("Unable to scrub table 'anope_ns_core' - RDB update failed."); + else if (rdb_scrub_table("anope_cs_access", clause) == 0) + alog("Unable to scrub table 'anope_cs_access' - RDB update failed."); + else { + /* I'm unsure how to clean up the OS ADMIN/OPER list on the db */ + /* I wish the "display" primary key would be the same on all tables */ + snprintf(clause, sizeof(clause), + "receiver='%s' AND serv='NICK'", q_display); + if (rdb_scrub_table("anope_ms_info", clause) == 0) + alog("Unable to scrub table 'anope_ms_info' - RDB update failed."); + } rdb_close(); free(q_display); } @@ -1528,7 +1570,8 @@ int delnick(NickAlias * na) if (rdb_open()) { q_nick = rdb_quote(na->nick); snprintf(clause, sizeof(clause), "nick='%s'", q_nick); - rdb_scrub_table("anope_ns_alias", clause); + if (rdb_scrub_table("anope_ns_alias", clause) == 0) + alog("Unable to scrub table 'anope_ns_alias' - RDB update failed"); rdb_close(); free(q_nick); } diff --git a/src/operserv.c b/src/operserv.c index e6c00a042..6f030b8cd 100644 --- a/src/operserv.c +++ b/src/operserv.c @@ -505,20 +505,51 @@ void save_os_rdb_dbase(void) if (!rdb_open()) return; - rdb_tag_table("anope_os_akills"); - rdb_tag_table("anope_os_sglines"); - rdb_tag_table("anope_os_sqlines"); - rdb_tag_table("anope_os_szlines"); + if (rdb_tag_table("anope_os_akills") == 0) { + alog("Unable to tag table 'anope_os_akills' - OperServ RDB save failed."); + return; + } + if (rdb_tag_table("anope_os_sglines") == 0) { + alog("Unable to tag table 'anope_os_sglines' - OperServ RDB save failed."); + return; + } + if (rdb_tag_table("anope_os_sqlines") == 0) { + alog("Unable to tag table 'anope_os_sqlines' - OperServ RDB save failed."); + return; + } + if (rdb_tag_table("anope_os_szlines") == 0) { + alog("Unable to tag table 'anope_os_szlines' - OperServ RDB save failed."); + return; + } /* We empty anope_os_core as required */ - rdb_empty_table("anope_os_core"); + if (rdb_empty_table("anope_os_core") == 0) { + alog("Unable to empty table 'anope_os_core' - OperServ RDB save failed"); + return; + } - rdb_save_os_db(maxusercnt, maxusertime, &akills, &sglines, &sqlines, - &szlines); + if (rdb_save_os_db + (maxusercnt, maxusertime, &akills, &sglines, &sqlines, + &szlines) == 0) { + alog("Unable to save OperServ data - OperServ RDB save failed"); + return; + } - rdb_clean_table("anope_os_akills"); - rdb_clean_table("anope_os_sglines"); - rdb_clean_table("anope_os_sqlines"); - rdb_clean_table("anope_os_szlines"); + if (rdb_clean_table("anope_os_akills") == 0) { + alog("Unable to clean table 'anope_os_akills' - OperServ RDB save failed."); + return; + } + if (rdb_clean_table("anope_os_sglines") == 0) { + alog("Unable to clean table 'anope_os_sglines' - OperServ RDB save failed."); + return; + } + if (rdb_clean_table("anope_os_sqlines") == 0) { + alog("Unable to clean table 'anope_os_sqlines' - OperServ RDB save failed."); + return; + } + if (rdb_clean_table("anope_os_szlines") == 0) { + alog("Unable to clean table 'anope_os_szlines' - OperServ RDB save failed."); + return; + } rdb_close(); #endif diff --git a/src/sessions.c b/src/sessions.c index bb00d18ba..23dd9871d 100644 --- a/src/sessions.c +++ b/src/sessions.c @@ -467,12 +467,21 @@ void save_rdb_exceptions() if (!rdb_open()) return; - rdb_tag_table("anope_os_exceptions"); + if (rdb_tag_table("anope_os_exceptions") == 0) { + alog("Unable to tag table 'anope_os_exceptions' - Exception RDB save failed."); + return; + } for (i = 0; i < nexceptions; i++) { e = &exceptions[i]; - rdb_save_exceptions(e); + if (rdb_save_exceptions(e) == 0) { + alog("Unable to save Exception '%s' - Exception RDB save failed.", e->mask); + return; + } + } + if (rdb_clean_table("anope_os_exceptions") == 0) { + alog("Unable to clean table 'anope_os_exceptions' - Exception RDB save failed."); + return; } - rdb_clean_table("anope_os_exceptions"); rdb_close(); #endif } diff --git a/src/users.c b/src/users.c index 140fac592..11d8410b1 100644 --- a/src/users.c +++ b/src/users.c @@ -651,9 +651,8 @@ User *do_nick(const char *source, char *nick, char *username, char *host, /* An old user changing nicks. */ if (UseTS6) user = find_byuid(source); - if (!user) { - user = finduser(source); - } else + + if (!user) user = finduser(source); if (!user) { |