diff options
| author | Michael Albinus | 2024-05-12 19:40:08 +0200 |
|---|---|---|
| committer | Michael Albinus | 2024-05-12 19:40:08 +0200 |
| commit | e53e8b4cf44be0fac0eb92c816b2c7915533e283 (patch) | |
| tree | 5fbb35a339461b7e2ff5be2628368c61f7a776fc | |
| parent | 2c759b9ce620311df97f43b791ba27b1302171c4 (diff) | |
| download | emacs-e53e8b4cf44be0fac0eb92c816b2c7915533e283.tar.gz emacs-e53e8b4cf44be0fac0eb92c816b2c7915533e283.zip | |
Add Tramp method "nspawn"
* doc/misc/tramp.texi: Adapt some markups.
(Inline methods) <nspawn>: Add.
(Default Host): Mention default host for "nspawn".
(Customizing Methods): Remove tramp-nspawn.
(Password handling): Add "nspawn".
* etc/NEWS: New Tramp method "nspawn".
* lisp/net/tramp-compat.el (tramp-nspawn): Warn, if that package is used.
* lisp/net/tramp-container.el (tramp-nspawn-program): New defcustom.
(tramp-nspawn-method): New defconst.
(tramp-nspawn--completion-function, tramp-enable-nspawn-method):
New defuns.
* lisp/net/tramp.el (tramp-local-host-regexp): Add OpenSUSE host names.
| -rw-r--r-- | doc/misc/tramp.texi | 95 | ||||
| -rw-r--r-- | etc/NEWS | 8 | ||||
| -rw-r--r-- | lisp/net/tramp-compat.el | 3 | ||||
| -rw-r--r-- | lisp/net/tramp-container.el | 64 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 6 |
5 files changed, 124 insertions, 52 deletions
diff --git a/doc/misc/tramp.texi b/doc/misc/tramp.texi index 6c36429fb79..e5e2f3b243f 100644 --- a/doc/misc/tramp.texi +++ b/doc/misc/tramp.texi | |||
| @@ -973,7 +973,12 @@ supports changing the remote login shell @command{/bin/sh}. | |||
| 973 | 973 | ||
| 974 | Check the @samp{Share SSH connections if possible} control for that | 974 | Check the @samp{Share SSH connections if possible} control for that |
| 975 | session. | 975 | session. |
| 976 | @end table | ||
| 977 | |||
| 978 | @noindent | ||
| 979 | The following methods allow to access containers in different ways: | ||
| 976 | 980 | ||
| 981 | @table @asis | ||
| 977 | @item @option{docker} | 982 | @item @option{docker} |
| 978 | @cindex method @option{docker} | 983 | @cindex method @option{docker} |
| 979 | @cindex @option{docker} method | 984 | @cindex @option{docker} method |
| @@ -1032,6 +1037,14 @@ name, as returned by @samp{apptainer instance list}. | |||
| 1032 | This is an optional method, @ref{Optional methods}. It does not | 1037 | This is an optional method, @ref{Optional methods}. It does not |
| 1033 | support user names. | 1038 | support user names. |
| 1034 | 1039 | ||
| 1040 | @item @option{nspawn} | ||
| 1041 | @cindex method @option{nspawn} | ||
| 1042 | @cindex @option{nspawn} method | ||
| 1043 | |||
| 1044 | Integration of @code{systemd-nspawn} instances. The host name is the | ||
| 1045 | instance name, as returned by @samp{machinectl list --all}. | ||
| 1046 | |||
| 1047 | This is an optional method, @ref{Optional methods}. | ||
| 1035 | @end table | 1048 | @end table |
| 1036 | 1049 | ||
| 1037 | 1050 | ||
| @@ -1256,9 +1269,9 @@ domain name). An example: | |||
| 1256 | @trampfn{smb,daniel%BIZARRE@@melancholia,/daniel$$/.emacs} | 1269 | @trampfn{smb,daniel%BIZARRE@@melancholia,/daniel$$/.emacs} |
| 1257 | @end example | 1270 | @end example |
| 1258 | 1271 | ||
| 1259 | where user @code{daniel} connects as a domain user to the SMB host | 1272 | where user @samp{daniel} connects as a domain user to the SMB host |
| 1260 | @code{melancholia} in the MS Windows domain @code{BIZARRE} to edit | 1273 | @samp{melancholia} in the MS Windows domain @samp{BIZARRE} to edit |
| 1261 | @file{.emacs} located in the home directory (share @code{daniel$}). | 1274 | @file{.emacs} located in the home directory (share @samp{daniel$}). |
| 1262 | 1275 | ||
| 1263 | Alternatively, for local WINS users (as opposed to domain users), | 1276 | Alternatively, for local WINS users (as opposed to domain users), |
| 1264 | substitute the domain name with the name of the local host in | 1277 | substitute the domain name with the name of the local host in |
| @@ -1268,9 +1281,9 @@ UPPERCASE as shown here: | |||
| 1268 | @trampfn{smb,daniel%MELANCHOLIA@@melancholia,/daniel$$/.emacs} | 1281 | @trampfn{smb,daniel%MELANCHOLIA@@melancholia,/daniel$$/.emacs} |
| 1269 | @end example | 1282 | @end example |
| 1270 | 1283 | ||
| 1271 | where user @code{daniel} connects as local user to the SMB host | 1284 | where user @samp{daniel} connects as local user to the SMB host |
| 1272 | @code{melancholia} in the local domain @code{MELANCHOLIA} to edit | 1285 | @samp{melancholia} in the local domain @samp{MELANCHOLIA} to edit |
| 1273 | @file{.emacs} located in the home directory (share @code{daniel$}). | 1286 | @file{.emacs} located in the home directory (share @samp{daniel$}). |
| 1274 | 1287 | ||
| 1275 | The domain name and user name are optional for @command{smbclient} | 1288 | The domain name and user name are optional for @command{smbclient} |
| 1276 | authentication. When user name is not specified, @command{smbclient} | 1289 | authentication. When user name is not specified, @command{smbclient} |
| @@ -1702,8 +1715,8 @@ follows: | |||
| 1702 | @end group | 1715 | @end group |
| 1703 | @end lisp | 1716 | @end lisp |
| 1704 | 1717 | ||
| 1705 | With all defaults set, @samp{@trampfn{-,,}} will connect @value{tramp} | 1718 | With all defaults set, @file{@trampfn{-,,}} will connect @value{tramp} |
| 1706 | to John's home directory on @code{target} via @code{ssh}. | 1719 | to John's home directory on @samp{target} via method @option{ssh}. |
| 1707 | @end defopt | 1720 | @end defopt |
| 1708 | 1721 | ||
| 1709 | @defopt tramp-default-host-alist | 1722 | @defopt tramp-default-host-alist |
| @@ -1712,6 +1725,10 @@ allows multiple default host values based on access method or user | |||
| 1712 | name combinations. The alist can hold multiple values. While | 1725 | name combinations. The alist can hold multiple values. While |
| 1713 | @code{tramp-default-host} is sufficient in most cases, some methods, | 1726 | @code{tramp-default-host} is sufficient in most cases, some methods, |
| 1714 | like @option{adb}, require defaults overwritten. | 1727 | like @option{adb}, require defaults overwritten. |
| 1728 | |||
| 1729 | The default host name for @option{nspawn} is @samp{.host}. Therefore, | ||
| 1730 | @file{@trampfn{nspawn,,}} and @file{@trampfn{sudo,,}} have the same | ||
| 1731 | effect. | ||
| 1715 | @end defopt | 1732 | @end defopt |
| 1716 | 1733 | ||
| 1717 | 1734 | ||
| @@ -1938,17 +1955,6 @@ Access of a hadoop/hdfs file system. A file is accessed via | |||
| 1938 | the user that you want to use, and @samp{node} is the name of the | 1955 | the user that you want to use, and @samp{node} is the name of the |
| 1939 | hadoop server. | 1956 | hadoop server. |
| 1940 | 1957 | ||
| 1941 | @item tramp-nspawn | ||
| 1942 | @cindex method @option{nspawn} | ||
| 1943 | @cindex @option{nspawn} method | ||
| 1944 | Access to environments provided by systemd-nspawn. A file is accessed | ||
| 1945 | via @file{@trampfn{nspawn,user@@container,/path/to/file}}, where | ||
| 1946 | @samp{user} is the (optional) user that you want to use, and | ||
| 1947 | @samp{container} is the container to connect to. systemd-nspawn and | ||
| 1948 | its container utilities often require super user access to run, use | ||
| 1949 | multi-hop file names with @option{doas} or @option{sudo} to raise your | ||
| 1950 | privileges. | ||
| 1951 | |||
| 1952 | @item vagrant-tramp | 1958 | @item vagrant-tramp |
| 1953 | @cindex method @option{vagrant} | 1959 | @cindex method @option{vagrant} |
| 1954 | @cindex @option{vagrant} method | 1960 | @cindex @option{vagrant} method |
| @@ -2118,11 +2124,12 @@ file name syntax, must be appended to the machine and login items: | |||
| 2118 | machine melancholia#4711 port davs login daniel%BIZARRE password geheim | 2124 | machine melancholia#4711 port davs login daniel%BIZARRE password geheim |
| 2119 | @end example | 2125 | @end example |
| 2120 | 2126 | ||
| 2121 | For the methods @option{doas}, @option{sudo} and @option{sudoedit} the | 2127 | For the methods @option{doas}, @option{sudo}, @option{sudoedit} and |
| 2122 | password of the user requesting the connection is needed, and not the | 2128 | @option{nspawn} the password of the user requesting the connection is |
| 2123 | password of the target user@footnote{On the local host, @code{run0} | 2129 | needed, and not the password of the target user@footnote{On the local |
| 2124 | uses a graphical password agent.}. If these connections happen on the | 2130 | host, @code{run0} uses a graphical password agent.}. If these |
| 2125 | local host, an entry with the local user and local host is used: | 2131 | connections happen on the local host, an entry with the local user and |
| 2132 | local host is used: | ||
| 2126 | 2133 | ||
| 2127 | @example | 2134 | @example |
| 2128 | machine @var{host} port sudo login @var{user} password secret | 2135 | machine @var{host} port sudo login @var{user} password secret |
| @@ -2701,8 +2708,8 @@ its execution of @command{/bin/sh} on the remote host because Bourne | |||
| 2701 | shell does not recognize the export command as entered in | 2708 | shell does not recognize the export command as entered in |
| 2702 | @file{.profile}. | 2709 | @file{.profile}. |
| 2703 | 2710 | ||
| 2704 | Likewise, (@code{~}) character in paths will cause errors because | 2711 | Likewise, (@samp{~}) character in paths will cause errors because |
| 2705 | Bourne shell does not do (@code{~}) character expansions. | 2712 | Bourne shell does not do (@samp{~}) character expansions. |
| 2706 | 2713 | ||
| 2707 | One approach to avoiding these incompatibilities is to make all | 2714 | One approach to avoiding these incompatibilities is to make all |
| 2708 | commands in @file{~/.shrc} and @file{~/.profile} Bourne shell | 2715 | commands in @file{~/.shrc} and @file{~/.profile} Bourne shell |
| @@ -3417,7 +3424,7 @@ configuration option will be selected, it can be @t{"--standard"} | |||
| 3417 | or @t{"--paranoia"}. See the @samp{encfs(1)} man page for details. | 3424 | or @t{"--paranoia"}. See the @samp{encfs(1)} man page for details. |
| 3418 | 3425 | ||
| 3419 | However, @value{tramp} must adapt these configuration sets. The | 3426 | However, @value{tramp} must adapt these configuration sets. The |
| 3420 | @code{chainedNameIV} configuration option must be disabled; otherwise | 3427 | @option{chainedNameIV} configuration option must be disabled; otherwise |
| 3421 | @value{tramp} couldn't handle file name encryption transparently. | 3428 | @value{tramp} couldn't handle file name encryption transparently. |
| 3422 | @end defopt | 3429 | @end defopt |
| 3423 | 3430 | ||
| @@ -3536,7 +3543,7 @@ on the remote host @var{host}, using the method @var{method}. | |||
| 3536 | @table @file | 3543 | @table @file |
| 3537 | @item @value{prefix}ssh@value{postfixhop}melancholia@value{postfix}.emacs | 3544 | @item @value{prefix}ssh@value{postfixhop}melancholia@value{postfix}.emacs |
| 3538 | For the file @file{.emacs} located in the home directory, on the host | 3545 | For the file @file{.emacs} located in the home directory, on the host |
| 3539 | @code{melancholia}, using method @code{ssh}. | 3546 | @samp{melancholia}, using method @option{ssh}. |
| 3540 | 3547 | ||
| 3541 | @item @value{prefix}ssh@value{postfixhop}melancholia.danann.net@value{postfix}.emacs | 3548 | @item @value{prefix}ssh@value{postfixhop}melancholia.danann.net@value{postfix}.emacs |
| 3542 | For the file @file{.emacs} specified using the fully qualified domain name of | 3549 | For the file @file{.emacs} specified using the fully qualified domain name of |
| @@ -3546,12 +3553,12 @@ the host. | |||
| 3546 | For the file @file{.emacs} specified using the @file{~}, which is expanded. | 3553 | For the file @file{.emacs} specified using the @file{~}, which is expanded. |
| 3547 | 3554 | ||
| 3548 | @item @value{prefix}ssh@value{postfixhop}melancholia@value{postfix}~daniel/.emacs | 3555 | @item @value{prefix}ssh@value{postfixhop}melancholia@value{postfix}~daniel/.emacs |
| 3549 | For the file @file{.emacs} located in @code{daniel}'s home directory | 3556 | For the file @file{.emacs} located in @samp{daniel}'s home directory |
| 3550 | on the host, @code{melancholia}. The @file{~<user>} construct is | 3557 | on the host, @samp{melancholia}. The @file{~<user>} construct is |
| 3551 | expanded to the home directory of that user on the remote host. | 3558 | expanded to the home directory of that user on the remote host. |
| 3552 | 3559 | ||
| 3553 | @item @value{prefix}ssh@value{postfixhop}melancholia@value{postfix}/etc/squid.conf | 3560 | @item @value{prefix}ssh@value{postfixhop}melancholia@value{postfix}/etc/squid.conf |
| 3554 | For the file @file{/etc/squid.conf} on the host @code{melancholia}. | 3561 | For the file @file{/etc/squid.conf} on the host @samp{melancholia}. |
| 3555 | 3562 | ||
| 3556 | @end table | 3563 | @end table |
| 3557 | 3564 | ||
| @@ -3569,8 +3576,8 @@ different name using the proper syntax will override this default | |||
| 3569 | behavior: @file{@trampfn{method,user@@host,path/to/file}}. | 3576 | behavior: @file{@trampfn{method,user@@host,path/to/file}}. |
| 3570 | 3577 | ||
| 3571 | @file{@trampfn{ssh,daniel@@melancholia,.emacs}} is for file | 3578 | @file{@trampfn{ssh,daniel@@melancholia,.emacs}} is for file |
| 3572 | @file{.emacs} in @code{daniel}'s home directory on the host, | 3579 | @file{.emacs} in @samp{daniel}'s home directory on the host, |
| 3573 | @code{melancholia}, accessing via method @code{ssh}. | 3580 | @samp{melancholia}, accessing via method @option{ssh}. |
| 3574 | 3581 | ||
| 3575 | For specifying port numbers, affix @file{#<port>} to the host | 3582 | For specifying port numbers, affix @file{#<port>} to the host |
| 3576 | name. For example: @file{@trampfn{ssh,daniel@@melancholia#42,.emacs}}. | 3583 | name. For example: @file{@trampfn{ssh,daniel@@melancholia#42,.emacs}}. |
| @@ -3603,8 +3610,8 @@ names. Beside the @code{default} value, @var{syntax} can be | |||
| 3603 | 3610 | ||
| 3604 | This remote file name syntax is similar to the syntax used by Ange FTP@. | 3611 | This remote file name syntax is similar to the syntax used by Ange FTP@. |
| 3605 | A remote file name has the form | 3612 | A remote file name has the form |
| 3606 | @code{@value{prefix}user@@host@value{postfix}path/to/file}. The | 3613 | @file{@value{prefix}user@@host@value{postfix}path/to/file}. The |
| 3607 | @code{user@@} part is optional, and the method is determined by | 3614 | @samp{user@@} part is optional, and the method is determined by |
| 3608 | @ref{Default Method}. | 3615 | @ref{Default Method}. |
| 3609 | 3616 | ||
| 3610 | @item @code{separate} | 3617 | @item @code{separate} |
| @@ -3615,8 +3622,8 @@ A remote file name has the form | |||
| 3615 | @include trampver.texi | 3622 | @include trampver.texi |
| 3616 | This remote file name syntax originated in the XEmacs text editor. | 3623 | This remote file name syntax originated in the XEmacs text editor. |
| 3617 | A remote file name has the form | 3624 | A remote file name has the form |
| 3618 | @code{@trampfn{method,user@@host,path/to/file}}. The @code{method} | 3625 | @file{@trampfn{method,user@@host,path/to/file}}. The @samp{method} |
| 3619 | and @code{user@@} parts are optional. | 3626 | and @samp{user@@} parts are optional. |
| 3620 | @clear separate | 3627 | @clear separate |
| 3621 | @set unified | 3628 | @set unified |
| 3622 | @include trampver.texi | 3629 | @include trampver.texi |
| @@ -3799,12 +3806,12 @@ Ad-hoc proxies can take patterns @code{%h} or @code{%u} like in | |||
| 3799 | @code{tramp-default-proxies-alist}. The following file name expands | 3806 | @code{tramp-default-proxies-alist}. The following file name expands |
| 3800 | to user @samp{root} on host @samp{remotehost}, starting with an | 3807 | to user @samp{root} on host @samp{remotehost}, starting with an |
| 3801 | @option{ssh} session on host @samp{remotehost}: | 3808 | @option{ssh} session on host @samp{remotehost}: |
| 3802 | @samp{@trampfn{ssh@value{postfixhop}%h|su,remotehost,}}. | 3809 | @file{@trampfn{ssh@value{postfixhop}%h|su,remotehost,}}. |
| 3803 | 3810 | ||
| 3804 | On the other hand, if a trailing hop does not specify a host name, the | 3811 | On the other hand, if a trailing hop does not specify a host name, the |
| 3805 | host name of the previous hop is reused. Therefore, the following | 3812 | host name of the previous hop is reused. Therefore, the following |
| 3806 | file name is equivalent to the previous example: | 3813 | file name is equivalent to the previous example: |
| 3807 | @samp{@trampfn{ssh@value{postfixhop}remotehost|su,,}}. | 3814 | @file{@trampfn{ssh@value{postfixhop}remotehost|su,,}}. |
| 3808 | 3815 | ||
| 3809 | @defopt tramp-completion-multi-hop-methods | 3816 | @defopt tramp-completion-multi-hop-methods |
| 3810 | When this list includes the last method in a multi-hop connection, the | 3817 | When this list includes the last method in a multi-hop connection, the |
| @@ -3831,8 +3838,8 @@ The buffer must either visit a file, or a directory | |||
| 3831 | 3838 | ||
| 3832 | @defopt tramp-file-name-with-method | 3839 | @defopt tramp-file-name-with-method |
| 3833 | The method @code{tramp-revert-buffer-with-sudo} shows an alternate | 3840 | The method @code{tramp-revert-buffer-with-sudo} shows an alternate |
| 3834 | buffer. It defaults to @code{sudo}, other valid methods are | 3841 | buffer. It defaults to @option{sudo}, other valid methods are |
| 3835 | @code{su}, @code{doas}, @code{run0}, and @code{ksu}. | 3842 | @option{su}, @option{doas}, @option{run0}, and @option{ksu}. |
| 3836 | 3843 | ||
| 3837 | @lisp | 3844 | @lisp |
| 3838 | (customize-set-variable 'tramp-file-name-with-method "doas") | 3845 | (customize-set-variable 'tramp-file-name-with-method "doas") |
| @@ -4066,7 +4073,7 @@ follows in the local @file{.emacs} file: | |||
| 4066 | local host that the remote host can redirect X11 window | 4073 | local host that the remote host can redirect X11 window |
| 4067 | interactions. If querying for a recognizable name is not possible for | 4074 | interactions. If querying for a recognizable name is not possible for |
| 4068 | whatever reason, then replace @code{(getenv "DISPLAY")} with a | 4075 | whatever reason, then replace @code{(getenv "DISPLAY")} with a |
| 4069 | hard-coded, fixed name. Note that using @code{:0} for X11 display name | 4076 | hard-coded, fixed name. Note that using @samp{:0} for X11 display name |
| 4070 | here will not work as expected. | 4077 | here will not work as expected. |
| 4071 | 4078 | ||
| 4072 | @vindex ForwardX11@r{, ssh option} | 4079 | @vindex ForwardX11@r{, ssh option} |
| @@ -4638,7 +4645,7 @@ specifies the target to be applied for renaming buffer file names from | |||
| 4638 | source via @code{tramp-rename-files}. @code{source} is a regular | 4645 | source via @code{tramp-rename-files}. @code{source} is a regular |
| 4639 | expressions, which matches a remote file name. @code{target} must be | 4646 | expressions, which matches a remote file name. @code{target} must be |
| 4640 | a directory name, which could be remote (including remote directories | 4647 | a directory name, which could be remote (including remote directories |
| 4641 | @value{tramp} infers by default, such as @samp{@trampfn{method,user@@host,}}). | 4648 | @value{tramp} infers by default, such as @file{@trampfn{method,user@@host,}}). |
| 4642 | 4649 | ||
| 4643 | @code{target} can contain the patterns @code{%m}, @code{%u} or | 4650 | @code{target} can contain the patterns @code{%m}, @code{%u} or |
| 4644 | @code{%h}, which are replaced by the method name, user name or host | 4651 | @code{%h}, which are replaced by the method name, user name or host |
| @@ -4667,7 +4674,7 @@ ssh@value{postfixhop}%h@value{postfix}") | |||
| 4667 | @end lisp | 4674 | @end lisp |
| 4668 | 4675 | ||
| 4669 | routes all connections to a host in @samp{company.org} via | 4676 | routes all connections to a host in @samp{company.org} via |
| 4670 | @samp{@trampfn{ssh,multi.hop,}}, which might be useful when using | 4677 | @file{@trampfn{ssh,multi.hop,}}, which might be useful when using |
| 4671 | Emacs outside the company network. | 4678 | Emacs outside the company network. |
| 4672 | 4679 | ||
| 4673 | @lisp | 4680 | @lisp |
| @@ -1079,9 +1079,11 @@ This connection method is similar to "sudo", but it uses the | |||
| 1079 | These are the external methods counterparts of "docker" and "podman". | 1079 | These are the external methods counterparts of "docker" and "podman". |
| 1080 | 1080 | ||
| 1081 | +++ | 1081 | +++ |
| 1082 | *** New optional connection methods "toolbox", "flatpak" and "apptainer". | 1082 | *** New optional connection methods for containers. |
| 1083 | They allow accessing system containers provided by Toolbox, sandboxes | 1083 | Tere are new optional connection methods "toolbox", "flatpak", |
| 1084 | provided by Flatpak, or instances managed by Apptainer. | 1084 | "apptainer" and "nspawn". They allow accessing system containers |
| 1085 | provided by Toolbox, sandboxes provided by Flatpak, instances managed by | ||
| 1086 | Apptainer, or accessing systemd-based light-weight containers.. | ||
| 1085 | 1087 | ||
| 1086 | +++ | 1088 | +++ |
| 1087 | *** Connection method "kubernetes" supports now optional container name. | 1089 | *** Connection method "kubernetes" supports now optional container name. |
diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index d7492be63f2..26c2049fbae 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el | |||
| @@ -55,6 +55,9 @@ | |||
| 55 | (with-eval-after-load 'kubernetes-tramp | 55 | (with-eval-after-load 'kubernetes-tramp |
| 56 | (warn (concat "Package `kubernetes-tramp' has been obsoleted, " | 56 | (warn (concat "Package `kubernetes-tramp' has been obsoleted, " |
| 57 | "please use integrated package `tramp-container'"))) | 57 | "please use integrated package `tramp-container'"))) |
| 58 | (with-eval-after-load 'tramp-nspawn | ||
| 59 | (warn (concat "Package `tramp-nspawn' has been obsoleted, " | ||
| 60 | "please use integrated package `tramp-container'"))) | ||
| 58 | 61 | ||
| 59 | ;; For not existing functions, obsolete functions, or functions with a | 62 | ;; For not existing functions, obsolete functions, or functions with a |
| 60 | ;; changed argument list, there are compiler warnings. We want to | 63 | ;; changed argument list, there are compiler warnings. We want to |
diff --git a/lisp/net/tramp-container.el b/lisp/net/tramp-container.el index 902fc6a451b..3d15d71d709 100644 --- a/lisp/net/tramp-container.el +++ b/lisp/net/tramp-container.el | |||
| @@ -81,8 +81,8 @@ | |||
| 81 | ;; C-x C-f /flatpak:SANDBOX:/path/to/file | 81 | ;; C-x C-f /flatpak:SANDBOX:/path/to/file |
| 82 | ;; | 82 | ;; |
| 83 | ;; Where: | 83 | ;; Where: |
| 84 | ;; SANDBOX is the running sandbox to connect to. | 84 | ;; SANDBOX is the running sandbox to connect to. |
| 85 | ;; It could be an application ID, an instance ID, or a PID. | 85 | ;; It could be an application ID, an instance ID, or a PID. |
| 86 | ;; | 86 | ;; |
| 87 | ;; | 87 | ;; |
| 88 | ;; | 88 | ;; |
| @@ -91,7 +91,17 @@ | |||
| 91 | ;; C-x C-f /apptainer:INSTANCE:/path/to/file | 91 | ;; C-x C-f /apptainer:INSTANCE:/path/to/file |
| 92 | ;; | 92 | ;; |
| 93 | ;; Where: | 93 | ;; Where: |
| 94 | ;; INSTANCE is the running instance to connect to. | 94 | ;; INSTANCE is the running instance to connect to. |
| 95 | ;; | ||
| 96 | ;; | ||
| 97 | ;; | ||
| 98 | ;; Open a file on a running systemd-nspawn container: | ||
| 99 | ;; | ||
| 100 | ;; C-x C-f /nspawn:USER@CONTAINER:/path/to/file | ||
| 101 | ;; | ||
| 102 | ;; Where: | ||
| 103 | ;; USER is the user on the container to connect as (optional) | ||
| 104 | ;; CONTAINER is the container to connect to | ||
| 95 | 105 | ||
| 96 | ;;; Code: | 106 | ;;; Code: |
| 97 | 107 | ||
| @@ -159,6 +169,13 @@ If it is nil, the default context will be used." | |||
| 159 | :type '(choice (const "apptainer") | 169 | :type '(choice (const "apptainer") |
| 160 | (string))) | 170 | (string))) |
| 161 | 171 | ||
| 172 | (defcustom tramp-nspawn-program "machinectl" | ||
| 173 | "Name of the machinectl program." | ||
| 174 | :group 'tramp | ||
| 175 | :version "30.1" | ||
| 176 | :type '(choice (const "machinectl") | ||
| 177 | (string))) | ||
| 178 | |||
| 162 | ;;;###tramp-autoload | 179 | ;;;###tramp-autoload |
| 163 | (defconst tramp-docker-method "docker" | 180 | (defconst tramp-docker-method "docker" |
| 164 | "Tramp method name to use to connect to Docker containers.") | 181 | "Tramp method name to use to connect to Docker containers.") |
| @@ -194,6 +211,10 @@ This is for out-of-band connections.") | |||
| 194 | "Tramp method name to use to connect to Apptainer instances.") | 211 | "Tramp method name to use to connect to Apptainer instances.") |
| 195 | 212 | ||
| 196 | ;;;###tramp-autoload | 213 | ;;;###tramp-autoload |
| 214 | (defconst tramp-nspawn-method "nspawn" | ||
| 215 | "Tramp method name to use to connect to systemd-nspawn containers.") | ||
| 216 | |||
| 217 | ;;;###tramp-autoload | ||
| 197 | (defmacro tramp-skeleton-completion-function (method &rest body) | 218 | (defmacro tramp-skeleton-completion-function (method &rest body) |
| 198 | "Skeleton for `tramp-*-completion-function' with multi-hop support. | 219 | "Skeleton for `tramp-*-completion-function' with multi-hop support. |
| 199 | BODY is the backend specific code." | 220 | BODY is the backend specific code." |
| @@ -416,6 +437,21 @@ see its function help for a description of the format." | |||
| 416 | lines))) | 437 | lines))) |
| 417 | (mapcar (lambda (name) (list nil name)) names)))) | 438 | (mapcar (lambda (name) (list nil name)) names)))) |
| 418 | 439 | ||
| 440 | (defun tramp-nspawn--completion-function (method) | ||
| 441 | "List systemd-nspawn containers available for connection. | ||
| 442 | |||
| 443 | This function is used by `tramp-set-completion-function', please | ||
| 444 | see its function help for a description of the format." | ||
| 445 | (tramp-skeleton-completion-function method | ||
| 446 | (when-let ((raw-list | ||
| 447 | (shell-command-to-string (concat program " list --all -q"))) | ||
| 448 | ;; Ignore header line. | ||
| 449 | (lines (cdr (split-string raw-list "\n"))) | ||
| 450 | (first-words (mapcar (lambda (line) (car (split-string line))) | ||
| 451 | lines)) | ||
| 452 | (machines (seq-take-while (lambda (name) name) first-words))) | ||
| 453 | (mapcar (lambda (m) (list nil m)) machines)))) | ||
| 454 | |||
| 419 | ;;;###tramp-autoload | 455 | ;;;###tramp-autoload |
| 420 | (defvar tramp-default-remote-shell) ;; Silence byte compiler. | 456 | (defvar tramp-default-remote-shell) ;; Silence byte compiler. |
| 421 | 457 | ||
| @@ -580,6 +616,28 @@ see its function help for a description of the format." | |||
| 580 | tramp-apptainer-method | 616 | tramp-apptainer-method |
| 581 | `((tramp-apptainer--completion-function ,tramp-apptainer-method)))) | 617 | `((tramp-apptainer--completion-function ,tramp-apptainer-method)))) |
| 582 | 618 | ||
| 619 | ;; todo: check tramp-async-args and tramp-direct-async | ||
| 620 | ;;;###tramp-autoload | ||
| 621 | (defun tramp-enable-nspawn-method () | ||
| 622 | "Enable connection to nspawn containers." | ||
| 623 | (add-to-list 'tramp-methods | ||
| 624 | `(,tramp-nspawn-method | ||
| 625 | (tramp-login-program ,tramp-nspawn-program) | ||
| 626 | (tramp-login-args (("shell") | ||
| 627 | ("-q") | ||
| 628 | ("--uid" "%u") | ||
| 629 | ("%h"))) | ||
| 630 | (tramp-remote-shell ,tramp-default-remote-shell) | ||
| 631 | (tramp-remote-shell-login ("-l")) | ||
| 632 | (tramp-remote-shell-args ("-i" "-c")))) | ||
| 633 | |||
| 634 | (add-to-list 'tramp-default-host-alist `(,tramp-nspawn-method nil ".host")) | ||
| 635 | (add-to-list 'tramp-completion-multi-hop-methods tramp-nspawn-method) | ||
| 636 | |||
| 637 | (tramp-set-completion-function | ||
| 638 | tramp-nspawn-method | ||
| 639 | `((tramp-nspawn--completion-function ,tramp-nspawn-method)))) | ||
| 640 | |||
| 583 | ;; Default connection-local variables for Tramp. | 641 | ;; Default connection-local variables for Tramp. |
| 584 | 642 | ||
| 585 | (defconst tramp-kubernetes-connection-local-default-variables | 643 | (defconst tramp-kubernetes-connection-local-default-variables |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 02a493f0a78..5bb1ab66175 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -562,11 +562,13 @@ host runs a restricted shell, it shall be added to this list, too." | |||
| 562 | ;; Fedora. | 562 | ;; Fedora. |
| 563 | "localhost4" "localhost6" | 563 | "localhost4" "localhost6" |
| 564 | ;; Ubuntu. | 564 | ;; Ubuntu. |
| 565 | "ip6-localhost" "ip6-loopback")) | 565 | "ip6-localhost" "ip6-loopback" |
| 566 | ;; OpenSUSE. | ||
| 567 | "ipv6-localhost" "ipv6-loopback")) | ||
| 566 | eos) | 568 | eos) |
| 567 | "Host names which are regarded as local host. | 569 | "Host names which are regarded as local host. |
| 568 | If the local host runs a chrooted environment, set this to nil." | 570 | If the local host runs a chrooted environment, set this to nil." |
| 569 | :version "29.3" | 571 | :version "30.1" |
| 570 | :type '(choice (const :tag "Chrooted environment" nil) | 572 | :type '(choice (const :tag "Chrooted environment" nil) |
| 571 | (regexp :tag "Host regexp"))) | 573 | (regexp :tag "Host regexp"))) |
| 572 | 574 | ||