1 | /* |
1 | /* |
2 | * authcookie.C: Remote authentication ticket management |
2 | * authcookie.C: Remote authentication ticket management |
3 | * Rights to this code are documented in doc/pod/license.pod. |
3 | * Rights to this code are documented in doc/pod/license.pod. |
4 | * |
4 | * |
5 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
5 | * Copyright © 2005-2007 Atheme Project (http://www.atheme.org) |
6 | */ |
6 | */ |
7 | |
7 | |
8 | static char const rcsid[] = "$Id: authcookie.C,v 1.3 2007/07/21 13:23:21 pippijn Exp $"; |
8 | static char const rcsid[] = "$Id: authcookie.C,v 1.4 2007/08/28 17:08:12 pippijn Exp $"; |
9 | |
9 | |
10 | #include "atheme.h" |
10 | #include "atheme.h" |
11 | #include "authcookie.h" |
11 | #include "authcookie.h" |
12 | |
12 | |
13 | list_t authcookie_list; |
13 | list_t authcookie_list; |
14 | static BlockHeap *authcookie_heap; |
|
|
15 | |
14 | |
16 | void |
15 | void |
17 | authcookie_init (void) |
16 | authcookie_init (void) |
18 | { |
17 | { |
|
|
18 | #if 0 |
19 | authcookie_heap = BlockHeapCreate (sizeof (authcookie_t), 1024); |
19 | authcookie_heap = BlockHeapCreate (sizeof (authcookie_t), 1024); |
20 | |
20 | #endif |
21 | if (!authcookie_heap) |
|
|
22 | { |
|
|
23 | slog (LG_ERROR, "authcookie_init(): cannot initialize block allocator."); |
|
|
24 | exit (EXIT_FAILURE); |
|
|
25 | } |
|
|
26 | } |
21 | } |
27 | |
22 | |
28 | /* |
23 | /* |
29 | * authcookie_create() |
24 | * authcookie_create() |
30 | * |
25 | * |
… | |
… | |
38 | * an authcookie ticket is created, and validated. |
33 | * an authcookie ticket is created, and validated. |
39 | */ |
34 | */ |
40 | authcookie_t * |
35 | authcookie_t * |
41 | authcookie_create (myuser_t *mu) |
36 | authcookie_create (myuser_t *mu) |
42 | { |
37 | { |
43 | authcookie_t *au = static_cast<authcookie_t *> (BlockHeapAlloc (authcookie_heap)); |
38 | authcookie_t *au = new authcookie_t; |
44 | |
39 | |
45 | au->ticket = gen_pw (20); |
40 | au->ticket = gen_pw (20); |
46 | au->myuser = mu; |
41 | au->myuser = mu; |
47 | au->expire = NOW + 3600; |
42 | au->expire = NOW + 3600; |
48 | |
43 | |
… | |
… | |
122 | authcookie_destroy (authcookie_t *ac) |
117 | authcookie_destroy (authcookie_t *ac) |
123 | { |
118 | { |
124 | return_if_fail (ac != NULL); |
119 | return_if_fail (ac != NULL); |
125 | |
120 | |
126 | node_del (&ac->node, &authcookie_list); |
121 | node_del (&ac->node, &authcookie_list); |
127 | free (ac->ticket); |
122 | sfree (ac->ticket); |
128 | BlockHeapFree (authcookie_heap, ac); |
123 | delete ac; |
129 | } |
124 | } |
130 | |
125 | |
131 | /* |
126 | /* |
132 | * authcookie_destroy_all() |
127 | * authcookie_destroy_all() |
133 | * |
128 | * |