| 1 | /*
|
| 2 | * auth.c - Authentication and Accounting Configuration
|
| 3 | *
|
| 4 | * $Id: auth.c,v 1.18 2008-08-26 11:45:46 tommy Exp $
|
| 5 | */
|
| 6 |
|
| 7 | #include "aconfig.h"
|
| 8 | #include "nntpd.h"
|
| 9 | #include "memory.h"
|
| 10 | #include "aprotos.h"
|
| 11 | #include "modmap.h"
|
| 12 |
|
| 13 |
|
| 14 | /*
|
| 15 | * AuthResult structure operations
|
| 16 | */
|
| 17 |
|
| 18 | PROTO AUTHRESULT * new_authresult(CLIENT * client)
|
| 19 | {
|
| 20 | AUTHRESULT *a;
|
| 21 |
|
| 22 | if ( (a=malloc(sizeof(AUTHRESULT)) ) == NULL )
|
| 23 | {
|
| 24 | return NULL;
|
| 25 | }
|
| 26 |
|
| 27 | a->username = strdup(client->username);
|
| 28 | a->password = strdup(client->password);
|
| 29 | a->username_s = strippat(a->username, client->auth->mask);
|
| 30 | a->logname = NULL;
|
| 31 |
|
| 32 | a->hostname = strdup(client->hostname);
|
| 33 | a->port = client->id + 1;
|
| 34 |
|
| 35 | a->in_addr = client->addr.sin_addr;
|
| 36 |
|
| 37 | a->authenticated = false;
|
| 38 | a->message = NULL;
|
| 39 | a->profile = NULL;
|
| 40 | a->posting = client->acl->post;
|
| 41 | a->bytes = 0;
|
| 42 | a->userkbit = 0;
|
| 43 |
|
| 44 | a->args = master->args;
|
| 45 | a->numargs = master->numargs;
|
| 46 |
|
| 47 | return a;
|
| 48 | }
|
| 49 |
|
| 50 |
|
| 51 | PROTO void free_authresult(AUTHRESULT *a)
|
| 52 | {
|
| 53 | free(a->username);
|
| 54 | free(a->password);
|
| 55 | free(a->hostname);
|
| 56 |
|
| 57 | /* FIXME: the strings from strippat can not be freed, so this is a memleak */
|
| 58 | // if ( a->username_s != NULL ) free(a->username_s);
|
| 59 |
|
| 60 | if ( a->logname != NULL ) free(a->logname);
|
| 61 | if ( a->profile != NULL ) free(a->profile);
|
| 62 | if ( a->message != NULL ) free(a->message);
|
| 63 | free(a);
|
| 64 | }
|
| 65 |
|
| 66 |
|
| 67 | /*
|
| 68 | * Authentication/Accounting Modules Operations
|
| 69 | */
|
| 70 |
|
| 71 | PROTO void (*find_auth_mod(char *name))()
|
| 72 | {
|
| 73 | int i;
|
| 74 |
|
| 75 | for(i = 0; i < sizeof(authmap) / sizeof(authmap[0]); i++)
|
| 76 | {
|
| 77 | if (strcmp(name, authmap[i].name) == 0)
|
| 78 | return authmap[i].ptr;
|
| 79 | }
|
| 80 |
|
| 81 | return NULL;
|
| 82 | }
|
| 83 |
|
| 84 |
|
| 85 | PROTO void (*find_acct_mod(char *name))()
|
| 86 | {
|
| 87 | int i;
|
| 88 |
|
| 89 | for(i = 0; i < sizeof(acctmap) / sizeof(acctmap[0]); i++)
|
| 90 | {
|
| 91 | if (strcmp(name, acctmap[i].name) == 0)
|
| 92 | return acctmap[i].ptr;
|
| 93 | }
|
| 94 |
|
| 95 | return NULL;
|
| 96 | }
|
| 97 |
|