psychon [Thu, 28 Aug 2008 10:47:01 +0000 (10:47 +0000)]
Add a 'ShowMOTD' command to *status and reorder 'HELP' output
ShowMOTD is now close to the other MOTD commands which only admins can access.
The old 'MOTD' is still available, but the help doesn't mention it anymore in
favor of 'MOTD'.
psychon [Sun, 24 Aug 2008 06:25:11 +0000 (06:25 +0000)]
Unify some of the preprocessor macros in Modules.cpp
The only difference between MODUNLOADCHK and GLOBALMODCALL and between
MODHALTCHK and GLOBALMODHALTCHK was that the one used CModule while the other
one used CGlobalModule.
Create two new macros that expects the class name as an extra parameter and
make all those other macros just call these two.
psychon [Sun, 24 Aug 2008 06:19:14 +0000 (06:19 +0000)]
Don't check if perl is enabled in modperl
The Makefile only compiles this module if it is enabled.
I think it's better to error out if for some reason this doesn't work instead
of silently producing an empty modperl.so.
psychon [Fri, 22 Aug 2008 12:48:56 +0000 (12:48 +0000)]
Fix some of the direct module calls in Client.cpp
OnModCTCP(), OnModCommand() and OnModNotice() are now called through a
preprocessor macro that does all the magic. This fixes a couple of bugs:
- the m_pUser member of global modules for OnModNotice() was wrong
- OnModCTCP() wasn't called for global modules
- Finally handle 'throw UNLOAD' for all of this three module calls
psychon [Wed, 20 Aug 2008 08:13:23 +0000 (08:13 +0000)]
Some cleanup and optimizations to CTable
CTable now caches the width of each column instead of recalculating it
each time it is needed. The code for this was there before, but it was not
used. Now the widths are calculated when the table is filled, not when the
width is needed the first time.
This caching leads to a huge speedup (3-4 times faster) if there are many rows
in the table.
This also cleans up the interface by making it possible to mark
GetColumnWidth and GetLine as const.
Fix a bug where ZNC always thought all channels where empty
Due to the recent change that ZNC calls SetIsOn(true) when we receive the JOIN,
not the 'end of names' reply, the nick list of a channel was always ignored.
This fixes this bug.
Thanks to cnu for using a svn version and reporting this bug. :)
When our primary nick is already taken, we try a couple of different nicks in
order to be able to connect to the IRC server. This code is now in an
own function.
BTW: CIRCSock::Readline() is still waaay too long.
Move the forwarding of raw 353 into an own function
This also contains some minor changes to the code. One of those is that we now
also handle namesx and uhnames for channels we don't know.
BTW: CIRCSock::ReadLine() is waaay too long.
The old code used a timer. That timer needed to be restarted if the user list
was changed (adding / removing of users), because it saved an iterator into
that map between runs, which would become invalid.
The new code in CConnectUserTimer::RunJob() is actually more complicated now,
but the iterator is gone. This also means no need to restart that timer
more or less always. ;) (This also means one theoretical source of bugs less)
partyline: Some fixes for users who are not connected to IRC
This was found via default channels (LoadModule = partyline ~#chan).
- Always use a valid (=non-empty) server name
- If a user is not connected to IRC, all clients might have a different idea of
the current nick. Handle this for SendNickList() via a new function
PutUserIRCNick() that uses the irc nick if we are connected to IRC and else
correctly uses the nick that clients thinks it curretnly has.
See these links for info on these defines:
http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt12ch29.html
http://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode.html
Shell module: Don't give any stdin to executed apps
We now close the write end of the pipe that serves as stdin for the apps
we run. This means that any read attempts will return EOD (read() returns 0)
which should hopefully tell our apps that we don't have stdin for them.
Sadly vim doesn't care... (Only thing I tested that still broke)
Make CClient::GetNickMask() always return a valid nickmask
The recent removal of CUser::m_bIRCConnected lead to a bug here which is now
fixed.
In addition to this, this function now also works properly for users without
a vhost.
Oh and in User.cpp: Make sure CUser::GetIRCServer() returns an empty string
when we are no longer connected to an IRCd.
Replace usage of getresuid() with getuid() and geteuid()
getresuid() is a non-standard extension and is actually not defined on
some (older) boxes. Since we gain nothing with also checking the saved user id,
we can use this instead and, voila, znc compiles again.
CUser::GetIRCSock() != NULL is the replacement. This is a small chance in
sematics. Before this, a user only counted as connected to IRC when the 001
numeric was received. Now it already counts as connected when the connection
was established. This change doesn't hurt any of the current users of
CUser::IsIRCConnected() and so this change should be fine.
Any library the znc binary links to is automatically available to modules.
So there is no point in linking modules to @LIBS@ as znc is linked against
those already. modules/Makefile.in already does it this way, not also
znc-config does it
__GNU_LIBRARY__ doesn't seem to be needed on FreeBSD
This defines was added in rev 586 saying it's needed for 'older BSD boxes'.
I don't know how old 'old' is in this context, but since we don't compile
on FreeBSD 4 anyway (which really is old), because getopt_long is missing
(added in FreeBSD 5), we should give this a try.
I have no FreeBSD 5 box for testing if znc compiled/compiles there, so
suprise me!
Config reading: Apply a small (unnoticeable) optimization
Trim() always removes all trailing and leading spaces and line endings from
that string, so there is no point in this main loop. It will always run once,
anyway.
If we were joining a channel on a server with NAMESX support while a client was
connected that didn't know NAMESX and we received a raw 353 with a trailing
whitespace (UnrealIRCd does this), we were calling std::string::at(0) for an
empty string, which caused some assert to fail and ZNC to die.
CIRCSock: Only say we are reconnecting if there is a server to connect to
If you '/msg *status delserver'd your last server, you would get a message
saying ZNC will reconnect, but it didn't. Now those messages look much better.
Fix a privilege escalation bug in webadmin if auth modules are used
auth modules = imapauth and saslauth
Some code in CWebAdminSock::OnLogin() is skipped if a module handles auth
and thus m_pUser stays NULL. Most checks for admin rights only check for
m_pUser being NULL and thus any user WHO ALREADY HAS A VALID LOGIN can edit
other users if they know their user name.
(=Change the password of an admin and log in using this info)
One of the major excpeptions are the templates which use m_bAdmin instead of
m_pUser for checking the privieleges, thus users still see the normal pages
and this bug stayed unnoticed for a while.
This patch now moves the code that sets m_pUser to some code which is executed
in both cases, when an auth module is in effect and when one isn't.
(Well, technically this isn't a move, but code duplication, but executing this
twice won't hurt and one of the follow-up patches cleans this up.)
psychon [Sat, 21 Jun 2008 11:20:30 +0000 (11:20 +0000)]
Clean up some includes
We no longer include Csocket.h in main.h because only few files actually need
it. (Only HTTPSock.h and Timers.h)
We also clean up some includes in Timers.h. It didn't actually include
the file it needed.
Oh and this also adds a warning to main.h if PATH_MAX is undefined. If this
happens, it is most likely a bug that needs to be addressed. (some missing
includes, I'd guess)
psychon [Tue, 3 Jun 2008 12:07:49 +0000 (12:07 +0000)]
Module query (like *shell) now uses the module name as prefix, not 'znc'
This hopefully avoids some ugly stuff. Namely, irssi pretending *status changed
its nick to *shell etc because they have the same ident and host and are in no
common channel.
This patch is based on a patch from SilverLeo. If this breaks it's his fault!
psychon [Tue, 3 Jun 2008 07:15:52 +0000 (07:15 +0000)]
Handle channel CTCP the same way we do for private CTCPs
This patch doesn't actually change anything for private CTCPs, it's
only the indentation level that changes! (Well, and that this code gets
its own function...)
psychon [Mon, 26 May 2008 15:02:09 +0000 (15:02 +0000)]
Webadmin: Don't reset all channel settings submitting a user page
In r1058 the behaviour of CUser::Clone() was changed. It now also handles the
channel settings. This change breaks webadmin, because it doesn't properly
set up the channels it feeds to CUser::Clone()
This commit 'fixes' this by adding an extra parameter to CUser::Clone() which
makes it revert to the old behaviour. Webadmin uses this parameter.