Exemple #1
0
/**
 * handle the IDENTIFY command
 */
void cs_identify(char *src,int ac,char **av) {
	if(ac<3) {
		notice(cs_name,src,CS_IDENTIFY_ERR_USAGE);
		notice(cs_name,src,NS_RPL_HLP_SHORT,cs_name,"HELP IDENTIFY");
		return;
	}
	char *chan = sstrdup(av[1]);
	char *pass = sstrdup(av[2]);
	user *u = finduser(src);
	if (!isregcs(chan)) {
		notice(cs_name, src, CS_ERR_NOTREG, chan);
		return;
	}
	if (isidentified(u, chan) > 0) {
		notice(ns_name, src, CS_IDENTIFY_RPL_ALREADYIDF, chan);
		return;
	}
	ChanInfo *c = findchan(chan);
	if (stricmp(pass,c->pass)!=0) {
		notice(cs_name,src,CS_IDENTIFY_ERR_WRONGPASS,chan);
		return;
	} else {
		notice(cs_name,src,CS_IDENTIFY_RPL_PASSACCEPTED,chan);
		add_identifiedcs(u,chan);
	}
	return;
}
Exemple #2
0
void alog(const char *fmt, ...)
{
    va_list args;
    char *buf;
    int errno_save = errno;
    char str[BUFSIZE];

    checkday();

    if (!fmt) {
        return;
    }

    va_start(args, fmt);
    vsnprintf(str, sizeof(str), fmt, args);
    va_end(args);

    buf = log_gettimestamp();

    if (logfile) {
        fprintf(logfile, "%s %s\n", buf, str);
    }
    if (nofork) {
        fprintf(stderr, "%s %s\n", buf, str);
    }
    if (LogChannel && logchan && !debug && findchan(LogChannel)) {
        privmsg(s_GlobalNoticer, LogChannel, "%s", str);
    }
    errno = errno_save;
}
Exemple #3
0
/**
 * The /os mode command.
 * @param u The user who issued the command
 * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
 **/
static int do_os_mode(User * u)
{
    int ac;
    char **av;
    char *chan = strtok(NULL, " "), *modes = strtok(NULL, "");
    Channel *c;

    if (!chan || !modes) {
        syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
        return MOD_CONT;
    }

    if (!(c = findchan(chan))) {
        notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (c->bouncy_modes) {
        notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
        return MOD_CONT;
    } else if ((ircd->adminmode) && (!is_services_admin(u))
               && (c->mode & ircd->adminmode)) {
        notice_lang(s_OperServ, u, PERMISSION_DENIED);
        return MOD_CONT;
    } else {
        anope_cmd_mode(s_OperServ, chan, "%s", modes);

        ac = split_buf(modes, &av, 1);
        chan_set_modes(s_OperServ, c, ac, av, -1);
        free(av);

        if (WallOSMode)
            anope_cmd_global(s_OperServ, "%s used MODE %s on %s", u->nick,
                             modes, chan);
    }
    return MOD_CONT;
}
Exemple #4
0
static void do_os_kick(User * u)
{
	char *argv[3];
	char *chan, *nick, *s;
	Channel *c;

	chan = strtok(NULL, " ");
	nick = strtok(NULL, " ");
	s = strtok(NULL, "");

	if (!chan || !nick || !s) {
		syntax_error(s_OperServ, u, "KICK", OPER_KICK_SYNTAX);
		return;
	}
	if (!(c = findchan(chan))) {
		notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
	} else if (c->bouncy_modes) {
		notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
		return;
	}
	send_cmd(s_OperServ, "KICK %s %s :%s (%s)", chan, nick, u->nick, s);
	
	if (WallOSKick) {
		wallops(s_OperServ, "%s used KICK on %s/%s", u->nick, nick,
		    chan);
	}
	
	argv[0] = sstrdup(chan);
	argv[1] = sstrdup(nick);
	argv[2] = sstrdup(s);
	do_kick(s_OperServ, 3, argv);
	free(argv[2]);
	free(argv[1]);
	free(argv[0]);
}
Exemple #5
0
/* Got 442: not on channel
 */
static int got442(char *from, char *msg)
{
  char *chname, *key;
  struct chanset_t *chan;

  if (!realservername || egg_strcasecmp(from, realservername))
    return 0;
  newsplit(&msg);
  chname = newsplit(&msg);
  chan = findchan(chname);
  if (chan && !channel_inactive(chan)) {
    module_entry *me = module_find("channels", 0, 0);

    putlog(LOG_MISC, chname, IRC_SERVNOTONCHAN, chname);
    if (me && me->funcs)
      (me->funcs[CHANNEL_CLEAR]) (chan, 1);
    chan->status &= ~CHAN_ACTIVE;

    key = chan->channel.key[0] ? chan->channel.key : chan->key_prot;
    if (key[0])
      dprintf(DP_SERVER, "JOIN %s %s\n", chan->name, key);
    else
      dprintf(DP_SERVER, "JOIN %s\n", chan->name);
  }
  return 0;
}
Exemple #6
0
/* 437 : Nickname juped (IRCnet)
 */
static int got437(char *from, char *msg)
{
  char *s;
  struct chanset_t *chan;

  newsplit(&msg);
  s = newsplit(&msg);
  if (s[0] && (strchr(CHANMETA, s[0]) != NULL)) {
    chan = findchan(s);
    if (chan) {
      if (chan->status & CHAN_ACTIVE) {
        putlog(LOG_MISC, "*", IRC_CANTCHANGENICK, s);
      } else {
        if (!channel_juped(chan)) {
          putlog(LOG_MISC, "*", IRC_CHANNELJUPED, s);
          chan->status |= CHAN_JUPED;
        }
      }
    }
  } else if (server_online) {
    if (!nick_juped)
      putlog(LOG_MISC, "*", "NICK IS JUPED: %s (keeping '%s').", s, botname);
    if (!rfc_casecmp(s, origbotname))
      nick_juped = 1;
  } else {
    putlog(LOG_MISC, "*", "%s: %s", IRC_BOTNICKJUPED, s);
    gotfake433(from);
  }
  return 0;
}
Exemple #7
0
 int do_redirect (User *u) {
     char *buf = moduleGetLastBuffer();
     User *target= NULL;
     Channel *c;
     ChannelInfo *ci;
     char *nick = myStrGetToken (buf,' ', 0);
     char *chan1 = myStrGetToken (buf,' ', 1);
     char *chan2 = myStrGetToken (buf,' ', 2);
     
     if (!u ||!chan1||!nick||!chan2)
     {
                  if (nick) free(nick);
                  if (chan1) free(chan1);
                  if (chan2) free(chan2);
                  return MOD_STOP;
     }
     if (!(target = finduser(nick))) 
     {
                  notice (s_OperServ, u->nick,"No such user to redirect");
                  if (nick) free(nick);
                  if (chan1) free(chan1);
                  if (chan2) free(chan2);
                  return MOD_STOP;
     }
     if (!(ci = cs_findchan(chan1)))
     {
              if (nick) free(nick);
              if (chan1) free(chan1);
              if (chan2) free(chan2);
              return MOD_STOP;
     }
     if (!(c = findchan(ci->name)))
     {
                 notice (s_OperServ, u->nick,"No such channel to be redirected from.");
                 if (nick) free(nick);
                 if (chan1) free(chan1);
                 if (chan2) free(chan2);
                 return MOD_STOP;        
     }
     if (!(is_on_chan(c,target)))
     {
                 notice (s_OperServ, u->nick,"User %s is not in this channel", target->nick);
                 if (nick) free(nick);
                 if (chan1) free(chan1);
                 if (chan2) free(chan2);
                 return MOD_STOP;
     }
    
    notice (s_OperServ, u->nick,"Redirecting user %s from channel %s to channel %s",target->nick,chan1,chan2);
    wallops(c->ci->bi->nick, "%s redirected %s from channel %s to channel %s .", u->nick, nick, c->name , chan2); 
	anope_cmd_svspart(c->ci->bi->nick, nick, c->name);
	anope_cmd_svsjoin(s_OperServ, target->nick, chan2, NULL);
    notice (s_OperServ, target->nick,"You have been redirected from channel %s to channel %s by operator %s", chan1,chan2,u->nick);
    if (nick) free(nick);
    if (chan1) free(chan1);
    if (chan2) free(chan2);
 
     /* Halt processing */
     return MOD_STOP;
 }
Exemple #8
0
/**
 * handle the MKICK command
 */
void cs_mkick(char *src, int ac, char **av) {
	if (ac < 2) {
		notice(cs_name, src, CS_MKICK_ERR_USAGE);
		notice(cs_name, src, CS_RPL_HLP, cs_name, "MKICK");
		return;
	}
	char *chan = sstrdup(av[1]);
	char *reason = sstrdup(av[2]);
	user *u = finduser(src);
	if (!isregcs(chan)) {
		notice(cs_name, src, CS_ERR_NOTREG, chan);
		return;
	}
	ChanInfo *c = findchan(chan);
	if (cs_xop_get_level(u, c) < cs_mkick_access) {
		notice(cs_name, src, CS_XOP_ERR_HIGHERACCESS, get_opacc(cs_mkick_access));
		return;
	}
	channel *channel = findchannel(chan);
	int relevant_count;
	if(channel->bot) {
		relevant_count = 1;
	} else {
		relevant_count = 0;
	}
		if(channel->ucnt<relevant_count) {
		notice(cs_name,src,CS_MKICK_RPL_NOUSERS,chan);
		return;
	}
	char final_reason[256];
	sprintf(final_reason,"MKICK Command used by %s (%s)",src,reason);
	do_mkick(channel,final_reason);

	return;
}
Exemple #9
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params)
	{
		User *u = source.u;
		const Anope::string &chan = params[0];
		const Anope::string &nick = params[1];
		const Anope::string &s = params[2];
		Channel *c;
		User *u2;

		if (!(c = findchan(chan)))
		{
			source.Reply(CHAN_X_NOT_IN_USE, chan.c_str());
			return;
		}
		else if (c->bouncy_modes)
		{
			source.Reply(_("Services is unable to change modes. Are your servers' U:lines configured correctly?"));
			return;
		}
		else if (!(u2 = finduser(nick)))
		{
			source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
			return;
		}

		c->Kick(source.owner, u2, "%s (%s)", u->nick.c_str(), s.c_str());
		Log(LOG_ADMIN, u, this) << "on " << u2->nick << " in " << c->name << " (" << s << ")";
		return;
	}
Exemple #10
0
static void pls_chan(int idx, char *par, char *bot)
{
  char *chname = NULL, result[RESULT_LEN] = "", buf[2048] = "";
  struct chanset_t *chan = NULL;

  if (!bot)
    putlog(LOG_CMDS, "*", "#%s# +chan %s", dcc[idx].nick, par);

  if (!par[0]) {
    dprintf(idx, "Usage: +chan [%s]<channel> [options]\n", CHANMETA);
    return;
  }

  chname = newsplit(&par);
  simple_snprintf(buf, sizeof(buf), "cjoin %s %s", chname, bot ? bot : "*");		/* +chan makes all bots join */
  if (par[0]) {
    strlcat(buf, " ", sizeof(buf));
    strlcat(buf, par, sizeof(buf));
    strlcat(buf, " ", sizeof(buf));
  }
    
  if (!bot && findchan_by_dname(chname)) {
    dprintf(idx, "That channel already exists!\n");
    return;
  } else if ((chan = findchan(chname)) && !bot) {
    dprintf(idx, "That channel already exists as %s!\n", chan->dname);
    return;
  } else if (strchr(CHANMETA, chname[0]) == NULL) {
    dprintf(idx, "Invalid channel prefix.\n");
    return;
  } else if (strchr(chname, ',') != NULL) {
    dprintf(idx, "Invalid channel name.\n");
    return;
  }
  if (!chan && !findchan_by_dname(chname) && channel_add(result, chname, par) == ERROR) {
    dprintf(idx, "Invalid channel or channel options.\n");
    if (result[0])
      dprintf(idx, " %s\n", result);
  } else {
    if ((chan = findchan_by_dname(chname))) {
      char tmp[51] = "";

      simple_snprintf(tmp, sizeof(tmp), "addedby %s addedts %li", dcc[idx].nick, (long) now);
      if (buf[0]) {
        strlcat(buf, " ", sizeof(buf));
        strlcat(buf, tmp, sizeof(buf));
      }
      do_chanset(NULL, chan, buf[0] ? buf : tmp, DO_LOCAL);
      if (!bot) {
        dprintf(idx, "Channel %s added to the botnet.\n", chname);
      } else {
        dprintf(idx, "Channel %s added to the bot: %s\n", chname, bot);
      }
      putallbots(buf);
    }
    if (conf.bot->hub)
      write_userfile(-1);
  }
}
Exemple #11
0
static int bot_gseen_rep(char *bot, char *code, char *par)
{
  char *nick, *chan, *reply;
  int i;

  Context;
  if (seenflood())
    return 0;
  if (!bnsnick || !bnschan) {
    if (bnsnick)
      nfree(bnsnick);
    if (bnschan)
      nfree(bnschan);
    bnsnick = bnschan = NULL;
    return 0;
  }
  nick = newsplit(&par);
  chan = newsplit(&par);
  reset_global_vars();
  glob_remotebot = bot;
  glob_slang = slang_find(coreslangs, slang_chanlang_get(chanlangs, chan));
  glob_nick = nick;
  reply = par;
  if (strcmp(nick, bnsnick) || strcmp(chan, bnschan))
    return 0; /* unwanted reply */
  if (findchan(chan)) {
    if (nopub(chan)) {
      nfree(bnsnick);
      nfree(bnschan);
      bnsnick = bnschan = NULL;
      debug1("%s is nopub, bns-reply dropped", chan);
      return 0;
    }
    if (quietseen(chan)) {
      set_prefix(SLNOTPREFIX);
      dprintf(DP_HELP, "NOTICE %s :%s%s%s\n", nick, reply_prefix, SLRBOTSAYS, reply);
    } else {
      set_prefix(SLPUBPREFIX);
      dprintf(DP_HELP, "PRIVMSG %s :%s%s%s\n", chan, reply_prefix, SLRBOTSAYS, reply);
    }
  } else if (!strcmp(chan, "[/msg]")) {
    set_prefix(SLMSGPREFIX);
    dprintf(DP_HELP, "PRIVMSG %s :%s%s%s\n", nick, reply_prefix, SLRBOTSAYS, reply);
  } else if (!strcmp(chan, "[partyline]")) {
    for (i = 0; i < dcc_total; i++) {
      if ((!strcasecmp(nick, dcc[i].nick)) &&
         (dcc[i].type->flags & DCT_SIMUL)) {
	set_prefix(SLDCCPREFIX);
        dprintf(i, "%s%s%s\n", reply_prefix, SLRBOTSAYS, reply);
        break;
      }
    }
  } else
    debug1("Couldn't send received bns answer, no such chan %s", chan);
  nfree(bnsnick);
  nfree(bnschan);
  bnsnick = bnschan = NULL;
  return 0;
}
Exemple #12
0
	void Execute(CommandSource &source, const std::vector<Anope::string> &params)
	{
		const Anope::string &chan = params[0];

		User *u = source.u;
		Channel *c = findchan(chan);

		if (!c)
		{
			source.Reply(CHAN_X_NOT_IN_USE, chan.c_str());
			return;
		}

		ChannelInfo *ci = c->ci;
		if (!ci)
		{
			source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
			return;
		}

		if (!ci->AccessFor(u).HasPriv("INVITE") && !u->HasCommand("chanserv/invite"))
		{
			source.Reply(ACCESS_DENIED);
			return;
		}

		User *u2;
		if (params.size() == 1)
			u2 = u;
		else
		{
			if (!(u2 = finduser(params[1])))
			{
				source.Reply(NICK_X_NOT_IN_USE, params[1].c_str());
				return;
			}
		}

		if (c->FindUser(u2))
		{
			if (u2 == u)
				source.Reply(_("You are already in \002%s\002!"), c->name.c_str());
			else
				source.Reply(_("\002%s\002 is already in \002%s\002!"), u2->nick.c_str(), c->name.c_str());
		}
		else
		{
			bool override = !ci->AccessFor(u).HasPriv("INVITE");

			ircdproto->SendInvite(ci->WhoSends(), chan, u2->nick);
			if (u2 != u)
			{
				source.Reply(_("\002%s\002 has been invited to \002%s\002."), u2->nick.c_str(), c->name.c_str());
				Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << u2->nick;
			}
			else
			{
Exemple #13
0
void asuka_cmd_mode(char *source, char *dest, char *buf)
{
    Channel *c;
    alog(LOG_PROTOCOL, "MODE Source %s, dest %s, buf %s", source, dest,
         buf);
    if ((c = findchan(dest)))
        send_cmd(p10id, "M %s %s %ld", dest, buf, (long int) c->creation_time);
    else
        send_cmd(p10id, "M %s %s", dest, buf);
}
Exemple #14
0
void alog(int type, const char *fmt, ...)
{
    va_list args;
    int errno_save = errno;
    char str[BUFSIZE];
    char *buf;
    *str = '\0';

    if (!fmt) {
        return;
    }

    if ((type == LOG_DEBUG || type == LOG_EXTRADEBUG
         || type == LOG_NONEXISTANT) && !denora->debug) {
        return;
    }
    if ((type == LOG_PROTOCOL) && !denora->protocoldebug) {
        return;
    }
    if (type == LOG_SQLDEBUG && !denora->sqldebug) {
        return;
    }
    if (LOG_EXTRADEBUG == type && denora->debug <= 1) {
        return;
    }
    if ((type == LOG_DEBUGSOCK || type == LOG_ADNS)
        && !denora->socketdebug) {
        return;
    }

    checkday();

    va_start(args, fmt);
    ircvsnprintf(str, sizeof(str), fmt, args);
    va_end(args);

    buf = log_gettimestamp();

    if (!NoLogs && logfile) {
        fprintf(logfile, "%s %s\n", buf, str);
    }

    if (denora->nofork) {
        fprintf(stderr, "%s %s\n", buf, str);
    }

    if (!BadPtr(LogChannel) && denora->debug < 2 && findchan(LogChannel)) {
        if (type == LOG_NORMAL || type == LOG_NONEXISTANT
            || type == LOG_ERROR) {
            privmsg(s_StatServ, LogChannel, "%s", str);
        }
    }
    errno = errno_save;
}
Exemple #15
0
void inspircd_cmd_mode(char *source, char *dest, char *buf)
{
    Channel *c;
    if (!buf) {
        return;
    }

    c = findchan(dest);
    send_cmd(source ? source : s_StatServ, "FMODE %s %u %s", dest,
             (unsigned int) ((c) ? c->creation_time : time(NULL)), buf);
}
Exemple #16
0
static int do_deowner(User * u)
{
    char *av[2];
    char *chan = strtok(NULL, " ");

    Channel *c;
    ChannelInfo *ci;
    struct u_chanlist *uc;

    if (!ircd->owner) {
        return MOD_CONT;
    }

    if (!chan) {
        av[0] = sstrdup(ircd->ownerunset);
        av[1] = GET_USER(u);

        /* Sets the mode to the user on every channels he is on. */

        for (uc = u->chans; uc; uc = uc->next) {
            if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
                && is_founder(u, ci)) {
                anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
                               av[0], GET_USER(u));
                chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
            }
        }

        free(av[0]);
        return MOD_CONT;
    }

    if (!(c = findchan(chan))) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (!(ci = c->ci)) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, c->name);
    } else if (ci->flags & CI_VERBOTEN) {
        notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
    } else if (!is_founder(u, ci)) {
        notice_lang(s_ChanServ, u, ACCESS_DENIED);
    } else if (!is_on_chan(c, u)) {
        notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u->nick, c->name);
    } else {
        anope_cmd_mode(whosends(ci), c->name, "%s %s", ircd->ownerunset,
                       GET_USER(u));

        av[0] = sstrdup(ircd->ownerunset);
        av[1] = GET_USER(u);
        chan_set_modes(s_ChanServ, c, 2, av, 1);
        free(av[0]);
    }
    return MOD_CONT;
}
Exemple #17
0
/* chan is created if not exists */
int db_getchancreate(char *chan)
{
    int res = -1;
    Channel *c;
    char *channel;
#ifdef USE_MYSQL
    MYSQL_RES *mysql_res;
#endif

    SET_SEGV_LOCATION();
    strtolwr(chan);

    c = findchan(chan);

    if (c) {
        if (c->sqlid) {
            return c->sqlid;
        } else {
            channel = sstrdup(c->sqlchan);
        }
    } else {
        channel = rdb_escape(chan);
    }


    if (!denora->do_sql) {
        return -1;
    }
    strtolwr(channel);
    rdb_query(QUERY_HIGH, "SELECT chanid FROM %s WHERE channel=\'%s\'",
              ChanTable, channel);
#ifdef USE_MYSQL
    mysql_res = mysql_store_result(mysql);
    if (mysql_res) {
        if (mysql_num_rows(mysql_res))
            res = atoi(*mysql_fetch_row(mysql_res));
        mysql_free_result(mysql_res);
    }
#endif
    SET_SEGV_LOCATION();
    if (res == -1) {
        rdb_query(QUERY_HIGH, "INSERT INTO %s (channel) VALUES (\'%s\')",
                  ChanTable, channel);
        res = rdb_insertid();
    }
    SET_SEGV_LOCATION();
    if (c && res) {
        c->sqlid = res;
    }
    free(channel);
    return res;
}
Exemple #18
0
/* PUB `seen' trigger. */
static int pub_seen(char *nick, char *host, char *hand,
		    char *channel, char *text)
{
  char prefix[50];
  struct chanset_t *chan = findchan(channel);

  Context;
  if ((chan != NULL) && channel_seen(chan)) {
    sprintf(prefix, "PRIVMSG %s :", channel);
    do_seen(DP_HELP, prefix, nick, hand, channel, text);
  }
  return 0;
}
Exemple #19
0
/**
 * The suspend command.
 * @param u The user who issued the command
 * @param ci The channel we will be suspending.
 * @param reason The reason given for suspending the channel.
 * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
 **/
int do_suspend(User * u, ChannelInfo *ci, char *reason) {
	Channel *c;

	if (!ci) {
		moduleNoticeLang(ci->bi->nick, u, LANG_SUSPEND_SYNTAX);
		return MOD_CONT;
	}

	if (ForceForbidReason && !reason) {
		moduleNoticeLang(ci->bi->nick, u, LANG_SUSPEND_NO_REASON);
		return MOD_CONT;
	}

	if (readonly) {
		notice_lang(ci->bi->nick, u, READ_ONLY_MODE);
		return MOD_CONT;
	}

	ci->flags |= CI_SUSPENDED;
	ci->forbidby = sstrdup(u->nick);
	if (reason)
		ci->forbidreason = sstrdup(reason);

	if ((c = findchan(ci->name))) {
		struct c_userlist *cu, *next;
		char *av[3];

		for (cu = c->users; cu; cu = next) {
			next = cu->next;

			if (is_oper(cu->user))
				continue;

			av[0] = c->name;
			av[1] = cu->user->nick;
			av[2] = reason ? reason : "CHAN_SUSPEND_REASON";
			xanadu_cmd_kick(ci->bi->nick, av[0], av[1], av[2]);
			do_kick(ci->bi->nick, 3, av);
		}
	}

	if (WallForbid)
		xanadu_cmd_global(ci->bi->nick, "\2%s\2 used SUSPEND on channel \2%s\2",
				u->nick, ci->name);

	alog("%s: %s set SUSPEND for channel %s", ci->bi->nick, u->nick, ci->name);
	notice_lang(ci->bi->nick, u, CHAN_SUSPEND_SUCCEEDED, ci->name);
	send_event(EVENT_CHAN_SUSPENDED, 1, ci->name);

	return MOD_CONT;
}
Exemple #20
0
	void DoChannel(XMLRPCServiceInterface *iface, XMLRPCClientSocket *source, XMLRPCRequest *request)
	{
		if (request->data.empty())
			return;

		Channel *c = findchan(request->data[0]);

		request->reply("name", iface->Sanitize(c ? c->name : request->data[0]));

		if (c)
		{
			request->reply("bancount", stringify(c->HasMode(CMODE_BAN)));
			int count = 0;
			std::pair<Channel::ModeList::iterator, Channel::ModeList::iterator> its = c->GetModeList(CMODE_BAN);
			for (; its.first != its.second; ++its.first)
				request->reply("ban" + stringify(++count), iface->Sanitize(its.first->second));

			request->reply("exceptcount", stringify(c->HasMode(CMODE_EXCEPT)));
			count = 0;
			its = c->GetModeList(CMODE_EXCEPT);
			for (; its.first != its.second; ++its.first)
				request->reply("except" + stringify(++count), iface->Sanitize(its.first->second));

			request->reply("invitecount", stringify(c->HasMode(CMODE_INVITEOVERRIDE)));
			count = 0;
			its = c->GetModeList(CMODE_INVITEOVERRIDE);
			for (; its.first != its.second; ++its.first)
				request->reply("invite" + stringify(++count), iface->Sanitize(its.first->second));

			Anope::string users;
			for (CUserList::const_iterator it = c->users.begin(); it != c->users.end(); ++it)
			{
				UserContainer *uc = *it;
				users += uc->Status->BuildModePrefixList() + uc->user->nick + " ";
			}
			if (!users.empty())
			{
				users.erase(users.length() - 1);
				request->reply("users", iface->Sanitize(users));
			}

			if (!c->topic.empty())
				request->reply("topic", iface->Sanitize(c->topic));

			if (!c->topic_setter.empty())
				request->reply("topicsetter", iface->Sanitize(c->topic_setter));

			request->reply("topictime", stringify(c->topic_time));
		}
	}
Exemple #21
0
void set_user_flagrec(struct userrec *u, struct flag_record *fr,
		      char *chname)
{
  struct chanuserrec *cr = NULL;
  int oldflags = fr->match;
  char buffer[100];
  struct chanset_t *ch;

  if (!u)
    return;
  if (oldflags & FR_GLOBAL) {
    u->flags = fr->global;

    u->flags_udef = fr->udef_global;
    if (!noshare && !(u->flags & USER_UNSHARED)) {
      fr->match = FR_GLOBAL;
      build_flags(buffer, fr, NULL);
      shareout(NULL, "a %s %s\n", u->handle, buffer);
    }
  }
  if ((oldflags & FR_BOT) && (u->flags & USER_BOT))
    set_user(&USERENTRY_BOTFL, u, (void *) fr->bot);
  /* dont share bot attrs */
  if ((oldflags & FR_CHAN) && chname) {
    for (cr = u->chanrec; cr; cr = cr->next)
      if (!rfc_casecmp(chname, cr->channel))
	break;
    ch = findchan(chname);
    if (!cr && ch) {
      cr = user_malloc(sizeof(struct chanuserrec));
      bzero(cr, sizeof(struct chanuserrec));

      cr->next = u->chanrec;
      u->chanrec = cr;
      strncpy(cr->channel, chname, 80);
      cr->channel[80] = 0;
    }
    if (cr && ch) {
      cr->flags = fr->chan;
      cr->flags_udef = fr->udef_chan;
      if (!noshare && !(u->flags & USER_UNSHARED) && channel_shared(ch)) {
	fr->match = FR_CHAN;
	build_flags(buffer, fr, NULL);
	shareout(ch, "a %s %s %s\n", u->handle, buffer, chname);
      }
    }
  }
  fr->match = oldflags;
}
Exemple #22
0
static int do_userlist(User * u)
{
    char *pattern = strtok(NULL, " ");
    char *opt = strtok(NULL, " ");

    Channel *c;
    int modes = 0;

    if (opt && !stricmp(opt, "INVISIBLE"))
        modes |= anope_get_invis_mode();

    if (pattern && (c = findchan(pattern))) {
        struct c_userlist *cu;

        notice_lang(s_OperServ, u, OPER_USERLIST_HEADER_CHAN, pattern);

        for (cu = c->users; cu; cu = cu->next) {
            if (modes && !(cu->user->mode & modes))
                continue;
            notice_lang(s_OperServ, u, OPER_USERLIST_RECORD,
                        cu->user->nick, common_get_vident(cu->user),
                        common_get_vhost(cu->user));
        }
    } else {
        char mask[BUFSIZE];
        int i;
        User *u2;

        notice_lang(s_OperServ, u, OPER_USERLIST_HEADER);

        for (i = 0; i < 1024; i++) {
            for (u2 = userlist[i]; u2; u2 = u2->next) {
                if (pattern) {
                    snprintf(mask, sizeof(mask), "%s!%s@%s", u2->nick,
                             common_get_vident(u2), common_get_vhost(u2));
                    if (!match_wild_nocase(pattern, mask))
                        continue;
                    if (modes && !(u2->mode & modes))
                        continue;
                }
                notice_lang(s_OperServ, u, OPER_USERLIST_RECORD, u2->nick,
                            common_get_vident(u2), common_get_vhost(u2));
            }
        }
    }

    notice_lang(s_OperServ, u, OPER_USERLIST_END);
    return MOD_CONT;
}
Exemple #23
0
static int my_cs_enforce(User * u)
{
    char *cur_buffer;
    char *chan=NULL;
    char *what=NULL;
    Channel *c;
    ChannelInfo *ci;

    cur_buffer = moduleGetLastBuffer();
    chan = myStrGetToken(cur_buffer, ' ', 0);

    if (!chan) {
        moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX);
    } else if (!(c = findchan(chan))) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_IN_USE, chan);
    } else if (!(ci = c->ci)) {
        notice_lang(s_ChanServ, u, CHAN_X_NOT_REGISTERED, chan);
    } else if (ci->flags & CI_VERBOTEN) {
        notice_lang(s_ChanServ, u, CHAN_X_FORBIDDEN, ci->name);
    } else if (!is_services_admin(u) && !check_access(u, ci, CA_AKICK)) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else {
        what = myStrGetToken(cur_buffer, ' ', 1);
        if (!what || (stricmp(what, "SET") == 0)) {
            do_enforce_set(c);
            moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE, what ? what : "SET");
        } else if (stricmp(what, "MODES") == 0) {
            do_enforce_modes(c);
            moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what);
        } else if (stricmp(what, "SECUREOPS") == 0) {
            do_enforce_secureops(c);
            moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what);
        } else if (stricmp(what, "RESTRICTED") == 0) {
            do_enforce_restricted(c);
            moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what);
        } else if (stricmp(what, "+R") == 0) {
            do_enforce_cmode_R(c);
            moduleNoticeLang(s_ChanServ,u,LNG_CHAN_RESPONSE,what);
        } else {
            moduleNoticeLang(s_ChanServ, u, LNG_ENFORCE_SYNTAX);
        }
    }

    if(chan) free(chan);
    if(what) free(what);

    return MOD_CONT;
}
Exemple #24
0
/*
 * :irc.mynet.org FMODE #opers 115432135 +bb *[email protected] *[email protected]
 * :<source server or nickname> FMODE <target> <timestamp> <modes and parameters>
 */
int denora_event_fmode(char *source, int ac, char **av)
{
    char *newav[127];
    int i = 0;
    Channel *c;

    if (denora->protocoldebug) {
        protocol_debug(source, ac, av);
    }

    if (ac < 3)
        return MOD_CONT;

    /* Checking the TS for validity to avoid desyncs */
    c = findchan(av[0]);
    if (c) {
        if (c->creation_time > strtol(av[1], NULL, 10)) {
            alog(LOG_DEBUG,
                 "DEBUG: av[1] %d < c->creation_time %d, c->creation_time lowered to %d",
                 av[1], c->creation_time, av[1]);
            c->creation_time = strtol(av[1], NULL, 10);
        } else if (c->creation_time < strtol(av[1], NULL, 10)) {
            alog(LOG_DEBUG,
                 "DEBUG: av[1] %d > c->creation_time %d, FMODE ignored.",
                 av[1], c->creation_time);
            return MOD_CONT;
        }
    } else {
        alog(LOG_DEBUG, "DEBUG: got FMODE for non-existing channel %s",
             av[0]);
        return MOD_CONT;
    }

    /* We need to remove the timestamp, which is av[1] */
    newav[0] = av[0];
    newav[1] = av[2];
    for (i = 2; i < (ac - 1); i++) {
        newav[i] = av[i + 1];
    }

    if (*newav[0] == '#' || *newav[0] == '&') {
        do_cmode(source, (ac - 1), newav);
    } else {
        do_umode(source, (ac - 1), newav);
    }

    return MOD_CONT;
}
Exemple #25
0
	bool OnTopic(const Anope::string &, const std::vector<Anope::string> &params)
	{
		if (params.size() < 4)
			return true;

		Channel *c = findchan(params[0]);
		if (!c)
		{
			Log() << "TOPIC for nonexistant channel " << params[0];
			return true;
		}

		c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime);

		return true;
	}
Exemple #26
0
static void mns_chan(int idx, char *par, char *bot)
{
  char *chname = NULL, buf2[1024] = "";
  struct chanset_t *chan = NULL;
  int i;

  if (!bot)
    putlog(LOG_CMDS, "*", "#%s# -chan %s", dcc[idx].nick, par);

  if (!par[0]) {
    dprintf(idx, "Usage: -chan [%s]<channel>\n", CHANMETA);
    return;
  }
  chname = newsplit(&par);

  simple_snprintf(buf2, sizeof(buf2), "cpart %s %s", chname, bot ? bot : "*");
  if (bot)		/* bot will just set it +inactive */
    putbot(bot, buf2);
  else
    putallbots(buf2);

  chan = findchan_by_dname(chname);
  if (!chan) {
    if ((chan = findchan(chname)))
      dprintf(idx, "That channel exists with a short name of %s, use that.\n", chan->dname);
    else
      dprintf(idx, "That channel doesn't exist!\n");
    return;
  }

  if (!bot) {
    for (i = 0; i < dcc_total; i++) {
      if (dcc[i].type && (dcc[i].type->flags & DCT_CHAT) && 
          !rfc_casecmp(dcc[i].u.chat->con_chan, chan->dname)) {
        dprintf(i, "%s is no longer a valid channel, changing your console to '*'\n", chname);
        strlcpy(dcc[i].u.chat->con_chan, "*", 2);
        console_dostore(i, 0);
      }
    }
    remove_channel(chan);
    if (conf.bot->hub)
      write_userfile(idx);
    dprintf(idx, "Channel %s removed from the botnet.\n", chname);
    dprintf(idx, "This includes any channel specific bans, invites, exemptions and user records that you set.\n");
  } else
    dprintf(idx, "Channel %s removed from the bot: %s\n", chname, bot);
}
Exemple #27
0
void get_user_flagrec(struct userrec *u, struct flag_record *fr,
		      char *chname)
{
  struct chanuserrec *cr = NULL;

  if (!u) {
    fr->global = fr->udef_global = fr->chan = fr->udef_chan = fr->bot = 0;

    return;
  }
  if (fr->match & FR_GLOBAL) {
    fr->global = u->flags;

    fr->udef_global = u->flags_udef;
  } else {
    fr->global = 0;

    fr->udef_global = 0;
  }
  if (fr->match & FR_BOT) {
    fr->bot = (long) get_user(&USERENTRY_BOTFL, u);
  } else
    fr->bot = 0;
  if (fr->match & FR_CHAN) {
    if (fr->match & FR_ANYWH) {
      fr->chan = u->flags;
      fr->udef_chan = u->flags_udef;
      for (cr = u->chanrec; cr; cr = cr->next)
	if (findchan(cr->channel)) {
	  fr->chan |= cr->flags;
	  fr->udef_chan |= cr->flags_udef;
	}
    } else {
      if (chname)
	for (cr = u->chanrec; cr; cr = cr->next)
	  if (!rfc_casecmp(chname, cr->channel))
	    break;
      if (chname && cr) {
	fr->chan = cr->flags;
	fr->udef_chan = cr->flags_udef;
      } else {
	fr->chan = 0;
	fr->udef_chan = 0;
      }
    }
  }
}
Exemple #28
0
static void do_os_mode(User * u)
{
	int argc;
	char **argv;
	char *chan, *modes, *s;
	Channel *c;

	s = strtok(NULL, "");

	if (!s) {
		syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
		return;
	}
	
	chan = s;
	s += strcspn(s, " ");

	if (!*s) {
		syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
		return;
	}

	*s = 0;
	modes = (s + 1) + strspn(s + 1, " ");

	if (!*modes) {
		syntax_error(s_OperServ, u, "MODE", OPER_MODE_SYNTAX);
		return;
	}

	if (!(c = findchan(chan))) {
		notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, chan);
	} else if (c->bouncy_modes) {
		notice_lang(s_OperServ, u, OPER_BOUNCY_MODES_U_LINE);
		return;
	} else {
		send_cmd(s_OperServ, "MODE %s %s", chan, modes);
		if (WallOSMode) {
			wallops(s_OperServ, "%s used MODE %s on %s",
			    u->nick, modes, chan);
		}

		*s = ' ';
		argc = split_buf(chan, &argv, 1);
		do_cmode(s_OperServ, argc, argv);
	}
}
Exemple #29
0
int
anope_event_topic (char *source, int ac, char **av)
{
  if (ac == 4)
    {
      do_topic (source, ac, av);
    }
  else
    {
      Channel *c = findchan (av[0]);
      time_t topic_time = time (NULL);

      if (!c)
	{
	  if (debug)
	    {
	      alog ("debug: TOPIC %s for nonexistent channel %s",
		    merge_args (ac - 1, av + 1), av[0]);
	    }
	  return MOD_CONT;
	}

      if (check_topiclock (c, topic_time))
	return MOD_CONT;

      if (c->topic)
	{
	  free (c->topic);
	  c->topic = NULL;
	}
      if (ac > 1 && *av[1])
	c->topic = sstrdup (av[1]);

      strscpy (c->topic_setter, source, sizeof (c->topic_setter));
      c->topic_time = topic_time;

      record_topic (av[0]);
	  
	  if (ac > 1 && *av[1])
	      send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]);
	  else
	      send_event(EVENT_TOPIC_UPDATED, 2, av[0], "");
			  
    }
  return MOD_CONT;
}
Exemple #30
0
static int delBan(int argc, char **argv)
{
    char *av[3];
    Channel *c;

    av[0] = sstrdup("-b");
    av[1] = argv[1];

    if ((c = findchan(argv[0])) && c->ci) {
        anope_cmd_mode(whosends(c->ci), c->name, "-b %s", av[1]);
        chan_set_modes(s_ChanServ, c, 2, av, 1);
    }

    free(av[0]);

    return MOD_CONT;
}