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-7.3/modules/m_challenge.c (file contents), Revision 1121 by michael, Sun Jan 9 11:03:03 2011 UTC vs.
ircd-hybrid/trunk/modules/m_challenge.c (file contents), Revision 1592 by michael, Sat Oct 27 21:02:32 2012 UTC

# Line 23 | Line 23
23   */
24  
25   #include "stdinc.h"
26 – #ifdef HAVE_LIBCRYPTO
27 –
28 – #include "handlers.h"
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"
35 < /* -lcrypto is implicit for building this module! */
31 > #include "conf.h"
32   #include "rsa.h"
37 – #include "msg.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  
43 – static void failed_challenge_notice(struct Client *, const char *,
44 –                                    const char *);
45 – static void m_challenge(struct Client *, struct Client *, int, char *[]);
46 –
47 – /* We have openssl support, so include /CHALLENGE */
48 – struct Message challenge_msgtab = {
49 –  "CHALLENGE", 0, 0, 2, 0, MFLG_SLOW, 0,
50 –  { m_unregistered, m_challenge, m_ignore, m_ignore, m_challenge, m_ignore }
51 – };
38  
39 < void
40 < _modinit(void)
39 > #ifdef HAVE_LIBCRYPTO
40 > /* failed_challenge_notice()
41 > *
42 > * inputs       - pointer to client doing /oper ...
43 > *              - pointer to nick they tried to oper as
44 > *              - pointer to reason they have failed
45 > * output       - nothing
46 > * side effects - notices all opers of the failed oper attempt if enabled
47 > */
48 > static void
49 > failed_challenge_notice(struct Client *source_p, const char *name,
50 >                        const char *reason)
51   {
52 <  mod_add_cmd(&challenge_msgtab);
53 < }
52 >  if (ConfigFileEntry.failed_oper_notice)
53 >    sendto_realops_flags(UMODE_ALL, L_ALL, "Failed CHALLENGE attempt as %s "
54 >                         "by %s (%s@%s) - %s", name, source_p->name,
55 >                         source_p->username, source_p->host, reason);
56  
57 < void
58 < _moddeinit(void)
59 < {
62 <  mod_del_cmd(&challenge_msgtab);
57 >  ilog(LOG_TYPE_OPER, "Failed CHALLENGE attempt as %s "
58 >       "by %s (%s@%s) - %s", name, source_p->name,
59 >       source_p->username, source_p->host, reason);
60   }
61  
65 – const char *_version = "$Revision$";
66 –
62   /*
63   * m_challenge - generate RSA challenge for wouldbe oper
64   * parv[0] = sender prefix
# Line 78 | Line 73 | m_challenge(struct Client *client_p, str
73    struct ConfItem *conf = NULL;
74    struct AccessItem *aconf = NULL;
75  
81 –  /* if theyre an oper, reprint oper motd and ignore */
82 –  if (IsOper(source_p))
83 –  {
84 –    sendto_one(source_p, form_str(RPL_YOUREOPER), me.name, parv[0]);
85 –    send_message_file(source_p, &ConfigFileEntry.opermotd);
86 –    return;
87 –  }
88 –
76    if (*parv[1] == '+')
77    {
78      /* Ignore it if we aren't expecting this... -A1kmm */
# Line 101 | Line 88 | m_challenge(struct Client *client_p, str
88        return;
89      }
90      
91 <    conf = find_exact_name_conf(OPER_TYPE,
92 <                                source_p->localClient->auth_oper,
106 <                                source_p->username, source_p->host);
107 <    if (conf == NULL)
108 <      conf = find_exact_name_conf(OPER_TYPE,
109 <                                  source_p->localClient->auth_oper,
110 <                                  source_p->username, source_p->sockhost);
91 >    conf = find_exact_name_conf(OPER_TYPE, source_p,
92 >                                source_p->localClient->auth_oper, NULL, NULL);
93      if (conf == NULL)
94      {
95 <      sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
96 <      log_oper_action(LOG_FAILED_OPER_TYPE, source_p, "%s\n",
115 <                      source_p->localClient->auth_oper);
95 >      /* XXX: logging */
96 >      sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
97        return;
98      }
99  
# Line 121 | Line 102 | m_challenge(struct Client *client_p, str
102        sendto_one(source_p,":%s NOTICE %s :Can't attach conf!",
103                   me.name, source_p->name);  
104        failed_challenge_notice(source_p, conf->name, "can't attach conf!");
124 –      log_oper_action(LOG_FAILED_OPER_TYPE, source_p, "%s\n",
125 –                      source_p->localClient->auth_oper);
105        return;
106      }
107  
108      oper_up(source_p);
109  
110 <    ilog(L_TRACE, "OPER %s by %s!%s@%s",
110 >    ilog(LOG_TYPE_OPER, "OPER %s by %s!%s@%s",
111           source_p->localClient->auth_oper, source_p->name, source_p->username,
112           source_p->host);
134 –    log_oper_action(LOG_OPER_TYPE, source_p,
135 –                    "%s\n", source_p->localClient->auth_oper);
113  
114      MyFree(source_p->localClient->response);
115      MyFree(source_p->localClient->auth_oper);
# Line 157 | Line 134 | m_challenge(struct Client *client_p, str
134  
135    if (aconf == NULL)
136    {
137 <    sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, parv[0]);
138 <    conf = find_exact_name_conf(OPER_TYPE, parv[1], NULL, NULL);
137 >    sendto_one (source_p, form_str(ERR_NOOPERHOST), me.name, source_p->name);
138 >    conf = find_exact_name_conf(OPER_TYPE, NULL, parv[1], NULL, NULL);
139      failed_challenge_notice(source_p, parv[1], (conf != NULL)
140                              ? "host mismatch" : "no oper {} block");
164 –    log_oper_action(LOG_FAILED_OPER_TYPE, source_p, "%s\n", parv[1]);
141      return;
142    }
143  
# Line 169 | Line 145 | m_challenge(struct Client *client_p, str
145    {
146      sendto_one (source_p, ":%s NOTICE %s :I'm sorry, PK authentication "
147                  "is not enabled for your oper{} block.", me.name,
148 <                parv[0]);
148 >                source_p->name);
149      return;
150    }
151  
152    if (!generate_challenge(&challenge, &(source_p->localClient->response),
153                            aconf->rsa_public_key))
154      sendto_one(source_p, form_str(RPL_RSACHALLENGE),
155 <               me.name, parv[0], challenge);
155 >               me.name, source_p->name, challenge);
156  
157    DupString(source_p->localClient->auth_oper, conf->name);
158    MyFree(challenge);
159   }
160  
185 – /* failed_challenge_notice()
186 – *
187 – * inputs       - pointer to client doing /oper ...
188 – *              - pointer to nick they tried to oper as
189 – *              - pointer to reason they have failed
190 – * output       - nothing
191 – * side effects - notices all opers of the failed oper attempt if enabled
192 – */
161   static void
162 < failed_challenge_notice(struct Client *source_p, const char *name,
163 <                        const char *reason)
162 > mo_challenge(struct Client *client_p, struct Client *source_p,
163 >             int parc, char *parv[])
164 > {
165 >  sendto_one(source_p, form_str(RPL_YOUREOPER),
166 >             me.name, source_p->name);
167 > }
168 >
169 > static struct Message challenge_msgtab = {
170 >  "CHALLENGE", 0, 0, 2, MAXPARA, MFLG_SLOW, 0,
171 >  { m_unregistered, m_challenge, m_ignore, m_ignore, mo_challenge, m_ignore }
172 > };
173 >
174 > static void
175 > module_init(void)
176 > {
177 >  mod_add_cmd(&challenge_msgtab);
178 > }
179 >
180 > static void
181 > module_exit(void)
182 > {
183 >  mod_del_cmd(&challenge_msgtab);
184 > }
185 >
186 > #else
187 >
188 > static void
189 > module_init(void)
190 > {
191 > }
192 >
193 > static void
194 > module_exit(void)
195   {
197 –  if (ConfigFileEntry.failed_oper_notice)
198 –    sendto_realops_flags(UMODE_ALL, L_ALL, "Failed CHALLENGE attempt as %s "
199 –                         "by %s (%s@%s) - %s", name, source_p->name,
200 –                         source_p->username, source_p->host, reason);
196   }
197   #endif
198 +
199 + struct module module_entry = {
200 +  .node    = { NULL, NULL, NULL },
201 +  .name    = NULL,
202 +  .version = "$Revision$",
203 +  .handle  = NULL,
204 +  .modinit = module_init,
205 +  .modexit = module_exit,
206 +  .flags   = 0
207 + };

Diff Legend

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