diff options
| author | Joakim Verona | 2013-01-05 00:04:41 +0100 |
|---|---|---|
| committer | Joakim Verona | 2013-01-05 00:04:41 +0100 |
| commit | b18e01b65e651d3b626b4edcaaa2aa636fe25b69 (patch) | |
| tree | 2832e227a4c45d3a4d423f972df29fb7f8616b14 /lisp/net | |
| parent | 55b74b54b179f340bdb311070273f26da3fbd0c9 (diff) | |
| parent | 1bd71e9fe16541bc48868a00ff372018961380b0 (diff) | |
| download | emacs-b18e01b65e651d3b626b4edcaaa2aa636fe25b69.tar.gz emacs-b18e01b65e651d3b626b4edcaaa2aa636fe25b69.zip | |
auto upstream
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/tramp-sh.el | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 5bbf1708654..79f8d82b02b 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -1452,23 +1452,22 @@ of." | |||
| 1452 | (defun tramp-set-file-uid-gid (filename &optional uid gid) | 1452 | (defun tramp-set-file-uid-gid (filename &optional uid gid) |
| 1453 | "Set the ownership for FILENAME. | 1453 | "Set the ownership for FILENAME. |
| 1454 | If UID and GID are provided, these values are used; otherwise uid | 1454 | If UID and GID are provided, these values are used; otherwise uid |
| 1455 | and gid of the corresponding user is taken. Both parameters must be integers." | 1455 | and gid of the corresponding user is taken. Both parameters must |
| 1456 | be non-negative integers." | ||
| 1456 | ;; Modern Unices allow chown only for root. So we might need | 1457 | ;; Modern Unices allow chown only for root. So we might need |
| 1457 | ;; another implementation, see `dired-do-chown'. OTOH, it is mostly | 1458 | ;; another implementation, see `dired-do-chown'. OTOH, it is mostly |
| 1458 | ;; working with su(do)? when it is needed, so it shall succeed in | 1459 | ;; working with su(do)? when it is needed, so it shall succeed in |
| 1459 | ;; the majority of cases. | 1460 | ;; the majority of cases. |
| 1460 | ;; Don't modify `last-coding-system-used' by accident. | 1461 | ;; Don't modify `last-coding-system-used' by accident. |
| 1461 | (let ((last-coding-system-used last-coding-system-used) | 1462 | (let ((last-coding-system-used last-coding-system-used)) |
| 1462 | (uid (and (numberp uid) (round uid))) | ||
| 1463 | (gid (and (numberp gid) (round gid)))) | ||
| 1464 | (if (file-remote-p filename) | 1463 | (if (file-remote-p filename) |
| 1465 | (with-parsed-tramp-file-name filename nil | 1464 | (with-parsed-tramp-file-name filename nil |
| 1466 | (if (and (zerop (user-uid)) (tramp-local-host-p v)) | 1465 | (if (and (zerop (user-uid)) (tramp-local-host-p v)) |
| 1467 | ;; If we are root on the local host, we can do it directly. | 1466 | ;; If we are root on the local host, we can do it directly. |
| 1468 | (tramp-set-file-uid-gid localname uid gid) | 1467 | (tramp-set-file-uid-gid localname uid gid) |
| 1469 | (let ((uid (or (and (integerp uid) uid) | 1468 | (let ((uid (or (and (natnump uid) uid) |
| 1470 | (tramp-get-remote-uid v 'integer))) | 1469 | (tramp-get-remote-uid v 'integer))) |
| 1471 | (gid (or (and (integerp gid) gid) | 1470 | (gid (or (and (natnump gid) gid) |
| 1472 | (tramp-get-remote-gid v 'integer)))) | 1471 | (tramp-get-remote-gid v 'integer)))) |
| 1473 | (tramp-send-command | 1472 | (tramp-send-command |
| 1474 | v (format | 1473 | v (format |
| @@ -1477,8 +1476,8 @@ and gid of the corresponding user is taken. Both parameters must be integers." | |||
| 1477 | 1476 | ||
| 1478 | ;; We handle also the local part, because there doesn't exist | 1477 | ;; We handle also the local part, because there doesn't exist |
| 1479 | ;; `set-file-uid-gid'. On W32 "chown" might not work. | 1478 | ;; `set-file-uid-gid'. On W32 "chown" might not work. |
| 1480 | (let ((uid (or (and (integerp uid) uid) (tramp-get-local-uid 'integer))) | 1479 | (let ((uid (or (and (natnump uid) uid) (tramp-get-local-uid 'integer))) |
| 1481 | (gid (or (and (integerp gid) gid) (tramp-get-local-gid 'integer)))) | 1480 | (gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer)))) |
| 1482 | (tramp-compat-call-process | 1481 | (tramp-compat-call-process |
| 1483 | "chown" nil nil nil | 1482 | "chown" nil nil nil |
| 1484 | (format "%d:%d" uid gid) (tramp-shell-quote-argument filename)))))) | 1483 | (format "%d:%d" uid gid) (tramp-shell-quote-argument filename)))))) |
| @@ -4665,7 +4664,7 @@ raises an error." | |||
| 4665 | command (buffer-string)))))))) | 4664 | command (buffer-string)))))))) |
| 4666 | 4665 | ||
| 4667 | (defun tramp-convert-file-attributes (vec attr) | 4666 | (defun tramp-convert-file-attributes (vec attr) |
| 4668 | "Convert file-attributes ATTR generated by perl script, stat or ls. | 4667 | "Convert `file-attributes' ATTR generated by perl script, stat or ls. |
| 4669 | Convert file mode bits to string and set virtual device number. | 4668 | Convert file mode bits to string and set virtual device number. |
| 4670 | Return ATTR." | 4669 | Return ATTR." |
| 4671 | (when attr | 4670 | (when attr |
| @@ -4673,6 +4672,17 @@ Return ATTR." | |||
| 4673 | (when (stringp (car attr)) | 4672 | (when (stringp (car attr)) |
| 4674 | (while (string-match tramp-color-escape-sequence-regexp (car attr)) | 4673 | (while (string-match tramp-color-escape-sequence-regexp (car attr)) |
| 4675 | (setcar attr (replace-match "" nil nil (car attr))))) | 4674 | (setcar attr (replace-match "" nil nil (car attr))))) |
| 4675 | ;; Convert uid and gid. Use -1 as indication of unusable value. | ||
| 4676 | (when (and (numberp (nth 2 attr)) (< (nth 2 attr) 0)) | ||
| 4677 | (setcar (nthcdr 2 attr) -1)) | ||
| 4678 | (when (and (floatp (nth 2 attr)) | ||
| 4679 | (<= (nth 2 attr) (tramp-compat-most-positive-fixnum))) | ||
| 4680 | (setcar (nthcdr 2 attr) (round (nth 2 attr)))) | ||
| 4681 | (when (and (numberp (nth 3 attr)) (< (nth 3 attr) 0)) | ||
| 4682 | (setcar (nthcdr 3 attr) -1)) | ||
| 4683 | (when (and (floatp (nth 3 attr)) | ||
| 4684 | (<= (nth 3 attr) (tramp-compat-most-positive-fixnum))) | ||
| 4685 | (setcar (nthcdr 3 attr) (round (nth 3 attr)))) | ||
| 4676 | ;; Convert last access time. | 4686 | ;; Convert last access time. |
| 4677 | (unless (listp (nth 4 attr)) | 4687 | (unless (listp (nth 4 attr)) |
| 4678 | (setcar (nthcdr 4 attr) | 4688 | (setcar (nthcdr 4 attr) |