Debian Codegraph @

modules/saslserv/external.c

raw
1 /*
2 * Copyright (c) 2006 Atheme Development Group
3 * Rights to this code are as documented in doc/LICENSE.
4 *
5 * EXTERNAL IRCv3.1 SASL draft mechanism implementation.
6 */
7
8 #include "atheme.h"
9 #include "authcookie.h"
10
11 DECLARE_MODULE_V1
12 (
13 "saslserv/external", false, _modinit, _moddeinit,
14 PACKAGE_STRING,
15 VENDOR_STRING
16 );
17
18 sasl_mech_register_func_t *regfuncs;
19 static int mech_start(sasl_session_t *p, char **out, size_t *out_len);
20 static int mech_step(sasl_session_t *p, char *message, size_t len, char **out, size_t *out_len);
21 static void mech_finish(sasl_session_t *p);
22 sasl_mechanism_t mech = {"EXTERNAL", &mech_start, &mech_step, &mech_finish};
23
24 void _modinit(module_t *m)
25 {
26 MODULE_TRY_REQUEST_SYMBOL(m, regfuncs, "saslserv/main", "sasl_mech_register_funcs");
27 regfuncs->mech_register(&mech);
28 }
29
30 void _moddeinit(module_unload_intent_t intent)
31 {
32 regfuncs->mech_unregister(&mech);
33 }
34
35 static int mech_start(sasl_session_t *p, char **out, size_t *out_len)
36 {
37 return ASASL_MORE;
38 }
39
40 static int mech_step(sasl_session_t *p, char *message, size_t len, char **out, size_t *out_len)
41 {
42 mycertfp_t *mcfp;
43 const char *name;
44 int namelen;
45
46 if(p->certfp == NULL)
47 return ASASL_FAIL;
48
49 mcfp = mycertfp_find(p->certfp);
50 if(mcfp == NULL)
51 return ASASL_FAIL;
52
53 /* The client response is the authorization identity, which is verified
54 * by saslserv/main, therefore the mechanism need not check it. */
55
56 name = entity(mcfp->mu)->name;
57 p->username = strdup(name);
58 p->authzid = strdup(message);
59
60 return ASASL_DONE;
61 }
62
63 static void mech_finish(sasl_session_t *p)
64 {
65 }
66
67 /* vim:cinoptions=>s,e0,n0,f0,{0,}0,^0,=s,ps,t0,c3,+s,(2s,us,)20,*30,gs,hs
68 * vim:ts=8
69 * vim:sw=8
70 * vim:noexpandtab
71 */