From unknown Sat Aug 09 04:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41628: [PATCH] Allow emacsclient to connect to other user's socket when using -s Resent-From: rabite Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 May 2020 15:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41628 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 41628@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Reply-To: rabite@posteo.de Received: via spool by submit@debbugs.gnu.org id=B.159093896423806 (code B ref -1); Sun, 31 May 2020 15:30:02 +0000 Received: (at submit) by debbugs.gnu.org; 31 May 2020 15:29:24 +0000 Received: from localhost ([127.0.0.1]:33620 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jfPts-0006Bt-5n for submit@debbugs.gnu.org; Sun, 31 May 2020 11:29:24 -0400 Received: from lists.gnu.org ([209.51.188.17]:50108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jfOMq-0003Uk-RO for submit@debbugs.gnu.org; Sun, 31 May 2020 09:51:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfOMq-0006k2-Iz for bug-gnu-emacs@gnu.org; Sun, 31 May 2020 09:51:12 -0400 Received: from mout02.posteo.de ([185.67.36.66]:56201) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jfOMl-0002z3-Ep for bug-gnu-emacs@gnu.org; Sun, 31 May 2020 09:51:12 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id B7A622400FD for ; Sun, 31 May 2020 15:51:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1590933063; bh=Zaj/n63dsEWXjY7LFKi2MLvRAtZGgMCl1L31c/M+sNk=; h=Date:From:To:Subject:From; b=T5hweyFHOs6RuPo4B/8Ok0rnei3iSkk9JX0HGwDa4vceORlIig5tqLqx83qcI9E7a stLrt87MxF5qsogfx77CeRLtq/+Lad+yvLl60M83bxsCnb9GW2RO5RmBZWM8L2bkJn DI+/OpL17ssXQyEWhablWLAKujH8AKRBJgnnTkMuYfqOhnhrRI95+9FCF8LIgPnHxy uueWXDnbj212IA0+bYb7jtdWBDhJ7a+I5htg1UajxS1yPnysi5QZPJOHoeMwy9k1CB kpp1QvhrJqQrW0j7iLegu5Y+w7i+4j83Ng0t1/97Juo/AgFfhjmNEmwMQPnffS3wDI dMio4lwivrRWQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 49Zfpb1BQ4z9rxS for ; Sun, 31 May 2020 15:51:02 +0200 (CEST) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=_09021876c5e2fe750c2f33f00d5f9f58" Date: Sun, 31 May 2020 15:51:02 +0200 From: rabite Mail-Reply-To: rabite@posteo.de Message-ID: X-Sender: rabite@posteo.de User-Agent: Posteo Webmail Received-SPF: pass client-ip=185.67.36.66; envelope-from=rabite@posteo.de; helo=mout02.posteo.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/05/31 08:26:17 X-ACL-Warn: Detected OS = Linux 3.11 and newer X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Mailman-Approved-At: Sun, 31 May 2020 11:29:23 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=_09021876c5e2fe750c2f33f00d5f9f58 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Since commit 5c0d8bb95bbd5354e6b2cd2e56a91afe4e780759 emacsclient won't connect to my usual emacs session when run as root. I use this all the time to edit files, combined with "-T /sudo:root@localhost" to handle permissions. Using a separate emacs process would be unpractical as it would require setting up a whole new emacs configuration and keeping it in sync with my main one. I think this is a common use-case for those who have an emacs-server running all the time and supporting it makes a lot of sense. In principle I see no reason emacsclient should refuse a connection that is possible in theory. It looks like this "feature" has been explicitly disabled, maybe because it might triggered unintentionally if running su doesn't set USER or something?. So I propose a new approach to allow root emacsclient to connect to non-root emacs servers: If the user sets a socket file explicitly using the -s switch, the socket_status() function skips the uid check and returns without error as long as the call to stat was successful. Generally, this would allow any user to connect to any emacs server as long as the permissions allow it. If not, it shows the "connect: Permission denied" message, if the socket file is reachable at all, that is. I added a tiny patch that implements this change. If necessary, I'd be willing to expand on it, or even implement a different approach depending on how much work/complicated it would be. --=_09021876c5e2fe750c2f33f00d5f9f58 Content-Transfer-Encoding: base64 Content-Type: text/x-diff; name=0001-allow-sockets-with-different-uid-if-set-explicitly.patch~ Content-Disposition: attachment; filename=0001-allow-sockets-with-different-uid-if-set-explicitly.patch~; size=684 RnJvbSBmNGQxYmZkNDExMmU0OTI3MGM0ODg3NDg1NjIwYjcxMzc2YWUyYzMwIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiByYWJpdGUgPHJhYml0ZUBwb3N0ZW8uZGU+CkRhdGU6IFN1biwg MzEgTWF5IDIwMjAgMTQ6NDg6NDcgKzAyMDAKU3ViamVjdDogW1BBVENIXSBhbGxvdyBzb2NrZXRz IHdpdGggZGlmZmVyZW50IHVpZCBpZiBzZXQgZXhwbGljaXRseQoKLS0tCiBsaWItc3JjL2VtYWNz Y2xpZW50LmMgfCAyICstCiAxIGZpbGUgY2hhbmdlZCwgMSBpbnNlcnRpb24oKyksIDEgZGVsZXRp b24oLSkKCmRpZmYgLS1naXQgYS9saWItc3JjL2VtYWNzY2xpZW50LmMgYi9saWItc3JjL2VtYWNz Y2xpZW50LmMKaW5kZXggMzgwYmU5NTIyMi4uY2NlZjkwODVlNCAxMDA2NDQKLS0tIGEvbGliLXNy Yy9lbWFjc2NsaWVudC5jCisrKyBiL2xpYi1zcmMvZW1hY3NjbGllbnQuYwpAQCAtMTE1Nyw3ICsx MTU3LDcgQEAgc29ja2V0X3N0YXR1cyAoY29uc3QgY2hhciAqbmFtZSwgdWlkX3QgdWlkKQogICBp ZiAoc3RhdCAobmFtZSwgJnN0YXRiZnIpICE9IDApCiAgICAgcmV0dXJuIGVycm5vOwogCi0gIGlm IChzdGF0YmZyLnN0X3VpZCAhPSB1aWQpCisgIGlmIChzdGF0YmZyLnN0X3VpZCAhPSB1aWQgJiYg IXNvY2tldF9uYW1lKQogICAgIHJldHVybiAtMTsKIAogICByZXR1cm4gMDsKLS0gCjIuMjYuMgoK --=_09021876c5e2fe750c2f33f00d5f9f58-- From unknown Sat Aug 09 04:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41628: [PATCH] Allow emacsclient to connect to other user's socket when using -s Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 May 2020 15:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41628 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: rabite@posteo.de Cc: 41628@debbugs.gnu.org Received: via spool by 41628-submit@debbugs.gnu.org id=B41628.159093989925249 (code B ref 41628); Sun, 31 May 2020 15:45:01 +0000 Received: (at 41628) by debbugs.gnu.org; 31 May 2020 15:44:59 +0000 Received: from localhost ([127.0.0.1]:33635 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jfQ8x-0006ZA-A9 for submit@debbugs.gnu.org; Sun, 31 May 2020 11:44:59 -0400 Received: from eggs.gnu.org ([209.51.188.92]:42930) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jfQ8v-0006Yx-3b for 41628@debbugs.gnu.org; Sun, 31 May 2020 11:44:57 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:55968) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jfQ8p-0004An-7F; Sun, 31 May 2020 11:44:51 -0400 Received: from [176.228.60.248] (port=4813 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jfQ8o-000269-H8; Sun, 31 May 2020 11:44:51 -0400 Date: Sun, 31 May 2020 18:44:50 +0300 Message-Id: <835zcckt1p.fsf@gnu.org> From: Eli Zaretskii In-Reply-To: (message from rabite on Sun, 31 May 2020 15:51:02 +0200) References: X-Spam-Score: -1.4 (-) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) > Date: Sun, 31 May 2020 15:51:02 +0200 > From: rabite > > Since commit 5c0d8bb95bbd5354e6b2cd2e56a91afe4e780759 emacsclient won't > connect to my usual emacs session when run as root. I use this all the > time to edit files, combined with "-T /sudo:root@localhost" to handle > permissions. Using a separate emacs process would be unpractical as it > would require setting up a whole new emacs configuration and keeping it > in sync with my main one. I think this is a common use-case for those > who have an emacs-server running all the time and supporting it makes a > lot of sense. In principle I see no reason emacsclient should refuse a > connection that is possible in theory. > > It looks like this "feature" has been explicitly disabled, maybe because > it might triggered unintentionally if running su doesn't set USER or > something? The discussion which led to that change is here: https://lists.gnu.org/r/emacs-devel/2018-11/msg00019.html From unknown Sat Aug 09 04:59:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#41628: [PATCH] Allow emacsclient to connect to other user's socket when using -s Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 05 Aug 2020 17:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41628 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: 41628@debbugs.gnu.org, rabite@posteo.de Received: via spool by 41628-submit@debbugs.gnu.org id=B41628.15966487767701 (code B ref 41628); Wed, 05 Aug 2020 17:33:02 +0000 Received: (at 41628) by debbugs.gnu.org; 5 Aug 2020 17:32:56 +0000 Received: from localhost ([127.0.0.1]:52182 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k3NHc-000209-Ev for submit@debbugs.gnu.org; Wed, 05 Aug 2020 13:32:56 -0400 Received: from quimby.gnus.org ([95.216.78.240]:43842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k3NHY-0001zr-Nq for 41628@debbugs.gnu.org; Wed, 05 Aug 2020 13:32:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=eDGsp+vn45JqBDgVFSTnHuNX/2/Q8DpvB8ai3+mkR0g=; b=YnlHxO8AZ3K48Ioz5u0UC1tULf Wgfz+26qjxHzBo4NGh7jfnxKy/9KxSRxZUDb2R2J0BqaqPN6j2vfpq5+sUyMwxzbwr2F5iWpKmHRP Ecz3tRBW8bKDyjVg926qZ8WljTvvy+RhC8HU2/vSRV9C10xBiQQykPvHsS/hEkBNGsFk=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k3NHM-0007At-19; Wed, 05 Aug 2020 19:32:46 +0200 From: Lars Ingebrigtsen References: <835zcckt1p.fsf@gnu.org> Date: Wed, 05 Aug 2020 19:32:38 +0200 In-Reply-To: <835zcckt1p.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 31 May 2020 18:44:50 +0300") Message-ID: <87sgd1hubt.fsf@gnus.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: Eli Zaretskii writes: >> Since commit 5c0d8bb95bbd5354e6b2cd2e56a91afe4e780759 emacsclient won't >> connect to my usual emacs session when run as root. I use this all the >> time to edit files, combined with "-T /sudo:root [...] Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Eli Zaretskii writes: >> Since commit 5c0d8bb95bbd5354e6b2cd2e56a91afe4e780759 emacsclient won't >> connect to my usual emacs session when run as root. I use this all the >> time to edit files, combined with "-T /sudo:root@localhost" to handle >> permissions. Using a separate emacs process would be unpractical as it >> would require setting up a whole new emacs configuration and keeping it >> in sync with my main one. I think this is a common use-case for those >> who have an emacs-server running all the time and supporting it makes a >> lot of sense. In principle I see no reason emacsclient should refuse a >> connection that is possible in theory. >> >> It looks like this "feature" has been explicitly disabled, maybe because >> it might triggered unintentionally if running su doesn't set USER or >> something? > > The discussion which led to that change is here: > > https://lists.gnu.org/r/emacs-devel/2018-11/msg00019.html So unless I understand something here, this is not something we want to allow (because of security concerns), so I'm closing this bug report. -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no From debbugs-submit-bounces@debbugs.gnu.org Wed Aug 05 13:32:59 2020 Received: (at control) by debbugs.gnu.org; 5 Aug 2020 17:33:00 +0000 Received: from localhost ([127.0.0.1]:52185 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k3NHf-00020O-NP for submit@debbugs.gnu.org; Wed, 05 Aug 2020 13:32:59 -0400 Received: from quimby.gnus.org ([95.216.78.240]:43858) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1k3NHf-000201-0O for control@debbugs.gnu.org; Wed, 05 Aug 2020 13:32:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Subject:From:To:Message-Id:Date:Sender:Reply-To:Cc: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=FBg22YT+mRGiOkTALAlY1z51XLhvZWc7RC0voIvrDHM=; b=nRMd8LeorjC6Um+knHJfsDRfRN 7Y3colSYAnIPjXn22o8/kMUnH5BD2iECj3CxYN9XcPUDq2TU+Mx2VQ6xL+jjRBXvERt7+FwiVRoPz onjsDDejSGhDJr+ot1qBpV/iNGWZ72m2RDbNo5D+qkGmqh2wH3g6lHuSUoeD8qRDNrI8=; Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k3NHX-0007B8-9e for control@debbugs.gnu.org; Wed, 05 Aug 2020 19:32:53 +0200 Date: Wed, 05 Aug 2020 19:32:50 +0200 Message-Id: <87r1slhubh.fsf@gnus.org> To: control@debbugs.gnu.org From: Lars Ingebrigtsen Subject: control message for bug #41628 X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see @@CONTACT_ADDRESS@@ for details. Content preview: tags 41628 wontfix close 41628 quit Content analysis details: (-2.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) tags 41628 wontfix close 41628 quit