diff options
author | Eiichi Sato <sato.eiichi@gmail.com> | 2015-03-21 03:04:28 +0900 |
---|---|---|
committer | Eiichi Sato <sato.eiichi@gmail.com> | 2015-03-28 15:40:20 +0900 |
commit | e2393938bf56f2bd6b93ea11e9282cf6d40a2514 (patch) | |
tree | 1828bf704f2056d7e4fc3e3503f035bf36a72397 | |
parent | 13ca8e30589c55dd263eb43824de9ac8d2ad8306 (diff) | |
download | ranger-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-x | ranger.py | 4 |
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 |