Software /
code /
prosody
Annotate
util/dependencies.lua @ 7769:2a7b52437167 0.9.12
util.dependencies: Set ssl.x509 so core.certmanager knows that LuaSec is capable of certificate validation (fixes #781)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 28 Nov 2016 14:27:59 +0100 |
parent | 7675:decb657bc0a0 |
child | 7779:b1f80447a2b1 |
child | 8223:adfffc5b4e2a |
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 |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
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 |
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
|
9 module("dependencies", package.seeall) |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
449
diff
changeset
|
10 |
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
|
11 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
|
12 |
2513
a8aa7616b154
util.dependencies: Load luarocks.loader/luarocks.require
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
13 -- 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
|
14 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
|
15 softreq "luarocks.require"; -- LuaRocks <1.x |
a8aa7616b154
util.dependencies: Load luarocks.loader/luarocks.require
Matthew Wild <mwild1@gmail.com>
parents:
2510
diff
changeset
|
16 end |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 |
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
|
18 function missingdep(name, sources, msg) |
409
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
19 print(""); |
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
20 print("**************************"); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 print("Prosody was unable to find "..tostring(name)); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 print("This package can be obtained in the following ways:"); |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 print("", platform..":"..(" "):rep(4+longest_platform-#platform)..source); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 end |
410
5ce6801ad2e4
Trivial whitespace fix in the missing dependency message
Matthew Wild <mwild1@gmail.com>
parents:
409
diff
changeset
|
31 print(""); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 print(msg or (name.." is required for Prosody to run, so we will now exit.")); |
526 | 33 print("More help can be found on our website, at http://prosody.im/doc/depends"); |
409
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
34 print("**************************"); |
2269e9cbe153
Add MD5 to the list of checked dependencies
Matthew Wild <mwild1@gmail.com>
parents:
408
diff
changeset
|
35 print(""); |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 |
4236
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
38 -- COMPAT w/pre-0.8 Debian: The Debian config file used to use |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
39 -- util.ztact, which has been removed from Prosody in 0.8. This |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
40 -- is to log an error for people who still use it, so they can |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
41 -- update their configs. |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
42 package.preload["util.ztact"] = function () |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
43 if not package.loaded["core.loggingmanager"] then |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
44 error("util.ztact has been removed from Prosody and you need to fix your config " |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
45 .."file. More information can be found at http://prosody.im/doc/packagers#ztact", 0); |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
46 else |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
47 error("module 'util.ztact' has been deprecated in Prosody 0.8."); |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
48 end |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
49 end; |
75ef9ea83b07
util.dependencies: Add a dummy util.ztact loader to log a message for people still using it (e.g. in their Debian-derived config files)
Matthew Wild <mwild1@gmail.com>
parents:
3904
diff
changeset
|
50 |
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
|
51 function check_dependencies() |
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
|
52 if _VERSION ~= "Lua 5.1" then |
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
|
53 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
|
54 print("Unsupported Lua version: ".._VERSION); |
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
|
55 print("Only Lua 5.1 is supported."); |
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
|
56 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
|
57 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
|
58 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
|
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 local fatal; |
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 |
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
|
62 local lxp = softreq "lxp" |
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 |
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 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
|
65 missingdep("luaexpat", { |
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 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-expat0"; |
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
|
67 ["luarocks"] = "luarocks install luaexpat"; |
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
|
68 ["Source"] = "http://www.keplerproject.org/luaexpat/"; |
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
|
69 }); |
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
|
70 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
|
71 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
|
72 |
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 socket = softreq "socket" |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 |
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
|
75 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
|
76 missingdep("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
|
77 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-socket2"; |
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
|
78 ["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
|
79 ["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
|
80 }); |
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 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
|
82 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
|
83 |
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
|
84 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
|
85 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
|
86 missingdep("luafilesystem", { |
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
|
87 ["luarocks"] = "luarocks install luafilesystem"; |
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
|
88 ["Debian/Ubuntu"] = "sudo apt-get install liblua5.1-filesystem0"; |
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
|
89 ["Source"] = "http://www.keplerproject.org/luafilesystem/"; |
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
|
90 }); |
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
|
91 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
|
92 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
|
93 |
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
|
94 local ssl = softreq "ssl" |
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
|
95 |
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
|
96 if not ssl then |
2157
7cb0aa497326
util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents:
2156
diff
changeset
|
97 missingdep("LuaSec", { |
7cb0aa497326
util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents:
2156
diff
changeset
|
98 ["Debian/Ubuntu"] = "http://prosody.im/download/start#debian_and_ubuntu"; |
7cb0aa497326
util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents:
2156
diff
changeset
|
99 ["luarocks"] = "luarocks install luasec"; |
7cb0aa497326
util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents:
2156
diff
changeset
|
100 ["Source"] = "http://www.inf.puc-rio.br/~brunoos/luasec/"; |
7cb0aa497326
util.dependencies: Clearer message, add homepages, etc.
Matthew Wild <mwild1@gmail.com>
parents:
2156
diff
changeset
|
101 }, "SSL/TLS support will not be available"); |
7675
decb657bc0a0
util.dependencies: Set global 'ssl' for compat with LuaSec 0.6 (fixes #749)
Kim Alvefur <zash@zash.se>
parents:
6065
diff
changeset
|
102 elseif not _G.ssl then |
decb657bc0a0
util.dependencies: Set global 'ssl' for compat with LuaSec 0.6 (fixes #749)
Kim Alvefur <zash@zash.se>
parents:
6065
diff
changeset
|
103 _G.ssl = ssl; |
decb657bc0a0
util.dependencies: Set global 'ssl' for compat with LuaSec 0.6 (fixes #749)
Kim Alvefur <zash@zash.se>
parents:
6065
diff
changeset
|
104 _G.ssl.context = require "ssl.context"; |
7769
2a7b52437167
util.dependencies: Set ssl.x509 so core.certmanager knows that LuaSec is capable of certificate validation (fixes #781)
Kim Alvefur <zash@zash.se>
parents:
7675
diff
changeset
|
105 _G.ssl.x509 = softreq "ssl.x509"; |
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
|
106 end |
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
|
107 |
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
|
108 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
|
109 if not encodings 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
|
110 if err:match("not found") 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
|
111 missingdep("util.encodings", { ["Windows"] = "Make sure you have encodings.dll from the Prosody distribution in util/"; |
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 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/encodings.so"; |
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 }); |
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 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 end |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 |
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
|
125 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
|
126 if not hashes 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
|
127 if err:match("not found") 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
|
128 missingdep("util.hashes", { ["Windows"] = "Make sure you have hashes.dll from the Prosody distribution in util/"; |
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 ["GNU/Linux"] = "Run './configure' and 'make' in the Prosody source directory to build util/hashes.so"; |
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 }); |
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 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
|
132 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
|
133 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
|
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 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
|
136 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
|
137 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
|
138 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
|
139 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
|
140 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
|
141 return not fatal; |
408
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 end |
eb1a0960cefb
Friendlier messages on missing dependencies
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 |
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
|
144 function log_warnings() |
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
|
145 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
|
146 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
|
147 if not major or ((tonumber(major) == 0 and (tonumber(minor) or 0) <= 3 and (tonumber(veryminor) or 0) <= 2) and patched ~= "M") 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 log("error", "This version of LuaSec contains a known bug that causes disconnects, see http://prosody.im/doc/depends"); |
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 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
|
150 end |
4426
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
151 if lxp then |
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
152 if not pcall(lxp.new, { StartDoctypeDecl = false }) then |
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
153 log("error", "The version of LuaExpat on your system leaves Prosody " |
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
154 .."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
|
155 .."LuaExpat 1.3.0 or higher as soon as possible. See " |
29d2dd705148
util.dependencies: Log error when LuaExpat is not capable of enforcing stanza size limits
Matthew Wild <mwild1@gmail.com>
parents:
4426
diff
changeset
|
156 .."http://prosody.im/doc/depends#luaexpat for more information."); |
29d2dd705148
util.dependencies: Log error when LuaExpat is not capable of enforcing stanza size limits
Matthew Wild <mwild1@gmail.com>
parents:
4426
diff
changeset
|
157 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
|
158 if not lxp.new({}).getcurrentbytecount then |
29d2dd705148
util.dependencies: Log error when LuaExpat is not capable of enforcing stanza size limits
Matthew Wild <mwild1@gmail.com>
parents:
4426
diff
changeset
|
159 log("error", "The version of LuaExpat on your system does not support " |
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 .."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
|
161 .."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
|
162 .."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
|
163 .."soon as possible. See " |
4426
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
164 .."http://prosody.im/doc/depends#luaexpat for more information."); |
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
165 end |
ee65aa40ef60
util.dependencies, util.xmppstream: Move LuaExpat version checking to util.dependencies.
Waqas Hussain <waqas20@gmail.com>
parents:
4236
diff
changeset
|
166 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
|
167 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
|
168 |
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
|
169 return _M; |