Commit Graph

63 Commits

Author SHA1 Message Date
psychon
4e5f9e8602 HTTPSock: Send Last-Modified headers for static files
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2246 726aef4b-f618-498e-8847-2d620e286838
2011-01-03 15:21:30 +00:00
psychon
9ef41ae6ad Make CHTTPSock generate a properly formated "Date:" header
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2245 726aef4b-f618-498e-8847-2d620e286838
2011-01-03 15:21:09 +00:00
psychon
aca3535c8d CHTTPSock: Fix for latest commit
We have to grab the contents of the read buffer before we do DisableReadLine().


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2149 726aef4b-f618-498e-8847-2d620e286838
2010-09-27 18:52:44 +00:00
psychon
9ff7a3d05e Remove CHTTPSock::GetErrorPage()
There is no valid reason to use GetErrorPage() instead of PrintErrorPage() which
can be seen from the fact that all the existing callers are *wrong*. So, to
avoid this mistake in the future, inline GetErrorPage() into its only valid
caller (PrintErrorPage()).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2040 726aef4b-f618-498e-8847-2d620e286838
2010-06-22 15:26:17 +00:00
cflakes
26396b1b06 Revert unintended change from revision 2029 and added a comment so it won't happen again.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2036 726aef4b-f618-498e-8847-2d620e286838
2010-06-21 12:51:37 +00:00
cflakes
114bb25aa8 Fixed an issue identified by Un1matr1x: If you were running two 0.090 ZNCs on the same IP,
(but different ports), any web login session from ZNC #1 would overwrite the session from
ZNC #2. While doing this, also removed an unnecessary check in CHTTPSock::SendCookie and
CHTTPSock::GetRequestCookies (which doesn't transparently translate cookie names and has
never been used so far).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2030 726aef4b-f618-498e-8847-2d620e286838
2010-06-19 19:07:24 +00:00
cflakes
bb567c51de We now trim all leading and trailing spaces from parameter values passed
into webadmin/webmods. This makes sense in almost every case, be it that
users accidentally hit the space bar or try to outsmart ZNC by entering
nothing but spaces into a textbox.
By doing the latter, it was possible to trick ZNC into not starting up
again. Thanks to Redirect_ for bringing this to our attention. Another
commit that will fix the underlying problem while writing to the config
file will follow.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1961 726aef4b-f618-498e-8847-2d620e286838
2010-05-01 18:36:05 +00:00
psychon
54073d1147 HTTPSock: Split up parameter access
Every function on CHTTPSock which works with request parameters now has a new
flag bool bPost which decides whether only POST or GET parameters should be
used.

This breaks everything which tries to access GET parameters, but once this is
fixed we should be pretty safe against CSRF.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1935 726aef4b-f618-498e-8847-2d620e286838
2010-04-25 14:09:23 +00:00
psychon
b0d140e2ed Webmods: Only accept POST requests with a secret parameter
This is a first step against CSRF. Thanks to flakes for the idea.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1932 726aef4b-f618-498e-8847-2d620e286838
2010-04-25 13:04:51 +00:00
cflakes
5dcea36faa Do not expose ZNC's version number through the web interface
unless there's an active user session.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1877 726aef4b-f618-498e-8847-2d620e286838
2010-04-04 15:20:22 +00:00
cflakes
4daa637130 WebMods/HTTPSock: Do not send Set-Cookie headers if the cookie has not changed.
To achieve that, split internal cookie jar into a jar for received cookies
and one for cookies that are to be sent with the response.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1840 726aef4b-f618-498e-8847-2d620e286838
2010-03-23 16:48:25 +00:00
psychon
082008ed98 CHTTPSock: Print warnings if one tries to send multiple pages
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1837 726aef4b-f618-498e-8847-2d620e286838
2010-03-16 09:55:10 +00:00
psychon
3e49639cc9 Really fix auth modules
It turns out that there was still another Close() hiding in CHTTPSock which made
stuff fail. However, just removing it fixes stuff.

Thanks to DarthGandalf for noticing that my fix wasn't fixing the bug that was
bugging him.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1835 726aef4b-f618-498e-8847-2d620e286838
2010-03-16 09:23:32 +00:00
psychon
cb193d8f72 Make it possible to process HTTP requests async
This changes CHTTPSock so that one can handle HTTP requests asynchronously.
This is done by not forcing a page to be sent out in the caller of
OnPageRequest() but instead requiring a call to the new function
CHTTPSock::PrintPage().


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1830 726aef4b-f618-498e-8847-2d620e286838
2010-03-15 15:27:02 +00:00
prozacx
c27713cc1d Added support for cookies and sessions. Logging in is now done via cookies.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1799 726aef4b-f618-498e-8847-2d620e286838
2010-03-01 01:22:02 +00:00
psychon
f72e2f8abd Remove --disable-modules
ZNC without modules is like rain without being inside,
you really don't want that!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1794 726aef4b-f618-498e-8847-2d620e286838
2010-02-25 12:29:40 +00:00
psychon
1d88f564dc Fix a bunch of style suggestions from cppcheck[1]
Thanks to DarthGandalf for this patch. You must be bored. :P

[1] cppcheck.sf.net


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1776 726aef4b-f618-498e-8847-2d620e286838
2010-02-19 16:21:07 +00:00
psychon
ec828fd081 Fix all overloaded Csock::ReadData() functions
CSocket changes the prototype, we follow.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1767 726aef4b-f618-498e-8847-2d620e286838
2010-02-18 13:16:44 +00:00
prozacx
8b7a876625 Added GetPath(), only print headers once, forward declare Cmodule
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1734 726aef4b-f618-498e-8847-2d620e286838
2010-02-05 02:03:17 +00:00
cflakes
ceaa6234f0 Fix[1] HTTP Cache-Control headers for static files served by webadmin.
[1] http://www.mnot.net/cache_docs/#CACHE-CONTROL


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1719 726aef4b-f618-498e-8847-2d620e286838
2010-01-24 16:05:21 +00:00
silverleo
07d7477dec It's 2010, where's my hoverboard?
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1693 726aef4b-f618-498e-8847-2d620e286838
2010-01-06 09:37:05 +00:00
psychon
98e37dd547 Webadmin: Don't include the ZNC version in the basic auth realm
If you save a password in your browser that password is bound to the "realm" of
the authentication. Since ZNC included its version number in this, all your
saved passwords were rendered useless on upgrade.

Avoid this by not including the version number in the HTTP authentication realm.

Thanks to tylerdu for reporting this.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1627 726aef4b-f618-498e-8847-2d620e286838
2009-09-14 17:23:40 +00:00
psychon
c7583c4946 Fix a low impact directory traversal bug
A common pattern for checking directories in ZNC is the following:

	sAbsolutePath = CDir::ChangeDir(sAllowedPath, sFile);
	if (sAbsolutePath.Left(sAllowedPath.length()) != sAllowedPath)
		Error;

But there is a problem: If sAllowedPath doesn't end with a slash, we are
vulnerable to an attack. If e.g. sAllowedPath = "/foo/bar", then
sFile = "../bartender" would result in sAbsolutePath = "/foo/bartender". Since
this path does begin with sAllowedPath, the code allowed it.

There shouldn't be any places where this can be exploited currently, but it is
still a security bug (path traversal).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1569 726aef4b-f618-498e-8847-2d620e286838
2009-07-21 18:36:33 +00:00
psychon
be6bd29b20 Limit HTTP POST data size to 1MiB
We need to have an upper limit of the size of HTTP POST data. With the current
code you could just send 4 GiB of data to webadmin and ZNC would try to keep all
of this in memory.

This patch implements an upper limit for HTTP POST data of 1 MiB.

Thanks to cnu for finding this.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1559 726aef4b-f618-498e-8847-2d620e286838
2009-07-06 17:07:03 +00:00
psychon
0af674ac89 First argument to CHTTPSock::PrintHeader() should be of type off_t
Thanks to KiNgMaR


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1474 726aef4b-f618-498e-8847-2d620e286838
2009-04-02 12:54:12 +00:00
psychon
2f5a1cafc5 Switch some code to use the new return type of GetSize()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1471 726aef4b-f618-498e-8847-2d620e286838
2009-03-31 15:11:32 +00:00
sebastinas
812526278a Swap some lines in CHTTPSock::ReadLine
Copying sData and trimming it can be omitted if the function is left
because m_bGotHeader is true.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1409 726aef4b-f618-498e-8847-2d620e286838
2009-03-04 18:19:29 +00:00
psychon
a938666602 HTTPSock: Remove some code which makes no sense
Thanks to sebastinas


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1408 726aef4b-f618-498e-8847-2d620e286838
2009-03-03 17:10:52 +00:00
psychon
21120e2146 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.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1395 726aef4b-f618-498e-8847-2d620e286838
2009-02-24 16:00:11 +00:00
psychon
a7e8326300 Fix some "uninitialized variable" compiler warning
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1392 726aef4b-f618-498e-8847-2d620e286838
2009-02-23 19:24:41 +00:00
psychon
8b15351aa2 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.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1374 726aef4b-f618-498e-8847-2d620e286838
2009-02-05 17:11:45 +00:00
psychon
8177a609d2 Make webadmin's debug output for ETags more readable
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1373 726aef4b-f618-498e-8847-2d620e286838
2009-02-05 15:33:48 +00:00
psychon
35458af905 Make some functions in CHTTPSock pure virtual where it makes sense
Or do you seriously expect anyone to set up a http which always replies
with 404 File not found errors?


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1372 726aef4b-f618-498e-8847-2d620e286838
2009-02-04 16:29:06 +00:00
psychon
649dca204f HTTPSock: Use TrimLeft() instead of a combination of Left() and LeftChomp()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1364 726aef4b-f618-498e-8847-2d620e286838
2009-02-02 15:24:48 +00:00
psychon
a6995ba59a Remove that useless and more or less unused enum for open() modes
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1361 726aef4b-f618-498e-8847-2d620e286838
2009-02-02 15:03:32 +00:00
psychon
235b10c200 Use that new define everywhere
Now there are no uses of DEBUG_ONLY() left :(


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1349 726aef4b-f618-498e-8847-2d620e286838
2009-01-25 16:51:54 +00:00
psychon
08ad0291ea Happy New Year 2009 everyone!
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1317 726aef4b-f618-498e-8847-2d620e286838
2009-01-01 12:22:21 +00:00
psychon
90ecce7880 Make httpsock (and thus webadmin) support client side caching of static files
If such a file is served (e.g. webadmin images) an ETag header is now generated.
When the browser needs the file again it sends the ETag back to us in an
If-None-Match header and the file isn't transfered again if the ETag still
matches. This should greatly reduce webadmin's traffic usage.

This also updates HTTPSock to sometimes generate a HTTP/1.1 reply
(ETag was added in HTTP/1.1).

This was successfully tested with Firefox 2 & 3 and IE7.
Konqueror failed badly (No If-None-Match header generated).

Thanks to flakes for having the idea, writing the patch and testing it.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1248 726aef4b-f618-498e-8847-2d620e286838
2008-10-12 15:49:03 +00:00
psychon
92a718e3a6 Use CSocket in webadmin instead of directly using Csock
This gets rid of some code duplication for managing the sockets.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1240 726aef4b-f618-498e-8847-2d620e286838
2008-10-04 20:55:50 +00:00
kroimon
5237a24747 Use CString::Equals() everywhere.
* (CString::CaseCmp() == 0) became CString::Equals()
* (CString::CaseCmp() != 0) became !CString::Equals()
* replaced some occurrences of strn?casecmp

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1234 726aef4b-f618-498e-8847-2d620e286838
2008-09-30 15:15:59 +00:00
psychon
18ce52e32d Limit the maximal read buffer space that is used for every socket
CSocket caches the data read from a socket and then looks for lines in there.
If there is no line end, this buffer can grow quite large. This patch now
closes sockets if they get a huge read buffer.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1233 726aef4b-f618-498e-8847-2d620e286838
2008-09-30 14:43:51 +00:00
psychon
01bc68b1cb Move ChangeDir() and MakeDir() from CUtils to CDir
Those function were not modified. Only change is the name.

Those *Dir() functions really made no sense in CUtils when there is FileUtils
stuff. They really fit much better into here. I'll bet they'll make new friends
fast. I mean, why shouldn't they?
Uhm... sorry ;)


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1044 726aef4b-f618-498e-8847-2d620e286838
2008-05-08 16:58:32 +00:00
psychon
5665fd872d Update to latest Csocket
This breaks (& fixes again, as far as ZNC itself is concerened) API!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1040 726aef4b-f618-498e-8847-2d620e286838
2008-05-06 14:47:13 +00:00
psychon
c64d7bc108 Force a space between if, for, while and (
This was done via:
   sed -ir 's/if(/if (/g; s/for(/for (/g; s/while(/while (/g' \
        *.h *.cpp modules/*.cpp



git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1030 726aef4b-f618-498e-8847-2d620e286838
2008-04-20 13:08:44 +00:00
psychon
1f9e4f9601 Save some space for --disable-modules by not compiling template and http socks
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@927 726aef4b-f618-498e-8847-2d620e286838
2008-01-18 22:46:40 +00:00
psychon
eeec633e30 Update copyright header for 2008
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@910 726aef4b-f618-498e-8847-2d620e286838
2008-01-07 21:13:07 +00:00
psychon
1f84cda286 Webadmin sent 'Server: ZNC ZNC 0.051', remove one 'ZNC'
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@864 726aef4b-f618-498e-8847-2d620e286838
2007-11-06 20:13:15 +00:00
psychon
a09a7e79f6 Switch to the copyright headers the GPLv2 wants us to have
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@843 726aef4b-f618-498e-8847-2d620e286838
2007-09-21 18:55:33 +00:00
prozacx
6dcacaa79e Added contact info
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@752 726aef4b-f618-498e-8847-2d620e286838
2006-09-13 07:39:48 +00:00
prozacx
a9e60b43c5 Migrated away from CString::ToString() in favor of explicit constructors
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@669 726aef4b-f618-498e-8847-2d620e286838
2006-02-25 09:43:35 +00:00