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