Skip to content
This repository
Browse code

Merge pull request #361 from zaadjis/master

Untrusting a .rvmrc doesn't work b/c only the hash is stored
  • Loading branch information...
commit 699b29e35a76e95eae14904407073deca1f210de 2 parents d992712 + 80e707e
Wayne E. Seguin authored August 11, 2011

Showing 1 changed file with 18 additions and 12 deletions. Show diff stats Hide diff stats

  1. 30  scripts/functions/rvmrc
30  scripts/functions/rvmrc
@@ -47,7 +47,7 @@ __rvm_trust_rvmrc()
47 47
 {
48 48
   __rvm_reset_rvmrc_trust "$1"
49 49
   "$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" \
50  
-    "$(__rvm_rvmrc_key "$1")" "$(__rvm_md5_for_contents "$1")" >/dev/null 2>&1
  50
+    "$(__rvm_rvmrc_key "$1")" "1;$(__rvm_md5_for_contents "$1")" >/dev/null 2>&1
51 51
   return $?
52 52
 }
53 53
 
@@ -55,7 +55,7 @@ __rvm_untrust_rvmrc()
55 55
 {
56 56
   __rvm_reset_rvmrc_trust "$1"
57 57
   "$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" \
58  
-    "$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1
  58
+    "$(__rvm_rvmrc_key "$1")" "0;$(__rvm_md5_for_contents "$1")" >/dev/null 2>&1
59 59
   return $?
60 60
 }
61 61
 
@@ -104,16 +104,20 @@ __rvm_rvmrc_tools()
104 104
 
105 105
       if [[ -f "$rvmrc_path" ]]
106 106
       then
107  
-        local trusted_value="$(__rvm_rvmrc_stored_trust "$rvmrc_path")"
108  
-        if [[ "$trusted_value" = "$(__rvm_md5_for_contents "$rvmrc_path")" ]]
  107
+        local saveIFS=$IFS
  108
+        IFS=$';'
  109
+        local trust=($(__rvm_rvmrc_stored_trust "$rvmrc_path"))
  110
+        IFS=$saveIFS
  111
+
  112
+        if [[ "${trust[1]}" ]] && [[ "${trust[1]}" != "$(__rvm_md5_for_contents "$rvmrc_path")" ]]
  113
+        then
  114
+          echo "The rvmrc at '$rvmrc_path' contains unreviewed changes."
  115
+        elif [[ "${trust[0]}" = "1" ]]
109 116
         then
110 117
           echo "The rvmrc at '$rvmrc_path' is currently trusted."
111  
-        elif [[ "$trusted_value" = "0" ]]
  118
+        elif [[ "${trust[0]}" = "0" ]]
112 119
         then
113 120
           echo "The rvmrc at '$rvmrc_path' is currently untrusted."
114  
-        elif [[ -n "$trusted_value" ]]
115  
-        then
116  
-          echo "The rvmrc at '$rvmrc_path' contains unreviewed changes."
117 121
         else
118 122
           echo "The trustiworthiness of '$rvmrc_path' is currently unknown."
119 123
         fi
@@ -146,14 +150,16 @@ __rvm_check_rvmrc_trustworthiness()
146 150
   # Trust when they have the flag... of doom!
147 151
   if [[ -n "$1" && ${rvm_trust_rvmrcs_flag:-0} -eq 0 ]]
148 152
   then
149  
-    value="$(__rvm_rvmrc_stored_trust "$1")"
150  
-    md5_for_contents="$(__rvm_md5_for_contents "$1")"
  153
+    local saveIFS=$IFS
  154
+    IFS=$';'
  155
+    local trust=($(__rvm_rvmrc_stored_trust "$1"))
  156
+    IFS=$saveIFS
151 157
 
152  
-    if [[ -z "$value" ]] || [[ "$value" != "$md5_for_contents" ]]
  158
+    if [[ -z "${trust[1]}" ]] || [[ "${trust[1]}" != "$(__rvm_md5_for_contents "$1")" ]]
153 159
     then
154 160
       __rvm_ask_to_trust "$1"
155 161
     else
156  
-      [[ "$md5_for_contents" = "$md5_for_contents" ]]
  162
+      [[ "${trust[0]}" = "1" ]]
157 163
     fi
158 164
 
159 165
   fi

0 notes on commit 699b29e

Please sign in to comment.
Something went wrong with that request. Please try again.