From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Ulrich Mueller Newsgroups: gmane.emacs.bugs Subject: bug#33847: 27.0.50; emacsclient does not find server socket Date: Sun, 20 Jan 2019 18:59:39 +0100 Message-ID: References: <8a6fc59c-08b3-e274-4fb1-74674c79540a@cs.ucla.edu> <9ebcad22-2cdb-46fb-4be9-efc4ad234b6d@cs.ucla.edu> <27d2f2eb-8956-4088-f3ec-5ff6c2cf2e8f@cs.ucla.edu> NNTP-Posting-Host: ciao.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ciao.gmane.org 1548007210 132183 195.159.176.228 (20 Jan 2019 18:00:10 GMT) X-Complaints-To: usenet@ciao.gmane.org NNTP-Posting-Date: Sun, 20 Jan 2019 18:00:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 33847@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 20 19:00:08 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1glHOA-000YJM-7D for geb-bug-gnu-emacs@m.gmane.org; Sun, 20 Jan 2019 19:00:06 +0100 Original-Received: from localhost ([127.0.0.1]:42698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glHOJ-0001Oq-DE for geb-bug-gnu-emacs@m.gmane.org; Sun, 20 Jan 2019 13:00:15 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:36846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glHOC-0001Kn-NK for bug-gnu-emacs@gnu.org; Sun, 20 Jan 2019 13:00:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1glHO6-0000ah-Nk for bug-gnu-emacs@gnu.org; Sun, 20 Jan 2019 13:00:08 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39881) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1glHO6-0000aN-K1 for bug-gnu-emacs@gnu.org; Sun, 20 Jan 2019 13:00:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1glHO6-00005F-Eu for bug-gnu-emacs@gnu.org; Sun, 20 Jan 2019 13:00:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Ulrich Mueller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Jan 2019 18:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33847 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33847-submit@debbugs.gnu.org id=B33847.154800719132736 (code B ref 33847); Sun, 20 Jan 2019 18:00:02 +0000 Original-Received: (at 33847) by debbugs.gnu.org; 20 Jan 2019 17:59:51 +0000 Original-Received: from localhost ([127.0.0.1]:39162 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1glHNv-0008Vw-JL for submit@debbugs.gnu.org; Sun, 20 Jan 2019 12:59:51 -0500 Original-Received: from smtp.gentoo.org ([140.211.166.183]:36976) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1glHNt-0008Vf-DM for 33847@debbugs.gnu.org; Sun, 20 Jan 2019 12:59:50 -0500 Original-Received: from a1i15 (host2092.kph.uni-mainz.de [134.93.134.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: ulm) by smtp.gentoo.org (Postfix) with ESMTPSA id 3C882335D06; Sun, 20 Jan 2019 17:59:42 +0000 (UTC) In-Reply-To: (Paul Eggert's message of "Sat, 29 Dec 2018 22:44:59 -0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:154624 Archived-At: >>>>> On Sun, 30 Dec 2018, Paul Eggert wrote: > Because we're not absolutists. On older systems that do not have > adequate provisions for security, Emacs does the best it can: that's > better than not doing anything, and people who run older, less-secure > systems are likely to not care all that much about security anyway so > this is OK. On newer systems that are more secure, though, Emacs can > be more secure. Since there doesn't seem to be any progress here, please find below the patch that I am using since some time. >From f8d87a0a89b91c120935bd5be802604b2c749767 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulrich=20M=C3=BCller?= Date: Sun, 20 Jan 2019 18:48:45 +0100 Subject: [PATCH] Add a fallback for the socket location in emacsclient (bug#33847) * lib-src/emacsclient.c (set_local_socket): Fall back to TMPDIR if the socket is not found under XDG_RUNTIME_DIR. --- lib-src/emacsclient.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index f476840898..27b945133e 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -1356,6 +1356,7 @@ set_local_socket (char const *server_name) enum { socknamesize = sizeof server.un.sun_path }; int tmpdirlen = -1; int socknamelen = -1; + int sock_status = -1; uid_t uid = geteuid (); if (strchr (server_name, '/') @@ -1366,9 +1367,15 @@ set_local_socket (char const *server_name) /* socket_name is a file name component. */ char const *xdg_runtime_dir = egetenv ("XDG_RUNTIME_DIR"); if (xdg_runtime_dir) - socknamelen = snprintf (sockname, socknamesize, "%s/emacs/%s", - xdg_runtime_dir, server_name); - else + { + socknamelen = snprintf (sockname, socknamesize, "%s/emacs/%s", + xdg_runtime_dir, server_name); + /* Check if sockname is valid and if the socket exists. */ + if (0 <= socknamelen && socknamelen < socknamesize) + sock_status = socket_status (sockname, uid); + } + + if (sock_status) { char const *tmpdir = egetenv ("TMPDIR"); if (tmpdir) @@ -1399,7 +1406,9 @@ set_local_socket (char const *server_name) } /* See if the socket exists, and if it's owned by us. */ - int sock_status = socket_status (sockname, uid); + if (sock_status) + sock_status = socket_status (sockname, uid); + if (sock_status) { /* Failing that, see if LOGNAME or USER exist and differ from -- 2.19.1