From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#53847: 28.0.91; Tramp SSHFS: incorrect remote home directory Date: Thu, 10 Mar 2022 12:37:44 +0100 Message-ID: <87ilsmujg7.fsf@gmx.de> References: <871r0ct40m.fsf@gmx.de> <87r17bv5b5.fsf@gmx.de> 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="14376"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 53847@debbugs.gnu.org To: Philipp Stephani Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Mar 10 13:32:56 2022 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 1nSHyS-0003e2-1T for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 10 Mar 2022 13:32:56 +0100 Original-Received: from localhost ([::1]:55460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSHyR-0001kU-0i for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 10 Mar 2022 07:32:55 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:53814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSH7K-000101-MC for bug-gnu-emacs@gnu.org; Thu, 10 Mar 2022 06:38:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:39589) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSH7K-0001JP-DI for bug-gnu-emacs@gnu.org; Thu, 10 Mar 2022 06:38:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nSH7K-0006CQ-58 for bug-gnu-emacs@gnu.org; Thu, 10 Mar 2022 06:38:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 10 Mar 2022 11:38:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53847 X-GNU-PR-Package: emacs Original-Received: via spool by 53847-submit@debbugs.gnu.org id=B53847.164691227323814 (code B ref 53847); Thu, 10 Mar 2022 11:38:02 +0000 Original-Received: (at 53847) by debbugs.gnu.org; 10 Mar 2022 11:37:53 +0000 Original-Received: from localhost ([127.0.0.1]:33486 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSH7B-0006C1-2N for submit@debbugs.gnu.org; Thu, 10 Mar 2022 06:37:53 -0500 Original-Received: from mout.gmx.net ([212.227.15.19]:43325) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSH79-0006Bm-FR for 53847@debbugs.gnu.org; Thu, 10 Mar 2022 06:37:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1646912265; bh=jET9FeEDhHXB/nQWxDzNMlK2reXSUdMYxfdysyarKRA=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=R1iLPxX6SvCcIIm+uind2ozRR2QCOGgIB35aG6fsjqJEdu8PKx4zGQ7bp4tYHj32U rwZVoc+7Wp0lYTePxvVJWTxlyE+eNZSJGGW50xZsfQTifBTgKI4Xc7Mwpd9MH8615m cylOTn+lhz/bb9sGwH8qxluDt7N6wZp6M2T+uT/c= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Original-Received: from gandalf.gmx.de ([212.91.243.107]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mqs4Z-1nwdvk0Hcv-00muRO; Thu, 10 Mar 2022 12:37:45 +0100 In-Reply-To: <87r17bv5b5.fsf@gmx.de> (Michael Albinus's message of "Wed, 09 Mar 2022 10:33:18 +0100") X-Provags-ID: V03:K1:XdswwPGrn5qLq9y+drLNZYlsd2+QI3M7msNA4xRNwz5KZ4e3l60 6wFdnQBEtvup8NPsc/9oCNF2AED+2tm79HBKYx1e9/tD8fgGbsg6e5PgjhsyuMyc7yIMClo r3wqZCq5jTh7YYTJo6DsTlZNq2+t+TUa3cfSqs6ujwYOkzy+0xTUmFuqEDuGby0gnB6ql6q HXUu98wAeXmAOLd45PoHg== X-UI-Out-Filterresults: notjunk:1;V03:K0:SHZ1bdf18n4=:Ekxg5DeHqTqDoZrCLISJnd SLp6p54eDdvQ2K+OS0iHo0neIcWDZd8pt9Fed0VKbyjg4kk0OCDRy3N6dj/ircnrLwcj9Mv1V gS4glnlyi+AgJoiNfcXRmRXJcdiReQEJ4fCvsspECEhMb0tZPW6n398J4GSSxoGB85UIM9JE5 bcNJVZ/E8xtJnTynDsQabvA/gLWrreKUUXqkFcM9TwH90VQBeawDwGpff5zNRny9JkGz+WuuI 36RC8x9mR3WL60kKw63/97VmckXyqGg0uWGjfrgV0EYS8Fg33LTdJOfSt4p4PhmPZiI8r+lYv 46XCsYlto8V/LAXt48syCSkjm1tZmA3ToFpnvmrrms7o8XBnlK68sbCJ4LZPQokDP23MpjPCr YSkK6TEwtWUatieGcV2W4SxV8zqM0mYsY4Z3PSbCeysG6kyMCmOr9uugteDHI2wjGdwDsOLtj Oe/tp92gjIw2FbPHUhcfxE5SGIDEeRqE1NkKs8Hn3/oXmAJ7Aa8RRDawjRW6WRUO/O521jUV+ uQqxI8KYL/Ol8ol9/39bTV8Qrw+sZZKY+p1SdXXc2iF2JH+/fDcqj+PPQHo18jrjpkChTd6Xg lTTgO07jS7hFH7lIBSZCgZIpzm+mvUJNRTPCXj4lPaoQKUz8lobfLjv+7hCVgns9TccOhPWpq Q0m6bKlOwTQjEcqG0EifLixizZDMSUwhTjeQ3BHSAg6o75GZr7SkiPC87ICOfmOlpLm2+DYFm CPM6XmGb0RNqrFzddmsl9UdNk3Sq3IpfbQo/J9uDtrKjvhoNYkQjytTHHklk9hUaTaUn26TD 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:228187 Archived-At: Michael Albinus writes: Hi Philipp, >> Thanks, but would it maybe be possible to find a better solution? I've >> been using SSHFS for a while now, and this particular issue is pretty >> annoying in practice. How about any of the following: >> - When connecting over SSHFS, ask the remote host (via SSH) for the >> home directory and cache the result. >> - Allow the user to configure a per-host static home directory (i.e. >> just a customizable mapping from hosts + users to home directories). I >> regularly only connect to 2 hosts with known hostnames and home >> directories, so at least for me maintaining such a mapping would be >> feasible. >> WDYT? > > Tramp uses already a cached value for the home directory, under the key > "~". You could try the following: > > (add-to-list 'tramp-connection-properties > (list (regexp-quote "/sshfs:user@randomhost.your.domain:") > "~" "/home/user")) > > It is untested, and you need a fresh git checkout of master. Please > report whether it works; I would add the recipe to the manual then. Well, it didn't work out of the box. So I've pushed a fix to the master branch in order to support this. Note, that you need the connection property "~user", with "user" being your remote user name. The Tramp manual has been enhanced with this new section: --8<---------------cut here---------------start------------->8--- 5.5 Expanding =E2=80=98~=E2=80=99 to home directory =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Home directories on remote hosts can be typed as tilde =E2=80=98~=E2=80=99.= If possible, they are expanded to the remote user=E2=80=99s home directory on = the remote host. Example: /ssh:user@host:~ =E2=87=92 /ssh:user@host:/home/user This works in general for =E2=80=98ssh=E2=80=99-like methods, and for = =E2=80=98sudoedit=E2=80=99. These methods allow also the home directory expansion for another user, like /sudoedit::~otheruser =E2=87=92 /sudoedit:root@localhost:/home/otheruser For other methods, a home directory can be expanded only if supported. This happens for example for the =E2=80=98sftp=E2=80=99 method.= Methods, which require a share directory in the remote file name (=E2=80=98afp=E2=80= =99, =E2=80=98smb=E2=80=99), use the value of this share directory as home direc= tory: /smb:user@host:~ =E2=87=92 /smb:user@host:/share Since Tramp cannot know in advance which share directory is intended to use, this expansion can be applied only when a share directory has been used already. The methods =E2=80=98adb=E2=80=99, =E2=80=98rclone=E2=80=99 and =E2=80= =98sshfs=E2=80=99 do not support home directory expansion at all. However, TRAMP keeps the home directory in the cache. Therefore, those methods could be configured to expand a home directory via a connection property, *Note Predefined connection information::. Example: (add-to-list 'tramp-connection-properties (list (regexp-quote "/sshfs:user@randomhost.your.domain:") "~user" "/home/user")) When your remote file name does not contain a =E2=80=98user=E2=80=99 par= t, the connection property "~" must be used instead. --8<---------------cut here---------------end--------------->8--- Best regards, Michael.