diff options
| author | Vibhav Pant | 2020-08-21 14:04:35 +0530 |
|---|---|---|
| committer | Vibhav Pant | 2020-08-21 14:04:35 +0530 |
| commit | f0f8d7b82492e741950c363a03b886965c91b1b0 (patch) | |
| tree | 19b716830b1ebabc0d7d75949c4e6800c0f104ad /lisp/net | |
| parent | 9e64a087c4d167e7ec1c4e22bea3e6af53b563de (diff) | |
| parent | c818c29771d3cb51875643b2f6c894073e429dd2 (diff) | |
| download | emacs-feature/native-comp-macos-fixes.tar.gz emacs-feature/native-comp-macos-fixes.zip | |
Merge branch 'feature/native-comp' into feature/native-comp-macos-fixesfeature/native-comp-macos-fixes
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/eudc-bob.el | 130 | ||||
| -rw-r--r-- | lisp/net/eww.el | 25 | ||||
| -rw-r--r-- | lisp/net/newst-treeview.el | 30 | ||||
| -rw-r--r-- | lisp/net/ntlm.el | 44 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 98 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 103 |
6 files changed, 190 insertions, 240 deletions
diff --git a/lisp/net/eudc-bob.el b/lisp/net/eudc-bob.el index 56ea033a963..bb6682520ae 100644 --- a/lisp/net/eudc-bob.el +++ b/lisp/net/eudc-bob.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; eudc-bob.el --- Binary Objects Support for EUDC | 1 | ;;; eudc-bob.el --- Binary Objects Support for EUDC -*- lexical-binding: t; -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1999-2020 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1999-2020 Free Software Foundation, Inc. |
| 4 | 4 | ||
| @@ -39,19 +39,41 @@ | |||
| 39 | 39 | ||
| 40 | (require 'eudc) | 40 | (require 'eudc) |
| 41 | 41 | ||
| 42 | (defvar eudc-bob-generic-keymap nil | 42 | (defvar eudc-bob-generic-keymap |
| 43 | (let ((map (make-sparse-keymap))) | ||
| 44 | (define-key map "s" 'eudc-bob-save-object) | ||
| 45 | (define-key map "!" 'eudc-bob-pipe-object-to-external-program) | ||
| 46 | (define-key map [down-mouse-3] 'eudc-bob-popup-menu) | ||
| 47 | map) | ||
| 43 | "Keymap for multimedia objects.") | 48 | "Keymap for multimedia objects.") |
| 44 | 49 | ||
| 45 | (defvar eudc-bob-image-keymap nil | 50 | (defvar eudc-bob-image-keymap |
| 51 | (let ((map (make-sparse-keymap))) | ||
| 52 | (set-keymap-parent map eudc-bob-generic-keymap) | ||
| 53 | (define-key map "t" 'eudc-bob-toggle-inline-display) | ||
| 54 | map) | ||
| 46 | "Keymap for inline images.") | 55 | "Keymap for inline images.") |
| 47 | 56 | ||
| 48 | (defvar eudc-bob-sound-keymap nil | 57 | (defvar eudc-bob-sound-keymap |
| 58 | (let ((map (make-sparse-keymap))) | ||
| 59 | (set-keymap-parent map eudc-bob-generic-keymap) | ||
| 60 | (define-key map (kbd "RET") 'eudc-bob-play-sound-at-point) | ||
| 61 | (define-key map [down-mouse-2] 'eudc-bob-play-sound-at-mouse) | ||
| 62 | map) | ||
| 49 | "Keymap for inline sounds.") | 63 | "Keymap for inline sounds.") |
| 50 | 64 | ||
| 51 | (defvar eudc-bob-url-keymap nil | 65 | (defvar eudc-bob-url-keymap |
| 66 | (let ((map (make-sparse-keymap))) | ||
| 67 | (define-key map (kbd "RET") 'browse-url-at-point) | ||
| 68 | (define-key map [down-mouse-2] 'browse-url-at-mouse) | ||
| 69 | map) | ||
| 52 | "Keymap for inline urls.") | 70 | "Keymap for inline urls.") |
| 53 | 71 | ||
| 54 | (defvar eudc-bob-mail-keymap nil | 72 | (defvar eudc-bob-mail-keymap |
| 73 | (let ((map (make-sparse-keymap))) | ||
| 74 | (define-key map (kbd "RET") 'goto-address-at-point) | ||
| 75 | (define-key map [down-mouse-2] 'goto-address-at-point) | ||
| 76 | map) | ||
| 55 | "Keymap for inline e-mail addresses.") | 77 | "Keymap for inline e-mail addresses.") |
| 56 | 78 | ||
| 57 | (defvar eudc-bob-generic-menu | 79 | (defvar eudc-bob-generic-menu |
| @@ -74,13 +96,6 @@ | |||
| 74 | (fboundp 'play-sound-internal)] | 96 | (fboundp 'play-sound-internal)] |
| 75 | ,@(cdr (cdr eudc-bob-generic-menu)))) | 97 | ,@(cdr (cdr eudc-bob-generic-menu)))) |
| 76 | 98 | ||
| 77 | (defun eudc-jump-to-event (event) | ||
| 78 | "Jump to the window and point where EVENT occurred." | ||
| 79 | (if (fboundp 'event-closest-point) | ||
| 80 | (goto-char (event-closest-point event)) | ||
| 81 | (set-buffer (window-buffer (posn-window (event-start event)))) | ||
| 82 | (goto-char (posn-point (event-start event))))) | ||
| 83 | |||
| 84 | (defun eudc-bob-get-overlay-prop (prop) | 99 | (defun eudc-bob-get-overlay-prop (prop) |
| 85 | "Get property PROP from one of the overlays around." | 100 | "Get property PROP from one of the overlays around." |
| 86 | (let ((overlays (append (overlays-at (1- (point))) | 101 | (let ((overlays (append (overlays-at (1- (point))) |
| @@ -205,42 +220,30 @@ display a button." | |||
| 205 | "Play the sound data contained in the button where EVENT occurred." | 220 | "Play the sound data contained in the button where EVENT occurred." |
| 206 | (interactive "e") | 221 | (interactive "e") |
| 207 | (save-excursion | 222 | (save-excursion |
| 208 | (eudc-jump-to-event event) | 223 | (mouse-set-point event) |
| 209 | (eudc-bob-play-sound-at-point))) | 224 | (eudc-bob-play-sound-at-point))) |
| 210 | 225 | ||
| 211 | (defun eudc-bob-save-object () | 226 | (defun eudc-bob-save-object (filename) |
| 212 | "Save the object data of the button at point." | 227 | "Save the object data of the button at point." |
| 213 | (interactive) | 228 | (interactive "fWrite file: ") |
| 214 | (let ((data (eudc-bob-get-overlay-prop 'object-data)) | 229 | (let ((data (eudc-bob-get-overlay-prop 'object-data)) |
| 215 | (buffer (generate-new-buffer "*eudc-tmp*"))) | 230 | (coding-system-for-write 'binary)) ;Inhibit EOL conversion. |
| 216 | (save-excursion | 231 | (write-region data nil filename))) |
| 217 | (set-buffer-file-coding-system 'binary) | ||
| 218 | (set-buffer buffer) | ||
| 219 | (set-buffer-multibyte nil) | ||
| 220 | (insert data) | ||
| 221 | (save-buffer)) | ||
| 222 | (kill-buffer buffer))) | ||
| 223 | 232 | ||
| 224 | (defun eudc-bob-pipe-object-to-external-program () | 233 | (defun eudc-bob-pipe-object-to-external-program (program) |
| 225 | "Pipe the object data of the button at point to an external program." | 234 | "Pipe the object data of the button at point to an external program." |
| 226 | (interactive) | 235 | (interactive (list (completing-read "Viewer: " eudc-external-viewers))) |
| 227 | (let ((data (eudc-bob-get-overlay-prop 'object-data)) | 236 | (let ((data (eudc-bob-get-overlay-prop 'object-data)) |
| 228 | (buffer (generate-new-buffer "*eudc-tmp*")) | 237 | (viewer (assoc program eudc-external-viewers))) |
| 229 | program | 238 | (with-temp-buffer |
| 230 | viewer) | 239 | (set-buffer-multibyte nil) |
| 231 | (condition-case nil | 240 | (insert data) |
| 232 | (save-excursion | 241 | (let ((coding-system-for-write 'binary)) ;Inhibit EOL conversion |
| 233 | (set-buffer-file-coding-system 'binary) | 242 | (if viewer |
| 234 | (set-buffer buffer) | 243 | (call-process-region (point-min) (point-max) |
| 235 | (insert data) | 244 | (car (cdr viewer)) |
| 236 | (setq program (completing-read "Viewer: " eudc-external-viewers)) | 245 | (cdr (cdr viewer))) |
| 237 | (if (setq viewer (assoc program eudc-external-viewers)) | 246 | (call-process-region (point-min) (point-max) program)))))) |
| 238 | (call-process-region (point-min) (point-max) | ||
| 239 | (car (cdr viewer)) | ||
| 240 | (cdr (cdr viewer))) | ||
| 241 | (call-process-region (point-min) (point-max) program))) | ||
| 242 | (error | ||
| 243 | (kill-buffer buffer))))) | ||
| 244 | 247 | ||
| 245 | (defun eudc-bob-menu () | 248 | (defun eudc-bob-menu () |
| 246 | "Retrieve the menu attached to a binary object." | 249 | "Retrieve the menu attached to a binary object." |
| @@ -250,47 +253,8 @@ display a button." | |||
| 250 | "Pop-up a menu of EUDC multimedia commands." | 253 | "Pop-up a menu of EUDC multimedia commands." |
| 251 | (interactive "@e") | 254 | (interactive "@e") |
| 252 | (run-hooks 'activate-menubar-hook) | 255 | (run-hooks 'activate-menubar-hook) |
| 253 | (eudc-jump-to-event event) | 256 | (mouse-set-point event) |
| 254 | (let ((result (x-popup-menu t (eudc-bob-menu))) | 257 | (popup-menu (eudc-bob-menu) event)) |
| 255 | command) | ||
| 256 | (if result | ||
| 257 | (progn | ||
| 258 | (setq command (lookup-key (eudc-bob-menu) | ||
| 259 | (apply 'vector result))) | ||
| 260 | (command-execute command))))) | ||
| 261 | |||
| 262 | (setq eudc-bob-generic-keymap | ||
| 263 | (let ((map (make-sparse-keymap))) | ||
| 264 | (define-key map "s" 'eudc-bob-save-object) | ||
| 265 | (define-key map "!" 'eudc-bob-pipe-object-to-external-program) | ||
| 266 | (define-key map [down-mouse-3] 'eudc-bob-popup-menu) | ||
| 267 | map)) | ||
| 268 | |||
| 269 | (setq eudc-bob-image-keymap | ||
| 270 | (let ((map (make-sparse-keymap))) | ||
| 271 | (define-key map "t" 'eudc-bob-toggle-inline-display) | ||
| 272 | map)) | ||
| 273 | |||
| 274 | (setq eudc-bob-sound-keymap | ||
| 275 | (let ((map (make-sparse-keymap))) | ||
| 276 | (define-key map [return] 'eudc-bob-play-sound-at-point) | ||
| 277 | (define-key map [down-mouse-2] 'eudc-bob-play-sound-at-mouse) | ||
| 278 | map)) | ||
| 279 | |||
| 280 | (setq eudc-bob-url-keymap | ||
| 281 | (let ((map (make-sparse-keymap))) | ||
| 282 | (define-key map [return] 'browse-url-at-point) | ||
| 283 | (define-key map [down-mouse-2] 'browse-url-at-mouse) | ||
| 284 | map)) | ||
| 285 | |||
| 286 | (setq eudc-bob-mail-keymap | ||
| 287 | (let ((map (make-sparse-keymap))) | ||
| 288 | (define-key map [return] 'goto-address-at-point) | ||
| 289 | (define-key map [down-mouse-2] 'goto-address-at-point) | ||
| 290 | map)) | ||
| 291 | |||
| 292 | (set-keymap-parent eudc-bob-image-keymap eudc-bob-generic-keymap) | ||
| 293 | (set-keymap-parent eudc-bob-sound-keymap eudc-bob-generic-keymap) | ||
| 294 | 258 | ||
| 295 | ;; If the first arguments can be nil here, then these 3 can be | 259 | ;; If the first arguments can be nil here, then these 3 can be |
| 296 | ;; defconsts once more. | 260 | ;; defconsts once more. |
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index e7170b3e6d1..04deb5bee05 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -672,9 +672,30 @@ Currently this means either text/html or application/xhtml+xml." | |||
| 672 | (setq header-line-format | 672 | (setq header-line-format |
| 673 | (and eww-header-line-format | 673 | (and eww-header-line-format |
| 674 | (let ((title (plist-get eww-data :title)) | 674 | (let ((title (plist-get eww-data :title)) |
| 675 | (peer (plist-get eww-data :peer))) | 675 | (peer (plist-get eww-data :peer)) |
| 676 | (url (plist-get eww-data :url))) | ||
| 676 | (when (zerop (length title)) | 677 | (when (zerop (length title)) |
| 677 | (setq title "[untitled]")) | 678 | (setq title "[untitled]")) |
| 679 | ;; Limit the length of the title so that the host name | ||
| 680 | ;; of the URL is always visible. | ||
| 681 | (when url | ||
| 682 | (let* ((parsed (url-generic-parse-url url)) | ||
| 683 | (host-length (length (format "%s://%s" | ||
| 684 | (url-type parsed) | ||
| 685 | (url-host parsed)))) | ||
| 686 | (width (window-width))) | ||
| 687 | (cond | ||
| 688 | ;; The host bit is wider than the window, so nix | ||
| 689 | ;; the title. | ||
| 690 | ((> (+ host-length 5) width) | ||
| 691 | (setq title "")) | ||
| 692 | ;; Trim the title. | ||
| 693 | ((> (+ (length title) host-length 2) width) | ||
| 694 | (setq title (concat | ||
| 695 | (substring title 0 (- width | ||
| 696 | host-length | ||
| 697 | 5)) | ||
| 698 | "...")))))) | ||
| 678 | ;; This connection has is https. | 699 | ;; This connection has is https. |
| 679 | (when peer | 700 | (when peer |
| 680 | (setq title | 701 | (setq title |
| @@ -686,7 +707,7 @@ Currently this means either text/html or application/xhtml+xml." | |||
| 686 | "%" "%%" | 707 | "%" "%%" |
| 687 | (format-spec | 708 | (format-spec |
| 688 | eww-header-line-format | 709 | eww-header-line-format |
| 689 | `((?u . ,(or (plist-get eww-data :url) "")) | 710 | `((?u . ,(or url "")) |
| 690 | (?t . ,title)))))))) | 711 | (?t . ,title)))))))) |
| 691 | 712 | ||
| 692 | (defun eww-tag-title (dom) | 713 | (defun eww-tag-title (dom) |
diff --git a/lisp/net/newst-treeview.el b/lisp/net/newst-treeview.el index 1bed61f3e7d..ff8a447c7c1 100644 --- a/lisp/net/newst-treeview.el +++ b/lisp/net/newst-treeview.el | |||
| @@ -131,14 +131,6 @@ groupcontent := feedname | groupdefinition) | |||
| 131 | Example: (\"Topmost group\" \"feed1\" (\"subgroup1\" \"feed 2\") | 131 | Example: (\"Topmost group\" \"feed1\" (\"subgroup1\" \"feed 2\") |
| 132 | \"feed3\")") | 132 | \"feed3\")") |
| 133 | 133 | ||
| 134 | (defcustom newsticker-groups-filename | ||
| 135 | nil | ||
| 136 | "Name of the newsticker groups settings file." | ||
| 137 | :version "25.1" ; changed default value to nil | ||
| 138 | :type '(choice (const nil) string) | ||
| 139 | :group 'newsticker-treeview) | ||
| 140 | (make-obsolete-variable 'newsticker-groups-filename 'newsticker-dir "23.1") | ||
| 141 | |||
| 142 | ;; ====================================================================== | 134 | ;; ====================================================================== |
| 143 | ;;; internal variables | 135 | ;;; internal variables |
| 144 | ;; ====================================================================== | 136 | ;; ====================================================================== |
| @@ -1265,29 +1257,9 @@ Note: does not update the layout." | |||
| 1265 | (defun newsticker--treeview-load () | 1257 | (defun newsticker--treeview-load () |
| 1266 | "Load treeview settings." | 1258 | "Load treeview settings." |
| 1267 | (let* ((coding-system-for-read 'utf-8) | 1259 | (let* ((coding-system-for-read 'utf-8) |
| 1268 | (filename | 1260 | (filename (concat newsticker-dir "/groups")) |
| 1269 | (or (and newsticker-groups-filename | ||
| 1270 | (not (string= | ||
| 1271 | (expand-file-name newsticker-groups-filename) | ||
| 1272 | (expand-file-name (concat newsticker-dir "/groups")))) | ||
| 1273 | (file-exists-p newsticker-groups-filename) | ||
| 1274 | (y-or-n-p | ||
| 1275 | (format-message | ||
| 1276 | (concat "Obsolete variable `newsticker-groups-filename' " | ||
| 1277 | "points to existing file \"%s\".\n" | ||
| 1278 | "Read it? ") | ||
| 1279 | newsticker-groups-filename)) | ||
| 1280 | newsticker-groups-filename) | ||
| 1281 | (concat newsticker-dir "/groups"))) | ||
| 1282 | (buf (and (file-exists-p filename) | 1261 | (buf (and (file-exists-p filename) |
| 1283 | (find-file-noselect filename)))) | 1262 | (find-file-noselect filename)))) |
| 1284 | (and newsticker-groups-filename | ||
| 1285 | (file-exists-p newsticker-groups-filename) | ||
| 1286 | (y-or-n-p (format-message | ||
| 1287 | (concat "Delete the file \"%s\",\nto which the obsolete " | ||
| 1288 | "variable `newsticker-groups-filename' points ? ") | ||
| 1289 | newsticker-groups-filename)) | ||
| 1290 | (delete-file newsticker-groups-filename)) | ||
| 1291 | (when buf | 1263 | (when buf |
| 1292 | (set-buffer buf) | 1264 | (set-buffer buf) |
| 1293 | (goto-char (point-min)) | 1265 | (goto-char (point-min)) |
diff --git a/lisp/net/ntlm.el b/lisp/net/ntlm.el index ebcd21948bf..9401430799c 100644 --- a/lisp/net/ntlm.el +++ b/lisp/net/ntlm.el | |||
| @@ -69,7 +69,6 @@ | |||
| 69 | 69 | ||
| 70 | (require 'md4) | 70 | (require 'md4) |
| 71 | (require 'hmac-md5) | 71 | (require 'hmac-md5) |
| 72 | (require 'calc) | ||
| 73 | 72 | ||
| 74 | (defgroup ntlm nil | 73 | (defgroup ntlm nil |
| 75 | "NTLM (NT LanManager) authentication." | 74 | "NTLM (NT LanManager) authentication." |
| @@ -133,32 +132,27 @@ is not given." | |||
| 133 | domain ;buffer field | 132 | domain ;buffer field |
| 134 | )))) | 133 | )))) |
| 135 | 134 | ||
| 136 | (defun ntlm-compute-timestamp () | 135 | (defun ntlm--time-to-timestamp (time) |
| 137 | "Compute an NTLMv2 timestamp. | 136 | "Convert TIME to an NTLMv2 timestamp. |
| 138 | Return a unibyte string representing the number of tenths of a | 137 | Return a unibyte string representing the number of tenths of a |
| 139 | microsecond since January 1, 1601 as a 64-bit little-endian | 138 | microsecond since January 1, 1601 as a 64-bit little-endian |
| 140 | signed integer." | 139 | signed integer. TIME must be on the form (HIGH LOW USEC PSEC)." |
| 141 | ;; FIXME: This can likely be significantly simplified using the new | 140 | (let* ((s (+ (ash (nth 0 time) 16) (nth 1 time))) |
| 142 | ;; bignums support! | 141 | (us (nth 2 time)) |
| 143 | (let* ((s-to-tenths-of-us "mul(add(lsh($1,16),$2),10000000)") | 142 | (ps (nth 3 time)) |
| 144 | (us-to-tenths-of-us "mul($3,10)") | 143 | (tenths-of-us-since-jan-1-1601 |
| 145 | (ps-to-tenths-of-us "idiv($4,100000)") | 144 | (+ (* s 10000000) (* us 10) (/ ps 100000) |
| 146 | (tenths-of-us-since-jan-1-1601 | 145 | ;; tenths of microseconds between 1601-01-01 and 1970-01-01 |
| 147 | (apply #'calc-eval (concat "add(add(add(" | 146 | 116444736000000000))) |
| 148 | s-to-tenths-of-us "," | 147 | (apply #'unibyte-string |
| 149 | us-to-tenths-of-us ")," | 148 | (mapcar (lambda (i) |
| 150 | ps-to-tenths-of-us ")," | 149 | (logand (ash tenths-of-us-since-jan-1-1601 (* i -8)) |
| 151 | ;; tenths of microseconds between | 150 | #xff)) |
| 152 | ;; 1601-01-01 and 1970-01-01 | 151 | (number-sequence 0 7))))) |
| 153 | "116444736000000000)") | 152 | |
| 154 | 'rawnum (time-convert nil 'list))) | 153 | (defun ntlm-compute-timestamp () |
| 155 | result-bytes) | 154 | "Current time as an NTLMv2 timestamp, as a unibyte string." |
| 156 | (dotimes (_byte 8) | 155 | (ntlm--time-to-timestamp (time-convert nil 'list))) |
| 157 | (push (calc-eval "and($1,16#FF)" 'rawnum tenths-of-us-since-jan-1-1601) | ||
| 158 | result-bytes) | ||
| 159 | (setq tenths-of-us-since-jan-1-1601 | ||
| 160 | (calc-eval "rsh($1,8,64)" 'rawnum tenths-of-us-since-jan-1-1601))) | ||
| 161 | (apply #'unibyte-string (nreverse result-bytes)))) | ||
| 162 | 156 | ||
| 163 | (defun ntlm-generate-nonce () | 157 | (defun ntlm-generate-nonce () |
| 164 | "Generate a random nonce, not to be used more than once. | 158 | "Generate a random nonce, not to be used more than once. |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index ca43475f453..fae15fe6a8e 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -4781,104 +4781,6 @@ Goes through the list `tramp-inline-compress-commands'." | |||
| 4781 | (tramp-message | 4781 | (tramp-message |
| 4782 | vec 2 "Couldn't find an inline transfer compress command"))))) | 4782 | vec 2 "Couldn't find an inline transfer compress command"))))) |
| 4783 | 4783 | ||
| 4784 | ;;;###tramp-autoload | ||
| 4785 | (defun tramp-multi-hop-p (vec) | ||
| 4786 | "Whether the method of VEC is capable of multi-hops." | ||
| 4787 | (and (tramp-sh-file-name-handler-p vec) | ||
| 4788 | (not (tramp-get-method-parameter vec 'tramp-copy-program)))) | ||
| 4789 | |||
| 4790 | (defun tramp-compute-multi-hops (vec) | ||
| 4791 | "Expands VEC according to `tramp-default-proxies-alist'." | ||
| 4792 | (let ((saved-tdpa tramp-default-proxies-alist) | ||
| 4793 | (target-alist `(,vec)) | ||
| 4794 | (hops (or (tramp-file-name-hop vec) "")) | ||
| 4795 | (item vec) | ||
| 4796 | choices proxy) | ||
| 4797 | |||
| 4798 | ;; Ad-hoc proxy definitions. | ||
| 4799 | (dolist (proxy (reverse (split-string hops tramp-postfix-hop-regexp 'omit))) | ||
| 4800 | (let* ((host-port (tramp-file-name-host-port item)) | ||
| 4801 | (user-domain (tramp-file-name-user-domain item)) | ||
| 4802 | (proxy (concat | ||
| 4803 | tramp-prefix-format proxy tramp-postfix-host-format)) | ||
| 4804 | (entry | ||
| 4805 | (list (and (stringp host-port) | ||
| 4806 | (concat "^" (regexp-quote host-port) "$")) | ||
| 4807 | (and (stringp user-domain) | ||
| 4808 | (concat "^" (regexp-quote user-domain) "$")) | ||
| 4809 | (propertize proxy 'tramp-ad-hoc t)))) | ||
| 4810 | (tramp-message vec 5 "Add %S to `tramp-default-proxies-alist'" entry) | ||
| 4811 | ;; Add the hop. | ||
| 4812 | (add-to-list 'tramp-default-proxies-alist entry) | ||
| 4813 | (setq item (tramp-dissect-file-name proxy)))) | ||
| 4814 | ;; Save the new value. | ||
| 4815 | (when (and hops tramp-save-ad-hoc-proxies) | ||
| 4816 | (customize-save-variable | ||
| 4817 | 'tramp-default-proxies-alist tramp-default-proxies-alist)) | ||
| 4818 | |||
| 4819 | ;; Look for proxy hosts to be passed. | ||
| 4820 | (setq choices tramp-default-proxies-alist) | ||
| 4821 | (while choices | ||
| 4822 | (setq item (pop choices) | ||
| 4823 | proxy (eval (nth 2 item))) | ||
| 4824 | (when (and | ||
| 4825 | ;; Host. | ||
| 4826 | (string-match-p | ||
| 4827 | (or (eval (nth 0 item)) "") | ||
| 4828 | (or (tramp-file-name-host-port (car target-alist)) "")) | ||
| 4829 | ;; User. | ||
| 4830 | (string-match-p | ||
| 4831 | (or (eval (nth 1 item)) "") | ||
| 4832 | (or (tramp-file-name-user-domain (car target-alist)) ""))) | ||
| 4833 | (if (null proxy) | ||
| 4834 | ;; No more hops needed. | ||
| 4835 | (setq choices nil) | ||
| 4836 | ;; Replace placeholders. | ||
| 4837 | (setq proxy | ||
| 4838 | (format-spec | ||
| 4839 | proxy | ||
| 4840 | (format-spec-make | ||
| 4841 | ?u (or (tramp-file-name-user (car target-alist)) "") | ||
| 4842 | ?h (or (tramp-file-name-host (car target-alist)) "")))) | ||
| 4843 | (with-parsed-tramp-file-name proxy l | ||
| 4844 | ;; Add the hop. | ||
| 4845 | (push l target-alist) | ||
| 4846 | ;; Start next search. | ||
| 4847 | (setq choices tramp-default-proxies-alist))))) | ||
| 4848 | |||
| 4849 | ;; Foreign and out-of-band methods are not supported for multi-hops. | ||
| 4850 | (when (cdr target-alist) | ||
| 4851 | (setq choices target-alist) | ||
| 4852 | (while (setq item (pop choices)) | ||
| 4853 | (unless (tramp-multi-hop-p item) | ||
| 4854 | (setq tramp-default-proxies-alist saved-tdpa) | ||
| 4855 | (tramp-user-error | ||
| 4856 | vec "Method `%s' is not supported for multi-hops." | ||
| 4857 | (tramp-file-name-method item))))) | ||
| 4858 | |||
| 4859 | ;; Some methods ("su", "sg", "sudo", "doas", "ksu") do not use the | ||
| 4860 | ;; host name in their command template. In this case, the remote | ||
| 4861 | ;; file name must use either a local host name (first hop), or a | ||
| 4862 | ;; host name matching the previous hop. | ||
| 4863 | (let ((previous-host (or tramp-local-host-regexp ""))) | ||
| 4864 | (setq choices target-alist) | ||
| 4865 | (while (setq item (pop choices)) | ||
| 4866 | (let ((host (tramp-file-name-host item))) | ||
| 4867 | (unless | ||
| 4868 | (or | ||
| 4869 | ;; The host name is used for the remote shell command. | ||
| 4870 | (member | ||
| 4871 | '("%h") (tramp-get-method-parameter item 'tramp-login-args)) | ||
| 4872 | ;; The host name must match previous hop. | ||
| 4873 | (string-match-p previous-host host)) | ||
| 4874 | (setq tramp-default-proxies-alist saved-tdpa) | ||
| 4875 | (tramp-user-error | ||
| 4876 | vec "Host name `%s' does not match `%s'" host previous-host)) | ||
| 4877 | (setq previous-host (concat "^" (regexp-quote host) "$"))))) | ||
| 4878 | |||
| 4879 | ;; Result. | ||
| 4880 | target-alist)) | ||
| 4881 | |||
| 4882 | (defun tramp-ssh-controlmaster-options (vec) | 4784 | (defun tramp-ssh-controlmaster-options (vec) |
| 4883 | "Return the Control* arguments of the local ssh." | 4785 | "Return the Control* arguments of the local ssh." |
| 4884 | (cond | 4786 | (cond |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index ab52bec39eb..83ade66ee14 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -3634,12 +3634,109 @@ User is always nil." | |||
| 3634 | (delete-file local-copy))))) | 3634 | (delete-file local-copy))))) |
| 3635 | t))) | 3635 | t))) |
| 3636 | 3636 | ||
| 3637 | (defun tramp-multi-hop-p (vec) | ||
| 3638 | "Whether the method of VEC is capable of multi-hops." | ||
| 3639 | (and (tramp-sh-file-name-handler-p vec) | ||
| 3640 | (not (tramp-get-method-parameter vec 'tramp-copy-program)))) | ||
| 3641 | |||
| 3642 | (defun tramp-compute-multi-hops (vec) | ||
| 3643 | "Expands VEC according to `tramp-default-proxies-alist'." | ||
| 3644 | (let ((saved-tdpa tramp-default-proxies-alist) | ||
| 3645 | (target-alist `(,vec)) | ||
| 3646 | (hops (or (tramp-file-name-hop vec) "")) | ||
| 3647 | (item vec) | ||
| 3648 | choices proxy) | ||
| 3649 | |||
| 3650 | ;; Ad-hoc proxy definitions. | ||
| 3651 | (dolist (proxy (reverse (split-string hops tramp-postfix-hop-regexp 'omit))) | ||
| 3652 | (let* ((host-port (tramp-file-name-host-port item)) | ||
| 3653 | (user-domain (tramp-file-name-user-domain item)) | ||
| 3654 | (proxy (concat | ||
| 3655 | tramp-prefix-format proxy tramp-postfix-host-format)) | ||
| 3656 | (entry | ||
| 3657 | (list (and (stringp host-port) | ||
| 3658 | (concat "^" (regexp-quote host-port) "$")) | ||
| 3659 | (and (stringp user-domain) | ||
| 3660 | (concat "^" (regexp-quote user-domain) "$")) | ||
| 3661 | (propertize proxy 'tramp-ad-hoc t)))) | ||
| 3662 | (tramp-message vec 5 "Add %S to `tramp-default-proxies-alist'" entry) | ||
| 3663 | ;; Add the hop. | ||
| 3664 | (add-to-list 'tramp-default-proxies-alist entry) | ||
| 3665 | (setq item (tramp-dissect-file-name proxy)))) | ||
| 3666 | ;; Save the new value. | ||
| 3667 | (when (and hops tramp-save-ad-hoc-proxies) | ||
| 3668 | (customize-save-variable | ||
| 3669 | 'tramp-default-proxies-alist tramp-default-proxies-alist)) | ||
| 3670 | |||
| 3671 | ;; Look for proxy hosts to be passed. | ||
| 3672 | (setq choices tramp-default-proxies-alist) | ||
| 3673 | (while choices | ||
| 3674 | (setq item (pop choices) | ||
| 3675 | proxy (eval (nth 2 item))) | ||
| 3676 | (when (and | ||
| 3677 | ;; Host. | ||
| 3678 | (string-match-p | ||
| 3679 | (or (eval (nth 0 item)) "") | ||
| 3680 | (or (tramp-file-name-host-port (car target-alist)) "")) | ||
| 3681 | ;; User. | ||
| 3682 | (string-match-p | ||
| 3683 | (or (eval (nth 1 item)) "") | ||
| 3684 | (or (tramp-file-name-user-domain (car target-alist)) ""))) | ||
| 3685 | (if (null proxy) | ||
| 3686 | ;; No more hops needed. | ||
| 3687 | (setq choices nil) | ||
| 3688 | ;; Replace placeholders. | ||
| 3689 | (setq proxy | ||
| 3690 | (format-spec | ||
| 3691 | proxy | ||
| 3692 | (format-spec-make | ||
| 3693 | ?u (or (tramp-file-name-user (car target-alist)) "") | ||
| 3694 | ?h (or (tramp-file-name-host (car target-alist)) "")))) | ||
| 3695 | (with-parsed-tramp-file-name proxy l | ||
| 3696 | ;; Add the hop. | ||
| 3697 | (push l target-alist) | ||
| 3698 | ;; Start next search. | ||
| 3699 | (setq choices tramp-default-proxies-alist))))) | ||
| 3700 | |||
| 3701 | ;; Foreign and out-of-band methods are not supported for multi-hops. | ||
| 3702 | (when (cdr target-alist) | ||
| 3703 | (setq choices target-alist) | ||
| 3704 | (while (setq item (pop choices)) | ||
| 3705 | (unless (tramp-multi-hop-p item) | ||
| 3706 | (setq tramp-default-proxies-alist saved-tdpa) | ||
| 3707 | (tramp-user-error | ||
| 3708 | vec "Method `%s' is not supported for multi-hops." | ||
| 3709 | (tramp-file-name-method item))))) | ||
| 3710 | |||
| 3711 | ;; Some methods ("su", "sg", "sudo", "doas", "ksu") do not use the | ||
| 3712 | ;; host name in their command template. In this case, the remote | ||
| 3713 | ;; file name must use either a local host name (first hop), or a | ||
| 3714 | ;; host name matching the previous hop. | ||
| 3715 | (let ((previous-host (or tramp-local-host-regexp ""))) | ||
| 3716 | (setq choices target-alist) | ||
| 3717 | (while (setq item (pop choices)) | ||
| 3718 | (let ((host (tramp-file-name-host item))) | ||
| 3719 | (unless | ||
| 3720 | (or | ||
| 3721 | ;; The host name is used for the remote shell command. | ||
| 3722 | (member | ||
| 3723 | '("%h") (tramp-get-method-parameter item 'tramp-login-args)) | ||
| 3724 | ;; The host name must match previous hop. | ||
| 3725 | (string-match-p previous-host host)) | ||
| 3726 | (setq tramp-default-proxies-alist saved-tdpa) | ||
| 3727 | (tramp-user-error | ||
| 3728 | vec "Host name `%s' does not match `%s'" host previous-host)) | ||
| 3729 | (setq previous-host (concat "^" (regexp-quote host) "$"))))) | ||
| 3730 | |||
| 3731 | ;; Result. | ||
| 3732 | target-alist)) | ||
| 3733 | |||
| 3637 | (defun tramp-direct-async-process-p (&rest args) | 3734 | (defun tramp-direct-async-process-p (&rest args) |
| 3638 | "Whether direct async `make-process' can be called." | 3735 | "Whether direct async `make-process' can be called." |
| 3639 | (let ((v (tramp-dissect-file-name default-directory))) | 3736 | (let ((v (tramp-dissect-file-name default-directory))) |
| 3640 | (and (tramp-get-connection-property v"direct-async-process" nil) | 3737 | (and (tramp-get-connection-property v "direct-async-process" nil) |
| 3641 | (not (tramp-multi-hop-p v)) | 3738 | (= (length (tramp-compute-multi-hops v)) 1) |
| 3642 | (not (plist-get args :stderr))))) | 3739 | (not (plist-get args :stderr))))) |
| 3643 | 3740 | ||
| 3644 | ;; We use BUFFER also as connection buffer during setup. Because of | 3741 | ;; We use BUFFER also as connection buffer during setup. Because of |
| 3645 | ;; this, its original contents must be saved, and restored once | 3742 | ;; this, its original contents must be saved, and restored once |