]>
Commit | Line | Data |
---|---|---|
d76ed9a9 AS |
1 | /* nickserv.h - Nick/authentiction service |
2 | * Copyright 2000-2004 srvx Development Team | |
3 | * | |
83ff05c3 | 4 | * This file is part of x3. |
d76ed9a9 | 5 | * |
d0f04f71 | 6 | * x3 is free software; you can redistribute it and/or modify |
d76ed9a9 | 7 | * it under the terms of the GNU General Public License as published by |
348683aa | 8 | * the Free Software Foundation; either version 3 of the License, or |
d76ed9a9 AS |
9 | * (at your option) any later version. |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with srvx; if not, write to the Free Software Foundation, | |
18 | * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. | |
19 | */ | |
20 | ||
21 | #ifndef _nickserv_h | |
22 | #define _nickserv_h | |
23 | ||
24 | #include "hash.h" /* for NICKLEN, etc., and common.h */ | |
e166c31b | 25 | #include <tre/regex.h> /* for regex in nickserv_config */ |
d76ed9a9 AS |
26 | struct svccmd; |
27 | ||
a32da4c7 | 28 | #define NICKSERV_HANDLE_LEN ACCOUNTLEN |
d76ed9a9 AS |
29 | #define COOKIELEN 10 |
30 | ||
31 | /* HI_FLAG_* go into handle_info.flags */ | |
32 | #define HI_FLAG_OPER_SUSPENDED 0x00000001 | |
33 | #define HI_FLAG_USE_PRIVMSG 0x00000002 | |
34 | #define HI_FLAG_SUPPORT_HELPER 0x00000004 | |
35 | #define HI_FLAG_HELPING 0x00000008 | |
36 | #define HI_FLAG_SUSPENDED 0x00000010 | |
37 | #define HI_FLAG_MIRC_COLOR 0x00000020 | |
38 | #define HI_FLAG_FROZEN 0x00000040 | |
39 | #define HI_FLAG_NODELETE 0x00000080 | |
40 | #define HI_FLAG_NETWORK_HELPER 0x00000100 | |
41 | #define HI_FLAG_BOT 0x00000200 | |
7fdb7639 | 42 | #define HI_FLAG_AUTOHIDE 0x00000400 |
0b587959 | 43 | #define HI_FLAG_ADVANCED 0x00000800 |
d76ed9a9 | 44 | /* Flag characters for the above. First char is LSB, etc. */ |
7fdb7639 | 45 | #define HANDLE_FLAGS "SphgscfnHbx" |
d76ed9a9 AS |
46 | |
47 | /* HI_STYLE_* go into handle_info.userlist_style */ | |
338a82b5 AS |
48 | #define HI_STYLE_NORMAL 'n' |
49 | #define HI_STYLE_CLEAN 'c' | |
50 | #define HI_STYLE_ADVANCED 'a' | |
d9896a83 | 51 | #define HI_STYLE_CLASSIC 'k' |
d76ed9a9 AS |
52 | |
53 | #define HI_DEFAULT_FLAGS (HI_FLAG_MIRC_COLOR) | |
338a82b5 AS |
54 | |
55 | /* This is overridden by conf file */ | |
56 | #define HI_DEFAULT_STYLE HI_STYLE_NORMAL | |
d76ed9a9 AS |
57 | |
58 | #define HANDLE_FLAGGED(hi, tok) ((hi)->flags & HI_FLAG_##tok) | |
59 | #define HANDLE_SET_FLAG(hi, tok) ((hi)->flags |= HI_FLAG_##tok) | |
60 | #define HANDLE_TOGGLE_FLAG(hi, tok) ((hi)->flags ^= HI_FLAG_##tok) | |
61 | #define HANDLE_CLEAR_FLAG(hi, tok) ((hi)->flags &= ~HI_FLAG_##tok) | |
62 | ||
63 | #define IsSupportHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, SUPPORT_HELPER)) | |
64 | #define IsNetworkHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, NETWORK_HELPER)) | |
65 | #define IsHelper(user) (IsSupportHelper(user) || IsNetworkHelper(user)) | |
66 | #define IsHelping(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, HELPING)) | |
67 | #define IsStaff(user) (IsOper(user) || IsSupportHelper(user) || IsNetworkHelper(user)) | |
68 | #define IsBot(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, BOT)) | |
69 | ||
70 | enum cookie_type { | |
71 | ACTIVATION, | |
72 | PASSWORD_CHANGE, | |
73 | EMAIL_CHANGE, | |
74 | ALLOWAUTH | |
75 | }; | |
76 | ||
77 | struct handle_cookie { | |
78 | struct handle_info *hi; | |
79 | char *data; | |
80 | enum cookie_type type; | |
81 | time_t expires; | |
82 | char cookie[COOKIELEN+1]; | |
83 | }; | |
84 | ||
2362161a | 85 | struct handle_note { |
0f6fe38c | 86 | char setter[NICKSERV_HANDLE_LEN+1]; |
87 | time_t date; | |
88 | char note[1]; | |
2362161a | 89 | }; |
90 | ||
d76ed9a9 AS |
91 | struct handle_info { |
92 | struct nick_info *nicks; | |
93 | struct string_list *masks; | |
5177fd21 | 94 | struct string_list *ignores; |
d76ed9a9 AS |
95 | struct userNode *users; |
96 | struct userData *channels; | |
97 | struct handle_cookie *cookie; | |
2362161a | 98 | struct handle_note *note; |
d76ed9a9 AS |
99 | struct language *language; |
100 | char *email_addr; | |
101 | char *epithet; | |
102 | char *infoline; | |
103 | char *handle; | |
104 | char *fakehost; | |
d76ed9a9 AS |
105 | time_t registered; |
106 | time_t lastseen; | |
107 | unsigned short flags; | |
108 | unsigned short opserv_level; | |
109 | unsigned short screen_width; | |
110 | unsigned short table_width; | |
111 | unsigned char userlist_style; | |
0f6fe38c | 112 | unsigned char announcements; |
d76ed9a9 AS |
113 | unsigned char maxlogins; |
114 | char passwd[MD5_CRYPT_LENGTH+1]; | |
115 | char last_quit_host[USERLEN+HOSTLEN+2]; | |
116 | }; | |
117 | ||
118 | struct nick_info { | |
119 | struct handle_info *owner; | |
120 | struct nick_info *next; /* next nick owned by same handle */ | |
121 | char nick[NICKLEN+1]; | |
122 | }; | |
123 | ||
124 | struct handle_info_list { | |
125 | unsigned int used, size; | |
126 | struct handle_info **list; | |
127 | char *tag; /* e.g. email address */ | |
128 | }; | |
129 | ||
130 | extern const char *handle_flags; | |
131 | ||
e166c31b AS |
132 | enum reclaim_action { |
133 | RECLAIM_NONE, | |
134 | RECLAIM_WARN, | |
135 | RECLAIM_SVSNICK, | |
136 | RECLAIM_KILL | |
137 | }; | |
138 | ||
139 | struct nickserv_config { | |
140 | unsigned int disable_nicks : 1; | |
141 | unsigned int valid_handle_regex_set : 1; | |
142 | unsigned int valid_nick_regex_set : 1; | |
143 | unsigned int valid_fakehost_regex_set : 1; | |
144 | unsigned int autogag_enabled : 1; | |
145 | unsigned int email_enabled : 1; | |
146 | unsigned int email_required : 1; | |
147 | unsigned int default_hostmask : 1; | |
148 | unsigned int warn_nick_owned : 1; | |
149 | unsigned int warn_clone_auth : 1; | |
150 | unsigned int sync_log : 1; | |
151 | unsigned long nicks_per_handle; | |
152 | unsigned long password_min_length; | |
153 | unsigned long password_min_digits; | |
154 | unsigned long password_min_upper; | |
155 | unsigned long password_min_lower; | |
156 | unsigned long db_backup_frequency; | |
157 | unsigned long handle_expire_frequency; | |
158 | unsigned long autogag_duration; | |
159 | unsigned long email_visible_level; | |
160 | unsigned long cookie_timeout; | |
161 | unsigned long handle_expire_delay; | |
162 | unsigned long nochan_handle_expire_delay; | |
163 | unsigned long modoper_level; | |
164 | unsigned long set_epithet_level; | |
165 | unsigned long set_title_level; | |
166 | unsigned long set_fakehost_level; | |
167 | unsigned long handles_per_email; | |
168 | unsigned long email_search_level; | |
169 | const char *network_name; | |
170 | const char *titlehost_suffix; | |
171 | regex_t valid_handle_regex; | |
172 | regex_t valid_nick_regex; | |
173 | regex_t valid_fakehost_regex; | |
174 | dict_t weak_password_dict; | |
175 | struct policer_params *auth_policer_params; | |
176 | enum reclaim_action reclaim_action; | |
177 | enum reclaim_action auto_reclaim_action; | |
178 | unsigned long auto_reclaim_delay; | |
179 | unsigned char default_maxlogins; | |
180 | unsigned char hard_maxlogins; | |
181 | const char *auto_oper; | |
182 | const char *auto_admin; | |
183 | char default_style; | |
184 | struct string_list *denied_fakehost_words; | |
acb142f0 | 185 | unsigned int force_handles_lowercase; |
e166c31b | 186 | unsigned int ldap_enable; |
39edf54a | 187 | #ifdef WITH_LDAP |
bec5dd26 | 188 | const char *ldap_uri; |
e166c31b AS |
189 | const char *ldap_base; |
190 | const char *ldap_dn_fmt; | |
191 | unsigned int ldap_version; | |
192 | unsigned int ldap_autocreate; | |
ea02341b AS |
193 | |
194 | const char *ldap_admin_dn; | |
195 | const char *ldap_admin_pass; | |
196 | const char *ldap_field_account; | |
197 | const char *ldap_field_password; | |
198 | const char *ldap_field_email; | |
73d4cc91 | 199 | struct string_list *ldap_object_classes; |
8a729617 | 200 | const char *ldap_oper_group_dn; |
17d4a698 | 201 | unsigned int ldap_oper_group_level; |
8a729617 | 202 | const char *ldap_field_group_member; |
ddcb3eb3 | 203 | unsigned int ldap_timeout; |
39edf54a | 204 | #endif |
e166c31b AS |
205 | }; |
206 | ||
d76ed9a9 AS |
207 | void init_nickserv(const char *nick); |
208 | struct handle_info *get_handle_info(const char *handle); | |
209 | struct handle_info *smart_get_handle_info(struct userNode *service, struct userNode *user, const char *name); | |
210 | int oper_try_set_access(struct userNode *user, struct userNode *bot, struct handle_info *target, unsigned int new_level); | |
c092fcad | 211 | int oper_outranks(struct svccmd *cmd, struct userNode *user, struct handle_info *hi); |
d76ed9a9 AS |
212 | struct nick_info *get_nick_info(const char *nick); |
213 | struct modeNode *find_handle_in_channel(struct chanNode *channel, struct handle_info *handle, struct userNode *except); | |
214 | int nickserv_modify_handle_flags(struct userNode *user, struct userNode *bot, const char *str, unsigned long *add, unsigned long *remove); | |
215 | int oper_has_access(struct userNode *user, struct userNode *bot, unsigned int min_level, unsigned int quiet); | |
216 | void nickserv_show_oper_accounts(struct userNode *user, struct svccmd *cmd); | |
217 | ||
c092fcad | 218 | struct handle_info *get_victim_oper(struct svccmd *cmd, struct userNode *user, const char *target); |
7dd05763 | 219 | struct handle_info *loc_auth(char *handle, char *password, char *userhost); |
d9cd0e9d | 220 | |
ec311f39 | 221 | typedef void (*user_mode_func_t)(struct userNode *user, const char *mode_change); |
222 | void reg_user_mode_func(user_mode_func_t func); | |
223 | typedef void (*channel_mode_func_t)(struct userNode *who, struct chanNode *channel, char **mode, unsigned int argc); | |
224 | void reg_channel_mode_func(channel_mode_func_t func); | |
225 | ||
d76ed9a9 AS |
226 | /* auth_funcs are called when a user gets a new handle_info. They are |
227 | * called *after* user->handle_info has been updated. */ | |
228 | typedef void (*auth_func_t)(struct userNode *user, struct handle_info *old_handle); | |
229 | void reg_auth_func(auth_func_t func); | |
230 | ||
231 | /* Called just after a handle is renamed. */ | |
232 | typedef void (*handle_rename_func_t)(struct handle_info *handle, const char *old_handle); | |
233 | void reg_handle_rename_func(handle_rename_func_t func); | |
234 | ||
235 | /* unreg_funcs are called right before a handle is unregistered. | |
236 | * `user' is the person who caused the handle to be unregistered (either a | |
237 | * client authed to the handle, or an oper). */ | |
238 | typedef void (*unreg_func_t)(struct userNode *user, struct handle_info *handle); | |
239 | void reg_unreg_func(unreg_func_t func); | |
240 | ||
241 | /* Called just before a handle is merged */ | |
242 | typedef void (*handle_merge_func_t)(struct userNode *user, struct handle_info *handle_to, struct handle_info *handle_from); | |
243 | void reg_handle_merge_func(handle_merge_func_t); | |
244 | ||
245 | /* Called after an allowauth. handle is null if allowauth authorization was | |
246 | * removed */ | |
247 | typedef void (*allowauth_func_t)(struct userNode *user, struct userNode *target, struct handle_info *handle); | |
248 | void reg_allowauth_func(allowauth_func_t func); | |
249 | ||
250 | /* Called when an auth attempt fails because of a bad password */ | |
251 | typedef void (*failpw_func_t)(struct userNode *user, struct handle_info *handle); | |
252 | void reg_failpw_func(failpw_func_t func); | |
253 | ||
3fdd6a74 | 254 | void send_func_list(struct userNode *user); |
255 | ||
d76ed9a9 | 256 | #endif |