Exemplo n.º 1
0
static int check_tcl_pubm(char *nick, char *from, char *chname, char *msg)
{
    struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
    int x;
    char buf[1024], host[161];
    struct userrec *u;

    simple_sprintf(buf, "%s %s", chname, msg);
    simple_sprintf(host, "%s!%s", nick, from);
    u = get_user_by_host(host);
    get_user_flagrec(u, &fr, chname);
    Tcl_SetVar(interp, "_pubm1", nick, 0);
    Tcl_SetVar(interp, "_pubm2", from, 0);
    Tcl_SetVar(interp, "_pubm3", u ? u->handle : "*", 0);
    Tcl_SetVar(interp, "_pubm4", chname, 0);
    Tcl_SetVar(interp, "_pubm5", msg, 0);
    x = check_tcl_bind(H_pubm, buf, &fr, " $_pubm1 $_pubm2 $_pubm3 $_pubm4 $_pubm5",
                       MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE | BIND_STACKRET);

    /*
     * 0 - no match
     * 1 - match, log
     * 2 - match, don't log
     */
    if (x == BIND_NOMATCH)
        return 0;
    if (x == BIND_EXEC_LOG)
        return 2;

    return 1;
}
Exemplo n.º 2
0
static void remote_filereq(int idx, char *from, char *file)
{
  char *p, what[256], dir[256], s[256], s1[256], *reject;
  FILE *f;
  filedb fdb;
  long i = 0;

  strcpy(what, file);
  p = strrchr(what, '/');
  if (p == NULL)
    dir[0] = 0;
  else {
    *p = 0;
    strcpy(dir, what);
    strcpy(what, p + 1);
  }
  f = filedb_open(dir, 0);
  reject = NULL;
  if (f == NULL) {
    reject = FILES_DIRDNE;
  } else {
    if (!findmatch(f, what, &i, &fdb)) {
      reject = FILES_FILEDNE;
      filedb_close(f);
    } else {
      if ((!(fdb.stat & FILE_SHARE)) ||
	  (fdb.stat & (FILE_HIDDEN | FILE_DIR))) {
	reject = FILES_NOSHARE;
	filedb_close(f);
      } else {
	filedb_close(f);
	/* copy to /tmp if needed */
	sprintf(s1, "%s%s%s%s", dccdir, dir, dir[0] ? "/" : "", what);
	if (copy_to_tmp) {
	  sprintf(s, "%s%s", tempdir, what);
	  copyfile(s1, s);
	} else
	  strcpy(s, s1);
	i = raw_dcc_send(s, "*remote", FILES_REMOTE, s);
	if (i > 0) {
	  wipe_tmp_filename(s, -1);
	  reject = FILES_SENDERR;
	}
      }
    }
  }
  simple_sprintf(s1, "%s:%s/%s", botnetnick, dir, what);
  if (reject) {
    botnet_send_filereject(idx, s1, from, reject);
    return;
  }
  /* grab info from dcc struct and bounce real request across net */
  i = dcc_total - 1;
  simple_sprintf(s, "%d %u %d", iptolong(getmyip()), dcc[i].port,
		dcc[i].u.xfer->length);
  botnet_send_filesend(idx, s1, from, s);
  putlog(LOG_FILES, "*", FILES_REMOTEREQ, dir, dir[0] ? "/" : "", what);
}
Exemplo n.º 3
0
/* once a minute, send 'ping' to each bot -- no exceptions */
void check_botnet_pings()
{
  int i;

  Context;
  for (i = 0; i < dcc_total; i++)
    if (dcc[i].type == &DCC_BOT)
      if (dcc[i].status & STAT_PINGED) {
	char s[1024];

	putlog(LOG_BOTS, "*", "%s: %s", BOT_PINGTIMEOUT, dcc[i].nick);
	simple_sprintf(s, "%s: %s", BOT_PINGTIMEOUT, dcc[i].nick);
	chatout("*** %s\n", s);
	botnet_send_unlinked(i, dcc[i].nick, s);
	killsock(dcc[i].sock);
	lostdcc(i);
      }
  Context;
  for (i = 0; i < dcc_total; i++)
    if (dcc[i].type == &DCC_BOT) {
      botnet_send_ping(i);
      dcc[i].status |= STAT_PINGED;
    }
  Context;
  for (i = 0; i < dcc_total; i++)
    if ((dcc[i].type == &DCC_BOT) && (dcc[i].status & STAT_LEAF)) {
      tand_t *bot, *via = findbot(dcc[i].nick);

      for (bot = tandbot; bot; bot = bot->next) {
	if ((via == bot->via) && (bot != via)) {
	  /* not leaflike behavior */
	  if (dcc[i].status & STAT_WARNED) {
	    char s[1024];

	    putlog(LOG_BOTS, "*", "%s %s (%s).", BOT_DISCONNECTED,
		   dcc[i].nick, BOT_BOTNOTLEAFLIKE);
	    dprintf(i, "bye\n");
	    simple_sprintf(s, "%s %s (%s)", BOT_DISCONNECTED, dcc[i].nick,
			   BOT_BOTNOTLEAFLIKE);
	    chatout("*** %s\n", s);
	    botnet_send_unlinked(i, dcc[i].nick, s);
	    killsock(dcc[i].sock);
	    lostdcc(i);
	  } else {
	    botnet_send_reject(i, botnetnick, NULL, bot->bot,
			       NULL, NULL);
	    dcc[i].status |= STAT_WARNED;
	  }
	} else
	  dcc[i].status &= ~STAT_WARNED;
      }
    }
  Context;
}
Exemplo n.º 4
0
static int ctcp_CHAT(char *nick, char *uhost, char *handle, char *object,
                     char *keyword, char *text)
{
  struct userrec *u = get_user_by_handle(userlist, handle);
  int atr = u ? u->flags : 0, i;
  char s[INET6_ADDRSTRLEN];
#ifdef TLS
  int ssl = 0;
#endif

  if ((atr & (USER_PARTY | USER_XFER)) || ((atr & USER_OP) && !require_p)) {

    if (u_pass_match(u, "-")) {
      simple_sprintf(ctcp_reply, "%s\001ERROR no password set\001",
                     ctcp_reply);
      return 1;
    }

#ifdef TLS
    if (!egg_strcasecmp(keyword, "SCHAT"))
      ssl = 1;
#endif
    for (i = 0; i < dcc_total; i++) {
      if ((dcc[i].type->flags & DCT_LISTEN) &&
#ifdef TLS
          (ssl == dcc[i].ssl) &&
#endif
          (!strcmp(dcc[i].nick, "(telnet)") ||
           !strcmp(dcc[i].nick, "(users)")) &&
          getdccaddr(&dcc[i].sockname, s, sizeof s)) {
        /* Do me a favour and don't change this back to a CTCP reply,
         * CTCP replies are NOTICE's this has to be a PRIVMSG
         * -poptix 5/1/1997 */
#ifdef TLS
	  dprintf(DP_SERVER, ":%s PRIVMSG %s :\001DCC %sCHAT chat %s %u\001\n",
		  botname, nick, (ssl ? "S" : ""), s, dcc[i].port);
#else
          dprintf(DP_SERVER, ":%s PRIVMSG %s :\001DCC CHAT chat %s %u\001\n",
                  botname, nick, s, dcc[i].port);
#endif
        return 1;
      }
    }
#ifdef TLS
    simple_sprintf(ctcp_reply, "%s\001ERROR no %stelnet port\001", ctcp_reply,
	 	   (ssl ? "SSL enabled " : ""));
#else
    simple_sprintf(ctcp_reply, "%s\001ERROR no telnet port\001", ctcp_reply);
#endif
  }
  return 1;
}
Exemplo n.º 5
0
static int console_pack(struct userrec *u, struct user_entry *e)
{
  char work[1024];
  struct console_info *ci;
  int l;

  Assert(e);
  Assert(e->u.extra);
  Assert(!e->name);

  ci = (struct console_info *) e->u.extra;

  l = simple_sprintf(work, "%s %s %s %d %d %d",
		     ci->channel, masktype(ci->conflags),
		     stripmasktype(ci->stripflags), ci->echoflags,
		     ci->page, ci->conchan);

  e->u.list = user_malloc(sizeof(struct list_type));
  e->u.list->next = NULL;
  e->u.list->extra = user_malloc(l + 1);
  strcpy(e->u.list->extra, work);

  nfree(ci->channel);
  nfree(ci);
  return 1;
}
Exemplo n.º 6
0
static int ctcp_ECHOERR(char *nick, char *uhost, char *handle,
                        char *object, char *keyword, char *text)
{
  if (ctcp_mode != 1 && strlen(text) <= 80)
    simple_sprintf(ctcp_reply, "%s\001%s %s\001", ctcp_reply, keyword, text);
  return 1;
}
Exemplo n.º 7
0
static int ctcp_FINGER(char *nick, char *uhost, char *handle,
                       char *object, char *keyword, char *text)
{
  if (ctcp_mode != 1 && ctcp_finger[0])
    simple_sprintf(ctcp_reply, "%s\001FINGER %s\001", ctcp_reply, ctcp_finger);
  return 1;
}
Exemplo n.º 8
0
static int check_tcl_msgm(char *cmd, char *nick, char *uhost,
                           struct userrec *u, char *arg)
{
  struct flag_record fr = { FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0 };
  int x;
  char args[1024];

  if (arg[0])
    simple_sprintf(args, "%s %s", cmd, arg);
  else
    strcpy(args, cmd);
  get_user_flagrec(u, &fr, NULL);
  Tcl_SetVar(interp, "_msgm1", nick, 0);
  Tcl_SetVar(interp, "_msgm2", uhost, 0);
  Tcl_SetVar(interp, "_msgm3", u ? u->handle : "*", 0);
  Tcl_SetVar(interp, "_msgm4", args, 0);
  x = check_tcl_bind(H_msgm, args, &fr, " $_msgm1 $_msgm2 $_msgm3 $_msgm4",
                     MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE | BIND_STACKRET);

  /*
   * 0 - no match
   * 1 - match, log
   * 2 - match, don't log
   */
  if (x == BIND_NOMATCH)
    return 0;
  if (x == BIND_EXEC_LOG)
    return 2;

  return 1;
}
Exemplo n.º 9
0
static int check_tcl_pub(char *nick, char *from, char *chname, char *msg)
{
    struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
    int x;
    char buf[512], *args = buf, *cmd, host[161], *hand;
    struct userrec *u;

    strcpy(args, msg);
    cmd = newsplit(&args);
    simple_sprintf(host, "%s!%s", nick, from);
    u = get_user_by_host(host);
    hand = u ? u->handle : "*";
    get_user_flagrec(u, &fr, chname);
    Tcl_SetVar(interp, "_pub1", nick, 0);
    Tcl_SetVar(interp, "_pub2", from, 0);
    Tcl_SetVar(interp, "_pub3", hand, 0);
    Tcl_SetVar(interp, "_pub4", chname, 0);
    Tcl_SetVar(interp, "_pub5", args, 0);
    x = check_tcl_bind(H_pub, cmd, &fr, " $_pub1 $_pub2 $_pub3 $_pub4 $_pub5",
                       MATCH_EXACT | BIND_USE_ATTR | BIND_HAS_BUILTINS);
    if (x == BIND_NOMATCH)
        return 0;
    if (x == BIND_EXEC_LOG)
        putlog(LOG_CMDS, chname, "<<%s>> !%s! %s %s", nick, hand, cmd, args);
    return 1;
}
Exemplo n.º 10
0
static void got_invite(struct chanset_t *chan, char *nick, char *from,
                       char *who, char *ch, struct userrec *u)
{
  char s[UHOSTLEN];

  simple_sprintf(s, "%s!%s", nick, from);
  newinvite(chan, who, s);
  check_tcl_mode(nick, from, u, chan->dname, "+I", who);
  if (!(chan = modebind_refresh(ch, from, &user, NULL, NULL)))
    return;

  if (channel_pending(chan) || HALFOP_CANTDOMODE('I'))
    return;

  if (!match_my_nick(nick)) {
    if (nick[0] && channel_nouserinvites(chan) && !glob_bot(user) &&
        !glob_master(user) && !chan_master(user)) {
      add_mode(chan, '-', 'I', who);
      return;
    }
    if ((!nick[0]) && (bounce_modes))
      reversing = 1;
  }
  if (reversing || (bounce_invites && (!nick[0]) &&
      (!u_equals_mask(global_invites, who) ||
      !u_equals_mask(chan->invites, who))))
    add_mode(chan, '-', 'I', who);
}
Exemplo n.º 11
0
/* Converts old versions of the filedb to the newest. Returns 1 if all went
 * well and otherwise 0. The new db is first written to a temporary place
 * and then moved over to the original db's position.
 *
 * Note: Unfortunately there is a small time-frame where aren't locking the
 *       DB, but want to replace it with a new one, using movefile().
 *       TODO: Copy old db to tmp file and then build the new db directly
 *             in the original file. This solves the tiny locking problem.
 *
 * Also remember to check the returned *fdb_s on failure, as it could be
 * NULL.
 */
static int convert_old_db(FILE ** fdb_s, char *filedb)
{
    filedb_top fdbt;
    FILE *fdb_t;
    int ret = 0;                  /* Default to 'failure' */

    filedb_readtop(*fdb_s, &fdbt);
    /* Old DB version? */
    if (fdbt.version > 0 && fdbt.version < FILEDB_VERSION3) {
        char *tempdb;

        putlog(LOG_MISC, "*", "Converting old filedb %s to newest format.",
               filedb);
        /* Create temp DB name */
        tempdb = nmalloc(strlen(filedb) + 5);
        simple_sprintf(tempdb, "%s-tmp", filedb);

        fdb_t = fopen(tempdb, "w+b");       /* Open temp DB         */
        if (fdb_t) {
            filedb_initdb(fdb_t);     /* Initialise new DB    */

            /* Convert old database to new one, saving
             * in temporary db file
             */
            if (fdbt.version == FILEDB_VERSION1)
                convert_version1(*fdb_s, fdb_t);        /* v1 -> v3             */
            else
                convert_version2(*fdb_s, fdb_t);        /* v2 -> v3             */

            unlockfile(*fdb_s);
            fclose(fdb_t);
            fclose(*fdb_s);

            /* Move over db to new location */
            if (movefile(tempdb, filedb))
                putlog(LOG_MISC, "*", "(!) Moving file db from %s to %s failed.",
                       tempdb, filedb);

            *fdb_s = fopen(filedb, "r+b");    /* Reopen new db        */
            if (*fdb_s) {
                lockfile(*fdb_s);
                /* Now we should have recreated the original situation,
                 * with the file pointer just pointing to the new version
                 * of the DB instead of the original one.
                 */
                ret = 1;
            } else
                putlog(LOG_MISC, "*", "(!) Reopening db %s failed.", filedb);
        }
        my_free(tempdb);
        /* Database already at the newest version? */
    } else if (fdbt.version == FILEDB_VERSION3)
        ret = 1;
    else
        putlog(LOG_MISC, "*", "(!) Unknown db version: %d", fdbt.version);
    if (!ret)
        putlog(LOG_MISC, "*", "Conversion of filedb %s failed.", filedb);
    return ret;
}
Exemplo n.º 12
0
static int ctcp_USERINFO(char *nick, char *uhost, char *handle,
                         char *object, char *keyword, char *text)
{
  if (ctcp_mode != 1 && ctcp_userinfo[0])
    simple_sprintf(ctcp_reply, "%s\001USERINFO %s\001", ctcp_reply,
                   ctcp_userinfo);
  return 1;
}
Exemplo n.º 13
0
static int ctcp_VERSION(char *nick, char *uhost, char *handle,
                        char *object, char *keyword, char *text)
{
  if (ctcp_mode != 1 && ctcp_version[0])
    simple_sprintf(ctcp_reply, "%s\001VERSION %s\001", ctcp_reply,
                   ctcp_version);
  return 1;
}
Exemplo n.º 14
0
static int cmd_onwire(struct userrec *u, int idx, char *par)
{
  wire_list *w, *w2;
  char wiretmp[512], wirecmd[512], idxtmp[512];
  char idle[20], *enctmp;
  time_t now2 = now;

  w = wirelist;
  while (w) {
    if (w->sock == dcc[idx].sock)
      break;
    w = w->next;
  }
  if (!w) {
    dprintf(idx, "%s\n", WIRE_NOTONWIRE);
    return 0;
  }
  dprintf(idx, "----- %s '%s':\n", WIRE_CURRENTLYON, w->key);
  dprintf(idx, "----- Nick       Bot        Host\n");
  dprintf(idx, "----- ---------- ---------- ------------------------------\n");
  enctmp = encrypt_string(w->key, "wire");
  sprintf(wirecmd, "!wire%s", enctmp);
  nfree(enctmp);
  enctmp = encrypt_string(w->key, dcc[idx].nick);
  strcpy(wiretmp, enctmp);
  nfree(enctmp);
  simple_sprintf(idxtmp, "!wirereq %d %s", dcc[idx].sock, wiretmp);
  botnet_send_zapf_broad(-1, botnetnick, wirecmd, idxtmp);
  w2 = wirelist;
  while (w2) {
    if (!strcmp(w2->key, w->key)) {
      int idx2 = findanyidx(w2->sock);

      if (now2 - dcc[idx2].timeval > 300) {
        unsigned long Days, hrs, mins;

        Days = (now2 - dcc[idx2].timeval) / 86400;
        hrs = ((now2 - dcc[idx2].timeval) - (Days * 86400)) / 3600;
        mins = ((now2 - dcc[idx2].timeval) - (hrs * 3600)) / 60;
        if (Days > 0)
          sprintf(idle, " [%s %lud%luh]", WIRE_IDLE, Days, hrs);
        else if (hrs > 0)
          sprintf(idle, " [%s %luh%lum]", WIRE_IDLE, hrs, mins);
        else
          sprintf(idle, " [%s %lum]", WIRE_IDLE, mins);
      } else
        idle[0] = 0;
      dprintf(idx, "----- %c%-9s %-9s  %s%s\n",
              geticon(idx2), dcc[idx2].nick, botnetnick, dcc[idx2].host, idle);
      if (dcc[idx2].u.chat->away)
        dprintf(idx, "-----    %s: %s\n", WIRE_AWAY, dcc[idx2].u.chat->away);
    }
    w2 = w2->next;
  }
  return 0;
}
Exemplo n.º 15
0
static void check_tcl_need(char *chname, char *type)
{
    char buf[1024];

    simple_sprintf(buf, "%s %s", chname, type);
    Tcl_SetVar(interp, "_need1", chname, 0);
    Tcl_SetVar(interp, "_need2", type, 0);
    check_tcl_bind(H_need, buf, 0, " $_need1 $_need2",
                   MATCH_MASK | BIND_STACKABLE);
}
Exemplo n.º 16
0
void zapfbot(int idx)
{
  char s[1024];

  simple_sprintf(s, "%s: %s", BOT_BOTDROPPED, dcc[idx].nick);
  chatout("*** %s\n", s);
  botnet_send_unlinked(idx, dcc[idx].nick, s);
  killsock(dcc[idx].sock);
  lostdcc(idx);
}
Exemplo n.º 17
0
static int ctcp_PING(char *nick, char *uhost, char *handle,
                     char *object, char *keyword, char *text)
{
  struct userrec *u = get_user_by_handle(userlist, handle);
  int atr = u ? u->flags : 0;

  if ((ctcp_mode != 1 || (atr & USER_OP)) && strlen(text) <= 80)
    simple_sprintf(ctcp_reply, "%s\001%s %s\001", ctcp_reply, keyword, text);
  return 1;
}
Exemplo n.º 18
0
static void check_tcl_signtopcnick(char *nick, char *uhost, struct userrec *u,
                                   char *chname, char *reason,
                                   p_tcl_bind_list table)
{
    struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
    char args[1024];

    if (table == H_sign)
        simple_sprintf(args, "%s %s!%s", chname, nick, uhost);
    else
        simple_sprintf(args, "%s %s", chname, reason);
    get_user_flagrec(u, &fr, chname);
    Tcl_SetVar(interp, "_stnm1", nick, 0);
    Tcl_SetVar(interp, "_stnm2", uhost, 0);
    Tcl_SetVar(interp, "_stnm3", u ? u->handle : "*", 0);
    Tcl_SetVar(interp, "_stnm4", chname, 0);
    Tcl_SetVar(interp, "_stnm5", reason, 0);
    check_tcl_bind(table, args, &fr, " $_stnm1 $_stnm2 $_stnm3 $_stnm4 $_stnm5",
                   MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
}
Exemplo n.º 19
0
static int ctcp_CLIENTINFO(char *nick, char *uhosr, char *handle,
                           char *object, char *keyword, char *msg)
{
  char *p = NULL;

  if (ctcp_mode == 1)
    return 1;
  else if (!msg[0])
    p = CLIENTINFO;
  else if (!egg_strcasecmp(msg, "sed"))
    p = CLIENTINFO_SED;
  else if (!egg_strcasecmp(msg, "version"))
    p = CLIENTINFO_VERSION;
  else if (!egg_strcasecmp(msg, "clientinfo"))
    p = CLIENTINFO_CLIENTINFO;
  else if (!egg_strcasecmp(msg, "userinfo"))
    p = CLIENTINFO_USERINFO;
  else if (!egg_strcasecmp(msg, "errmsg"))
    p = CLIENTINFO_ERRMSG;
  else if (!egg_strcasecmp(msg, "finger"))
    p = CLIENTINFO_FINGER;
  else if (!egg_strcasecmp(msg, "time"))
    p = CLIENTINFO_TIME;
  else if (!egg_strcasecmp(msg, "action"))
    p = CLIENTINFO_ACTION;
  else if (!egg_strcasecmp(msg, "dcc"))
    p = CLIENTINFO_DCC;
  else if (!egg_strcasecmp(msg, "utc"))
    p = CLIENTINFO_UTC;
  else if (!egg_strcasecmp(msg, "ping"))
    p = CLIENTINFO_PING;
  else if (!egg_strcasecmp(msg, "echo"))
    p = CLIENTINFO_ECHO;
  if (p == NULL) {
    simple_sprintf(ctcp_reply,
                   "%s\001ERRMSG CLIENTINFO: %s is not a valid function\001",
                   ctcp_reply, msg);
  } else
    simple_sprintf(ctcp_reply, "%s\001CLIENTINFO %s\001", ctcp_reply, p);
  return 1;
}
Exemplo n.º 20
0
/* trace <from@bot> <dest> <chain:chain..>
 */
static void bot_trace(int idx, char *par)
{
  char *from, *dest;
  int i;

  from = newsplit(&par);
  dest = newsplit(&par);
  simple_sprintf(TBUF, "%s:%s", par, botnetnick);
  botnet_send_traced(idx, from, TBUF);
  if (egg_strcasecmp(dest, botnetnick) && ((i = nextbot(dest)) > 0))
    botnet_send_trace(i, from, dest, par);
}
Exemplo n.º 21
0
static int ctcp_TIME(char *nick, char *uhost, char *handle, char *object,
                     char *keyword, char *text)
{
  char tms[25];

  if (ctcp_mode == 1)
    return 1;
  strncpy(tms, ctime(&now), 24);
  tms[24] = 0;
  simple_sprintf(ctcp_reply, "%s\001TIME %s\001", ctcp_reply, tms);
  return 1;
}
Exemplo n.º 22
0
static void botnet_send_assoc(int idx, int chan, char *nick, char *buf)
{
  char x[1024];
  int idx2;

  simple_sprintf(x, "assoc %D %s %s", chan, nick, buf);
  for (idx2 = 0; idx2 < dcc_total; idx2++)
    if ((dcc[idx2].type == &DCC_BOT) && (idx2 != idx) &&
        (b_numver(idx2) >= NEAT_BOTNET) &&
        !(bot_flags(dcc[idx2].user) & BOT_ISOLATE))
      botnet_send_zapf(idx2, botnetnick, dcc[idx2].nick, x);
}
Exemplo n.º 23
0
static int console_tcl_get(Tcl_Interp *irp, struct userrec *u,
			   struct user_entry *e, int argc, char **argv)
{
  char work[1024];
  struct console_info *i = e->u.extra;

  simple_sprintf(work, "%s %s %s %d %d %d",
		 i->channel, masktype(i->conflags),
		 stripmasktype(i->stripflags), i->echoflags,
		 i->page, i->conchan);
  Tcl_AppendResult(irp, work, NULL);
  return TCL_OK;
}
Exemplo n.º 24
0
static void check_tcl_joinspltrejn(char *nick, char *uhost, struct userrec *u,
                                   char *chname, p_tcl_bind_list table)
{
    struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
    char args[1024];

    simple_sprintf(args, "%s %s!%s", chname, nick, uhost);
    get_user_flagrec(u, &fr, chname);
    Tcl_SetVar(interp, "_jp1", nick, 0);
    Tcl_SetVar(interp, "_jp2", uhost, 0);
    Tcl_SetVar(interp, "_jp3", u ? u->handle : "*", 0);
    Tcl_SetVar(interp, "_jp4", chname, 0);
    check_tcl_bind(table, args, &fr, " $_jp1 $_jp2 $_jp3 $_jp4",
                   MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
}
Exemplo n.º 25
0
static void check_tcl_part(char *nick, char *uhost, struct userrec *u,
                           char *chname, char *text)
{
    struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
    char args[1024];

    simple_sprintf(args, "%s %s!%s", chname, nick, uhost);
    get_user_flagrec(u, &fr, chname);
    Tcl_SetVar(interp, "_p1", nick, 0);
    Tcl_SetVar(interp, "_p2", uhost, 0);
    Tcl_SetVar(interp, "_p3", u ? u->handle : "*", 0);
    Tcl_SetVar(interp, "_p4", chname, 0);
    Tcl_SetVar(interp, "_p5", text ? text : "", 0);
    check_tcl_bind(H_part, args, &fr, " $_p1 $_p2 $_p3 $_p4 $_p5",
                   MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
}
Exemplo n.º 26
0
static void bot_linked(int idx, char *par)
{
  char s[1024];
  int bots, users;

  bots = bots_in_subtree(findbot(dcc[idx].nick));
  users = users_in_subtree(findbot(dcc[idx].nick));
  putlog(LOG_BOTS, "*", "%s", BOT_OLDBOT);
  simple_sprintf(s, "%s %s (%s) (lost %d bot%s and %d user%s",
                 MISC_DISCONNECTED, dcc[idx].nick, MISC_OUTDATED,
                 bots, (bots != 1) ? "s" : "", users, (users != 1) ? "s" : "");
  chatout("*** %s\n", s);
  botnet_send_unlinked(idx, dcc[idx].nick, s);
  killsock(dcc[idx].sock);
  lostdcc(idx);
}
Exemplo n.º 27
0
static void link_assoc(char *bot, char *via)
{
  char x[1024];

  if (!egg_strcasecmp(via, botnetnick)) {
    int idx = nextbot(bot);
    assoc_t *a;

    if (!(bot_flags(dcc[idx].user) & BOT_ISOLATE)) {
      for (a = assoc; a && a->name[0]; a = a->next) {
        simple_sprintf(x, "assoc %D %s %s", (int) a->channel, botnetnick,
                       a->name);
        botnet_send_zapf(idx, botnetnick, dcc[idx].nick, x);
      }
    }
  }
}
Exemplo n.º 28
0
static void channels_writeuserfile(void)
{
  char s[1024];
  FILE *f;
  int ret = 0;

  simple_sprintf(s, "%s~new", userfile);
  f = fopen(s, "a");
  if (f) {
    ret = write_bans(f, -1);
    ret += write_exempts(f, -1);
    ret += write_invites(f, -1);
    fclose(f);
  }
  if (ret < 3)
    putlog(LOG_MISC, "*", USERF_ERRWRITE);
  write_channels();
}
Exemplo n.º 29
0
static void check_tcl_mode(char *nick, char *uhost, struct userrec *u,
                           char *chname, char *mode, char *target)
{
    struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
    char args[512];

    get_user_flagrec(u, &fr, chname);
    simple_sprintf(args, "%s %s", chname, mode);
    Tcl_SetVar(interp, "_mode1", nick, 0);
    Tcl_SetVar(interp, "_mode2", uhost, 0);
    Tcl_SetVar(interp, "_mode3", u ? u->handle : "*", 0);
    Tcl_SetVar(interp, "_mode4", chname, 0);
    Tcl_SetVar(interp, "_mode5", mode, 0);
    Tcl_SetVar(interp, "_mode6", target, 0);
    check_tcl_bind(H_mode, args, &fr,
                   " $_mode1 $_mode2 $_mode3 $_mode4 $_mode5 $_mode6",
                   MATCH_MODE | BIND_USE_ATTR | BIND_STACKABLE);
}
Exemplo n.º 30
0
static void check_tcl_kick(char *nick, char *uhost, struct userrec *u,
                           char *chname, char *dest, char *reason)
{
    struct flag_record fr = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
    char args[512];

    get_user_flagrec(u, &fr, chname);
    simple_sprintf(args, "%s %s %s", chname, dest, reason);
    Tcl_SetVar(interp, "_kick1", nick, 0);
    Tcl_SetVar(interp, "_kick2", uhost, 0);
    Tcl_SetVar(interp, "_kick3", u ? u->handle : "*", 0);
    Tcl_SetVar(interp, "_kick4", chname, 0);
    Tcl_SetVar(interp, "_kick5", dest, 0);
    Tcl_SetVar(interp, "_kick6", reason, 0);
    check_tcl_bind(H_kick, args, &fr,
                   " $_kick1 $_kick2 $_kick3 $_kick4 $_kick5 $_kick6",
                   MATCH_MASK | BIND_USE_ATTR | BIND_STACKABLE);
}