# # patch "ChangeLog" # from [756728e6e8e1907f674cd0c90500b327606faed5] # to [4d34f72d18f9eee6a85a1de5bb100f87042d0b39] # # patch "cert.cc" # from [b491c5c3c908f4fa77a664b38d81d0eb4e2b68e9] # to [1b665ff961adf486f4a109e9cbd022631556eb9b] # # patch "cert.hh" # from [7e7e906bb36445343533611871cd5d3680cb7f99] # to [cecfad39f70d66bade08f08e08f023325c611b0a] # # patch "commands.cc" # from [fdaba30fa16a3399ef5d01e59af862e1247e5d32] # to [d081b1c2d4e1d5be86e053b15d0b347d47695113] # # patch "rcs_import.cc" # from [1cae15157195ea7014977d5184a10d6472a959b2] # to [0b20cfb6281be6eda31c0e861912a2fe57145638] # # patch "revision.cc" # from [278be7ae9f1e835cf402808d651e5a1d1a49d72f] # to [44d378125e8ae284703e4a5780e65788d8d301ef] # ======================================================================== --- ChangeLog 756728e6e8e1907f674cd0c90500b327606faed5 +++ ChangeLog 4d34f72d18f9eee6a85a1de5bb100f87042d0b39 @@ -1,3 +1,14 @@ +2005-10-10 Nathaniel Smith + + * cert.{cc,hh} (get_user_key): New function, replacing + guess_default_key. + * revision.cc (build_changesets_from_existing_revs) + (build_changesets_from_manifest_ancestry): + * rcs_import.cc (import_cvs_repo): + * commands.cc (internalize_cert_name, push, sync, serve): + * cert.cc (make_simple_cert, cert_revision_author_default): Use + it. + 2005-10-10 Matthew Gregan * lua.cc (Lua::ok): Only log the 'Lua::ok() failed' message if ======================================================================== --- cert.cc b491c5c3c908f4fa77a664b38d81d0eb4e2b68e9 +++ cert.cc 1b665ff961adf486f4a109e9cbd022631556eb9b @@ -437,33 +437,31 @@ string const branch_cert_name("branch"); -bool -guess_default_key(rsa_keypair_id & key, - app_state & app) +void +get_user_key(rsa_keypair_id & key, app_state & app) { if (app.signing_key() != "") { key = app.signing_key; - return true; + return; } if (app.branch_name() != "") { cert_value branch(app.branch_name()); if (app.lua.hook_get_branch_key(branch, key)) - return true; + return; } vector all_privkeys; app.keys.get_keys(all_privkeys); - if (all_privkeys.size() != 1) - return false; - else - { - key = all_privkeys[0]; - return true; - } + N(!all_privkeys.empty(), F("you have no private key to make signatures with\n" + "perhaps you need to 'genkey '")); + N(all_privkeys.size() > 1, + F("you have multiple private keys\n" + "pick one to use for signatures by adding '-k' to your command")); + key = all_privkeys[0]; } void @@ -507,8 +505,7 @@ cert & c) { rsa_keypair_id key; - N(guess_default_key(key,app), - F("no unique private key for cert construction")); + get_user_key(key, app); base64 encoded_val; encode_base64(cv, encoded_val); cert t(id, nm, encoded_val, key); @@ -622,9 +619,7 @@ if (!app.lua.hook_get_author(app.branch_name(), author)) { rsa_keypair_id key; - N(guess_default_key(key, app), - F("no default author name for branch '%s'") - % app.branch_name); + get_user_key(key, app), author = key(); } cert_revision_author(m, author, app, pc); ======================================================================== --- cert.hh 7e7e906bb36445343533611871cd5d3680cb7f99 +++ cert.hh cecfad39f70d66bade08f08e08f023325c611b0a @@ -97,9 +97,9 @@ // conventions. you should use these unless you have a compelling // reason not to. -bool -guess_default_key(rsa_keypair_id & key, - app_state & app); +// N()'s out if there is no unique key for us to use +void +get_user_key(rsa_keypair_id & key, app_state & app); void guess_branch(revision_id const & id, ======================================================================== --- commands.cc fdaba30fa16a3399ef5d01e59af862e1247e5d32 +++ commands.cc d081b1c2d4e1d5be86e053b15d0b347d47695113 @@ -321,14 +321,14 @@ CMD(help, N_("informative"), N_("command [ARGS...]"), N_("display command help"), OPT_NONE) { - if (args.size() < 1) - throw usage(""); + if (args.size() < 1) + throw usage(""); - string full_cmd = complete_command(idx(args, 0)()); - if (cmds.find(full_cmd) == cmds.end()) - throw usage(""); + string full_cmd = complete_command(idx(args, 0)()); + if (cmds.find(full_cmd) == cmds.end()) + throw usage(""); - throw usage(full_cmd); + throw usage(full_cmd); } static void @@ -946,11 +946,7 @@ internalize_cert_name(idx(args, 1), name); rsa_keypair_id key; - if (app.signing_key() != "") - key = app.signing_key; - else - N(guess_default_key(key, app), - F("no unique private key found, and no key specified")); + get_user_key(key, app); cert_value val; if (args.size() == 3) @@ -2021,7 +2017,7 @@ process_netsync_args(name, args, addr, include_pattern, exclude_pattern, true, app); rsa_keypair_id key; - N(guess_default_key(key, app), F("could not guess default signing key")); + get_user_key(key, app); app.signing_key = key; run_netsync_protocol(client_voice, source_role, addr, @@ -2050,7 +2046,7 @@ process_netsync_args(name, args, addr, include_pattern, exclude_pattern, true, app); rsa_keypair_id key; - N(guess_default_key(key, app), F("could not guess default signing key")); + get_user_key(key, app); app.signing_key = key; run_netsync_protocol(client_voice, source_and_sink_role, addr, @@ -2067,7 +2063,7 @@ pid_file pid(app.pidfile); rsa_keypair_id key; - N(guess_default_key(key, app), F("could not guess default signing key")); + get_user_key(key, app); app.signing_key = key; N(app.lua.hook_persist_phrase_ok(), ======================================================================== --- rcs_import.cc 1cae15157195ea7014977d5184a10d6472a959b2 +++ rcs_import.cc 0b20cfb6281be6eda31c0e861912a2fe57145638 @@ -1227,8 +1227,7 @@ { // early short-circuit to avoid failure after lots of work rsa_keypair_id key; - N(guess_default_key(key,app), - F("no unique private key for cert construction")); + get_user_key(key, app); require_password(key, app); } ======================================================================== --- revision.cc 278be7ae9f1e835cf402808d651e5a1d1a49d72f +++ revision.cc 44d378125e8ae284703e4a5780e65788d8d301ef @@ -1590,8 +1590,7 @@ { // early short-circuit to avoid failure after lots of work rsa_keypair_id key; - N(guess_default_key(key,app), - F("no unique private key for cert construction")); + get_user_key(key,app); require_password(key, app); } @@ -1622,8 +1621,7 @@ { // early short-circuit to avoid failure after lots of work rsa_keypair_id key; - N(guess_default_key(key,app), - F("no unique private key for cert construction")); + get_user_key(key,app); require_password(key, app); }