summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorEiichi Sato <sato.eiichi@gmail.com>2015-03-21 03:04:28 +0900
committerEiichi Sato <sato.eiichi@gmail.com>2015-03-28 15:40:20 +0900
commite2393938bf56f2bd6b93ea11e9282cf6d40a2514 (patch)
tree1828bf704f2056d7e4fc3e3503f035bf36a72397
parent13ca8e30589c55dd263eb43824de9ac8d2ad8306 (diff)
downloadranger-e2393938bf56f2bd6b93ea11e9282cf6d40a2514.tar.gz
ranger.py: fixed issues with $tempfile in embedded shell
Previously, $tempfile (namely, /tmp/chosendir) was not cleaned up
correctly when the ranger process quit in `pwd` without moving to other
directory.  This causes permission errors in multi-user environments
trying to overwrite $tempfile created by a different user.

This commit solves the problem in two ways:

 - Correctly clean up temporary files
 - Avoid writing to the same temporary by using mktemp(1)
-rwxr-xr-xranger.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/ranger.py b/ranger.py
index 4b2e7daa..1d7e42e1 100755
--- a/ranger.py
+++ b/ranger.py
@@ -9,7 +9,7 @@
 # default is simply "ranger". (Not this file itself!)
 # The other arguments are passed to ranger.
 """":
-tempfile='/tmp/chosendir'
+tempfile="$(mktemp)"
 ranger="${1:-ranger}"
 test -z "$1" || shift
 "$ranger" --choosedir="$tempfile" "${@:-$(pwd)}"
@@ -17,8 +17,8 @@ returnvalue=$?
 test -f "$tempfile" &&
 if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
     cd "$(cat "$tempfile")"
-    rm -f -- "$tempfile"
 fi
+rm -f -- "$tempfile"
 return $returnvalue
 """ and None
 
8:22:57 +0700 committer stepshal <nessento@openmailbox.org> 2016-06-16 18:22:57 +0700 Add two blank lines where is expected' href='/akspecs/ranger/commit/examples/plugin_chmod_keybindings.py?h=v1.9.3&id=ab41c7766ced3f1b8f6b4ed317f0db4e0d71b897'>ab41c776 ^
ca1a5d21 ^
b3d031a9 ^
972da7ba ^
d1a1173d ^

33aeef8e ^
d1a1173d ^


972da7ba ^
b3d031a9 ^
ca1a5d21 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26