From debbugs-submit-bounces@debbugs.gnu.org Mon Jan 02 13:23:08 2023 Received: (at submit) by debbugs.gnu.org; 2 Jan 2023 18:23:08 +0000 Received: from localhost ([127.0.0.1]:44020 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCPSl-0005Cs-0V for submit@debbugs.gnu.org; Mon, 02 Jan 2023 13:23:08 -0500 Received: from lists.gnu.org ([209.51.188.17]:41944) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pCJS8-0004JR-NA for submit@debbugs.gnu.org; Mon, 02 Jan 2023 06:58:05 -0500 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 1pCJS8-0007Dh-Dz for bug-gnu-emacs@gnu.org; Mon, 02 Jan 2023 06:58:04 -0500 Received: from mail2.aboa.net ([212.146.44.12]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCJS4-00041w-KY for bug-gnu-emacs@gnu.org; Mon, 02 Jan 2023 06:58:04 -0500 DomainKey-Signature: a=rsa-sha1; c=nofws; d=sinervo.fi; h=message-id :subject:from:to:date:content-type:content-transfer-encoding :mime-version; q=dns; s=private; b=JMXV/p0L5OVEQcARxYhNyIyhQbUNy jmJg0MVal1WIts2CVGBiNvAqAhJc/uK8v0bOZFLHtG3ZvHZ5iDhNzg8Tf+HrW0WT YZw0DiFH+/9o1z7VaEfESzUcpR4sdUK3onwcBhWT0tILGO+d/htFLyg2Hma/8K5v qMtIs8HG486I0A= DKIM-Signature: v=1; a=rsa-sha1; c=simple; d=sinervo.fi; h=message-id :subject:from:to:date:content-type:content-transfer-encoding :mime-version; s=private; bh=VtzoaNmDUzGQdC9MNNtC/nkdswI=; b=f+z K/KhhrepFTG5/7ZlEmWyzR+QQepOnjdx3E1wMx7H+pGNSlh24DXcVufGLrQNFtc2 Kj8NZJ8dc1wH2hkCsNvePgS0SrHtl+lk95QByJWhincV2MHDA5YzSo5NXAAIZ32R 0mpegLlr4xq7KgufXSQdjESSowaa6yGATHAJkQOU= Received: (qmail 13183 invoked by uid 89); 2 Jan 2023 11:57:39 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=private; d=sinervo.fi; b=L2zrkh/3O+TAR8+RUwLq1px5sX0R/0EvQ/he1Ykx17PFdt2sp00gIHuE4Pj8u6Bs1drowwiD5nzSi/jkJiJQFmMf0cIsbOKtZhCgcRJrVCWa8kGp0Vn+rWT+MT1Vm5mnXHRpaBUV1lJLTnmUlSwLfCPTeIfEkJX/1QGcPHhi8+Q=; Received: by simscan 1.4.0 ppid: 13166, pid: 13180, t: 0.0598s scanners: attach: 1.4.0 Received: from unknown (HELO ?192.168.32.147?) (jani@sinervo.fi@93.106.137.199) by mail2 with ESMTPA; 2 Jan 2023 11:57:39 -0000 Message-ID: Subject: 28.2; tramp: Remote host name not always accounted when computing multi-hops From: Jani Juhani Sinervo To: bug-gnu-emacs@gnu.org Date: Mon, 02 Jan 2023 13:57:29 +0200 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.2 (by Flathub.org) MIME-Version: 1.0 Received-SPF: pass client-ip=212.146.44.12; envelope-from=jani@sinervo.fi; helo=mail2.aboa.net X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Mon, 02 Jan 2023 13:23:05 -0500 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 (--) When using a custom TRAMP method with a program that expects the host name to be passed in as an argument to a command-line switch, the natural way of writing the `tramp-login-args' like (("--switch" "%h")) does not work, since `tramp-compute-multi-hops' only considers the host name to have been used within the command template, if it is in its own list, as in (("--switch") ("%h")). This is a problem, because there are tools, like Toolbox[0], which allow running the command within a specific container. For example with Toolbox, it would look something like the following: `toolbox run -c container-name-here command' This can be turned into a TRAMP method relatively easily, and the most natural way to write the `tramp-login-args' would be the following: (tramp-login-args (("run") ("-c" "%h") ("sh"))) This however will not work for the aforementioned bug in `tramp-compute-multi-hops'. While splitting the "-c" and "%h" into their own lists works, and would work for the usecase of `C-x C-f /toolbox:container-name-here:', there is a reasonable interpretation for `C-x C-f /toolbox::', entering the default container, in which case splitting the optional "-c"-flag from the "host name" would not be the valid thing to do. [0]: https://containertoolbx.org/ Steps to reproduce from `emacs -Q': 1. Evaluate the following Lisp in the scratch buffer: (require 'tramp) (add-to-list 'tramp-methods =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (c= ons "ssh4" =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '((tramp-login-program "ssh") =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (tramp-login-args (("-l" "%u"= ) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C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C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ("-c"))))) 2. Try to connect somewhere with this method, for example by doing: `C-x C-f /ssh4:example.org: TAB' Expected behavior: TRAMP should try to connect to the host according to the method definition. Actual behavior: TRAMP gives the error message: Host name =E2=80=98example.org=E2=80=99 does not match =E2=80=98\`\(127\.0\.0\.1\|::1\|hostname\|localhost6?\)\'=E2=80=99 The code responsible can be found in `lisp/net/tramp.el' and within the function `tramp-compute-multi-hops'. Excerpt: ;; Some methods ("su", "sg", "sudo", "doas", "ksu") do not use the ;; host name in their command template.=C2=A0 In this case, the remote ;; file name must use either a local host name (first hop), or a ;; host name matching the previous hop. (let ((previous-host (or tramp-local-host-regexp ""))) =C2=A0 (setq choices target-alist) =C2=A0 (while (setq item (pop choices)) =C2=A0=C2=A0=C2=A0 (let ((host (tramp-file-name-host item))) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (unless =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (or =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; The host na= me is used for the remote shell command. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (member =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 '("%h") = (tramp-get-method-parameter item 'tramp-login- args)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ;; The host na= me must match previous hop. =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (string-match-= p previous-host host)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq tramp-default-proxies-alis= t saved-tdpa) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (tramp-user-error =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 vec "Host name `%s' does n= ot match `%s'" host previous-host)) =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (setq previous-host (concat "^" (regexp-quot= e host) "$"))))) We notice that the culprit here is the call to `member', where it erroneously checks for the host name being used by the command template by only checking whether the literal list '("%h") is within the `tramp-login-args'. My proposed fix would be the go through the `tramp-login-args' method parameter, and go through each of the list-of-lists to check whether there is a string "%h" there. In GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.35, cairo version 1.16.0) =C2=A0of 2022-12-09 built on cncf-x86-3 Windowing system distributor 'The X.Org Foundation', version 11.0.12201007 System Description: Freedesktop.org SDK 22.08 (Flatpak runtime) Configured using: =C2=A0'configure --prefix=3D/app --with-gnutls 'CFLAGS=3D-O2 -g -pipe =C2=A0-Wp,-D_FORTIFY_SOURCE=3D2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions =C2=A0-fstack-protector-strong -grecord-gcc-switches =C2=A0-fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection =C2=A0-fno-omit-frame-pointer ' 'LDFLAGS=3D-L/app/lib -Wl,-z,relro,-z,now =C2=A0-Wl,--as-needed '' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Important settings: =C2=A0 value of $LANG: en_GB.UTF-8 =C2=A0 value of $XMODIFIERS: @im=3Dibus =C2=A0 locale-coding-system: utf-8-unix Major mode: Fundamental Minor modes in effect: =C2=A0 electric-pair-mode: t =C2=A0 icomplete-mode: t =C2=A0 yas-global-mode: t =C2=A0 global-git-commit-mode: t =C2=A0 magit-auto-revert-mode: t =C2=A0 shell-dirtrack-mode: t =C2=A0 global-corfu-mode: t =C2=A0 override-global-mode: t =C2=A0 tooltip-mode: t =C2=A0 global-eldoc-mode: t =C2=A0 show-paren-mode: t =C2=A0 electric-indent-mode: t =C2=A0 mouse-wheel-mode: t =C2=A0 file-name-shadow-mode: t =C2=A0 global-font-lock-mode: t =C2=A0 blink-cursor-mode: t =C2=A0 auto-composition-mode: t =C2=A0 auto-encryption-mode: t =C2=A0 auto-compression-mode: t =C2=A0 buffer-read-only: t =C2=A0 column-number-mode: t =C2=A0 line-number-mode: t =C2=A0 indent-tabs-mode: t =C2=A0 transient-mark-mode: t Load-path shadows: /var/home/jani/.emacs.d/elpa/transient-20221202.1727/transient hides /app/share/emacs/28.2/lisp/transient Features: (shadow sort mail-extr emacsbug sendmail checkdoc lisp-mnt rainbow-delimiters elec-pair cus-edit cus-load wid-edit icomplete geiser slime-tramp docker-tramp tramp-cache tramp tramp-loaddefs trampver tramp-integration files-x tramp-compat parse-time iso8601 ls-lisp slime-asdf grep slime-fancy slime-indentation slime-cl-indent cl-indent slime-trace-dialog slime-fontifying-fu slime-package-fu slime- references slime-compiler-notes-tree advice slime-scratch slime-presentations bridge slime-macrostep macrostep slime-mdot-fu slime-enclosing-context slime-fuzzy slime-fancy-trace slime-fancy-inspector slime-c-p-c slime-editing-commands slime-autodoc slime-repl slime-parse slime arc-mode archive-mode pp hyperspec ibuffer ibuffer-loaddefs elixir-mode elixir-format elixir-smie pass f f-shortdoc shortdoc s password-store auth-source-pass adoc-mode tempo markup-faces markdown-mode edit-indirect color haskell-mode haskell-cabal haskell-utils haskell-font-lock haskell-indentation haskell-string haskell-sort-imports haskell-lexeme haskell-align-imports haskell-complete-module haskell-ghc-support noutline outline etags fileloop generator xref dabbrev haskell-customize typescript-mode cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs irony irony-iotask meson-mode smie tango-theme yasnippet magit-submodule magit-obsolete magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit- status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode diff diff-mode git-commit rx log-edit message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util rmail rmail-loaddefs time-date mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log magit-core magit-autorevert autorevert filenotify magit-margin magit-transient magit-process with-editor shell pcomplete server magit-mode transient edmacro kmacro magit-git magit-base magit-section format-spec crm dash compat-27 compat-26 compat compat-macs flymake- proc flymake project compile text-property-search comint ansi-color ring warnings thingatpt corfu cl-extra help-mode use-package-bind-key bind-key easy-mmode use-package-ensure use-package-core tex-site slime-autoloads info package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x- dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 262115 24837) =C2=A0(symbols 48 27853 4) =C2=A0(strings 32 93904 4769) =C2=A0(string-bytes 1 3030693) =C2=A0(vectors 16 50616) =C2=A0(vector-slots 8 589420 28184) =C2=A0(floats 8 264 120) =C2=A0(intervals 56 490 79) =C2=A0(buffers 992 13)) From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 04 12:26:49 2023 Received: (at 60499) by debbugs.gnu.org; 4 Jan 2023 17:26:49 +0000 Received: from localhost ([127.0.0.1]:49494 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pD7XN-00029C-58 for submit@debbugs.gnu.org; Wed, 04 Jan 2023 12:26:49 -0500 Received: from mout.gmx.net ([212.227.15.18]:45825) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pD7XL-00028m-Ek for 60499@debbugs.gnu.org; Wed, 04 Jan 2023 12:26:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1672853186; bh=z97wM2Ik+/v0fk1Q28ARZmWUGnZZtbqH/8usLqIXz2Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=YUFYhv/xfErSYfiFET7Uf+Fu4lula0l+n56QtazHZuDd9ehHJYvQp+2jKONlVwdky M0zgusz0dfK9WcAGqO9cjQ5+81gIlJTsgQJxd4Y532C2vKJaoMD0coRmaJx8YW1Loc I58rHj/FSFRYzz/G0ttvlOg/0LFLfb1YkZcA0Ide5yF6an1WzH9HXE1BrZkHlpdKAo sTIGAYs4md5CPirAh3HGdmUUoPPD8kG1QyC7TwdC+ZrGvwi62UCjioeRT8f72cJDya zrtOioaEYH7OqgZAcgBwhG9Ny3couVfjaD1hxWSi8jR/KFbutlvIWuGjwQPv/1JoQm CfWnKbL/xyUFg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.45]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1My32L-1osPgz0rrr-00zUJC; Wed, 04 Jan 2023 18:26:26 +0100 From: Michael Albinus To: Jani Juhani Sinervo Subject: Re: bug#60499: 28.2; tramp: Remote host name not always accounted when computing multi-hops In-Reply-To: (Jani Juhani Sinervo's message of "Mon, 02 Jan 2023 13:57:29 +0200") References: Date: Wed, 04 Jan 2023 18:26:25 +0100 Message-ID: <874jt6nrcu.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Provags-ID: V03:K1:T+GIxmQHMhVahQThqgvDp7+ipFC7OvzFAqRKeZVU8c+wDzisfCH irEnGwQjlNgFVAJ0W2DJB2V4V5We/KOsOX8zc4G+BgA44M42AiK/XH+/ZHYAHLY2t/C0TOx 5yDteuQlUBsciJELAtVvTOk4eX8yFrB7Jwc2DuPkV9Yi196I6SdKB+hWoKEAwL8XQGygg9P Z/QRSZO512N8ZJH9JJ6ow== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:GJE2oaBRhdE=;5sPKAH50t+PD6R+icHAzo2DZEgx uz3oAvn/SbuU2D9pNTjvr9xw893DA8k6+l4gFhe4lJzOR6vZw2pKQ5cT5F8XAEJiEqxhFhQF7 bEpdsES9mGltson6KBIB1oVfgY/arKCAfJJL68UgIVxcHpsyE17IoD9lwRVY/stAYkaXSVSfM HosRU3V0Osb4P8OC7BPwRukTY42kd/hGYXW8Opne0p3tJmbkB1qetUI1xoJWHkeWDpBWnXGSY rykK6EGkwmSsuluHEZA6WOwyVOsdr6fLLolhBn2QJM9U0JWN7Iq/lOr11H32hlkdX+FBIS80c YwupbaRL9/9c45XMXbwZwr+1fcr8P7KGP0gIyvqKwyyqAVu9DrRcKrgVyLaI2+dB9OIUYQGrj Wr96wp1HukLOtVORs2mFPnERFiANPVoCoqnjIvaWzO2LUo/LyULH3235Xgw27qypc17SrTHxJ Rtweom0sAPRCd0Xl3F5GcsWLBMZuZm4VA6PAKQGsDu6zD1fBiPYm7zCtWLeHeww5OebXg5ch6 Fj5USEYUYaNIvquIDxbR2+Q2l//N/523zZBcMA6dywg0hjljqy798JA9qtYPwR/qm898sFQM9 rq4dwwoRCWR1DvjJbmg77DxulONWn69VsEqcBYyFLgeTyUD6GvW5xzHE8iPrT6N8fMpxTjh6i 97Cl5HRygAqR5+b0dzdZCLY5ph1zi3d+Y/2lZJ1pgp46Rii2qrIYvdU69REvAMzZUxAsLBGBA eFZOXn7WtMheaRnf41c29lFK48BD0DqKc3QgbSnemACs/iOTXADgUS6/imunA4RH9siOAbeK3 lbXa1pEzBhrZrGDV9CwifaaZe5q2mq4DW+Vfs238o5j27IkBsK/bJBahgW4nA9UzdZllKF1aF EHq3VDcsPP4AtVHCbYqaqK4LR7D3B3oGYoBbMDpAQMp1KH/4IrtaM34VakYZSRBXxw229Oa0c mULi5E4sY4Y7WGI30J0D1CNy4lM= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60499 Cc: 60499@debbugs.gnu.org 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.7 (-) --=-=-= Content-Type: text/plain Jani Juhani Sinervo writes: Hi Jani, > When using a custom TRAMP method with a program that expects the host > name to be passed in as an argument to a command-line switch, the > natural way of writing the `tramp-login-args' like (("--switch" "%h")) > does not work, since `tramp-compute-multi-hops' only considers the host > name to have been used within the command template, if it is in its own > list, as in (("--switch") ("%h")). > > This is a problem, because there are tools, like Toolbox[0], which > allow running the command within a specific container. For example with > Toolbox, it would look something like the following: > > `toolbox run -c container-name-here command' > > This can be turned into a TRAMP method relatively easily, and the most > natural way to write the `tramp-login-args' would be the following: > > (tramp-login-args (("run") ("-c" "%h") ("sh"))) Thanks for the bug report. > The code responsible can be found in `lisp/net/tramp.el' and within the > function `tramp-compute-multi-hops'. Excerpt: > > We notice that the culprit here is the call to `member', where it > erroneously checks for the host name being used by the command template > by only checking whether the literal list '("%h") is within the > `tramp-login-args'. > > My proposed fix would be the go through the `tramp-login-args' method > parameter, and go through each of the list-of-lists to check whether > there is a string "%h" there. I've pushed a slightly simpler fix to the emacs-29 branch, see appended. It will appear with the upcoming Emacs 29.1. Until it is released, you could also try to apply it in Emacs 28.2 (I didn't check myself). Or you wait for the next GNU ELPA release of Tramp, 2.6.0.1, which will appear later this month. Btw, the idea with toolbox looks good. I'll see whether I could add it to Tramp 2.7, living in the Emacs master branch. However, I'd prefer to say (tramp-login-args (("enter") ("-c" "%h"))) Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 61a606c3383..f0b17ef3934 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -4694,7 +4694,8 @@ tramp-compute-multi-hops (or ;; The host name is used for the remote shell command. (member - '("%h") (tramp-get-method-parameter item 'tramp-login-args)) + "%h" (tramp-compat-flatten-tree + (tramp-get-method-parameter item 'tramp-login-args))) ;; The host name must match previous hop. (string-match-p previous-host host)) (setq tramp-default-proxies-alist saved-tdpa) --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 08 13:27:53 2023 Received: (at 60499-done) by debbugs.gnu.org; 8 Jan 2023 18:27:53 +0000 Received: from localhost ([127.0.0.1]:34625 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEaOe-0008It-Rs for submit@debbugs.gnu.org; Sun, 08 Jan 2023 13:27:53 -0500 Received: from mout.gmx.net ([212.227.17.20]:46349) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pEaOc-0008Ib-Tl for 60499-done@debbugs.gnu.org; Sun, 08 Jan 2023 13:27:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1673202449; bh=VZKAHUKriamM5kKK9ZCAT07NTdcObGwoQYeVVS4gpJ8=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date; b=RCnlCPDGjoUEZxNNSDvsTUTaKMnNqQpnF2YPBQ4sWDqfdwyR3fJTp5AZSMGNQNzCl yTIloTN1CxA6/27dsqasVh0P37uXdG7Bt+ujRFRhvNwhN/B+Hl7k5Wi0U76ELpqty6 x3F24WE8gcCtRSTzn24vHy8xJslu7DzETZ5Q9fAYAJspxTA/EKi18wD+TsbpFycgxI B6P1ji/x57XYUMMrJSncFowrKAsLocdzryuBrhHk/BlJ64brIc8/bWgZhes0flkLG7 7txcvneRPgZDzfFPXY1GbEOW0HiEHJ9ppyrjArLh0yZvK4O/Iwyd+8EzL6oM69HiYv 5eev+UMqD3pAQ== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from gandalf.gmx.de ([185.89.37.45]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mz9Ux-1orz1u1LMp-00wCzI; Sun, 08 Jan 2023 19:27:29 +0100 From: Michael Albinus To: Jani Juhani Sinervo Subject: Re: bug#60499: 28.2; tramp: Remote host name not always accounted when computing multi-hops In-Reply-To: <874jt6nrcu.fsf@gmx.de> (Michael Albinus's message of "Wed, 04 Jan 2023 18:26:25 +0100") References: <874jt6nrcu.fsf@gmx.de> Date: Sun, 08 Jan 2023 19:27:28 +0100 Message-ID: <87fsck286n.fsf@gmx.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:/pwT1vC8XPS11DXwiPUWktJziGGTn7/37Vq5aODZk4+/+/z/aP7 5xLj8H9QmuQbB5j/Gh5OtIFVv1j+6gteNYnrZo3dxJRAz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mL ZyL4IMFX+t/aB2rzZ+rhxSdTP4ocRoQFciJa/1PDClQecIKppTAarCp7JFj62H3sor1smIYCN yacvMTypPrDfnUz9apqx8c6bv9Y= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 60499-done Cc: 60499-done@debbugs.gnu.org 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.7 (-) Version: 29.1 Michael Albinus writes: Hi Jani, > Btw, the idea with toolbox looks good. I'll see whether I could add it > to Tramp 2.7, living in the Emacs master branch. I've added this to Emacs master (Tramp 2.7). > However, I'd prefer to say > > (tramp-login-args (("enter") ("-c" "%h"))) This didn't work, so I'm using "toolbox run ..." as proposed. Since there's nothing left to do, I'm closing the bug. Best regards, Michael. From unknown Fri Aug 15 18:50:02 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 06 Feb 2023 12:24:16 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator