Exemplo n.º 1
0
/** Find Spoofhost configuration for \a cptr with spoof host matching host and
 *  a password matching \a passwd
 * @param[in] cptr Client to match Spoofhost configuration against.
 * @param[in] host Spoofhost host to look for, if NULL look for an autoapply Spoofhost.
 * @param[in] passwd Password to compare against Spoofhost configuration.
 * @param[out] status 0 for Success, 1 for invalid password and 2 for no Spoofhost configuration.
 * @return SHostConf struct of matching Spoofhost configuration or 0 on error.
 */
struct SHostConf* find_shost_conf(struct Client *cptr, char *host, char *passwd, int *status)
{
  struct SHostConf* sconf;
  char *crypted;
  int res = 0;

  *status = 2;

  for(sconf = shostConfList; sconf; sconf = sconf->next) {
    if ((host == NULL) && !(sconf->flags & SHFLAG_AUTOAPPLY))
      continue;
    if (host != NULL) {
      if (!(sconf->flags & SHFLAG_ISMASK) && strcmp(sconf->spoofhost, host))
        continue;
      if ((sconf->flags & SHFLAG_ISMASK) && match(sconf->spoofhost, host))
        continue;
    }

    if (sconf->usermask) {
      if (match(sconf->usermask, cli_username(cptr)) &&
          !((sconf->flags & SHFLAG_MATCHUSER) && !match(sconf->usermask, cli_user(cptr)->username)))
        continue;
    }

    if (sconf->bits > 0) {
      if (!ipmask_check(&cli_ip(cptr), &sconf->address, sconf->bits))
        continue;
    } else if (sconf->hostmask && match(sconf->hostmask, cli_sockhost(cptr)))
      continue;

    *status = 1;
    res = 0;

    if ((host == NULL) && (sconf->flags & SHFLAG_AUTOAPPLY)) {
      *status = 0;
      return sconf;
    }

    if (EmptyString(passwd) && !EmptyString(sconf->passwd))
      continue;
    if (!EmptyString(passwd) && EmptyString(sconf->passwd))
      continue;
    if (!EmptyString(passwd) && !EmptyString(sconf->passwd)) {
      crypted = ircd_crypt(passwd, sconf->passwd);
      if (!crypted)
        continue;

      res = strcmp(crypted, sconf->passwd);
      MyFree(crypted);
    }

    if (0 == res) {
      *status = 0;
      return sconf;
    }
  }

  return 0;
}
Exemplo n.º 2
0
/** Find WebIRC configuration for \a cptr with password matching \a passwd
 * @param[in] cptr Client to match WebIRC configuration against.
 * @param[in] passwd Password to compare against WebIRC configuration.
 * @param[out] status 0 for Success, 1 for invalid password and 2 for no WebIRC configuration.
 * @return WebIRCConf struct of matching WebIRC configuration or 0 on error.
 */
struct WebIRCConf* find_webirc_conf(struct Client *cptr, char *passwd, int* status)
{
  struct WebIRCConf *wconf;
  char *crypted;
  int res;

  *status = 2;

  if (!passwd)
    return 0;

  for(wconf = webircConfList; wconf; wconf = wconf->next) {
    if (wconf->usermask && match(wconf->usermask, cli_username(cptr)))
      continue;
    if (wconf->bits > 0) {
      if (!ipmask_check(&cli_ip(cptr), &wconf->address, wconf->bits))
        continue;
    } else if (wconf->hostmask && match(wconf->hostmask, cli_sockhost(cptr)))
      continue;

    *status = 1;

    if (!wconf->passwd) {
      *status = 0;
      return wconf;
    }

    crypted = ircd_crypt(passwd, wconf->passwd);

    if (!crypted)
      continue;

    res = strcmp(crypted, wconf->passwd);
    MyFree(crypted);

    if (0 == res) {
      *status = 0;
      return wconf;
    }
  }

  return 0;
}
Exemplo n.º 3
0
int oper_password_match(const char* to_match, const char* passwd)
{
  char *crypted;
  int res;
  /*
   * use first two chars of the password they send in as salt
   *
   * passwd may be NULL. Head it off at the pass...
   */
  if (!to_match || !passwd)
    return 0;

  /* we no longer do a CRYPT_OPER_PASSWORD check because a clear 
     text passwords just handled by a fallback mechanism called 
     crypt_clear if it's enabled -- hikari */
  crypted = ircd_crypt(to_match, passwd);

  if (!crypted)
   return 0;
  res = strcmp(crypted, passwd);
  MyFree(crypted);
  return 0 == res;
}