aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2013-01-04 10:41:23 +0100
committerMichael Albinus2013-01-04 10:41:23 +0100
commitf99ced353f1e6d41f085d6325b0182ed2d644753 (patch)
tree0eab967a0ebf1df12336a42b12b95572bfe41c26
parentb55349fbd859656ee4747f261f90b56d01d4084c (diff)
downloademacs-f99ced353f1e6d41f085d6325b0182ed2d644753.tar.gz
emacs-f99ced353f1e6d41f085d6325b0182ed2d644753.zip
* net/tramp-sh.el (tramp-set-file-uid-gid): UID and GID must be
non-negative integers. Otherwise, the default values are used. (tramp-convert-file-attributes): Convert uid and gid to integers.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/net/tramp-sh.el28
2 files changed, 25 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 90b6e683e0a..86cd55c6c36 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12013-01-04 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp-sh.el (tramp-set-file-uid-gid): UID and GID must be
4 non-negative integers. Otherwise, the default values are used.
5 (tramp-convert-file-attributes): Convert uid and gid to integers.
6
12013-01-03 Glenn Morris <rgm@gnu.org> 72013-01-03 Glenn Morris <rgm@gnu.org>
2 8
3 * term.el (term-handle-colors-array): Ensure face attributes 9 * term.el (term-handle-colors-array): Ensure face attributes
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 2bffb868aba..2152ba1e270 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -1449,23 +1449,22 @@ of."
1449(defun tramp-set-file-uid-gid (filename &optional uid gid) 1449(defun tramp-set-file-uid-gid (filename &optional uid gid)
1450 "Set the ownership for FILENAME. 1450 "Set the ownership for FILENAME.
1451If UID and GID are provided, these values are used; otherwise uid 1451If UID and GID are provided, these values are used; otherwise uid
1452and gid of the corresponding user is taken. Both parameters must be integers." 1452and gid of the corresponding user is taken. Both parameters must
1453be non-negative integers."
1453 ;; Modern Unices allow chown only for root. So we might need 1454 ;; Modern Unices allow chown only for root. So we might need
1454 ;; another implementation, see `dired-do-chown'. OTOH, it is mostly 1455 ;; another implementation, see `dired-do-chown'. OTOH, it is mostly
1455 ;; working with su(do)? when it is needed, so it shall succeed in 1456 ;; working with su(do)? when it is needed, so it shall succeed in
1456 ;; the majority of cases. 1457 ;; the majority of cases.
1457 ;; Don't modify `last-coding-system-used' by accident. 1458 ;; Don't modify `last-coding-system-used' by accident.
1458 (let ((last-coding-system-used last-coding-system-used) 1459 (let ((last-coding-system-used last-coding-system-used))
1459 (uid (and (numberp uid) (round uid)))
1460 (gid (and (numberp gid) (round gid))))
1461 (if (file-remote-p filename) 1460 (if (file-remote-p filename)
1462 (with-parsed-tramp-file-name filename nil 1461 (with-parsed-tramp-file-name filename nil
1463 (if (and (zerop (user-uid)) (tramp-local-host-p v)) 1462 (if (and (zerop (user-uid)) (tramp-local-host-p v))
1464 ;; If we are root on the local host, we can do it directly. 1463 ;; If we are root on the local host, we can do it directly.
1465 (tramp-set-file-uid-gid localname uid gid) 1464 (tramp-set-file-uid-gid localname uid gid)
1466 (let ((uid (or (and (integerp uid) uid) 1465 (let ((uid (or (and (natnump uid) uid)
1467 (tramp-get-remote-uid v 'integer))) 1466 (tramp-get-remote-uid v 'integer)))
1468 (gid (or (and (integerp gid) gid) 1467 (gid (or (and (natnump gid) gid)
1469 (tramp-get-remote-gid v 'integer)))) 1468 (tramp-get-remote-gid v 'integer))))
1470 (tramp-send-command 1469 (tramp-send-command
1471 v (format 1470 v (format
@@ -1474,8 +1473,8 @@ and gid of the corresponding user is taken. Both parameters must be integers."
1474 1473
1475 ;; We handle also the local part, because there doesn't exist 1474 ;; We handle also the local part, because there doesn't exist
1476 ;; `set-file-uid-gid'. On W32 "chown" might not work. 1475 ;; `set-file-uid-gid'. On W32 "chown" might not work.
1477 (let ((uid (or (and (integerp uid) uid) (tramp-get-local-uid 'integer))) 1476 (let ((uid (or (and (natnump uid) uid) (tramp-get-local-uid 'integer)))
1478 (gid (or (and (integerp gid) gid) (tramp-get-local-gid 'integer)))) 1477 (gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer))))
1479 (tramp-compat-call-process 1478 (tramp-compat-call-process
1480 "chown" nil nil nil 1479 "chown" nil nil nil
1481 (format "%d:%d" uid gid) (tramp-shell-quote-argument filename)))))) 1480 (format "%d:%d" uid gid) (tramp-shell-quote-argument filename))))))
@@ -4606,7 +4605,7 @@ raises an error."
4606 command (buffer-string)))))))) 4605 command (buffer-string))))))))
4607 4606
4608(defun tramp-convert-file-attributes (vec attr) 4607(defun tramp-convert-file-attributes (vec attr)
4609 "Convert file-attributes ATTR generated by perl script, stat or ls. 4608 "Convert `file-attributes' ATTR generated by perl script, stat or ls.
4610Convert file mode bits to string and set virtual device number. 4609Convert file mode bits to string and set virtual device number.
4611Return ATTR." 4610Return ATTR."
4612 (when attr 4611 (when attr
@@ -4614,6 +4613,17 @@ Return ATTR."
4614 (when (stringp (car attr)) 4613 (when (stringp (car attr))
4615 (while (string-match tramp-color-escape-sequence-regexp (car attr)) 4614 (while (string-match tramp-color-escape-sequence-regexp (car attr))
4616 (setcar attr (replace-match "" nil nil (car attr))))) 4615 (setcar attr (replace-match "" nil nil (car attr)))))
4616 ;; Convert uid and gid. Use -1 as indication of unusable value.
4617 (when (and (numberp (nth 2 attr)) (< (nth 2 attr) 0))
4618 (setcar (nthcdr 2 attr) -1))
4619 (when (and (floatp (nth 2 attr))
4620 (<= (nth 2 attr) (tramp-compat-most-positive-fixnum)))
4621 (setcar (nthcdr 2 attr) (round (nth 2 attr))))
4622 (when (and (numberp (nth 3 attr)) (< (nth 3 attr) 0))
4623 (setcar (nthcdr 3 attr) -1))
4624 (when (and (floatp (nth 3 attr))
4625 (<= (nth 3 attr) (tramp-compat-most-positive-fixnum)))
4626 (setcar (nthcdr 3 attr) (round (nth 3 attr))))
4617 ;; Convert last access time. 4627 ;; Convert last access time.
4618 (unless (listp (nth 4 attr)) 4628 (unless (listp (nth 4 attr))
4619 (setcar (nthcdr 4 attr) 4629 (setcar (nthcdr 4 attr)