Пример #1
0
int flagrec_ok(struct flag_record *req, struct flag_record *have)
{
  /* FIXME: flag masks with '&' in them won't be subject to
   *        further tests below. Example: 'o&j'
   */
  if (req->match & FR_AND)
    return flagrec_eq(req, have);
  else if (req->match & FR_OR) {
    int hav = have->global;

    /* Exception 1 - global +d/+k cant use -|-, unless they are +p */
    if (!req->chan && !req->global && !req->udef_global && !req->udef_chan) {
      if (!allow_dk_cmds) {
        if (glob_party(*have))
          return 1;
        if (glob_kick(*have) || chan_kick(*have))
          return 0;             /* +k cant use -|- commands */
        if (glob_deop(*have) || chan_deop(*have))
          return 0;             /* neither can +d's */
      }
      return 1;
    }
    /* The +n/+m checks aren't needed anymore because +n/+m
     * automatically adds lower flags
     */
    if (!require_p && ((hav & USER_OP) || (have->chan & USER_OWNER)))
      hav |= USER_PARTY;
    if (hav & req->global)
      return 1;
    if (have->chan & req->chan)
      return 1;
    if (have->udef_global & req->udef_global)
      return 1;
    if (have->udef_chan & req->udef_chan)
      return 1;
    return 0;
  }
  return 0;                     /* fr0k3 binding, dont pass it */
}
Пример #2
0
int flagrec_ok(struct flag_record *req,
	       struct flag_record *have)
{
  if (req->match & FR_AND) {
    return flagrec_eq(req, have);
  } else if (req->match & FR_OR) {
    int hav = have->global;

    /* exception 1 - global +d/+k cant use -|-, unless they are +p */
    if (!req->chan && !req->global && !req->udef_global &&
	!req->udef_chan) {
      if (!allow_dk_cmds) {
	if (glob_party(*have))
	  return 1;
	if (glob_kick(*have) || chan_kick(*have))
	  return 0;		/* +k cant use -|- commands */
	if (glob_deop(*have) || chan_deop(*have))
	  return 0;		/* neither can +d's */
      }
      return 1;
    }
    /* the +n/+m checks arent needed anymore since +n/+m
     * automatically add lower flags */
    if (!require_p && ((hav & USER_OP) || (have->chan & USER_OWNER)))
      hav |= USER_PARTY;
    if (hav & req->global)
      return 1;
    if (have->chan & req->chan)
      return 1;
    if (have->udef_global & req->udef_global)
      return 1;
    if (have->udef_chan & req->udef_chan)
      return 1;
    return 0;
  }
  return 0;			/* fr0k3 binding, dont pass it */
}
Пример #3
0
/* this only handles CHAT requests, otherwise it's handled in filesys */
static int filesys_DCC_CHAT(char *nick, char *from, char *handle,
			    char *object, char *keyword, char *text)
{
  char *param, *ip, *prt, buf[512], *msg = buf;
  int i, sock;
  struct userrec *u = get_user_by_handle(userlist, handle);
  struct flag_record fr =
  {FR_GLOBAL | FR_CHAN | FR_ANYWH, 0, 0, 0, 0, 0};

  Context;
  if (!strncasecmp(text, "SEND ", 5)) {
    filesys_dcc_send(nick, from, u, text + 5);
    return 1;
  }
  if (strncasecmp(text, "CHAT ", 5) || !u)
    return 0;
  strcpy(buf, text + 5);
  get_user_flagrec(u, &fr, 0);
  param = newsplit(&msg);
  if (dcc_total == max_dcc) {
    putlog(LOG_MISC, "*", DCC_TOOMANYDCCS2, "CHAT(file)", param, nick, from);
  } else if (glob_party(fr) || (!require_p && chan_op(fr)))
    return 0;			/* allow ctcp.so to pick up the chat */
  else if (!glob_xfer(fr)) {
    if (!quiet_reject)
      dprintf(DP_HELP, "NOTICE %s :.\n", nick, DCC_REFUSED3);
    putlog(LOG_MISC, "*", "%s: %s!%s", DCC_REFUSED, nick, from);
  } else if (u_pass_match(u, "-")) {
    if (!quiet_reject)
      dprintf(DP_HELP, "NOTICE %s :%s.\n", nick, DCC_REFUSED3);
    putlog(LOG_MISC, "*", "%s: %s!%s", DCC_REFUSED4, nick, from);
  } else if (!dccdir[0]) {
    putlog(LOG_MISC, "*", "%s: %s!%s", DCC_REFUSED5, nick, from);
  } else {
    ip = newsplit(&msg);
    prt = newsplit(&msg);
    sock = getsock(0);
    if (open_telnet_dcc(sock, ip, prt) < 0) {
      neterror(buf);
      if (!quiet_reject)
        dprintf(DP_HELP, "NOTICE %s :%s (%s)\n", nick,
	        DCC_CONNECTFAILED1, buf);
      putlog(LOG_MISC, "*", "%s: CHAT(file) (%s!%s)", DCC_CONNECTFAILED2,
	     nick, from);
      putlog(LOG_MISC, "*", "    (%s)", buf);
      killsock(sock);
    } else if ((atoi(prt) < min_dcc_port) || (atoi(prt) > max_dcc_port)) {
      /* invalid port range, do clients even use over 5000?? */
      if (!quiet_reject)
        dprintf(DP_HELP, "NOTICE %s :%s (invalid port)\n", nick,
	        DCC_CONNECTFAILED1);
      putlog(LOG_FILES, "*", "%s: %s!%s", DCC_REFUSED7, nick, from);

    } else {
      i = new_dcc(&DCC_FILES_PASS, sizeof(struct file_info));

      dcc[i].addr = my_atoul(ip);
      dcc[i].port = atoi(prt);
      dcc[i].sock = sock;
      strcpy(dcc[i].nick, u->handle);
      strcpy(dcc[i].host, from);
      dcc[i].status = STAT_ECHO;
      dcc[i].timeval = now;
      dcc[i].u.file->chat = get_data_ptr(sizeof(struct chat_info));
      bzero(dcc[i].u.file->chat, sizeof(struct chat_info));

      strcpy(dcc[i].u.file->chat->con_chan, "*");
      dcc[i].user = u;
      putlog(LOG_MISC, "*", "DCC connection: CHAT(file) (%s!%s)", nick, from);
      dprintf(i, "%s\n", DCC_ENTERPASS);
    }
  }
  return 1;
}