Package: ekeyd
Version: 1.1.5-6.1
Severity: grave
Tags: patch
Justification: renders package unusable

After the recent upgrade of the lua-socket package to version
3.0~rc1+git+ac3201d-2, ekeyd no longer starts if Unix domain sockets are
used (for either the control or EGD socket). Instead, it exits with this
error message:

Unable to run configuration file:
control.lua:755: control.lua:526: attempt to index global 'socket' (a nil value)

This is due to an incompatible change in the lua-socket API for Unix domain 
sockets.

I have attached a patch which allows ekeyd to work with both the old and
new versions of lua-socket, as well as an upcoming change that has not
yet been packaged in Debian. (Git commit 3a33c37b;
https://github.com/diegonehab/luasocket/commit/3a33c37b9ce852d0b3531e82c6ffdb47bb937f0a.)

-- System Information:
Debian Release: 9.0
  APT prefers testing
  APT policy: (990, 'testing'), (700, 'unstable'), (500, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 4.8.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages ekeyd depends on:
ii  libc6        2.24-8
ii  liblua5.1-0  5.1.5-8.1+b2
ii  lua-socket   3.0~rc1+git+ac3201d-2
ii  lua5.1       5.1.5-8.1+b2

Versions of packages ekeyd recommends:
ii  udev  232-8

Versions of packages ekeyd suggests:
pn  munin-node  <none>

-- Configuration Files:
/etc/entropykey/ekeyd.conf changed [not included]
/etc/entropykey/keyring [Errno 13] Permission denied: '/etc/entropykey/keyring'

-- no debconf information
From: Courtney Bane <debian-bugs-4...@cbane.org>
Date: Mon, 23 Jan 2017 20:30:59 -0600
Subject: Fix compatibility problems with Unix domain sockets in newer
 versions of luasocket.

---
 host/control.lua | 14 ++++++++------
 host/ekeydctl.in |  7 ++++---
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/host/control.lua b/host/control.lua
index 7b9b1b8..22d700f 100644
--- a/host/control.lua
+++ b/host/control.lua
@@ -38,11 +38,11 @@ local PROTOCOL_VERSION = "1"
 local dos_callcount = 0
 
 -- Libraries we need
-require "socket"
+socket = require "socket"
 
 local have_unix_domain_sockets = false
 function tryload_unix()
-   require "socket.unix"
+   socket.unix = require "socket.unix"
    have_unix_domain_sockets = true
 end
 
@@ -521,14 +521,15 @@ end
 
 if have_unix_domain_sockets then
    function UnixControlSocket(sockname)
+      local sock = socket.unix.stream or socket.unix.tcp or socket.unix
       -- Add a UDS control socket to the set of control sockets available
       -- First, try and connect, so we can abort if it's present.
-      if socket.unix():connect(sockname) then
+      if sock():connect(sockname) then
 	 error("Control socket " .. sockname .. " already present. Is ekeyd already running?")
       end
       -- Okay, clean up (ignoring errors) and create a fresh socket
       unlink(sockname)
-      local u = socket.unix()
+      local u = sock()
       assert(u:bind(sockname))
       assert(u:listen())
       addctlsocket(u, "U:" .. sockname)
@@ -554,12 +555,13 @@ end _ "TCPControlSocket"
 if have_unix_domain_sockets then
    function EGDUnixSocket(sockname, modestr, user, group)
       SetFoldedOutput()
-      if socket.unix():connect(sockname) then
+      local sock = socket.unix.stream or socket.unix.tcp or socket.unix
+      if sock():connect(sockname) then
 	 error("EGD socket " .. sockname .. " already present. Is ekeyd/EGD already running?")
       end
       -- Add a UDS control socket to the set of control sockets available
       unlink(sockname)
-      local u = socket.unix()
+      local u = sock()
       assert(u:bind(sockname))
       assert(u:listen())
       addctlsocket(u, "U:" .. sockname, false, egd_ctlread)
diff --git a/host/ekeydctl.in b/host/ekeydctl.in
index 9292ac6..802cf38 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)
 
 
@@ -98,7 +98,8 @@ end
 
 function connect_to_daemon()
    if __unixcontrolpath then
-      __socket = socket.unix()
+      local sock = socket.unix.stream or socket.unix.tcp or socket.unix
+      __socket = sock()
       local result, msg = __socket:connect(__unixcontrolpath)
       if not result then
 	 error("Unable to connect to ekeyd at " .. __unixcontrolpath .. " (" .. msg .. ") Is ekeyd running?")

Reply via email to