psychon [Tue, 24 Mar 2009 18:45:03 +0000 (18:45 +0000)]
Add znc --debug / znc -g
This enables the debug output you get with --enable-debug on --disable-debug
builds. The behaviour if znc was compiled with --disable-debug isn't changed.
psychon [Tue, 24 Mar 2009 12:03:51 +0000 (12:03 +0000)]
Add znc -f / --foreground
This argument makes znc not fork into the background. It has no effect if
configure is called with --enable-debug, znc will always stay in the foreground
in this case.
The hunk at the end of main.cpp is just whitespace stuff. The only difference
in there is that #ifdef _DEBUG #else #endif is changed into
if (bForeground) { } else { } (which makes this whitespace stuff necessary).
psychon [Sun, 22 Mar 2009 19:05:34 +0000 (19:05 +0000)]
Fix a crash bug with recursion in module calls
This was found via partyline and notify_connect. notify_connect calls
CZNC::Broadcast() in OnClientLogin() which calls the OnBroadcast() module call.
When returning from this module calls, m_pUser and m_pClient was reset to NULL
and all the following modules got their OnClientLogin() called with m_pUser and
m_pClient set to NULL.
This patch fixes this by resetting those vars to their old values instead to
NULL when returning from a module call.
This patch also fixes the bug that m_pUser and m_pClient in modules were reset
to NULL after they caused a module call which called back into the current
module. The fix looks similar to the other one (this one is the Modules.h part).
psychon [Wed, 18 Mar 2009 15:45:43 +0000 (15:45 +0000)]
Get rid of znc.conf-backup
The old code created a copy of the config file before writing a new version.
This backup is now gone.
With this patch the config is written to a temporary file znc.conf~ and then
fsync()d to make sure the data safely is on the disk. Then the real config file
znc.conf is overwritten with this temporary file via a rename() call.
This should be safer than the old way, plus it gets rid of a unneeded file.
psychon [Sat, 14 Mar 2009 11:12:18 +0000 (11:12 +0000)]
Regenerate configure with the newer autoconf 2.63 (was 2.61 before)
This removes svn:eol-style from configure since it now contains
this in line 4122 (\r is a literal mac line ending):
ac_cr='\r'
This confused subversion. Bad svn, bad!
silverleo [Fri, 13 Mar 2009 17:24:36 +0000 (17:24 +0000)]
Added raw 432 processing for illegal and erroneous nicks and changed the condition to trigger SendAltNick() since ircds like to interpret the standards.
sebastinas [Wed, 11 Mar 2009 14:32:12 +0000 (14:32 +0000)]
Fix for CSmartPtr::GetCount
Since CSmartPtr::GetCount returns a pointer to unsigned int it's
possible to manually change the reference count from outside.
Increasing the reference count will result in a memory leak and
decreasing will produce undefined behaviour.
GetCount now returns a pointer to const unsigned int to fix this.
psychon [Tue, 10 Mar 2009 19:15:08 +0000 (19:15 +0000)]
Check if the version of a module matches when querying info about it
When the module was compiled for a wrong ZNC version it's description will
say so. Everything which displays a list of available modules together with
their description will display this (--makeconf, /msg *status listavailmods,
webadmin).
psychon [Mon, 9 Mar 2009 17:37:35 +0000 (17:37 +0000)]
Add /msg *status UpdateMod[ule] which reloads an user module on all users
This command allows admins to really reload a module when they have updated it.
Because the dynamic linker does not really reload a shared object until all
handles to this object where dlclose()'d, this new command is necessary.
psychon [Sat, 7 Mar 2009 12:37:38 +0000 (12:37 +0000)]
Always notify the user when someone else tried to login but was rejected
Before this, you only got a message from *status when someone tried to login
with a bad password and no auth module (imapauth/saslauth) was loaded.
With this patch every failed login will generate a message.
psychon [Tue, 24 Feb 2009 16:00:11 +0000 (16:00 +0000)]
Handle newlines in CHTTPSock::GetParam() and strip them out.
There was a bug in webadmin which allowed any users to write arbitrary strings
to znc.conf by setting e.g. their quit message to:
Some quit message
Admin = true
LoadModule = shell
</User>
ISpoofFile = /home/<user>/.ssh/authorited_keys
ISpoofFormat = <some ssh key>
<User a>
(The newlines must be sent as newlines to webadmin)
This commit fixes this by stripping all newlines from all the data fields
by default. Since some fields (e.g. CTCPReplies and Servers) do need newlines,
there is a new function CHTTPSock::GetRawParam() which doesn't do the stripping.
Thanks to cnu for finding and reporting this bug.
Thanks to kroimon for patch review.
psychon [Tue, 24 Feb 2009 15:52:43 +0000 (15:52 +0000)]
Check the return value of strftime()
strftime() returns zero for errors and the state of the buffer we passed to it
is undefined in this case. This lead to a non-null-terminated string being
used.
The impact of this bug should be low, no writing was done and you were only
able to get a partial stack dump. A crash through this is quite unlikely.
psychon [Sat, 21 Feb 2009 16:48:28 +0000 (16:48 +0000)]
Call OnFailedLogin() for all failed logins, not only those on the irc port
This breaks CAuthBase's API for modules that want to auth users.
Instead of overloading AcceptLogin() and RefuseLogin(), they now have to
overload AcceptedLogin() and RefusedLogin().
Modules that auth users (e.g. imapauth) still call AcceptLogin() and
RefuseLogin() which is where OnFailedLogin() gets called.
psychon [Thu, 19 Feb 2009 16:40:21 +0000 (16:40 +0000)]
Some stuff for the admin module
- No longer a global module, why was it ever one?
- Fix '/msg *admin set ident a' to error out instead of modifying my own user.
- Document '$me'.
- Other, minor stuff.
psychon [Tue, 17 Feb 2009 15:29:06 +0000 (15:29 +0000)]
Some cleanup to CFile
Remove CFile::SetFD() which was unused and made FD leaks way too easy.
Remove CFile::CFile(int fd, const CString& sLongName) since it's unused and
it was the only reason we needed the m_bClose member which is now also gone.
Call ClearBuffer() in Close() in case someone reuses CFile instances.
psychon [Mon, 16 Feb 2009 17:36:52 +0000 (17:36 +0000)]
Remove some completely unused code in Modules.cpp
Modules.cpp is capsuled in a huge #ifdef _MODULES block (see r767), but some
code in there still uses #ifndef _MODULES, which is never going to be used.
psychon [Mon, 16 Feb 2009 17:26:46 +0000 (17:26 +0000)]
Import the admin module
This module basically does the same things webadmin does, but via
an IRC query interface.
Thanks to sebastinas for writing the original version of this module.
Thanks to kroimon for making this suite ZNC's coding style better and porting
it to newer ZNC versions.
Finally, I added a DelUser command and ported it again to laters versions.
psychon [Thu, 5 Feb 2009 17:11:45 +0000 (17:11 +0000)]
HTTPSock: Don't transfer endless static files in PrintFile()
This limits the max file size to 16 MiB and makes the read loop stop after
it has read as many bytes as GetSize() said the file is long. This fixes
an endless loop when trying to transfer endless files like /dev/zero.
psychon [Tue, 3 Feb 2009 18:15:56 +0000 (18:15 +0000)]
Remove this unused definition of strcasestr()
No idea why we provide this definition for __sun (solaris?), but it doesn't
look like anything uses this and we don't compile on those weird boxes anyway.
psychon [Thu, 29 Jan 2009 19:11:53 +0000 (19:11 +0000)]
Some fixes to modperl, most notable no with time increasing memory usage
Because some ENTER/LEAVE pair was missing, the stack perl uses for passing
arguments grew and grew.
Besides adding those calls this also fixes some more of the callback calling
code to look a little closer to the examples from perldoc.
This also fixes some warnings perl threw at us when unloading by not
making ZNC::{CONTINUE,HALT{,MODS,CORE}} mortal.
Thanks to tomaw and AnMaster for reporting and helping me debug this mem issue.
psychon [Sat, 24 Jan 2009 19:10:05 +0000 (19:10 +0000)]
Savebuff: Don't reload old channel buffers
Channel buffers are loaded from disk when we join a channel (OnJoin) and when
the module is loaded (OnBoot(), called from OnLoad()) and only if KeepBuffer
for that channel is turned on. So every case is handled.
If we now also load channel buffers in SaveBufferToDisk() we will only reload
old channel buffers which were deleted since then
(e.g. /msg *status clearallchannelbuffers).
Thanks to Julian for finding this bug and helping me debug.