# # patch "ChangeLog" # from [759652f62c49dd33941686f7dc390269e2cae41e] # to [5c90e7715b774c4ff564805af24a6c67388afcf5] # # patch "app_state.cc" # from [95b80895c52c4882e33f41e100099b6f7536504d] # to [7c07c3e2fdd93785501045113bb5ad53c7b9c8c6] # # patch "app_state.hh" # from [1ef19ce6f39d7218cff11fffb74b4a2c187874c3] # to [3038b295c471109120a068d0219cfc96d06fb199] # # patch "commands.cc" # from [d3c7c640db9dbd79733ad1cb555759a11f7567ff] # to [3e9f7cc114e41187072354743b8f5f2759e371e7] # # patch "monotone.cc" # from [d33163fa6269ada5c72e97b3ac6aeb0c51186575] # to [ac18f5db69aaf109485e4e807365247964ae955f] # # patch "netsync.cc" # from [71d961a2e668c7b4f96ab03520eb72d6c90c4914] # to [8dd0970ff9d0f74cb97c49e8b239c2256e2bec8e] # # patch "options.hh" # from [2fb08fad90b5079eb5ab3455037b8a6433e439cb] # to [3fbf3de00d5b037c5de4cb232691e19a02488aa5] # # patch "tests/t_netsync_pubkey.at" # from [f23c7b6f4f92b5a8353e275cc2f1e8efdb95e147] # to [331073b6faf1b43e2ff5ba2d3b557842e3ac28c8] # ======================================================================== --- ChangeLog 759652f62c49dd33941686f7dc390269e2cae41e +++ ChangeLog 5c90e7715b774c4ff564805af24a6c67388afcf5 @@ -1,3 +1,14 @@ +2005-10-16 Timothy Brownawell + + Teach client to optionally push unused keys; new pubkeys can now be + given to a server without restarting it. + * app_state.{cc,hh}, monotone.cc, options.hh: + new command-specific-option --key-to-push= , used to sync/push + a key that hasn't signed anything + * netsync.cc: make it work + * commands.cc: push and sync take it + * tests/t_netsync_pubkey.at: test it + 2005-10-14 Nathaniel Smith * key_store.{cc,hh} (get_key_dir): New method. ======================================================================== --- app_state.cc 95b80895c52c4882e33f41e100099b6f7536504d +++ app_state.cc 7c07c3e2fdd93785501045113bb5ad53c7b9c8c6 @@ -292,6 +292,14 @@ } void +app_state::add_key_to_push(utf8 const & key) +{ + rsa_keypair_id k; + internalize_rsa_keypair_id(key, k); + keys_to_push.push_back(k); +} + +void app_state::set_root(system_path const & path) { require_path_is_directory(path, ======================================================================== --- app_state.hh 1ef19ce6f39d7218cff11fffb74b4a2c187874c3 +++ app_state.hh 3038b295c471109120a068d0219cfc96d06fb199 @@ -66,6 +66,7 @@ utf8 bind_port; bool missing; bool unknown; + std::vector keys_to_push; @@ -112,6 +113,7 @@ void add_exclude(utf8 const & exclude_pattern); void set_diff_format(diff_type dtype); void set_diff_args(utf8 const & args); + void add_key_to_push(utf8 const & key); void set_stdhooks(bool b); void set_rcfiles(bool b); ======================================================================== --- commands.cc d3c7c640db9dbd79733ad1cb555759a11f7567ff +++ commands.cc 3e9f7cc114e41187072354743b8f5f2759e371e7 @@ -2056,7 +2056,7 @@ CMD(push, N_("network"), N_("[ADDRESS[:PORTNUMBER] [PATTERN]]"), N_("push branches matching PATTERN to netsync server at ADDRESS"), - OPT_SET_DEFAULT % OPT_EXCLUDE) + OPT_SET_DEFAULT % OPT_EXCLUDE % OPT_KEY_TO_PUSH) { utf8 addr, include_pattern, exclude_pattern; process_netsync_args(name, args, addr, include_pattern, exclude_pattern, true, false, app); @@ -2085,7 +2085,7 @@ CMD(sync, N_("network"), N_("[ADDRESS[:PORTNUMBER] [PATTERN]]"), N_("sync branches matching PATTERN with netsync server at ADDRESS"), - OPT_SET_DEFAULT % OPT_EXCLUDE) + OPT_SET_DEFAULT % OPT_EXCLUDE % OPT_KEY_TO_PUSH) { utf8 addr, include_pattern, exclude_pattern; process_netsync_args(name, args, addr, include_pattern, exclude_pattern, true, false, app); ======================================================================== --- monotone.cc d33163fa6269ada5c72e97b3ac6aeb0c51186575 +++ monotone.cc ac18f5db69aaf109485e4e807365247964ae955f @@ -72,6 +72,7 @@ {"bind", 0, POPT_ARG_STRING, &argstr, OPT_BIND, gettext_noop("address:port to listen on (default :5253)"), NULL}, {"missing", 0, POPT_ARG_NONE, NULL, OPT_MISSING, gettext_noop("perform the operations for files missing from working directory"), NULL}, {"unknown", 0, POPT_ARG_NONE, NULL, OPT_UNKNOWN, gettext_noop("perform the operations for unknown files from working directory"), NULL}, + {"key-to-push", 0, POPT_ARG_STRING, &argstr, OPT_KEY_TO_PUSH, gettext_noop("push the specified key even if it hasn't signed anything"), NULL}, { NULL, 0, 0, NULL, 0, NULL, NULL } }; @@ -472,6 +473,12 @@ app.unknown = true; break; + case OPT_KEY_TO_PUSH: + { + app.add_key_to_push(string(argstr)); + } + break; + case OPT_HELP: default: requested_help = true; ======================================================================== --- netsync.cc 71d961a2e668c7b4f96ab03520eb72d6c90c4914 +++ netsync.cc 8dd0970ff9d0f74cb97c49e8b239c2256e2bec8e @@ -3572,6 +3572,22 @@ } } + // add any keys specified on the command line + for (vector::const_iterator key = app.keys_to_push.begin(); + key != app.keys_to_push.end(); ++key) + { + if (inserted_keys.find(*key) == inserted_keys.end()) + { + if (!app.db.public_key_exists(*key)) + { + if (app.keys.key_pair_exists(*key)) + app.keys.ensure_in_database(*key); + else + W(F("Cannot find key '%s'") % *key); + } + inserted_keys.insert(*key); + } + } // insert all the keys for (set::const_iterator key = inserted_keys.begin(); key != inserted_keys.end(); key++) ======================================================================== --- options.hh 2fb08fad90b5079eb5ab3455037b8a6433e439cb +++ options.hh 3fbf3de00d5b037c5de4cb232691e19a02488aa5 @@ -47,3 +47,4 @@ #define OPT_BIND 38 #define OPT_MISSING 39 #define OPT_UNKNOWN 40 +#define OPT_KEY_TO_PUSH 41 ======================================================================== --- tests/t_netsync_pubkey.at f23c7b6f4f92b5a8353e275cc2f1e8efdb95e147 +++ tests/t_netsync_pubkey.at 331073b6faf1b43e2ff5ba2d3b557842e3ac28c8 @@ -43,6 +43,12 @@ AT_CHECK(QGREP($PUBKEY stdout), [1]) AT_CHECK(QGREP($PRIVKEY stdout), [1]) +# Now check that --key-to-push works. +NETSYNC_SERVE_N_START(2, testbranch) +AT_CHECK(MONOTONE --rcfile=netsync.lua push NETSYNC_ADDRESS testbranch address@hidden, [], [ignore], [ignore]) +NETSYNC_SERVE_STOP +AT_CHECK(MONOTONE2 dropkey address@hidden, [], [ignore], [ignore]) + # Now commit a version that does use the new key, and make sure that # now it does get transferred. SET_FILE(testfile, [version 1 of test file