Ejemplo n.º 1
0
	bool VerifyResponse(const CNick& Nick, const CString& sResponse) {
		MCString::iterator itQueue = m_msQueue.find(Nick.GetNick().AsLower());

		if (itQueue == m_msQueue.end()) {
			PutModule("[" + Nick.GetHostMask() + "] sent an unchallenged response.  This could be due to lag.");
			return false;
		}

		CString sChallenge = itQueue->second;
		m_msQueue.erase(itQueue);

		for (map<CString, CAutoOpUser*>::iterator it = m_msUsers.begin(); it != m_msUsers.end(); it++) {
			if (it->second->HostMatches(Nick.GetHostMask())) {
				if (sResponse == CString(it->second->GetUserKey() + "::" + sChallenge).MD5()) {
					OpUser(Nick, *it->second);
					return true;
				} else {
					PutModule("WARNING! [" + Nick.GetHostMask() + "] sent a bad response.  Please verify that you have their correct password.");
					return false;
				}
			}
		}

		PutModule("WARNING! [" + Nick.GetHostMask() + "] sent a response but did not match any defined users.");
		return false;
	}
Ejemplo n.º 2
0
void doop(struct user *user, char *tail)
{
  unsigned char flags;
  struct reggedchannel *chanptr;
  char *channel;

  channel = tail;
  SeperateWord(tail);

  if (channel == NULL) {
    NoticeToUser(user, "Usage: op #channel");
    return;
  }

  if ((chanptr = GetChannelPointer(channel)) == NULL) {
    NoticeToUser(user, "Unknown channel %s.", channel);
    return;
  }

  flags = GetChannelFlags(user->authedas, chanptr);

  /* Check for OP or MASTER or OWNER flag */
  if (!(flags & (CFLAG_OP | CFLAG_MASTER | CFLAG_OWNER)) || IsSuspended(chanptr)) {
    /* No flags -- perhaps they are an oper? */
    if (!((user->oper) && (user->authedas->authlevel > 200))) {
      /* Nope, not an oper either */
      NoticeToUser(user, "Sorry, you need the +o flag on %s to get ops.", channel);
      return;
    }
  }

  /* Do the actual op */
  OpUser(chanptr, user->numeric);

  /* Update lastused timestamp on channel */
  chanptr->lastused = time(NULL);

  NoticeToUser(user, "Done.");
}
Ejemplo n.º 3
0
void DoJoins(char *numeric, char *channellist, time_t timestamp)
{
  char *currentchan;
  char *nextchan = channellist;
  struct reggedchannel *chanptr;
  struct user *user_ptr;
  int automodes;

  /* Right then.  First up, let's see if it's 0 being joined here */
  /* If so, we need to do all the work of a part (i.e. nothing) for each channel */

  if (!strncmp(channellist, "0", 1))
    return;

  user_ptr = usertablepointer[getserverindex(numeric)][getclientindex(numeric)];

  while (*nextchan) {
    currentchan = nextchan;

    /* The next two blocks are going to turn currentchan into a pointer 
     * to a well-formed string.
     * nextchan will point to the first char of the next channel name, if any
     * or NULL if this is the last one */

    for (; *nextchan != ',' && *nextchan != '\0'; nextchan++);  /* Look for the next comma, or end of list */

    /* If we stopped on a comma, change to a NUL and advance nextchan
     * Otherwise, it was a NUL already, and we leave nextchan there so 
     * the loop will stop next time round */
    if (*nextchan == ',') {
      *nextchan = '\0';
      nextchan++;
    }

    chanptr = GetChannelPointer(currentchan);
    if (chanptr == NULL)        /* It's not a channel we care about, carry on with the next one */
      continue;

    if (IsSuspended(chanptr))   /* Same as above, we dont really care about this channel */
      continue;

    /* Check the timestamp */
    if (timestamp > 0)
      SyncTimestamp(chanptr, timestamp);

    if (chanptr->welcome)
      NoticeToUser(user_ptr, "[%s] %s", chanptr->channelname, chanptr->welcome);

    automodes = AutoModes(numeric, currentchan);

    /* Update lastused timestamp on channel if user is known on it. */
    if (automodes > 0) {
      chanptr->lastused = time(NULL);
    }

    switch (automodes) {

    case AUTOMODE_NOAUTOFLAGS:
      /* User is known, but shouldnt have voice nor op automatically. */
      /* Do the same as for AUTOMODE_NOTHING (it could be a voice user). */
    case AUTOMODE_NOTHING:
      /* It's a registered channel, which the user has no modes on */
      /* We need to deop them if it's a create */
      /* If the channel is inviteonly and it's a create, */
      /* then kick their ass if they're unknown. */
      /* We rely on the channel to be +i at all times after a createa */
      /* if we have inviteonly set as chanflag. */
      if (timestamp > 0) {
        if (!IsInviteOnly(chanptr)) { /* Channel is a normal channel */
          DeopUser(chanptr, numeric);
        } else {                /* Channel is invite only. */
          if (automodes == AUTOMODE_NOAUTOFLAGS) {
            DeopUser(chanptr, numeric); /* User has flags, so shouldnt be kicked. */
          } else {              /* Must be a AUTOMODE_NOTHING, so no flags, and therefore not known on the channel. */
            KickUser(chanptr, user_ptr->numeric, "Channel is invite only");
          }
        }
      }
      break;

    case AUTOMODE_OP:
      /* It's a registered channel, which the user has ops on */
      /* We need to op them if and only if it's NOT a create */

      if (timestamp == 0)
        OpUser(chanptr, numeric);
      else
        CheckJoined(chanptr);
      break;

    case AUTOMODE_VOICE:
      /* It's a registered channel, the user has autovoice */
      /* If it's a create, deop-and-voice, 
       * if it's a join, just voice */

      if (timestamp == 0) {
        VoiceUser(chanptr, numeric);
      } else {
        CheckJoined(chanptr);
        VoiceAndDeopUser(chanptr, numeric);
      }
      break;

    default:
      /* It's an unregistered channel, do nothing */
      /* Note that with the continue above we shouldn't get here any more */
      break;
    }
  }
}