On Thu, 02 Feb 2017 at 23:28:54 +0100, Mathieu Parent wrote:
> Can you try the attached patch with both lua-socket versions?
> - 3.0~rc1+git+321c0c9-2
> - 3.0~rc1+git+ac3201d-3

Your patch works with 3.0~rc1+git+321c0c9-2 but not with
3.0~rc1+git+ac3201d-3:

> Feb 04 14:37:45 perpetual systemd[1]: Starting LSB: Entropy Key Manager...
> Feb 04 14:37:45 perpetual ekeyd[19586]: Starting Simtec Entropy Key Daemon: 
> ekeydUnable to run control setup code:
> Feb 04 14:37:45 perpetual ekeyd[19586]: control.lua:49: attempt to index 
> global 'socket' (a nil value)
> Feb 04 14:37:45 perpetual ekeyd[19586]: .
> Feb 04 14:37:45 perpetual systemd[1]: Started LSB: Entropy Key Manager.

The ekeydctl utility (tested via "ekeydctl list") also failed to start
with a similar error. After turning `require "socket"` into
`local socket = require "socket"` as in Courtney's patch, ekeydctl
continued to fail with

> Internal error: /usr/sbin/ekeydctl:101: attempt to call field 'unix' (a nil 
> value)

which can be resolved by changing `require "socket.unix"` to
`socket.unix = require "socket.unix"`, again from Courtney's patch.

The result (attached) seems to work with both 3.0~rc1+git+321c0c9-2 and
3.0~rc1+git+ac3201d-3. Does that patch look valid to everyone?
(I will admit that I don't actually know Lua!)

Since I have the hardware to be able to test ekeyd, which most DDs won't,
I'm intending to do an NMU with that change if nobody tells me not to.

Regards,
    S
From: Simon McVittie <s...@debian.org>
Date: Sat, 4 Feb 2017 14:42:19 +0000
Subject: Fix compatibility with changed UNIX socket API

Based on patches from Mathieu Parent and Courtney Bane.
---
 host/control.lua | 15 +++++++++------
 host/ekeydctl.in |  4 ++--
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/host/control.lua b/host/control.lua
index 7b9b1b8..48723ec 100644
--- a/host/control.lua
+++ b/host/control.lua
@@ -38,16 +38,19 @@ local PROTOCOL_VERSION = "1"
 local dos_callcount = 0
 
 -- Libraries we need
-require "socket"
+local socket = require "socket"
 
 local have_unix_domain_sockets = false
-function tryload_unix()
-   require "socket.unix"
-   have_unix_domain_sockets = true
+local ok, unix = pcall(require, "socket.unix")
+if ok then
+   if type(unix) == "function" then
+      socket.unix = unix
+   else
+      socket.unix = unix.stream or unix.tcp
+   end
+   have_unix_domain_sockets = socket.unix ~= nil
 end
 
-pcall(tryload_unix)
-
 local protectedenv = {}
 
 -- Control socket interface
diff --git a/host/ekeydctl.in b/host/ekeydctl.in
index 9292ac6..801db7c 100755
--- a/host/ekeydctl.in
+++ b/host/ekeydctl.in
@@ -1,11 +1,11 @@
 #!/usr/bin/env lua@LUA_V@
 -- -*- Lua -*-
 
-require "socket"
+local socket = require "socket"
 
 -- Try to load the UNIX domain sockets support
 pcall(function()
-	 require "socket.unix"
+	 socket.unix = require "socket.unix"
       end)
 
 

Reply via email to