aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2019-01-22 10:38:49 +0100
committerMichael Albinus2019-01-22 10:38:49 +0100
commitc580081578edf8663e80cd86a1b4de377be58dc1 (patch)
tree01d0c1893b43e9ace726e5b07a3fd7030852185d
parent5259fdf96073febd18e83785960c443bdf02a310 (diff)
downloademacs-c580081578edf8663e80cd86a1b4de377be58dc1.tar.gz
emacs-c580081578edf8663e80cd86a1b4de377be58dc1.zip
Respect setgid bit of the upper directory in Tramp
* doc/misc/trampver.texi: * lisp/net/trampver.el: Change version to "2.4.2-pre". * lisp/net/tramp.el: Bump version to 2.4.2-pre. (tramp-set-file-uid-gid): Respect setgid bit of the upper directory. (tramp-default-file-modes, tramp-handle-insert-file-contents) (tramp-mode-string-to-int, tramp-make-tramp-temp-file): * 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) (tramp-sh-handle-write-region): Use octal constants.
-rw-r--r--doc/misc/trampver.texi2
-rw-r--r--lisp/net/tramp-adb.el8
-rw-r--r--lisp/net/tramp-sh.el12
-rw-r--r--lisp/net/tramp.el42
-rw-r--r--lisp/net/trampver.el4
5 files changed, 32 insertions, 36 deletions
diff --git a/doc/misc/trampver.texi b/doc/misc/trampver.texi
index f5cc2bae179..5b1408a4974 100644
--- a/doc/misc/trampver.texi
+++ b/doc/misc/trampver.texi
@@ -7,7 +7,7 @@
7 7
8@c In the Tramp GIT, the version number is auto-frobbed from tramp.el, 8@c In the Tramp GIT, the version number is auto-frobbed from tramp.el,
9@c and the bug report address is auto-frobbed from configure.ac. 9@c and the bug report address is auto-frobbed from configure.ac.
10@set trampver 2.4.1 10@set trampver 2.4.2-pre
11@set tramp-bug-report-address tramp-devel@@gnu.org 11@set tramp-bug-report-address tramp-devel@@gnu.org
12 12
13@c Other flags from configuration. 13@c Other flags from configuration.
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index 73774dbc444..c900d3c9a21 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -609,9 +609,7 @@ Emacs dired can't find files."
609 (ignore-errors (delete-file tmpfile)) 609 (ignore-errors (delete-file tmpfile))
610 (tramp-error 610 (tramp-error
611 v 'file-error "Cannot make local copy of file `%s'" filename)) 611 v 'file-error "Cannot make local copy of file `%s'" filename))
612 (set-file-modes 612 (set-file-modes tmpfile (logior (or (file-modes filename) 0) #o0400)))
613 tmpfile
614 (logior (or (file-modes filename) 0) (string-to-number "0400" 8))))
615 tmpfile))) 613 tmpfile)))
616 614
617(defun tramp-adb-handle-file-writable-p (filename) 615(defun tramp-adb-handle-file-writable-p (filename)
@@ -657,9 +655,7 @@ But handle the case, if the \"test\" command is not available."
657 (tmpfile (tramp-compat-make-temp-file filename))) 655 (tmpfile (tramp-compat-make-temp-file filename)))
658 (when (and append (file-exists-p filename)) 656 (when (and append (file-exists-p filename))
659 (copy-file filename tmpfile 'ok) 657 (copy-file filename tmpfile 'ok)
660 (set-file-modes 658 (set-file-modes tmpfile (logior (or (file-modes tmpfile) 0) #o0600)))
661 tmpfile
662 (logior (or (file-modes tmpfile) 0) (string-to-number "0600" 8))))
663 (tramp-run-real-handler 659 (tramp-run-real-handler
664 'write-region (list start end tmpfile append 'no-message lockname)) 660 'write-region (list start end tmpfile append 'no-message lockname))
665 (with-tramp-progress-reporter 661 (with-tramp-progress-reporter
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index dfb4b84517f..d0e7357f8f5 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2184,8 +2184,7 @@ the uid and gid from FILENAME."
2184 (or (eq op 'copy) 2184 (or (eq op 'copy)
2185 (zerop 2185 (zerop
2186 (logand 2186 (logand
2187 (file-modes (file-name-directory localname1)) 2187 (file-modes (file-name-directory localname1)) #o1000)))
2188 (string-to-number "1000" 8))))
2189 (file-writable-p (file-name-directory localname2)) 2188 (file-writable-p (file-name-directory localname2))
2190 (or (file-directory-p localname2) 2189 (or (file-directory-p localname2)
2191 (file-writable-p localname2)))) 2190 (file-writable-p localname2))))
@@ -2229,8 +2228,7 @@ the uid and gid from FILENAME."
2229 ;; We must change the ownership as remote user. 2228 ;; We must change the ownership as remote user.
2230 ;; Since this does not work reliable, we also 2229 ;; Since this does not work reliable, we also
2231 ;; give read permissions. 2230 ;; give read permissions.
2232 (set-file-modes 2231 (set-file-modes (concat prefix tmpfile) #o0777)
2233 (concat prefix tmpfile) (string-to-number "0777" 8))
2234 (tramp-set-file-uid-gid 2232 (tramp-set-file-uid-gid
2235 (concat prefix tmpfile) 2233 (concat prefix tmpfile)
2236 (tramp-get-local-uid 'integer) 2234 (tramp-get-local-uid 'integer)
@@ -2244,7 +2242,7 @@ the uid and gid from FILENAME."
2244 ;; We must change the ownership as local user. 2242 ;; We must change the ownership as local user.
2245 ;; Since this does not work reliable, we also 2243 ;; Since this does not work reliable, we also
2246 ;; give read permissions. 2244 ;; give read permissions.
2247 (set-file-modes tmpfile (string-to-number "0777" 8)) 2245 (set-file-modes tmpfile #o0777)
2248 (tramp-set-file-uid-gid 2246 (tramp-set-file-uid-gid
2249 tmpfile 2247 tmpfile
2250 (tramp-get-remote-uid v 'integer) 2248 (tramp-get-remote-uid v 'integer)
@@ -3267,9 +3265,7 @@ the result will be a local, non-Tramp, file name."
3267 ;; handles permissions. 3265 ;; handles permissions.
3268 ;; Ensure that it is still readable. 3266 ;; Ensure that it is still readable.
3269 (when modes 3267 (when modes
3270 (set-file-modes 3268 (set-file-modes tmpfile (logior (or modes 0) #o0400)))
3271 tmpfile
3272 (logior (or modes 0) (string-to-number "0400" 8))))
3273 3269
3274 ;; This is a bit lengthy due to the different methods 3270 ;; This is a bit lengthy due to the different methods
3275 ;; possible for file transfer. First, we check whether the 3271 ;; possible for file transfer. First, we check whether the
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index a65094f811f..6428e18331b 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -7,7 +7,7 @@
7;; Maintainer: Michael Albinus <michael.albinus@gmx.de> 7;; Maintainer: Michael Albinus <michael.albinus@gmx.de>
8;; Keywords: comm, processes 8;; Keywords: comm, processes
9;; Package: tramp 9;; Package: tramp
10;; Version: 2.4.1 10;; Version: 2.4.2-pre
11;; Package-Requires: ((emacs "24.1")) 11;; Package-Requires: ((emacs "24.1"))
12 12
13;; This file is part of GNU Emacs. 13;; This file is part of GNU Emacs.
@@ -2148,7 +2148,7 @@ been set up by `rfn-eshadow-setup-minibuffer'."
2148If the file modes of FILENAME cannot be determined, return the 2148If the file modes of FILENAME cannot be determined, return the
2149value of `default-file-modes', without execute permissions." 2149value of `default-file-modes', without execute permissions."
2150 (or (file-modes filename) 2150 (or (file-modes filename)
2151 (logand (default-file-modes) (string-to-number "0666" 8)))) 2151 (logand (default-file-modes) #o0666)))
2152 2152
2153(defun tramp-replace-environment-variables (filename) 2153(defun tramp-replace-environment-variables (filename)
2154 "Replace environment variables in FILENAME. 2154 "Replace environment variables in FILENAME.
@@ -3539,7 +3539,7 @@ User is always nil."
3539 ;; When the file is not readable for the owner, it 3539 ;; When the file is not readable for the owner, it
3540 ;; cannot be inserted, even if it is readable for the 3540 ;; cannot be inserted, even if it is readable for the
3541 ;; group or for everybody. 3541 ;; group or for everybody.
3542 (set-file-modes local-copy (string-to-number "0600" 8)) 3542 (set-file-modes local-copy #o0600)
3543 3543
3544 (when (and (null remote-copy) 3544 (when (and (null remote-copy)
3545 (tramp-get-method-parameter 3545 (tramp-get-method-parameter
@@ -4254,47 +4254,47 @@ would yield t. On the other hand, the following check results in nil:
4254 (other-execute-or-sticky (aref mode-chars 9))) 4254 (other-execute-or-sticky (aref mode-chars 9)))
4255 (logior 4255 (logior
4256 (cond 4256 (cond
4257 ((char-equal owner-read ?r) (string-to-number "00400" 8)) 4257 ((char-equal owner-read ?r) #o0400)
4258 ((char-equal owner-read ?-) 0) 4258 ((char-equal owner-read ?-) 0)
4259 (t (error "Second char `%c' must be one of `r-'" owner-read))) 4259 (t (error "Second char `%c' must be one of `r-'" owner-read)))
4260 (cond 4260 (cond
4261 ((char-equal owner-write ?w) (string-to-number "00200" 8)) 4261 ((char-equal owner-write ?w) #o0200)
4262 ((char-equal owner-write ?-) 0) 4262 ((char-equal owner-write ?-) 0)
4263 (t (error "Third char `%c' must be one of `w-'" owner-write))) 4263 (t (error "Third char `%c' must be one of `w-'" owner-write)))
4264 (cond 4264 (cond
4265 ((char-equal owner-execute-or-setid ?x) (string-to-number "00100" 8)) 4265 ((char-equal owner-execute-or-setid ?x) #o0100)
4266 ((char-equal owner-execute-or-setid ?S) (string-to-number "04000" 8)) 4266 ((char-equal owner-execute-or-setid ?S) #o4000)
4267 ((char-equal owner-execute-or-setid ?s) (string-to-number "04100" 8)) 4267 ((char-equal owner-execute-or-setid ?s) #o4100)
4268 ((char-equal owner-execute-or-setid ?-) 0) 4268 ((char-equal owner-execute-or-setid ?-) 0)
4269 (t (error "Fourth char `%c' must be one of `xsS-'" 4269 (t (error "Fourth char `%c' must be one of `xsS-'"
4270 owner-execute-or-setid))) 4270 owner-execute-or-setid)))
4271 (cond 4271 (cond
4272 ((char-equal group-read ?r) (string-to-number "00040" 8)) 4272 ((char-equal group-read ?r) #o0040)
4273 ((char-equal group-read ?-) 0) 4273 ((char-equal group-read ?-) 0)
4274 (t (error "Fifth char `%c' must be one of `r-'" group-read))) 4274 (t (error "Fifth char `%c' must be one of `r-'" group-read)))
4275 (cond 4275 (cond
4276 ((char-equal group-write ?w) (string-to-number "00020" 8)) 4276 ((char-equal group-write ?w) #o0020)
4277 ((char-equal group-write ?-) 0) 4277 ((char-equal group-write ?-) 0)
4278 (t (error "Sixth char `%c' must be one of `w-'" group-write))) 4278 (t (error "Sixth char `%c' must be one of `w-'" group-write)))
4279 (cond 4279 (cond
4280 ((char-equal group-execute-or-setid ?x) (string-to-number "00010" 8)) 4280 ((char-equal group-execute-or-setid ?x) #o0010)
4281 ((char-equal group-execute-or-setid ?S) (string-to-number "02000" 8)) 4281 ((char-equal group-execute-or-setid ?S) #o2000)
4282 ((char-equal group-execute-or-setid ?s) (string-to-number "02010" 8)) 4282 ((char-equal group-execute-or-setid ?s) #o2010)
4283 ((char-equal group-execute-or-setid ?-) 0) 4283 ((char-equal group-execute-or-setid ?-) 0)
4284 (t (error "Seventh char `%c' must be one of `xsS-'" 4284 (t (error "Seventh char `%c' must be one of `xsS-'"
4285 group-execute-or-setid))) 4285 group-execute-or-setid)))
4286 (cond 4286 (cond
4287 ((char-equal other-read ?r) (string-to-number "00004" 8)) 4287 ((char-equal other-read ?r) #o0004)
4288 ((char-equal other-read ?-) 0) 4288 ((char-equal other-read ?-) 0)
4289 (t (error "Eighth char `%c' must be one of `r-'" other-read))) 4289 (t (error "Eighth char `%c' must be one of `r-'" other-read)))
4290 (cond 4290 (cond
4291 ((char-equal other-write ?w) (string-to-number "00002" 8)) 4291 ((char-equal other-write ?w) #o0002)
4292 ((char-equal other-write ?-) 0) 4292 ((char-equal other-write ?-) 0)
4293 (t (error "Ninth char `%c' must be one of `w-'" other-write))) 4293 (t (error "Ninth char `%c' must be one of `w-'" other-write)))
4294 (cond 4294 (cond
4295 ((char-equal other-execute-or-sticky ?x) (string-to-number "00001" 8)) 4295 ((char-equal other-execute-or-sticky ?x) #o0001)
4296 ((char-equal other-execute-or-sticky ?T) (string-to-number "01000" 8)) 4296 ((char-equal other-execute-or-sticky ?T) #o1000)
4297 ((char-equal other-execute-or-sticky ?t) (string-to-number "01001" 8)) 4297 ((char-equal other-execute-or-sticky ?t) #o1001)
4298 ((char-equal other-execute-or-sticky ?-) 0) 4298 ((char-equal other-execute-or-sticky ?-) 0)
4299 (t (error "Tenth char `%c' must be one of `xtT-'" 4299 (t (error "Tenth char `%c' must be one of `xtT-'"
4300 other-execute-or-sticky)))))) 4300 other-execute-or-sticky))))))
@@ -4353,7 +4353,11 @@ If UID and GID are provided, these values are used; otherwise uid
4353and gid of the corresponding remote or local user is taken, 4353and gid of the corresponding remote or local user is taken,
4354depending whether FILENAME is remote or local. Both parameters 4354depending whether FILENAME is remote or local. Both parameters
4355must be non-negative integers. 4355must be non-negative integers.
4356The setgid bit of the upper directory is respected.
4356If FILENAME is remote, a file name handler is called." 4357If FILENAME is remote, a file name handler is called."
4358 (unless (zerop (logand #o2000 (file-modes (file-name-directory filename))))
4359 (setq gid (tramp-compat-file-attribute-group-id
4360 (file-attributes (file-name-directory filename) 'integer))))
4357 (let ((handler (find-file-name-handler filename 'tramp-set-file-uid-gid))) 4361 (let ((handler (find-file-name-handler filename 'tramp-set-file-uid-gid)))
4358 (if handler 4362 (if handler
4359 (funcall handler 'tramp-set-file-uid-gid filename uid gid) 4363 (funcall handler 'tramp-set-file-uid-gid filename uid gid)
@@ -4521,7 +4525,7 @@ Return the local name of the temporary file."
4521 (setq result nil) 4525 (setq result nil)
4522 ;; This creates the file by side effect. 4526 ;; This creates the file by side effect.
4523 (set-file-times result) 4527 (set-file-times result)
4524 (set-file-modes result (string-to-number "0700" 8)))) 4528 (set-file-modes result #o0700)))
4525 4529
4526 ;; Return the local part. 4530 ;; Return the local part.
4527 (with-parsed-tramp-file-name result nil localname))) 4531 (with-parsed-tramp-file-name result nil localname)))
diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el
index ccc7de12cb4..83d34c02220 100644
--- a/lisp/net/trampver.el
+++ b/lisp/net/trampver.el
@@ -31,7 +31,7 @@
31;; aclocal.m4; should be changed only there. 31;; aclocal.m4; should be changed only there.
32 32
33;;;###tramp-autoload 33;;;###tramp-autoload
34(defconst tramp-version "2.4.1" 34(defconst tramp-version "2.4.2-pre"
35 "This version of Tramp.") 35 "This version of Tramp.")
36 36
37;;;###tramp-autoload 37;;;###tramp-autoload
@@ -65,7 +65,7 @@
65;; Check for Emacs version. 65;; Check for Emacs version.
66(let ((x (if (not (string-lessp emacs-version "24.1")) 66(let ((x (if (not (string-lessp emacs-version "24.1"))
67 "ok" 67 "ok"
68 (format "Tramp 2.4.1 is not fit for %s" 68 (format "Tramp 2.4.2-pre is not fit for %s"
69 (replace-regexp-in-string "\n" "" (emacs-version)))))) 69 (replace-regexp-in-string "\n" "" (emacs-version))))))
70 (unless (string-equal "ok" x) (error "%s" x))) 70 (unless (string-equal "ok" x) (error "%s" x)))
71 71