psychon [Wed, 20 May 2009 11:19:17 +0000 (11:19 +0000)]
Revert rev 1510 "Ask SSL clients for a ssl cert"
This commit breaks webadmin. This was found with firefox. If you got any client
certificates imported into firefox, it will ask you to select which certificate
to use a couple of times per click (once per HTTP request which means also when
loading images etc).
Since webadmin by default shares the listen port with znc, we can't limit this
SSL_VERIFY_PEER to webadmin listening ports. The simplest solution is thus to
just drop this.
silverleo [Wed, 20 May 2009 10:36:34 +0000 (10:36 +0000)]
Revert rev1504 that introduced an error with modtcl.
Tcl fork()s to create a child process, the child exits and tcl tries to get
the child's exit code via waitpid() but when the child process exits, we get
SIGCHLD, call waitpid() ourselves and thus the exit code (and the whole
zombie) is discarded and tcl can't get the child's exit code.
psychon [Mon, 11 May 2009 16:16:10 +0000 (16:16 +0000)]
Fix a wrong cached /mode reply
ZNC replies to /mode #chan with the cached channel modes without querying the
IRCd. This was added to avoid traffic spikes to the ircd when a client
logged in.
The logic in this code had a bug that made it also reply with stale cached
values if we once were but aren't anymore in that channel (e.g. after
you've been kicked).
psychon [Mon, 11 May 2009 16:06:40 +0000 (16:06 +0000)]
Close client sockets only after all pending data was sent
Now e.g. the message "Invalid Password" on login even reaches the other end
before the connection shoots itself in the foot.
There is one place in Client.cpp which I didn't change: ReachedMaxBuffer()
If a client is flooding is, why should we wait until we are done answering
that flood?...
psychon [Mon, 4 May 2009 19:21:26 +0000 (19:21 +0000)]
Handle SIGCHLD for collecting zombie processes
The old code failed to collect the following command to *shell correctly:
exec > /dev/null 2> /dev/null < /dev/null ; sleep 10
The timeout in CExecSock::close2() was over before the child processes exited
and a zombie was left behind. Plus we used some ugly busy looping while
waiting for the child to exit. Using SIGCHLD for collecting zombies is
soooooo much nicer.
psychon [Sun, 3 May 2009 11:23:05 +0000 (11:23 +0000)]
Install a file for pkg-config
configure now generates to files for pkg-config:
znc.pc and znc-uninstalled.pc
This is supposed to replace the znc-config binary. Everything which can be done
with znc-config can now also be done with pkg-config.
znc-uninstalled.pc is only generated by configure, but not installed by the
Makefiles. It's there to fix some kind of bug we have with znc-config.
ZNC can run quite fine from the source, there is no need to ever run
"make install". The only problem is that e.g. znc-extra won't build, since
it gets -I/usr/local/include/znc from znc-config which doesn't work since znc
was never installed.
pkg-config has a nice fix for this: If you ask for "a", but "a-uninstalled"
exists, pkg-config will use the later one instead. This is used in
znc-uninstalled.pc to output a different -I flag which works for the
uninstalled headers.
(You only have to set $PKG_CONFIG_PATH to znc's source dir for this to work)
When you are already in #znc and you did 'stick znc' (# prefix missing!),
stickychan caused segfaults or different weird behavior. This happened because
stickychan didn't handle errors from CUser::AddChan(). AddChan() can only error
out if the channel already exists, but since stickychan already checked this,
were does the error come from?
CChan's constructor does some sanity checks on the channel name. It
automatically adds the proper channel prefix (most likely #) if it's missing.
This means when stickychan checked for the channel "znc" it correctly didn't
find one. When it then tried to add "znc", it really tried adding "#znc" which
could fail if the channel was already added.
fcntl.h is needed for fcntl() and defines like FD_CLOEXEC, F_SETFD and F_GETFD.
This worked so far, because some C++ header pulled in fcntl.h, but there are
systems out there for which this is not true. (Found on solaris)
perl's LDFLAGS where included in $LIBS when checking for libperl. This meant
that e.g. the -L flag necessary for finding libperl was after the "-lperl"
argument. This made the test fail.
This moves these flags into $LDFLAGS (and later restores the old $LDFLAGS
since only modperl needs those flags, modules/Makefile.in handles that).
Thanks to sartek for reporting this is broken on solaris and testing the patch.
This adds a new, second argument to fail2ban which is the number of failed
logins one is allowed before being banned. Each login attempt resets the
timeout. This value defaults to 2.
This adds a second template parameter to TCacheMap which is the value which is
saved in the map. This second parameter can be retrived with the new
TCacheMap::GetItem() and set with a new second argument to TCacheMap::AddItem()
This moves all static webadmin files (images, css) to the data/ subdirectory
of the skin dir. The webadmin module is changed to redirect requests to
/<skin name>/ to that data directory. The skins are changed to use the
new URL when linking to their stuff. (I only needed to change the path to
the main.css file in each Header.tmpl. Since the .css and the images are now
in the same directory, relative URLs work just fine).
This means that we now generate different URLs after changing the webadmin
skins and the browser cache can do its thing.
admin: DelUser can now handle spaces in user names
The new CloneUser command allows one to create a user with a space in
its name and the code for reading znc.conf allows spaces too. So now
one can even get rid of this users again...
psychon [Tue, 31 Mar 2009 12:25:24 +0000 (12:25 +0000)]
Make znc --datadir some-dir --makeconf work
Without this the restart after the config is written fails, because the file
name it wants to open went through ExpandConfigPath() twice. This lead to a
path like ./some-dir/configs/some-dir/configs.
psychon [Tue, 31 Mar 2009 09:07:02 +0000 (09:07 +0000)]
DCCSock: Make sure we don't cache too much data in memory
This now only reads new data from disk if there is less than 1 MiB left to be
sent, which is still a lot. Before this there was no limit and the other end of
the socket could try to make us run out of memory.
psychon [Tue, 31 Mar 2009 08:24:34 +0000 (08:24 +0000)]
DCC only allows file transfers of up to 4 GiB big files
Make CDCCSock use uint32_t to generate the "unsigned, 4 byte integer in network
byte order" which is used to acknowledge the received data. Also make
OpenFile() abort for files bigger than 4 GiB, because we would run into
integer overflows later on. These transfers might work with some remote client,
but ZNC is (no longer?) one of them. ;)
Thanks to KiNgMaR for the original patch and some help with the uint32_t stuff.
psychon [Mon, 30 Mar 2009 18:28:09 +0000 (18:28 +0000)]
Some changes to the code rewriting znc.conf
Added some error checking and fixes a bug where the exclusive lock we use on
the config file was removed. This was because we made the kernel allocate a
new inode for the config while our lock was still on the old version of the
config file. This should now be fixed.
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.