From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Bj=C3=B6rn?= Bidar via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#66667: [PATCH] Socket forwarding in emacsclient --tramp-prefix example Date: Sun, 22 Oct 2023 04:05:57 +0300 Message-ID: <27539.506233164$1697936816@news.gmane.org> References: <20231021150127.66683-1-git@mavit.org.uk> Reply-To: =?UTF-8?Q?Bj=C3=B6rn?= Bidar Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5434"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 66667@debbugs.gnu.org, Peter Oliver To: Peter Oliver Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 22 03:06:48 2023 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 1quMvY-0001C7-6R for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 22 Oct 2023 03:06:48 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quMvN-00071s-4U; Sat, 21 Oct 2023 21:06:37 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1quMvK-00071g-4U for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 21:06:35 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quMvJ-0007RL-Mg for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 21:06:33 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1quMvl-0000YI-Hm for bug-gnu-emacs@gnu.org; Sat, 21 Oct 2023 21:07:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Bj=C3=B6rn?= Bidar Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Oct 2023 01:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 66667 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 66667-submit@debbugs.gnu.org id=B66667.16979368042095 (code B ref 66667); Sun, 22 Oct 2023 01:07:01 +0000 Original-Received: (at 66667) by debbugs.gnu.org; 22 Oct 2023 01:06:44 +0000 Original-Received: from localhost ([127.0.0.1]:45246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quMvP-0000Xd-Lf for submit@debbugs.gnu.org; Sat, 21 Oct 2023 21:06:43 -0400 Original-Received: from thaodan.de ([185.216.177.71]:46306) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1quMvJ-0000XI-0v for 66667@debbugs.gnu.org; Sat, 21 Oct 2023 21:06:38 -0400 Original-Received: from odin (dsl-trebng12-50dc77-87.dhcp.inet.fi [80.220.119.87]) by thaodan.de (Postfix) with ESMTPSA id 3E8F4D08C7F; Sun, 22 Oct 2023 04:05:58 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=thaodan.de; s=mail; t=1697936758; bh=9mHrsfwdEOdm8xgXEmM8e44q0bIiKtzLx7Zf/96JK7w=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=gpBZBFWz/LlqUWFNDXSaZNHGdZpY4uk48aaI3ZohxX4r02LMh5DhH9phmxALO4t0B +wd7SU6PQWDJPpd64Pu5DReWnC38EaXwMvTe1fXoVsKgbZiFfNeD7yPSGylHToZPbT fHkoIQ/hH0yYJZv2xnTiEtwvwgrF2YRFAIHoquQ+HCcdEwBElH/qt3EPmqi1nEP6Ak A49Q32D1re7YQUEid7kOTOK3uapSkf+1aZ1xS074tuUY8KvhJ67V9MNALvMLwpW64j 3t8HMlaGNLiaN0BE47O/5i7gdUHepKpwFaS4lvGSuww3GJyALlQBzmYylVCfy/9ZSc Qcs3ycZXkB4xXIL8Vza4fPHjvASQ+UONqrbt+sD5P9s/s57XiJLH5wodCjsxL638gW SIQa3rLR7rPuPWmBT1LQYDnno2UUCghNPKZDZPisyJnmsHLJsv11dqgnu4B2ajRMJG KqHzBQgiWfFSc2YrwtOcSW+fwoHigGV0EIPybrVrXaqiipHebOc9/QtPsqjhbXEV4L wZywvWchkH9F69pBBkieicQFSyGfjZvkfm3HAUlf+OfhybM45vLoxYhPs/A0xqcvJ1 99WtOnCWsaALHdo8Dn1sZUniBF1VrSAZo4glljpG5fiNX1TuHSu+qHr37Xp6fPSCDV PjH+T0x3y7SjIKwJUZquwTW4= In-Reply-To: <20231021150127.66683-1-git@mavit.org.uk> (Peter Oliver's message of "Sat, 21 Oct 2023 16:01:27 +0100") Autocrypt: addr=bjorn.bidar@thaodan.de; prefer-encrypt=nopreference; keydata= mDMEZNfpPhYJKwYBBAHaRw8BAQdACBEmr+0xwIIHZfIDlZmm7sa+lHHSb0g9FZrN6qE6ru60JUJq w7ZybiBCaWRhciA8Ympvcm4uYmlkYXJAdGhhb2Rhbi5kZT6IlgQTFgoAPgIbAwULCQgHAgIiAgYV CgkICwIEFgIDAQIeBwIXgBYhBFHxdut1RzAepymoq1wbdKFlHF9oBQJk1/YmAhkBAAoJEFwbdKFl HF9oB9cBAJoIIGQKXm4cpap+Flxc/EGnYl0123lcEyzuduqvlDT0AQC3OlFKm/OiqJ8IMTrzJRZ8 phFssTkSrrFXnM2jm5PYDoiTBBMWCgA7FiEEUfF263VHMB6nKairXBt0oWUcX2gFAmTX6T4CGwMF CwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgkQXBt0oWUcX2hbCQEAtru7kvM8hi8zo6z9ux2h K+B5xViKuo7Z8K3IXuK5ugwA+wUfKzomzdBPhfxDsqLcEziGRxoyx0Q3ld9aermBUccHtBxCasO2 cm4gQmlkYXIgPG1lQHRoYW9kYW4uZGU+iJMEExYKADsCGwMFCwkIBwICIgIGFQoJCAsCBBYCAwEC HgcCF4AWIQRR8XbrdUcwHqcpqKtcG3ShZRxfaAUCZNf2FQAKCRBcG3ShZRxfaCzSAP4hZ7cSp0YN XYpcjHdsySh2MuBhhoPeLGXs+2kSiqBiOwD/TP8AgPEg/R+SI9GI9on7fBJJ0mp2IT8kZ2rhDOjg gA6IkwQTFgoAOxYhBFHxdut1RzAepymoq1wbdKFlH 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:272946 Archived-At: Peter Oliver writes: > Previously, the emacsclient --tramp-prefix documentation suggested > using it in conjunction with a forwarded TCP port. However, OpenSSH > has supported forwarding sockets since version 6.7 (released 2014), so > let=E2=80=99s suggest that instead. Sockets require less manual configur= ation > than ports, are less likely to clash, and are more secure, so will be > a better choice for the majority of people looking to set up this > facility for the first time. > > * doc/emacs/misc.texi (emacsclient Options): Suggest forwarding sockets. > --- > doc/emacs/misc.texi | 18 ++++++++---------- > 1 file changed, 8 insertions(+), 10 deletions(-) > > diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi > index a05b7f6c6ea..93771832ff5 100644 > --- a/doc/emacs/misc.texi > +++ b/doc/emacs/misc.texi > @@ -2158,8 +2158,9 @@ emacsclient Options > Set the prefix to add to filenames for Emacs to locate files on remote > machines (@pxref{Remote Files}) using TRAMP (@pxref{Top, The Tramp > Manual,, tramp, The Tramp Manual}). This is mostly useful in > -combination with using the Emacs server over TCP (@pxref{TCP Emacs > -server}). By ssh-forwarding the listening port and making the > +combination with using the Emacs server from a remote host. By > +ssh-forwarding the listening socket, or ssh-forwarding the listening > +port @pxref{TCP Emacs server} and making the > @var{server-file} available on a remote machine, programs on the > remote machine can use @command{emacsclient} as the value for the > @env{EDITOR} and similar environment variables, but instead of talking > @@ -2171,16 +2172,13 @@ emacsclient Options > effect as using the @samp{-T} option. If both are specified, the > command-line option takes precedence. >=20=20 > -For example, assume two hosts, @samp{local} and @samp{remote}, and > -that the local Emacs listens on tcp port 12345. Assume further that > -@file{/home} is on a shared file system, so that the server file > -@file{~/.emacs.d/server/server} is readable on both hosts. > +For example, assume two hosts, @samp{local} and @samp{remote}. >=20=20 > @example > -local$ ssh -R12345:localhost:12345 remote > -remote$ export EDITOR=3D"emacsclient \ > - --server-file=3Dserver \ > - --tramp=3D/ssh:remote:" > +local$ ssh -R "/tmp/emacs-%r.socket":"$@{XDG_RUNTIME_DIR:-$@{TMPDIR:-/tm= p@}/emacs%i@}$@{XDG_RUNTIME_DIR:+/emacs@}/server" remote > +remote$ export EMACS_SOCKET_NAME=3D/tmp/emacs-$USER.socket If the host has run /run/user it would make sense to setup the Emacs socket inside this directory. If the socket fie is in /tmp every other user can read it, using /run/user = is more secure. On older systems this might be /var/run/user I think. > +remote$ export EMACSCLIENT_TRAMP=3D/ssh:remote: > +remote$ export EDITOR=3Demacsclient > remote$ $EDITOR /tmp/foo.txt #Should open in local emacs. > @end example