+/*
+ * rehash
+ *
+ * Actual REHASH service routine. Called with sig == 0 if it has been called
+ * as a result of an operator issuing this command, else assume it has been
+ * called as a result of the server receiving a HUP signal.
+ */
+int rehash(struct Client *cptr, int sig)
+{
+ struct ConfItem** tmp = &GlobalConfList;
+ struct ConfItem* tmp2;
+ struct ConfClass* cltmp;
+ struct Client* acptr;
+ struct MotdItem* temp;
+ int i;
+ int ret = 0;
+ int found_g = 0;
+
+ if (1 == sig)
+ sendto_opmask_butone(0, SNO_OLDSNO,
+ "Got signal SIGHUP, reloading ircd conf. file");
+
+ while ((tmp2 = *tmp)) {
+ if (tmp2->clients) {
+ /*
+ * Configuration entry is still in use by some
+ * local clients, cannot delete it--mark it so
+ * that it will be deleted when the last client
+ * exits...
+ */
+ if (!(tmp2->status & CONF_CLIENT)) {
+ *tmp = tmp2->next;
+ tmp2->next = 0;
+ }
+ else
+ tmp = &tmp2->next;
+ tmp2->status |= CONF_ILLEGAL;
+ }
+ else {
+ *tmp = tmp2->next;
+ /* free expression trees of connect rules */
+ if ((tmp2->status & (CONF_CRULEALL | CONF_CRULEAUTO)) &&
+ (tmp2->passwd != NULL))
+ crule_free(&(tmp2->passwd));
+ free_conf(tmp2);
+ }
+ }
+ erase_motd_conf_list(&motdConfList);
+ /*
+ * We don't delete the class table, rather mark all entries
+ * for deletion. The table is cleaned up by check_class(). - avalon
+ */
+ for (cltmp = NextClass(FirstClass()); cltmp; cltmp = NextClass(cltmp))
+ MarkDelete(cltmp);
+
+ /*
+ * delete the juped nicks list
+ */
+ clearNickJupes();
+
+ if (sig != 2)
+ flush_resolver_cache();
+
+ mark_listeners_closing();
+
+ if (!read_configuration_file()) /* This calls check_class(), */
+ check_class(); /* unless it fails */
+
+ /*
+ * make sure that the server listener is re-added so it doesn't get
+ * closed
+ */
+ close_listeners();
+
+ /*
+ * Flush out deleted I and P lines although still in use.
+ */
+ for (tmp = &GlobalConfList; (tmp2 = *tmp);) {
+ if (!(tmp2->status & CONF_ILLEGAL))
+ tmp = &tmp2->next;
+ else
+ {
+ *tmp = tmp2->next;
+ tmp2->next = NULL;
+ if (!tmp2->clients)
+ free_conf(tmp2);
+ }
+ }
+ for (i = 0; i <= HighestFd; i++) {
+ if ((acptr = LocalClientArray[i])) {
+ assert(!IsMe(acptr));
+ if (IsServer(acptr)) {
+ det_confs_butmask(acptr,
+ ~(CONF_HUB | CONF_LEAF | CONF_UWORLD | CONF_ILLEGAL));
+ attach_confs_byname(acptr, acptr->name,
+ CONF_HUB | CONF_LEAF | CONF_UWORLD);
+ }
+ /* Because admin's are getting so uppity about people managing to
+ * get past K/G's etc, we'll "fix" the bug by actually explaining
+ * whats going on.
+ */
+ if ((found_g = find_kill(acptr))) {
+ sendto_opmask_butone(0, found_g == -2 ? SNO_GLINE : SNO_OPERKILL,
+ found_g == -2 ? "G-line active for %s%s" :
+ "K-line active for %s%s",
+ IsUnknown(acptr) ? "Unregistered Client ":"",
+ get_client_name(acptr, HIDE_IP));
+ if (exit_client(cptr, acptr, &me, found_g == -2 ? "G-lined" :
+ "K-lined") == CPTR_KILLED)
+ ret = CPTR_KILLED;
+ }
+ }
+ }
+ /*
+ * free old motd structs
+ */
+ while (motd) {
+ temp = motd->next;
+ MyFree(motd);
+ motd = temp;
+ }
+ while (rmotd) {
+ temp = rmotd->next;
+ MyFree(rmotd);
+ rmotd = temp;
+ }
+ /* reload motd files */
+ read_tlines();
+ rmotd = read_motd(RPATH);
+ motd = read_motd(MPATH);
+ return ret;
+}
+
+/*
+ * conf_init
+ *
+ * Read configuration file.
+ *
+ * returns 0, if file cannot be opened
+ * 1, if file read
+ */
+
+int conf_init(void)
+{
+ if (read_configuration_file()) {
+ /*
+ * make sure we're sane to start if the config
+ * file read didn't get everything we need.
+ * XXX - should any of these abort the server?
+ * TODO: add warning messages
+ */
+ if (0 == localConf.location1)
+ DupString(localConf.location1, "");
+ if (0 == localConf.location2)
+ DupString(localConf.location2, "");
+ if (0 == localConf.contact)
+ DupString(localConf.contact, "");
+
+ return 1;
+ }
+ return 0;
+}
+