]> jfr.im git - irc/evilnet/x3.git/blame - src/nickserv.h
Added an error check to help trace users figure out mistakes with mark vs marked
[irc/evilnet/x3.git] / src / nickserv.h
CommitLineData
d76ed9a9 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 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 */
39d37f27 25#include "dict.h"
e166c31b 26#include <tre/regex.h> /* for regex in nickserv_config */
d76ed9a9 27struct svccmd;
28
a32da4c7 29#define NICKSERV_HANDLE_LEN ACCOUNTLEN
d76ed9a9 30#define COOKIELEN 10
31
32/* HI_FLAG_* go into handle_info.flags */
33#define HI_FLAG_OPER_SUSPENDED 0x00000001
34#define HI_FLAG_USE_PRIVMSG 0x00000002
35#define HI_FLAG_SUPPORT_HELPER 0x00000004
36#define HI_FLAG_HELPING 0x00000008
37#define HI_FLAG_SUSPENDED 0x00000010
38#define HI_FLAG_MIRC_COLOR 0x00000020
39#define HI_FLAG_FROZEN 0x00000040
40#define HI_FLAG_NODELETE 0x00000080
41#define HI_FLAG_NETWORK_HELPER 0x00000100
42#define HI_FLAG_BOT 0x00000200
7fdb7639 43#define HI_FLAG_AUTOHIDE 0x00000400
bea3f934
MB
44#define HI_FLAG_IMPERSONATE 0x00000800
45#define HI_FLAG_ADVANCED 0x00001000
d76ed9a9 46/* Flag characters for the above. First char is LSB, etc. */
bea3f934 47#define HANDLE_FLAGS "SphgscfnHbxI"
d76ed9a9 48
49/* HI_STYLE_* go into handle_info.userlist_style */
338a82b5 50#define HI_STYLE_NORMAL 'n'
51#define HI_STYLE_CLEAN 'c'
52#define HI_STYLE_ADVANCED 'a'
d9896a83 53#define HI_STYLE_CLASSIC 'k'
d76ed9a9 54
55#define HI_DEFAULT_FLAGS (HI_FLAG_MIRC_COLOR)
338a82b5 56
57/* This is overridden by conf file */
58#define HI_DEFAULT_STYLE HI_STYLE_NORMAL
d76ed9a9 59
60#define HANDLE_FLAGGED(hi, tok) ((hi)->flags & HI_FLAG_##tok)
61#define HANDLE_SET_FLAG(hi, tok) ((hi)->flags |= HI_FLAG_##tok)
62#define HANDLE_TOGGLE_FLAG(hi, tok) ((hi)->flags ^= HI_FLAG_##tok)
63#define HANDLE_CLEAR_FLAG(hi, tok) ((hi)->flags &= ~HI_FLAG_##tok)
64
65#define IsSupportHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, SUPPORT_HELPER))
66#define IsNetworkHelper(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, NETWORK_HELPER))
67#define IsHelper(user) (IsSupportHelper(user) || IsNetworkHelper(user))
68#define IsHelping(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, HELPING))
69#define IsStaff(user) (IsOper(user) || IsSupportHelper(user) || IsNetworkHelper(user))
70#define IsBot(user) (user->handle_info && HANDLE_FLAGGED(user->handle_info, BOT))
71
72enum cookie_type {
73 ACTIVATION,
74 PASSWORD_CHANGE,
75 EMAIL_CHANGE,
76 ALLOWAUTH
77};
78
79struct handle_cookie {
80 struct handle_info *hi;
81 char *data;
82 enum cookie_type type;
83 time_t expires;
84 char cookie[COOKIELEN+1];
85};
86
2362161a 87struct handle_note {
0f6fe38c 88 char setter[NICKSERV_HANDLE_LEN+1];
89 time_t date;
90 char note[1];
2362161a 91};
92
d76ed9a9 93struct handle_info {
94 struct nick_info *nicks;
95 struct string_list *masks;
2fa83595 96 struct string_list *sslfps;
5177fd21 97 struct string_list *ignores;
d76ed9a9 98 struct userNode *users;
99 struct userData *channels;
100 struct handle_cookie *cookie;
2362161a 101 struct handle_note *note;
d76ed9a9 102 struct language *language;
103 char *email_addr;
104 char *epithet;
105 char *infoline;
106 char *handle;
107 char *fakehost;
d76ed9a9 108 time_t registered;
109 time_t lastseen;
1136f709 110 int karma;
d76ed9a9 111 unsigned short flags;
112 unsigned short opserv_level;
113 unsigned short screen_width;
114 unsigned short table_width;
115 unsigned char userlist_style;
0f6fe38c 116 unsigned char announcements;
d76ed9a9 117 unsigned char maxlogins;
118 char passwd[MD5_CRYPT_LENGTH+1];
119 char last_quit_host[USERLEN+HOSTLEN+2];
120};
121
122struct nick_info {
123 struct handle_info *owner;
124 struct nick_info *next; /* next nick owned by same handle */
125 char nick[NICKLEN+1];
ae275267
MB
126 time_t registered;
127 time_t lastseen;
d76ed9a9 128};
129
130struct handle_info_list {
131 unsigned int used, size;
132 struct handle_info **list;
133 char *tag; /* e.g. email address */
134};
135
136extern const char *handle_flags;
137
e166c31b 138enum reclaim_action {
139 RECLAIM_NONE,
140 RECLAIM_WARN,
141 RECLAIM_SVSNICK,
142 RECLAIM_KILL
143};
144
145struct nickserv_config {
146 unsigned int disable_nicks : 1;
147 unsigned int valid_handle_regex_set : 1;
148 unsigned int valid_nick_regex_set : 1;
149 unsigned int valid_fakehost_regex_set : 1;
150 unsigned int autogag_enabled : 1;
151 unsigned int email_enabled : 1;
152 unsigned int email_required : 1;
153 unsigned int default_hostmask : 1;
154 unsigned int warn_nick_owned : 1;
155 unsigned int warn_clone_auth : 1;
156 unsigned int sync_log : 1;
ae275267 157 unsigned int expire_nicks : 1;
e166c31b 158 unsigned long nicks_per_handle;
159 unsigned long password_min_length;
160 unsigned long password_min_digits;
161 unsigned long password_min_upper;
162 unsigned long password_min_lower;
163 unsigned long db_backup_frequency;
164 unsigned long handle_expire_frequency;
165 unsigned long autogag_duration;
166 unsigned long email_visible_level;
167 unsigned long cookie_timeout;
168 unsigned long handle_expire_delay;
169 unsigned long nochan_handle_expire_delay;
170 unsigned long modoper_level;
171 unsigned long set_epithet_level;
172 unsigned long set_title_level;
173 unsigned long set_fakehost_level;
174 unsigned long handles_per_email;
175 unsigned long email_search_level;
ae275267
MB
176 unsigned long nick_expire_frequency;
177 unsigned long nick_expire_delay;
e166c31b 178 const char *network_name;
179 const char *titlehost_suffix;
180 regex_t valid_handle_regex;
181 regex_t valid_nick_regex;
182 regex_t valid_fakehost_regex;
183 dict_t weak_password_dict;
184 struct policer_params *auth_policer_params;
185 enum reclaim_action reclaim_action;
186 enum reclaim_action auto_reclaim_action;
187 unsigned long auto_reclaim_delay;
188 unsigned char default_maxlogins;
189 unsigned char hard_maxlogins;
1136f709 190 unsigned long ounregister_inactive;
191 unsigned long ounregister_flags;
e166c31b 192 const char *auto_oper;
193 const char *auto_admin;
6ae87c77 194 const char *auto_oper_privs;
195 const char *auto_admin_privs;
e166c31b 196 char default_style;
197 struct string_list *denied_fakehost_words;
acb142f0 198 unsigned int force_handles_lowercase;
e166c31b 199 unsigned int ldap_enable;
39edf54a 200#ifdef WITH_LDAP
bec5dd26 201 const char *ldap_uri;
e166c31b 202 const char *ldap_base;
203 const char *ldap_dn_fmt;
204 unsigned int ldap_version;
205 unsigned int ldap_autocreate;
ea02341b 206
207 const char *ldap_admin_dn;
208 const char *ldap_admin_pass;
209 const char *ldap_field_account;
210 const char *ldap_field_password;
211 const char *ldap_field_email;
35ea100f 212 const char *ldap_field_oslevel;
73d4cc91 213 struct string_list *ldap_object_classes;
8a729617 214 const char *ldap_oper_group_dn;
17d4a698 215 unsigned int ldap_oper_group_level;
8a729617 216 const char *ldap_field_group_member;
ddcb3eb3 217 unsigned int ldap_timeout;
39edf54a 218#endif
e166c31b 219};
220
d76ed9a9 221void init_nickserv(const char *nick);
222struct handle_info *get_handle_info(const char *handle);
223struct handle_info *smart_get_handle_info(struct userNode *service, struct userNode *user, const char *name);
224int oper_try_set_access(struct userNode *user, struct userNode *bot, struct handle_info *target, unsigned int new_level);
1136f709 225int oper_outranks(struct userNode *user, struct handle_info *hi);
d76ed9a9 226struct nick_info *get_nick_info(const char *nick);
227struct modeNode *find_handle_in_channel(struct chanNode *channel, struct handle_info *handle, struct userNode *except);
228int nickserv_modify_handle_flags(struct userNode *user, struct userNode *bot, const char *str, unsigned long *add, unsigned long *remove);
229int oper_has_access(struct userNode *user, struct userNode *bot, unsigned int min_level, unsigned int quiet);
230void nickserv_show_oper_accounts(struct userNode *user, struct svccmd *cmd);
231
1136f709 232struct handle_info *get_victim_oper(struct userNode *user, const char *target);
1679a283 233struct handle_info *loc_auth(char *sslfp, char *handle, char *password, char *userhost);
d9cd0e9d 234
3a196bdb 235typedef void (*user_mode_func_t)(struct userNode *user, const char *mode_change, void *extra);
236void reg_user_mode_func(user_mode_func_t func, void *extra);
ee8c50bd 237typedef void (*channel_mode_func_t)(struct userNode *who, struct chanNode *channel, char **mode, unsigned int argc, void *extra);
238void reg_channel_mode_func(channel_mode_func_t func, void *extra);
ec311f39 239
d76ed9a9 240/* auth_funcs are called when a user gets a new handle_info. They are
241 * called *after* user->handle_info has been updated. */
81ac4787 242typedef void (*auth_func_t)(struct userNode *user, struct handle_info *old_handle, void *extra);
243void reg_auth_func(auth_func_t func, void *extra);
d76ed9a9 244
245/* Called just after a handle is renamed. */
3070719a 246typedef void (*handle_rename_func_t)(struct handle_info *handle, const char *old_handle, void *extra);
247void reg_handle_rename_func(handle_rename_func_t func, void *extra);
d76ed9a9 248
249/* unreg_funcs are called right before a handle is unregistered.
250 * `user' is the person who caused the handle to be unregistered (either a
251 * client authed to the handle, or an oper). */
974d3831 252typedef void (*unreg_func_t)(struct userNode *user, struct handle_info *handle, void *extra);
253void reg_unreg_func(unreg_func_t func, void *extra);
d76ed9a9 254
255/* Called just before a handle is merged */
50dafce8 256typedef void (*handle_merge_func_t)(struct userNode *user, struct handle_info *handle_to, struct handle_info *handle_from, void *extra);
257void reg_handle_merge_func(handle_merge_func_t, void *extra);
d76ed9a9 258
259/* Called after an allowauth. handle is null if allowauth authorization was
260 * removed */
99c332f8 261typedef void (*allowauth_func_t)(struct userNode *user, struct userNode *target, struct handle_info *handle, void *extra);
262void reg_allowauth_func(allowauth_func_t func, void *extra);
d76ed9a9 263
264/* Called when an auth attempt fails because of a bad password */
c8b793cb 265typedef void (*failpw_func_t)(struct userNode *user, struct handle_info *handle, void *extra);
266void reg_failpw_func(failpw_func_t func, void *extra);
d76ed9a9 267
3fdd6a74 268void send_func_list(struct userNode *user);
269
39d37f27 270extern dict_t nickserv_handle_dict;
271
d76ed9a9 272#endif