No module in extra/ comes with any data currently, so this was tested by moving
perform to extra/. The install is untested.
Signed-off-by: Uli Schlachter <psychon@znc.in>
The rule is that zncconfig.h must be the very same thing that is included. We
cheat and only include it in headers (so that modules dont have to have be
changed). However, it looks like some modules where missed.
This commit fixes test/ConfigTest which crashed if _GLIBCXX_DEBUG was enabled
(--enable-debug) because it didn't see this define before including a c++
header.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Come on, it's a self-signed certificate, how much value does it have anyway?
Also, it gets rid of a question during --makeconf which confuses some people.
This should now use $HOSTNAME and fall back to "host.unknown" if that isn't set.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Since commit 1a1cc4c756, we'd always send a "MODE #chan" to IRC when we
received a "JOIN #chan". It used to work before that commit, because the mode
reply which is automatically sent on join is sent before the "end of /names"
numeric.
This just removes that MODE request. Proper IRC server should always send a MODE
reply on channel join.
Thanks to nyuszika7h`` for the report.
Signed-off-by: Uli Schlachter <psychon@znc.in>
When we hit the "maximum open files" limit, we close the listener that hit this
error. Previously we did so silently which means no one could figure out what
happened.
This commits adds a broadcast message giving a hint, but this should never
happen in a real-world situation anyway (unless you have 1000 users).
Signed-off-by: Uli Schlachter <psychon@znc.in>
This fixes the "busy loop waiting for an SSL handshake to finish" which the last
"Update to latest Csocket" was already supposed to fix. However, that fix had a
bug if poll() is used instead of select().
poll()'s timeout argument is in milliseconds while select also allows
microseconds. Since Csocket originally used select(), it expects the
microseconds-approach. This means it has to divide by 1000 to get the timeout
argument for poll().
However, the iQuickReset which was used to "fix" (rather: hide) the busy loop
was less than 1ms so this still resulted in a timeout of 0 (= busy loop) because
integer division truncates the result.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This means that they will get a new cookie on the next request. This will make
sure that you will be able to use webadmin again if your IP changed (which seems
to happen to quite a number of people).
Signed-off-by: Uli Schlachter <psychon@znc.in>
This helps people figuring out that they are still building their modules for
the wrong znc version since they have more than one installation on their box.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Fixes:
- A possible crash bug for empty DNS replies with c-ares. E.g. a AAAA lookup for
google.com doesn't give any reply but is still successful. This might be a
c-ares bug (there is ARES_ENODATA) or c-ares just changed its behavior?
(No bug report, just noticed accidentally)
- Connecting to ipv4-only hosts with a v6 bindhost caused weird errors:
https://github.com/znc/znc/issues/47
- There was a pull request for some DSA server certificate thingy:
https://github.com/znc/znc/pull/46
- Busy loop waiting for an SSL handshake to finish:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631590
- Some other stuff? No idea what some of the changes in here are actually doing.
Signed-off-by: Uli Schlachter <psychon@znc.in>
For character values above 127, the signed char that could be used here did the
wrong thing. That is, *it >> 4 returned a negative value and the array hexdigits
was read indexed with that wrong value.
Fix this by explicitly using unsigned char.
Thanks to crocket for reporting this bug which he found with perform (broken
entries after a restart/reload).
Signed-off-by: Uli Schlachter <psychon@znc.in>
This moves the version check into the function which loads the module info. That
way, we just need a single dlsym() call per module and thus can't get any errors
from the second dlsym() call. And IMHO this feels nicer anyway. ;-)
Signed-off-by: Uli Schlachter <psychon@znc.in>
This adds hostmasks to autoattach. E.g. if you don't like me, you add an entry
of "! * psychon!*" and autoattach won't attach you to channels just because I
said something. The same can be done in the non-negated case, "only attach when
foo says something".
Signed-off-by: Uli Schlachter <psychon@znc.in>
The old code didn't actually destroy the session, but only made sure we couldn't
use it anymore. What a waste of memory.
This was tested by adding a DEBUG()-call to CWebSock::~CWebSock():
Before this patch:
Page Request [/]
Remote IP: 127.0.0.1; discarding session [ca104adaa54f933b6b8394e88e68ab0d22e0fc227ed23e93d1421e4d3fda8211]
Auto generated session: [d40364e8d0a55432b86a1b2598865c2323e35cc6e77cade35b9a1b7605712ca6]
After this patch:
Page Request [/]
Remote IP: 127.0.0.1; discarding session [707e3b262fe47b93d8c796354574506c398cc5b5d84aa2972dc3d031d8f731f5]
Destroying session [707e3b262fe47b93d8c796354574506c398cc5b5d84aa2972dc3d031d8f731f5, 127.0.0.1 for <unknown>
Auto generated session: [47de1c82a8b6eaae54a9cc8c29163ab53ec2add7198cf1df7f80506ea1bda2b6]
Obviously, the destructor is only called after this change.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Some modules (e.g. webadmin) don't handle messages to *module in any way. Make
it clear to the user why they didn't get any reply back in this case.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This fixes a problem where Csocket detected socket timeouts (as configured with
SetTimeout()) too late if there was few activity. See csocket's git commit
message for more info, I'm lazy. :-P
Signed-off-by: Uli Schlachter <psychon@znc.in>
Congratulations, Apple. Your OS is really great. In some versions (according to
google, it used to work in older releases), poll() can only handle sockets. If
you give it a pipe (as e.g. the shell module does), it will fail with POLLNVAL
which Csocket handles by going into an endless loop.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This causes every piece of code which wants to use CFile or CDir to have to
include FileUtils.h. This causes quite some noise.
Signed-off-by: Uli Schlachter <psychon@znc.in>
As a result, Utils.h no longer has to include Socket.h and lots of stuff breaks.
Due to a severe case of lazyness, some of the code for CExecSock is still in
Utils.cpp. Feel free to fix if you really have to.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Both these headers only really need CFile* which can be handled with a forward
declaration.
To make this possible, some methods are moved from the header file into the
corresponding implementation file, because they used CFile or CDir static
members.
Signed-off-by: Uli Schlachter <psychon@znc.in>
From Client.h, only CAuthBase is needed. This is solved by moving the whole
CWebAuth class to WebModules.cpp.
The include of FileUtils.h is avoided by changing the API. GetAvailSkins() now
returns the skin names instead of a CFile for the skin's path.
Signed-off-by: Uli Schlachter <psychon@znc.in>
znc.h pulls in most headers, Socket.h pulls in way less headers. This should
speed up compiles by 0.0000000314%.
The rest of this is compile fixes for stuff which assumed that Listener.h
includes znc.h for them. :-)
Signed-off-by: Uli Schlachter <psychon@znc.in>
ZNC will now send a PING if the connection was idle for 270 to 300 seconds.
After 540 seconds (that is, about 270 to 240 seconds later) the timeout is
triggered and ZNC reconnects.
These values are "inspired" by the values eggdrop uses.
The old timeouts were 180 to 210 secs for the PING and 240 secs for the timeout.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Instead of doing ugly stuff to shorten the "Loaded Module [foo]" message, we now
just always generate the shorter version of that message. The code paths which
didn't do this shortening now prepend that message themselves.
The result is that every message looks the same as it did before, but the code
for generating these is a little nicer.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This moves stuff to a two-step model. First, the new class CConfig reads the
config file, parses it and creates a in-memory model of stuff. Only then do we
actually go forward and apply the stuff.
The upside of this is that some config errors are caught before we change
anything on the running upside.
Let's see how much stuff this broke...
Signed-off-by: Uli Schlachter <psychon@znc.in>
When we have an error during rehashing / config writing, we continue keeping the
old lock around since we haven't gotten rid of that one yet.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This code now errors out if there is any error while writing the config. I
tested this with a full file system (full tmpfs of size 4k).
Signed-off-by: Uli Schlachter <psychon@znc.in>
Getting an exclusive lock on a file with TryExLock() requires write access,
therefor O_RDONLY is wrong here.
This worked back when we were using flock() for file locking, because flock()
doesn't need write access for an exclusive locks.
This fixes a bug where "--makeconf" claims that there is already a znc instance
running on the config file. This happened because it mis-interpreted the -EBADF
error from fcntl() as "something else already has a lock".
Signed-off-by: Uli Schlachter <psychon@znc.in>
Whenever an error happens with some file operation, the error flag is now set.
This is especially interesting for tracking errors from Write().
Signed-off-by: Uli Schlachter <psychon@znc.in>
This removes the following module hooks:
OnConfigLine()
OnWriteConfig()
OnWriteUserConfig()
OnWriteChanConfig()
Modules could use these hooks for writing/reading their own stuff to/from
znc.conf. However, no module (ever?) did this and IMHO no module should ever do
this either. Modules can save stuff via SetNV(), module arguments (SetArgs())
and in their GetSavePath().
Signed-off-by: Uli Schlachter <psychon@znc.in>
This fixes various issues with slow connecting users. E.g. the users caused
themselves to be added to the ConnectThrottle map even though they didn't
actually try to connect.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Thanks to this change, linking the following object files produces no unresolved
symbols: FileUtils.o Utils.o ZNCString.o MD5.o SHA256.o
The idea here is that ZNC is a little better modularized.
Signed-off-by: Uli Schlachter <psychon@znc.in>
If getopt_long() (GNU extension) isn't available, we use the plain old getopt()
instead. This means that long options won't work, but at least this compiles.
Tested on Solaris 9, but should also work on Irix.
Signed-off-by: Uli Schlachter <psychon@znc.in>
Changing the user name for a CUser instance is a really, really bad idea. There
are lots of paths that depend on the user name and only few of them are fixed up
when the user name changes.
This fixes a problem where admin's "CloneUser from to" caused problems with
modules, because all modules where loaded under the old user name and thus they
read/write NV data from the wrong directory in ~/.znc/users.
Thanks to un1matr1x for reporting this.
Signed-off-by: Uli Schlachter <psychon@znc.in>
shell didn't compile since 6bc36d1708 because it used the
three-argument-version of CModule::PutModule(). This commit replaced that with a
call to CModule::PutUser().
Signed-off-by: Uli Schlachter <psychon@znc.in>
This module hook is called to generate messages for unknown commands. This hook
has a default implementation that actually does something!
Signed-off-by: Uli Schlachter <psychon@znc.in>
With this, modules can use AddCommand() to register commands. CModule will
dispatch all calls to OnModCommand() to the correct command handler.
If a module calls AddHelpCommand(), it will also generate help output.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This let's CFile expand relative-to-home paths. I "accidentally" broke
ISpoofFile with some recent commit and that is now fixed with this. This should
solve this problem for quite a lot of other places, too.
Idea (c) by DarthGandalf, thanks. :)
Signed-off-by: Uli Schlachter <psychon@znc.in>
This works correctly because only the config writing/reading accesses
CZNC::m_sSSLCertFile directly, everything else goes through this getter.
This ChangeDir() call will also "sanitize" the path. E.g. "/foo//..//home///"
will be turned into "/home/" and stuff like that.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This makes the code use GetISpoofFile() instead of accessing m_sISpoofFile
directly. Additonally, CFile::GetLongName() is used for printing the filepath.
(This also removes an useless if branch, because nothing here cares if
m_sISpoofFile is empty, we just need the lock file.)
Signed-off-by: Uli Schlachter <psychon@znc.in>
This way, we can write the original value back to the config. Also, this "fixes"
a bug because webadmin didn't do this step.
Signed-off-by: Uli Schlachter <psychon@znc.in>
"Don't force --foreground when compiled with --enable-debug"
Instead, this is now wrapped in an #ifdef ALWAYS_RUN_IN_FOREGROUND, so that I
can use ./configure CXXFLAGS="-DALWAYS_RUN_IN_FOREGROUND".
Signed-off-by: Uli Schlachter <psychon@znc.in>
This changes admin to assume that an "empty username" was specified if some
arguments is empty which shouldn't be empty. This empty username is then
interpreted as meaning the current user.
Signed-off-by: Uli Schlachter <psychon@znc.in>
This function is the counterpart for CUser::AddCTCPReply(). Guess what? It
removes an entry from CUser::m_mssCTCPReplies again! It's magic!
Signed-off-by: Uli Schlachter <psychon@znc.in>
It shouldn't make any real difference (especially not for std::vector), but
"empty()" is better than using "size() == 0".
Signed-off-by: Uli Schlachter <psychon@znc.in>
CTCP requests can't contain spaces so it's useless to specify rules for those.
This doesn't affect any of the existing callers because those use Token(0) for
generating the first argument to this function.
Signed-off-by: Uli Schlachter <psychon@znc.in>
All the places that add entries to the CTCPReplies map use CString::Token(0) to
split the first token away. This means it is impossible for this to contain
spaces. Now this means that it is pointless to look up the full CTCP request in
the CTCPReplies map because it can't contain any matching item.
Signed-off-by: Uli Schlachter <psychon@znc.in>
We are using a vanilla version of Csocket again. Previously, our copy of
Csocket.h had a new '#include "zncconfig.h"'.
The other changes are mostly cleanup for various compiler warnings. The switch
from inet_ntoa() to inet_ntop() is for thread-safety reasons.
Signed-off-by: Uli Schlachter <psychon@znc.in>
If you did ./configure --enable-tcl, tcl wasn't actually enabled because
--enable-extra was missing, That's less than optimal.
Just moving modtcl out of modules/extra solves this problem.
Big thanks go to zynox/kylef for noticing this!
Signed-off-by: Uli Schlachter <psychon@znc.in>
When ChanServ ops someone in a channel without joining first, znc didn't call
modules for this event, because it couldn't figure out a CNick* instance to use
Instead, the module hooks are now executed with a temporary CNick instance which
is created by CIRCSock anyway.
Big thanks to Robby for reporting this and helping me test it!
Signed-off-by: Uli Schlachter <psychon@znc.in>
The explanation for the arguments for AddPort and DelPort can still be reached
via e.g. "/znc addport". Removing this makes the output from /znc help a lot
smaller.
Signed-off-by: Uli Schlachter <psychon@znc.in>