# # # add_file "tests/t_no_log_password.at" # content [e24beec232d342ed6092565160a22125e8201a25] # # patch "ChangeLog" # from [471a335cd00a1ca8d3edfa50e17e0a6f4971ef31] # to [96326add6188c0ae836e19e174016cbe1c8770ff] # # patch "lua.cc" # from [f383734fd155f9144eb978155db7da45660c5d40] # to [6abb5987206ee45b2389366b815cc391e9ecce7b] # # patch "testsuite.at" # from [fa3102ad0e7ece720b941c86e2ab5505784fb931] # to [79d82504789095bb96bdc3c50fd7fbf57b3a51ec] # ============================================================ --- tests/t_no_log_password.at e24beec232d342ed6092565160a22125e8201a25 +++ tests/t_no_log_password.at e24beec232d342ed6092565160a22125e8201a25 @@ -0,0 +1,22 @@ +# -*- Autoconf -*- + +AT_SETUP([(imp) do not log the result of hook_get_passphrase]) + +MTN_SETUP + +ADD_FILE(input.txt, [version 0 of the file +]) + +AT_DATA(hook.lua, [function get_passphrase(keyid) + if keyid == "quux" then return "xyzzy" end + return keyid +end +]) + +AT_CHECK((echo xyzzypassphrasexyzzy; echo xyzzypassphrasexyzzy) | MTN genkey quux, [], [ignore], [ignore]) + +AT_CHECK(MTN --branch=testbranch --debug commit -m foo --rcfile hook.lua, [], [ignore], [stderr]) + +AT_CHECK(QGREP xyzzypassphrasexyzzy stderr, [1], [ignore], [ignore]) + +AT_CLEANUP ============================================================ --- ChangeLog 471a335cd00a1ca8d3edfa50e17e0a6f4971ef31 +++ ChangeLog 96326add6188c0ae836e19e174016cbe1c8770ff @@ -1,5 +1,13 @@ 2006-04-25 Timothy Brownawell + * lua.cc: There is now an "extract_classified_str" to go with + "extract_str", which doesn't log the value of the returned string. + Use this in hook_get_passphrase. + * tests/t_no_log_password.at: Test that the passphrase is not logged. + * testsuite.at: Call it. + +2006-04-25 Timothy Brownawell + * po/POTFILES.in: add cmd.hh and the cmd_*.cc files 2006-04-25 Richard Levitte ============================================================ --- lua.cc f383734fd155f9144eb978155db7da45660c5d40 +++ lua.cc 6abb5987206ee45b2389366b815cc391e9ecce7b @@ -204,7 +204,7 @@ // extractors - Lua & extract_str(string & str) + Lua & extract_str_nolog(string & str) { if (failed) return *this; if (!lua_isstring (st, -1)) @@ -213,10 +213,23 @@ return *this; } str = string(lua_tostring(st, -1), lua_strlen(st, -1)); + return *this; + } + + Lua & extract_str(string & str) + { + extract_str_nolog(str); L(FL("lua: extracted string = %s") % str); return *this; } + Lua & extract_classified_str(string & str) + { + extract_str_nolog(str); + L(FL("lua: extracted string [CLASSIFIED]")); + return *this; + } + Lua & extract_int(int & i) { if (failed) return *this; @@ -939,7 +952,7 @@ .func("get_passphrase") .push_str(k()) .call(1,1) - .extract_str(phrase) + .extract_classified_str(phrase) .ok(); } ============================================================ --- testsuite.at fa3102ad0e7ece720b941c86e2ab5505784fb931 +++ testsuite.at 79d82504789095bb96bdc3c50fd7fbf57b3a51ec @@ -881,3 +881,4 @@ m4_include(tests/t_checkout_heads.at) m4_include(tests/t_ls_epochs.at) m4_include(tests/t_hook_helpers.at) +m4_include(tests/t_no_log_password.at)