ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/saslserv/plain.C
Revision: 1.3
Committed: Sat Jul 21 13:23:21 2007 UTC (19 years, 3 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Changes since 1.2: +2 -2 lines
Log Message:
- added rcsid to some files
- more documentation tweaks
- made most protocol commands local to phandler.C
- added ircd metadata (inspircd only for now)
- added inspircd swhois support

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2006 Atheme Development Group
3 pippijn 1.2 * Rights to this code are as documented in doc/pod/license.pod.
4 pippijn 1.1 *
5     * PLAIN mechanism provider
6     *
7 pippijn 1.3 * $Id: plain.C,v 1.2 2007-07-21 01:29:10 pippijn Exp $
8 pippijn 1.1 */
9    
10     #include "atheme.h"
11     #include <account/myuser.h>
12    
13 pippijn 1.3 static char const rcsid[] = "$Id$";
14 pippijn 1.1
15     struct ss_plain_listeners : callback::has_listeners
16     {
17     };
18    
19     ss_plain_listeners listeners;
20    
21     DECLARE_MODULE_V1 ("saslserv/plain", false, _modinit, _moddeinit, rcsid, "The Ermyth Team <http://ermyth.schmorp.de>");
22    
23     list_t *mechanisms;
24     node_t *mnode;
25     static int mech_start (sasl_session_t *p, char **out, int *out_len);
26     static int mech_step (sasl_session_t *p, char *message, int len, char **out, int *out_len);
27     static void mech_finish (sasl_session_t *p);
28     sasl_mechanism_t mech = { "PLAIN", &mech_start, &mech_step, &mech_finish };
29    
30     void
31     _modinit (module_t *m)
32     {
33     MODULE_USE_SYMBOL (mechanisms, "saslserv/main", "sasl_mechanisms");
34     mnode = node_create ();
35     node_add (&mech, mnode, mechanisms);
36     }
37    
38     void
39     _moddeinit ()
40     {
41     node_del (mnode, mechanisms);
42     }
43    
44     static int
45     mech_start (sasl_session_t *p, char **out, int *out_len)
46     {
47     return ASASL_MORE;
48     }
49    
50     static int
51     mech_step (sasl_session_t *p, char *message, int len, char **out, int *out_len)
52     {
53     char auth[256];
54     char pass[256];
55     myuser_t *mu;
56    
57     /* Skip the authzid entirely */
58     len -= strlen (message) + 1;
59     if (len <= 0)
60     return ASASL_FAIL;
61     message += strlen (message) + 1;
62    
63     /* Copy the authcid */
64     if (strlen (message) > 255)
65     return ASASL_FAIL;
66     len -= strlen (message) + 1;
67     if (len <= 0)
68     return ASASL_FAIL;
69     strcpy (auth, message);
70     message += strlen (message) + 1;
71    
72     /* Copy the password */
73     if (strlen (message) > 255)
74     return ASASL_FAIL;
75     strlcpy (pass, message, len + 1);
76    
77     /* Done dissecting, now check. */
78     if (!(mu = myuser_find (auth)))
79     return ASASL_FAIL;
80    
81     p->username = strdup (auth);
82     return verify_password (mu, pass) ? ASASL_DONE : ASASL_FAIL;
83     }
84    
85     static void
86     mech_finish (sasl_session_t *p)
87     {
88     }
89    
90     /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
91     * vim:ts=8
92     * vim:sw=8
93     * vim:noexpandtab
94     */