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