From ab186b9a38b5b2b1a4af4e8aaec8a07b1f790dd1 Mon Sep 17 00:00:00 2001
From: Roman Tsisyk <roman@tsisyk.com>
Date: Fri, 5 Feb 2016 12:35:05 +0300
Subject: [PATCH] Fix #1293: Permission denied on tarantoolctl enter

---
 extra/dist/tarantoolctl.in     |  9 ++++++++-
 test/app/tarantoolctl.result   |  3 +++
 test/app/tarantoolctl.test.lua | 17 +++++++++++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 test/app/tarantoolctl.result
 create mode 100755 test/app/tarantoolctl.test.lua

diff --git a/extra/dist/tarantoolctl.in b/extra/dist/tarantoolctl.in
index 535154c96b..8859b95189 100755
--- a/extra/dist/tarantoolctl.in
+++ b/extra/dist/tarantoolctl.in
@@ -421,6 +421,8 @@ local function wrapper_cfg(cfg)
     require('fiber').name(instance_name)
     log.info('Run console at %s', console_sock)
     console.listen(console_sock)
+    -- gh-1293: members of `tarantool` group should be able to do `enter`
+    fio.chmod(console_sock, tonumber('0664', 8))
 
     return res
 end
@@ -536,7 +538,12 @@ elseif cmd == 'logrotate' then
 
 elseif cmd == 'enter' then
     if fio.stat(console_sock) == nil then
-        log.error("Can't connect to %s (socket not found)", console_sock)
+        local e = errno()
+        log.error("Can't connect to %s (%s)", console_sock, errno.strerror())
+        if not usermode and e == errno.EACCES then
+            log.error("Please add $USER to group '%s': useradd -a -G %s $USER",
+                      group_name, group_name)
+        end
         os.exit(-1)
     end
 
diff --git a/test/app/tarantoolctl.result b/test/app/tarantoolctl.result
new file mode 100644
index 0000000000..4e24c1a042
--- /dev/null
+++ b/test/app/tarantoolctl.result
@@ -0,0 +1,3 @@
+TAP version 13
+1..1
+ok - gh1293: permission denied on tarantoolctl enter
diff --git a/test/app/tarantoolctl.test.lua b/test/app/tarantoolctl.test.lua
new file mode 100755
index 0000000000..9726b3ba61
--- /dev/null
+++ b/test/app/tarantoolctl.test.lua
@@ -0,0 +1,17 @@
+#!/usr/bin/env tarantool
+
+local test = require('tap').test('cfg')
+test:plan(1)
+
+-------------------------------------------------------------------------------
+-- gh-1293: permission denied on tarantoolctl enter
+-------------------------------------------------------------------------------
+
+-- test-run uses tarantoolctl under the hood
+local console_sock = 'box.control'
+local mode = require('fio').stat(console_sock).mode
+test:is(string.format("%o", mode), "140664",
+    "gh1293: permission denied on tarantoolctl enter")
+
+test:check()
+os.exit(0)
-- 
GitLab