]> git.e2factory.org Git - e2factory.git/commitdiff
e2build: for interactive playground use, setup standard file descriptors
authorTobias Ulmer <tu@emlix.com>
Mon, 18 Feb 2019 18:32:46 +0000 (19:32 +0100)
committerTobias Ulmer <tu@emlix.com>
Mon, 18 Feb 2019 18:32:46 +0000 (19:32 +0100)
Because we request a pty for signaling purposes, interactive use of the
shell isn't possible. To enable interactive use, duplicate the standard
descriptors of the parent and set them up in the child which will end
up being bash.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
local/e2build.lua

index 8797b9f1f781234c14cb7696491fbc9ad4b96a93..e561f91a221344517243eb3f9c9bb693d7f0e36e 100644 (file)
@@ -264,8 +264,21 @@ function e2build.build_process_class:_enter_playground(res, rbs)
     table.insert(cmd, "-c")
     table.insert(cmd, rbs:build_settings():command())
 
+    -- The shell is for interactive use, but we still want a pty for terminating
+    -- e2-su via signal.
+    -- This means we have to save the standard file descriptors and re-dup2 them
+    -- in place after forkpty.
+    local fdctv = {}
+    for _,fd in ipairs({eio.STDIN, eio.STDOUT, eio.STDERR}) do
+        local fdnew, re = eio.dup(fd)
+        if not fdnew then
+            return false, e:cat(re)
+        end
+        table.insert(fdctv, { dup = fd, istype = "readfo", file = fdnew })
+    end
+
     e2tool.set_umask()
-    rc, re = e2lib.callcmd(cmd, nil, nil, nil, nil, true)
+    rc, re = e2lib.callcmd(cmd, fdctv, nil, nil, nil, true)
     if not rc then
         e2tool.reset_umask()
         return false, e:cat(re)