#define KEY_SET_EPITHET_LEVEL "set_epithet_level"
#define KEY_SET_TITLE_LEVEL "set_title_level"
#define KEY_SET_FAKEHOST_LEVEL "set_fakehost_level"
+#define KEY_SET_FAKEIDENT_LEVEL "set_fakeident_level"
#define KEY_TITLEHOST_SUFFIX "titlehost_suffix"
#define KEY_FLAG_LEVELS "flag_levels"
#define KEY_HANDLE_EXPIRE_FREQ "handle_expire_freq"
#define KEY_OUNREGISTER_INACTIVE "ounregister_inactive"
#define KEY_OUNREGISTER_FLAGS "ounregister_flags"
#define KEY_HANDLE_TS_MODE "account_timestamp_mode"
+#define KEY_MAX_AUTHLOG_LEN "max_authlog_len"
#define KEY_ID "id"
#define KEY_PASSWD "passwd"
#define KEY_REGISTER_ON "register"
#define KEY_LAST_SEEN "lastseen"
#define KEY_INFO "info"
+#define KEY_DEVNULL "devnull"
+#define KEY_WEBSITE "website"
#define KEY_USERLIST_STYLE "user_style"
#define KEY_SCREEN_WIDTH "screen_width"
#define KEY_LAST_AUTHED_HOST "last_authed_host"
#define KEY_TABLE_WIDTH "table_width"
#define KEY_MAXLOGINS "maxlogins"
#define KEY_FAKEHOST "fakehost"
+#define KEY_FAKEIDENT "fakeident"
#define KEY_NOTES "notes"
#define KEY_NOTE_EXPIRES "expires"
#define KEY_NOTE_SET "set"
#define KEY_NOTE_SETTER "setter"
#define KEY_NOTE_NOTE "note"
#define KEY_KARMA "karma"
+#define KEY_AUTHLOG "authlog"
+#define KEY_AUTHLOG_LOGIN_TIME "login_time"
+#define KEY_AUTHLOG_LOGOUT_TIME "logout_time"
+#define KEY_AUTHLOG_HOSTMASK "hostmask"
+#define KEY_AUTHLOG_QUIT_REASON "quit_reason"
#define NICKSERV_VALID_CHARS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_"
{ "NSMSG_STAMPED_AUTHCOOKIE", "You have already authenticated to an account once this session; you may not use a cookie to authenticate to another account." },
{ "NSMSG_TITLE_INVALID", "Titles cannot contain any dots; please choose another." },
{ "NSMSG_TITLE_TRUNCATED", "That title combined with the user's account name would result in a truncated host; please choose a shorter title." },
+ { "NSMSG_TITLE_TRUNCATED_RENAME", "That account name combined with the user's title would result in a truncated host; please choose a shorter account name." },
{ "NSMSG_FAKEHOST_INVALID", "Fake hosts must be shorter than %d characters and cannot start with a dot." },
+ { "NSMSG_FAKEIDENT_INVALID", "Fake idents must be shorter than %d characters." },
+ { "NSMSG_FAKEMASK_INVALID", "Fake ident@hosts must be shorter than %d characters." },
{ "NSMSG_HANDLEINFO_ON", "Account information for $b%s$b:" },
{ "NSMSG_HANDLEINFO_ID", " Account ID: %lu" },
{ "NSMSG_HANDLEINFO_REGGED", " Registered on: %s" },
{ "NSMSG_HANDLEINFO_COOKIE_ALLOWAUTH", " Cookie: There is currently an allowauth cookie issued for this account" },
{ "NSMSG_HANDLEINFO_COOKIE_UNKNOWN", " Cookie: There is currently an unknown cookie issued for this account" },
{ "NSMSG_HANDLEINFO_INFOLINE", " Infoline: %s" },
+ { "NSMSG_HANDLEINFO_DEVNULL", " DevNull Class: %s" },
+ { "NSMSG_HANDLEINFO_WEBSITE", " Website: %s" },
+ { "NSMSG_HANDLEINFO_ACCESS", " Access: %i" },
{ "NSMSG_HANDLEINFO_FLAGS", " Flags: %s" },
{ "NSMSG_HANDLEINFO_EPITHET", " Epithet: %s" },
+ { "NSMSG_HANDLEINFO_FAKEIDENT", " Fake ident: %s" },
{ "NSMSG_HANDLEINFO_FAKEHOST", " Fake host: %s" },
+ { "NSMSG_HANDLEINFO_FAKEIDENTHOST", " Fake host: %s@%s" },
{ "NSMSG_HANDLEINFO_LAST_HOST", " Last quit hostmask: %s" },
{ "NSMSG_HANDLEINFO_NO_NOTES", " Notes: None" },
{ "NSMSG_HANDLEINFO_NOTE_EXPIRES", " Note %d (%s ago by %s, expires %s): %s" },
{ "NSMSG_SETTING_LIST", "$b$N account settings:$b" },
{ "NSMSG_INVALID_OPTION", "$b%s$b is an invalid account setting." },
{ "NSMSG_SET_INFO", "$bINFO: $b%s" },
+ { "NSMSG_SET_DEVNULL", "$bDEVNULL: $b%s" },
+ { "NSMSG_SET_AUTOHIDE", "$bAUTOHIDE: $b%s" },
+ { "NSMSG_SET_WEBSITE", "$bWEBSITE: $b%s" },
{ "NSMSG_SET_WIDTH", "$bWIDTH: $b%d" },
{ "NSMSG_SET_TABLEWIDTH", "$bTABLEWIDTH: $b%d" },
{ "NSMSG_SET_COLOR", "$bCOLOR: $b%s" },
{ "NSMSG_SET_EPITHET", "$bEPITHET: $b%s" },
{ "NSMSG_SET_TITLE", "$bTITLE: $b%s" },
{ "NSMSG_SET_FAKEHOST", "$bFAKEHOST: $b%s" },
+ { "NSMSG_SET_FAKEIDENT", "$bFAKEIDENT: $b%s" },
+ { "NSMSG_SET_FAKEIDENTHOST", "$bFAKEHOST: $b%s@%s" },
{ "NSMSG_INVALID_KARMA", "$b%s$b is not a valid karma modifier." },
{ "NSMSG_SET_KARMA", "$bKARMA: $b%d$b" },
{ "NSEMAIL_ACTIVATION_SUBJECT", "Account verification for %s" },
unsigned long set_epithet_level;
unsigned long set_title_level;
unsigned long set_fakehost_level;
+ unsigned long set_fakeident_level;
unsigned long handles_per_email;
unsigned long email_search_level;
const char *network_name;
- const char *titlehost_suffix;
regex_t valid_handle_regex;
regex_t valid_nick_regex;
dict_t weak_password_dict;
unsigned char hard_maxlogins;
unsigned long ounregister_inactive;
unsigned long ounregister_flags;
+ unsigned int max_authlog_len;
} nickserv_conf;
+struct pendingLOCUser {
+ struct handle_info *handle_info;
+ unsigned long time;
+ struct authlogEntry *authlog;
+ struct pendingLOCUser *next;
+};
+
+const char *titlehost_suffix = NULL;
+static struct pendingLOCUser *pendingLOCUsers = NULL;
+
/* We have 2^32 unique account IDs to use. */
unsigned long int highest_id = 0;
dict_insert(nickserv_handle_dict, hi->handle, hi);
hi->id = id;
+ hi->website = NULL;
+ hi->devnull = NULL;
dict_insert(nickserv_id_dict, strdup(id_base64), hi);
return hi;
free(hi->infoline);
free(hi->epithet);
free(hi->fakehost);
+ free(hi->devnull);
+ free(hi->website);
+ free(hi->fakeident);
if (hi->cookie) {
timeq_del(hi->cookie->expires, nickserv_free_cookie, hi->cookie, 0);
nickserv_free_cookie(hi->cookie);
if (!hil->used)
dict_remove(nickserv_email_dict, hi->email_addr);
}
+ struct authlogEntry *authlog, *next;
+ for(authlog = hi->authlog; authlog; authlog = next) {
+ next = authlog->next;
+ struct pendingLOCUser *pending, *prev_pending = NULL;
+ for(pending = pendingLOCUsers; pending; pending = pending->next) {
+ if(pending->authlog == authlog) {
+ if(prev_pending)
+ prev_pending->next = pending->next;
+ else
+ pendingLOCUsers = pending->next;
+ free(pending);
+ break;
+ }
+ prev_pending = pending;
+ }
+ free((char *) authlog->hostmask);
+ if(authlog->quit_reason)
+ free((char *) authlog->quit_reason);
+ free(authlog);
+ }
free(hi);
}
}
static int
-is_valid_email_addr(const char *email)
+is_valid_email_addr(const char *org_email)
{
- return strchr(email, '@') != NULL;
+ char email[strlen(org_email)+1];
+ strcpy(email, org_email);
+ //validate email address
+ //1st check: there need to be one @
+ char *p1 = strchr(email, '@');
+ if(!p1 || strchr(p1+1, '@')) return 0;
+ *p1 = '\0';
+ //2nd check: username (bevore @) must be at least 1 char long and out of part_chars
+ char *part_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._%+-";
+ int i;
+ if(p1 - email == 0) return 0;
+ for(i = 0; i < (p1 - email); i++) {
+ if(!strchr(part_chars, email[i])) return 0;
+ }
+ //3rd check: there need to be at least 1 dot in the domain part and all characters out of part_chars
+ part_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-";
+ char *p2 = NULL;
+ p1++;
+ i = 0;
+ while(*p1) {
+ if(*p1 == '.') {
+ if(!i) return 0;
+ i = 0;
+ p2 = p1;
+ } else if(!strchr(part_chars, *p1))
+ return 0;
+ else
+ i++;
+ p1++;
+ }
+ if(!p2) return 0;
+ //4th check: TLD must be <= 5 chars, no special chars
+ i = 0;
+ p2++;
+ while(*p2) {
+ if(!isalpha(*p2))
+ return 0;
+ else
+ i++;
+ p2++;
+ }
+ if(i > 5) return 0;
+ return 1;
}
static const char *
unsigned int ii;
/* If no hostmasks on the account, allow it. */
- if (!hi->masks->used)
+ if (!hi->masks->used || IsDummy(user))
return 1;
/* If any hostmask matches, allow it. */
for (ii=0; ii<hi->masks->used; ii++)
return buffer;
} else if (handle->fakehost[0] == '.') {
/* A leading dot indicates the stored value is actually a title. */
- snprintf(buffer, sizeof(buffer), "%s.%s.%s", handle->handle, handle->fakehost+1, nickserv_conf.titlehost_suffix);
+ snprintf(buffer, sizeof(buffer), "%s.%s.%s", handle->handle, handle->fakehost+1, titlehost_suffix);
+ return buffer;
+ } else if (handle->fakehost[0] == '$') {
+ /* A leading $ indicates the stored value begins with the user handle. */
+ snprintf(buffer, sizeof(buffer), "%s%s", handle->handle, handle->fakehost+1);
return buffer;
}
return handle->fakehost;
}
+static char *
+generate_fakeident(struct handle_info *handle, struct userNode *user)
+{
+ static char buffer[USERLEN+1];
+
+ if (!handle->fakeident) {
+ if (!user)
+ return NULL;
+ safestrncpy(buffer, user->ident, sizeof(buffer));
+ return buffer;
+ }
+ return handle->fakeident;
+}
+
static void
-apply_fakehost(struct handle_info *handle)
+apply_fakehost(struct handle_info *handle, struct userNode *user)
{
struct userNode *target;
- char *fake;
+ char *fakehost, *fakeident;
if (!handle->users)
return;
- fake = generate_fakehost(handle);
- for (target = handle->users; target; target = target->next_authed)
- assign_fakehost(target, fake, 1);
+
+ fakehost = generate_fakehost(handle);
+
+ if (user) {
+ fakeident = generate_fakeident(handle, user);
+ assign_fakehost(user, fakehost, fakeident, 0, 1);
+ return;
+ }
+
+ for (target = handle->users; target; target = target->next_authed) {
+ fakeident = generate_fakeident(handle, target);
+ assign_fakehost(target, fakehost, fakeident, 0, 1);
+ }
}
static void
if (IsHelper(user) && !userList_contains(&curr_helpers, user))
userList_append(&curr_helpers, user);
- if (hi->fakehost || old_info)
- apply_fakehost(hi);
+ if (hi->fakehost || hi->fakeident || old_info)
+ apply_fakehost(hi, user);
if (stamp) {
if (!nickserv_conf.disable_nicks) {
char *mask;
struct userNode *settee;
struct handle_info *hi;
+ const char *pass, *email;
NICKSERV_MIN_PARMS(3);
+ pass = argv[2];
+ argv[2] = "****";
+
if (!is_valid_handle(argv[1])) {
reply("NSMSG_BAD_HANDLE", argv[1]);
return 0;
}
- if (argc < 4) {
+ if (argc < 5 || !nickserv_conf.email_enabled) {
+ email = NULL;
+ } else {
+ const char *str;
+ email = argv[4];
+ if (!is_valid_email_addr(email)) {
+ send_message(user, nickserv, "NSMSG_BAD_EMAIL_ADDR");
+ return 0;
+ }
+ if ((str = mail_prohibited_address(email))) {
+ send_message(user, nickserv, "NSMSG_EMAIL_PROHIBITED", email, str);
+ return 0;
+ }
+ }
+
+ if (argc < 4 || !strcmp(argv[3], "*")) {
mask = NULL;
settee = NULL;
} else if (strchr(argv[3], '@')) {
free(mask);
return 0;
}
- if (!(hi = nickserv_register(user, settee, argv[1], argv[2], 0))) {
+ if (!(hi = nickserv_register(user, settee, argv[1], pass, 0))) {
free(mask);
return 0;
}
if (mask)
string_list_append(hi->masks, mask);
+ if (email)
+ nickserv_set_email_addr(hi, email);
return 1;
}
}
reply("NSMSG_HANDLEINFO_INFOLINE", (hi->infoline ? hi->infoline : nsmsg_none));
+ if ((oper_has_access(user, cmd->parent->bot, 200, 1)) || IsNetworkHelper(user))
+ reply("NSMSG_HANDLEINFO_DEVNULL", (hi->devnull ? hi->devnull : nsmsg_none));
+ if (user->handle_info && HANDLE_FLAGGED(user->handle_info, BOT))
+ reply("NSMSG_HANDLEINFO_WEBSITE", (hi->website ? hi->website : nsmsg_none));
+ if(hi->opserv_level > 0 && user->handle_info && HANDLE_FLAGGED(user->handle_info, BOT))
+ reply("NSMSG_HANDLEINFO_ACCESS", hi->opserv_level);
if (HANDLE_FLAGGED(hi, FROZEN))
reply("NSMSG_HANDLEINFO_VACATION");
reply("NSMSG_HANDLEINFO_EPITHET", (hi->epithet ? hi->epithet : nsmsg_none));
}
- if (hi->fakehost)
- reply("NSMSG_HANDLEINFO_FAKEHOST", (hi->fakehost ? hi->fakehost : handle_find_message(hi, "MSG_NONE")));
+ if (hi->fakeident && hi->fakehost)
+ reply("NSMSG_HANDLEINFO_FAKEIDENTHOST", hi->fakeident, hi->fakehost);
+ else if (hi->fakeident)
+ reply("NSMSG_HANDLEINFO_FAKEIDENT", hi->fakeident);
+ else if (hi->fakehost)
+ reply("NSMSG_HANDLEINFO_FAKEHOST", hi->fakehost);
if (hi->last_quit_host[0])
reply("NSMSG_HANDLEINFO_LAST_HOST", hi->last_quit_host);
reply("NSMSG_HANDLE_EXISTS", argv[2]);
return 0;
}
+ if (hi->fakehost && hi->fakehost[0] == '.' &&
+ (strlen(argv[2]) + strlen(hi->fakehost+1) +
+ strlen(titlehost_suffix) + 2) > HOSTLEN) {
+ send_message(user, nickserv, "NSMSG_TITLE_TRUNCATED_RENAME");
+ return 0;
+ }
dict_remove2(nickserv_handle_dict, old_handle = hi->handle, 1);
hi->handle = strdup(argv[2]);
reply("NSMSG_HANDLE_CHANGED", old_handle, hi->handle);
global_message(MESSAGE_RECIPIENT_STAFF, msgbuf);
free(old_handle);
+ apply_fakehost(hi, NULL);
return 1;
}
failpw_func_list[failpw_func_used++] = func;
}
+static struct authlogEntry *authlog_add(struct handle_info *hi, struct userNode *user, const char *mask) {
+ if(!hi || (!user && !mask)) return NULL;
+ if(!mask)
+ mask = generate_hostmask(user, GENMASK_USENICK|GENMASK_STRICT_IDENT|GENMASK_NO_HIDING|GENMASK_STRICT_HOST);
+ struct authlogEntry *authlog, *next, *prev = NULL;
+ authlog = malloc(sizeof(*authlog));
+ authlog->login_time = now;
+ authlog->logout_time = 0;
+ authlog->hostmask = mask;
+ authlog->quit_reason = NULL;
+ authlog->user = user;
+ authlog->next = hi->authlog;
+ hi->authlog = authlog;
+ unsigned int i = 0;
+ for(authlog = hi->authlog; authlog; authlog = next) {
+ i++;
+ next = authlog->next;
+ if(i > nickserv_conf.max_authlog_len) {
+ struct pendingLOCUser *pending, *prev_pending = NULL;
+ for(pending = pendingLOCUsers; pending; pending = pending->next) {
+ if(pending->authlog == authlog) {
+ if(prev_pending)
+ prev_pending->next = pending->next;
+ else
+ pendingLOCUsers = pending->next;
+ free(pending);
+ break;
+ }
+ prev_pending = pending;
+ }
+ free((char *) authlog->hostmask);
+ if(authlog->quit_reason)
+ free((char *) authlog->quit_reason);
+ if(prev)
+ prev->next = authlog->next;
+ else
+ hi->authlog = authlog->next;
+ free(authlog);
+ } else
+ prev = authlog;
+ }
+ return hi->authlog;
+}
+
static NICKSERV_FUNC(cmd_auth)
{
int pw_arg, used, maxlogins;
return 1;
}
}
+ if (HANDLE_FLAGGED(hi, AUTOHIDE)) {
+ //ok we have a fakehost set... but we need to set mode +x
+ irc_svsmode(nickserv,user,"+x");
+ }
set_user_handle_info(user, hi, 1);
if (nickserv_conf.email_required && !hi->email_addr)
if (irc_in_addr_is_valid(user->ip) && irc_pton(&ip, NULL, user->hostname))
string_list_append(hi->masks, generate_hostmask(user, GENMASK_OMITNICK|GENMASK_BYIP|GENMASK_NO_HIDING|GENMASK_ANY_IDENT));
}
+ authlog_add(hi, user, NULL);
argv[pw_arg] = "****";
reply("NSMSG_AUTH_SUCCESS");
return 1;
}
+struct handle_info *checklogin(const char *user, const char *pass, const char *numeric, const char *hostmask, const char *ipmask)
+{
+ struct handle_info *hi;
+ unsigned int match = 0, ii = 0;
+ hi = dict_find(nickserv_handle_dict, user, NULL);
+ if(!hi)
+ return NULL;
+ /* If no hostmasks on the account, allow it. */
+ if (hi->masks->used) {
+ /* If any hostmask matches, allow it. */
+ for (ii=0; ii<hi->masks->used; ii++)
+ if (match_ircglob(hostmask, hi->masks->list[ii]) || match_ircglob(ipmask, hi->masks->list[ii])) {
+ match = 1;
+ break;
+ }
+ if(!match)
+ return NULL;
+ }
+ if(!checkpass(pass, hi->passwd))
+ return NULL;
+ if (HANDLE_FLAGGED(hi, SUSPENDED))
+ return NULL;
+ char *ptr = malloc(strlen(hostmask)+1);
+ strcpy(ptr, hostmask);
+ struct authlogEntry *authlog = authlog_add(hi, NULL, ptr);
+ struct pendingLOCUser *pending;
+ if(authlog && (pending = malloc(sizeof(*pending)))) {
+ pending->handle_info = hi;
+ pending->time = now;
+ pending->authlog = authlog;
+ pending->next = pendingLOCUsers;
+ pendingLOCUsers = pending;
+ }
+ return hi;
+}
+
+char *getfakehost(const char *user)
+{
+ struct handle_info *hi;
+ hi = dict_find(nickserv_handle_dict, user, NULL);
+ if(!hi)
+ return 0;
+ return generate_fakehost(hi);
+}
+
static allowauth_func_t *allowauth_func_list;
static unsigned int allowauth_func_size = 0, allowauth_func_used = 0;
allowauth_func_list[allowauth_func_used++] = func;
}
+static int cmd_authlog_func(struct userNode *user, struct svccmd *cmd, struct handle_info *hi);
+
+static MODCMD_FUNC(cmd_authlog)
+{
+ return cmd_authlog_func(user, cmd, user->handle_info);
+}
+
+static MODCMD_FUNC(cmd_oauthlog) {
+ struct handle_info *hi;
+
+ NICKSERV_MIN_PARMS(1);
+
+ if (!(hi = get_victim_oper(user, argv[1])))
+ return 0;
+
+ return cmd_authlog_func(user, cmd, hi);
+}
+
+static int cmd_authlog_func(struct userNode *user, struct svccmd *cmd, struct handle_info *hi) {
+ struct helpfile_table tbl;
+ struct authlogEntry *authlog;
+ int i = 0;
+
+ for(authlog = hi->authlog; authlog; authlog = authlog->next) {
+ i++;
+ }
+
+ tbl.length = i+1;
+ tbl.width = 4;
+ tbl.flags = 0;
+ tbl.flags = TABLE_NO_FREE;
+ tbl.contents = malloc(tbl.length * sizeof(tbl.contents[0]));
+ tbl.contents[0] = malloc(tbl.width * sizeof(tbl.contents[0][0]));
+ tbl.contents[0][0] = "Hostmask";
+ tbl.contents[0][1] = "Login";
+ tbl.contents[0][2] = "Logout";
+ tbl.contents[0][3] = "Quit Reason";
+
+ if(!tbl.length) {
+ table_send(cmd->parent->bot, user->nick, 0, NULL, tbl);
+ reply("MSG_NONE");
+ free(tbl.contents[0]);
+ free(tbl.contents);
+ return 0;
+ }
+
+ char *str, *ptr;
+ char intervalBuf[INTERVALLEN];
+ i = 0;
+ for(authlog = hi->authlog; authlog; authlog = authlog->next) {
+ tbl.contents[++i] = malloc(tbl.width * sizeof(tbl.contents[0][0]));
+ tbl.contents[i][0] = authlog->hostmask;
+ str = intervalString(intervalBuf, now - authlog->login_time, hi);
+ ptr = malloc(strlen(str)+1);
+ strcpy(ptr, str);
+ tbl.contents[i][1] = ptr;
+ if(authlog->logout_time)
+ str = intervalString(intervalBuf, now - authlog->logout_time, hi);
+ else if(!authlog->user)
+ str = "Unknown";
+ else {
+ sprintf(intervalBuf, "Never (%s)", authlog->user->nick);
+ str = intervalBuf;
+ }
+ ptr = malloc(strlen(str)+1);
+ strcpy(ptr, str);
+ tbl.contents[i][2] = ptr;
+ tbl.contents[i][3] = (authlog->quit_reason ? authlog->quit_reason : "-");
+ }
+
+ table_send(cmd->parent->bot, user->nick, 0, NULL, tbl);
+ for(i = 1; i < tbl.length; ++i)
+ {
+ free((char *) tbl.contents[i][1]);
+ free((char *) tbl.contents[i][2]);
+ free(tbl.contents[i]);
+ }
+ free(tbl.contents[0]);
+ free(tbl.contents);
+
+ return 0;
+}
+
static NICKSERV_FUNC(cmd_allowauth)
{
struct userNode *target;
unsigned int i;
char *set_display[] = {
"INFO", "WIDTH", "TABLEWIDTH", "COLOR", "PRIVMSG", "STYLE",
- "EMAIL", "MAXLOGINS", "LANGUAGE"
+ "EMAIL", "MAXLOGINS", "LANGUAGE", "DEVNULL"
};
send_message(user, nickserv, "NSMSG_SETTING_LIST");
return 1;
}
+static OPTION_FUNC(opt_devnull)
+{
+ const char *devnull;
+
+ if (argc > 1) {
+ if (!override) {
+ send_message(user, nickserv, "MSG_SETTING_PRIVILEGED", argv[0]);
+ return 0;
+ }
+ if ((argv[1][0] == '*') && (argv[1][1] == 0)) {
+ free(hi->devnull);
+ hi->devnull = NULL;
+ } else {
+ devnull = unsplit_string(argv+1, argc-1, NULL);
+ if(devnull_check(devnull) == 1) {
+ if(hi->devnull)
+ free(hi->devnull);
+ hi->devnull = strdup(devnull);
+ }
+ }
+ }
+
+ devnull = hi->devnull ? hi->devnull : user_find_message(user, "MSG_NONE");
+ send_message(user, nickserv, "NSMSG_SET_DEVNULL", devnull);
+ return 1;
+}
+
+void nickserv_devnull_delete(char *name) {
+ dict_iterator_t it;
+ struct handle_info *hi;
+
+ for (it = dict_first(nickserv_handle_dict); it; it = iter_next(it)) {
+ hi = iter_data(it);
+ if (hi->devnull && !irccasecmp(name, hi->devnull)) {
+ free(hi->devnull);
+ hi->devnull = NULL;
+ }
+ }
+}
+
+void nickserv_devnull_rename(char *oldname, char *newname) {
+ dict_iterator_t it;
+ struct handle_info *hi;
+
+ for (it = dict_first(nickserv_handle_dict); it; it = iter_next(it)) {
+ hi = iter_data(it);
+ if (hi->devnull && !irccasecmp(oldname, hi->devnull)) {
+ hi->devnull = strdup(newname);
+ }
+ }
+}
+
+static OPTION_FUNC(opt_website)
+{
+ const char *website;
+
+ if (argc > 1) {
+ if (!HANDLE_FLAGGED(user->handle_info, BOT)) {
+ send_message(user, nickserv, "MSG_SETTING_PRIVILEGED", argv[0]);
+ return 0;
+ }
+ if ((argv[1][0] == '*') && (argv[1][1] == 0)) {
+ free(hi->website);
+ hi->website = NULL;
+ } else {
+ website = unsplit_string(argv+1, argc-1, NULL);
+ hi->website = strdup(website);
+ }
+ }
+ if (HANDLE_FLAGGED(user->handle_info, BOT)) {
+ website = hi->website ? hi->website : user_find_message(user, "MSG_NONE");
+ send_message(user, nickserv, "NSMSG_SET_WEBSITE", website);
+ }
+ return 1;
+}
+
static OPTION_FUNC(opt_width)
{
if (argc > 1)
return 1;
}
+static OPTION_FUNC(opt_autohide)
+{
+ if (argc > 1) {
+ if (enabled_string(argv[1]))
+ HANDLE_SET_FLAG(hi, AUTOHIDE);
+ else if (disabled_string(argv[1]))
+ HANDLE_CLEAR_FLAG(hi, AUTOHIDE);
+ else {
+ send_message(user, nickserv, "MSG_INVALID_BINARY", argv[1]);
+ return 0;
+ }
+ }
+
+ send_message(user, nickserv, "NSMSG_SET_AUTOHIDE", user_find_message(user, HANDLE_FLAGGED(hi, AUTOHIDE) ? "MSG_ON" : "MSG_OFF"));
+ return 1;
+}
+
static OPTION_FUNC(opt_style)
{
char *style;
return 0;
}
if ((strlen(user->handle_info->handle) + strlen(title) +
- strlen(nickserv_conf.titlehost_suffix) + 2) > HOSTLEN) {
+ strlen(titlehost_suffix) + 2) > HOSTLEN) {
send_message(user, nickserv, "NSMSG_TITLE_TRUNCATED");
return 0;
}
hi->fakehost[0] = '.';
strcpy(hi->fakehost+1, title);
}
- apply_fakehost(hi);
+ apply_fakehost(hi, NULL);
} else if (hi->fakehost && (hi->fakehost[0] == '.'))
title = hi->fakehost + 1;
else
static OPTION_FUNC(opt_fakehost)
{
- const char *fake;
+ char mask[USERLEN + HOSTLEN + 2];
+ char *host, *ident;
if (!override) {
send_message(user, nickserv, "MSG_SETTING_PRIVILEGED", argv[0]);
}
if ((argc > 1) && oper_has_access(user, nickserv, nickserv_conf.set_fakehost_level, 0)) {
- fake = argv[1];
- if ((strlen(fake) > HOSTLEN) || (fake[0] == '.')) {
+ if(strlen(argv[1]) >= sizeof(mask)) {
+ send_message(user, nickserv, "NSMSG_FAKEMASK_INVALID", USERLEN + HOSTLEN + 1);
+ return 0;
+ }
+
+ safestrncpy(mask, argv[1], sizeof(mask));
+
+ if ((host = strrchr(mask, '@')) && host != mask) {
+ /* If ident@host was used and the user doesn't have access to set idents, do not change anything. */
+ if (!oper_has_access(user, nickserv, nickserv_conf.set_fakeident_level, 0)) {
+ host = NULL;
+ ident = NULL;
+ } else {
+ ident = mask;
+ *host++ = '\0';
+ }
+ } else {
+ ident = NULL;
+ host = mask;
+ }
+
+ if (ident && strlen(ident) > USERLEN) {
+ send_message(user, nickserv, "NSMSG_FAKEIDENT_INVALID", USERLEN);
+ return 0;
+ }
+
+ if (host && ((strlen(host) > HOSTLEN) || (host[0] == '.'))) {
send_message(user, nickserv, "NSMSG_FAKEHOST_INVALID", HOSTLEN);
return 0;
}
- free(hi->fakehost);
- if (!strcmp(fake, "*"))
- hi->fakehost = NULL;
+
+ if (host && host[0]) {
+ free(hi->fakehost);
+ if (!strcmp(host, "*"))
+ hi->fakehost = NULL;
+ else
+ hi->fakehost = strdup(host);
+ host = hi->fakehost;
+ }
+ else
+ host = generate_fakehost(hi);
+
+ if (ident) {
+ free(hi->fakeident);
+ if (!strcmp(ident, "*"))
+ hi->fakeident = NULL;
+ else
+ hi->fakeident = strdup(ident);
+ ident = hi->fakeident;
+ }
+ else
+ ident = generate_fakeident(hi, NULL);
+
+ apply_fakehost(hi, NULL);
+ } else {
+ host = generate_fakehost(hi);
+ ident = generate_fakeident(hi, NULL);
+ }
+ if (!host)
+ host = (char *) user_find_message(user, "MSG_NONE");
+ if(ident)
+ send_message(user, nickserv, "NSMSG_SET_FAKEIDENTHOST", ident, host);
+ else
+ send_message(user, nickserv, "NSMSG_SET_FAKEHOST", host);
+ return 1;
+}
+
+static OPTION_FUNC(opt_fakeident)
+{
+ const char *ident;
+
+ if (!override) {
+ send_message(user, nickserv, "MSG_SETTING_PRIVILEGED", argv[0]);
+ return 0;
+ }
+
+ if ((argc > 1) && oper_has_access(user, nickserv, nickserv_conf.set_fakeident_level, 0)) {
+ ident = argv[1];
+ if (strlen(ident) > USERLEN) {
+ send_message(user, nickserv, "NSMSG_FAKEIDENT_INVALID", USERLEN);
+ return 0;
+ }
+ free(hi->fakeident);
+ if (!strcmp(ident, "*"))
+ hi->fakeident = NULL;
else
- hi->fakehost = strdup(fake);
- fake = hi->fakehost;
- apply_fakehost(hi);
+ hi->fakeident = strdup(ident);
+ ident = hi->fakeident;
+ apply_fakehost(hi, NULL);
} else
- fake = generate_fakehost(hi);
- if (!fake)
- fake = user_find_message(user, "MSG_NONE");
- send_message(user, nickserv, "NSMSG_SET_FAKEHOST", fake);
+ ident = generate_fakeident(hi, NULL); /* NULL if no fake ident set */
+ if (!ident)
+ ident = user_find_message(user, "MSG_NONE");
+ send_message(user, nickserv, "NSMSG_SET_FAKEIDENT", ident);
return 1;
}
static NICKSERV_FUNC(cmd_reclaim)
{
- struct handle_info *hi;
struct nick_info *ni;
struct userNode *victim;
NICKSERV_MIN_PARMS(2);
- hi = user->handle_info;
ni = dict_find(nickserv_nick_dict, argv[1], 0);
if (!ni) {
reply("NSMSG_UNKNOWN_NICK", argv[1]);
saxdb_write_string(ctx, KEY_EPITHET, hi->epithet);
if (hi->fakehost)
saxdb_write_string(ctx, KEY_FAKEHOST, hi->fakehost);
+ if (hi->fakeident)
+ saxdb_write_string(ctx, KEY_FAKEIDENT, hi->fakeident);
if (hi->flags) {
int ii, flen;
saxdb_write_int(ctx, KEY_ID, hi->id);
if (hi->infoline)
saxdb_write_string(ctx, KEY_INFO, hi->infoline);
+ if (hi->devnull)
+ saxdb_write_string(ctx, KEY_DEVNULL, hi->devnull);
+ if (hi->website)
+ saxdb_write_string(ctx, KEY_WEBSITE, hi->website);
if (hi->last_quit_host[0])
saxdb_write_string(ctx, KEY_LAST_QUIT_HOST, hi->last_quit_host);
saxdb_write_int(ctx, KEY_LAST_SEEN, hi->lastseen);
flags[0] = hi->userlist_style;
flags[1] = 0;
saxdb_write_string(ctx, KEY_USERLIST_STYLE, flags);
+ if(hi->authlog) {
+ saxdb_start_record(ctx, KEY_AUTHLOG, 0);
+ struct authlogEntry *authlog;
+ int i = 0;
+ for(authlog = hi->authlog; authlog; authlog = authlog->next) {
+ saxdb_start_record(ctx, strtab(++i), 0);
+ saxdb_write_int(ctx, KEY_AUTHLOG_LOGIN_TIME, authlog->login_time);
+ saxdb_write_int(ctx, KEY_AUTHLOG_LOGOUT_TIME, authlog->logout_time);
+ saxdb_write_string(ctx, KEY_AUTHLOG_HOSTMASK, authlog->hostmask);
+ if(authlog->quit_reason)
+ saxdb_write_string(ctx, KEY_AUTHLOG_QUIT_REASON, authlog->quit_reason);
+ saxdb_end_record(ctx);
+ }
+ saxdb_end_record(ctx); //END KEY_AUTHLOG
+ }
saxdb_end_record(ctx);
}
return 0;
*/
if (hi_from->fakehost && !hi_to->fakehost)
hi_to->fakehost = strdup(hi_from->fakehost);
+ if (hi_from->fakeident && !hi_to->fakeident)
+ hi_to->fakeident = strdup(hi_from->fakeident);
/* Notify of success. */
sprintf(buffer, "%s (%s) merged account %s into %s.", user->nick, user->handle_info->handle, hi_from->handle, hi_to->handle);
return 1;
}
+#define NICKSERV_DISCRIM_FIELDS_AUTH 0x01
+#define NICKSERV_DISCRIM_FIELDS_EMAIL 0x02
+#define NICKSERV_DISCRIM_FIELDS_SEEN 0x04
+#define NICKSERV_DISCRIM_FIELDS_ACCESS 0x08
+#define NICKSERV_DISCRIM_FIELDS_FAKEHOST 0x10
+#define NICKSERV_DISCRIM_FIELDS_WEBSITE 0x20
+#define NICKSERV_DISCRIM_FIELDS_DEVNULL 0x40
+
+#define NICKSERV_DISCRIM_FIELD_COUNT 7
+
struct nickserv_discrim {
+ unsigned int show_fields;
+ struct helpfile_table *output_table;
+ int output_table_pos;
+ unsigned int output_table_free_fields;
+
unsigned long flags_on, flags_off;
unsigned long min_registered, max_registered;
unsigned long lastseen;
const char *nickmask;
const char *hostmask;
const char *fakehostmask;
+ const char *fakeidentmask;
+ const char *website;
+ const char *devnullclass;
const char *handlemask;
const char *emailmask;
};
-typedef void (*discrim_search_func)(struct userNode *source, struct handle_info *hi);
+typedef void (*discrim_search_func)(struct userNode *source, struct handle_info *hi, struct nickserv_discrim *discrim);
struct discrim_apply_info {
struct nickserv_discrim *discrim;
discrim->limit = strtoul(argv[++i], NULL, 0);
} else if (!irccasecmp(argv[i], "flags")) {
nickserv_modify_handle_flags(user, nickserv, argv[++i], &discrim->flags_on, &discrim->flags_off);
+ } else if (!irccasecmp(argv[i], "fields")) {
+ char *fields = argv[++i];
+ char *delimiter = strstr(fields, ",");
+ while(1) {
+ if(delimiter)
+ *delimiter = '\0';
+ if(!irccasecmp(fields, "auth"))
+ discrim->show_fields |= NICKSERV_DISCRIM_FIELDS_AUTH;
+ else if(!irccasecmp(fields, "email"))
+ discrim->show_fields |= NICKSERV_DISCRIM_FIELDS_EMAIL;
+ else if(!irccasecmp(fields, "seen"))
+ discrim->show_fields |= NICKSERV_DISCRIM_FIELDS_SEEN;
+ else if(!irccasecmp(fields, "access"))
+ discrim->show_fields |= NICKSERV_DISCRIM_FIELDS_ACCESS;
+ else if(!irccasecmp(fields, "fakehost"))
+ discrim->show_fields |= NICKSERV_DISCRIM_FIELDS_FAKEHOST;
+ else if(!irccasecmp(fields, "website") && IsBot(user))
+ discrim->show_fields |= NICKSERV_DISCRIM_FIELDS_WEBSITE;
+ else if(!irccasecmp(fields, "devnull"))
+ discrim->show_fields |= NICKSERV_DISCRIM_FIELDS_DEVNULL;
+ else {
+ send_message(user, nickserv, "MSG_INVALID_FIELD", fields);
+ goto fail;
+ }
+ if(delimiter) {
+ *delimiter = ',';
+ fields = delimiter+1;
+ if(*fields) {
+ delimiter = strstr(fields, ",");
+ continue;
+ }
+ }
+ break;
+ }
} else if (!irccasecmp(argv[i], "registered")) {
const char *cmp = argv[++i];
if (cmp[0] == '<') {
} else {
discrim->fakehostmask = argv[i];
}
+ } else if (!irccasecmp(argv[i], "fakeident")) {
+ if (!irccasecmp(argv[++i], "*")) {
+ discrim->fakeidentmask = 0;
+ } else {
+ discrim->fakeidentmask = argv[i];
+ }
+ } else if (!irccasecmp(argv[i], "website")) {
+ if (!irccasecmp(argv[++i], "*")) {
+ discrim->website = 0;
+ } else {
+ discrim->website = argv[i];
+ }
+ } else if (!irccasecmp(argv[i], "devnull")) {
+ if (!irccasecmp(argv[++i], "*")) {
+ discrim->devnullclass = 0;
+ } else {
+ discrim->devnullclass = argv[i];
+ }
} else if (!irccasecmp(argv[i], "handlemask") || !irccasecmp(argv[i], "accountmask")) {
if (!irccasecmp(argv[++i], "*")) {
discrim->handlemask = 0;
|| (discrim->lastseen < (hi->users?now:hi->lastseen))
|| (discrim->handlemask && !match_ircglob(hi->handle, discrim->handlemask))
|| (discrim->fakehostmask && (!hi->fakehost || !match_ircglob(hi->fakehost, discrim->fakehostmask)))
+ || (discrim->fakeidentmask && (!hi->fakeident || !match_ircglob(hi->fakeident, discrim->fakeidentmask)))
+ || (discrim->website && (!hi->website || !match_ircglob(hi->website, discrim->website)))
+ || (discrim->devnullclass && (!hi->devnull || !match_ircglob(hi->devnull, discrim->devnullclass)))
|| (discrim->emailmask && (!hi->email_addr || !match_ircglob(hi->email_addr, discrim->emailmask)))
|| (discrim->min_level > hi->opserv_level)
|| (discrim->max_level < hi->opserv_level)
it = next) {
next = iter_next(it);
if (nickserv_discrim_match(discrim, iter_data(it))) {
- dsf(source, iter_data(it));
+ dsf(source, iter_data(it), discrim);
matched++;
}
}
}
static void
-search_print_func(struct userNode *source, struct handle_info *match)
+search_print_func(struct userNode *source, struct handle_info *match, struct nickserv_discrim *discrim)
{
- send_message(source, nickserv, "NSMSG_SEARCH_MATCH", match->handle);
+ if(discrim->show_fields) {
+ //custom fields
+ if(discrim->output_table) {
+ discrim->output_table->contents[++discrim->output_table_pos] = malloc(discrim->output_table->width * sizeof(discrim->output_table->contents[0][0]));
+ int i = 0;
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_AUTH)
+ discrim->output_table->contents[discrim->output_table_pos][i++] = match->handle;
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_EMAIL)
+ discrim->output_table->contents[discrim->output_table_pos][i++] = (match->email_addr ? match->email_addr : "*");
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_SEEN) {
+ char *seen;
+ char seenBuf[INTERVALLEN];
+ if(match->users) {
+ seen = "Here";
+ } else if(match->lastseen == 0) {
+ seen = "Never";
+ } else {
+ seen = intervalString(seenBuf, now - match->lastseen, source->handle_info);
+ }
+ discrim->output_table_free_fields |= 1 << i;
+ discrim->output_table->contents[discrim->output_table_pos][i++] = strdup(seen);
+ }
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_ACCESS)
+ discrim->output_table->contents[discrim->output_table_pos][i++] = strtab(match->opserv_level);
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_FAKEHOST)
+ discrim->output_table->contents[discrim->output_table_pos][i++] = (match->fakehost ? match->fakehost : "*");
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_WEBSITE)
+ discrim->output_table->contents[discrim->output_table_pos][i++] = (match->website ? match->website : "*");
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_DEVNULL)
+ discrim->output_table->contents[discrim->output_table_pos][i++] = (match->devnull ? match->devnull : "*");
+
+ }
+ } else
+ send_message(source, nickserv, "NSMSG_SEARCH_MATCH", match->handle);
}
static void
-search_count_func(UNUSED_ARG(struct userNode *source), UNUSED_ARG(struct handle_info *match))
+search_count_func(UNUSED_ARG(struct userNode *source), UNUSED_ARG(struct handle_info *match), UNUSED_ARG(struct nickserv_discrim *discrim))
{
}
static void
-search_unregister_func (struct userNode *source, struct handle_info *match)
+search_unregister_func (struct userNode *source, struct handle_info *match, UNUSED_ARG(struct nickserv_discrim *discrim))
{
if (oper_has_access(source, nickserv, match->opserv_level, 0))
nickserv_unregister_handle(match, source);
discrim->limit = INT_MAX;
matches = nickserv_discrim_search(discrim, action, user);
-
+
+ if(discrim->show_fields) {
+ int width = 0;
+ int ii;
+ for(ii = 0; ii < NICKSERV_DISCRIM_FIELD_COUNT; ii++) {
+ if(discrim->show_fields & (1 << ii)) width++;
+ }
+ discrim->output_table = malloc(sizeof(discrim->output_table[0]));
+ discrim->output_table->length = matches+1;
+ discrim->output_table->width = width;
+ discrim->output_table->flags = TABLE_NO_FREE;
+ discrim->output_table->contents = malloc(discrim->output_table->length * sizeof(discrim->output_table->contents[0]));
+ discrim->output_table->contents[0] = malloc(discrim->output_table->width * sizeof(discrim->output_table->contents[0][0]));
+
+ ii = 0;
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_AUTH)
+ discrim->output_table->contents[0][ii++] = "Auth";
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_EMAIL)
+ discrim->output_table->contents[0][ii++] = "EMail";
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_SEEN)
+ discrim->output_table->contents[0][ii++] = "Seen";
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_ACCESS)
+ discrim->output_table->contents[0][ii++] = "Access";
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_FAKEHOST)
+ discrim->output_table->contents[0][ii++] = "Fakehost";
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_WEBSITE)
+ discrim->output_table->contents[0][ii++] = "Website";
+ if(discrim->show_fields & NICKSERV_DISCRIM_FIELDS_DEVNULL)
+ discrim->output_table->contents[0][ii++] = "DevNull";
+
+ nickserv_discrim_search(discrim, action, user);
+
+ table_send(nickserv, user->nick, 0, NULL, *discrim->output_table);
+
+ for(ii = 1; ii < discrim->output_table->length; ++ii) {
+ int ij;
+ for(ij = 0; ij < NICKSERV_DISCRIM_FIELD_COUNT; ij++) {
+ if(discrim->output_table_free_fields & (1 << ij))
+ free((char*)discrim->output_table->contents[ii][ij]);
+ }
+ free(discrim->output_table->contents[ii]);
+ }
+ free(discrim->output_table->contents[0]);
+ free(discrim->output_table->contents);
+ free(discrim->output_table);
+ }
if (matches)
reply("MSG_MATCH_COUNT", matches);
else
reply("MSG_NO_MATCHES");
+
free(discrim);
return 0;
}
return 1;
}
+static int
+nickserv_db_read_authlog(UNUSED_ARG(const char *key), void *data, void *extra)
+{
+ struct record_data *rd = data;
+ struct handle_info *hi = extra;
+ const char *str;
+ struct authlogEntry *authlog;
+ authlog = malloc(sizeof(*authlog));
+
+ str = database_get_data(rd->d.object, KEY_AUTHLOG_LOGIN_TIME, RECDB_QSTRING);
+ authlog->login_time = str ? strtoul(str, NULL, 0) : 0;
+
+ str = database_get_data(rd->d.object, KEY_AUTHLOG_LOGOUT_TIME, RECDB_QSTRING);
+ authlog->logout_time = str ? strtoul(str, NULL, 0) : 0;
+
+ str = database_get_data(rd->d.object, KEY_AUTHLOG_HOSTMASK, RECDB_QSTRING);
+ authlog->hostmask = str ? strdup(str) : NULL;
+
+ str = database_get_data(rd->d.object, KEY_AUTHLOG_QUIT_REASON, RECDB_QSTRING);
+ authlog->quit_reason = str ? strdup(str) : NULL;
+
+ authlog->user = NULL;
+
+ authlog->next = NULL;
+
+ //append it to the end of the list...
+ struct authlogEntry *authlog_entry;
+ if(!hi->authlog) {
+ hi->authlog = authlog;
+ } else {
+ for(authlog_entry = hi->authlog; authlog_entry; authlog_entry = authlog_entry->next) {
+ if(!authlog_entry->next) {
+ authlog_entry->next = authlog;
+ break;
+ }
+ }
+ }
+ return 0;
+}
static void
nickserv_db_read_handle(const char *handle, dict_t obj)
str = database_get_data(obj, KEY_INFO, RECDB_QSTRING);
if (str)
hi->infoline = strdup(str);
+ str = database_get_data(obj, KEY_WEBSITE, RECDB_QSTRING);
+ if (str)
+ hi->website = strdup(str);
+ str = database_get_data(obj, KEY_DEVNULL, RECDB_QSTRING);
+ if (str)
+ hi->devnull = strdup(str);
str = database_get_data(obj, KEY_REGISTER_ON, RECDB_QSTRING);
hi->registered = str ? strtoul(str, NULL, 0) : now;
str = database_get_data(obj, KEY_LAST_SEEN, RECDB_QSTRING);
str = database_get_data(obj, KEY_FAKEHOST, RECDB_QSTRING);
if (str)
hi->fakehost = strdup(str);
+ str = database_get_data(obj, KEY_FAKEIDENT, RECDB_QSTRING);
+ if (str)
+ hi->fakeident = strdup(str);
/* Read the "cookie" sub-database (if it exists). */
subdb = database_get_data(obj, KEY_COOKIE, RECDB_OBJECT);
if (subdb) {
last_note = note;
}
}
+ if ((subdb = database_get_data(obj, KEY_AUTHLOG, RECDB_OBJECT)))
+ dict_foreach(subdb, nickserv_db_read_authlog, hi);
}
static int
nickserv_conf.set_title_level = str ? strtoul(str, NULL, 0) : 900;
str = database_get_data(conf_node, KEY_SET_FAKEHOST_LEVEL, RECDB_QSTRING);
nickserv_conf.set_fakehost_level = str ? strtoul(str, NULL, 0) : 1000;
+ str = database_get_data(conf_node, KEY_SET_FAKEIDENT_LEVEL, RECDB_QSTRING);
+ nickserv_conf.set_fakeident_level = str ? strtoul(str, NULL, 0) : 1000;
str = database_get_data(conf_node, KEY_HANDLE_EXPIRE_FREQ, RECDB_QSTRING);
if (!str)
str = database_get_data(conf_node, KEY_ACCOUNT_EXPIRE_FREQ, RECDB_QSTRING);
nickserv_conf.default_maxlogins = str ? strtoul(str, NULL, 0) : 2;
str = database_get_data(conf_node, "hard_maxlogins", RECDB_QSTRING);
nickserv_conf.hard_maxlogins = str ? strtoul(str, NULL, 0) : 10;
+ str = database_get_data(conf_node, KEY_MAX_AUTHLOG_LEN, RECDB_QSTRING);
+ nickserv_conf.max_authlog_len = str ? strtoul(str, NULL, 0) : 30;
str = database_get_data(conf_node, KEY_OUNREGISTER_INACTIVE, RECDB_QSTRING);
nickserv_conf.ounregister_inactive = str ? ParseInterval(str) : 86400*28;
str = database_get_data(conf_node, KEY_OUNREGISTER_FLAGS, RECDB_QSTRING);
str = database_get_data(conf_node, KEY_EMAIL_SEARCH_LEVEL, RECDB_QSTRING);
nickserv_conf.email_search_level = str ? strtoul(str, NULL, 0) : 600;
str = database_get_data(conf_node, KEY_TITLEHOST_SUFFIX, RECDB_QSTRING);
- nickserv_conf.titlehost_suffix = str ? str : "example.net";
+ titlehost_suffix = str ? str : "example.net";
str = conf_get_data("server/network", RECDB_QSTRING);
nickserv_conf.network_name = str ? str : "some IRC network";
if (!nickserv_conf.auth_policer_params) {
static void
check_user_nick(struct userNode *user) {
+ //check if this user is a pending LOC user
+ if(pendingLOCUsers) {
+ struct pendingLOCUser *pending, *next, *prev = NULL;
+ for(pending = pendingLOCUsers; pending; pending = next) {
+ next = pending->next;
+ if(user->handle_info == pending->handle_info) {
+ pending->authlog->user = user;
+ free((char*) pending->authlog->hostmask);
+ pending->authlog->hostmask = generate_hostmask(user, GENMASK_USENICK|GENMASK_STRICT_IDENT|GENMASK_NO_HIDING|GENMASK_STRICT_HOST);
+ if(prev)
+ prev->next = next;
+ else
+ pendingLOCUsers = next;
+ free(pending);
+ }
+ if(now - pending->time > 10) {
+ if(prev)
+ prev->next = next;
+ else
+ pendingLOCUsers = next;
+ free(pending);
+ }
+ }
+ }
struct nick_info *ni;
user->modes &= ~FLAGS_REGNICK;
if (!(ni = get_nick_info(user->nick)))
}
void
-nickserv_remove_user(struct userNode *user, UNUSED_ARG(struct userNode *killer), UNUSED_ARG(const char *why))
+nickserv_remove_user(struct userNode *user, UNUSED_ARG(struct userNode *killer), const char *why)
{
+ if(user->handle_info) {
+ //check if theres an open authlog entry
+ struct authlogEntry *authlog;
+ for(authlog = user->handle_info->authlog; authlog; authlog = authlog->next) {
+ if(authlog->user == user) {
+ authlog->user = NULL;
+ authlog->logout_time = now;
+ authlog->quit_reason = strdup(why);
+ break;
+ }
+ }
+ }
dict_remove(nickserv_allow_auth_dict, user->nick);
timeq_del(0, nickserv_reclaim_p, user, TIMEQ_IGNORE_WHEN);
set_user_handle_info(user, NULL, 0);
regfree(&nickserv_conf.valid_handle_regex);
if (nickserv_conf.valid_nick_regex_set)
regfree(&nickserv_conf.valid_nick_regex);
+ struct pendingLOCUser *pending, *next;
+ for(pending = pendingLOCUsers; pending; pending = next) {
+ next = pending->next;
+ free(pending);
+ }
+ pendingLOCUsers = NULL;
}
void
nickserv_define_func("MERGEDB", cmd_mergedb, 999, 1, 0);
nickserv_define_func("CHECKPASS", cmd_checkpass, 601, 1, 0);
nickserv_define_func("CHECKEMAIL", cmd_checkemail, 0, 1, 0);
+ nickserv_define_func("AUTHLOG", cmd_authlog, -1, 1, 0);
+ nickserv_define_func("OAUTHLOG", cmd_oauthlog, 0, 1, 0);
/* other options */
dict_insert(nickserv_opt_dict, "INFO", opt_info);
dict_insert(nickserv_opt_dict, "WIDTH", opt_width);
dict_insert(nickserv_opt_dict, "COLOR", opt_color);
dict_insert(nickserv_opt_dict, "PRIVMSG", opt_privmsg);
dict_insert(nickserv_opt_dict, "STYLE", opt_style);
+ dict_insert(nickserv_opt_dict, "AUTOHIDE", opt_autohide);
dict_insert(nickserv_opt_dict, "PASS", opt_password);
dict_insert(nickserv_opt_dict, "PASSWORD", opt_password);
dict_insert(nickserv_opt_dict, "FLAGS", opt_flags);
+ dict_insert(nickserv_opt_dict, "WEBSITE", opt_website);
+ dict_insert(nickserv_opt_dict, "DEVNULL", opt_devnull);
dict_insert(nickserv_opt_dict, "ACCESS", opt_level);
dict_insert(nickserv_opt_dict, "LEVEL", opt_level);
dict_insert(nickserv_opt_dict, "EPITHET", opt_epithet);
- if (nickserv_conf.titlehost_suffix) {
+ if (titlehost_suffix) {
dict_insert(nickserv_opt_dict, "TITLE", opt_title);
dict_insert(nickserv_opt_dict, "FAKEHOST", opt_fakehost);
+ dict_insert(nickserv_opt_dict, "FAKEIDENT", opt_fakeident);
}
dict_insert(nickserv_opt_dict, "MAXLOGINS", opt_maxlogins);
dict_insert(nickserv_opt_dict, "LANGUAGE", opt_language);