Software /
code /
prosody
Annotate
util/dependencies.lua @ 12181:783056b4e448 0.11 0.11.12
util.xml: Do not allow doctypes, comments or processing instructions
Yes. This is as bad as it sounds. CVE pending.
In Prosody itself, this only affects mod_websocket, which uses util.xml
to parse the <open/> frame, thus allowing unauthenticated remote DoS
using Billion Laughs. However, third-party modules using util.xml may
also be affected by this.
This commit installs handlers which disallow the use of doctype
declarations and processing instructions without any escape hatch. It,
by default, also introduces such a handler for comments, however, there
is a way to enable comments nontheless.
This is because util.xml is used to parse human-facing data, where
comments are generally a desirable feature, and also because comments
are generally harmless.
author | Jonas Schäfer <jonas@wielicki.name> |
---|---|
date | Mon, 10 Jan 2022 18:23:54 +0100 |
parent | 11140:e17b98feb0b7 |
child | 11141:a5acd6354845 |
rev | line source |
---|---|
1523
841d61be198f
Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
1 -- Prosody IM |
2923
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
2815
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
2815
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4426
diff
changeset
|
4 -- |
758 | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
7 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
8 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
9 local function softreq(...) local ok, lib = pcall(require, ...); if ok then return lib; else return nil, lib; end end |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 |
2513
a8aa7616b154
util.dependencies: Load luarocks.loader/luarocks.require
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
11 -- Required to be able to find packages installed with luarocks |
a8aa7616b154
util.dependencies: Load luarocks.loader/luarocks.require
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
12 if not softreq "luarocks.loader" then -- LuaRocks 2.x |
a8aa7616b154
util.dependencies: Load luarocks.loader/luarocks.require
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
13 softreq "luarocks.require"; -- LuaRocks <1.x |
a8aa7616b154
util.dependencies: Load luarocks.loader/luarocks.require
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
14 end |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
16 local function missingdep(name, sources, msg) |
409
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
17 print(""); |
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
18 print("**************************"); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 print("Prosody was unable to find "..tostring(name)); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 print("This package can be obtained in the following ways:"); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 print(""); |
2815
84123bcfa0ba
util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents:
2298
diff
changeset
|
22 local longest_platform = 0; |
84123bcfa0ba
util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents:
2298
diff
changeset
|
23 for platform in pairs(sources) do |
84123bcfa0ba
util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents:
2298
diff
changeset
|
24 longest_platform = math.max(longest_platform, #platform); |
84123bcfa0ba
util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents:
2298
diff
changeset
|
25 end |
84123bcfa0ba
util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents:
2298
diff
changeset
|
26 for platform, source in pairs(sources) do |
84123bcfa0ba
util.dependencies: Make the commands line up properly in the "missing dependency" output. Yes, this was the commit you didn't know you were waiting for!
Matthew Wild <mwild1@gmail.com>
parents:
2298
diff
changeset
|
27 print("", platform..":"..(" "):rep(4+longest_platform-#platform)..source); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 end |
410
5ce6801ad2e4
Trivial whitespace fix in the missing dependency message
Matthew Wild <mwild1@gmail.com>
parents:
409
diff
changeset
|
29 print(""); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 print(msg or (name.." is required for Prosody to run, so we will now exit.")); |
7359
a5a080c12c96
Update every link to the documentation to use HTTPS
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
7264
diff
changeset
|
31 print("More help can be found on our website, at https://prosody.im/doc/depends"); |
409
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
32 print("**************************"); |
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
33 print(""); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
36 local function check_dependencies() |
6778
4009ae66e0f0
util.dependencies: Only abort on Lua versions before 5.1, log a warning about 5.2 and above for now
Kim Alvefur <zash@zash.se>
parents:
6777
diff
changeset
|
37 if _VERSION < "Lua 5.1" then |
6065
9ab23488a17c
util.dependencies: Check for Lua 5.1. We don't currently support any other versions. LuaJIT identifies as 5.1.
Waqas Hussain <waqas20@gmail.com>
parents:
6043
diff
changeset
|
38 print "***********************************" |
9ab23488a17c
util.dependencies: Check for Lua 5.1. We don't currently support any other versions. LuaJIT identifies as 5.1.
Waqas Hussain <waqas20@gmail.com>
parents:
6043
diff
changeset
|
39 print("Unsupported Lua version: ".._VERSION); |
6778
4009ae66e0f0
util.dependencies: Only abort on Lua versions before 5.1, log a warning about 5.2 and above for now
Kim Alvefur <zash@zash.se>
parents:
6777
diff
changeset
|
40 print("At least Lua 5.1 is required."); |
6065
9ab23488a17c
util.dependencies: Check for Lua 5.1. We don't currently support any other versions. LuaJIT identifies as 5.1.
Waqas Hussain <waqas20@gmail.com>
parents:
6043
diff
changeset
|
41 print "***********************************" |
9ab23488a17c
util.dependencies: Check for Lua 5.1. We don't currently support any other versions. LuaJIT identifies as 5.1.
Waqas Hussain <waqas20@gmail.com>
parents:
6043
diff
changeset
|
42 return false; |
9ab23488a17c
util.dependencies: Check for Lua 5.1. We don't currently support any other versions. LuaJIT identifies as 5.1.
Waqas Hussain <waqas20@gmail.com>
parents:
6043
diff
changeset
|
43 end |
9ab23488a17c
util.dependencies: Check for Lua 5.1. We don't currently support any other versions. LuaJIT identifies as 5.1.
Waqas Hussain <waqas20@gmail.com>
parents:
6043
diff
changeset
|
44 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
45 local fatal; |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4426
diff
changeset
|
46 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
47 local lxp = softreq "lxp" |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4426
diff
changeset
|
48 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
49 if not lxp then |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
50 missingdep("luaexpat", { |
7813
56b0ae8cbb02
util.dependencies: Update Debian package names for liblua5.1-lib0 -> lua-lib transition
Kim Alvefur <zash@zash.se>
parents:
7779
diff
changeset
|
51 ["Debian/Ubuntu"] = "sudo apt-get install lua-expat"; |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
52 ["luarocks"] = "luarocks install luaexpat"; |
7766
5594d0caa5a8
util.dependencies: Update links for LuaExpat and LuaSec which have moved to new locations
Kim Alvefur <zash@zash.se>
parents:
7721
diff
changeset
|
53 ["Source"] = "http://matthewwild.co.uk/projects/luaexpat/"; |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
54 }); |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
55 fatal = true; |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
56 end |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4426
diff
changeset
|
57 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
58 local socket = softreq "socket" |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4426
diff
changeset
|
59 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
60 if not socket then |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
61 missingdep("luasocket", { |
7813
56b0ae8cbb02
util.dependencies: Update Debian package names for liblua5.1-lib0 -> lua-lib transition
Kim Alvefur <zash@zash.se>
parents:
7779
diff
changeset
|
62 ["Debian/Ubuntu"] = "sudo apt-get install lua-socket"; |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
63 ["luarocks"] = "luarocks install luasocket"; |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
64 ["Source"] = "http://www.tecgraf.puc-rio.br/~diego/professional/luasocket/"; |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
65 }); |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
66 fatal = true; |
9494
b19f676203fd
util.dependencies: Add compat code for normalization of socket constructors
Kim Alvefur <zash@zash.se>
parents:
8235
diff
changeset
|
67 elseif not socket.tcp4 then |
b19f676203fd
util.dependencies: Add compat code for normalization of socket constructors
Kim Alvefur <zash@zash.se>
parents:
8235
diff
changeset
|
68 -- COMPAT LuaSocket before being IP-version agnostic |
b19f676203fd
util.dependencies: Add compat code for normalization of socket constructors
Kim Alvefur <zash@zash.se>
parents:
8235
diff
changeset
|
69 socket.tcp4 = socket.tcp; |
b19f676203fd
util.dependencies: Add compat code for normalization of socket constructors
Kim Alvefur <zash@zash.se>
parents:
8235
diff
changeset
|
70 socket.udp4 = socket.udp; |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
71 end |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4426
diff
changeset
|
72 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
73 local lfs, err = softreq "lfs" |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
74 if not lfs then |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
75 missingdep("luafilesystem", { |
7875
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
76 ["luarocks"] = "luarocks install luafilesystem"; |
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
77 ["Debian/Ubuntu"] = "sudo apt-get install lua-filesystem"; |
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
78 ["Source"] = "http://www.keplerproject.org/luafilesystem/"; |
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
79 }); |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
80 fatal = true; |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
81 end |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4426
diff
changeset
|
82 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
83 local ssl = softreq "ssl" |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4426
diff
changeset
|
84 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
85 if not ssl then |
2157
7cb0aa497326
util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents:
2156
diff
changeset
|
86 missingdep("LuaSec", { |
7993
c654c92aad55
util.dependencies: Give APT command for installing lua-sec
Kim Alvefur <zash@zash.se>
parents:
7875
diff
changeset
|
87 ["Debian/Ubuntu"] = "sudo apt-get install lua-sec"; |
2157
7cb0aa497326
util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents:
2156
diff
changeset
|
88 ["luarocks"] = "luarocks install luasec"; |
7766
5594d0caa5a8
util.dependencies: Update links for LuaExpat and LuaSec which have moved to new locations
Kim Alvefur <zash@zash.se>
parents:
7721
diff
changeset
|
89 ["Source"] = "https://github.com/brunoos/luasec"; |
2157
7cb0aa497326
util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents:
2156
diff
changeset
|
90 }, "SSL/TLS support will not be available"); |
413
4b61529d0884
Refuse to run without SSL/TLS unless run_without_ssl is set in config
Matthew Wild <mwild1@gmail.com>
parents:
410
diff
changeset
|
91 end |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4426
diff
changeset
|
92 |
11140
e17b98feb0b7
util.dependencies: Check for bitop library same way as net.websocket.frames (fixes #1594)
Kim Alvefur <zash@zash.se>
parents:
9560
diff
changeset
|
93 local bit = softreq"bit" or softreq"bit32"; |
7767
36bf9ed87ae1
util.dependencies: Add check and info about lua-bitops (for mod_websockets)
Kim Alvefur <zash@zash.se>
parents:
7766
diff
changeset
|
94 |
36bf9ed87ae1
util.dependencies: Add check and info about lua-bitops (for mod_websockets)
Kim Alvefur <zash@zash.se>
parents:
7766
diff
changeset
|
95 if not bit then |
36bf9ed87ae1
util.dependencies: Add check and info about lua-bitops (for mod_websockets)
Kim Alvefur <zash@zash.se>
parents:
7766
diff
changeset
|
96 missingdep("lua-bitops", { |
36bf9ed87ae1
util.dependencies: Add check and info about lua-bitops (for mod_websockets)
Kim Alvefur <zash@zash.se>
parents:
7766
diff
changeset
|
97 ["Debian/Ubuntu"] = "sudo apt-get install lua-bitop"; |
36bf9ed87ae1
util.dependencies: Add check and info about lua-bitops (for mod_websockets)
Kim Alvefur <zash@zash.se>
parents:
7766
diff
changeset
|
98 ["luarocks"] = "luarocks install luabitop"; |
36bf9ed87ae1
util.dependencies: Add check and info about lua-bitops (for mod_websockets)
Kim Alvefur <zash@zash.se>
parents:
7766
diff
changeset
|
99 ["Source"] = "http://bitop.luajit.org/"; |
36bf9ed87ae1
util.dependencies: Add check and info about lua-bitops (for mod_websockets)
Kim Alvefur <zash@zash.se>
parents:
7766
diff
changeset
|
100 }, "WebSocket support will not be available"); |
36bf9ed87ae1
util.dependencies: Add check and info about lua-bitops (for mod_websockets)
Kim Alvefur <zash@zash.se>
parents:
7766
diff
changeset
|
101 end |
36bf9ed87ae1
util.dependencies: Add check and info about lua-bitops (for mod_websockets)
Kim Alvefur <zash@zash.se>
parents:
7766
diff
changeset
|
102 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
103 local encodings, err = softreq "util.encodings" |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
104 if not encodings then |
7264
6d97895c2bd7
util.dependencies: Show the full error when a symbol is not found (i.e., when running Prosody with the wrong version of Lua).
Thijs Alkemade <me@thijsalkema.de>
parents:
7007
diff
changeset
|
105 if err:match("module '[^']*' not found") then |
7875
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
106 missingdep("util.encodings", { |
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
107 ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/"; |
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
108 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so"; |
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
109 }); |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
110 else |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
111 print "***********************************" |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
112 print("util/encodings couldn't be loaded. Check that you have a recent version of libidn"); |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
113 print "" |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
114 print("The full error was:"); |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
115 print(err) |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
116 print "***********************************" |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
117 end |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
118 fatal = true; |
2169
c06fdb6b57bd
util.dependencies: Log an error if the current version of LuaSec installed contains The Bug (thanks Remko)
Matthew Wild <mwild1@gmail.com>
parents:
2158
diff
changeset
|
119 end |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
121 local hashes, err = softreq "util.hashes" |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
122 if not hashes then |
7264
6d97895c2bd7
util.dependencies: Show the full error when a symbol is not found (i.e., when running Prosody with the wrong version of Lua).
Thijs Alkemade <me@thijsalkema.de>
parents:
7007
diff
changeset
|
123 if err:match("module '[^']*' not found") then |
7875
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
124 missingdep("util.hashes", { |
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
125 ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/"; |
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
126 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so"; |
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
127 }); |
3fbfd7210d78
util.dependencies: Normalize whitespace
Kim Alvefur <zash@zash.se>
parents:
7813
diff
changeset
|
128 else |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
129 print "***********************************" |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
130 print("util/hashes couldn't be loaded. Check that you have a recent version of OpenSSL (libcrypto in particular)"); |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
131 print "" |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
132 print("The full error was:"); |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
133 print(err) |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
134 print "***********************************" |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
135 end |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
136 fatal = true; |
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
137 end |
7767
36bf9ed87ae1
util.dependencies: Add check and info about lua-bitops (for mod_websockets)
Kim Alvefur <zash@zash.se>
parents:
7766
diff
changeset
|
138 |
2510
97b5ea975cb9
util.dependencies, prosody, prosodyctl: Give util.dependencies a check_dependencies() function so the caller can decide what to do when dependencies aren't met - update prosody/prosodyctl for this change
Matthew Wild <mwild1@gmail.com>
parents:
2299
diff
changeset
|
139 return not fatal; |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
142 local function log_warnings() |
7721
92f771147de8
util.dependencies: Disable warning about Lua 5.2 (but still warn about 5.3)
Kim Alvefur <zash@zash.se>
parents:
7679
diff
changeset
|
143 if _VERSION > "Lua 5.2" then |
7007
e28fbe6dd424
util.dependencies: Use prosody.log() instead of global log()
Matthew Wild <mwild1@gmail.com>
parents:
6778
diff
changeset
|
144 prosody.log("warn", "Support for %s is experimental, please report any issues", _VERSION); |
6778
4009ae66e0f0
util.dependencies: Only abort on Lua versions before 5.1, log a warning about 5.2 and above for now
Kim Alvefur <zash@zash.se>
parents:
6777
diff
changeset
|
145 end |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
146 local ssl = softreq"ssl"; |
3904
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
2925
diff
changeset
|
147 if ssl then |
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
2925
diff
changeset
|
148 local major, minor, veryminor, patched = ssl._VERSION:match("(%d+)%.(%d+)%.?(%d*)(M?)"); |
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
2925
diff
changeset
|
149 if not major or ((tonumber(major) == 0 and (tonumber(minor) or 0) <= 3 and (tonumber(veryminor) or 0) <= 2) and patched ~= "M") then |
7359
a5a080c12c96
Update every link to the documentation to use HTTPS
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
7264
diff
changeset
|
150 prosody.log("error", "This version of LuaSec contains a known bug that causes disconnects, see https://prosody.im/doc/depends"); |
3904
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
2925
diff
changeset
|
151 end |
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
2925
diff
changeset
|
152 end |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
153 local lxp = softreq"lxp"; |
4426
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
154 if lxp then |
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
155 if not pcall(lxp.new, { StartDoctypeDecl = false }) then |
7007
e28fbe6dd424
util.dependencies: Use prosody.log() instead of global log()
Matthew Wild <mwild1@gmail.com>
parents:
6778
diff
changeset
|
156 prosody.log("error", "The version of LuaExpat on your system leaves Prosody " |
4426
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
157 .."vulnerable to denial-of-service attacks. You should upgrade to " |
6043
29d2dd705148
util.dependencies: Log error when LuaExpat is not capable of enforcing stanza size limits
Matthew Wild <mwild1@gmail.com>
parents:
4426
diff
changeset
|
158 .."LuaExpat 1.3.0 or higher as soon as possible. See " |
7359
a5a080c12c96
Update every link to the documentation to use HTTPS
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
7264
diff
changeset
|
159 .."https://prosody.im/doc/depends#luaexpat for more information."); |
6043
29d2dd705148
util.dependencies: Log error when LuaExpat is not capable of enforcing stanza size limits
Matthew Wild <mwild1@gmail.com>
parents:
4426
diff
changeset
|
160 end |
29d2dd705148
util.dependencies: Log error when LuaExpat is not capable of enforcing stanza size limits
Matthew Wild <mwild1@gmail.com>
parents:
4426
diff
changeset
|
161 if not lxp.new({}).getcurrentbytecount then |
7007
e28fbe6dd424
util.dependencies: Use prosody.log() instead of global log()
Matthew Wild <mwild1@gmail.com>
parents:
6778
diff
changeset
|
162 prosody.log("error", "The version of LuaExpat on your system does not support " |
6043
29d2dd705148
util.dependencies: Log error when LuaExpat is not capable of enforcing stanza size limits
Matthew Wild <mwild1@gmail.com>
parents:
4426
diff
changeset
|
163 .."stanza size limits, which may leave servers on untrusted " |
29d2dd705148
util.dependencies: Log error when LuaExpat is not capable of enforcing stanza size limits
Matthew Wild <mwild1@gmail.com>
parents:
4426
diff
changeset
|
164 .."networks (e.g. the internet) vulnerable to denial-of-service " |
29d2dd705148
util.dependencies: Log error when LuaExpat is not capable of enforcing stanza size limits
Matthew Wild <mwild1@gmail.com>
parents:
4426
diff
changeset
|
165 .."attacks. You should upgrade to LuaExpat 1.3.0 or higher as " |
29d2dd705148
util.dependencies: Log error when LuaExpat is not capable of enforcing stanza size limits
Matthew Wild <mwild1@gmail.com>
parents:
4426
diff
changeset
|
166 .."soon as possible. See " |
7359
a5a080c12c96
Update every link to the documentation to use HTTPS
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
7264
diff
changeset
|
167 .."https://prosody.im/doc/depends#luaexpat for more information."); |
4426
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
168 end |
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
169 end |
3904
f93163081b3c
prosody, prosodyctl, util.dependencies: Split checking and logging of dependencies so we can check hard deps before the config and logging is loaded
Matthew Wild <mwild1@gmail.com>
parents:
2925
diff
changeset
|
170 end |
742
b9f59372eb4e
util.dependencies: Show useful messages when our own libraries are not found, too
Matthew Wild <mwild1@gmail.com>
parents:
615
diff
changeset
|
171 |
6777
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
172 return { |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
173 softreq = softreq; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
174 missingdep = missingdep; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
175 check_dependencies = check_dependencies; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
176 log_warnings = log_warnings; |
5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents:
6067
diff
changeset
|
177 }; |