# # # add_file "tests/t_no_persist_phrase.at" # content [4c25100bf7d7c11892124eaaebeb2b32d671e134] # # patch "ChangeLog" # from [e390eee7ab1d79fd2791c6571a58e017f8576335] # to [2b0d17d621c7332beccae61e81da3022d90342b5] # # patch "keys.cc" # from [f3cf085b551faae43daa06fd8cd9b307bcde462f] # to [b61b2cda83c67d33c1a2fb3ff0f7098ecfeb1570] # # patch "testsuite.at" # from [a1e90a759bbe7ea6d49bdd600cb46c515af9ddc2] # to [77e349809a60bede569a6890139dc03154cb2b70] # ============================================================ --- tests/t_no_persist_phrase.at 4c25100bf7d7c11892124eaaebeb2b32d671e134 +++ tests/t_no_persist_phrase.at 4c25100bf7d7c11892124eaaebeb2b32d671e134 @@ -0,0 +1,39 @@ +# -*- Autoconf -*- + +AT_SETUP([disallowing persistence of passphrase]) + +MONOTONE_SETUP + +AT_DATA(persist.lua, [ +function persist_phrase_ok() + return false +end + +get_passphrase = nil +]) + +AT_DATA(input.txt, [version 0 of the file +]) + +AT_CHECK(MONOTONE add input.txt, [], [ignore], [ignore]) + +AT_DATA(input.txt, [version 1 of the file +]) + +AT_DATA(passphrase, address@hidden address@hidden address@hidden address@hidden +]) + +AT_CHECK(MONOTONE --branch=testbranch --rcfile=persist.lua commit --message=blah-blah + + * keys.cc (get_passphrase): Update std::map correctly--remove + existing cached passphrase for a given keyid, then store the new + one using safe_insert(). + (make_signature): Fix crash when running monotone with persistent + passphrases disallowed--remove shared_ptr that was going out of + scope too early, and shadowed and existing shared_ptr in the + correct scope. + * tests/t_no_persist_phrase.at: New test to check that basic no + persistent passphrase functionality works. + * testsuite.at: Include new test. + 2006-01-18 Timothy Brownawell * merkle_tree.{cc,hh}: Add a locate_item() function to find the ============================================================ --- keys.cc f3cf085b551faae43daa06fd8cd9b307bcde462f +++ keys.cc b61b2cda83c67d33c1a2fb3ff0f7098ecfeb1570 @@ -16,6 +16,7 @@ #include "lua.hh" #include "netio.hh" #include "platform.hh" +#include "safe_map.hh" #include "transforms.hh" #include "sanity.hh" #include "ui.hh" @@ -124,7 +125,8 @@ // permit security relaxation. maybe. if (persist_phrase) { - phrases.insert(make_pair(keyid,string(pass1))); + phrases.erase(keyid); + safe_insert(phrases, make_pair(keyid, string(pass1))); } } catch (...) @@ -337,7 +339,6 @@ else { - shared_ptr priv_key; priv_key = get_private_key(app.lua, id, priv); signer = shared_ptr(get_pk_signer(*priv_key, "EMSA3(SHA-1)")); ============================================================ --- testsuite.at a1e90a759bbe7ea6d49bdd600cb46c515af9ddc2 +++ testsuite.at 77e349809a60bede569a6890139dc03154cb2b70 @@ -756,3 +756,4 @@ m4_include(tests/t_rosterify_one_rev.at) m4_include(tests/t_selectors_b_h.at) m4_include(tests/t_revert_ignored.at) +m4_include(tests/t_no_persist_phrase.at)