Michael Poole [Fri, 11 Jul 2008 02:04:41 +0000 (22:04 -0400)]
Allow NickServ to ignore accounts if the user's account create ts is wrong.
src/nickserv.c (KEY_HANDLE_TS_MODE): Define.
(enum handle_ts_mode): Define.
(nickserv_conf): Add handle_ts_mode field.
(nickserv_conf_read): Set it.
(handle_account): Use it.
srvx.conf.example: Document it.
Michael Poole [Wed, 9 Jul 2008 03:01:19 +0000 (23:01 -0400)]
Support sending and receiving account timestamps (but ignore them for now).
src/hash.h (account_func_t): Add timestamp and serial ID fields.
(call_account_func): Likewise.
(StampUser): Likewise.
src/hash.c (call_account_func): Pass them through to account_func.
(StampUser): Pass them through to irc_account.
src/nickserv.h (handle_info::id): Make this field unconditional.
src/nickserv.c (register_handle): Make the ID assignment unconditional.
(free_handle_info): Make the ID handling here unconditional.
(set_user_handle_info): Pass all the ID fields to StampUser().
(cmd_handleinfo): Move NSMSG_HANDLEINFO_ID to be staff only.
(nickserv_saxdb_write): Make the ID assertion and write unconditional.
(nickserv_db_read_handle): Remove redundant "int".
(handle_account): Use account name preferentially, fall back to ID.
src/proto.h (irc_account): Add timestamp and serial number parameters.
src/proto-bahamut.c (AddUser): Make stamp parameter unsigned long. Pass
it appropriately to call_account_func().
(irc_account): Add timestamp and serial number parameters; use serial
number in place of a base64-decoded stamp.
src/proto-p10.c (irc_account): Send timestamp and serial number for user.
(cmd_account): Parse them when they are present.
(mod_usermode): Likewise.
Michael Poole [Tue, 8 Jul 2008 02:16:16 +0000 (22:16 -0400)]
Properly handle collisions during burst with persistent local clients.
src/proto-p10.c (AddUser): Reorganize if/then/else chain to update a
persistent client's timestamp if there is a collision during burst,
but not to re-introduce the user immediately.
src/chanserv.c (CSMSG_LOW_CHANNEL_ACCESS): Be more specific.
(user_opt_autoinvite): Tell the user if his access is too low for the
option to have an effect.
Michael Poole [Sat, 5 Jul 2008 11:51:06 +0000 (07:51 -0400)]
Fix SourceForge bug #864524: Say if too few arguments passed to alias.
src/modcmd.c (svccmd_expand_alias): If the lower bound is past the end of
the argument list, return -1.
(svccmd_invoke_argv): Detect that and report it as needing more params.
Michael Poole [Sun, 15 Jun 2008 13:23:22 +0000 (09:23 -0400)]
Use correct error string for getaddrinfo() and getnameinfo() failures.
src/ioset.c (ioset_connect): Include the error string when getaddrinfo()
fails.
src/mail-smtp.c (smtp_fill_name): Use gai_strerror() rather than strerror().
Michael Poole [Wed, 30 Apr 2008 02:13:08 +0000 (22:13 -0400)]
Fully fix build on Cygwin.
src/common.h (localtime_r): Do not declare in this file.
src/compat.h (localtime_r): Fix conditional definition of localtime_r().
(EAI_*): Define getaddrinfo()/getnameinfo() error codes if needed.
src/compat.c (getaddrinfo): Return errors by macro.
(getnameinfo): Implement a simple version of this function.
Michael Poole [Thu, 24 Apr 2008 11:29:24 +0000 (07:29 -0400)]
Update Win32 builds to mostly work under Cygwin.
Makefile.win32: Add -mno-cygwin to LDFLAGS so native Cygwin builds work.
configure.in: Look for stdint.h, localtime() and --with-win32.
src/compat.c: Remove "extern" modifiers on function definitions. Only
implement localtime_r() if we have localtime() too.
src/compat.h: Include stdint.h if we have it; define LINE_MAX if needed.
Also define NI_NUMERICHOST for the benefits of getnameinfo().
src/config.h.win32: Resynchronize with config.h.in; set WITH_IOSET_SELECT
and WITH_PROTOCOL_P10.
Michael Poole [Sun, 30 Mar 2008 04:00:48 +0000 (00:00 -0400)]
Implement our own output buffering inside saxdb.
src/saxdb.c (SAXDB_BUFFER_SIZE): Default to 32 KB if not already defined.
(struct saxdb_context): Add "obuf" member.
(saxdb_flush): Define new helper function.
(saxdb_put_char): Convert to function.
(saxdb_put_nchars): Update to use "obuf" and saxdb_flush().
(saxdb_put_string): Update to use saxdb_put_nchars().
(saxdb_put_qstring): Likewise.
(saxdb_open_context): Allocate space for ctx->obuf.
(saxdb_close_context): Flush the buffer and free ctx->obuf.
Michael Poole [Sun, 30 Mar 2008 02:43:42 +0000 (22:43 -0400)]
Add close_file arg to saxdb_close_context(); allocate all saxdb contexts from heap.
src/saxdb.h (saxdb_close_context): Add "close_file" argument.
src/saxdb.c (saxdb_write_db): Use saxdb_{open,close}_context() rather than
putting it on the stack.
(write_database): Likewise.
(saxdb_close_context): Implement the close_file argument.
src/modcmd.c (cmd_dump_messages): Use the close_file argument.
src/mod-helpserv.c (helpserv_log_request): Likewise.
Michael Poole [Tue, 25 Mar 2008 02:56:18 +0000 (22:56 -0400)]
Implement kqueue()/kevent() ioset backend.
configure.in: Check for <sys/event.h>, kqueue() and kevent(). If kevent()
is present, default to enabling ioset-kevent.
src/Makefile.am: Include ioset-kevent.c as extra source.
src/ioset-kevent.c: New file.
src/ioset.c: Update name for this event backend.
Michael Poole [Thu, 20 Mar 2008 03:46:29 +0000 (23:46 -0400)]
Remove extraneous semicolons from end of macro uses.
src/chanserv.c: Do this for dnrList.
src/log.c: Do it for logList.
src/mail-smtp.c: Do it for mail_queue.
src/mod-helpserv.c: Do it for helpserv_botlist, helpserv_reqlist and
helpserv_userlist, and their sized allocators.
src/mod-memoserv.c: Do it for memoList.
src/modcmd.c: Do it for svccmd_list and module_list.
src/modcmd.h: Remove the extra semicolon at the end of SVCMSG_HOOK()'s definition.
src/nickserv.c: Do it for handle_info_list.
src/saxdb.c: Do it for int_list.
Michael Poole [Sat, 5 Jan 2008 17:22:03 +0000 (12:22 -0500)]
Convert time-related variables to consistently use "unsigned long".
configure.in: Remove no-longer-used check for FMT_TIME_T.
src/*.c: Convert time_t and time adjustment values to unsigned long.
src/*.h: Likewise.
src/config.h.win32: Remove definition of FMT_TIME_T.
Michael Poole [Fri, 14 Dec 2007 04:47:10 +0000 (23:47 -0500)]
Greatly enhance the slab allocator.
configure.in: Look for mprotect() function.
src/Makefile.am: Add slab-read program.
src/slab-read.c: New helper program.
src/alloc-slab.c (SLAB_DEBUG_HEADER): New bitmask macro.
(SLAB_DEBUG_LOG): Likewise. Implement its functions.
(SLAB_DEBUG_PERMS): Likewise. Implement its functions.
(SLAB_DEBUG): Update default.
(slab_alloc): Call slab_unprotect() when pulling free_slab_head. Call
slab_log_alloc() on any slab allocation.
(slab_unalloc): Call slab_log_free() on slab unallocation. Call
slab_unprotect() and slab_protect() when manipulating free slabs.
(slab_malloc): Call slab_log_alloc() on large object allocation.
(slab_free): Call slab_log_unmap() on large object free.
Michael Poole [Fri, 14 Dec 2007 03:56:03 +0000 (22:56 -0500)]
Fix some memory leaks in the slab allocator (funny, isn't it?).
alloc-slab.c (SLAB_DEBUG): Allow environment to override definition.
(SLAB_RESERVE): Likewise.
(MAX_SLAB_FREE): New preprocessor macro, used to cap free_slab_count.
(slab_unalloc): Reindent SLAB_RESERVE logic. Unconditionally link the
free slab to the list of free slabs. Add code to check MAX_SLAB_FREE.
Michael Poole [Fri, 14 Dec 2007 03:32:13 +0000 (22:32 -0500)]
Avoid appending a user to curr_opers or curr_helpers more than once.
hash.h (userList_contains): Declare new function.
hash.c (userList_contains): Implement it.
nickserv.c (set_user_handle_info): Use it to check against curr_helpers.
proto-p10.c (mod_usermode): Use it for curr_opers.
Michael Poole [Fri, 14 Dec 2007 03:01:04 +0000 (22:01 -0500)]
Fix some memory leaks.
recdb.c (parse_database): Close recdb.f on all exit paths.
sar.c (sar_cleanup): Free the string lists allocated inside config struct.
saxdb.c (saxdb_read_db): Free the previous mondo_db (if any) at first read.
Michael Poole [Fri, 14 Dec 2007 02:42:30 +0000 (21:42 -0500)]
Store git version string to a C file, not a header.
.gitignore: Update git-ignore.* file name.
Makefile.am: Update rebuild rules and srvx_SOURCES to match.
common.h: Declare git_version[].
main-common.c: Include git_version in version banner. Update copyright years.
modcmd.c: Use git_version instead of GIT_VERSION.
Michael Poole [Thu, 13 Dec 2007 04:07:52 +0000 (23:07 -0500)]
Fix DNR expiration and expiration-based DNR searches.
src/chanserv.c (expire_dnrs): Use the usual trick for iterating over a dict
while we might want to delete elements from it.
(dnr_search_matches): Simplify the min_expires test. If max_expires is
set, fail if the DNR never expires or it expires later.
(dnr_search_create): Initialize max_expires to 0, not INT_MAX.
Michael Poole [Fri, 27 Jul 2007 03:15:23 +0000 (23:15 -0400)]
Avoid trying to mmap() or read a zero-byte database file.
src/recdb.c (parse_database): If the file is empty, we can just return an
empty database without trying to mmap() it (zero-sized mmap generates
EINVAL) or trying to read it.
Michael Poole [Tue, 29 May 2007 02:14:21 +0000 (22:14 -0400)]
Get native Win32 mode working (at least in a basic state).
Makefile.win32: Use mail-smtp backend. Fix main build rule.
src/ioset-win32.c (ioset_win32_init): Return values appropriately.
(ioset_win32_loop): Update "now" before dispatching events.
src/ioset.c: Add errno kludges to work properly on Win32. Use send() and
recv() rather than write() and read(). Use simple comparisons rather
than switch statements with only one case.
src/mail-smtp.c: Initial pass at SMTP backend for mail service. Does not
yet try to send the mail body, and has not been tested.
src/main-common.c: Move usage(), version(), license() to here ..
src/main.c: .. from here.
src/main-win32.c: Parse command-line options.
Michael Poole [Mon, 28 May 2007 19:02:30 +0000 (15:02 -0400)]
Fix misapplied patches from the GameSurge branch.
* src/nickserv.c (cmd_handleinfo): Use IsStaff() rather than IsSupport().
* src/opserv.c (cmd_block): Use C style comment, not C++ style.
(is_oper_victim): Likewise.
Michael Poole [Sat, 31 Mar 2007 17:26:31 +0000 (13:26 -0400)]
Use correct free functions for blacklist dicts.
src/mod-blacklist.c (blacklist_conf_read): Use dnsbl_zone_free() to free
zone structures, and free() to free blacklist reasons, rather than
vice versa.
Michael Poole [Sat, 31 Mar 2007 17:20:19 +0000 (13:20 -0400)]
For giveownership to new members, give old owner access 499 instead of 400.
src/chanserv.c (cmd_giveownership): When the new user did not exist, give
them UL_OWNER-1 (499) access rather than UL_COOWNER, so that when the
access levels are swapped later, the previous owner ends up with 499.
src/nickserv.c (msgtab): New entries for the "notes" command.
(cmd_notes): New function to show notes for an account.
(cmd_oset): Check access for subcommands.
(struct nickserv_discrim): New "fakehostmask" field.
(nickserv_discrim_create): Set it.
(nickserv_discrim_match): Check against it.
(init_nickserv): Register NOTES and OSET KARMA commands.
src/nickserv.help (SEARCH CRITERIA): Mention FAKEHOST and KARMA options.