]> git.e2factory.org Git - e2factory.git/commitdiff
Add optional sudo support to e2factory
authorTobias Ulmer <tu@emlix.com>
Mon, 25 Jun 2018 18:08:25 +0000 (20:08 +0200)
committerTobias Ulmer <tu@emlix.com>
Mon, 10 Dec 2018 17:00:11 +0000 (18:00 +0100)
Once sudo is enable, e2-su-2.2 suid permissions can be removed and set
to 755.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
INSTALL
doc/man/e2.conf.5.in
generic/e2lib.lua
generic/tools.lua

diff --git a/INSTALL b/INSTALL
index ca985c54d48c5d00a541d027311a52379c182e1f..ca2d1b7c24aaf933e2f032293e828f97ea34ad18 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -13,8 +13,13 @@ First make sure that the following packages are installed in your system
 
 More packages are required but usually installed by default.
 
-e2factory uses a unix group named ebs by default. All users of e2factory
-must belong to that group. Create the group.
+e2factory requires root permissions to build in a chroot environment.
+It uses the suid helper e2-su-2.2 belonging to the unix group "ebs".
+
+Alernatively users can configure the use of sudo without password and
+set e2-su-2.2 permissions to 755. Check the manual for further details.
+
+All users of e2factory must belong to the ebs group. Create the group.
 
   groupadd ebs
 
index 1e63125e694466881f4ce5c1f6878be40bd60ad1..70d4d1d5476cc3c689dbedf32e3f462196807e3b 100644 (file)
@@ -73,7 +73,7 @@ config {
     }
   },
   tools = {
-    ["<tool-name>"] = { name="<string>", flags="<string>" },
+    ["<tool-name>"] = { name="<string>", flags="<string>", enable=<bool> },
     ...
   },
   cache = {
@@ -187,6 +187,12 @@ Type: String
 .br
 Flags/arguments to be passed to the tool.
 
+.TP
+.BR enable
+Type: Boolean
+.br
+Enables or disables the use of an optional tool.
+
 .TP
 .BR cache
 Type: Table
index 0606af393a89d0824ba91615aa5971a56e3e5fb7..836cfabc3ad6672030d6cc02aea51e2fa05bca45 100644 (file)
@@ -2466,8 +2466,32 @@ end
 -- @return bool
 function e2lib.e2_su_2_2(argv)
     assert(type(argv) == "table")
+    local rc, re
+
+    rc, re = e2lib.get_global_config()
+    if not rc then
+        return false, re
+    end
+
+    rc, re = tools.enabled("sudo")
+    if rc then
+        local cmd
 
-    return e2lib.call_tool_argv("e2-su-2.2", argv)
+        cmd, re = tools.get_tool_flags_argv("e2-su-2.2")
+        if not cmd then
+            return false, re
+        end
+
+        for _,arg in ipairs(argv) do
+            table.insert(cmd, arg)
+        end
+
+        table.insert(cmd, 1, "--")
+
+        return e2lib.call_tool_argv("sudo", cmd)
+    else
+        return e2lib.call_tool_argv("e2-su-2.2", argv)
+    end
 end
 
 --- call the tar command
index 099ed8d426bec17d110050b90988953b64d27b65..f53a66b2a4c6a711dca4119c1898de2304873204 100644 (file)
@@ -312,6 +312,7 @@ function tools.add_default_tools()
         unzip = { name = "unzip", flags = "", optional = false },
         ["e2-su-2.2"] = { name = buildconfig.BINDIR .. "/e2-su-2.2",
         flags = "", optional = false },
+        sudo = { name = "sudo", optional = true, enable = false },
     }
 
     for name, t in pairs(defaults) do