Skip to content

Commit

Permalink
Merge pull request #361 from zaadjis/master
Browse files Browse the repository at this point in the history
Untrusting a .rvmrc doesn't work b/c only the hash is stored
  • Loading branch information
wayneeseguin committed Aug 12, 2011
2 parents d992712 + 80e707e commit 699b29e
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions scripts/functions/rvmrc
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ __rvm_trust_rvmrc()
{ {
__rvm_reset_rvmrc_trust "$1" __rvm_reset_rvmrc_trust "$1"
"$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" \ "$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 $? return $?
} }


__rvm_untrust_rvmrc() __rvm_untrust_rvmrc()
{ {
__rvm_reset_rvmrc_trust "$1" __rvm_reset_rvmrc_trust "$1"
"$rvm_scripts_path/db" "$rvm_user_path/rvmrcs" \ "$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 $? return $?
} }


Expand Down Expand Up @@ -104,16 +104,20 @@ __rvm_rvmrc_tools()


if [[ -f "$rvmrc_path" ]] if [[ -f "$rvmrc_path" ]]
then then
local trusted_value="$(__rvm_rvmrc_stored_trust "$rvmrc_path")" local saveIFS=$IFS
if [[ "$trusted_value" = "$(__rvm_md5_for_contents "$rvmrc_path")" ]] 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 then
echo "The rvmrc at '$rvmrc_path' is currently trusted." echo "The rvmrc at '$rvmrc_path' is currently trusted."
elif [[ "$trusted_value" = "0" ]] elif [[ "${trust[0]}" = "0" ]]
then then
echo "The rvmrc at '$rvmrc_path' is currently untrusted." echo "The rvmrc at '$rvmrc_path' is currently untrusted."
elif [[ -n "$trusted_value" ]]
then
echo "The rvmrc at '$rvmrc_path' contains unreviewed changes."
else else
echo "The trustiworthiness of '$rvmrc_path' is currently unknown." echo "The trustiworthiness of '$rvmrc_path' is currently unknown."
fi fi
Expand Down Expand Up @@ -146,14 +150,16 @@ __rvm_check_rvmrc_trustworthiness()
# Trust when they have the flag... of doom! # Trust when they have the flag... of doom!
if [[ -n "$1" && ${rvm_trust_rvmrcs_flag:-0} -eq 0 ]] if [[ -n "$1" && ${rvm_trust_rvmrcs_flag:-0} -eq 0 ]]
then then
value="$(__rvm_rvmrc_stored_trust "$1")" local saveIFS=$IFS
md5_for_contents="$(__rvm_md5_for_contents "$1")" 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 then
__rvm_ask_to_trust "$1" __rvm_ask_to_trust "$1"
else else
[[ "$md5_for_contents" = "$md5_for_contents" ]] [[ "${trust[0]}" = "1" ]]
fi fi


fi fi
Expand Down

0 comments on commit 699b29e

Please sign in to comment.