Permalink
Browse files

Merge pull request #361 from zaadjis/master

Untrusting a .rvmrc doesn't work b/c only the hash is stored
  • Loading branch information...
2 parents d992712 + 80e707e commit 699b29e35a76e95eae14904407073deca1f210de @wayneeseguin wayneeseguin committed Aug 12, 2011
Showing with 18 additions and 12 deletions.
  1. +18 −12 scripts/functions/rvmrc
@@ -47,15 +47,15 @@ __rvm_trust_rvmrc()
{
__rvm_reset_rvmrc_trust "$1"
"$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" \
- "$(__rvm_rvmrc_key "$1")" "$(__rvm_md5_for_contents "$1")" >/dev/null 2>&1
+ "$(__rvm_rvmrc_key "$1")" "1;$(__rvm_md5_for_contents "$1")" >/dev/null 2>&1
return $?
}
__rvm_untrust_rvmrc()
{
__rvm_reset_rvmrc_trust "$1"
"$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" \
- "$(__rvm_rvmrc_key "$1")" "0" >/dev/null 2>&1
+ "$(__rvm_rvmrc_key "$1")" "0;$(__rvm_md5_for_contents "$1")" >/dev/null 2>&1
return $?
}
@@ -104,16 +104,20 @@ __rvm_rvmrc_tools()
if [[ -f "$rvmrc_path" ]]
then
- local trusted_value="$(__rvm_rvmrc_stored_trust "$rvmrc_path")"
- if [[ "$trusted_value" = "$(__rvm_md5_for_contents "$rvmrc_path")" ]]
+ local saveIFS=$IFS
+ IFS=$';'
+ local trust=($(__rvm_rvmrc_stored_trust "$rvmrc_path"))
+ IFS=$saveIFS
+
+ if [[ "${trust[1]}" ]] && [[ "${trust[1]}" != "$(__rvm_md5_for_contents "$rvmrc_path")" ]]
+ then
+ echo "The rvmrc at '$rvmrc_path' contains unreviewed changes."
+ elif [[ "${trust[0]}" = "1" ]]
then
echo "The rvmrc at '$rvmrc_path' is currently trusted."
- elif [[ "$trusted_value" = "0" ]]
+ elif [[ "${trust[0]}" = "0" ]]
then
echo "The rvmrc at '$rvmrc_path' is currently untrusted."
- elif [[ -n "$trusted_value" ]]
- then
- echo "The rvmrc at '$rvmrc_path' contains unreviewed changes."
else
echo "The trustiworthiness of '$rvmrc_path' is currently unknown."
fi
@@ -146,14 +150,16 @@ __rvm_check_rvmrc_trustworthiness()
# Trust when they have the flag... of doom!
if [[ -n "$1" && ${rvm_trust_rvmrcs_flag:-0} -eq 0 ]]
then
- value="$(__rvm_rvmrc_stored_trust "$1")"
- md5_for_contents="$(__rvm_md5_for_contents "$1")"
+ local saveIFS=$IFS
+ IFS=$';'
+ local trust=($(__rvm_rvmrc_stored_trust "$1"))
+ IFS=$saveIFS
- if [[ -z "$value" ]] || [[ "$value" != "$md5_for_contents" ]]
+ if [[ -z "${trust[1]}" ]] || [[ "${trust[1]}" != "$(__rvm_md5_for_contents "$1")" ]]
then
__rvm_ask_to_trust "$1"
else
- [[ "$md5_for_contents" = "$md5_for_contents" ]]
+ [[ "${trust[0]}" = "1" ]]
fi
fi

0 comments on commit 699b29e

Please sign in to comment.