summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-11-26 13:02:58 -0200
committerSilvio Rhatto <rhatto@riseup.net>2013-11-26 13:02:58 -0200
commit812ab3dc1031f34dc001339f2cb9864fd7c09a70 (patch)
treeff7b1369c92ab47fb751add5d5d35d1260e8c62d
parentef014f585c83958488f8349feba9c3eefbf2f419 (diff)
downloadkeyringer-812ab3dc1031f34dc001339f2cb9864fd7c09a70.tar.gz
keyringer-812ab3dc1031f34dc001339f2cb9864fd7c09a70.tar.bz2
Simpler ramdisk/tmpfs check at keyringer_check_tmp
-rwxr-xr-xlib/keyringer/functions18
1 files changed, 4 insertions, 14 deletions
diff --git a/lib/keyringer/functions b/lib/keyringer/functions
index 667b0cd..a278caf 100755
--- a/lib/keyringer/functions
+++ b/lib/keyringer/functions
@@ -114,7 +114,7 @@ function keyringer_is_git {
# Check the security of a temporary folder
function keyringer_check_tmp {
local path="$1"
- local major
+ local mount
# Mode check
if [ -z "$path" ] || [ ! -d "$path" ] || [ ! -w "$path" ] || [ ! -x "$path" ]; then
@@ -122,19 +122,9 @@ function keyringer_check_tmp {
fi
# Ramdisk check
- # Non-device mounts have major number "0", see
- # https://www.kernel.org/doc/Documentation/devices.txt
- if [ -x "/sbin/udevadm" ]; then
- major="$(/sbin/udevadm info --device-id-of-file "$path" | cut -d : -f 1)"
- elif which mountpoint &> /dev/null; then
- major="$(mountpoint -d $(df "$path" | sed -n '$p' | awk '{print $NF}') | cut -d : -f 1)"
- fi
-
- if [ ! -z "$major" ]; then
- return $major
- else
- return 1
- fi
+ mount="`df "$path" | sed -n '$p' | awk '{ print $NF }'`"
+ mount -l -t tmpfs | awk '{ print $3 }' | grep -q -e "^$mount$";
+ return $?
}
# Setup a temporary file