Esempio n. 1
0
/*
** m_oper
**      parv[0] = sender prefix
**      parv[1] = oper name
**      parv[2] = oper password
*/
static void
m_oper(struct Client *client_p, struct Client *source_p,
       int parc, char *parv[])
{
  struct ConfItem *conf;
  struct AccessItem *aconf=NULL;
  const char *name = parv[1];
  const char *password = parv[2];

  if (EmptyString(password))
  {
    sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
	       me.name, source_p->name, "OPER");
    return;
  }

  /* end the grace period */
  if (!IsFloodDone(source_p))
    flood_endgrace(source_p);

  if ((conf = find_password_conf(name,source_p)) == NULL)
  {
    sendto_one(source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
    conf = find_exact_name_conf(OPER_TYPE, name, NULL, NULL);
    failed_oper_notice(source_p, name, (conf != NULL) ?
                       "host mismatch" : "no oper {} block");
    log_failed_oper(source_p, name);
    return;
  }

  aconf = (struct AccessItem *)map_to_conf(conf);

  if (match_oper_password(password, aconf))
  {
    if (attach_conf(source_p, conf) != 0)
    {
      sendto_one(source_p, ":%s NOTICE %s :Can't attach conf!",
                 me.name, source_p->name);
      failed_oper_notice(source_p, name, "can't attach conf!");
      log_failed_oper(source_p, name);
      return;
    }

    oper_up(source_p);

    ilog(L_TRACE, "OPER %s by %s!%s@%s",
         name, source_p->name, source_p->username, source_p->host);
    log_oper(source_p, name);
  }
  else
  {
    sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name, parv[0]);
    failed_oper_notice(source_p, name, "password mismatch");
    log_failed_oper(source_p, name);
  }
}
Esempio n. 2
0
/*
** m_oper
**      parv[0] = sender prefix
**      parv[1] = oper name
**      parv[2] = oper password
*/
static void
m_oper(struct Client *client_p, struct Client *source_p,
       int parc, char *parv[])
{
  struct ConfItem *aconf;
  struct ConfItem *oconf = NULL;
  char  *name;
  char  *password;
  dlink_node *ptr;

  name = parv[1];
  password = parv[2];

  if (EmptyString(password))
  {
    sendto_one(source_p, form_str(source_p,ERR_NEEDMOREPARAMS),
	       me.name, source_p->name, "OPER");
    return;
  }

  /* end the grace period */
  if(!IsFloodDone(source_p))
    flood_endgrace(source_p);

  if((aconf = find_password_aconf(name,source_p)) == NULL)
  {
    sendto_one(source_p, form_str(source_p,ERR_NOOPERHOST), me.name, source_p->name);
    if (ConfigFileEntry.failed_oper_notice)
    {
      sendto_realops_flags(FLAGS_ALL, L_ALL,
			   "Failed OPER attempt - host mismatch by %s (%s@%s)",
			   source_p->name, source_p->username, 
			   source_p->host);
    }
    log_failed_oper(source_p, name);
    return;
  }

  if (match_oper_password(password,aconf))
  {
    /*
     *  20001216:
     *  detach old iline
     *  -einride
     */
    if ((ptr = source_p->localClient->confs.head) != NULL)
    {
      oconf = ptr->data;
      detach_conf(source_p,oconf);
    }

    if(attach_conf(source_p, aconf) != 0)
    {
      sendto_one(source_p,":%s NOTICE %s :Can't attach conf!",
		 me.name,source_p->name);
      sendto_realops_flags(FLAGS_ALL, L_ALL,
			   "Failed OPER attempt by %s (%s@%s) can't attach conf!",
			   source_p->name, source_p->username,
			   source_p->host);
      /* 
       * 20001216:
       * Reattach old iline
       *     -einride
       */
      attach_conf(source_p, oconf);
      log_failed_oper(source_p, name);
      return;
    }

    oper_up(source_p, aconf);
      
    ilog(L_TRACE, "OPER %s by %s!%s@%s",
	 name, source_p->name, source_p->username, source_p->host);
    log_oper(source_p, name);
  }
  else
  {
    sendto_one(source_p,form_str(source_p,ERR_PASSWDMISMATCH),me.name, parv[0]);
    if (ConfigFileEntry.failed_oper_notice)
    {
      sendto_realops_flags(FLAGS_ALL, L_ALL,
			   "Failed OPER attempt by %s (%s@%s)",
			   source_p->name, source_p->username,
			   source_p->host);
    }
    log_failed_oper(source_p, name);
  }
}
Esempio n. 3
0
/*
 * m_challenge - generate RSA challenge for wouldbe oper
 * parv[0] = sender prefix
 * parv[1] = operator to challenge for, or +response
 *
 */
static void
m_challenge(struct Client *client_p, struct Client *source_p,
            int parc, char *parv[])
{
  char *challenge;
  struct ConfItem *conf=NULL;
  struct AccessItem *aconf=NULL;

  if ((source_p->user == NULL) || (source_p->localClient == NULL))
    return;

  /* if theyre an oper, reprint oper motd and ignore */
  if (IsOper(source_p))
  {
    sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, parv[0]);
    send_message_file(source_p, &ConfigFileEntry.opermotd);
    return;
  }

  if (*parv[1] == '+')
  {
    /* Ignore it if we aren't expecting this... -A1kmm */
    if (!source_p->user->response)
      return;

    if (irccmp(source_p->user->response, ++parv[1]))
    {
      sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name,
		 source_p->name);
      failed_challenge_notice(source_p, source_p->user->auth_oper,
			      "challenge failed");
      return;
    }
     
    if ((conf = find_exact_name_conf(OPER_TYPE,
				     source_p->user->auth_oper,
				     source_p->username, source_p->host
				   )) == NULL)
    {
      sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
      log_failed_oper(source_p, source_p->user->auth_oper);
      return;
    }

    if (attach_conf(source_p, conf) != 0)
    {
      sendto_one(source_p,":%s NOTICE %s :Can't attach conf!",
		 me.name, source_p->name);   
      failed_challenge_notice(source_p, conf->name, "can't attach conf!");
      log_failed_oper(source_p, source_p->user->auth_oper);
      return;
    }

    oper_up(source_p);

    ilog(L_TRACE, "OPER %s by %s!%s@%s",
	 source_p->user->auth_oper, source_p->name, source_p->username,
	 source_p->host);
    log_oper(source_p, source_p->user->auth_oper);

    MyFree(source_p->user->response);
    MyFree(source_p->user->auth_oper);
    source_p->user->response  = NULL;
    source_p->user->auth_oper = NULL;
    return;
  }

  MyFree(source_p->user->response);
  MyFree(source_p->user->auth_oper);
  source_p->user->response  = NULL;
  source_p->user->auth_oper = NULL;

  if ((conf = find_conf_exact(OPER_TYPE,
			      parv[1], source_p->username, source_p->host
			      )) != NULL)
  {
    aconf = (struct AccessItem *)map_to_conf(conf);
  }
  else if ((conf = find_conf_exact(OPER_TYPE,
				   parv[1], source_p->username,
				   source_p->localClient->sockhost)) != NULL)
  {
    aconf = (struct AccessItem *)map_to_conf(conf);
  }

  if(aconf == NULL)
  {
    sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
    conf = find_exact_name_conf(OPER_TYPE, parv[1], NULL, NULL);
    failed_challenge_notice(source_p, parv[1], (conf != NULL)
                            ? "host mismatch" : "no oper {} block");
    log_failed_oper(source_p, parv[1]);
    return;
  }
  if (aconf->rsa_public_key == NULL)
  {
    sendto_one (source_p, ":%s NOTICE %s :I'm sorry, PK authentication "
		"is not enabled for your oper{} block.", me.name,
		parv[0]);
    return;
  }
  if (
   !generate_challenge (&challenge, &(source_p->user->response), aconf->rsa_public_key)
     )
  {
    sendto_one(source_p, form_str(RPL_RSACHALLENGE), me.name, parv[0],
		challenge);
  }

  DupString(source_p->user->auth_oper, conf->name);
  MyFree(challenge);
}