# # # add_dir "tests/non_workspace_keydir" # # add_file "tests/non_workspace_keydir/__driver__.lua" # content [5ddca64934a6f5710f345e58a31c652db2f2529a] # # patch "cmd_netsync.cc" # from [b8ca190aad2224943377ec9a1371bfbada568d4b] # to [3fc803802fa21cc1e8e35faa705c749fa284c841] # # patch "options_list.hh" # from [5ee94e644545cd8550638c47113655d8022d78c8] # to [62ca74d018e89677fff23a364bbc161d2cb153c3] # # patch "platform.hh" # from [b39c772b2b9967346509da8f1c814f2b8549889c] # to [7b09b4e28d7c7379e6336a3fa8d76cf937d3ac1f] # ============================================================ --- tests/non_workspace_keydir/__driver__.lua 5ddca64934a6f5710f345e58a31c652db2f2529a +++ tests/non_workspace_keydir/__driver__.lua 5ddca64934a6f5710f345e58a31c652db2f2529a @@ -0,0 +1,37 @@ +mtn_setup() + +-- adapted from lua-testsuite.lua +function pure_mtn(...) + if monotone_path == nil then + monotone_path = os.getenv("mtn") + if monotone_path == nil then + err("'mtn' environment variable not set") + end + end + return {monotone_path, "--norc", "--root=" .. test.root, "--db", "test.db", + "--rcfile", test.root .. "/test_hooks.lua", unpack(arg)} +end + +-- this should find a private key in the specified keydir +-- presumably the -15 return code comes from the kill -15 in the finish function in testlib.lua + +srv = bg(pure_mtn("serve", "--confdir="..test.root, "--keydir="..test.root.."/keys"), -15, false, true) +sleep(2) +srv:finish() + +-- this should find a private key in the keys directory under the specified confdir +-- presumably the -15 return code comes from the kill -15 in the finish function in testlib.lua + +srv = bg(pure_mtn("serve" ,"--confdir="..test.root), -15, false, true) +sleep(2) +srv:finish() + +-- this should fail to decrypt the private key found in ~/.monotone/keys + +-- however before get_default_keydir was added to the key_dir option in +-- options_list.hh it would hit an invariant on an empty key_dir for any +-- CMD_NO_WORKSPACE that attempted to call get_user_key(...) + +srv = bg(pure_mtn("serve"), 1, false, true) +sleep(2) +srv:finish() ============================================================ --- cmd_netsync.cc b8ca190aad2224943377ec9a1371bfbada568d4b +++ cmd_netsync.cc 3fc803802fa21cc1e8e35faa705c749fa284c841 @@ -472,7 +472,7 @@ CMD_NO_WORKSPACE(serve, "serve", "", CMD if (app.opts.use_transport_auth) { N(app.lua.hook_persist_phrase_ok(), - F("need permission to store persistent passphrase " + F("need permission to store persistent passphrase " "(see hook persist_phrase_ok())")); if (!app.opts.bind_uris.empty()) ============================================================ --- options_list.hh 5ee94e644545cd8550638c47113655d8022d78c8 +++ options_list.hh 62ca74d018e89677fff23a364bbc161d2cb153c3 @@ -291,7 +291,7 @@ OPTION(globals, key, true, "key,k", gett } #endif -GOPT(key_dir, "keydir", system_path, , +GOPT(key_dir, "keydir", system_path, get_default_keydir(), gettext_noop("set location of key store")) #ifdef option_bodies { @@ -587,4 +587,3 @@ OPTION(automate_inventory_opts, no_corre // indent-tabs-mode: nil // End: // vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s: - ============================================================ --- platform.hh b39c772b2b9967346509da8f1c814f2b8549889c +++ platform.hh 7b09b4e28d7c7379e6336a3fa8d76cf937d3ac1f @@ -80,7 +80,7 @@ public: // this time in the future?" bit in the hashed information. This bit // will change when we pass the future point, and trigger a re-check of // the file's contents. - // + // // This is, of course, still not perfect. There is no way to make our stat // atomic with the actual read of the file, so there's always a race condition // there. Additionally, this handling means that checkout will never actually @@ -111,6 +111,10 @@ std::string get_default_confdir(); void change_current_working_dir(std::string const & to); std::string tilde_expand(std::string const & path); std::string get_default_confdir(); + +inline std::string get_default_keydir() +{ return get_default_confdir() + "/keys"; } + std::string get_homedir(); namespace path {