2018-12-16 14:49:07 +00:00
|
|
|
|
;;; tramp-sudoedit.el --- Functions for accessing under root permissions -*- lexical-binding:t -*-
|
|
|
|
|
|
2022-01-01 07:45:51 +00:00
|
|
|
|
;; Copyright (C) 2018-2022 Free Software Foundation, Inc.
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
;; Author: Michael Albinus <michael.albinus@gmx.de>
|
|
|
|
|
;; Keywords: comm, processes
|
|
|
|
|
;; Package: tramp
|
|
|
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
|
;; it under the terms of the GNU General Public License as published by
|
|
|
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
;; (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful,
|
|
|
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
;; GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
|
|
;; The "sudoedit" Tramp method allows to edit a file as a different
|
|
|
|
|
;; user on the local host. Contrary to the "sudo" method, all magic
|
|
|
|
|
;; file name functions are implemented by single "sudo ..." commands.
|
|
|
|
|
;; The purpose is to make editing such a file as secure as possible;
|
|
|
|
|
;; there must be no session running in the Emacs background which
|
|
|
|
|
;; could be attacked from inside Emacs.
|
|
|
|
|
|
|
|
|
|
;; Consequently, external processes are not implemented.
|
|
|
|
|
|
|
|
|
|
;;; Code:
|
|
|
|
|
|
|
|
|
|
(require 'tramp)
|
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defconst tramp-sudoedit-method "sudoedit"
|
|
|
|
|
"When this method name is used, call sudoedit for editing a file.")
|
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(tramp--with-startup
|
|
|
|
|
(add-to-list 'tramp-methods
|
|
|
|
|
`(,tramp-sudoedit-method
|
2019-01-08 14:03:57 +00:00
|
|
|
|
(tramp-sudo-login (("sudo") ("-u" "%u") ("-S") ("-H")
|
2022-02-19 17:38:12 +00:00
|
|
|
|
("-p" "Password:") ("--")))
|
|
|
|
|
(tramp-password-previous-hop t)))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(add-to-list 'tramp-default-user-alist '("\\`sudoedit\\'" nil "root"))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(tramp-set-completion-function
|
|
|
|
|
tramp-sudoedit-method tramp-completion-function-alist-su))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defconst tramp-sudoedit-sudo-actions
|
|
|
|
|
'((tramp-password-prompt-regexp tramp-action-password)
|
|
|
|
|
(tramp-wrong-passwd-regexp tramp-action-permission-denied)
|
|
|
|
|
(tramp-process-alive-regexp tramp-sudoedit-action-sudo))
|
|
|
|
|
"List of pattern/action pairs.
|
|
|
|
|
This list is used for sudo calls.
|
|
|
|
|
|
|
|
|
|
See `tramp-actions-before-shell' for more info.")
|
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defconst tramp-sudoedit-file-name-handler-alist
|
2021-11-15 12:33:07 +00:00
|
|
|
|
'((abbreviate-file-name . tramp-handle-abbreviate-file-name)
|
|
|
|
|
(access-file . tramp-handle-access-file)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(add-name-to-file . tramp-sudoedit-handle-add-name-to-file)
|
|
|
|
|
(byte-compiler-base-file-name . ignore)
|
2019-11-05 11:58:47 +00:00
|
|
|
|
(copy-directory . tramp-handle-copy-directory)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(copy-file . tramp-sudoedit-handle-copy-file)
|
|
|
|
|
(delete-directory . tramp-sudoedit-handle-delete-directory)
|
|
|
|
|
(delete-file . tramp-sudoedit-handle-delete-file)
|
|
|
|
|
(diff-latest-backup-file . ignore)
|
|
|
|
|
;; `directory-file-name' performed by default handler.
|
|
|
|
|
(directory-files . tramp-handle-directory-files)
|
|
|
|
|
(directory-files-and-attributes
|
|
|
|
|
. tramp-handle-directory-files-and-attributes)
|
|
|
|
|
(dired-compress-file . ignore)
|
|
|
|
|
(dired-uncache . tramp-handle-dired-uncache)
|
|
|
|
|
(exec-path . ignore)
|
|
|
|
|
(expand-file-name . tramp-sudoedit-handle-expand-file-name)
|
|
|
|
|
(file-accessible-directory-p . tramp-handle-file-accessible-directory-p)
|
|
|
|
|
(file-acl . tramp-sudoedit-handle-file-acl)
|
|
|
|
|
(file-attributes . tramp-sudoedit-handle-file-attributes)
|
|
|
|
|
(file-directory-p . tramp-handle-file-directory-p)
|
|
|
|
|
(file-equal-p . tramp-handle-file-equal-p)
|
|
|
|
|
(file-executable-p . tramp-sudoedit-handle-file-executable-p)
|
|
|
|
|
(file-exists-p . tramp-sudoedit-handle-file-exists-p)
|
|
|
|
|
(file-in-directory-p . tramp-handle-file-in-directory-p)
|
|
|
|
|
(file-local-copy . tramp-handle-file-local-copy)
|
Implement file locks for remote files (Bug#49261)
* doc/lispref/files.texi (Magic File Names): Add file-locked-p,
lock-file and unlock-file.
* etc/NEWS: Tramp supports file locks now.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-adb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file)
(tramp-crypt-handle-unlock-file): New defun.
* lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify.
(tramp-fuse-unmount): New defun.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-rclone-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sh-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-smb-handle-copy-directory): Use `sleep-for'.
(tramp-smb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sshfs-handle-write-region): Handle LOCKNAME.
(tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sudoedit-maybe-open-connection):
Set "lock-pid" connection property.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid)
(tramp-handle-file-locked-p, tramp-handle-lock-file)
(tramp-handle-unlock-file): New defuns.
(tramp-lock-file-contents-regexp): New regexp.
(tramp-handle-write-region): Handle LOCKNAME.
* src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p):
Call handler if exists.
(Flock_file, Funlock_file): New defuns.
(Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols.
(Slock_file, Sunlock_file): Declare subroutines.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test40-make-nearby-temp-file)
(tramp-archive-test43-file-system-info): Rename.
* test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil.
(tramp--test-fuse-p): New defun.
(tramp-test14-delete-directory): Use it.
(tramp-test39-lock-file): New test.
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters)
(tramp-test41-special-characters-with-stat)
(tramp-test41-special-characters-with-perl)
(tramp-test41-special-characters-with-ls, tramp-test42-utf8)
(tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl)
(tramp-test42-utf8-with-ls, tramp-test43-file-system-info)
(tramp-test44-asynchronous-requests, tramp-test45-auto-load)
(tramp-test45-delay-load, tramp-test45-recursive-load)
(tramp-test45-remote-load-path, tramp-test46-unload): Rename.
(tramp--test-special-characters, tramp--test-utf8)
(tramp--test-asynchronous-requests-timeout): Modify docstring.
2021-07-07 16:36:53 +00:00
|
|
|
|
(file-locked-p . tramp-handle-file-locked-p)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(file-modes . tramp-handle-file-modes)
|
|
|
|
|
(file-name-all-completions
|
|
|
|
|
. tramp-sudoedit-handle-file-name-all-completions)
|
|
|
|
|
(file-name-as-directory . tramp-handle-file-name-as-directory)
|
|
|
|
|
(file-name-case-insensitive-p . tramp-handle-file-name-case-insensitive-p)
|
|
|
|
|
(file-name-completion . tramp-handle-file-name-completion)
|
|
|
|
|
(file-name-directory . tramp-handle-file-name-directory)
|
|
|
|
|
(file-name-nondirectory . tramp-handle-file-name-nondirectory)
|
|
|
|
|
;; `file-name-sans-versions' performed by default handler.
|
|
|
|
|
(file-newer-than-file-p . tramp-handle-file-newer-than-file-p)
|
2022-02-16 19:22:45 +00:00
|
|
|
|
(file-notify-add-watch . tramp-handle-file-notify-add-watch)
|
|
|
|
|
(file-notify-rm-watch . tramp-handle-file-notify-rm-watch)
|
|
|
|
|
(file-notify-valid-p . tramp-handle-file-notify-valid-p)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(file-ownership-preserved-p . ignore)
|
|
|
|
|
(file-readable-p . tramp-sudoedit-handle-file-readable-p)
|
|
|
|
|
(file-regular-p . tramp-handle-file-regular-p)
|
|
|
|
|
(file-remote-p . tramp-handle-file-remote-p)
|
|
|
|
|
(file-selinux-context . tramp-sudoedit-handle-file-selinux-context)
|
|
|
|
|
(file-symlink-p . tramp-handle-file-symlink-p)
|
|
|
|
|
(file-system-info . tramp-sudoedit-handle-file-system-info)
|
|
|
|
|
(file-truename . tramp-sudoedit-handle-file-truename)
|
|
|
|
|
(file-writable-p . tramp-sudoedit-handle-file-writable-p)
|
|
|
|
|
(find-backup-file-name . tramp-handle-find-backup-file-name)
|
|
|
|
|
;; `get-file-buffer' performed by default handler.
|
|
|
|
|
(insert-directory . tramp-handle-insert-directory)
|
|
|
|
|
(insert-file-contents . tramp-handle-insert-file-contents)
|
|
|
|
|
(load . tramp-handle-load)
|
Implement file locks for remote files (Bug#49261)
* doc/lispref/files.texi (Magic File Names): Add file-locked-p,
lock-file and unlock-file.
* etc/NEWS: Tramp supports file locks now.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-adb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file)
(tramp-crypt-handle-unlock-file): New defun.
* lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify.
(tramp-fuse-unmount): New defun.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-rclone-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sh-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-smb-handle-copy-directory): Use `sleep-for'.
(tramp-smb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sshfs-handle-write-region): Handle LOCKNAME.
(tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sudoedit-maybe-open-connection):
Set "lock-pid" connection property.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid)
(tramp-handle-file-locked-p, tramp-handle-lock-file)
(tramp-handle-unlock-file): New defuns.
(tramp-lock-file-contents-regexp): New regexp.
(tramp-handle-write-region): Handle LOCKNAME.
* src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p):
Call handler if exists.
(Flock_file, Funlock_file): New defuns.
(Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols.
(Slock_file, Sunlock_file): Declare subroutines.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test40-make-nearby-temp-file)
(tramp-archive-test43-file-system-info): Rename.
* test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil.
(tramp--test-fuse-p): New defun.
(tramp-test14-delete-directory): Use it.
(tramp-test39-lock-file): New test.
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters)
(tramp-test41-special-characters-with-stat)
(tramp-test41-special-characters-with-perl)
(tramp-test41-special-characters-with-ls, tramp-test42-utf8)
(tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl)
(tramp-test42-utf8-with-ls, tramp-test43-file-system-info)
(tramp-test44-asynchronous-requests, tramp-test45-auto-load)
(tramp-test45-delay-load, tramp-test45-recursive-load)
(tramp-test45-remote-load-path, tramp-test46-unload): Rename.
(tramp--test-special-characters, tramp--test-utf8)
(tramp--test-asynchronous-requests-timeout): Modify docstring.
2021-07-07 16:36:53 +00:00
|
|
|
|
(lock-file . tramp-handle-lock-file)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
|
|
|
|
|
(make-directory . tramp-sudoedit-handle-make-directory)
|
|
|
|
|
(make-directory-internal . ignore)
|
2021-07-13 17:50:05 +00:00
|
|
|
|
(make-lock-file-name . tramp-handle-make-lock-file-name)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(make-nearby-temp-file . tramp-handle-make-nearby-temp-file)
|
2018-12-23 08:48:05 +00:00
|
|
|
|
(make-process . ignore)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(make-symbolic-link . tramp-sudoedit-handle-make-symbolic-link)
|
|
|
|
|
(process-file . ignore)
|
|
|
|
|
(rename-file . tramp-sudoedit-handle-rename-file)
|
|
|
|
|
(set-file-acl . tramp-sudoedit-handle-set-file-acl)
|
|
|
|
|
(set-file-modes . tramp-sudoedit-handle-set-file-modes)
|
|
|
|
|
(set-file-selinux-context . tramp-sudoedit-handle-set-file-selinux-context)
|
|
|
|
|
(set-file-times . tramp-sudoedit-handle-set-file-times)
|
|
|
|
|
(set-visited-file-modtime . tramp-handle-set-visited-file-modtime)
|
|
|
|
|
(shell-command . ignore)
|
|
|
|
|
(start-file-process . ignore)
|
|
|
|
|
(substitute-in-file-name . tramp-handle-substitute-in-file-name)
|
|
|
|
|
(temporary-file-directory . tramp-handle-temporary-file-directory)
|
2022-03-07 12:42:30 +00:00
|
|
|
|
(tramp-get-home-directory . tramp-sudoedit-handle-get-home-directory)
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(tramp-get-remote-gid . tramp-sudoedit-handle-get-remote-gid)
|
|
|
|
|
(tramp-get-remote-uid . tramp-sudoedit-handle-get-remote-uid)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(tramp-set-file-uid-gid . tramp-sudoedit-handle-set-file-uid-gid)
|
|
|
|
|
(unhandled-file-name-directory . ignore)
|
Implement file locks for remote files (Bug#49261)
* doc/lispref/files.texi (Magic File Names): Add file-locked-p,
lock-file and unlock-file.
* etc/NEWS: Tramp supports file locks now.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-adb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file)
(tramp-crypt-handle-unlock-file): New defun.
* lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify.
(tramp-fuse-unmount): New defun.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-rclone-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sh-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-smb-handle-copy-directory): Use `sleep-for'.
(tramp-smb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sshfs-handle-write-region): Handle LOCKNAME.
(tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sudoedit-maybe-open-connection):
Set "lock-pid" connection property.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid)
(tramp-handle-file-locked-p, tramp-handle-lock-file)
(tramp-handle-unlock-file): New defuns.
(tramp-lock-file-contents-regexp): New regexp.
(tramp-handle-write-region): Handle LOCKNAME.
* src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p):
Call handler if exists.
(Flock_file, Funlock_file): New defuns.
(Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols.
(Slock_file, Sunlock_file): Declare subroutines.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test40-make-nearby-temp-file)
(tramp-archive-test43-file-system-info): Rename.
* test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil.
(tramp--test-fuse-p): New defun.
(tramp-test14-delete-directory): Use it.
(tramp-test39-lock-file): New test.
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters)
(tramp-test41-special-characters-with-stat)
(tramp-test41-special-characters-with-perl)
(tramp-test41-special-characters-with-ls, tramp-test42-utf8)
(tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl)
(tramp-test42-utf8-with-ls, tramp-test43-file-system-info)
(tramp-test44-asynchronous-requests, tramp-test45-auto-load)
(tramp-test45-delay-load, tramp-test45-recursive-load)
(tramp-test45-remote-load-path, tramp-test46-unload): Rename.
(tramp--test-special-characters, tramp--test-utf8)
(tramp--test-asynchronous-requests-timeout): Modify docstring.
2021-07-07 16:36:53 +00:00
|
|
|
|
(unlock-file . tramp-handle-unlock-file)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(vc-registered . ignore)
|
|
|
|
|
(verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)
|
|
|
|
|
(write-region . tramp-sudoedit-handle-write-region))
|
|
|
|
|
"Alist of handler functions for Tramp SUDOEDIT method.")
|
|
|
|
|
|
|
|
|
|
;; It must be a `defsubst' in order to push the whole code into
|
|
|
|
|
;; tramp-loaddefs.el. Otherwise, there would be recursive autoloading.
|
|
|
|
|
;;;###tramp-autoload
|
2021-11-11 18:34:17 +00:00
|
|
|
|
(defsubst tramp-sudoedit-file-name-p (vec-or-filename)
|
|
|
|
|
"Check if it's a VEC-OR-FILENAME for SUDOEDIT."
|
|
|
|
|
(when-let* ((vec (tramp-ensure-dissected-file-name vec-or-filename)))
|
|
|
|
|
(string= (tramp-file-name-method vec) tramp-sudoedit-method)))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
|
|
|
|
(defun tramp-sudoedit-file-name-handler (operation &rest args)
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
"Invoke the SUDOEDIT handler for OPERATION and ARGS.
|
2021-02-03 17:48:09 +00:00
|
|
|
|
First arg specifies the OPERATION, second arg is a list of
|
|
|
|
|
arguments to pass to the OPERATION."
|
Sync with Tramp 2.5.0-pre
* doc/misc/tramp.texi: Protext Tramp x.y and Emacs x.y by @w{}.
(GVFS-based methods): Move "GNOME Online Accounts" index.
(Customizing Methods, Android shell setup, File name completion)
(Frequently Asked Questions): Fix typos.
* doc/misc/trampver.texi: Change version to "2.5.0-pre".
* lisp/net/trampver.el: Change version to "2.5.0-pre".
(inhibit-message): Don't declare.
* lisp/net/tramp.el: Bump version to 2.5.0-pre. Require Emacs 25.1.
(tramp-debug-message): Simplify.
(tramp-message): Don't use `tramp-message-show-message'.
(tramp-with-demoted-errors, with-parsed-tramp-file-name)
(with-tramp-file-property, with-tramp-connection-property):
Adapt `declare' form.
(with-tramp-progress-reporter): Suppress progress reporter when
noninteractive.
(tramp-completion-mode, tramp-completion-mode-p): Remove.
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(format-message): Remove compatibility code.
(tramp-compat-directory-name-p)
(tramp-compat-tramp-file-name-slots): Remove.
* lisp/net/tramp.el (tramp-debug-message, tramp-message)
(tramp-backtrace, tramp-error, tramp-error-with-buffer)
(tramp-user-error, tramp-with-demoted-errors)
(tramp-signal-hook-function):
* lisp/net/tramp-compat.el (tramp-compat-funcall)
* lisp/net/tramp-gvfs.el (tramp-dbus-function):
Add `tramp-suppress-trace' property.
* lisp/net/tramp.el (tramp-get-method-parameter)
(tramp-dissect-file-name, tramp-error, tramp-error-with-buffer)
(tramp-user-error, with-parsed-tramp-file-name)
(with-tramp-progress-reporter, tramp-file-name-handler)
(tramp-completion-file-name-handler, tramp-autoload-file-name-handler)
(tramp-register-file-name-handlers, tramp-connectable-p)
(tramp-handle-file-modes, tramp-handle-file-regular-p)
(tramp-handle-file-truename, tramp-handle-insert-directory)
(tramp-handle-load, tramp-set-file-uid-gid):
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler)
(tramp-adb-handle-file-truename, tramp-adb-handle-copy-file)
(tramp-adb-handle-rename-file):
* lisp/net/tramp-archive.el (with-parsed-tramp-archive-file-name):
* lisp/net/tramp-cache.el (tramp-get-file-property, tramp-cache-print):
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(tramp-compat-exec-path):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler)
(tramp-gvfs-dbus-byte-array-to-string)
(tramp-gvfs-do-copy-or-rename-file):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler)
(tramp-rclone-do-copy-or-rename-file):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename)
(tramp-sh-handle-copy-directory, tramp-do-copy-or-rename-file)
(tramp-sh-handle-insert-directory, tramp-sh-file-name-handler)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler)
(tramp-smb-handle-copy-file, tramp-smb-handle-copy-directory)
(tramp-smb-handle-copy-file, tramp-smb-handle-insert-directory)
(tramp-smb-handle-rename-file, tramp-smb-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler)
(tramp-sudoedit-do-copy-or-rename-file)
(tramp-sudoedit-handle-file-truename):
Use `if-let', `when-let', `directory-name-p', `inhibit-message',
`non-essential and `cl-struct-slot-info'. Don't use `seconds-to-time'.
* test/lisp/net/tramp-archive-tests.el (tramp-message-show-message):
Don't set.
* test/lisp/net/tramp-tests.el (inhibit-message): Don't declare.
(tramp-message-show-message): Don't set.
(tramp-test06-directory-file-name): Use `non-essential'.
(tramp-test10-write-region): Use `inhibit-message'.
(tramp-test36-vc-registered): No special handling for old Emacsen.
(tramp--test-emacs25-p): Remove.
(tramp-test45-unload): Special case of `tramp-completion-mode'.
2020-01-19 13:11:07 +00:00
|
|
|
|
(if-let ((fn (assoc operation tramp-sudoedit-file-name-handler-alist)))
|
|
|
|
|
(save-match-data (apply (cdr fn) args))
|
|
|
|
|
(tramp-run-real-handler operation args)))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
;;;###tramp-autoload
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(tramp--with-startup
|
|
|
|
|
(tramp-register-foreign-file-name-handler
|
|
|
|
|
#'tramp-sudoedit-file-name-p #'tramp-sudoedit-file-name-handler))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
2022-02-19 17:38:12 +00:00
|
|
|
|
;; Needed for `tramp-read-passwd'.
|
|
|
|
|
(defconst tramp-sudoedit-null-hop
|
|
|
|
|
(make-tramp-file-name
|
|
|
|
|
:method tramp-sudoedit-method :user (user-login-name) :host tramp-system-name)
|
|
|
|
|
"Connection hop which identifies the virtual hop before the first one.")
|
|
|
|
|
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
;; File name primitives.
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-add-name-to-file
|
|
|
|
|
(filename newname &optional ok-if-already-exists)
|
|
|
|
|
"Like `add-name-to-file' for Tramp files."
|
|
|
|
|
(unless (tramp-equal-remote filename newname)
|
|
|
|
|
(with-parsed-tramp-file-name
|
|
|
|
|
(if (tramp-tramp-file-p filename) filename newname) nil
|
|
|
|
|
(tramp-error
|
|
|
|
|
v 'file-error
|
|
|
|
|
"add-name-to-file: %s"
|
|
|
|
|
"only implemented for same method, same user, same host")))
|
|
|
|
|
(with-parsed-tramp-file-name filename v1
|
|
|
|
|
(with-parsed-tramp-file-name newname v2
|
|
|
|
|
;; Do the 'confirm if exists' thing.
|
|
|
|
|
(when (file-exists-p newname)
|
|
|
|
|
;; What to do?
|
|
|
|
|
(if (or (null ok-if-already-exists) ; not allowed to exist
|
|
|
|
|
(and (numberp ok-if-already-exists)
|
|
|
|
|
(not (yes-or-no-p
|
|
|
|
|
(format
|
2021-09-16 14:50:24 +00:00
|
|
|
|
"File %s already exists; make it a link anyway?"
|
2018-12-16 14:49:07 +00:00
|
|
|
|
v2-localname)))))
|
|
|
|
|
(tramp-error v2 'file-already-exists newname)
|
|
|
|
|
(delete-file newname)))
|
|
|
|
|
(tramp-flush-file-properties v2 v2-localname)
|
|
|
|
|
(unless
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v1 "ln"
|
|
|
|
|
(tramp-compat-file-name-unquote v1-localname)
|
|
|
|
|
(tramp-compat-file-name-unquote v2-localname))
|
|
|
|
|
(tramp-error
|
|
|
|
|
v1 'file-error
|
|
|
|
|
"error with add-name-to-file, see buffer `%s' for details"
|
|
|
|
|
(buffer-name))))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-do-copy-or-rename-file
|
|
|
|
|
(op filename newname &optional ok-if-already-exists keep-date
|
|
|
|
|
preserve-uid-gid preserve-extended-attributes)
|
|
|
|
|
"Copy or rename a remote file.
|
|
|
|
|
OP must be `copy' or `rename' and indicates the operation to perform.
|
|
|
|
|
FILENAME specifies the file to copy or rename, NEWNAME is the name of
|
|
|
|
|
the new file (for copy) or the new name of the file (for rename).
|
|
|
|
|
OK-IF-ALREADY-EXISTS means don't barf if NEWNAME exists already.
|
|
|
|
|
KEEP-DATE means to make sure that NEWNAME has the same timestamp
|
|
|
|
|
as FILENAME. PRESERVE-UID-GID, when non-nil, instructs to keep
|
|
|
|
|
the uid and gid if both files are on the same host.
|
|
|
|
|
PRESERVE-EXTENDED-ATTRIBUTES activates selinux and acl commands.
|
|
|
|
|
|
|
|
|
|
This function is invoked by `tramp-sudoedit-handle-copy-file' and
|
|
|
|
|
`tramp-sudoedit-handle-rename-file'. It is an error if OP is
|
|
|
|
|
neither of `copy' and `rename'. FILENAME and NEWNAME must be
|
|
|
|
|
absolute file names."
|
|
|
|
|
(unless (memq op '(copy rename))
|
|
|
|
|
(error "Unknown operation `%s', must be `copy' or `rename'" op))
|
|
|
|
|
|
|
|
|
|
(setq filename (file-truename filename))
|
|
|
|
|
(if (file-directory-p filename)
|
|
|
|
|
(progn
|
|
|
|
|
(copy-directory filename newname keep-date t)
|
|
|
|
|
(when (eq op 'rename) (delete-directory filename 'recursive)))
|
|
|
|
|
|
|
|
|
|
(let ((t1 (tramp-sudoedit-file-name-p filename))
|
|
|
|
|
(t2 (tramp-sudoedit-file-name-p newname))
|
Remove Emacs 25 compatibility from Tramp
* doc/misc/tramp.texi (Remote programs, Remote processes)
(Frequently Asked Questions): Adapt Emacs versions.
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.6.0-pre".
* lisp/net/tramp-adb.el (top): Don't use `tramp-compat-funcall' for
connection-local functions.
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-handle-temporary-file-directory)
(tramp-compat-temporary-file-directory-function)
(tramp-compat-file-attribute-type)
(tramp-compat-file-attribute-link-number)
(tramp-compat-file-attribute-user-id)
(tramp-compat-file-attribute-group-id)
(tramp-compat-file-attribute-access-time)
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-status-change-time)
(tramp-compat-file-attribute-size)
(tramp-compat-file-attribute-modes, tramp-file-missing)
(tramp-compat-file-missing, tramp-compat-file-local-name): Remove.
(tramp-compat-file-name-quoted-p, tramp-compat-file-name-quote)
(tramp-compat-file-name-unquote)
(tramp-compat-progress-reporter-update)
(tramp-compat-file-modes, tramp-compat-set-file-modes)
(tramp-compat-set-file-times, tramp-compat-directory-files)
(tramp-compat-directory-files-and-attributes): Adapt implementation.
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Adapt callees.
* lisp/net/tramp-crypt.el (tramp-crypt-config-file-name):
Expand file name.
* lisp/net/tramp-fuse.el (tramp-fuse-handle-file-readable-p): Remove.
* lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Don't check Emacs version.
(tramp-gvfs-handler-mounted-unmounted): Use `make-tramp-file-name'.
* lisp/net/tramp-integration.el (rfn-eshadow-overlay):
Remove declaration.
(top): Don't use `tramp-compat-funcall' for connection-local functions.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Use `tramp-rclone-handle-file-readable-p'.
(tramp-rclone-handle-file-readable-p): New defun.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Use `tramp-handle-file-readable-p'.
* lisp/net/tramp.el (tramp-temp-name-prefix, tramp-lookup-syntax):
Adapt docstring.
(tramp-set-connection-local-variables)
(tramp-set-connection-local-variables-for-buffer): Don't use
`tramp-compat-funcall' for connection-local functions.
(tramp-file-name-for-operation): Reorder list.
(tramp-handle-make-symbolic-link): Don't handle TARGET and
OK-IF-ALREADY-EXISTS.
(tramp-read-passwd): Don't use `read-passwd' any longer.
(top): Don't check for `interrupt-process-functions'.
* test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs26-p):
Remove.
(tramp-archive-test02-file-name-dissect): Use `make-tramp-file-name'.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-archive-test46-auto-load)
(tramp-archive-test46-delay-load): Rename.
* test/lisp/net/tramp-tests.el (dired-aux, seq): Require them.
(dired-compress, connection-local-criteria-alist)
(connection-local-profile-alist, async-shell-command-width):
Don't declare.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-test04-substitute-in-file-name)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test15-copy-directory)
(tramp-test17-insert-directory)
(tramp-test17-dired-with-wildcards, tramp-test21-file-links)
(tramp-test31-interrupt-process)
(tramp-test34-connection-local-variables)
(tramp-test34-explicit-shell-file-name)
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters, tramp-test42-utf8)
(tramp-test46-delay-load, tramp-test46-remote-load-path)
(tramp-test47-unload): Don't check for Emacs 26 special features.
(tramp--test-emacs26-p): Remove.
(tramp--test-emacs29-p): New defun.
(tramp-test45-dired-compress-file)
(tramp-test45-dired-compress-dir): Use it.
(tramp-test44-asynchronous-requests): Use `seq-random-elt'.
2021-11-12 17:17:32 +00:00
|
|
|
|
(file-times (file-attribute-modification-time
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(file-attributes filename)))
|
|
|
|
|
(file-modes (tramp-default-file-modes filename))
|
|
|
|
|
(attributes (and preserve-extended-attributes
|
2021-07-25 12:14:49 +00:00
|
|
|
|
(file-extended-attributes filename)))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(sudoedit-operation
|
|
|
|
|
(cond
|
|
|
|
|
((and (eq op 'copy) preserve-uid-gid) '("cp" "-f" "-p"))
|
|
|
|
|
((eq op 'copy) '("cp" "-f"))
|
|
|
|
|
((eq op 'rename) '("mv" "-f"))))
|
|
|
|
|
(msg-operation (if (eq op 'copy) "Copying" "Renaming")))
|
|
|
|
|
|
|
|
|
|
(with-parsed-tramp-file-name (if t1 filename newname) nil
|
2019-11-04 16:34:31 +00:00
|
|
|
|
(unless (file-exists-p filename)
|
Remove Emacs 25 compatibility from Tramp
* doc/misc/tramp.texi (Remote programs, Remote processes)
(Frequently Asked Questions): Adapt Emacs versions.
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.6.0-pre".
* lisp/net/tramp-adb.el (top): Don't use `tramp-compat-funcall' for
connection-local functions.
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-handle-temporary-file-directory)
(tramp-compat-temporary-file-directory-function)
(tramp-compat-file-attribute-type)
(tramp-compat-file-attribute-link-number)
(tramp-compat-file-attribute-user-id)
(tramp-compat-file-attribute-group-id)
(tramp-compat-file-attribute-access-time)
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-status-change-time)
(tramp-compat-file-attribute-size)
(tramp-compat-file-attribute-modes, tramp-file-missing)
(tramp-compat-file-missing, tramp-compat-file-local-name): Remove.
(tramp-compat-file-name-quoted-p, tramp-compat-file-name-quote)
(tramp-compat-file-name-unquote)
(tramp-compat-progress-reporter-update)
(tramp-compat-file-modes, tramp-compat-set-file-modes)
(tramp-compat-set-file-times, tramp-compat-directory-files)
(tramp-compat-directory-files-and-attributes): Adapt implementation.
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Adapt callees.
* lisp/net/tramp-crypt.el (tramp-crypt-config-file-name):
Expand file name.
* lisp/net/tramp-fuse.el (tramp-fuse-handle-file-readable-p): Remove.
* lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Don't check Emacs version.
(tramp-gvfs-handler-mounted-unmounted): Use `make-tramp-file-name'.
* lisp/net/tramp-integration.el (rfn-eshadow-overlay):
Remove declaration.
(top): Don't use `tramp-compat-funcall' for connection-local functions.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Use `tramp-rclone-handle-file-readable-p'.
(tramp-rclone-handle-file-readable-p): New defun.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Use `tramp-handle-file-readable-p'.
* lisp/net/tramp.el (tramp-temp-name-prefix, tramp-lookup-syntax):
Adapt docstring.
(tramp-set-connection-local-variables)
(tramp-set-connection-local-variables-for-buffer): Don't use
`tramp-compat-funcall' for connection-local functions.
(tramp-file-name-for-operation): Reorder list.
(tramp-handle-make-symbolic-link): Don't handle TARGET and
OK-IF-ALREADY-EXISTS.
(tramp-read-passwd): Don't use `read-passwd' any longer.
(top): Don't check for `interrupt-process-functions'.
* test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs26-p):
Remove.
(tramp-archive-test02-file-name-dissect): Use `make-tramp-file-name'.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-archive-test46-auto-load)
(tramp-archive-test46-delay-load): Rename.
* test/lisp/net/tramp-tests.el (dired-aux, seq): Require them.
(dired-compress, connection-local-criteria-alist)
(connection-local-profile-alist, async-shell-command-width):
Don't declare.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-test04-substitute-in-file-name)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test15-copy-directory)
(tramp-test17-insert-directory)
(tramp-test17-dired-with-wildcards, tramp-test21-file-links)
(tramp-test31-interrupt-process)
(tramp-test34-connection-local-variables)
(tramp-test34-explicit-shell-file-name)
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters, tramp-test42-utf8)
(tramp-test46-delay-load, tramp-test46-remote-load-path)
(tramp-test47-unload): Don't check for Emacs 26 special features.
(tramp--test-emacs26-p): Remove.
(tramp--test-emacs29-p): New defun.
(tramp-test45-dired-compress-file)
(tramp-test45-dired-compress-dir): Use it.
(tramp-test44-asynchronous-requests): Use `seq-random-elt'.
2021-11-12 17:17:32 +00:00
|
|
|
|
(tramp-error v 'file-missing filename))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(when (and (not ok-if-already-exists) (file-exists-p newname))
|
|
|
|
|
(tramp-error v 'file-already-exists newname))
|
2019-08-08 14:47:29 +00:00
|
|
|
|
(when (and (file-directory-p newname)
|
Sync with Tramp 2.5.0-pre
* doc/misc/tramp.texi: Protext Tramp x.y and Emacs x.y by @w{}.
(GVFS-based methods): Move "GNOME Online Accounts" index.
(Customizing Methods, Android shell setup, File name completion)
(Frequently Asked Questions): Fix typos.
* doc/misc/trampver.texi: Change version to "2.5.0-pre".
* lisp/net/trampver.el: Change version to "2.5.0-pre".
(inhibit-message): Don't declare.
* lisp/net/tramp.el: Bump version to 2.5.0-pre. Require Emacs 25.1.
(tramp-debug-message): Simplify.
(tramp-message): Don't use `tramp-message-show-message'.
(tramp-with-demoted-errors, with-parsed-tramp-file-name)
(with-tramp-file-property, with-tramp-connection-property):
Adapt `declare' form.
(with-tramp-progress-reporter): Suppress progress reporter when
noninteractive.
(tramp-completion-mode, tramp-completion-mode-p): Remove.
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(format-message): Remove compatibility code.
(tramp-compat-directory-name-p)
(tramp-compat-tramp-file-name-slots): Remove.
* lisp/net/tramp.el (tramp-debug-message, tramp-message)
(tramp-backtrace, tramp-error, tramp-error-with-buffer)
(tramp-user-error, tramp-with-demoted-errors)
(tramp-signal-hook-function):
* lisp/net/tramp-compat.el (tramp-compat-funcall)
* lisp/net/tramp-gvfs.el (tramp-dbus-function):
Add `tramp-suppress-trace' property.
* lisp/net/tramp.el (tramp-get-method-parameter)
(tramp-dissect-file-name, tramp-error, tramp-error-with-buffer)
(tramp-user-error, with-parsed-tramp-file-name)
(with-tramp-progress-reporter, tramp-file-name-handler)
(tramp-completion-file-name-handler, tramp-autoload-file-name-handler)
(tramp-register-file-name-handlers, tramp-connectable-p)
(tramp-handle-file-modes, tramp-handle-file-regular-p)
(tramp-handle-file-truename, tramp-handle-insert-directory)
(tramp-handle-load, tramp-set-file-uid-gid):
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler)
(tramp-adb-handle-file-truename, tramp-adb-handle-copy-file)
(tramp-adb-handle-rename-file):
* lisp/net/tramp-archive.el (with-parsed-tramp-archive-file-name):
* lisp/net/tramp-cache.el (tramp-get-file-property, tramp-cache-print):
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(tramp-compat-exec-path):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler)
(tramp-gvfs-dbus-byte-array-to-string)
(tramp-gvfs-do-copy-or-rename-file):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler)
(tramp-rclone-do-copy-or-rename-file):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename)
(tramp-sh-handle-copy-directory, tramp-do-copy-or-rename-file)
(tramp-sh-handle-insert-directory, tramp-sh-file-name-handler)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler)
(tramp-smb-handle-copy-file, tramp-smb-handle-copy-directory)
(tramp-smb-handle-copy-file, tramp-smb-handle-insert-directory)
(tramp-smb-handle-rename-file, tramp-smb-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler)
(tramp-sudoedit-do-copy-or-rename-file)
(tramp-sudoedit-handle-file-truename):
Use `if-let', `when-let', `directory-name-p', `inhibit-message',
`non-essential and `cl-struct-slot-info'. Don't use `seconds-to-time'.
* test/lisp/net/tramp-archive-tests.el (tramp-message-show-message):
Don't set.
* test/lisp/net/tramp-tests.el (inhibit-message): Don't declare.
(tramp-message-show-message): Don't set.
(tramp-test06-directory-file-name): Use `non-essential'.
(tramp-test10-write-region): Use `inhibit-message'.
(tramp-test36-vc-registered): No special handling for old Emacsen.
(tramp--test-emacs25-p): Remove.
(tramp-test45-unload): Special case of `tramp-completion-mode'.
2020-01-19 13:11:07 +00:00
|
|
|
|
(not (directory-name-p newname)))
|
2019-07-12 13:10:57 +00:00
|
|
|
|
(tramp-error v 'file-error "File is a directory %s" newname))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(if (or (and (file-remote-p filename) (not t1))
|
|
|
|
|
(and (file-remote-p newname) (not t2)))
|
|
|
|
|
;; We cannot copy or rename directly.
|
|
|
|
|
(let ((tmpfile (tramp-compat-make-temp-file filename)))
|
|
|
|
|
(if (eq op 'copy)
|
|
|
|
|
(copy-file filename tmpfile t)
|
|
|
|
|
(rename-file filename tmpfile t))
|
|
|
|
|
(rename-file tmpfile newname ok-if-already-exists))
|
|
|
|
|
|
|
|
|
|
;; Direct action.
|
|
|
|
|
(with-tramp-progress-reporter
|
|
|
|
|
v 0 (format "%s %s to %s" msg-operation filename newname)
|
|
|
|
|
(unless (tramp-sudoedit-send-command
|
|
|
|
|
v sudoedit-operation
|
2020-01-06 11:11:53 +00:00
|
|
|
|
(tramp-unquote-file-local-name filename)
|
|
|
|
|
(tramp-unquote-file-local-name newname))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(tramp-error
|
|
|
|
|
v 'file-error
|
|
|
|
|
"Error %s `%s' `%s'" msg-operation filename newname))))
|
|
|
|
|
|
|
|
|
|
;; When `newname' is local, we must change the ownership to
|
|
|
|
|
;; the local user.
|
|
|
|
|
(unless (file-remote-p newname)
|
|
|
|
|
(tramp-set-file-uid-gid
|
|
|
|
|
(concat (file-remote-p filename) newname)
|
|
|
|
|
(tramp-get-local-uid 'integer)
|
|
|
|
|
(tramp-get-local-gid 'integer)))
|
|
|
|
|
|
|
|
|
|
;; Set the time and mode. Mask possible errors.
|
|
|
|
|
(when keep-date
|
|
|
|
|
(ignore-errors
|
2020-03-09 15:05:21 +00:00
|
|
|
|
(tramp-compat-set-file-times
|
|
|
|
|
newname file-times (unless ok-if-already-exists 'nofollow))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(set-file-modes newname file-modes)))
|
|
|
|
|
|
|
|
|
|
;; Handle `preserve-extended-attributes'. We ignore possible
|
|
|
|
|
;; errors, because ACL strings could be incompatible.
|
|
|
|
|
(when attributes
|
|
|
|
|
(ignore-errors
|
2021-07-25 12:14:49 +00:00
|
|
|
|
(set-file-extended-attributes newname attributes)))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(when (and t1 (eq op 'rename))
|
|
|
|
|
(with-parsed-tramp-file-name filename v1
|
|
|
|
|
(tramp-flush-file-properties v1 v1-localname)))
|
|
|
|
|
|
|
|
|
|
(when t2
|
|
|
|
|
(with-parsed-tramp-file-name newname v2
|
2019-01-08 14:03:57 +00:00
|
|
|
|
(tramp-flush-file-properties v2 v2-localname)))))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-copy-file
|
|
|
|
|
(filename newname &optional ok-if-already-exists keep-date
|
|
|
|
|
preserve-uid-gid preserve-extended-attributes)
|
|
|
|
|
"Like `copy-file' for Tramp files."
|
2020-01-24 13:41:44 +00:00
|
|
|
|
(setq filename (expand-file-name filename)
|
|
|
|
|
newname (expand-file-name newname))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; At least one file a Tramp file?
|
|
|
|
|
(if (or (tramp-tramp-file-p filename)
|
|
|
|
|
(tramp-tramp-file-p newname))
|
|
|
|
|
(tramp-sudoedit-do-copy-or-rename-file
|
|
|
|
|
'copy filename newname ok-if-already-exists keep-date
|
|
|
|
|
preserve-uid-gid preserve-extended-attributes)
|
|
|
|
|
(tramp-run-real-handler
|
2019-02-28 09:33:05 +00:00
|
|
|
|
#'copy-file
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(list filename newname ok-if-already-exists keep-date
|
|
|
|
|
preserve-uid-gid preserve-extended-attributes))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-delete-directory
|
|
|
|
|
(directory &optional recursive trash)
|
|
|
|
|
"Like `delete-directory' for Tramp files."
|
2020-11-01 11:42:29 +00:00
|
|
|
|
(tramp-skeleton-delete-directory directory recursive trash
|
|
|
|
|
(unless (tramp-sudoedit-send-command
|
|
|
|
|
v (if recursive '("rm" "-rf") "rmdir")
|
|
|
|
|
(tramp-compat-file-name-unquote localname))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(tramp-error v 'file-error "Couldn't delete %s" directory))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-delete-file (filename &optional trash)
|
|
|
|
|
"Like `delete-file' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
|
|
|
|
(tramp-flush-file-properties v localname)
|
2020-11-01 11:42:29 +00:00
|
|
|
|
(if (and delete-by-moving-to-trash trash)
|
|
|
|
|
(move-file-to-trash filename)
|
|
|
|
|
(unless (tramp-sudoedit-send-command
|
2021-12-09 19:03:16 +00:00
|
|
|
|
v "rm" "-f" (tramp-compat-file-name-unquote localname))
|
2020-11-01 11:42:29 +00:00
|
|
|
|
;; Propagate the error.
|
|
|
|
|
(with-current-buffer (tramp-get-connection-buffer v)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(tramp-error-with-buffer
|
|
|
|
|
nil v 'file-error "Couldn't delete %s" filename))))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-expand-file-name (name &optional dir)
|
|
|
|
|
"Like `expand-file-name' for Tramp files.
|
|
|
|
|
If the localname part of the given file name starts with \"/../\" then
|
|
|
|
|
the result will be a local, non-Tramp, file name."
|
|
|
|
|
;; If DIR is not given, use `default-directory' or "/".
|
|
|
|
|
(setq dir (or dir default-directory "/"))
|
2019-03-06 11:06:09 +00:00
|
|
|
|
;; Handle empty NAME.
|
|
|
|
|
(when (zerop (length name)) (setq name "."))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; Unless NAME is absolute, concat DIR and NAME.
|
|
|
|
|
(unless (file-name-absolute-p name)
|
2021-07-25 10:05:01 +00:00
|
|
|
|
(setq name (tramp-compat-file-name-concat dir name)))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(with-parsed-tramp-file-name name nil
|
|
|
|
|
;; Tilde expansion if necessary. We cannot accept "~/", because
|
|
|
|
|
;; under sudo "~/" is expanded to the local user home directory
|
|
|
|
|
;; but to the root home directory.
|
|
|
|
|
(when (zerop (length localname))
|
|
|
|
|
(setq localname "~"))
|
|
|
|
|
(unless (file-name-absolute-p localname)
|
|
|
|
|
(setq localname (format "~%s/%s" user localname)))
|
2022-03-07 12:42:30 +00:00
|
|
|
|
(when (string-match "\\`~\\([^/]*\\)\\(.*\\)\\'" localname)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(let ((uname (match-string 1 localname))
|
2022-03-07 12:42:30 +00:00
|
|
|
|
(fname (match-string 2 localname))
|
|
|
|
|
hname)
|
|
|
|
|
(when (zerop (length uname))
|
|
|
|
|
(setq uname user))
|
|
|
|
|
(when (setq hname (tramp-get-home-directory v uname))
|
|
|
|
|
(setq localname (concat hname fname)))))
|
|
|
|
|
;; Do not keep "/..".
|
|
|
|
|
(when (string-match-p "^/\\.\\.?$" localname)
|
|
|
|
|
(setq localname "/"))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; Do normal `expand-file-name' (this does "~user/", "/./" and "/../").
|
2022-03-07 12:42:30 +00:00
|
|
|
|
(tramp-make-tramp-file-name
|
|
|
|
|
v (if (string-match-p "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname)
|
|
|
|
|
localname
|
|
|
|
|
(tramp-run-real-handler
|
|
|
|
|
#'expand-file-name (list localname))))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-remote-acl-p (vec)
|
|
|
|
|
"Check, whether ACL is enabled on the remote host."
|
2020-03-29 10:24:04 +00:00
|
|
|
|
(with-tramp-connection-property (tramp-get-process vec) "acl-p"
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(zerop (tramp-call-process vec "getfacl" nil nil nil "/"))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-file-acl (filename)
|
|
|
|
|
"Like `file-acl' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
|
|
|
|
(with-tramp-file-property v localname "file-acl"
|
|
|
|
|
(let ((result (and (tramp-sudoedit-remote-acl-p v)
|
|
|
|
|
(tramp-sudoedit-send-command-string
|
|
|
|
|
v "getfacl" "-acp"
|
|
|
|
|
(tramp-compat-file-name-unquote localname)))))
|
|
|
|
|
;; The acl string must have a trailing \n, which is not
|
|
|
|
|
;; provided by `tramp-sudoedit-send-command-string'. Add it.
|
|
|
|
|
(and (stringp result) (concat result "\n"))))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-file-attributes (filename &optional id-format)
|
|
|
|
|
"Like `file-attributes' for Tramp files."
|
|
|
|
|
(unless id-format (setq id-format 'integer))
|
|
|
|
|
(with-parsed-tramp-file-name (expand-file-name filename) nil
|
|
|
|
|
(with-tramp-file-property
|
|
|
|
|
v localname (format "file-attributes-%s" id-format)
|
|
|
|
|
(tramp-message v 5 "file attributes: %s" localname)
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(tramp-convert-file-attributes
|
|
|
|
|
v
|
|
|
|
|
(tramp-sudoedit-send-command-and-read
|
|
|
|
|
v "env" "QUOTING_STYLE=locale" "stat" "-c"
|
|
|
|
|
(format
|
|
|
|
|
;; Apostrophes in the stat output are masked as
|
|
|
|
|
;; `tramp-stat-marker', in order to make a proper shell
|
|
|
|
|
;; escape of them in file names.
|
|
|
|
|
"((%s%%N%s) %%h %s %s %%X %%Y %%Z %%s %s%%A%s t %%i -1)"
|
|
|
|
|
tramp-stat-marker tramp-stat-marker
|
|
|
|
|
(if (eq id-format 'integer)
|
|
|
|
|
"%u"
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(concat tramp-stat-marker "%U" tramp-stat-marker)))
|
|
|
|
|
(if (eq id-format 'integer)
|
|
|
|
|
"%g"
|
|
|
|
|
(eval-when-compile
|
|
|
|
|
(concat tramp-stat-marker "%G" tramp-stat-marker)))
|
|
|
|
|
tramp-stat-marker tramp-stat-marker)
|
|
|
|
|
(tramp-compat-file-name-unquote localname)))))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-file-executable-p (filename)
|
|
|
|
|
"Like `file-executable-p' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
|
|
|
|
(with-tramp-file-property v localname "file-executable-p"
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v "test" "-x" (tramp-compat-file-name-unquote localname)))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-file-exists-p (filename)
|
|
|
|
|
"Like `file-exists-p' for Tramp files."
|
2019-09-12 14:38:48 +00:00
|
|
|
|
;; `file-exists-p' is used as predicate in file name completion.
|
|
|
|
|
;; We don't want to run it when `non-essential' is t, or there is
|
|
|
|
|
;; no connection process yet.
|
|
|
|
|
(when (tramp-connectable-p filename)
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
|
|
|
|
(with-tramp-file-property v localname "file-exists-p"
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v "test" "-e" (tramp-compat-file-name-unquote localname))))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-file-name-all-completions (filename directory)
|
|
|
|
|
"Like `file-name-all-completions' for Tramp files."
|
|
|
|
|
(all-completions
|
|
|
|
|
filename
|
|
|
|
|
(with-parsed-tramp-file-name (expand-file-name directory) nil
|
|
|
|
|
(with-tramp-file-property v localname "file-name-all-completions"
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v "ls" "-a1" "--quoting-style=literal" "--show-control-chars"
|
|
|
|
|
(if (zerop (length localname))
|
|
|
|
|
"" (tramp-compat-file-name-unquote localname)))
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (f)
|
|
|
|
|
(if (file-directory-p (expand-file-name f directory))
|
|
|
|
|
(file-name-as-directory f)
|
|
|
|
|
f))
|
2021-12-06 18:36:15 +00:00
|
|
|
|
(delq
|
|
|
|
|
nil
|
|
|
|
|
(mapcar
|
|
|
|
|
(lambda (l) (and (not (string-match-p "^[[:space:]]*$" l)) l))
|
|
|
|
|
(split-string
|
|
|
|
|
(tramp-get-buffer-string (tramp-get-connection-buffer v))
|
|
|
|
|
"\n" 'omit))))))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-file-readable-p (filename)
|
|
|
|
|
"Like `file-readable-p' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
|
|
|
|
(with-tramp-file-property v localname "file-readable-p"
|
2021-10-18 17:54:13 +00:00
|
|
|
|
(or (tramp-handle-file-readable-p filename)
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v "test" "-r" (tramp-compat-file-name-unquote localname))))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
Add 'nofollow' flag to set-file-modes etc.
This avoids some race conditions (Bug#39683). E.g., if some other
program changes a file to a symlink between the time Emacs creates
the file and the time it changes the file’s permissions, using the
new flag prevents Emacs from inadvertently changing the
permissions of a victim in some completely unrelated directory.
* admin/merge-gnulib (GNULIB_MODULES): Add fchmodat.
* doc/lispref/files.texi (Testing Accessibility, Changing Files):
* doc/lispref/os.texi (File Notifications):
* etc/NEWS:
Adjust documentation accordingly.
* lib/chmodat.c, lib/fchmodat.c, lib/lchmod.c, m4/fchmodat.m4:
* m4/lchmod.m4: New files, copied from Gnulib.
* lib/gnulib.mk.in: Regenerate.
* lisp/dired-aux.el (dired-do-chmod):
* lisp/doc-view.el (doc-view-make-safe-dir):
* lisp/emacs-lisp/autoload.el (autoload--save-buffer):
* lisp/emacs-lisp/bytecomp.el (byte-compile-file):
* lisp/eshell/em-pred.el (eshell-pred-file-mode):
* lisp/files.el (backup-buffer-copy, copy-directory):
* lisp/gnus/mail-source.el (mail-source-movemail):
* lisp/gnus/mm-decode.el (mm-display-external):
* lisp/gnus/nnmail.el (nnmail-write-region):
* lisp/net/tramp-adb.el (tramp-adb-handle-file-local-copy)
(tramp-adb-handle-write-region):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-directly):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-write-region):
* lisp/net/tramp.el (tramp-handle-write-region)
(tramp-make-tramp-temp-file):
* lisp/server.el (server-ensure-safe-dir):
* lisp/url/url-util.el (url-make-private-file):
When getting or setting file modes, avoid following symbolic links
when the file is not supposed to be a symbolic link.
* lisp/doc-view.el (doc-view-make-safe-dir):
Omit no-longer-needed separate symlink test.
* lisp/gnus/gnus-util.el (gnus-set-file-modes):
* lisp/net/tramp.el (tramp-handle-file-modes):
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-set-file-modes):
* src/fileio.c (symlink_nofollow_flag): New function.
(Ffile_modes, Fset_file_modes):
Support an optional FLAG arg. All C callers changed.
* lisp/net/ange-ftp.el (ange-ftp-set-file-modes):
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-modes):
* lisp/net/tramp-sh.el (tramp-sh-handle-set-file-modes):
* lisp/net/tramp-smb.el (tramp-smb-handle-set-file-modes):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-set-file-modes):
Accept an optional FLAG arg that is currently ignored,
and add a FIXME comment for it.
* m4/gnulib-comp.m4: Regenerate.
2020-02-24 00:19:42 +00:00
|
|
|
|
(defun tramp-sudoedit-handle-set-file-modes (filename mode &optional flag)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
"Like `set-file-modes' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
2020-02-26 17:43:11 +00:00
|
|
|
|
;; It is unlikely that "chmod -h" works.
|
|
|
|
|
(unless (and (eq flag 'nofollow) (file-symlink-p filename))
|
|
|
|
|
(tramp-flush-file-properties v localname)
|
|
|
|
|
(unless (tramp-sudoedit-send-command
|
|
|
|
|
v "chmod" (format "%o" mode)
|
|
|
|
|
(tramp-compat-file-name-unquote localname))
|
|
|
|
|
(tramp-error
|
|
|
|
|
v 'file-error "Error while changing file's mode %s" filename)))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-remote-selinux-p (vec)
|
|
|
|
|
"Check, whether SELINUX is enabled on the remote host."
|
2020-03-29 10:24:04 +00:00
|
|
|
|
(with-tramp-connection-property (tramp-get-process vec) "selinux-p"
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(zerop (tramp-call-process vec "selinuxenabled"))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-file-selinux-context (filename)
|
|
|
|
|
"Like `file-selinux-context' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
|
|
|
|
(with-tramp-file-property v localname "file-selinux-context"
|
|
|
|
|
(let ((context '(nil nil nil nil))
|
2020-07-12 13:02:56 +00:00
|
|
|
|
(regexp (concat "\\([[:alnum:]_]+\\):" "\\([[:alnum:]_]+\\):"
|
|
|
|
|
"\\([[:alnum:]_]+\\):" "\\([[:alnum:]_]+\\)")))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(when (and (tramp-sudoedit-remote-selinux-p v)
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v "ls" "-d" "-Z"
|
|
|
|
|
(tramp-compat-file-name-unquote localname)))
|
|
|
|
|
(with-current-buffer (tramp-get-connection-buffer v)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(when (re-search-forward regexp (point-at-eol) t)
|
|
|
|
|
(setq context (list (match-string 1) (match-string 2)
|
|
|
|
|
(match-string 3) (match-string 4))))))
|
|
|
|
|
;; Return the context.
|
|
|
|
|
context))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-file-system-info (filename)
|
|
|
|
|
"Like `file-system-info' for Tramp files."
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(with-parsed-tramp-file-name (expand-file-name filename) nil
|
|
|
|
|
(tramp-message v 5 "file system info: %s" localname)
|
|
|
|
|
(when (tramp-sudoedit-send-command
|
|
|
|
|
v "df" "--block-size=1" "--output=size,used,avail"
|
2020-01-04 13:00:39 +00:00
|
|
|
|
(tramp-compat-file-name-unquote localname))
|
|
|
|
|
(with-current-buffer (tramp-get-connection-buffer v)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(forward-line)
|
|
|
|
|
(when (looking-at
|
2020-07-12 13:02:56 +00:00
|
|
|
|
(concat "[[:space:]]*\\([[:digit:]]+\\)"
|
|
|
|
|
"[[:space:]]+\\([[:digit:]]+\\)"
|
|
|
|
|
"[[:space:]]+\\([[:digit:]]+\\)"))
|
2020-01-04 13:00:39 +00:00
|
|
|
|
(list (string-to-number (match-string 1))
|
|
|
|
|
;; The second value is the used size. We need the
|
|
|
|
|
;; free size.
|
|
|
|
|
(- (string-to-number (match-string 1))
|
|
|
|
|
(string-to-number (match-string 2)))
|
|
|
|
|
(string-to-number (match-string 3)))))))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
Add ‘nofollow’ flag to set-file-times
This is a companion to the recent set-file-modes patch.
It adds support for a ‘nofollow’ flag to set-file-times (Bug#39773).
Like the set-file-modes patch, it needs work in the w32 port.
* admin/merge-gnulib (GNULIB_MODULES): Add futimens, utimensat.
Remove utimens.
* doc/lispref/files.texi (Changing Files):
* etc/NEWS: Mention the change.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lisp/files.el (copy-directory):
* lisp/gnus/gnus-cloud.el (gnus-cloud-replace-file):
* lisp/net/tramp-adb.el (tramp-adb-handle-copy-file):
* lisp/net/tramp-smb.el (tramp-smb-handle-copy-file):
* lisp/tar-mode.el (tar-copy):
* test/lisp/filenotify-tests.el (file-notify-test03-events):
* test/lisp/files-tests.el:
(files-tests-file-name-non-special-set-file-times):
* test/lisp/net/tramp-tests.el (tramp-test22-file-times):
When setting file times, avoid following symbolic links
when the file is not supposed to be a symbolic link.
* lib/futimens.c, lib/utimensat.c, m4/futimens.m4, m4/utimensat.m4:
New files, copied from Gnulib.
* lisp/gnus/gnus-cloud.el (gnus-cloud-replace-file):
When creating a file that is not supposed to exist already,
use the excl flag to check this.
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times):
* lisp/net/tramp-sh.el (tramp-sh-handle-set-file-times):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-set-file-times):
Accept an optional FLAG arg that is currently ignored,
and add a FIXME comment for it.
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-set-file-times):
* src/fileio.c (Fset_file_times):
Support an optional FLAG arg.
* src/fileio.c (Fcopy_file): Use futimens instead of set_file_times,
as it’s simpler and is a POSIX API.
* src/sysdep.c (set_file_times): Move from here ...
* src/w32.c (set_file_times): ... to here, and make it static,
since it is now used only in w32.c. Presumably w32.c should also
add support for futimens and utimensat (the POSIX APIs, which
Emacs now uses) and it can remove fdutimens (the Gnulib API,
which Emacs no longer uses).
2020-03-07 20:04:05 +00:00
|
|
|
|
(defun tramp-sudoedit-handle-set-file-times (filename &optional time flag)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
"Like `set-file-times' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
|
|
|
|
(tramp-flush-file-properties v localname)
|
|
|
|
|
(let ((time
|
|
|
|
|
(if (or (null time)
|
|
|
|
|
(tramp-compat-time-equal-p time tramp-time-doesnt-exist)
|
|
|
|
|
(tramp-compat-time-equal-p time tramp-time-dont-know))
|
2021-12-06 02:25:46 +00:00
|
|
|
|
nil
|
2018-12-16 14:49:07 +00:00
|
|
|
|
time)))
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v "env" "TZ=UTC" "touch" "-t"
|
|
|
|
|
(format-time-string "%Y%m%d%H%M.%S" time t)
|
2020-03-09 15:05:21 +00:00
|
|
|
|
(if (eq flag 'nofollow) "-h" "")
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(tramp-compat-file-name-unquote localname)))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-file-truename (filename)
|
|
|
|
|
"Like `file-truename' for Tramp files."
|
2019-08-12 14:18:59 +00:00
|
|
|
|
;; Preserve trailing "/".
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(funcall
|
Sync with Tramp 2.5.0-pre
* doc/misc/tramp.texi: Protext Tramp x.y and Emacs x.y by @w{}.
(GVFS-based methods): Move "GNOME Online Accounts" index.
(Customizing Methods, Android shell setup, File name completion)
(Frequently Asked Questions): Fix typos.
* doc/misc/trampver.texi: Change version to "2.5.0-pre".
* lisp/net/trampver.el: Change version to "2.5.0-pre".
(inhibit-message): Don't declare.
* lisp/net/tramp.el: Bump version to 2.5.0-pre. Require Emacs 25.1.
(tramp-debug-message): Simplify.
(tramp-message): Don't use `tramp-message-show-message'.
(tramp-with-demoted-errors, with-parsed-tramp-file-name)
(with-tramp-file-property, with-tramp-connection-property):
Adapt `declare' form.
(with-tramp-progress-reporter): Suppress progress reporter when
noninteractive.
(tramp-completion-mode, tramp-completion-mode-p): Remove.
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(format-message): Remove compatibility code.
(tramp-compat-directory-name-p)
(tramp-compat-tramp-file-name-slots): Remove.
* lisp/net/tramp.el (tramp-debug-message, tramp-message)
(tramp-backtrace, tramp-error, tramp-error-with-buffer)
(tramp-user-error, tramp-with-demoted-errors)
(tramp-signal-hook-function):
* lisp/net/tramp-compat.el (tramp-compat-funcall)
* lisp/net/tramp-gvfs.el (tramp-dbus-function):
Add `tramp-suppress-trace' property.
* lisp/net/tramp.el (tramp-get-method-parameter)
(tramp-dissect-file-name, tramp-error, tramp-error-with-buffer)
(tramp-user-error, with-parsed-tramp-file-name)
(with-tramp-progress-reporter, tramp-file-name-handler)
(tramp-completion-file-name-handler, tramp-autoload-file-name-handler)
(tramp-register-file-name-handlers, tramp-connectable-p)
(tramp-handle-file-modes, tramp-handle-file-regular-p)
(tramp-handle-file-truename, tramp-handle-insert-directory)
(tramp-handle-load, tramp-set-file-uid-gid):
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler)
(tramp-adb-handle-file-truename, tramp-adb-handle-copy-file)
(tramp-adb-handle-rename-file):
* lisp/net/tramp-archive.el (with-parsed-tramp-archive-file-name):
* lisp/net/tramp-cache.el (tramp-get-file-property, tramp-cache-print):
* lisp/net/tramp-compat.el (tramp-compat-process-running-p)
(tramp-compat-exec-path):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler)
(tramp-gvfs-dbus-byte-array-to-string)
(tramp-gvfs-do-copy-or-rename-file):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler)
(tramp-rclone-do-copy-or-rename-file):
* lisp/net/tramp-sh.el (tramp-sh-handle-file-truename)
(tramp-sh-handle-copy-directory, tramp-do-copy-or-rename-file)
(tramp-sh-handle-insert-directory, tramp-sh-file-name-handler)
(tramp-maybe-open-connection):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler)
(tramp-smb-handle-copy-file, tramp-smb-handle-copy-directory)
(tramp-smb-handle-copy-file, tramp-smb-handle-insert-directory)
(tramp-smb-handle-rename-file, tramp-smb-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler)
(tramp-sudoedit-do-copy-or-rename-file)
(tramp-sudoedit-handle-file-truename):
Use `if-let', `when-let', `directory-name-p', `inhibit-message',
`non-essential and `cl-struct-slot-info'. Don't use `seconds-to-time'.
* test/lisp/net/tramp-archive-tests.el (tramp-message-show-message):
Don't set.
* test/lisp/net/tramp-tests.el (inhibit-message): Don't declare.
(tramp-message-show-message): Don't set.
(tramp-test06-directory-file-name): Use `non-essential'.
(tramp-test10-write-region): Use `inhibit-message'.
(tramp-test36-vc-registered): No special handling for old Emacsen.
(tramp--test-emacs25-p): Remove.
(tramp-test45-unload): Special case of `tramp-completion-mode'.
2020-01-19 13:11:07 +00:00
|
|
|
|
(if (directory-name-p filename) #'file-name-as-directory #'identity)
|
2019-08-12 14:18:59 +00:00
|
|
|
|
;; Quote properly.
|
|
|
|
|
(funcall
|
|
|
|
|
(if (tramp-compat-file-name-quoted-p filename)
|
|
|
|
|
#'tramp-compat-file-name-quote #'identity)
|
|
|
|
|
(with-parsed-tramp-file-name
|
|
|
|
|
(tramp-compat-file-name-unquote (expand-file-name filename)) nil
|
|
|
|
|
(tramp-make-tramp-file-name
|
|
|
|
|
v
|
|
|
|
|
(with-tramp-file-property v localname "file-truename"
|
|
|
|
|
(let (result)
|
|
|
|
|
(tramp-message v 4 "Finding true name for `%s'" filename)
|
|
|
|
|
(setq result (tramp-sudoedit-send-command-string
|
|
|
|
|
v "readlink" "--canonicalize-missing" localname))
|
|
|
|
|
;; Detect cycle.
|
|
|
|
|
(when (and (file-symlink-p filename)
|
|
|
|
|
(string-equal result localname))
|
|
|
|
|
(tramp-error
|
|
|
|
|
v 'file-error
|
|
|
|
|
"Apparent cycle of symbolic links for %s" filename))
|
|
|
|
|
;; If the resulting localname looks remote, we must quote it
|
|
|
|
|
;; for security reasons.
|
|
|
|
|
(when (file-remote-p result)
|
|
|
|
|
(setq result (tramp-compat-file-name-quote result 'top)))
|
|
|
|
|
(tramp-message v 4 "True name of `%s' is `%s'" localname result)
|
2022-01-18 10:27:15 +00:00
|
|
|
|
result)))))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-file-writable-p (filename)
|
|
|
|
|
"Like `file-writable-p' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
|
|
|
|
(with-tramp-file-property v localname "file-writable-p"
|
|
|
|
|
(if (file-exists-p filename)
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v "test" "-w" (tramp-compat-file-name-unquote localname))
|
|
|
|
|
(let ((dir (file-name-directory filename)))
|
|
|
|
|
(and (file-exists-p dir)
|
|
|
|
|
(file-writable-p dir)))))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-make-directory (dir &optional parents)
|
|
|
|
|
"Like `make-directory' for Tramp files."
|
|
|
|
|
(setq dir (expand-file-name dir))
|
|
|
|
|
(with-parsed-tramp-file-name dir nil
|
2019-11-06 15:49:35 +00:00
|
|
|
|
(when (and (null parents) (file-exists-p dir))
|
|
|
|
|
(tramp-error v 'file-already-exists "Directory already exists %s" dir))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; When PARENTS is non-nil, DIR could be a chain of non-existent
|
|
|
|
|
;; directories a/b/c/... Instead of checking, we simply flush the
|
|
|
|
|
;; whole cache.
|
|
|
|
|
(tramp-flush-directory-properties
|
|
|
|
|
v (if parents "/" (file-name-directory localname)))
|
|
|
|
|
(unless (tramp-sudoedit-send-command
|
|
|
|
|
v (if parents '("mkdir" "-p") "mkdir")
|
2021-09-10 13:30:06 +00:00
|
|
|
|
"-m" (format "%#o" (default-file-modes))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(tramp-compat-file-name-unquote localname))
|
|
|
|
|
(tramp-error v 'file-error "Couldn't make directory %s" dir))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-make-symbolic-link
|
|
|
|
|
(target linkname &optional ok-if-already-exists)
|
|
|
|
|
"Like `make-symbolic-link' for Tramp files.
|
|
|
|
|
If TARGET is a non-Tramp file, it is used verbatim as the target
|
|
|
|
|
of the symlink. If TARGET is a Tramp file, only the localname
|
|
|
|
|
component is used as the target of the symlink."
|
|
|
|
|
(if (not (tramp-tramp-file-p (expand-file-name linkname)))
|
|
|
|
|
(tramp-run-real-handler
|
2019-02-28 09:33:05 +00:00
|
|
|
|
#'make-symbolic-link (list target linkname ok-if-already-exists))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(with-parsed-tramp-file-name linkname nil
|
|
|
|
|
;; If TARGET is a Tramp name, use just the localname component.
|
2019-06-04 10:51:45 +00:00
|
|
|
|
;; Don't check for a proper method.
|
|
|
|
|
(let ((non-essential t))
|
|
|
|
|
(when (and (tramp-tramp-file-p target)
|
|
|
|
|
(tramp-file-name-equal-p v (tramp-dissect-file-name target)))
|
2020-01-06 11:11:53 +00:00
|
|
|
|
(setq target (tramp-file-local-name (expand-file-name target)))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
;; If TARGET is still remote, quote it.
|
|
|
|
|
(if (tramp-tramp-file-p target)
|
2019-08-12 14:18:59 +00:00
|
|
|
|
(make-symbolic-link (tramp-compat-file-name-quote target 'top)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
linkname ok-if-already-exists)
|
|
|
|
|
|
|
|
|
|
;; Do the 'confirm if exists' thing.
|
|
|
|
|
(when (file-exists-p linkname)
|
|
|
|
|
;; What to do?
|
|
|
|
|
(if (or (null ok-if-already-exists) ; not allowed to exist
|
|
|
|
|
(and (numberp ok-if-already-exists)
|
|
|
|
|
(not
|
|
|
|
|
(yes-or-no-p
|
|
|
|
|
(format
|
2021-09-16 14:50:24 +00:00
|
|
|
|
"File %s already exists; make it a link anyway?"
|
2018-12-16 14:49:07 +00:00
|
|
|
|
localname)))))
|
|
|
|
|
(tramp-error v 'file-already-exists localname)
|
|
|
|
|
(delete-file linkname)))
|
|
|
|
|
|
|
|
|
|
(tramp-flush-file-properties v localname)
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v "ln" "-sf"
|
|
|
|
|
(tramp-compat-file-name-unquote target)
|
|
|
|
|
(tramp-compat-file-name-unquote localname))))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-rename-file
|
|
|
|
|
(filename newname &optional ok-if-already-exists)
|
|
|
|
|
"Like `rename-file' for Tramp files."
|
2020-01-24 13:41:44 +00:00
|
|
|
|
(setq filename (expand-file-name filename)
|
|
|
|
|
newname (expand-file-name newname))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; At least one file a Tramp file?
|
|
|
|
|
(if (or (tramp-tramp-file-p filename)
|
|
|
|
|
(tramp-tramp-file-p newname))
|
|
|
|
|
(tramp-sudoedit-do-copy-or-rename-file
|
|
|
|
|
'rename filename newname ok-if-already-exists
|
|
|
|
|
'keep-date 'preserve-uid-gid)
|
|
|
|
|
(tramp-run-real-handler
|
2021-05-22 15:51:07 +00:00
|
|
|
|
#'rename-file (list filename newname ok-if-already-exists))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-set-file-acl (filename acl-string)
|
|
|
|
|
"Like `set-file-acl' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name (expand-file-name filename) nil
|
|
|
|
|
(when (and (stringp acl-string) (tramp-sudoedit-remote-acl-p v))
|
|
|
|
|
;; Massage `acl-string'.
|
2019-06-28 14:32:12 +00:00
|
|
|
|
(setq acl-string (string-join (split-string acl-string "\n" 'omit) ","))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(prog1
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v "setfacl" "-m"
|
|
|
|
|
acl-string (tramp-compat-file-name-unquote localname))
|
|
|
|
|
(tramp-flush-file-property v localname "file-acl")))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-set-file-selinux-context (filename context)
|
|
|
|
|
"Like `set-file-selinux-context' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
|
|
|
|
(when (and (consp context)
|
|
|
|
|
(tramp-sudoedit-remote-selinux-p v))
|
|
|
|
|
(let ((user (and (stringp (nth 0 context)) (nth 0 context)))
|
|
|
|
|
(role (and (stringp (nth 1 context)) (nth 1 context)))
|
|
|
|
|
(type (and (stringp (nth 2 context)) (nth 2 context)))
|
|
|
|
|
(range (and (stringp (nth 3 context)) (nth 3 context))))
|
|
|
|
|
(when (tramp-sudoedit-send-command
|
2019-01-08 14:03:57 +00:00
|
|
|
|
v "chcon"
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(when user (format "--user=%s" user))
|
|
|
|
|
(when role (format "--role=%s" role))
|
|
|
|
|
(when type (format "--type=%s" type))
|
|
|
|
|
(when range (format "--range=%s" range))
|
|
|
|
|
(tramp-compat-file-name-unquote localname))
|
|
|
|
|
(if (and user role type range)
|
|
|
|
|
(tramp-set-file-property
|
|
|
|
|
v localname "file-selinux-context" context)
|
|
|
|
|
(tramp-flush-file-property v localname "file-selinux-context"))
|
|
|
|
|
t)))))
|
|
|
|
|
|
2022-03-07 12:42:30 +00:00
|
|
|
|
(defun tramp-sudoedit-handle-get-home-directory (vec &optional user)
|
|
|
|
|
"The remote home directory for connection VEC as local file name.
|
|
|
|
|
If USER is a string, return its home directory instead of the
|
|
|
|
|
user identified by VEC. If there is no user specified in either
|
|
|
|
|
VEC or USER, or if there is no home directory, return nil."
|
|
|
|
|
(expand-file-name (concat "~" (or user (tramp-file-name-user vec)))))
|
|
|
|
|
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(defun tramp-sudoedit-handle-get-remote-uid (vec id-format)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
"The uid of the remote connection VEC, in ID-FORMAT.
|
|
|
|
|
ID-FORMAT valid values are `string' and `integer'."
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(if (equal id-format 'integer)
|
|
|
|
|
(tramp-sudoedit-send-command-and-read vec "id" "-u")
|
|
|
|
|
(tramp-sudoedit-send-command-string vec "id" "-un")))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(defun tramp-sudoedit-handle-get-remote-gid (vec id-format)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
"The gid of the remote connection VEC, in ID-FORMAT.
|
|
|
|
|
ID-FORMAT valid values are `string' and `integer'."
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(if (equal id-format 'integer)
|
|
|
|
|
(tramp-sudoedit-send-command-and-read vec "id" "-g")
|
|
|
|
|
(tramp-sudoedit-send-command-string vec "id" "-gn")))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-set-file-uid-gid (filename &optional uid gid)
|
|
|
|
|
"Like `tramp-set-file-uid-gid' for Tramp files."
|
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
|
|
|
|
(tramp-sudoedit-send-command
|
|
|
|
|
v "chown"
|
|
|
|
|
(format "%d:%d"
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(or uid (tramp-get-remote-uid v 'integer))
|
|
|
|
|
(or gid (tramp-get-remote-gid v 'integer)))
|
2020-01-06 11:11:53 +00:00
|
|
|
|
(tramp-unquote-file-local-name filename))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-handle-write-region
|
|
|
|
|
(start end filename &optional append visit lockname mustbenew)
|
|
|
|
|
"Like `write-region' for Tramp files."
|
Implement file locks for remote files (Bug#49261)
* doc/lispref/files.texi (Magic File Names): Add file-locked-p,
lock-file and unlock-file.
* etc/NEWS: Tramp supports file locks now.
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-adb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-crypt-handle-file-locked-p, tramp-crypt-handle-lock-file)
(tramp-crypt-handle-unlock-file): New defun.
* lisp/net/tramp-fuse.el (tramp-fuse-mounted-p): Simplify.
(tramp-fuse-unmount): New defun.
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-gvfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-rclone-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sh-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-smb-handle-copy-directory): Use `sleep-for'.
(tramp-smb-handle-write-region): Handle LOCKNAME.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sshfs-handle-write-region): Handle LOCKNAME.
(tramp-sshfs-maybe-open-connection): Set "lock-pid" connection property.
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-sudoedit-maybe-open-connection):
Set "lock-pid" connection property.
* lisp/net/tramp.el (tramp-file-name-for-operation):
Add `file-locked-p', `lock-file' and `unlock-file'.
(tramp-make-lock-name, tramp-get-lock-file, tramp-get-lock-pid)
(tramp-handle-file-locked-p, tramp-handle-lock-file)
(tramp-handle-unlock-file): New defuns.
(tramp-lock-file-contents-regexp): New regexp.
(tramp-handle-write-region): Handle LOCKNAME.
* src/filelock.c (lock_file, unlock_file_body, Ffile_locked_p):
Call handler if exists.
(Flock_file, Funlock_file): New defuns.
(Qlock_file, Qunlock_file, Qfile_locked_p): Declare symbols.
(Slock_file, Sunlock_file): Declare subroutines.
* test/lisp/net/tramp-archive-tests.el
(tramp-archive-test40-make-nearby-temp-file)
(tramp-archive-test43-file-system-info): Rename.
* test/lisp/net/tramp-tests.el (top): Set `create-lockfiles' to nil.
(tramp--test-fuse-p): New defun.
(tramp-test14-delete-directory): Use it.
(tramp-test39-lock-file): New test.
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters)
(tramp-test41-special-characters-with-stat)
(tramp-test41-special-characters-with-perl)
(tramp-test41-special-characters-with-ls, tramp-test42-utf8)
(tramp-test42-utf8-with-stat, tramp-test42-utf8-with-perl)
(tramp-test42-utf8-with-ls, tramp-test43-file-system-info)
(tramp-test44-asynchronous-requests, tramp-test45-auto-load)
(tramp-test45-delay-load, tramp-test45-recursive-load)
(tramp-test45-remote-load-path, tramp-test46-unload): Rename.
(tramp--test-special-characters, tramp--test-utf8)
(tramp--test-asynchronous-requests-timeout): Modify docstring.
2021-07-07 16:36:53 +00:00
|
|
|
|
(setq filename (expand-file-name filename))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(with-parsed-tramp-file-name filename nil
|
Remove Emacs 25 compatibility from Tramp
* doc/misc/tramp.texi (Remote programs, Remote processes)
(Frequently Asked Questions): Adapt Emacs versions.
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.6.0-pre".
* lisp/net/tramp-adb.el (top): Don't use `tramp-compat-funcall' for
connection-local functions.
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-handle-temporary-file-directory)
(tramp-compat-temporary-file-directory-function)
(tramp-compat-file-attribute-type)
(tramp-compat-file-attribute-link-number)
(tramp-compat-file-attribute-user-id)
(tramp-compat-file-attribute-group-id)
(tramp-compat-file-attribute-access-time)
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-status-change-time)
(tramp-compat-file-attribute-size)
(tramp-compat-file-attribute-modes, tramp-file-missing)
(tramp-compat-file-missing, tramp-compat-file-local-name): Remove.
(tramp-compat-file-name-quoted-p, tramp-compat-file-name-quote)
(tramp-compat-file-name-unquote)
(tramp-compat-progress-reporter-update)
(tramp-compat-file-modes, tramp-compat-set-file-modes)
(tramp-compat-set-file-times, tramp-compat-directory-files)
(tramp-compat-directory-files-and-attributes): Adapt implementation.
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Adapt callees.
* lisp/net/tramp-crypt.el (tramp-crypt-config-file-name):
Expand file name.
* lisp/net/tramp-fuse.el (tramp-fuse-handle-file-readable-p): Remove.
* lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Don't check Emacs version.
(tramp-gvfs-handler-mounted-unmounted): Use `make-tramp-file-name'.
* lisp/net/tramp-integration.el (rfn-eshadow-overlay):
Remove declaration.
(top): Don't use `tramp-compat-funcall' for connection-local functions.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Use `tramp-rclone-handle-file-readable-p'.
(tramp-rclone-handle-file-readable-p): New defun.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Use `tramp-handle-file-readable-p'.
* lisp/net/tramp.el (tramp-temp-name-prefix, tramp-lookup-syntax):
Adapt docstring.
(tramp-set-connection-local-variables)
(tramp-set-connection-local-variables-for-buffer): Don't use
`tramp-compat-funcall' for connection-local functions.
(tramp-file-name-for-operation): Reorder list.
(tramp-handle-make-symbolic-link): Don't handle TARGET and
OK-IF-ALREADY-EXISTS.
(tramp-read-passwd): Don't use `read-passwd' any longer.
(top): Don't check for `interrupt-process-functions'.
* test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs26-p):
Remove.
(tramp-archive-test02-file-name-dissect): Use `make-tramp-file-name'.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-archive-test46-auto-load)
(tramp-archive-test46-delay-load): Rename.
* test/lisp/net/tramp-tests.el (dired-aux, seq): Require them.
(dired-compress, connection-local-criteria-alist)
(connection-local-profile-alist, async-shell-command-width):
Don't declare.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-test04-substitute-in-file-name)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test15-copy-directory)
(tramp-test17-insert-directory)
(tramp-test17-dired-with-wildcards, tramp-test21-file-links)
(tramp-test31-interrupt-process)
(tramp-test34-connection-local-variables)
(tramp-test34-explicit-shell-file-name)
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters, tramp-test42-utf8)
(tramp-test46-delay-load, tramp-test46-remote-load-path)
(tramp-test47-unload): Don't check for Emacs 26 special features.
(tramp--test-emacs26-p): Remove.
(tramp--test-emacs29-p): New defun.
(tramp-test45-dired-compress-file)
(tramp-test45-dired-compress-dir): Use it.
(tramp-test44-asynchronous-requests): Use `seq-random-elt'.
2021-11-12 17:17:32 +00:00
|
|
|
|
(let* ((uid (or (file-attribute-user-id (file-attributes filename 'integer))
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(tramp-get-remote-uid v 'integer)))
|
Remove Emacs 25 compatibility from Tramp
* doc/misc/tramp.texi (Remote programs, Remote processes)
(Frequently Asked Questions): Adapt Emacs versions.
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.6.0-pre".
* lisp/net/tramp-adb.el (top): Don't use `tramp-compat-funcall' for
connection-local functions.
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-handle-temporary-file-directory)
(tramp-compat-temporary-file-directory-function)
(tramp-compat-file-attribute-type)
(tramp-compat-file-attribute-link-number)
(tramp-compat-file-attribute-user-id)
(tramp-compat-file-attribute-group-id)
(tramp-compat-file-attribute-access-time)
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-status-change-time)
(tramp-compat-file-attribute-size)
(tramp-compat-file-attribute-modes, tramp-file-missing)
(tramp-compat-file-missing, tramp-compat-file-local-name): Remove.
(tramp-compat-file-name-quoted-p, tramp-compat-file-name-quote)
(tramp-compat-file-name-unquote)
(tramp-compat-progress-reporter-update)
(tramp-compat-file-modes, tramp-compat-set-file-modes)
(tramp-compat-set-file-times, tramp-compat-directory-files)
(tramp-compat-directory-files-and-attributes): Adapt implementation.
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Adapt callees.
* lisp/net/tramp-crypt.el (tramp-crypt-config-file-name):
Expand file name.
* lisp/net/tramp-fuse.el (tramp-fuse-handle-file-readable-p): Remove.
* lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Don't check Emacs version.
(tramp-gvfs-handler-mounted-unmounted): Use `make-tramp-file-name'.
* lisp/net/tramp-integration.el (rfn-eshadow-overlay):
Remove declaration.
(top): Don't use `tramp-compat-funcall' for connection-local functions.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Use `tramp-rclone-handle-file-readable-p'.
(tramp-rclone-handle-file-readable-p): New defun.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Use `tramp-handle-file-readable-p'.
* lisp/net/tramp.el (tramp-temp-name-prefix, tramp-lookup-syntax):
Adapt docstring.
(tramp-set-connection-local-variables)
(tramp-set-connection-local-variables-for-buffer): Don't use
`tramp-compat-funcall' for connection-local functions.
(tramp-file-name-for-operation): Reorder list.
(tramp-handle-make-symbolic-link): Don't handle TARGET and
OK-IF-ALREADY-EXISTS.
(tramp-read-passwd): Don't use `read-passwd' any longer.
(top): Don't check for `interrupt-process-functions'.
* test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs26-p):
Remove.
(tramp-archive-test02-file-name-dissect): Use `make-tramp-file-name'.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-archive-test46-auto-load)
(tramp-archive-test46-delay-load): Rename.
* test/lisp/net/tramp-tests.el (dired-aux, seq): Require them.
(dired-compress, connection-local-criteria-alist)
(connection-local-profile-alist, async-shell-command-width):
Don't declare.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-test04-substitute-in-file-name)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test15-copy-directory)
(tramp-test17-insert-directory)
(tramp-test17-dired-with-wildcards, tramp-test21-file-links)
(tramp-test31-interrupt-process)
(tramp-test34-connection-local-variables)
(tramp-test34-explicit-shell-file-name)
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters, tramp-test42-utf8)
(tramp-test46-delay-load, tramp-test46-remote-load-path)
(tramp-test47-unload): Don't check for Emacs 26 special features.
(tramp--test-emacs26-p): Remove.
(tramp--test-emacs29-p): New defun.
(tramp-test45-dired-compress-file)
(tramp-test45-dired-compress-dir): Use it.
(tramp-test44-asynchronous-requests): Use `seq-random-elt'.
2021-11-12 17:17:32 +00:00
|
|
|
|
(gid (or (file-attribute-group-id (file-attributes filename 'integer))
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(tramp-get-remote-gid v 'integer)))
|
2020-02-25 12:25:57 +00:00
|
|
|
|
(flag (and (eq mustbenew 'excl) 'nofollow))
|
2021-07-25 12:14:49 +00:00
|
|
|
|
(modes (tramp-default-file-modes filename flag))
|
|
|
|
|
(attributes (file-extended-attributes filename)))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(prog1
|
|
|
|
|
(tramp-handle-write-region
|
|
|
|
|
start end filename append visit lockname mustbenew)
|
|
|
|
|
|
2021-07-25 12:14:49 +00:00
|
|
|
|
;; Set the ownership, modes and extended attributes. This is
|
|
|
|
|
;; not performed in `tramp-handle-write-region'.
|
Remove Emacs 25 compatibility from Tramp
* doc/misc/tramp.texi (Remote programs, Remote processes)
(Frequently Asked Questions): Adapt Emacs versions.
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.6.0-pre".
* lisp/net/tramp-adb.el (top): Don't use `tramp-compat-funcall' for
connection-local functions.
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-handle-temporary-file-directory)
(tramp-compat-temporary-file-directory-function)
(tramp-compat-file-attribute-type)
(tramp-compat-file-attribute-link-number)
(tramp-compat-file-attribute-user-id)
(tramp-compat-file-attribute-group-id)
(tramp-compat-file-attribute-access-time)
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-status-change-time)
(tramp-compat-file-attribute-size)
(tramp-compat-file-attribute-modes, tramp-file-missing)
(tramp-compat-file-missing, tramp-compat-file-local-name): Remove.
(tramp-compat-file-name-quoted-p, tramp-compat-file-name-quote)
(tramp-compat-file-name-unquote)
(tramp-compat-progress-reporter-update)
(tramp-compat-file-modes, tramp-compat-set-file-modes)
(tramp-compat-set-file-times, tramp-compat-directory-files)
(tramp-compat-directory-files-and-attributes): Adapt implementation.
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Adapt callees.
* lisp/net/tramp-crypt.el (tramp-crypt-config-file-name):
Expand file name.
* lisp/net/tramp-fuse.el (tramp-fuse-handle-file-readable-p): Remove.
* lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Don't check Emacs version.
(tramp-gvfs-handler-mounted-unmounted): Use `make-tramp-file-name'.
* lisp/net/tramp-integration.el (rfn-eshadow-overlay):
Remove declaration.
(top): Don't use `tramp-compat-funcall' for connection-local functions.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Use `tramp-rclone-handle-file-readable-p'.
(tramp-rclone-handle-file-readable-p): New defun.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Use `tramp-handle-file-readable-p'.
* lisp/net/tramp.el (tramp-temp-name-prefix, tramp-lookup-syntax):
Adapt docstring.
(tramp-set-connection-local-variables)
(tramp-set-connection-local-variables-for-buffer): Don't use
`tramp-compat-funcall' for connection-local functions.
(tramp-file-name-for-operation): Reorder list.
(tramp-handle-make-symbolic-link): Don't handle TARGET and
OK-IF-ALREADY-EXISTS.
(tramp-read-passwd): Don't use `read-passwd' any longer.
(top): Don't check for `interrupt-process-functions'.
* test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs26-p):
Remove.
(tramp-archive-test02-file-name-dissect): Use `make-tramp-file-name'.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-archive-test46-auto-load)
(tramp-archive-test46-delay-load): Rename.
* test/lisp/net/tramp-tests.el (dired-aux, seq): Require them.
(dired-compress, connection-local-criteria-alist)
(connection-local-profile-alist, async-shell-command-width):
Don't declare.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-test04-substitute-in-file-name)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test15-copy-directory)
(tramp-test17-insert-directory)
(tramp-test17-dired-with-wildcards, tramp-test21-file-links)
(tramp-test31-interrupt-process)
(tramp-test34-connection-local-variables)
(tramp-test34-explicit-shell-file-name)
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters, tramp-test42-utf8)
(tramp-test46-delay-load, tramp-test46-remote-load-path)
(tramp-test47-unload): Don't check for Emacs 26 special features.
(tramp--test-emacs26-p): Remove.
(tramp--test-emacs29-p): New defun.
(tramp-test45-dired-compress-file)
(tramp-test45-dired-compress-dir): Use it.
(tramp-test44-asynchronous-requests): Use `seq-random-elt'.
2021-11-12 17:17:32 +00:00
|
|
|
|
(unless (and (= (file-attribute-user-id
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(file-attributes filename 'integer))
|
|
|
|
|
uid)
|
Remove Emacs 25 compatibility from Tramp
* doc/misc/tramp.texi (Remote programs, Remote processes)
(Frequently Asked Questions): Adapt Emacs versions.
* doc/misc/trampver.texi:
* lisp/net/trampver.el: Change version to "2.6.0-pre".
* lisp/net/tramp-adb.el (top): Don't use `tramp-compat-funcall' for
connection-local functions.
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-handle-temporary-file-directory)
(tramp-compat-temporary-file-directory-function)
(tramp-compat-file-attribute-type)
(tramp-compat-file-attribute-link-number)
(tramp-compat-file-attribute-user-id)
(tramp-compat-file-attribute-group-id)
(tramp-compat-file-attribute-access-time)
(tramp-compat-file-attribute-modification-time)
(tramp-compat-file-attribute-status-change-time)
(tramp-compat-file-attribute-size)
(tramp-compat-file-attribute-modes, tramp-file-missing)
(tramp-compat-file-missing, tramp-compat-file-local-name): Remove.
(tramp-compat-file-name-quoted-p, tramp-compat-file-name-quote)
(tramp-compat-file-name-unquote)
(tramp-compat-progress-reporter-update)
(tramp-compat-file-modes, tramp-compat-set-file-modes)
(tramp-compat-set-file-times, tramp-compat-directory-files)
(tramp-compat-directory-files-and-attributes): Adapt implementation.
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Adapt callees.
* lisp/net/tramp-crypt.el (tramp-crypt-config-file-name):
Expand file name.
* lisp/net/tramp-fuse.el (tramp-fuse-handle-file-readable-p): Remove.
* lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Don't check Emacs version.
(tramp-gvfs-handler-mounted-unmounted): Use `make-tramp-file-name'.
* lisp/net/tramp-integration.el (rfn-eshadow-overlay):
Remove declaration.
(top): Don't use `tramp-compat-funcall' for connection-local functions.
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
Use `tramp-rclone-handle-file-readable-p'.
(tramp-rclone-handle-file-readable-p): New defun.
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
Use `tramp-handle-file-readable-p'.
* lisp/net/tramp.el (tramp-temp-name-prefix, tramp-lookup-syntax):
Adapt docstring.
(tramp-set-connection-local-variables)
(tramp-set-connection-local-variables-for-buffer): Don't use
`tramp-compat-funcall' for connection-local functions.
(tramp-file-name-for-operation): Reorder list.
(tramp-handle-make-symbolic-link): Don't handle TARGET and
OK-IF-ALREADY-EXISTS.
(tramp-read-passwd): Don't use `read-passwd' any longer.
(top): Don't check for `interrupt-process-functions'.
* test/lisp/net/tramp-archive-tests.el (tramp-archive--test-emacs26-p):
Remove.
(tramp-archive-test02-file-name-dissect): Use `make-tramp-file-name'.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-archive-test46-auto-load)
(tramp-archive-test46-delay-load): Rename.
* test/lisp/net/tramp-tests.el (dired-aux, seq): Require them.
(dired-compress, connection-local-criteria-alist)
(connection-local-profile-alist, async-shell-command-width):
Don't declare.
(all): Replace Emacs 26 compatibility functions with their
original name.
(tramp-test04-substitute-in-file-name)
(tramp-test10-write-region, tramp-test11-copy-file)
(tramp-test12-rename-file, tramp-test15-copy-directory)
(tramp-test17-insert-directory)
(tramp-test17-dired-with-wildcards, tramp-test21-file-links)
(tramp-test31-interrupt-process)
(tramp-test34-connection-local-variables)
(tramp-test34-explicit-shell-file-name)
(tramp-test40-make-nearby-temp-file)
(tramp-test41-special-characters, tramp-test42-utf8)
(tramp-test46-delay-load, tramp-test46-remote-load-path)
(tramp-test47-unload): Don't check for Emacs 26 special features.
(tramp--test-emacs26-p): Remove.
(tramp--test-emacs29-p): New defun.
(tramp-test45-dired-compress-file)
(tramp-test45-dired-compress-dir): Use it.
(tramp-test44-asynchronous-requests): Use `seq-random-elt'.
2021-11-12 17:17:32 +00:00
|
|
|
|
(= (file-attribute-group-id
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(file-attributes filename 'integer))
|
|
|
|
|
gid))
|
|
|
|
|
(tramp-set-file-uid-gid filename uid gid))
|
2021-07-25 12:14:49 +00:00
|
|
|
|
(tramp-compat-set-file-modes filename modes flag)
|
|
|
|
|
;; We ignore possible errors, because ACL strings could be
|
|
|
|
|
;; incompatible.
|
|
|
|
|
(when attributes
|
|
|
|
|
(ignore-errors
|
|
|
|
|
(set-file-extended-attributes filename attributes)))))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; Internal functions.
|
|
|
|
|
|
|
|
|
|
;; Used in `tramp-sudoedit-sudo-actions'.
|
|
|
|
|
(defun tramp-sudoedit-action-sudo (proc vec)
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
"Check, whether a sudo process has finished. Remove unneeded output."
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; There might be pending output for the exit status.
|
2019-01-29 16:25:36 +00:00
|
|
|
|
(unless (process-live-p proc)
|
2019-01-28 15:33:27 +00:00
|
|
|
|
(while (tramp-accept-process-output proc 0))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; Delete narrowed region, it would be in the way reading a Lisp form.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(widen)
|
|
|
|
|
(delete-region (point-min) (point))
|
|
|
|
|
;; Delete empty lines.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (and (not (eobp)) (= (point) (point-at-eol)))
|
|
|
|
|
(forward-line))
|
|
|
|
|
(delete-region (point-min) (point))
|
|
|
|
|
(tramp-message vec 3 "Process has finished.")
|
|
|
|
|
(throw 'tramp-action 'ok)))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-maybe-open-connection (vec)
|
|
|
|
|
"Maybe open a connection VEC.
|
|
|
|
|
Does not do anything if a connection is already open, but re-opens the
|
|
|
|
|
connection if a previous connection has died for some reason."
|
2019-09-12 14:38:48 +00:00
|
|
|
|
;; During completion, don't reopen a new connection.
|
|
|
|
|
(unless (tramp-connectable-p vec)
|
|
|
|
|
(throw 'non-essential 'non-essential))
|
|
|
|
|
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; We need a process bound to the connection buffer. Therefore, we
|
|
|
|
|
;; create a dummy process. Maybe there is a better solution?
|
|
|
|
|
(unless (tramp-get-connection-process vec)
|
|
|
|
|
(let ((p (make-network-process
|
2019-06-04 10:51:45 +00:00
|
|
|
|
:name (tramp-get-connection-name vec)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
:buffer (tramp-get-connection-buffer vec)
|
|
|
|
|
:server t :host 'local :service t :noquery t)))
|
|
|
|
|
(process-put p 'vector vec)
|
|
|
|
|
(set-process-query-on-exit-flag p nil)
|
|
|
|
|
|
|
|
|
|
;; Set connection-local variables.
|
2019-02-06 08:07:39 +00:00
|
|
|
|
(tramp-set-connection-local-variables vec)
|
|
|
|
|
|
|
|
|
|
;; Mark it as connected.
|
2020-06-14 13:31:17 +00:00
|
|
|
|
(tramp-set-connection-property p "connected" t))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-send-command (vec &rest args)
|
|
|
|
|
"Send commands ARGS to connection VEC.
|
|
|
|
|
If an element of ARGS is a list, it will be flattened. If an
|
|
|
|
|
element of ARGS is nil, it will be deleted.
|
|
|
|
|
Erases temporary buffer before sending the command. Returns nil
|
|
|
|
|
in case of error, t otherwise."
|
|
|
|
|
(tramp-sudoedit-maybe-open-connection vec)
|
|
|
|
|
(with-current-buffer (tramp-get-connection-buffer vec)
|
|
|
|
|
(erase-buffer)
|
Add remote processes to Tramp sshfs method
* doc/misc/tramp.texi (FUSE setup): Method sshfs supports also
remote processes.
* lisp/net/tramp-cache.el (tramp-get-file-property)
(tramp-set-file-property): Move setting of
`tramp-cache-unload-hook' out of function.
* lisp/net/tramp.el (tramp-expand-args): New defun.
(tramp-handle-make-process):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band)
(tramp-maybe-open-connection):
* lisp/net/tramp-sshfs.el (tramp-sshfs-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-send-command): Use it.
* lisp/net/tramp-sshfs.el (tramp-methods) <sshfs>:
Adapt `tramp-mount-args'. Add `tramp-login-args',
`tramp-direct-async', `tramp-remote-shell',
`tramp-remote-shell-login' and `tramp-remote-shell-args'.
(tramp-connection-properties): Set "direct-async-process" fir sshfs.
(tramp-sshfs-file-name-handler-alist): Add `exec-path',
`make-process', `process-file', `set-file-modes', `shell-command',
`start-file-process', `tramp-get-remote-gid',
`tramp-get-remote-uid' and `tramp-set-file-uid-gid'.
(tramp-sshfs-handle-exec-path, tramp-sshfs-handle-process-file)
(tramp-sshfs-handle-set-file-modes): New defuns.
* test/lisp/net/tramp-tests.el (tramp-test20-file-modes)
(tramp-test28-process-file, tramp-test29-start-file-process)
(tramp-test30-make-process, tramp-test32-shell-command)
(tramp-test32-shell-command-dont-erase-buffer)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test43-asynchronous-requests): Run also for tramp-sshfs.
(tramp--test-shell-file-name): New defun.
(tramp-test28-process-file)
(tramp-test34-explicit-shell-file-name)
(tramp-test43-asynchronous-requests): Use it.
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls): Remove superfluous skip.
2021-03-11 16:16:50 +00:00
|
|
|
|
(let* ((delete-exited-processes t)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(process-connection-type tramp-process-connection-type)
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(p (apply #'start-process
|
Add remote processes to Tramp sshfs method
* doc/misc/tramp.texi (FUSE setup): Method sshfs supports also
remote processes.
* lisp/net/tramp-cache.el (tramp-get-file-property)
(tramp-set-file-property): Move setting of
`tramp-cache-unload-hook' out of function.
* lisp/net/tramp.el (tramp-expand-args): New defun.
(tramp-handle-make-process):
* lisp/net/tramp-sh.el (tramp-do-copy-or-rename-file-out-of-band)
(tramp-maybe-open-connection):
* lisp/net/tramp-sshfs.el (tramp-sshfs-maybe-open-connection):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-send-command): Use it.
* lisp/net/tramp-sshfs.el (tramp-methods) <sshfs>:
Adapt `tramp-mount-args'. Add `tramp-login-args',
`tramp-direct-async', `tramp-remote-shell',
`tramp-remote-shell-login' and `tramp-remote-shell-args'.
(tramp-connection-properties): Set "direct-async-process" fir sshfs.
(tramp-sshfs-file-name-handler-alist): Add `exec-path',
`make-process', `process-file', `set-file-modes', `shell-command',
`start-file-process', `tramp-get-remote-gid',
`tramp-get-remote-uid' and `tramp-set-file-uid-gid'.
(tramp-sshfs-handle-exec-path, tramp-sshfs-handle-process-file)
(tramp-sshfs-handle-set-file-modes): New defuns.
* test/lisp/net/tramp-tests.el (tramp-test20-file-modes)
(tramp-test28-process-file, tramp-test29-start-file-process)
(tramp-test30-make-process, tramp-test32-shell-command)
(tramp-test32-shell-command-dont-erase-buffer)
(tramp-test34-explicit-shell-file-name, tramp-test35-exec-path)
(tramp-test43-asynchronous-requests): Run also for tramp-sshfs.
(tramp--test-shell-file-name): New defun.
(tramp-test28-process-file)
(tramp-test34-explicit-shell-file-name)
(tramp-test43-asynchronous-requests): Use it.
(tramp-test40-special-characters-with-stat)
(tramp-test40-special-characters-with-perl)
(tramp-test40-special-characters-with-ls)
(tramp-test41-utf8-with-stat, tramp-test41-utf8-with-perl)
(tramp-test41-utf8-with-ls): Remove superfluous skip.
2021-03-11 16:16:50 +00:00
|
|
|
|
(tramp-get-connection-name vec) (current-buffer)
|
|
|
|
|
(append
|
|
|
|
|
(tramp-expand-args
|
|
|
|
|
vec 'tramp-sudo-login
|
|
|
|
|
?h (or (tramp-file-name-host vec) "")
|
|
|
|
|
?u (or (tramp-file-name-user vec) ""))
|
|
|
|
|
(tramp-compat-flatten-tree args))))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; We suppress the messages `Waiting for prompts from remote shell'.
|
|
|
|
|
(tramp-verbose (if (= tramp-verbose 3) 2 tramp-verbose))
|
2021-07-26 07:55:30 +00:00
|
|
|
|
;; The password shall be cached also in case of "emacs -Q".
|
|
|
|
|
;; See `tramp-process-actions'.
|
|
|
|
|
(tramp-cache-read-persistent-data t)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; We do not want to save the password.
|
|
|
|
|
auth-source-save-behavior)
|
2019-06-28 14:32:12 +00:00
|
|
|
|
(tramp-message vec 6 "%s" (string-join (process-command p) " "))
|
2018-12-16 14:49:07 +00:00
|
|
|
|
;; Avoid process status message in output buffer.
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(set-process-sentinel p #'ignore)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(process-put p 'vector vec)
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(process-put p 'adjust-window-size-function #'ignore)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(set-process-query-on-exit-flag p nil)
|
2022-02-19 17:38:12 +00:00
|
|
|
|
(tramp-set-connection-property p "password-vector" tramp-sudoedit-null-hop)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(tramp-process-actions p vec nil tramp-sudoedit-sudo-actions)
|
|
|
|
|
(tramp-message vec 6 "%s\n%s" (process-exit-status p) (buffer-string))
|
|
|
|
|
(prog1
|
|
|
|
|
(zerop (process-exit-status p))
|
|
|
|
|
(delete-process p)))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-send-command-and-read (vec &rest args)
|
|
|
|
|
"Run command ARGS and return the output, which must be a Lisp expression.
|
|
|
|
|
In case there is no valid Lisp expression, it raises an error."
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(when (apply #'tramp-sudoedit-send-command vec args)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(with-current-buffer (tramp-get-connection-buffer vec)
|
|
|
|
|
;; Replace stat marker.
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(when (search-forward tramp-stat-marker nil t)
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (search-forward "\"" nil t)
|
|
|
|
|
(replace-match "\\\"" nil 'literal))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(while (search-forward tramp-stat-marker nil t)
|
|
|
|
|
(replace-match "\"")))
|
|
|
|
|
;; Read the expression.
|
|
|
|
|
(tramp-message vec 6 "\n%s" (buffer-string))
|
|
|
|
|
(goto-char (point-min))
|
|
|
|
|
(condition-case nil
|
|
|
|
|
(prog1 (read (current-buffer))
|
|
|
|
|
;; Error handling.
|
|
|
|
|
(when (re-search-forward "\\S-" (point-at-eol) t)
|
|
|
|
|
(error nil)))
|
|
|
|
|
(error (tramp-error
|
|
|
|
|
vec 'file-error
|
|
|
|
|
"`%s' does not return a valid Lisp expression: `%s'"
|
|
|
|
|
(car args) (buffer-string)))))))
|
|
|
|
|
|
|
|
|
|
(defun tramp-sudoedit-send-command-string (vec &rest args)
|
Adapt Tramp docstrings according to checkdoc
* lisp/net/tramp.el (tramp-backup-directory-alist)
(tramp-echoed-echo-mark-regexp, tramp-syntax-values)
(tramp-lookup-syntax, tramp-build-prefix-format)
(tramp-build-prefix-regexp, tramp-build-method-regexp)
(tramp-build-postfix-method-format)
(tramp-build-postfix-method-regexp)
(tramp-build-prefix-ipv6-format, tramp-build-prefix-ipv6-regexp)
(tramp-build-postfix-ipv6-format)
(tramp-build-postfix-ipv6-regexp)
(tramp-build-postfix-host-format)
(tramp-build-postfix-host-regexp, tramp-unknown-id-string)
(tramp-unknown-id-integer, tramp-build-file-name-regexp)
(tramp-build-completion-file-name-regexp, tramp-chunksize)
(tramp-find-method, tramp-find-user, tramp-find-host)
(tramp-dissect-file-name, tramp-get-buffer)
(tramp-get-connection-buffer, tramp-debug-message, tramp-error)
(with-tramp-connection-property, tramp-run-real-handler)
(tramp-file-name-for-operation, tramp-file-name-handler)
(tramp-completion-file-name-handler)
(tramp-completion-handle-file-name-completion)
(tramp-completion-dissect-file-name)
(tramp-completion-dissect-file-name1)
(tramp-handle-file-name-as-directory)
(tramp-handle-file-name-directory)
(tramp-handle-file-name-nondirectory, tramp-mode-string-to-int)
(tramp-file-mode-from-int):
* lisp/net/tramp-adb.el (tramp-adb-file-name-p):
* lisp/net/tramp-archive.el (tramp-archive-run-real-handler)
(tramp-archive-file-name-handler)
(tramp-archive-dissect-file-name)
(with-parsed-tramp-archive-file-name)
(tramp-archive-gvfs-file-name, tramp-archive-handle-access-file):
* lisp/net/tramp-cmds.el (tramp-list-remote-buffers):
* lisp/net/tramp-compat.el (tramp-unload-file-name-handlers)
(tramp-compat-funcall, tramp-compat-tramp-file-name-slots):
* lisp/net/tramp-ftp.el (tramp-ftp-file-name-handler)
(tramp-ftp-file-name-p):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-p)
(tramp-gvfs-file-name-handler)
(tramp-gvfs-stringify-dbus-message)
(tramp-gvfs-monitor-process-filter)
(tramp-gvfs-handler-mounted-unmounted):
* lisp/net/tramp-integration.el
(tramp-rfn-eshadow-update-overlay-regexp):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-p)
(tramp-rclone-file-name-handler, tramp-rclone-send-command):
* lisp/net/tramp-sh.el (tramp-sh--quoting-style-options)
(tramp-sh-gio-monitor-process-filter)
(tramp-sh-gvfs-monitor-dir-process-filter)
(tramp-sh-inotifywait-process-filter, tramp-find-executable)
(tramp-set-remote-path, tramp-open-shell, tramp-find-shell)
(tramp-send-command-and-check, tramp-shell-case-fold)
(tramp-get-remote-path):
* lisp/net/tramp-smb.el (tramp-smb-file-name-p)
(tramp-smb-file-name-handler)
(tramp-smb-do-file-attributes-with-stat)
(tramp-smb-handle-substitute-in-file-name)
(tramp-smb-get-stat-capability, tramp-smb-shell-quote-argument):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-p)
(tramp-sudoedit-file-name-handler)
(tramp-sudoedit-send-command-string):
* test/lisp/net/tramp-archive-tests.el (tramp-archive-test-all):
* test/lisp/net/tramp-tests.el (tramp--test-gvfs-p)
(tramp--test-with-proper-process-name-and-buffer)
(tramp-test-all): Adapt docstrings according to `checkdoc'.
2019-11-13 12:10:58 +00:00
|
|
|
|
"Run command ARGS and return the output as a string."
|
* lisp/net/tramp: Rework mutual dependencies
Functionally split tramp-loaddefs.el into two parts: one part run
while loading it at the very beginning of loading tramp.el (holding plain
autoloads and declarations), and another run at the very end of loading
tramp.el (holding setup code).
This should reduce infinite-recursion problems while loading.
* lisp/net/tramp.el: Require tramp-loaddefs at beginning.
Run (new and internal) tramp--startup-hook at the end.
Remove all tramp-autoloads. Prefer tramp--with-startup over
eval-after-load.
(tramp--with-startup): New macro.
(tramp-set-syntax): Show the new value rather than the old value in the
error message.
(tramp-syntax-values): Explicitly return 'values'.
(tramp-prefix-format, tramp-prefix-regexp, tramp-method-regexp)
(tramp-postfix-method-format, tramp-postfix-method-regexp)
(tramp-prefix-ipv6-format, tramp-prefix-ipv6-regexp)
(tramp-postfix-ipv6-format, tramp-postfix-ipv6-regexp)
(tramp-postfix-host-format, tramp-postfix-host-regexp)
(tramp-remote-file-name-spec-regexp, tramp-file-name-structure)
(tramp-completion-file-name-regexp): Don't initialize in the declaration,
since it's recomputed at the end anyway.
(tramp-time-dont-know, tramp-time-doesnt-exist): Move before first use.
* lisp/net/tramp-compat.el: Don't require tramp-loaddefs any more.
(tramp-compat-tramp-syntax): Declare tramp-syntax.
* lisp/net/tramp-smb.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-adb.el: Wrap all autoloaded setup operations within
tramp--with-startup.
* lisp/net/tramp-sh.el: Wrap all autoloaded setup operations within
tramp--with-startup.
(tramp-display-escape-sequence-regexp)
(tramp-device-escape-sequence-regexp): Don't tramp-autoload any more.
(tramp-stat-marker): Use eval-and-compile rather than tramp-autoload.
* lisp/net/tramp-sudoedit.el: Wrap all autoloaded setup operations within
tramp--with-startup.
Require tramp-sh at compile-time to precompute some regexps based on
tramp-stat-marker.
2018-12-16 15:32:53 +00:00
|
|
|
|
(when (apply #'tramp-sudoedit-send-command vec args)
|
2018-12-16 14:49:07 +00:00
|
|
|
|
(with-current-buffer (tramp-get-connection-buffer vec)
|
|
|
|
|
(tramp-message vec 6 "\n%s" (buffer-string))
|
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
;(delete-blank-lines)
|
|
|
|
|
(while (looking-back "[ \t\n]+" nil 'greedy)
|
|
|
|
|
(delete-region (match-beginning 0) (point)))
|
|
|
|
|
(when (> (point-max) (point-min))
|
|
|
|
|
(substring-no-properties (buffer-string))))))
|
|
|
|
|
|
|
|
|
|
(add-hook 'tramp-unload-hook
|
|
|
|
|
(lambda ()
|
|
|
|
|
(unload-feature 'tramp-sudoedit 'force)))
|
|
|
|
|
|
|
|
|
|
(provide 'tramp-sudoedit)
|
|
|
|
|
|
|
|
|
|
;;; TODO:
|
|
|
|
|
|
|
|
|
|
;; * Fix *-selinux functions. Likely, this is due to wrong file
|
|
|
|
|
;; ownership after `write-region' and/or `copy-file'.
|
|
|
|
|
|
|
|
|
|
;;; tramp-sudoedit.el ends here
|