Пример #1
0
void Field::check_access_by(InstanceClass* sender_class,
                            InstanceClass* static_receiver_class,
                            FailureMode fail_mode JVM_TRAPS) {
  InstanceClass* field_class = ic();
  if (is_public()) {
    return;
  }
  if (field_class->equals(sender_class)) {
    return;
  }
  if (!is_private()) {
    if (field_class->is_same_class_package(sender_class)) {
      return;
    }
    if (is_protected()) {
      if (sender_class->is_subclass_of(field_class)) {
        if (static_receiver_class->equals(sender_class) || 
            static_receiver_class->is_subclass_of(sender_class) || 
            sender_class->is_subclass_of(static_receiver_class)) {
          return;
        }
      }
    }
  }
  Throw::illegal_access(fail_mode JVM_NO_CHECK_AT_BOTTOM);
}
Пример #2
0
/**
 * Handle kickban/kb fantasy commands.
 * @param argc Argument count
 * @param argv Argument list
 * @return MOD_CONT or MOD_STOP
 **/
int do_fantasy(int argc, char **argv)
{
    User *u, *u2;
    ChannelInfo *ci;
    char *target = NULL;
    char *reason = NULL;

    if (argc < 3)
        return MOD_CONT;

    if ((stricmp(argv[0], "kickban") == 0)
        || (stricmp(argv[0], "kb") == 0)) {
        u = finduser(argv[1]);
        ci = cs_findchan(argv[2]);
        if (!u || !ci)
            return MOD_CONT;

        if (argc >= 4) {
            target = myStrGetToken(argv[3], ' ', 0);
            reason = myStrGetTokenRemainder(argv[3], ' ', 1);
        }
        if (!target && check_access(u, ci, CA_BANME)) {
            bot_raw_ban(u, ci, u->nick, "Requested");
        } else if (target && check_access(u, ci, CA_BAN)) {
            if (stricmp(target, ci->bi->nick) == 0) {
                bot_raw_ban(u, ci, u->nick, "Oops!");
            } else {
                u2 = finduser(target);
                if (u2 && ci->c && is_on_chan(ci->c, u2)) {
                    if (!reason && !is_protected(u2))
                        bot_raw_ban(u, ci, target, "Requested");
                    else if (!is_protected(u2))
                        bot_raw_ban(u, ci, target, reason);
                }
            }
        }
    }

    if (target)
       free(target);
    if (reason)
       free(reason);

    return MOD_CONT;
}
Пример #3
0
int dfs_rename(const char *from, const char *to)
{
  TRACE1("rename", from) 

 // retrieve dfs specific data
  dfs_context *dfs = (dfs_context*)fuse_get_context()->private_data;

  // check params and the context var
  assert(from);
  assert(to);
  assert(dfs);

  assert('/' == *from);
  assert('/' == *to);

  if (is_protected(from) || is_protected(to)) {
    syslog(LOG_ERR,"ERROR: hdfs trying to rename: %s %s", from, to);
    return -EACCES;
  }

  if (dfs->read_only) {
    syslog(LOG_ERR,"ERROR: hdfs is configured as read-only, cannot rename the directory %s\n",from);
    return -EACCES;
  }

  hdfsFS userFS;
  // if not connected, try to connect and fail out if we can't.
  if ((userFS = doConnectAsUser(dfs->nn_hostname,dfs->nn_port))== NULL) {
    syslog(LOG_ERR, "ERROR: could not connect to dfs %s:%d\n", __FILE__, __LINE__);
    return -EIO;
  }

  if (hdfsRename(userFS, from, to)) {
    syslog(LOG_ERR,"ERROR: hdfs trying to rename %s to %s",from, to);
    return -EIO;
  }

  return 0;

}
Пример #4
0
int dfs_rmdir(const char *path)
{
  struct hdfsConn *conn = NULL;
  hdfsFS fs;
  int ret;
  dfs_context *dfs = (dfs_context*)fuse_get_context()->private_data;
  int numEntries = 0;
  hdfsFileInfo *info = NULL;

  TRACE1("rmdir", path)

  assert(path);
  assert(dfs);
  assert('/' == *path);

  if (is_protected(path)) {
    ERROR("Trying to delete protected directory %s", path);
    ret = -EACCES;
    goto cleanup;
  }

  ret = fuseConnectAsThreadUid(&conn);
  if (ret) {
    fprintf(stderr, "fuseConnectAsThreadUid: failed to open a libhdfs "
            "connection!  error %d.\n", ret);
    ret = -EIO;
    goto cleanup;
  }
  fs = hdfsConnGetFs(conn);
  info = hdfsListDirectory(fs, path, &numEntries);
  if (numEntries) {
    ret = -ENOTEMPTY;
    goto cleanup;
  }

  if (hdfsDeleteWithTrash(fs, path, dfs->usetrash)) {
    ERROR("Error trying to delete directory %s", path);
    ret = -EIO;
    goto cleanup;
  }
  ret = 0;

cleanup:
  if (info) {
    hdfsFreeFileInfo(info, numEntries);
  }
  if (conn) {
    hdfsConnRelease(conn);
  }
  return ret;
}
Пример #5
0
    // @Override
    virtual void debug_print(int indent) override {
        print_space(indent);

        if (is_public())
            printf("public ");
        else if (is_protected())
            printf("protected ");
        else if (is_private())
            printf("private ");

        if (is_static())
            printf("static ");
        if (is_final())
            printf("final ");
    }
Пример #6
0
void AccessFlags::print_on(outputStream* st) const {
  if (is_public      ()) st->print("public "      );
  if (is_private     ()) st->print("private "     );
  if (is_protected   ()) st->print("protected "   );
  if (is_static      ()) st->print("static "      );
  if (is_final       ()) st->print("final "       );
  if (is_synchronized()) st->print("synchronized ");
  if (is_volatile    ()) st->print("volatile "    );
  if (is_transient   ()) st->print("transient "   );
  if (is_native      ()) st->print("native "      );
  if (is_interface   ()) st->print("interface "   );
  if (is_abstract    ()) st->print("abstract "    );
  if (is_strict      ()) st->print("strict "      );
  if (is_synthetic   ()) st->print("synthetic "   );
  if (is_old         ()) st->print("{old} "       );
  if (is_obsolete    ()) st->print("{obsolete} "  );
}
Пример #7
0
int dfs_mkdir(const char *path, mode_t mode)
{
  TRACE1("mkdir", path)

  // retrieve dfs specific data
  dfs_context *dfs = (dfs_context*)fuse_get_context()->private_data;

  // check params and the context var
  assert(path);
  assert(dfs);
  assert('/' == *path);

  if (is_protected(path)) {
    syslog(LOG_ERR,"ERROR: hdfs trying to create the directory: %s", path);
    return -EACCES;
  }

  if (dfs->read_only) {
    syslog(LOG_ERR,"ERROR: hdfs is configured as read-only, cannot create the directory %s\n",path);
    return -EACCES;
  }
  
  hdfsFS userFS;
  // if not connected, try to connect and fail out if we can't.
  if ((userFS = doConnectAsUser(dfs->nn_hostname,dfs->nn_port))== NULL) {
    syslog(LOG_ERR, "ERROR: could not connect to dfs %s:%d\n", __FILE__, __LINE__);
    return -EIO;
  }

  // In theory the create and chmod should be atomic.

  if (hdfsCreateDirectory(userFS, path)) {
    syslog(LOG_ERR,"ERROR: hdfs trying to create directory %s",path);
    return -EIO;
  }

#if PERMS
  if (hdfsChmod(userFS, path, (short)mode)) {
    syslog(LOG_ERR,"ERROR: hdfs trying to chmod %s to %d",path, (int)mode);
    return -EIO;
  }
#endif
  return 0;

}
Пример #8
0
json serialize_decl(name const & d, environment const & env, options const & o) {
    // using namespace override resolution rule
    list<name> const & ns_list = get_namespaces(env);
    for (name const & ns : ns_list) {
        name new_d = d.replace_prefix(ns, name());
        if (new_d != d &&
            !new_d.is_anonymous() &&
            (!new_d.is_atomic() || !is_protected(env, d))) {
            return serialize_decl(new_d, d, env, o);
        }
    }
    // if the alias is unique use it
    if (auto it = is_uniquely_aliased(env, d)) {
        return serialize_decl(*it, d, env, o);
    } else {
        return serialize_decl(d, d, env, o);
    }
}
Пример #9
0
static int canBanUser(Channel * c, User * u, User * u2)
{
    ChannelInfo *ci;
    int ok = 0;
    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, c->name);
    } else if (!check_access(u, ci, CA_BAN)) {
        notice_lang(s_ChanServ, u, ACCESS_DENIED);
    } else if (ircd->except && is_excepted(ci, u2)) {
        notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name);
    } else if (ircd->protectedumode && is_protected(u2)) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else {
        ok = 1;
    }

    return ok;
}
Пример #10
0
int dfs_unlink(const char *path)
{
  TRACE1("unlink", path)

  // retrieve dfs specific data
  dfs_context *dfs = (dfs_context*)fuse_get_context()->private_data;

  // check params and the context var
  assert(path);
  assert(dfs);
  assert('/' == *path);

  if (is_protected(path)) {
    syslog(LOG_ERR,"ERROR: hdfs trying to delete a protected directory: %s ",path);
    return -EACCES;
  }

  if (dfs->read_only) {
    syslog(LOG_ERR,"ERROR: hdfs is configured as read-only, cannot create the directory %s\n",path);
    return -EACCES;
  }

  hdfsFS userFS;
  // if not connected, try to connect and fail out if we can't.
  if ((userFS = doConnectAsUser(dfs->nn_hostname,dfs->nn_port))== NULL) {
    syslog(LOG_ERR, "ERROR: could not connect to dfs %s:%d\n", __FILE__, __LINE__);
    return -EIO;
  }


  if (hdfsDeleteWithTrash(userFS, path, dfs->usetrash)) {
    syslog(LOG_ERR,"ERROR: hdfs trying to delete the file %s",path);
    return -EIO;
  }

  return 0;

}
Пример #11
0
// ------------------------------------------------------------------
// ciFlags::print_member_flags
void ciFlags::print_member_flags(outputStream* st) {
  if (is_public()) {
    st->print("public");
  } else if (is_private()) {
    st->print("private");
  } else if (is_protected()) {
    st->print("protected");
  } else {
    st->print("DEFAULT_ACCESS");
  }

  if (is_static()) {
    st->print(",static");
  }
  if (is_final()) {
    st->print(",final");
  }
  if (is_synchronized()) {
    st->print(",synchronized");
  }
  if (is_volatile()) {
    st->print(",volatile");
  }
  if (is_transient()) {
    st->print(",transient");
  }
  if (is_native()) {
    st->print(",native");
  }
  if (is_abstract()) {
    st->print(",abstract");
  }
  if (is_strict()) {
    st->print(",strict");
  }

}
Пример #12
0
static int do_util(User * u, CSModeUtil * util)
{
    char *av[2];
    char *chan = strtok(NULL, " ");
    char *nick = strtok(NULL, " ");

    Channel *c;
    ChannelInfo *ci;
    User *u2;

    int is_same;

    if (!chan) {
        struct u_chanlist *uc;

        av[0] = util->mode;
        av[1] = u->nick;

        /* 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)
                && check_access(u, ci, util->levelself)) {
                anope_cmd_mode(whosends(ci), uc->chan->name, "%s %s",
                               util->mode, GET_USER(u));
                chan_set_modes(s_ChanServ, uc->chan, 2, av, 2);

                if (util->notice && ci->flags & util->notice)
                    notice(whosends(ci), uc->chan->name,
                           "%s command used for %s by %s", util->name,
                           u->nick, u->nick);
            }
        }

        return MOD_CONT;
    } else if (!nick) {
        nick = u->nick;
    }

    is_same = (nick == u->nick) ? 1 : (stricmp(nick, u->nick) == 0);

    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_same ? !(u2 = u) : !(u2 = finduser(nick))) {
        notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, nick);
    } else if (is_same ? !check_access(u, ci, util->levelself) :
               !check_access(u, ci, util->level)) {
        notice_lang(s_ChanServ, u, ACCESS_DENIED);
    } else if (*util->mode == '-' && !is_same && (ci->flags & CI_PEACE)
               && (get_access(u2, ci) >= get_access(u, ci))) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else if (*util->mode == '-' && is_protected(u2) && !is_same) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else if (!is_on_chan(c, u2)) {
        notice_lang(s_ChanServ, u, NICK_X_NOT_ON_CHAN, u2->nick, c->name);
    } else {
        anope_cmd_mode(whosends(ci), c->name, "%s %s", util->mode,
                       GET_USER(u2));

        av[0] = util->mode;
        av[1] = GET_USER(u2);
        chan_set_modes(s_ChanServ, c, 2, av, 3);

        if (util->notice && ci->flags & util->notice)
            notice(whosends(ci), c->name, "%s command used for %s by %s",
                   util->name, u2->nick, u->nick);
    }
    return MOD_CONT;
}
Пример #13
0
/**
 * The /cs ban command.
 * @param u The user who issued the command
 * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing.
 **/
int do_ban(User * u)
{
    char *chan = strtok(NULL, " ");
    char *params = strtok(NULL, " ");
    char *reason = strtok(NULL, "");

    Channel *c;
    ChannelInfo *ci;
    User *u2;

    int is_same;

    if (!reason) {
        reason = "Requested";
    } else {
        if (strlen(reason) > 200)
            reason[200] = '\0';
    }

    if (!chan) {
        struct u_chanlist *uc, *next;

        /* Bans the user on every channels he is on. */

        for (uc = u->chans; uc; uc = next) {
            next = uc->next;
            if ((ci = uc->chan->ci) && !(ci->flags & CI_VERBOTEN)
                && check_access(u, ci, CA_BANME)) {
                char *av[3];
                char mask[BUFSIZE];

                /*
                 * Dont ban/kick the user on channels where he is excepted
                 * to prevent services <-> server wars.
                 */
                if (ircd->except) {
                    if (is_excepted(ci, u))
                        notice_lang(s_ChanServ, u, CHAN_EXCEPTED,
                                    u->nick, ci->name);
                    continue;
                }
                if (is_protected(u)) {
                    notice_lang(s_ChanServ, u, PERMISSION_DENIED);
                    continue;
                }

                av[0] = sstrdup("+b");
                get_idealban(ci, u, mask, sizeof(mask));
                av[1] = mask;
                xanadu_cmd_mode(whosends(ci), uc->chan->name, "+b %s",
                               av[1]);
                chan_set_modes(s_ChanServ, uc->chan, 2, av, 1);
                free(av[0]);

                if ((ci->flags & CI_SIGNKICK)
                    || ((ci->flags & CI_SIGNKICK_LEVEL)
                        && !check_access(u, ci, CA_SIGNKICK)))
                    xanadu_cmd_kick(whosends(ci), ci->name, u->nick,
                                   "%s (%s)", reason, u->nick);
                else
                    xanadu_cmd_kick(whosends(ci), ci->name, u->nick, "%s",
                                   reason);
                av[0] = ci->name;
                av[1] = u->nick;
                av[2] = reason;
                do_kick(s_ChanServ, 3, av);
            }
        }

        return MOD_CONT;
    } else if (!params) {
        params = u->nick;
    }

    is_same = (params == u->nick) ? 1 : (stricmp(params, u->nick) == 0);

    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, chan);
    } else if (is_same ? !(u2 = u) : !(u2 = finduser(params))) {
        notice_lang(s_ChanServ, u, NICK_X_NOT_IN_USE, params);
    } else if (!is_same ? !check_access(u, ci, CA_BAN) :
               !check_access(u, ci, CA_BANME)) {
        notice_lang(s_ChanServ, u, ACCESS_DENIED);
    } else if (!is_same && (ci->flags & CI_PEACE)
               && (get_access(u2, ci) >= get_access(u, ci))) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
        /*
         * Dont ban/kick the user on channels where he is excepted
         * to prevent services <-> server wars.
         */
    } else if (ircd->except && is_excepted(ci, u2)) {
        notice_lang(s_ChanServ, u, CHAN_EXCEPTED, u2->nick, ci->name);
    } else if (ircd->protectedumode && is_protected(u2)) {
        notice_lang(s_ChanServ, u, PERMISSION_DENIED);
    } else {
        char *av[3];
        char mask[BUFSIZE];

        av[0] = sstrdup("+b");
        get_idealban(ci, u2, mask, sizeof(mask));
        av[1] = mask;
        xanadu_cmd_mode(whosends(ci), c->name, "+b %s", av[1]);
        chan_set_modes(s_ChanServ, c, 2, av, 1);
        free(av[0]);

        /* We still allow host banning while not allowing to kick */
        if (!is_on_chan(c, u2))
            return MOD_CONT;

        if ((ci->flags & CI_SIGNKICK)
            || ((ci->flags & CI_SIGNKICK_LEVEL)
                && !check_access(u, ci, CA_SIGNKICK)))
            xanadu_cmd_kick(whosends(ci), ci->name, params, "%s (%s)",
                           reason, u->nick);
        else
            xanadu_cmd_kick(whosends(ci), ci->name, params, "%s", reason);

        av[0] = ci->name;
        av[1] = params;
        av[2] = reason;
        do_kick(s_ChanServ, 3, av);
    }
    return MOD_CONT;
}
Пример #14
0
int fantasy_defkick(int argc, char **argv)
{
    User *u, *u2;
    ChannelInfo *ci;
    char *target = NULL;
    char *reason = NULL;

    if (argc < 3)
        return MOD_CONT;
    if (!stricmp(argv[0], "help")) 
    {
            u = finduser(argv[1]);
       		if (argc >= 4) 
            {
			   int ret = MOD_CONT;
			   char *cmd, *param;
			   cmd = myStrGetToken(argv[3],' ',0);
			   param = myStrGetToken(argv[3],' ',1);
			   if (!stricmp(cmd, "kickr")) 
               {
                  notice(s_BotServ, u->nick, "\037Syntax\037: \002!kickr [NICK] [TRIGGER]\002   or");
                  notice(s_BotServ, u->nick, "\037Syntax\037: \002!kr [NICK] [TRIGGER]\002");
                  notice(s_BotServ, u->nick, "(For example: !kr VisioN idling  or !kickr VisioN idling)");
                  notice(s_BotServ, u->nick, "\n");
                  notice(s_BotServ, u->nick, "----------------------------------------------------------------------------------------------------------");
                  notice(s_BotServ, u->nick, "\n");
                  notice(s_BotServ, u->nick, "\037Description\037: This command allows you to kick a user from a channel, using the bot's default kick reasons.");
                  notice(s_BotServ, u->nick, "The bot supports multipule kick reasons for each of the basic abuses for channels, a list of which");
                  notice(s_BotServ, u->nick, "you can find below.");
                  notice(s_BotServ, u->nick, "\n");
                  notice(s_BotServ, u->nick, "List of triggers:");
                  notice(s_BotServ, u->nick, "\037\002Name\002\037           \037\002Description\002\037");
                  notice(s_BotServ, u->nick, "badlang        Kicks for bad language (insults etc)");
                  notice(s_BotServ, u->nick, "caps             Kicks for capital letters ");
                  notice(s_BotServ, u->nick, "flood            Kicks for channel flooding ");
                  notice(s_BotServ, u->nick, "bold             Kicks for bold letters ");
                  notice(s_BotServ, u->nick, "advertise      Kicks for Spam/Advertising ");
                  notice(s_BotServ, u->nick, "repeat          Kicks for repetition ");
                  notice(s_BotServ, u->nick, "idle               Kicks for idling (mostly for help chans) ");
                  notice(s_BotServ, u->nick, "badnick        Kicks for bad nicknames ");
                  ret = MOD_CONT;
               }
			free(cmd);
			if (param) free(param);
			return ret;
            }
   }
   else if ((stricmp(argv[0], "kickr") == 0) || (stricmp(argv[0], "kr") == 0)) 
   {
        u = finduser(argv[1]);
        ci = cs_findchan(argv[2]);
        if (!u || !ci)
            return MOD_CONT;
        if (argc >= 4) 
        {
            target = myStrGetToken(argv[3], ' ', 0);
            reason = myStrGetTokenRemainder(argv[3], ' ', 1);
        }
        if (!check_access(u, ci, CA_KICK)) 
        {
            notice(s_BotServ, u->nick, "You are not authorised to kick the selected user.");
        }
        else if (!target && check_access(u, ci, CA_KICKME)) 
        {
            notice(s_BotServ, u->nick, "\037Syntax\037: \002!kickr [NICK] [TRIGGER]\002   or");
            notice(s_BotServ, u->nick, "\037Syntax\037: \002!kr [NICK] [TRIGGER]\002");
            notice(s_BotServ, u->nick, "For detailed information about this command and");
            notice(s_BotServ, u->nick, "for a list of triggers, type \002!help kickr\002");
        } 
        else if (target && check_access(u, ci, CA_KICK)) 
        {
            if (!stricmp(target, ci->bi->nick))
                bot_raw_kick(u, ci, u->nick, "Wrong Move!");
            else 
            {
                u2 = finduser(target);
                if (u2 && ci->c && is_on_chan(ci->c, u2)) 
                {   
                    if (!reason && !is_protected(u2))
                        bot_raw_kick(u, ci, target, "Requested");
                    else if (!is_protected(u2)) 
                    {
                         if ((stricmp(reason , "badlang") == 0))  
                            bot_raw_kick(u, ci, target, BADLANG);
			             else if ((stricmp(reason , "caps") == 0)) 
                              bot_raw_kick(u, ci, target, CAPS);
			             else if ((stricmp(reason , "flood") == 0)) 
				              bot_raw_kick(u, ci, target, FLOOD);
			             else if ((stricmp(reason , "bold") == 0))
				              bot_raw_kick(u, ci, target, BOLD);
                         else if ((stricmp(reason , "advertise") == 0)) 
				              bot_raw_kick(u, ci, target, ADVERTISE);
	                     else if ((stricmp(reason , "repeat") == 0)) 
				              bot_raw_kick(u, ci, target, REPEAT);
	                     else if ((stricmp(reason , "idle") == 0)) 
				              bot_raw_kick(u, ci, target, IDLE);
	                     else if ((stricmp(reason , "badnick") == 0)) 
				              bot_raw_kick(u, ci, target, BADNICK);

                     else     
                     {
                           notice(s_BotServ, u->nick, "The number you chose does not correspond to a kick reason.");
                           notice(s_BotServ, u->nick, "If you want to kick with your own custom reason , use !kick trigger");
                     }
                 }      
                    
              }
            }
        }
    }
    if (target) free(target);
    if (reason) free(reason);
    return MOD_CONT;
}
Пример #15
0
int do_core_kick(User * u, Channel *c, char *target, char *reason) {
	ChannelInfo *ci = c->ci;
	User *u2;
	int is_same, exists;

	if (!target)
		target = u->nick;

	is_same = (target == u->nick) ? 1 : (stricmp(target, u->nick) == 0);

	if (is_same) {
		u2 = u;
		exists = 1;
	} else
		exists = ((u2 = finduser(target)) ? 1 : 0);

	if (!is_same ? !check_access(u, ci, CA_KICK) : !check_access(u, ci, CA_KICKME)) {
		notice_lang(ci->bi->nick, u, ACCESS_DENIED);
	} else if (!is_same && exists && (ci->flags & CI_PEACE) && (get_access(u2, ci) >= get_access(u, ci))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	} else if (exists && ((ircd->protectedumode && is_protected(u2)) && !is_founder(u, ci))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	} else if (exists && RestrictKB && ((!is_founder(u, ci) && is_services_oper(u2)) ||
			(is_founder(u, ci) && is_services_admin(u2)))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	} else if (stricmp(target, ci->bi->nick) == 0) {
		bot_raw_kick(u, ci, u->nick, "Oops!");
	} else {
		if (exists) {
			if (is_on_chan(ci->c, u2)) {
				if (!reason)
					bot_raw_kick(u, ci, target, "Requested");
				else
					bot_raw_kick(u, ci, target, reason);
			}

		} else {
			char mask[BUFSIZE];
			struct c_userlist *cu = NULL, *next = NULL;

			if (my_match_wild_nocase("*!*@*", target))
				snprintf(mask, BUFSIZE, "%s", target);
			/* If we get a *@* target we need to add the *!... */
			else if (my_match_wild_nocase("*@*", target))
				snprintf(mask, BUFSIZE, "*!%s", target);
			else if (my_match_wild_nocase("*!*", target))
				snprintf(mask, BUFSIZE, "%s@*", target);
			/* If we get a * target we need to add the !*@* (assume nick)... */
			else
				snprintf(mask, BUFSIZE, "%s!*@*", target);

			cu = c->users;
			while (cu) {
				next = cu->next;
				/* This only checks against the cloacked host & vhost for normal users.
				 * IPs are only checked when triggered by an oper.. */
				if (is_oper(u) ? match_usermask_full(mask, cu->user, true) : match_usermask(mask, cu->user)) {
					/* Check whether we are allowed to kick this matching user.. */
					if (!((ircd->protectedumode && is_protected(cu->user) && !is_founder(u, ci))
							|| ((ci->flags & CI_PEACE) && (get_access(cu->user, ci) >= get_access(u, ci)))
							|| (RestrictKB && ((!is_founder(u, ci) && is_services_oper(cu->user)) ||
							(is_founder(u, ci) && is_services_admin(cu->user)))))) {
						if (!reason)
							bot_raw_kick(u, ci, cu->user->nick, "Requested");
						else
							bot_raw_kick(u, ci, cu->user->nick, reason);
					}
				}
				cu = next;
			}
		}
	}
	return MOD_CONT;
}
Пример #16
0
int do_core_kickban(User * u, Channel *c, char *target, char *reason) {
	ChannelInfo *ci = c->ci;
	User *u2;
	int is_same, exists;
	char *av[2];

	if (!target)
		target = u->nick;

	is_same = (target == u->nick) ? 1 : (stricmp(target, u->nick) == 0);

	if (is_same) {
		u2 = u;
		exists = 1;
	} else
		exists = ((u2 = finduser(target)) ? 1 : 0);

	if (!is_same ? !check_access(u, ci, CA_BAN) : !check_access(u, ci, CA_BANME)) {
		notice_lang(ci->bi->nick, u, ACCESS_DENIED);
	} else if (!is_same && exists && (ci->flags & CI_PEACE) && (get_access(u2, ci) >= get_access(u, ci))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	} else if (exists && ((ircd->protectedumode && is_protected(u2)) && !is_founder(u, ci))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	/**
	 * Dont ban the user on channels where he is excepted
	 * to prevent services <-> server wars.
	 **/
	} else if (exists && (ircd->except && is_excepted(ci, u2))) {
		notice_lang(ci->bi->nick, u, CHAN_EXCEPTED, u2->nick, ci->name);
	} else if (!exists && (ircd->except && is_excepted_mask(ci, target))) {
		notice_lang(ci->bi->nick, u, CHAN_EXCEPTED, target, ci->name);
	} else if (exists && RestrictKB && ((!is_founder(u, ci) && is_services_oper(u2)) ||
			(is_founder(u, ci) && is_services_admin(u2)))) {
		notice_lang(ci->bi->nick, u, PERMISSION_DENIED);
	} else if (stricmp(target, ci->bi->nick) == 0) {
		bot_raw_ban(u, ci, u->nick, "Oops!");
	} else {
		if (exists) {
			if (is_on_chan(ci->c, u2)) {
				if (!reason)
					bot_raw_ban(u, ci, target, "Requested");
				else
					bot_raw_ban(u, ci, target, reason);
			}

		} else if (my_match_wild_nocase("*@*", target)) {
			char mask[BUFSIZE];

			/* If we get a *@* target we need to add the *!... */
			if (!my_match_wild_nocase("*!*@*", target))
				snprintf(mask, BUFSIZE, "*!%s", target);
			else
				snprintf(mask, BUFSIZE, "%s", target);

			/* Only continue if the mask doesn't match an exception or is otherwise prohibited.. */
			if (check_banmask(u, c, mask)) {
				struct c_userlist *cu = NULL, *next = NULL;

				av[0] = "+b";
				av[1] = mask;

				anope_cmd_mode(ci->bi->nick, c->name, "+b %s", av[1]);
				chan_set_modes(ci->bi->nick, c, 2, av, 1);

				cu = c->users;
				while (cu) {
					next = cu->next;
					/* This only checks against the cloacked host & vhost for normal users.
					 * IPs are only checked when triggered by an oper.. */
					if (is_oper(u) ? match_usermask_full(mask, cu->user, true) : match_usermask(mask, cu->user)) {
						if (!reason)
							bot_raw_kick(u, ci, cu->user->nick, "Requested");
						else
							bot_raw_kick(u, ci, cu->user->nick, reason);
					}
					cu = next;
				}
			}
		} else
			noticeLang(ci->bi->nick, u, LANG_REQ_NICK_OR_MASK);
	}
	return MOD_CONT;
}