]> git.e2factory.org Git - e2factory.git/commitdiff
e2tool: access command line options more safely
authorTobias Ulmer <tu@emlix.com>
Wed, 24 Apr 2019 16:52:42 +0000 (18:52 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 24 Apr 2019 16:53:46 +0000 (18:53 +0200)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/cscache.lua
local/e2tool.lua

index 301ed05d6fee02e003411c5692a247d6db28fd58..e9865acd928a50a5a12c27f6c96bd559332905ad 100644 (file)
@@ -23,9 +23,9 @@ local cscache
 local class = require("class")
 local digest -- initialized later
 local e2lib = require("e2lib")
-local e2option = require("e2option")
 local e2tool = require("e2tool")
 local eio = require("eio")
+local policy = require("policy")
 
 
 --- Checksum cache class.
@@ -175,7 +175,7 @@ function cs_cache_class:load_cache()
 
     self._csdict = {}
 
-    if e2option.opts["build-mode"] == "release" then
+    if policy.opts.build_mode() == "release" then
         return
     end
 
index 56c0eeeb5c031449950fc4543992286497fc942d..58d6fb274b5de8f0725ea44c50621a41d505295a 100644 (file)
@@ -28,7 +28,6 @@ local class = require("class")
 local digest = require("digest")
 local e2build = require("e2build")
 local e2lib = require("e2lib")
-local e2option = require("e2option")
 local eio = require("eio")
 local environment = require("environment")
 local err = require("err")
@@ -370,7 +369,7 @@ function e2tool.file_class:fileid()
 
     assert(cs_done, "no checksum algorithm enabled for fileid()")
 
-    if e2option.opts["check-remote"] then
+    if policy.opts.check_remote() then
         rc, re = self:checksum_verify()
         if not rc then
             return false, e:cat(re)
@@ -431,14 +430,14 @@ function e2tool.file_class:checksum_verify()
         end
 
         -- Server-side checksum computation for ssh-like transports
-        if e2option.opts["check-remote"] then
+        if policy.opts.check_remote() then
             cs_remote, re = self:_compute_remote_checksum(digest_type)
             if re then
                 return false, e:cat(re)
             end
         end
 
-        if not cs_cache or (e2option.opts["check-remote"] and not cs_remote) then
+        if not cs_cache or (policy.opts.check_remote() and not cs_remote) then
             cs_fetch, re = self:_compute_checksum(digest_type, { cache = false })
             if not cs_fetch then
                 return false, e:cat(re)
@@ -940,14 +939,14 @@ function e2tool.e2project_class:load_project(skip_load_config)
         return false, e:cat(re)
     end
 
-    if e2option.opts["check"] then
+    if policy.opts.check() then
         rc, re = self:check_local()
         if not rc then
             return false, e:cat(re)
         end
     end
 
-    if e2option.opts["check-remote"] then
+    if policy.opts.check_remote() then
         rc, re = self:check_remote()
         if not rc then
             return false, e:cat(re)