diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2014-10-02 11:41:56 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2014-10-02 11:41:56 -0300 |
commit | 8278ed2e1e007d155fc75b1cf925932970b0693c (patch) | |
tree | 3230be8c303e2ba731bc9998b381c1aa4d812658 | |
parent | af1906327a0462f8d8464e81bcea18b4e29fefb5 (diff) | |
download | luarocks-8278ed2e1e007d155fc75b1cf925932970b0693c.tar.gz luarocks-8278ed2e1e007d155fc75b1cf925932970b0693c.tar.bz2 luarocks-8278ed2e1e007d155fc75b1cf925932970b0693c.zip |
Add flag to enable/disable SSL cert check.
We disabled SSL certificate checks for wget and curl a while ago,
when we first added https repositories. We'll keep the check disabled
by default for now, but this adds a config option,
`check_certificates=true` that can be used in your config.lua.
-rw-r--r-- | src/luarocks/cfg.lua | 8 | ||||
-rw-r--r-- | src/luarocks/fs/unix/tools.lua | 4 | ||||
-rw-r--r-- | src/luarocks/fs/win32/tools.lua | 4 |
3 files changed, 12 insertions, 4 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 0f433a7c..c305f702 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -204,6 +204,7 @@ local defaults = { | |||
204 | fs_use_modules = true, | 204 | fs_use_modules = true, |
205 | hooks_enabled = true, | 205 | hooks_enabled = true, |
206 | deps_mode = "one", | 206 | deps_mode = "one", |
207 | check_certificates = false, | ||
207 | 208 | ||
208 | lua_modules_path = "/share/lua/"..cfg.lua_version, | 209 | lua_modules_path = "/share/lua/"..cfg.lua_version, |
209 | lib_modules_path = "/lib/lua/"..cfg.lua_version, | 210 | lib_modules_path = "/lib/lua/"..cfg.lua_version, |
@@ -278,6 +279,8 @@ local defaults = { | |||
278 | 279 | ||
279 | RSYNCFLAGS = "--exclude=.git -Oavz", | 280 | RSYNCFLAGS = "--exclude=.git -Oavz", |
280 | STATFLAG = "-c '%a'", | 281 | STATFLAG = "-c '%a'", |
282 | CURLNOCERTFLAG = "", | ||
283 | WGETNOCERTFLAG = "", | ||
281 | }, | 284 | }, |
282 | 285 | ||
283 | external_deps_subdirs = site_config.LUAROCKS_EXTERNAL_DEPS_SUBDIRS or { | 286 | external_deps_subdirs = site_config.LUAROCKS_EXTERNAL_DEPS_SUBDIRS or { |
@@ -532,6 +535,11 @@ local cfg_mt = { | |||
532 | } | 535 | } |
533 | setmetatable(cfg, cfg_mt) | 536 | setmetatable(cfg, cfg_mt) |
534 | 537 | ||
538 | if not cfg.check_certificates then | ||
539 | cfg.variables.CURLNOCERTFLAG = "-k" | ||
540 | cfg.variables.WGETNOCERTFLAG = "--no-check-certificate" | ||
541 | end | ||
542 | |||
535 | function cfg.make_paths_from_tree(tree) | 543 | function cfg.make_paths_from_tree(tree) |
536 | local lua_path, lib_path, bin_path | 544 | local lua_path, lib_path, bin_path |
537 | if type(tree) == "string" then | 545 | if type(tree) == "string" then |
diff --git a/src/luarocks/fs/unix/tools.lua b/src/luarocks/fs/unix/tools.lua index f36e815a..8db1f0e5 100644 --- a/src/luarocks/fs/unix/tools.lua +++ b/src/luarocks/fs/unix/tools.lua | |||
@@ -246,7 +246,7 @@ function tools.use_downloader(url, filename, cache) | |||
246 | 246 | ||
247 | local ok | 247 | local ok |
248 | if cfg.downloader == "wget" then | 248 | if cfg.downloader == "wget" then |
249 | local wget_cmd = fs.Q(vars.WGET).." --no-check-certificate --no-cache --user-agent='"..cfg.user_agent.." via wget' --quiet " | 249 | local wget_cmd = fs.Q(vars.WGET).." "..vars.WGETNOCERTFLAG.." --no-cache --user-agent='"..cfg.user_agent.." via wget' --quiet " |
250 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | 250 | if cfg.connection_timeout and cfg.connection_timeout > 0 then |
251 | wget_cmd = wget_cmd .. "--timeout="..tonumber(cfg.connection_timeout).." --tries=1 " | 251 | wget_cmd = wget_cmd .. "--timeout="..tonumber(cfg.connection_timeout).." --tries=1 " |
252 | end | 252 | end |
@@ -262,7 +262,7 @@ function tools.use_downloader(url, filename, cache) | |||
262 | ok = fs.execute_quiet(wget_cmd, url) | 262 | ok = fs.execute_quiet(wget_cmd, url) |
263 | end | 263 | end |
264 | elseif cfg.downloader == "curl" then | 264 | elseif cfg.downloader == "curl" then |
265 | local curl_cmd = fs.Q(vars.CURL).." -f -k -L --user-agent '"..cfg.user_agent.." via curl' " | 265 | local curl_cmd = fs.Q(vars.CURL).." "..vars.CURLNOCERTFLAG.." -f -L --user-agent '"..cfg.user_agent.." via curl' " |
266 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | 266 | if cfg.connection_timeout and cfg.connection_timeout > 0 then |
267 | curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " | 267 | curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " |
268 | end | 268 | end |
diff --git a/src/luarocks/fs/win32/tools.lua b/src/luarocks/fs/win32/tools.lua index f970f36a..e906b4a1 100644 --- a/src/luarocks/fs/win32/tools.lua +++ b/src/luarocks/fs/win32/tools.lua | |||
@@ -256,7 +256,7 @@ function tools.use_downloader(url, filename, cache) | |||
256 | 256 | ||
257 | local ok | 257 | local ok |
258 | if cfg.downloader == "wget" then | 258 | if cfg.downloader == "wget" then |
259 | local wget_cmd = fs.Q(vars.WGET).." --no-check-certificate --no-cache --user-agent=\""..cfg.user_agent.." via wget\" --quiet " | 259 | local wget_cmd = fs.Q(vars.WGET).." "..vars.WGETNOCERTFLAG.." --no-cache --user-agent=\""..cfg.user_agent.." via wget\" --quiet " |
260 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | 260 | if cfg.connection_timeout and cfg.connection_timeout > 0 then |
261 | wget_cmd = wget_cmd .. "--timeout="..tonumber(cfg.connection_timeout).." --tries=1 " | 261 | wget_cmd = wget_cmd .. "--timeout="..tonumber(cfg.connection_timeout).." --tries=1 " |
262 | end | 262 | end |
@@ -272,7 +272,7 @@ function tools.use_downloader(url, filename, cache) | |||
272 | ok = fs.execute_quiet(wget_cmd, url) | 272 | ok = fs.execute_quiet(wget_cmd, url) |
273 | end | 273 | end |
274 | elseif cfg.downloader == "curl" then | 274 | elseif cfg.downloader == "curl" then |
275 | local curl_cmd = vars.CURL.." -f -k -L --user-agent \""..cfg.user_agent.." via curl\" " | 275 | local curl_cmd = vars.CURL).." "..vars.CURLNOCERTFLAG.." -f -L --user-agent \""..cfg.user_agent.." via curl\" " |
276 | if cfg.connection_timeout and cfg.connection_timeout > 0 then | 276 | if cfg.connection_timeout and cfg.connection_timeout > 0 then |
277 | curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " | 277 | curl_cmd = curl_cmd .. "--connect-timeout "..tonumber(cfg.connection_timeout).." " |
278 | end | 278 | end |