From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrew Eggenberger Newsgroups: gmane.emacs.bugs Subject: bug#44131: 28.0.50; emacsclient Invalid socket owner error Date: Sun, 1 Nov 2020 19:24:42 -0600 Message-ID: References: <871rhqsoln.fsf@debian.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000f9e6ea05b3159c6b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27642"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 44131@debbugs.gnu.org To: Andrea Corallo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 02 02:25:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZOar-00073d-KO for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 02 Nov 2020 02:25:09 +0100 Original-Received: from localhost ([::1]:51692 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kZOaq-00043d-Fg for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 01 Nov 2020 20:25:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45024) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kZOak-00043E-DY for bug-gnu-emacs@gnu.org; Sun, 01 Nov 2020 20:25:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55763) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kZOak-0001BG-24 for bug-gnu-emacs@gnu.org; Sun, 01 Nov 2020 20:25:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kZOaj-0006MB-S4 for bug-gnu-emacs@gnu.org; Sun, 01 Nov 2020 20:25:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Andrew Eggenberger Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 02 Nov 2020 01:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44131 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: moreinfo Original-Received: via spool by 44131-submit@debbugs.gnu.org id=B44131.160428030024426 (code B ref 44131); Mon, 02 Nov 2020 01:25:01 +0000 Original-Received: (at 44131) by debbugs.gnu.org; 2 Nov 2020 01:25:00 +0000 Original-Received: from localhost ([127.0.0.1]:39076 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZOai-0006Lt-Ip for submit@debbugs.gnu.org; Sun, 01 Nov 2020 20:25:00 -0500 Original-Received: from mail-ot1-f53.google.com ([209.85.210.53]:43119) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kZOag-0006Le-E0 for 44131@debbugs.gnu.org; Sun, 01 Nov 2020 20:24:59 -0500 Original-Received: by mail-ot1-f53.google.com with SMTP id y22so662476oti.10 for <44131@debbugs.gnu.org>; Sun, 01 Nov 2020 17:24:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=78MOsSIlS9/gxoZ1IXTgWfEBI4RKWDbCQRaB0J8r3ew=; b=BsCw/3o3eleqZ6yIx+V9nwbtu0TzFPLFQOVDxcxpPDSD7kPLxCBylYP7rb2HuyIaOl 9/AR6+Pvrgj+T9ORpKRuzPZoCSsBZ3oMSosjvHEBvB8vMCDVj+IM/2RaByeCoxwq0Sn0 Joirk8CpOUOh2CEA5u1nOmiv+NQRdyEenP44trWhPcBJW4PFD3uH2Wl+IBToPF7qL9kR PeUxb/XTAtWbR84A67kmR9SFgN6QMZitBg3F4ehmJmRYkrnozZMw3YPSH0593NNEvw8k 1oIzydS2MT7rN2RKb2b/1HAn0pK34kJ/iApwdMm1mTND7YjlBO4MWB3BilFfVQQT//kl jHvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=78MOsSIlS9/gxoZ1IXTgWfEBI4RKWDbCQRaB0J8r3ew=; b=amY1dep/62xqzsZM8UlLFSb52/XhgQazbVcFPA5TvN3jzHRRat3U6jcbdLdsTetEXU 2VQVc5/A+aLb79Uza1azQA1+nJzbM4phx8GqYUqqnAfi4zl47pBX4DdswgSGEcLd0av5 3hnLxMzX5sItZnOxp21AnyDh2JWi5pSbq0abjxON0bs7YSuVBEt2MVSFm2sJJcByy09L EHhtdG36fl2/KfVDKd+TQzsbOtTod/+dEuiKcbZgPCDi6uZZMZdfiIBaqoS8gq0bDzgg YwgbeViebcjkulR+48QFT4tH3qNHEpbV5qr99HoQo29EAQlgWSGlUYVKSPivlz2irkKM GxrQ== X-Gm-Message-State: AOAM533m4ncSUSdF0bAsXmR8FE6B3Wf9bpYE4cPwhlxCHF/WJ74HQItx 0TY87R2U3bofraPzvLEP+A3sPQ8mPtdjMygqSUo= X-Google-Smtp-Source: ABdhPJysr6f37hS06M3NoppSPUP6jzhJtf/Ty0OpLqvCAUsyyDsSx2iKixyn/FQlZexor+/VzDcEhYRDgdZi5uUzn2M= X-Received: by 2002:a05:6830:1c62:: with SMTP id s2mr9717223otg.177.1604280292860; Sun, 01 Nov 2020 17:24:52 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:192494 Archived-At: --000000000000f9e6ea05b3159c6b Content-Type: text/plain; charset="UTF-8" Hi, The problem seems to stem from the way the hurd treats fstat calls on local socket file descriptors. They all have the uid of 0 (root), while emacsclient can be run by other users. After trying to teach the hurd's local socket server to use the uid of the user who requested the socket and failing, I created the naive patch below that fixes the problem. Please let me know if there's a better solution. I git blamed the changes that led to this issue and I don't understand the race condition the uid comparison is supposed prevent. Andrew Eggenberger diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 871fa7a8d3..6059993ff6 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -1480,8 +1480,13 @@ set_local_socket (char const *server_name) sock_status = errno; else if (connect_stat.st_uid == uid) return s; +#ifdef __GNU__ + else + return s; +#else else sock_status = -1; +#endif CLOSE_SOCKET (s); } --000000000000f9e6ea05b3159c6b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

The pro= blem seems to stem from the way the hurd treats fstat calls on local socket=
file descriptors. They all have the uid of 0 (root), while emacs= client can be run by=C2=A0
other users. After trying to teach the= hurd's local socket server to use the uid of=C2=A0
the user = who requested the socket and failing, I created the naive patch below that<= /div>
fixes the problem.

Please let me know if= there's a better solution. I git blamed the changes that led to this
issue and I don't understand the race condition the uid compar= ison is supposed prevent.

Andrew Eggenberger
=

diff --git a/lib-src/emacsclient.c b/lib-src/emacsclien= t.c
index 871fa7a8d3..6059993ff6 100644
--- a/lib-src/e= macsclient.c
+++ b/lib-src/emacsclient.c
@@ -1480,8 +14= 80,13 @@ set_local_socket (char const *server_name)
=C2=A0 =C2=A0= =C2=A0 =C2=A0 sock_status =3D errno;
=C2=A0 =C2=A0 =C2=A0 =C2=A0= else if (connect_stat.st_uid =3D=3D uid)
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 return s;
+#ifdef __GNU__
+ =C2=A0 =C2=A0 =C2=A0els= e
+ =C2=A0 =C2=A0 =C2=A0 return s;
+#else
=C2= =A0 =C2=A0 =C2=A0 =C2=A0else
=C2=A0 =C2=A0 =C2=A0 =C2=A0 sock_sta= tus =3D -1;
+#endif

=C2=A0 =C2=A0 =C2=A0= =C2=A0CLOSE_SOCKET (s);
=C2=A0 =C2=A0 =C2=A0}
--000000000000f9e6ea05b3159c6b--