Commit Graph

65 Commits

Author SHA1 Message Date
psychon
bf6dc459db WebModules: Fix a crash during shutdown
During shutdown, the global list of sessions is destroyed. The new multimap
which counts sessions per address is also destroyed. However, they are destroyed
in unspecified order. This is not what we want because destructing the session
map also destroyed all the sessions which then has to access the sessions-per-ip
multimap. This obviously crashes if the multimap was already destroyed.

The fix here is to introduce a new class that contains both of those maps and
makes sure all the sessions are destroyed before the maps are destroyed
themselves. I hope this description makes some sense...


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2264 726aef4b-f618-498e-8847-2d620e286838
2011-01-14 22:03:33 +00:00
psychon
913a3c8ded Limit the number of web sessions per IP to 5
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2263 726aef4b-f618-498e-8847-2d620e286838
2011-01-14 20:22:43 +00:00
psychon
4556cc7c9b WebMods: Verify a session belongs to the remote IP address
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2262 726aef4b-f618-498e-8847-2d620e286838
2011-01-14 20:22:23 +00:00
psychon
577a097e32 Keep a list of web sessions per IP address
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2261 726aef4b-f618-498e-8847-2d620e286838
2011-01-14 20:22:02 +00:00
psychon
b9b0fd4c87 Oh, shiny... NOT
(Yes, it's that time of the year again)

Signed-off-by: Uli Schlachter <psychon@znc.in>

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2260 726aef4b-f618-498e-8847-2d620e286838
2011-01-14 17:03:24 +00:00
psychon
fa5b3acc8f webmods: Remove some more useless code
We don't actually have a "modlist" template, so this code would cause a 404.
Going through the "find module with empty name" codepath here has the same
result, so this can be safely removed.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2239 726aef4b-f618-498e-8847-2d620e286838
2011-01-01 22:59:41 +00:00
psychon
0ca689f2eb webmods: Fix
One of my recent commits made webmods only find user modules instead of global
modules. This worked before because m_sForcedUser was an empty string which made
the code look for global modules. This commit adds an explicit check for global
modules which hopefully fixes all problems.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2238 726aef4b-f618-498e-8847-2d620e286838
2011-01-01 22:57:54 +00:00
psychon
5050b93658 WebMods: Clean some stuff up
This removes two unused methods (ResolveModule() and FillErrorPage()) and marks
some other methods const/static/protected.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2236 726aef4b-f618-498e-8847-2d620e286838
2010-12-31 16:15:53 +00:00
psychon
3f62466751 WebMods: Remove some dead code
Using some module as another user didn't actually work. For user modules, the
following code stops you:

 else if (!pModule->IsGlobal() && pModule->GetUser() != GetSession()->GetUser()) {
     PrintErrorPage(403, "Forbidden", "You must login as " + pModule->GetUser()->GetUserName() + " in order to view this page");

For global modules this didn't work either. Once a "forced" user name was
specified, OnPageRequestInternal() stopped looking at global modules:

 CModule* pModule = CZNC::Get().FindModule(m_sModName, m_sForceUser);
 if (!pModule && m_sForceUser.empty()) {
 [snip]
 if (!pModule) {
     return PAGE_NOTFOUND;

So, whatever m_sForceUser was supposed to do, it never did that.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2235 726aef4b-f618-498e-8847-2d620e286838
2010-12-31 15:52:54 +00:00
psychon
377bbf80f3 Fix the only warning from -Wswitch-enum we had
WebModules.cpp:511: error: enumeration value ‘PAGE_NOTFOUND’ not handled in
switch [-Wswitch-enum]


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2179 726aef4b-f618-498e-8847-2d620e286838
2010-11-07 16:57:08 +00:00
darthgandalf
417018172c Really fixed embedded web stuff after installation.
This introduces workaround, but templates can't look
the same filename in different directories...

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2135 726aef4b-f618-498e-8847-2d620e286838
2010-09-12 18:19:45 +00:00
darthgandalf
62e25df78b Make embedded web stuff to work even after install.
Thanks to un1matr1x for reporting this.

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2134 726aef4b-f618-498e-8847-2d620e286838
2010-09-12 17:27:51 +00:00
darthgandalf
dffabfed2e Modules can now embed web stuff directly to other web pages which support this feature.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2128 726aef4b-f618-498e-8847-2d620e286838
2010-09-11 18:51:54 +00:00
psychon
6d16047113 WebMods: Use PrintErrorPage() instead of GetErrorPage()
GetErrorPage() only generates the HTML for the error page while PrintErrorPage()
actually makes sure the error page is sent with the correct HTTP status code.
(We sent all error pages with status "200 OK"!)


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2039 726aef4b-f618-498e-8847-2d620e286838
2010-06-22 15:18:56 +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
psychon
f31621b305 Remove some unneeded functions from CWebSock
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2014 726aef4b-f618-498e-8847-2d620e286838
2010-06-07 12:38:24 +00:00
cflakes
f4b4eafc74 Removed the mis-use of the fake module concept in WebMods.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2011 726aef4b-f618-498e-8847-2d620e286838
2010-06-06 11:41:31 +00:00
cflakes
779401307e Fixed web mod traffic being counted twice. Issue identified by psychon.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@2003 726aef4b-f618-498e-8847-2d620e286838
2010-05-22 10:32:59 +00:00
psychon
c6b5a4d4db Move module's templates to their data dir
Instead of having the template files and images in /usr/share/znc/www/<mod>/,
modules now get to use /usr/share/znc/<mod>/tmpl/ and files/ for this purpose.
This puts those directories for static data to good use again and might even fix
some bugs (after all, the code for that dir is older and more tested than the
new code for www/).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1997 726aef4b-f618-498e-8847-2d620e286838
2010-05-17 13:25:17 +00:00
psychon
38d6129964 Move the definition of _SKINDIR_ elsewhere
It's only used in WebModules.cpp and in contrast to the other #defines from
main.h, this one is not set in configure by default.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1996 726aef4b-f618-498e-8847-2d620e286838
2010-05-17 12:56:23 +00:00
psychon
fbe5dd10e7 Move module templates to DATADIR
The file hierarchy standard wants that!


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1982 726aef4b-f618-498e-8847-2d620e286838
2010-05-13 16:51:17 +00:00
psychon
0c0c51172e WebModules: Make PAGE_DONE imply Close()
When one now finishes a web request with PAGE_DONE, the code actively calls
Close(CLT_AFTERWRITE) which one previously had to call explicitly. This means
there is finally a difference between PAGE_DONE and PAGE_DEFERRED. ;)


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1981 726aef4b-f618-498e-8847-2d620e286838
2010-05-13 15:54:06 +00:00
psychon
ee66aca77b Some debug output less
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1968 726aef4b-f618-498e-8847-2d620e286838
2010-05-03 17:53:47 +00:00
psychon
3b6205979e WebMods: Calculate the module's web path correctly
Until now, the code checked for <moddir>/www/<mod name> and just used
./modules/www/<mod name> if the other dir didn't exist.

Now we calculate the correct path from the module's shared object's path, which
is the correct thing to do.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1967 726aef4b-f618-498e-8847-2d620e286838
2010-05-03 13:49:45 +00:00
psychon
99f1efc843 Some more fun with tabs
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1966 726aef4b-f618-498e-8847-2d620e286838
2010-05-02 08:36:57 +00:00
cflakes
9c5068a754 WebMods: Fix cookie check and menu entry variables to use the new GetParam methods.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1936 726aef4b-f618-498e-8847-2d620e286838
2010-04-25 14:45:22 +00:00
cflakes
68c4931e2d WebMods: Delete obsolete login.tpl template. The login form has been
on / and /help and so on for some months.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1934 726aef4b-f618-498e-8847-2d620e286838
2010-04-25 13:52:19 +00:00
cflakes
298d7f0997 WebMods: Following the last commit, this adds the CSRF check token
to existing action="post" forms. Right now, we don't have much of a
real protection against CSRF yet, but psychon is working on making
that happen :)


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1933 726aef4b-f618-498e-8847-2d620e286838
2010-04-25 13:35:06 +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
psychon
eaaddf01bb Webmods: Only accept "/login"
Nothing uses a "/login/bla"-style URI and thus we shouldn't have to check for it


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1931 726aef4b-f618-498e-8847-2d620e286838
2010-04-25 12:52:03 +00:00
cflakes
49df8dc27d Clarify the meaning of returning false from OnWebRequest.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1886 726aef4b-f618-498e-8847-2d620e286838
2010-04-05 15:17:23 +00:00
psychon
9b9fd6699a Cosmetic fix for the debug output
PrintStaticFile() called ExpandFile() twice if debug output was enabled which
caused it's DEBUG() error messages to be printed twice.

It then called CHTTPSock::PrintFile() to print the actual file. PrintFile()
always sends a result page, no matter if this is an error page or a proper
result page. Thus we should always return PAGE_DONE here, since PAGE_NOTFOUND
was already handled.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1882 726aef4b-f618-498e-8847-2d620e286838
2010-04-04 18:54:44 +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
6c5421b021 Deleted obsolete modules/webadmin dir, copied CSS files for ice & default to
webskins dir, made default the _default_ skin, moved dark-clouds to dark-clouds,
added /skinfiles/ feature to base skins on each other (and not only on default).

Next up: re-adding help texts that got lost during webadmin->webmods transition,
making skins look nice again.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1868 726aef4b-f618-498e-8847-2d620e286838
2010-04-04 10:27:33 +00:00
psychon
0decb1b7a2 GetSession(): Properly cache the result
This function caches its result for not-logged-in users since r1857. With this
commit, it also now works properly for logged-in ones.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1862 726aef4b-f618-498e-8847-2d620e286838
2010-03-30 19:52:17 +00:00
psychon
039d95073e Bugfix for CWebSock::GetRequestCookie()
When a module page is requested, m_sModName is set. When then GetSession() tries
to look up its session cookie, it doesn't find it since GetRequestCookie()
actually looks up Mod::<modname>::<cookie name>.

The fix is to look up the global cookie name if the mod one doesnt exist.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1861 726aef4b-f618-498e-8847-2d620e286838
2010-03-30 19:49:51 +00:00
psychon
ba05f11ea4 Remove CWebSock::m_bLoggedIn
We can just check if m_pUser is NULL for the very same thing.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1859 726aef4b-f618-498e-8847-2d620e286838
2010-03-30 12:20:31 +00:00
psychon
4d149f3d5f Use GetSession() instead of m_spSession
m_spSession could be a NULL pointer while GetSession() new returns a NULL
pointer.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1858 726aef4b-f618-498e-8847-2d620e286838
2010-03-30 12:11:27 +00:00
psychon
12629f8e94 Make sure CWebSock::GetSession() only generates one session
When one sent a basic-auth header, OnLogin() was called with the request's data
which caused a GetSession() call which generated a new session. Sadly, this
session wasn't saved anywhere, so a new one session was generated later when
OnPageRequest() triggered. This could lead to a NULL pointer dereference.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1857 726aef4b-f618-498e-8847-2d620e286838
2010-03-30 12:06:27 +00:00
psychon
b22c63c6c4 And again a little less spamminess
Meh, so much work to do on these --debug spam. :(


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1855 726aef4b-f618-498e-8847-2d620e286838
2010-03-30 10:10:26 +00:00
cflakes
cf3fbdffff Add a robots.txt file. Since WebMods now deliver (albeit basic) pages to visitors
that have not logged into any ZNC account, we certainly want to protect peoples'
ZNC's from Google's crawlers.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1843 726aef4b-f618-498e-8847-2d620e286838
2010-03-23 23:26:38 +00:00
cflakes
5b723fe7a4 WebSock: Add PAGE_DONE to EPageReqResult. It's used to better differentiate between
async processing (PAGE_DEFERRED) and redirects and other synchronous stuff (-> PAGE_DONE).


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1842 726aef4b-f618-498e-8847-2d620e286838
2010-03-23 18:03:12 +00:00
cflakes
437eef7fdd Add OnWebPreRequest web module hook to allow modules to do PAGE_DEFERRED style async processing.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1841 726aef4b-f618-498e-8847-2d620e286838
2010-03-23 17:59:42 +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
cflakes
bf5e56c04f WebMods: Add an error message for users that have cookie support turned off.
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1839 726aef4b-f618-498e-8847-2d620e286838
2010-03-23 16:12:38 +00:00
psychon
39c5a677a9 Fix a couple of places where WebMods tried to send multiple pages
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1838 726aef4b-f618-498e-8847-2d620e286838
2010-03-16 10:04:31 +00:00
psychon
fffa0f7d36 Remove the spamminess of --debug a little
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1836 726aef4b-f618-498e-8847-2d620e286838
2010-03-16 09:53:58 +00:00
psychon
b764aa7b42 Fix WebModules with auth modules
When e.g. imapauth started handling a login from WebMods it opened a new TCP
connection etc. This took time, but WebMods didn't actually wait for the login
to finish which caused the login to fail later on since the HTTP socket was
already destroyed.

This fixes it by letting the HTTP sock just hang. Once the login finishes,
CHTTPSock::Redirect() is called to let it come back to life again.

Thanks to DarthGandalf for finding this issue.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1834 726aef4b-f618-498e-8847-2d620e286838
2010-03-15 16:06:56 +00:00
psychon
1d7fdc2954 Change the return type of OnPageRequestInternal()
Instead of return a bool, this now returns an enum. This explains the meaning of
the returned value better and will be used in the next commit to fix a bug.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1833 726aef4b-f618-498e-8847-2d620e286838
2010-03-15 15:58:15 +00:00
psychon
e54b0bda0a Revert r1831
No, I'm not going to explain why. :P


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1832 726aef4b-f618-498e-8847-2d620e286838
2010-03-15 15:43:22 +00:00