ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/ermyth/modules/saslserv/plain.C
Revision: 1.1
Committed: Thu Jul 19 08:24:56 2007 UTC (19 years, 3 months ago) by pippijn
Content type: text/plain
Branch: MAIN
Log Message:
initial import. the most important changes since Atheme are:
- fixed many memory leaks
- fixed many bugs
- converted to C++ and use more STL containers
- added a (not very enhanced yet) perl module
- greatly improved XML-RPC speed
- added a JSON-RPC module with code from json-cpp
- added a valgrind memcheck module to operserv
- added a more object oriented base64 implementation
- added a specialised unit test framework
- improved stability
- use gettimeofday() if available
- reworked adding/removing commands
- MemoServ IGNORE DEL can now remove indices

File Contents

# User Rev Content
1 pippijn 1.1 /*
2     * Copyright © 2006 Atheme Development Group
3     * Rights to this code are as documented in doc/LICENSE.
4     *
5     * PLAIN mechanism provider
6     *
7     * $Id: plain.c 7779 2007-03-03 13:55:42Z pippijn $
8     */
9    
10     #include "atheme.h"
11     #include <account/myuser.h>
12    
13     static char const rcsid[] = "$Id";
14    
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     */