emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/emacs-24 r111133: * net/tramp-sh.el (tramp-


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111133: * net/tramp-sh.el (tramp-set-file-uid-gid): UID and GID must be
Date: Fri, 04 Jan 2013 10:41:23 +0100
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111133
committer: Michael Albinus <address@hidden>
branch nick: emacs-24
timestamp: Fri 2013-01-04 10:41:23 +0100
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/net/tramp-sh.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-01-03 18:31:45 +0000
+++ b/lisp/ChangeLog    2013-01-04 09:41:23 +0000
@@ -1,3 +1,9 @@
+2013-01-04  Michael Albinus  <address@hidden>
+
+       * 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.
+
 2013-01-03  Glenn Morris  <address@hidden>
 
        * term.el (term-handle-colors-array): Ensure face attributes

=== modified file 'lisp/net/tramp-sh.el'
--- a/lisp/net/tramp-sh.el      2013-01-03 01:35:49 +0000
+++ b/lisp/net/tramp-sh.el      2013-01-04 09:41:23 +0000
@@ -1449,23 +1449,22 @@
 (defun tramp-set-file-uid-gid (filename &optional uid gid)
   "Set the ownership for FILENAME.
 If UID and GID are provided, these values are used; otherwise uid
-and gid of the corresponding user is taken.  Both parameters must be integers."
+and gid of the corresponding user is taken.  Both parameters must
+be non-negative integers."
   ;; Modern Unices allow chown only for root.  So we might need
   ;; another implementation, see `dired-do-chown'.  OTOH, it is mostly
   ;; working with su(do)? when it is needed, so it shall succeed in
   ;; the majority of cases.
   ;; Don't modify `last-coding-system-used' by accident.
-  (let ((last-coding-system-used last-coding-system-used)
-       (uid (and (numberp uid) (round uid)))
-       (gid (and (numberp gid) (round gid))))
+  (let ((last-coding-system-used last-coding-system-used))
     (if (file-remote-p filename)
        (with-parsed-tramp-file-name filename nil
          (if (and (zerop (user-uid)) (tramp-local-host-p v))
              ;; If we are root on the local host, we can do it directly.
              (tramp-set-file-uid-gid localname uid gid)
-           (let ((uid (or (and (integerp uid) uid)
+           (let ((uid (or (and (natnump uid) uid)
                           (tramp-get-remote-uid v 'integer)))
-                 (gid (or (and (integerp gid) gid)
+                 (gid (or (and (natnump gid) gid)
                           (tramp-get-remote-gid v 'integer))))
              (tramp-send-command
               v (format
@@ -1474,8 +1473,8 @@
 
       ;; We handle also the local part, because there doesn't exist
       ;; `set-file-uid-gid'.  On W32 "chown" might not work.
-      (let ((uid (or (and (integerp uid) uid) (tramp-get-local-uid 'integer)))
-           (gid (or (and (integerp gid) gid) (tramp-get-local-gid 'integer))))
+      (let ((uid (or (and (natnump uid) uid) (tramp-get-local-uid 'integer)))
+           (gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer))))
        (tramp-compat-call-process
         "chown" nil nil nil
          (format "%d:%d" uid gid) (tramp-shell-quote-argument filename))))))
@@ -4606,7 +4605,7 @@
                  command (buffer-string))))))))
 
 (defun tramp-convert-file-attributes (vec attr)
-  "Convert file-attributes ATTR generated by perl script, stat or ls.
+  "Convert `file-attributes' ATTR generated by perl script, stat or ls.
 Convert file mode bits to string and set virtual device number.
 Return ATTR."
   (when attr
@@ -4614,6 +4613,17 @@
     (when (stringp (car attr))
       (while (string-match tramp-color-escape-sequence-regexp (car attr))
        (setcar attr (replace-match "" nil nil (car attr)))))
+    ;; Convert uid and gid.  Use -1 as indication of unusable value.
+    (when (and (numberp (nth 2 attr)) (< (nth 2 attr) 0))
+      (setcar (nthcdr 2 attr) -1))
+    (when (and (floatp (nth 2 attr))
+               (<= (nth 2 attr) (tramp-compat-most-positive-fixnum)))
+      (setcar (nthcdr 2 attr) (round (nth 2 attr))))
+    (when (and (numberp (nth 3 attr)) (< (nth 3 attr) 0))
+      (setcar (nthcdr 3 attr) -1))
+    (when (and (floatp (nth 3 attr))
+               (<= (nth 3 attr) (tramp-compat-most-positive-fixnum)))
+      (setcar (nthcdr 3 attr) (round (nth 3 attr))))
     ;; Convert last access time.
     (unless (listp (nth 4 attr))
       (setcar (nthcdr 4 attr)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]