# # # patch "NEWS" # from [76511d0b3a4b098028881ed70e290f90f0928584] # to [ff3af5dd194b9096c3407ebd4a92e57dbf61d7d3] # # patch "cmd_key_cert.cc" # from [5df3ef740769087a6cd9544fad65e1f1c8b30cbd] # to [f4b426aa88a7d6e1e2c92a638d8777b235916d6b] # # patch "cmd_packet.cc" # from [250e7188d51581406f9d28753c798754125abe4f] # to [a8e747e04000557bb5bc67405bdeb6425181f7f6] # # patch "monotone.texi" # from [f7e524e86db1abd48eb792525bd88f7b1a74c5dd] # to [c61b38b48b6d528d8105e139d3b293cd467c861a] # # patch "tests/automate_key_manage/__driver__.lua" # from [4e880f5b51665955bcdb176e719820fcdfd3f8d6] # to [55f0c4b71b2b2387b904dbd53e07aaace3fa7d72] # ============================================================ --- NEWS 76511d0b3a4b098028881ed70e290f90f0928584 +++ NEWS ff3af5dd194b9096c3407ebd4a92e57dbf61d7d3 @@ -83,6 +83,8 @@ Xxx Xxx 99 99:99:99 UTC 2010 New Features + - New automate versions of 'pubkey' and 'dropkey'. + - The 'disapprove' command now accepts a revision range in addition to a single revision. ============================================================ --- cmd_key_cert.cc 5df3ef740769087a6cd9544fad65e1f1c8b30cbd +++ cmd_key_cert.cc f4b426aa88a7d6e1e2c92a638d8777b235916d6b @@ -88,10 +88,13 @@ CMD_AUTOMATE(genkey, N_("KEY_NAME PASSPH // Error conditions: If the passphrase is empty or the key already exists, // prints an error message to stderr and exits with status 1. CMD_AUTOMATE(genkey, N_("KEY_NAME PASSPHRASE"), - N_("Generates a key"), + N_("Generates an RSA key-pair"), "", options::opts::force_duplicate_key) { + // not unified with CMD(genkey), because the call to create_key_pair is + // significantly different. + E(args.size() == 2, origin::user, F("wrong argument count")); @@ -134,19 +137,15 @@ CMD_AUTOMATE(genkey, N_("KEY_NAME PASSPH } -CMD(dropkey, "dropkey", "", CMD_REF(key_and_cert), N_("KEY_NAME_OR_HASH"), - N_("Drops a public and/or private key"), - "", - options::opts::none) +static void +dropkey_common (app_state & app, + args_vector args) { database db(app); key_store keys(app); bool key_deleted = false; bool checked_db = false; - if (args.size() != 1) - throw usage(execid); - key_identity_info identity; project_t project(db); project.get_key_identity(keys, app.lua, @@ -183,6 +182,28 @@ CMD(dropkey, "dropkey", "", CMD_REF(key_ E(key_deleted, origin::user, fmt % idx(args, 0)()); } +CMD(dropkey, "dropkey", "", CMD_REF(key_and_cert), N_("KEY_NAME_OR_HASH"), + N_("Drops a public and/or private key"), + "", + options::opts::none) +{ + if (args.size() != 1) + throw usage(execid); + + dropkey_common (app, args); +} + +CMD_AUTOMATE(dropkey, N_("KEY_NAME_OR_HASH"), + N_("Drops a public and/or private key"), + "", + options::opts::none) +{ + E(args.size() == 1, origin::user, + F("wrong argument count")); + + dropkey_common (app, args); +} + CMD(passphrase, "passphrase", "", CMD_REF(key_and_cert), N_("KEY_NAME_OR_HASH"), N_("Changes the passphrase of a private RSA key"), "", ============================================================ --- cmd_packet.cc 250e7188d51581406f9d28753c798754125abe4f +++ cmd_packet.cc a8e747e04000557bb5bc67405bdeb6425181f7f6 @@ -1,3 +1,4 @@ +// Copyright (C) 2010 Stephen Leake // Copyright (C) 2002 Graydon Hoare // // This program is made available under the GNU GPL version 2.0 or @@ -24,14 +25,11 @@ using std::vector; using std::istringstream; using std::vector; -CMD(pubkey, "pubkey", "", CMD_REF(packet_io), N_("ID"), - N_("Prints a public key packet"), - "", - options::opts::none) +static void +pubkey_common (app_state & app, + args_vector args, + std::ostream & output) { - if (args.size() != 1) - throw usage(execid); - database db(app); key_store keys(app); project_t project(db); @@ -57,10 +55,32 @@ CMD(pubkey, "pubkey", "", CMD_REF(packet E(exists, origin::user, F("public key '%s' does not exist") % idx(args, 0)()); - packet_writer pw(cout); + packet_writer pw(output); pw.consume_public_key(identity.given_name, key); } +CMD(pubkey, "pubkey", "", CMD_REF(packet_io), N_("KEY_NAME_OR_HASH"), + N_("Prints a public key packet"), + "", + options::opts::none) +{ + if (args.size() != 1) + throw usage(execid); + + pubkey_common (app, args, cout); +} + +CMD_AUTOMATE(pubkey, N_("KEY_NAME_OR_HASH"), + N_("Prints a public key packet"), + "", + options::opts::none) +{ + E(args.size() == 1, origin::user, + F("wrong argument count")); + + pubkey_common (app, args, output); +} + CMD(privkey, "privkey", "", CMD_REF(packet_io), N_("ID"), N_("Prints a private key packet"), "", ============================================================ --- monotone.texi f7e524e86db1abd48eb792525bd88f7b1a74c5dd +++ monotone.texi c61b38b48b6d528d8105e139d3b293cd467c861a @@ -9341,6 +9341,79 @@ @section Automation @end table address@hidden mtn automate pubkey @var{keyid} + address@hidden @strong address@hidden Arguments: + address@hidden identifies the key to display, by name or hash. + address@hidden Changes: + address@hidden address@hidden +FIXME -- initial + address@hidden itemize + address@hidden Purpose: + +Same as @command{pubkey}; print the key in packet format, suitable for +reading by @command{automate read_packets}. + address@hidden Sample output: + address@hidden +[pubkey address@hidden +MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDQs4OEcqULwepphO5Rsb/aSLpiEryGtEkQRNQPNFxvcu1rwVnNKRxep1KCDrwV3se9f4hUQ8zz73NQggS82guSI/YuyXZDZHrw+v3YgAMV/mKGnAjgYnyRNUL1xCywV7fnqTduBBqkDEVSCqphWlii/gFB/PVo4sbJ4Hk7O6ujWwIDAQAB +[end] address@hidden verbatim + address@hidden Output format: + +See example. + address@hidden Error conditions: + +If the key does not exist, an error message is printed on the error stream. + address@hidden table + address@hidden mtn automate dropkey @var{keyid} + address@hidden @strong address@hidden Arguments: + address@hidden identifies the key to drop, by name or hash. + address@hidden Changes: + address@hidden address@hidden +FIXME -- initial + address@hidden itemize + address@hidden Purpose: + +Same as @command{dropkey}; drops the public and/or private key. This +command should be used with caution as changes are irreversible +without a backup of the key(s) that were dropped. + address@hidden Sample output: + +None. + address@hidden Output format: + +None on the main stream; progress message on the progress stream. + address@hidden Error conditions: + +If the key does not exist, an error message is printed on the error stream. + address@hidden table + @item mtn automate packet_for_rdata @var{id} @table @strong @@ -10295,7 +10368,7 @@ @section Automation @table @strong @item Arguments: -A data packet, @var{packet-data}, as produced by @command{mtn pubkey @var{keyname}}. +A data packet, @var{packet-data}, as produced by @command{mtn pubkey @var{keyid}}. @item Added in: ============================================================ --- tests/automate_key_manage/__driver__.lua 4e880f5b51665955bcdb176e719820fcdfd3f8d6 +++ tests/automate_key_manage/__driver__.lua 55f0c4b71b2b2387b904dbd53e07aaace3fa7d72 @@ -9,6 +9,8 @@ check(mtn("pubkey", "address@hidden"), 0, t check(mtn("automate", "genkey", "address@hidden", "foopass"), 0, false, false) check(mtn("pubkey", "address@hidden"), 0, true) +-- non-automate output uses OS-specific line endings, while automate uses Unix line endings. +canonicalize("stdout") rename("stdout", "key_packet") check(mtn("automate", "pubkey", "address@hidden"), 0, true) check(samefile("stdout", "key_packet"))