ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/modules/m_challenge.c
(Generate patch)

Comparing:
ircd-hybrid-8/modules/m_challenge.c (file contents), Revision 1285 by michael, Sun Feb 5 15:12:59 2012 UTC vs.
ircd-hybrid/trunk/modules/m_challenge.c (file contents), Revision 1832 by michael, Fri Apr 19 19:16:09 2013 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 – #ifdef HAVE_LIBCRYPTO
26   #include "client.h"
27   #include "ircd.h"
28   #include "modules.h"
29   #include "numeric.h"
30   #include "send.h"
31 < #include "s_conf.h"
31 > #include "conf.h"
32   #include "rsa.h"
33   #include "parse.h"
34   #include "irc_string.h"
35 < #include "s_log.h"
35 > #include "log.h"
36   #include "s_user.h"
37 + #include "memory.h"
38  
39  
40 + #ifdef HAVE_LIBCRYPTO
41   /* failed_challenge_notice()
42   *
43   * inputs       - pointer to client doing /oper ...
# Line 50 | Line 51 | failed_challenge_notice(struct Client *s
51                          const char *reason)
52   {
53    if (ConfigFileEntry.failed_oper_notice)
54 <    sendto_realops_flags(UMODE_ALL, L_ALL, "Failed CHALLENGE attempt as %s "
54 >    sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
55 >                         "Failed CHALLENGE attempt as %s "
56                           "by %s (%s@%s) - %s", name, source_p->name,
57                           source_p->username, source_p->host, reason);
58  
# Line 70 | Line 72 | m_challenge(struct Client *client_p, str
72              int parc, char *parv[])
73   {
74    char *challenge = NULL;
75 <  struct ConfItem *conf = NULL;
74 <  struct AccessItem *aconf = NULL;
75 <
76 <  /* if theyre an oper, reprint oper motd and ignore */
77 <  if (HasUMode(source_p, UMODE_OPER))
78 <  {
79 <    sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, source_p->name);
80 <    send_message_file(source_p, &ConfigFileEntry.opermotd);
81 <    return;
82 <  }
75 >  struct MaskItem *conf = NULL;
76  
77    if (*parv[1] == '+')
78    {
# Line 89 | Line 82 | m_challenge(struct Client *client_p, str
82  
83      if (irccmp(source_p->localClient->response, ++parv[1]))
84      {
85 <      sendto_one(source_p, form_str(ERR_PASSWDMISMATCH), me.name,
85 >      sendto_one(source_p, ERR_PASSWDMISMATCH, me.name,
86                   source_p->name);
87        failed_challenge_notice(source_p, source_p->localClient->auth_oper,
88                                "challenge failed");
89        return;
90      }
91      
92 <    conf = find_exact_name_conf(OPER_TYPE, source_p,
92 >    conf = find_exact_name_conf(CONF_OPER, source_p,
93                                  source_p->localClient->auth_oper, NULL, NULL);
94      if (conf == NULL)
95      {
96        /* XXX: logging */
97 <      sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
97 >      sendto_one (source_p, ERR_NOOPERHOST, me.name, source_p->name);
98        return;
99      }
100  
# Line 131 | Line 124 | m_challenge(struct Client *client_p, str
124    source_p->localClient->response  = NULL;
125    source_p->localClient->auth_oper = NULL;
126  
127 <  if ((conf = find_conf_exact(OPER_TYPE,
135 <                              parv[1], source_p->username, source_p->host
136 <                              )) != NULL)
137 <    aconf = map_to_conf(conf);
138 <  else if ((conf = find_conf_exact(OPER_TYPE,
139 <                                   parv[1], source_p->username,
140 <                                   source_p->sockhost)) != NULL)
141 <    aconf = map_to_conf(conf);
127 >  conf = find_exact_name_conf(CONF_OPER, source_p, parv[1], NULL, NULL);
128  
129 <  if (aconf == NULL)
129 >  if (!conf)
130    {
131 <    sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
132 <    conf = find_exact_name_conf(OPER_TYPE, NULL, parv[1], NULL, NULL);
131 >    sendto_one (source_p, ERR_NOOPERHOST, me.name, source_p->name);
132 >    conf = find_exact_name_conf(CONF_OPER, NULL, parv[1], NULL, NULL);
133      failed_challenge_notice(source_p, parv[1], (conf != NULL)
134                              ? "host mismatch" : "no oper {} block");
135      return;
136    }
137  
138 <  if (aconf->rsa_public_key == NULL)
138 >  if (conf->rsa_public_key == NULL)
139    {
140      sendto_one (source_p, ":%s NOTICE %s :I'm sorry, PK authentication "
141                  "is not enabled for your oper{} block.", me.name,
# Line 158 | Line 144 | m_challenge(struct Client *client_p, str
144    }
145  
146    if (!generate_challenge(&challenge, &(source_p->localClient->response),
147 <                          aconf->rsa_public_key))
148 <    sendto_one(source_p, form_str(RPL_RSACHALLENGE),
147 >                          conf->rsa_public_key))
148 >    sendto_one(source_p, RPL_RSACHALLENGE,
149                 me.name, source_p->name, challenge);
150  
151 <  DupString(source_p->localClient->auth_oper, conf->name);
151 >  source_p->localClient->auth_oper = xstrdup(conf->name);
152    MyFree(challenge);
153   }
154  
155 + static void
156 + mo_challenge(struct Client *client_p, struct Client *source_p,
157 +             int parc, char *parv[])
158 + {
159 +  sendto_one(source_p, RPL_YOUREOPER,
160 +             me.name, source_p->name);
161 + }
162 +
163   static struct Message challenge_msgtab = {
164    "CHALLENGE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
165 <  { m_unregistered, m_challenge, m_ignore, m_ignore, m_challenge, m_ignore }
165 >  { m_unregistered, m_challenge, m_ignore, m_ignore, mo_challenge, m_ignore }
166   };
167  
168   static void
# Line 183 | Line 177 | module_exit(void)
177    mod_del_cmd(&challenge_msgtab);
178   }
179  
180 + #else
181 +
182 + static void
183 + module_init(void)
184 + {
185 + }
186 +
187 + static void
188 + module_exit(void)
189 + {
190 + }
191 + #endif
192 +
193   struct module module_entry = {
194    .node    = { NULL, NULL, NULL },
195    .name    = NULL,
# Line 192 | Line 199 | struct module module_entry = {
199    .modexit = module_exit,
200    .flags   = 0
201   };
195 – #endif

Diff Legend

– Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)