]> gitweb.fluxo.info Git - keyringer.git/commitdiff
Simpler ramdisk/tmpfs check at keyringer_check_tmp
authorSilvio Rhatto <rhatto@riseup.net>
Tue, 26 Nov 2013 15:02:58 +0000 (13:02 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Tue, 26 Nov 2013 15:02:58 +0000 (13:02 -0200)
lib/keyringer/functions

index 667b0cd098213831fc34593d05bf07db16195194..a278cafe793bf05137f1a693ba128e97b7ff883f 100755 (executable)
@@ -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