#
#
# rename "tests/automate_read_packets"
# to "tests/automate_key_manage"
#
# patch "automate.cc"
# from [2796409829849a402d028dba43bec0d4148e8f75]
# to [ed511fdc50c5bc9750a73da0760ac5d2fe3c6f95]
#
# patch "cmd_key_cert.cc"
# from [1fdeeafa69f1aa0f5ea982eb756090195bb6ecb7]
# to [5df3ef740769087a6cd9544fad65e1f1c8b30cbd]
#
# patch "tests/automate_key_manage/__driver__.lua"
# from [75b2fcbfddb0c8cd731d172b14000b0ef86999a8]
# to [4e880f5b51665955bcdb176e719820fcdfd3f8d6]
#
============================================================
--- automate.cc 2796409829849a402d028dba43bec0d4148e8f75
+++ automate.cc ed511fdc50c5bc9750a73da0760ac5d2fe3c6f95
@@ -1,5 +1,5 @@
// Copyright (C) 2004 Nathaniel Smith
-// 2007 Stephen Leake
+// 2007, 2010 Stephen Leake
//
// This program is made available under the GNU GPL version 2.0 or
// greater. See the accompanying file COPYING for details.
@@ -521,7 +521,7 @@ CMD_AUTOMATE(select, N_("SELECTOR"),
project_t project(db);
set completions;
- // FIXME: replace this with
+ // FIXME: replace this with
// complete(app.opts, app.lua, project, idx(args, 0)(), completions);
// some time which errors out if no completions could be found for a
// specific selector - this breaks BC with earlier automate versions though
@@ -1750,84 +1750,14 @@ namespace
{
symbol const key("key");
symbol const signature("signature");
- symbol const name("name");
symbol const value("value");
symbol const trust("trust");
- symbol const hash("hash");
- symbol const public_location("public_location");
- symbol const private_location("private_location");
-
symbol const domain("domain");
symbol const entry("entry");
}
};
-// Name: genkey
-// Arguments:
-// 1: the key ID
-// 2: the key passphrase
-// Added in: 3.1
-// Changed in: 10.0
-// Purpose: Generates a key with the given ID and passphrase
-//
-// Output format: a basic_io stanza for the new key, as for ls keys
-//
-// Sample output:
-// name "address@hidden"
-// hash [475055ec71ad48f5dfaf875b0fea597b5cbbee64]
-// public_location "database" "keystore"
-// private_location "keystore"
-//
-// 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"),
- "",
- options::opts::force_duplicate_key)
-{
- E(args.size() == 2, origin::user,
- F("wrong argument count"));
-
- database db(app);
- key_store keys(app);
-
- key_name name = typecast_vocab(idx(args, 0));
-
- if (!app.opts.force_duplicate_key)
- {
- E(!keys.key_pair_exists(name), origin::user,
- F("you already have a key named '%s'") % name);
- if (db.database_specified())
- {
- E(!db.public_key_exists(name), origin::user,
- F("there is another key named '%s'") % name);
- }
- }
-
- utf8 passphrase = idx(args, 1);
-
- key_id hash;
- keys.create_key_pair(db, name, key_store::create_quiet, &passphrase, &hash);
-
- basic_io::printer prt;
- basic_io::stanza stz;
- vector publocs, privlocs;
- if (db.database_specified())
- publocs.push_back("database");
- publocs.push_back("keystore");
- privlocs.push_back("keystore");
-
- stz.push_str_pair(syms::name, name());
- stz.push_binary_pair(syms::hash, hash.inner());
- stz.push_str_multi(syms::public_location, publocs);
- stz.push_str_multi(syms::private_location, privlocs);
- prt.print_stanza(stz);
-
- output.write(prt.buf.data(), prt.buf.size());
-
-}
-
// Name: get_option
// Arguments:
// 1: an options name
============================================================
--- cmd_key_cert.cc 1fdeeafa69f1aa0f5ea982eb756090195bb6ecb7
+++ cmd_key_cert.cc 5df3ef740769087a6cd9544fad65e1f1c8b30cbd
@@ -1,4 +1,4 @@
-// Copyright (C) 2002 Graydon Hoare
+// Copyright (C) 2002, 2010 Graydon Hoare
//
// This program is made available under the GNU GPL version 2.0 or
// greater. See the accompanying file COPYING for details.
@@ -12,6 +12,7 @@
#include
#include
+#include "basic_io.hh"
#include "charset.hh"
#include "cmd.hh"
#include "app_state.hh"
@@ -30,6 +31,17 @@ using std::string;
using std::set;
using std::string;
+namespace
+{
+ namespace syms
+ {
+ symbol const name("name");
+ symbol const hash("hash");
+ symbol const public_location("public_location");
+ symbol const private_location("private_location");
+ }
+};
+
CMD(genkey, "genkey", "", CMD_REF(key_and_cert), N_("KEY_NAME"),
N_("Generates an RSA key-pair"),
"",
@@ -57,6 +69,71 @@ CMD(genkey, "genkey", "", CMD_REF(key_an
keys.create_key_pair(db, name);
}
+// Name: genkey
+// Arguments:
+// 1: the key ID
+// 2: the key passphrase
+// Added in: 3.1
+// Changed in: 10.0
+// Purpose: Generates a key with the given ID and passphrase
+//
+// Output format: a basic_io stanza for the new key, as for ls keys
+//
+// Sample output:
+// name "address@hidden"
+// hash [475055ec71ad48f5dfaf875b0fea597b5cbbee64]
+// public_location "database" "keystore"
+// private_location "keystore"
+//
+// 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"),
+ "",
+ options::opts::force_duplicate_key)
+{
+ E(args.size() == 2, origin::user,
+ F("wrong argument count"));
+
+ database db(app);
+ key_store keys(app);
+
+ key_name name = typecast_vocab(idx(args, 0));
+
+ if (!app.opts.force_duplicate_key)
+ {
+ E(!keys.key_pair_exists(name), origin::user,
+ F("you already have a key named '%s'") % name);
+ if (db.database_specified())
+ {
+ E(!db.public_key_exists(name), origin::user,
+ F("there is another key named '%s'") % name);
+ }
+ }
+
+ utf8 passphrase = idx(args, 1);
+
+ key_id hash;
+ keys.create_key_pair(db, name, key_store::create_quiet, &passphrase, &hash);
+
+ basic_io::printer prt;
+ basic_io::stanza stz;
+ vector publocs, privlocs;
+ if (db.database_specified())
+ publocs.push_back("database");
+ publocs.push_back("keystore");
+ privlocs.push_back("keystore");
+
+ stz.push_str_pair(syms::name, name());
+ stz.push_binary_pair(syms::hash, hash.inner());
+ stz.push_str_multi(syms::public_location, publocs);
+ stz.push_str_multi(syms::private_location, privlocs);
+ prt.print_stanza(stz);
+
+ output.write(prt.buf.data(), prt.buf.size());
+
+}
+
CMD(dropkey, "dropkey", "", CMD_REF(key_and_cert), N_("KEY_NAME_OR_HASH"),
N_("Drops a public and/or private key"),
"",
============================================================
--- tests/automate_key_manage/__driver__.lua 75b2fcbfddb0c8cd731d172b14000b0ef86999a8
+++ tests/automate_key_manage/__driver__.lua 4e880f5b51665955bcdb176e719820fcdfd3f8d6
@@ -1,13 +1,22 @@
+-- Test automate key management functions:
+-- genkey
+-- pubkey
+-- dropkey
+-- read_packets (putkey)
+-- keys
+
mtn_setup()
check(mtn("automate", "genkey", "address@hidden", "foopass"), 0, false, false)
check(mtn("pubkey", "address@hidden"), 0, true)
rename("stdout", "key_packet")
-check(mtn("dropkey", "address@hidden"), 0, false, false)
+check(mtn("automate", "pubkey", "address@hidden"), 0, true)
+check(samefile("stdout", "key_packet"))
+check(mtn("automate", "dropkey", "address@hidden"), 0, false, false)
-check(mtn("ls", "keys"), 0, true)
+check(mtn("automate", "keys"), 0, true)
check(not qgrep("address@hidden", "stdout"))
check(mtn("automate", "read_packets", readfile("key_packet")), 0)
-check(mtn("ls", "keys"), 0, true)
+check(mtn("automate", "keys"), 0, true)
check(qgrep("address@hidden", "stdout"))