diff -u --recursive --new-file gnome-keyring-0.4.0-vanilla/gnome-keyringtool.c gnome-keyring-0.4.0/gnome-keyringtool.c
--- gnome-keyring-0.4.0-vanilla/gnome-keyringtool.c	1969-12-31 18:00:00.000000000 -0600
+++ gnome-keyring-0.4.0/gnome-keyringtool.c	2004-11-13 18:10:23.000000000 -0600
@@ -0,0 +1,523 @@
+/* gnome-keyringtool.c - utility for manipulating keyrings.
+
+   Copyright (C) 2004 W. Michael Petullo
+
+   The Gnome Keyring Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The Gnome Keyring Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the Gnome Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+
+   Author: W. Michael Petullo <gnome-keyringtool@flyn.org>
+*/
+
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <glib.h>
+#include <gnome-keyring.h>
+
+/* ============================ globals ==================================== */ 
+static GMainLoop *loop = NULL;
+
+/* ============================ op_id_t ==================================== */
+typedef enum {
+	UNLOCK,
+	CREATE,
+	PASSWD,
+	CREATEDEFAULT,
+	SETDEFAULT,
+	DELETE
+} op_id_t;
+
+/* ============================ operations_t =============================== */
+typedef struct operation_t {
+	char *name;
+	op_id_t id;
+	int (*op) (const char *name);
+	gboolean has_arg;
+} operation_t;
+
+/* ============================ operation functions ======================== */
+static int op_unlock(const char *name);
+static int op_create(const char *name);
+static int op_passwd(const char *name);
+static int op_createdefault(const char *name);
+static int op_setdefault(const char *name);
+static int op_getdefault(const char *name);
+static int op_delete(const char *name);
+
+/* ============================ AUTHTOK_SIZE =============================== */
+const size_t AUTHTOK_SIZE = 1024;
+
+/* ============================ usage ====================================== */
+static const char *usage = "gnome-keyringtool [options] operation [name]\n\n"
+    "-h, --help           print a list of options\n\n"
+    "operations:\n\n"
+    "unlock name          unlock the named keyring\n"
+    "create name          create the named keyring\n"
+    "passwd name          change the password for the named keyring\n"
+    "createdefault name   create the named keyring and make it the default\n"
+    "setdefault name      set the named keyringas the default\n"
+    "getdefault           print the name of the default keyring\n"
+    "delete name          delete the named keyring\n";
+
+/* ============================ operation ================================== */
+operation_t operation[] = {
+	{"unlock", UNLOCK, op_unlock, 1},
+	{"create", CREATE, op_create, 1},
+	{"passwd", PASSWD, op_passwd, 1},
+	{"createdefault", CREATE, op_createdefault, 1},
+	{"setdefault", SETDEFAULT, op_setdefault, 1},
+	{"getdefault", SETDEFAULT, op_getdefault, 0},
+	{"delete", SETDEFAULT, op_delete, 1},
+	{NULL, 0, NULL}
+};
+
+/* ============================ settings_t ================================= */
+typedef struct settings_t {
+	operation_t *op;
+	char *arg;
+} settings_t;
+
+/* ============================ print_usage () ============================== */
+void print_usage(const int exitcode, const char *error, const char *more)
+{
+	fprintf(stderr, "%s\n", usage);
+	if (error)
+		fprintf(stderr, "%s: %s.\n\n", error, more);
+	exit(exitcode);
+}
+
+/* ============================ set_defaults () ============================= */
+void set_defaults(settings_t * settings)
+{
+	settings->op = NULL;
+	settings->arg = NULL;
+}
+
+/* ============================ parse_args () =============================== */
+void parse_args(int argc, char *argv[], settings_t * settings)
+{
+	int c, i;
+	int opt_index = 0;
+	struct option opts[] = {
+		{"help", 0, 0, 'h'},
+		{0, 0, 0, 0}
+	};
+	while ((c = getopt_long(argc, argv, "hk:", opts, &opt_index))
+	       >= 0) {
+		switch (c) {
+		case 'h':
+			print_usage(EXIT_SUCCESS, NULL, NULL);
+		default:
+			print_usage(EXIT_FAILURE, NULL, NULL);
+		}
+	}
+	if (argv[optind] == NULL)
+		print_usage(EXIT_FAILURE, "gnome-keyringtool",
+			    "No operation specified");
+	for (i = 0;
+	     operation[i].name && strcmp(operation[i].name, argv[optind]);
+	     i++) {
+	}
+	if (operation[i].name == NULL)
+		print_usage(EXIT_FAILURE, "gnome-keyringtool",
+			    "operation not supported");
+	settings->op = &operation[i];
+	optind++;
+	if (operation[i].has_arg)
+		if (!(settings->arg = argv[optind++]))
+			print_usage(EXIT_FAILURE, "gnome-keyringtool",
+				    "No keyring name specified");
+}
+
+/* ============================ keyring_op_cb () ============================ */
+/* INPUT: result, the result of the operation; data, a pointer to an int;
+ *        loop, a global
+ * SIDE AFFECTS: *data == 1 or 0 on error
+ *               glib main loop stops and regular execution continues
+ */
+void keyring_op_cb(GnomeKeyringResult result, gpointer data)
+{
+        assert(loop != NULL);
+        assert(data != NULL);
+
+        if (result != GNOME_KEYRING_RESULT_OK) {
+                fprintf(stderr, "gnome-keyringtool: error performing keyring operation: %d\n", result);
+                *(int *) data = 0;
+        } else
+                *(int *) data = 1;
+        g_main_loop_quit(loop);
+}
+
+/* ============================ strip_cr () ================================ */
+/* INPUT: s, a string
+ * SIDE AFFECTS: terminating carriage return in s is removed if it exists
+ * OUTPUT: s
+ */
+char *strip_cr(char *s)
+{
+        int len;
+
+        assert(s != NULL);
+
+        len = strlen(s);
+        s[len - 1] = s[len - 1] == '\n' ? 0x00 : s[len - 1];
+        return s;
+}
+
+/* ============================ fgets_no_cr () ============================= */
+/* INPUT: s, a buffer; size, the size of s; stream, a stream to read from
+ * SIDE AFFECTS: at most size - 1 characters are read from stream and placed
+ *               in s; terminating carriage return in s is removed
+ * OUTPUT: s
+ */
+char *fgets_no_cr(char *s, int size, FILE *stream)
+{
+        char *fnval;
+
+        assert(s != NULL);
+        assert(size > 0);
+        assert(stream != NULL);
+
+        if ((fnval = fgets(s, size, stream)) == NULL)
+                goto _return;
+        strip_cr(s);
+_return:
+        return fnval;
+}
+
+/* ============================ get_authtok () ============================= */
+/* INPUT: pass, a pointer to an array of size AUTHTOK_SIZE
+ * SIDE AFFECT: pass is filled with an authentication token, read from
+ *              stdin
+ * OUTPUT: if error NULL else pointer to pass
+ */
+static char *get_authtok(char *pass)
+{
+	fprintf(stdout, "Please enter password: ");
+	return fgets_no_cr(pass, AUTHTOK_SIZE, stdin);
+}
+
+/* ============================ run_loop () ================================ */
+/* INPUT: loop, a global != NULL
+ * SIDE AFFECTS: glib main loop is running
+ */
+void run_loop(void)
+{
+        assert(loop != NULL);
+        g_main_loop_run(loop);
+}
+
+/* ============================ quit_loop () =============================== */
+/* INPUT: loop, a global != NULL
+ * SIDE AFFECTS: glib main loop has quit
+ */
+void quit_loop(void)
+{
+        assert(loop != NULL);
+
+        g_main_loop_quit(loop);
+}
+
+/* ============================ op_create () =============================== */
+/* INPUT: name, the name of the keyring to create
+ * SIDE AFFECT: the keyring has been created
+ * OUTPUT: if error 0 else non-0
+ */
+static int op_create(const char *name)
+{
+	int ret = 1;
+	char authtok[AUTHTOK_SIZE];
+
+	assert(name != NULL);
+	if (get_authtok(authtok) == NULL) {
+		fprintf(stderr, "gnome-keyringtool: error reading authtok\n");
+		ret = 0;
+		goto _return;
+	}
+
+	gnome_keyring_create(name, authtok, keyring_op_cb, &ret, NULL);
+	run_loop();
+	memset(authtok, 0x00, AUTHTOK_SIZE);
+_return:
+	return ret;
+}
+
+/* ============================ op_setdefault () =========================== */
+/* INPUT: name, the name of the keyring to set as the default
+ * SIDE AFFECT: the keyring has been set to the default
+ * OUTPUT: if error 0 else non-0
+ */
+static int op_setdefault(const char *name)
+{
+	int ret = 1;
+
+	assert(name != NULL);
+
+	gnome_keyring_set_default_keyring(name, keyring_op_cb, &ret, NULL);
+	run_loop();
+	return ret;
+}
+
+/* ============================ op_createdefault () ======================== */
+/* INPUT: name, the name of the keyring to create
+ * SIDE AFFECT: the keyring has been created and set as the default
+ * OUTPUT: if error 0 else non-0
+ */
+static int op_createdefault(const char *name)
+{
+	return op_create(name) && op_setdefault(name);
+}
+
+/* ============================ get_keyring_info_cb () ===================== */
+/* INPUT: result, the result of the operation; info, the keyring info;
+ *        ptr, a pointer to a *GnomeKeyringInfo
+ * SIDE AFFECTS: ptr is set
+ *               glib main loop stops and regular execution continues
+ */
+static void get_keyring_info_cb(GnomeKeyringResult result,
+                                GnomeKeyringInfo * info, gpointer ptr)
+{
+        if (info == NULL || result != GNOME_KEYRING_RESULT_OK) {
+		*((GnomeKeyringInfo **) ptr) = NULL;
+                goto _return;
+        }
+        *((GnomeKeyringInfo **) ptr) = gnome_keyring_info_copy(info);
+      _return:
+        quit_loop();
+}
+
+/* ============================ get_keyring_info () ======================== */
+/* INPUT: name a valid keyring name
+ * OUTPUT: the keyring's info or NULL on error
+ */
+static GnomeKeyringInfo *get_keyring_info(const char *name)
+{
+        GnomeKeyringInfo *ret = NULL;
+                                                                                
+        assert(name != NULL);
+                                                                                
+        gnome_keyring_get_info(name, get_keyring_info_cb, &ret, NULL);
+        run_loop();
+        return ret;
+}
+
+/* ============================ keyring_set_info () ======================== */
+/* INPUT: name, the name of the keyring to set; info, the info
+ * SIDE AFFECT: the keyring's information is set
+ * OUTPUT: if error 0 else non-0
+ */
+static int keyring_set_info(const char *name, GnomeKeyringInfo * info)
+{
+        int ret = 1;
+                                                                                
+        assert(name != NULL);
+        assert(info != NULL);
+                                                                                
+        gnome_keyring_set_info(name, info, keyring_op_cb, &ret, NULL);
+        run_loop();
+        return ret;
+}
+
+/* ============================ get_default_keyring_cb () ================== */
+/* INPUT: result, the result of the operation; name, the name of the default
+ *        keyring; ptr, a pointer to a char *
+ * SIDE AFFECTS: ptr is set
+ *               glib main loop stops and regular execution continues
+ */
+static void get_default_keyring_cb(GnomeKeyringResult result,
+				   const char *name, gpointer ptr)
+{
+	assert((const char **) ptr != NULL);
+
+	if (name == NULL || result != GNOME_KEYRING_RESULT_OK)
+		*(const char **) ptr = NULL;
+	else
+		*(const char **) ptr = g_strdup(name);
+	quit_loop();
+}
+
+/* ============================ get_default () ============================= */
+/* OUTPUT: the name of the default keyring or NULL on error
+ */
+static char *get_default(void)
+{
+	char *name = NULL;
+
+	gnome_keyring_get_default_keyring(get_default_keyring_cb, &name,
+					  NULL);
+	run_loop();
+
+	return name;
+}
+
+/* ============================ op_getdefault () =========================== */
+/* SIDE AFFECT: the name of the default keyring is printed to stdout
+ * OUTPUT: if error 0 else non-0
+ */
+static int op_getdefault(const char *ignore)
+{
+	int ret = 1;
+	char *name = get_default();
+
+	if (name == NULL)
+		ret = 0;
+	else {
+		fprintf(stdout, "%s\n", name);
+		g_free(name);
+        }
+	return ret;
+}
+
+/* ============================ op_passwd () =============================== */
+/* INPUT: name, the name of the keyring to change the password of
+ * SIDE AFFECT: the password has been created (the password is read from stdin)
+ * OUTPUT: if error 0 else non-0
+ */
+static int op_passwd(const char *name)
+{
+	int ret = 1;
+	GnomeKeyringInfo *info;
+	char authtok[AUTHTOK_SIZE], *default_keyring;
+
+	fprintf(stderr, "gnome-keyringtool: passwd not yet implemented\n");
+	ret = 0;
+	goto _return;
+	/* FIXME: password changing needs to be added to libgnome-keyring.
+
+	assert(name != NULL);
+
+	if (get_authtok(authtok) == NULL) {
+		fprintf(stderr, "gnome-keyringtool: error reading authtok\n");
+		ret = 0;
+		goto _return;
+	}
+	if ((default_keyring = get_default ()) == NULL) {
+		fprintf(stderr, "gnome-keyringtool: error finding default keyring\n");
+		ret = 0;
+                goto _return;
+        }
+	if ((info = get_keyring_info(name)) == NULL) {
+		fprintf(stderr, "gnome-keyringtool: error reading info\n");
+		ret = 0;
+		goto _return;
+	}
+	gnome_keyring_create("backup", authtok, keyring_op_cb, &ret, NULL);
+	if (ret == 0) {
+		fprintf(stderr, "gnome-keyringtool: error creating backup\n");
+		goto _return;
+	}
+	if (keyring_set_info("backup", info) == 0) {
+		fprintf(stderr, "gnome-keyringtool: error setting info for backup\n");
+		ret = 0;
+		goto _return;
+	}
+	if (op_delete(name) == 0) {
+		fprintf(stderr, "gnome-keyringtool: error deleting %s\n", name);
+		ret = 0;
+		goto _return;
+	}
+	gnome_keyring_create(name, authtok, keyring_op_cb, &ret, NULL);
+	if (ret == 0) {
+		fprintf(stderr, "gnome-keyringtool: error creating %s\n", name);
+		ret = 0;
+		goto _return;
+	}
+	if (! strcmp(default_keyring, name) && op_setdefault(name) == 0) {
+		fprintf(stderr, "gnome-keyringtool: error setting %s to default\n", name);
+		ret = 0;
+		goto _return;
+	}
+	if (keyring_set_info(name, info) == 0) {
+		fprintf(stderr, "gnome-keyringtool: error setting info for %s\n", name);
+		ret = 0;
+		goto _return;
+	}
+	if (op_delete("backup") == 0) {
+		fprintf(stderr, "gnome-keyringtool: error deleting backup\n");
+		ret = 0;
+		goto _return;
+	}
+	run_loop();
+	*/
+_return:
+	memset(authtok, 0x00, AUTHTOK_SIZE);
+	return ret;
+}
+
+/* ============================ op_delete () =============================== */
+/* INPUT: name, the name of the keyring to delete
+ * SIDE AFFECT: the keyring has been deleted
+ * OUTPUT: if error 0 else non-0
+ */
+static int op_delete(const char *name)
+{
+	int ret = 1;
+
+	assert(name);
+
+	gnome_keyring_delete(name, keyring_op_cb, &ret, NULL);
+	run_loop();
+	return ret;
+}
+
+/* ============================ op_unlock () =============================== */
+/* INPUT: name, the name of the keyring to unlock
+ * SIDE AFFECT: the keyring is unlocked
+ * OUTPUT: if error 0 else non-0
+ */
+static int op_unlock(const char *name)
+{
+	int ret = 1;
+	char authtok[AUTHTOK_SIZE];
+
+	assert(name != NULL);
+	if (get_authtok(authtok) == NULL) {
+		fprintf(stderr, "gnome-keyringtool: error reading authtok\n");
+		ret = 0;
+		goto _return;
+	}
+	gnome_keyring_unlock(name, authtok, keyring_op_cb, &ret, NULL);
+	run_loop();
+	memset(authtok, 0x00, AUTHTOK_SIZE);
+_return:
+	return ret;
+}
+
+/* ============================ init_loop () =============================== */
+/* SIDE AFFECTS: glib main loop is initialized */
+void init_loop(void)
+{
+        loop = g_main_loop_new(NULL, FALSE);
+}
+
+/* ============================ main () ===================================== */
+int main(int argc, char *argv[], char *env[])
+{
+	settings_t settings;
+
+	set_defaults(&settings);
+	parse_args(argc, argv, &settings);
+	init_loop();
+
+	if (settings.op->op(settings.arg) == 0) {
+		fprintf(stderr,
+			"gnome-keyringtool: error performing operation on %s\n",
+			settings.arg);
+		exit(EXIT_FAILURE);
+	}
+	exit(EXIT_SUCCESS);
+}
diff -u --recursive --new-file gnome-keyring-0.4.0-vanilla/Makefile.am gnome-keyring-0.4.0/Makefile.am
--- gnome-keyring-0.4.0-vanilla/Makefile.am	2004-08-09 11:23:07.000000000 -0500
+++ gnome-keyring-0.4.0/Makefile.am	2004-10-27 10:25:19.000000000 -0500
@@ -4,7 +4,8 @@
 libgnomekeyringincludedir = $(includedir)/gnome-keyring-1/
 
 bin_PROGRAMS= \
-	gnome-keyring-daemon
+	gnome-keyring-daemon \
+	gnome-keyringtool
 
 libexec_PROGRAMS= \
 	gnome-keyring-ask
@@ -74,6 +75,14 @@
 	@LIBOBJS@ \
 	$(GLIB_LIBS)
 
+gnome_keyringtool_SOURCES = \
+	gnome-keyringtool.c
+
+gnome_keyringtool_LDADD = \
+	libgnome-keyring.la \
+	@LIBOBJS@ \
+	$(GLIB_LIBS)
+
 gnome_keyring_ask_SOURCES = \
 	gnome-keyring-ask.c
 
