Exemple #1
0
static void write_debug()
{
  int x;
  char s[25];
  int y;

  if (nested_debug) {
    /* Yoicks, if we have this there's serious trouble!
     * All of these are pretty reliable, so we'll try these.
     *
     * NOTE: dont try and display context-notes in here, it's
     *       _not_ safe <cybah>
     */
    x = creat("DEBUG.DEBUG", 0644);
    setsock(x, SOCK_NONSOCK);
    if (x >= 0) {
      strncpyz(s, ctime(&now), sizeof s);
      dprintf(-x, "Debug (%s) written %s\n", ver, s);
      dprintf(-x, "Please report problem to [email protected]\n");
      dprintf(-x, "after a visit to http://www.eggheads.org/bugzilla/\n");
      dprintf(-x, "Full Patch List: %s\n", egg_xtra);
      dprintf(-x, "Context: ");
      cx_ptr = cx_ptr & 15;
      for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15))
        dprintf(-x, "%s/%d,\n         ", cx_file[y], cx_line[y]);
      dprintf(-x, "%s/%d\n\n", cx_file[y], cx_line[y]);
      killsock(x);
      close(x);
    }
    bg_send_quit(BG_ABORT);
    exit(1);                    /* Dont even try & tell people about, that may
                                 * have caused the fault last time. */
  } else
    nested_debug = 1;
  putlog(LOG_MISC, "*", "* Last context: %s/%d [%s]", cx_file[cx_ptr],
         cx_line[cx_ptr], cx_note[cx_ptr][0] ? cx_note[cx_ptr] : "");
  putlog(LOG_MISC, "*", "* Please REPORT this BUG!");
  putlog(LOG_MISC, "*", "* Check doc/BUG-REPORT on how to do so.");
  x = creat("DEBUG", 0644);
  setsock(x, SOCK_NONSOCK);
  if (x < 0) {
    putlog(LOG_MISC, "*", "* Failed to write DEBUG");
  } else {
    strncpyz(s, ctime(&now), sizeof s);
    dprintf(-x, "Debug (%s) written %s\n", ver, s);
    dprintf(-x, "Full Patch List: %s\n", egg_xtra);
#ifdef STATIC
    dprintf(-x, "STATICALLY LINKED\n");
#endif

    /* info library */
    dprintf(-x, "Tcl library: %s\n",
            ((interp) && (Tcl_Eval(interp, "info library") == TCL_OK)) ?
            tcl_resultstring() : "*unknown*");

    /* info tclversion/patchlevel */
    dprintf(-x, "Tcl version: %s (header version %s)\n",
            ((interp) && (Tcl_Eval(interp, "info patchlevel") == TCL_OK)) ?
            tcl_resultstring() : (Tcl_Eval(interp, "info tclversion") == TCL_OK) ?
            tcl_resultstring() : "*unknown*", TCL_PATCH_LEVEL ? TCL_PATCH_LEVEL :
            "*unknown*");

    if (tcl_threaded())
      dprintf(-x, "Tcl is threaded\n");
#ifdef IPV6
    dprintf(-x, "Compiled with IPv6 support\n");
#else
    dprintf(-x, "Compiled without IPv6 support\n");
#endif

#ifdef TLS
    dprintf(-x, "Compiled with TLS support\n");
#else
    dprintf(-x, "Compiled without TLS support\n");
#endif

    dprintf(-x, "Configure flags: %s\n", EGG_AC_ARGS);
#ifdef CCFLAGS
    dprintf(-x, "Compile flags: %s\n", CCFLAGS);
#endif

#ifdef LDFLAGS
    dprintf(-x, "Link flags: %s\n", LDFLAGS);
#endif

#ifdef STRIPFLAGS
    dprintf(-x, "Strip flags: %s\n", STRIPFLAGS);
#endif

    dprintf(-x, "Context: ");
    cx_ptr = cx_ptr & 15;
    for (y = ((cx_ptr + 1) & 15); y != cx_ptr; y = ((y + 1) & 15))
      dprintf(-x, "%s/%d, [%s]\n         ", cx_file[y], cx_line[y],
              (cx_note[y][0]) ? cx_note[y] : "");
    dprintf(-x, "%s/%d [%s]\n\n", cx_file[cx_ptr], cx_line[cx_ptr],
            (cx_note[cx_ptr][0]) ? cx_note[cx_ptr] : "");
    tell_dcc(-x);
    dprintf(-x, "\n");
    debug_mem_to_dcc(-x);
    killsock(x);
    close(x);
    putlog(LOG_MISC, "*", "* Wrote DEBUG");
  }
}
Exemple #2
0
void
readsocks(const char *fname)
{
  /* Don't bother setting this if a hub
     ... it is only intended to prevent parting channels (in bot_shouldjoin())
   */
  if (!conf.bot->hub)
    restarting = 1;

  char *nick = NULL, *jnick = NULL, *ip4 = NULL, *ip6 = NULL;
  time_t old_buildts = 0;

  bool cached_005 = 0;
  const char salt1[] = SALT1;
  EncryptedStream stream(salt1);
  stream.loadFile(fname);
  bd::String str, type;

  reset_chans = 0;

  while (stream.tell() < stream.length()) {
    str = stream.getline().chomp();
    dprintf(DP_DEBUG, "read line: %s\n", str.c_str());
    type = newsplit(str);

    if (type == STR("-dcc"))
      dprintf(DP_DEBUG, STR("Added dcc: %d\n"), dcc_read(stream));
    else if (type == STR("-sock"))
      dprintf(DP_DEBUG, STR("Added fd: %d\n"), sock_read(stream));
    else if (type == STR("+online_since"))
      online_since = strtol(str.c_str(), NULL, 10);
    else if (type == STR("+server_online"))
      server_online = strtol(str.c_str(), NULL, 10);
    else if (type == STR("+server_floodless"))
      floodless = 1;
    else if (type == STR("+in_deaf"))
      in_deaf = 1;
    else if (type == STR("+in_callerid"))
      in_callerid = 1;
    else if (type == STR("+chan")) {
      bd::String chname = str;
      channel_add(NULL, chname.c_str(), NULL);
      struct chanset_t* chan = findchan_by_dname(chname.c_str());
      strlcpy(chan->name, chan->dname, sizeof(chan->name));
      chan->status = chan->ircnet_status = 0;
      chan->ircnet_status |= CHAN_PEND;
      reset_chans = 2;
    }
    else if (type == STR("+buildts"))
      old_buildts = strtol(str.c_str(), NULL, 10);
    else if (type == STR("+botname"))
      nick = str.dup();
    else if (type == STR("+rolls"))
      rolls = atoi(str.c_str());
    else if (type == STR("+altnick_char"))
      altnick_char = str[0];
    else if (type == STR("+burst"))
      burst = atoi(str.c_str());
    else if (type == STR("+flood_count"))
      flood_count = atoi(str.c_str());
    else if (type == STR("+my_cookie_counter")) {
      my_cookie_counter = strtol(str.c_str(), NULL, 10);
      my_cookie_counter += 100; // Increase to avoid race conditions
    }
    else if (type == STR("+ip4"))
      ip4 = str.dup();
    else if (type == STR("+ip6"))
      ip6 = str.dup();
    else if (type == STR("+serv_cache")) {
      if (!cached_005 && str.find(STR("005")))
        cached_005 = 1;
      dprintf(DP_CACHE, "%s", str.c_str());
    }
  }

  restart_time = now;
  if (old_buildts && buildts > old_buildts)
    restart_was_update = 1;

  tell_dcc(DP_DEBUG);
  tell_netdebug(DP_DEBUG);

  unlink(fname);

  if (servidx >= 0) {
    char nserv[50] = "";

    if ((ip4 && ip6) && (strcmp(ip4, myipstr(AF_INET)) || strcmp(ip6, myipstr(AF_INET6)))) {
      if (tands > 0) {		/* We're not linked yet.. but for future */
        botnet_send_chat(-1, conf.bot->nick, STR("IP changed."));
        botnet_send_bye(STR("IP changed."));
      }
      fatal("brb", 1);
    } else if (conf.bot->hub) {
      // I became a hub during restart... disconnect from IRC.
      if (tands > 0) {		/* We're not linked yet.. but for future */
        botnet_send_chat(-1, conf.bot->nick, STR("Changing to HUB."));
        botnet_send_bye(STR("Changing to HUB."));
      }
      nuke_server("emoquit");
    } else {
      simple_snprintf(nserv, sizeof(nserv), "%s:%d", dcc[servidx].host, dcc[servidx].port);
      add_server(nserv);
      curserv = 0;
      keepnick = 0; /* Wait to change nicks until relinking, fixes nick/jupenick switching issues during restart */
      reset_flood();
      if (!server_online) server_online = now;
      rehash_server(dcc[servidx].host, nick);
      if (cached_005)
        replay_cache(servidx, NULL);
      else
        dprintf(DP_DUMP, "VERSION\n");
      if (!reset_chans)
        reset_chans = 1;
    }
  }
  delete[] nick;
  delete[] ip4;
  delete[] ip6;
  if (jnick)
    free(jnick);
  if (socksfile)
    free(socksfile);
}