1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-keyring.c Store secret cookies in your homedir
4 * Copyright (C) 2003 Red Hat Inc.
6 * Licensed under the Academic Free License version 1.2
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "dbus-keyring.h"
25 #include <dbus/dbus-string.h>
26 #include <dbus/dbus-list.h>
27 #include <dbus/dbus-sysdeps.h>
30 * @defgroup DBusKeyring keyring class
31 * @ingroup DBusInternals
32 * @brief DBusKeyring data structure
34 * Types and functions related to DBusKeyring. DBusKeyring is intended
35 * to manage cookies used to authenticate clients to servers. This is
36 * essentially the "verify that client can read the user's homedir"
37 * authentication mechanism. Both client and server must have access
40 * The secret keys are not kept in locked memory, and are written to a
41 * file in the user's homedir. However they are transient (only used
42 * by a single server instance for a fixed period of time, then
43 * discarded). Also, the keys are not sent over the wire.
47 * @defgroup DBusKeyringInternals DBusKeyring implementation details
48 * @ingroup DBusInternals
49 * @brief DBusKeyring implementation details
51 * The guts of DBusKeyring.
56 /** The maximum age of a key before we create a new key to use in
57 * challenges. This isn't super-reliably enforced, since system
58 * clocks can change or be wrong, but we make a best effort to only
59 * use keys for a short time.
61 #define NEW_KEY_TIMEOUT_SECONDS (60*5)
63 * The time after which we drop a key from the secrets file.
64 * The EXPIRE_KEYS_TIMEOUT_SECONDS - NEW_KEY_TIMEOUT_SECONDS is the minimum
65 * time window a client has to complete authentication.
67 #define EXPIRE_KEYS_TIMEOUT_SECONDS (NEW_KEY_TIMEOUT_SECONDS + (60*2))
69 * The maximum amount of time a key can be in the future.
71 #define MAX_TIME_TRAVEL_SECONDS (60*5)
75 dbus_int32_t id; /**< identifier used to refer to the key */
77 long creation_time; /**< when the key was generated,
78 * as unix timestamp. signed long
79 * matches struct timeval.
82 DBusString secret; /**< the actual key */
87 * @brief Internals of DBusKeyring.
89 * DBusKeyring internals. DBusKeyring is an opaque object, it must be
90 * used via accessor functions.
94 int refcount; /**< Reference count */
95 DBusString username; /**< Username keyring is for */
96 DBusString directory; /**< Directory the below two items are inside */
97 DBusString filename; /**< Keyring filename */
98 DBusString filename_lock; /**< Name of lockfile */
99 DBusKey *keys; /**< Keys loaded from the file */
100 int n_keys; /**< Number of keys */
104 _dbus_keyring_new (void)
106 DBusKeyring *keyring;
108 keyring = dbus_new0 (DBusKeyring, 1);
112 if (!_dbus_string_init (&keyring->directory, _DBUS_INT_MAX))
115 if (!_dbus_string_init (&keyring->filename, _DBUS_INT_MAX))
118 if (!_dbus_string_init (&keyring->filename_lock, _DBUS_INT_MAX))
121 if (!_dbus_string_init (&keyring->username, _DBUS_INT_MAX))
124 keyring->refcount = 1;
125 keyring->keys = NULL;
131 _dbus_string_free (&keyring->username);
133 _dbus_string_free (&keyring->filename);
135 _dbus_string_free (&keyring->directory);
143 free_keys (DBusKey *keys,
148 /* should be safe for args NULL, 0 */
153 _dbus_string_free (&keys[i].secret);
160 /* Our locking scheme is highly unreliable. However, there is
161 * unfortunately no reliable locking scheme in user home directories;
162 * between bugs in Linux NFS, people using Tru64 or other total crap
163 * NFS, AFS, random-file-system-of-the-week, and so forth, fcntl() in
164 * homedirs simply generates tons of bug reports. This has been
165 * learned through hard experience with GConf, unfortunately.
167 * This bad hack might work better for the kind of lock we have here,
168 * which we don't expect to hold for any length of time. Crashing
169 * while we hold it should be unlikely, and timing out such that we
170 * delete a stale lock should also be unlikely except when the
171 * filesystem is running really slowly. Stuff might break in corner
172 * cases but as long as it's not a security-level breakage it should
176 /** Maximum number of timeouts waiting for lock before we decide it's stale */
177 #define MAX_LOCK_TIMEOUTS 32
178 /** Length of each timeout while waiting for a lock */
179 #define LOCK_TIMEOUT_MILLISECONDS 250
182 _dbus_keyring_lock (DBusKeyring *keyring)
187 while (n_timeouts < MAX_LOCK_TIMEOUTS)
191 dbus_error_init (&error);
192 if (_dbus_create_file_exclusively (&keyring->filename_lock,
196 _dbus_verbose ("Did not get lock file, sleeping %d milliseconds (%s)\n",
197 LOCK_TIMEOUT_MILLISECONDS, error.message);
198 dbus_error_free (&error);
200 _dbus_sleep_milliseconds (LOCK_TIMEOUT_MILLISECONDS);
205 if (n_timeouts == MAX_LOCK_TIMEOUTS)
209 _dbus_verbose ("Lock file timed out %d times, assuming stale\n",
212 dbus_error_init (&error);
214 if (!_dbus_delete_file (&keyring->filename_lock, &error))
216 _dbus_verbose ("Couldn't delete old lock file: %s\n",
218 dbus_error_free (&error);
222 if (!_dbus_create_file_exclusively (&keyring->filename_lock,
225 _dbus_verbose ("Couldn't create lock file after deleting stale one: %s\n",
227 dbus_error_free (&error);
236 _dbus_keyring_unlock (DBusKeyring *keyring)
239 dbus_error_init (&error);
240 if (!_dbus_delete_file (&keyring->filename_lock, &error))
242 _dbus_warn ("Failed to delete lock file: %s\n",
244 dbus_error_free (&error);
249 find_key_by_id (DBusKey *keys,
258 if (keys[i].id == id)
268 add_new_key (DBusKey **keys_p,
275 unsigned long timestamp;
276 const unsigned char *s;
281 if (!_dbus_string_init (&bytes, _DBUS_INT_MAX))
283 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
284 "No memory to generate new secret key");
292 /* Generate an integer ID and then the actual key. */
295 if (!_dbus_generate_random_bytes (&bytes, 4))
297 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
298 "No memory to generate new secret key");
302 _dbus_string_get_const_data (&bytes, (const char**) &s);
304 id = s[0] | (s[1] << 8) | (s[2] << 16) | (s[3] << 24);
307 _dbus_assert (id >= 0);
309 if (find_key_by_id (keys, n_keys, id) != NULL)
311 _dbus_string_set_length (&bytes, 0);
312 _dbus_verbose ("Key ID %d already existed, trying another one\n",
317 _dbus_verbose ("Creating key with ID %d\n", id);
319 #define KEY_LENGTH_BYTES 24
320 _dbus_string_set_length (&bytes, 0);
321 if (!_dbus_generate_random_bytes (&bytes, KEY_LENGTH_BYTES))
323 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
324 "No memory to generate new secret key");
328 new = dbus_realloc (keys, sizeof (DBusKey) * (n_keys + 1));
331 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
332 "No memory to reallocate secret key list");
339 if (!_dbus_string_init (&keys[n_keys-1].secret,
342 n_keys -= 1; /* we don't want to free the one we didn't init */
343 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
344 "No memory to store secret key");
348 _dbus_get_current_time (×tamp, NULL);
350 keys[n_keys-1].id = id;
351 keys[n_keys-1].creation_time = timestamp;
352 if (!_dbus_string_move (&bytes, 0,
353 &keys[n_keys-1].secret,
356 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
357 "No memory to store secret key");
370 _dbus_string_free (&bytes);
375 * Reloads the keyring file, optionally adds one new key to the file,
376 * removes all expired keys from the file iff a key was added, then
377 * resaves the file. Stores the keys from the file in keyring->keys.
378 * Note that the file is only resaved (written to) if a key is added,
379 * this means that only servers ever write to the file and need to
380 * lock it, which avoids a lot of lock contention at login time and
383 * @param keyring the keyring
384 * @param add_new #TRUE to add a new key to the file, expire keys, and resave
385 * @param error return location for errors
386 * @returns #FALSE on failure
389 _dbus_keyring_reload (DBusKeyring *keyring,
395 DBusResultCode result;
397 dbus_bool_t have_lock;
403 if (!_dbus_string_init (&contents, _DBUS_INT_MAX))
405 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
406 "No memory to reload keyring");
410 if (!_dbus_string_init (&line, _DBUS_INT_MAX))
412 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
413 "No memory to reload keyring");
414 _dbus_string_free (&contents);
423 _dbus_get_current_time (&now, NULL);
427 if (!_dbus_keyring_lock (keyring))
429 dbus_set_error (error, DBUS_ERROR_FAILED,
430 "Could not lock keyring file to add to it");
437 result = _dbus_file_get_contents (&contents,
440 if (result != DBUS_RESULT_SUCCESS)
442 _dbus_verbose ("Failed to load keyring file: %s\n",
443 dbus_result_to_string (result));
444 /* continue with empty keyring file, so we recreate it */
447 if (!_dbus_string_validate_ascii (&contents, 0,
448 _dbus_string_get_length (&contents)))
450 _dbus_warn ("Secret keyring file contains non-ASCII! Ignoring existing contents\n");
451 _dbus_string_set_length (&contents, 0);
454 while (_dbus_string_pop_line (&contents, &line))
464 if (!_dbus_string_parse_int (&line, 0, &val, &next))
466 _dbus_verbose ("could not parse secret key ID at start of line\n");
470 if (val > _DBUS_INT_MAX || val < 0)
472 _dbus_verbose ("invalid secret key ID at start of line\n");
478 _dbus_string_skip_blank (&line, next, &next);
480 if (!_dbus_string_parse_int (&line, next, ×tamp, &next))
482 _dbus_verbose ("could not parse secret key timestamp\n");
487 (now + MAX_TIME_TRAVEL_SECONDS) < timestamp ||
488 (now - EXPIRE_KEYS_TIMEOUT_SECONDS) > timestamp)
490 _dbus_verbose ("dropping/ignoring %ld-seconds old key with timestamp %ld as current time is %ld\n",
491 now - timestamp, timestamp, now);
495 _dbus_string_skip_blank (&line, next, &next);
497 len = _dbus_string_get_length (&line);
499 if ((len - next) == 0)
501 _dbus_verbose ("no secret key after ID and timestamp\n");
505 /* We have all three parts */
506 new = dbus_realloc (keys, sizeof (DBusKey) * (n_keys + 1));
509 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
510 "No memory to reallocate secret key list");
517 if (!_dbus_string_init (&keys[n_keys-1].secret,
520 n_keys -= 1; /* we don't want to free the one we didn't init */
521 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
522 "No memory to store secret key");
526 keys[n_keys-1].id = id;
527 keys[n_keys-1].creation_time = timestamp;
528 if (!_dbus_string_hex_decode (&line, next,
529 &keys[n_keys-1].secret,
532 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
533 "No memory to store secret key or invalid hex encoding");
538 _dbus_verbose ("Successfully loaded %d existing keys\n",
543 if (!add_new_key (&keys, &n_keys, error))
545 _dbus_verbose ("Failed to generate new key: %s\n",
546 error ? "(unknown)" : error->message);
550 _dbus_string_set_length (&contents, 0);
555 if (!_dbus_string_append_int (&contents,
559 if (!_dbus_string_append_byte (&contents, ' '))
562 if (!_dbus_string_append_int (&contents,
563 keys[i].creation_time))
566 if (!_dbus_string_append_byte (&contents, ' '))
569 if (!_dbus_string_hex_encode (&keys[i].secret, 0,
571 _dbus_string_get_length (&contents)))
574 if (!_dbus_string_append_byte (&contents, '\n'))
581 dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
582 "No memory to save secret keyring");
586 result = _dbus_string_save_to_file (&contents, &keyring->filename);
587 if (result != DBUS_RESULT_SUCCESS)
589 dbus_set_error (error, DBUS_ERROR_FAILED,
590 "Failed to save keyring file: %s",
591 dbus_result_to_string (result));
596 dbus_free (keyring->keys);
597 keyring->keys = keys;
598 keyring->n_keys = n_keys;
606 _dbus_keyring_unlock (keyring);
608 if (! ((retval == TRUE && (error == NULL || error->name == NULL)) ||
609 (retval == FALSE && (error == NULL || error->name != NULL))))
611 if (error && error->name)
612 _dbus_verbose ("error is %s: %s\n", error->name, error->message);
613 _dbus_warn ("returning %d but error pointer %p name %s\n",
614 retval, error, error->name ? error->name : "(none)");
615 _dbus_assert_not_reached ("didn't handle errors properly");
623 _dbus_string_zero (&keys[i].secret);
624 _dbus_string_free (&keys[i].secret);
631 _dbus_string_free (&contents);
632 _dbus_string_free (&line);
637 /** @} */ /* end of internals */
640 * @addtogroup DBusKeyring
646 * Increments reference count of the keyring
648 * @param keyring the keyring
651 _dbus_keyring_ref (DBusKeyring *keyring)
653 keyring->refcount += 1;
657 * Decrements refcount and finalizes if it reaches
660 * @param keyring the keyring
663 _dbus_keyring_unref (DBusKeyring *keyring)
665 keyring->refcount -= 1;
667 if (keyring->refcount == 0)
669 _dbus_string_free (&keyring->username);
670 _dbus_string_free (&keyring->filename);
671 _dbus_string_free (&keyring->filename_lock);
672 _dbus_string_free (&keyring->directory);
673 free_keys (keyring->keys, keyring->n_keys);
679 * Creates a new keyring that lives in the ~/.dbus-keyrings
680 * directory of the given user. If the username is #NULL,
681 * uses the user owning the current process.
683 * @param username username to get keyring for, or #NULL
684 * @param context which keyring to get
685 * @param error return location for errors
686 * @returns the keyring or #NULL on error
689 _dbus_keyring_new_homedir (const DBusString *username,
690 const DBusString *context,
694 DBusKeyring *keyring;
695 dbus_bool_t error_set;
702 if (!_dbus_string_init (&homedir, _DBUS_INT_MAX))
705 _dbus_string_init_const (&dotdir, ".dbus-keyrings");
707 if (username == NULL)
709 const DBusString *const_homedir;
711 if (!_dbus_user_info_from_current_process (&username,
716 if (!_dbus_string_copy (const_homedir, 0,
722 if (!_dbus_homedir_from_username (username, &homedir))
726 _dbus_assert (username != NULL);
728 keyring = _dbus_keyring_new ();
732 /* should have been validated already, but paranoia check here */
733 if (!_dbus_keyring_validate_context (context))
736 dbus_set_error_const (error,
738 "Invalid context in keyring creation");
742 if (!_dbus_string_copy (username, 0,
743 &keyring->username, 0))
746 if (!_dbus_string_copy (&homedir, 0,
747 &keyring->directory, 0))
750 _dbus_string_free (&homedir);
752 if (!_dbus_concat_dir_and_file (&keyring->directory,
756 if (!_dbus_string_copy (&keyring->directory, 0,
757 &keyring->filename, 0))
760 if (!_dbus_concat_dir_and_file (&keyring->filename,
764 if (!_dbus_string_copy (&keyring->filename, 0,
765 &keyring->filename_lock, 0))
768 if (!_dbus_string_append (&keyring->filename_lock, ".lock"))
771 dbus_error_init (&tmp_error);
772 if (!_dbus_keyring_reload (keyring, FALSE, &tmp_error))
774 _dbus_verbose ("didn't load an existing keyring: %s\n",
776 dbus_error_free (&tmp_error);
779 /* We don't fail fatally if we can't create the directory,
780 * but the keyring will probably always be empty
781 * unless someone else manages to create it
783 dbus_error_init (&tmp_error);
784 if (!_dbus_create_directory (&keyring->directory,
787 _dbus_verbose ("Creating keyring directory: %s\n",
789 dbus_error_free (&tmp_error);
796 dbus_set_error_const (error,
797 DBUS_ERROR_NO_MEMORY,
798 "No memory to create keyring");
800 _dbus_keyring_unref (keyring);
801 _dbus_string_free (&homedir);
807 * Checks whether the context is a valid context.
808 * Contexts that might cause confusion when used
809 * in filenames are not allowed (contexts can't
810 * start with a dot or contain dir separators).
812 * @todo this is the most inefficient implementation
815 * @param context the context
816 * @returns #TRUE if valid
819 _dbus_keyring_validate_context (const DBusString *context)
821 if (_dbus_string_get_length (context) == 0)
823 _dbus_verbose ("context is zero-length\n");
827 if (!_dbus_string_validate_ascii (context, 0,
828 _dbus_string_get_length (context)))
830 _dbus_verbose ("context not valid ascii\n");
834 /* no directory separators */
835 if (_dbus_string_find (context, 0, "/", NULL))
837 _dbus_verbose ("context contains a slash\n");
841 if (_dbus_string_find (context, 0, "\\", NULL))
843 _dbus_verbose ("context contains a backslash\n");
847 /* prevent attempts to use dotfiles or ".." or ".lock"
848 * all of which might allow some kind of attack
850 if (_dbus_string_find (context, 0, ".", NULL))
852 _dbus_verbose ("context contains a dot\n");
856 /* no spaces/tabs, those are used for separators in the protocol */
857 if (_dbus_string_find_blank (context, 0, NULL))
859 _dbus_verbose ("context contains a blank\n");
863 if (_dbus_string_find (context, 0, "\n", NULL))
865 _dbus_verbose ("context contains a newline\n");
869 if (_dbus_string_find (context, 0, "\r", NULL))
871 _dbus_verbose ("context contains a carriage return\n");
879 find_recent_key (DBusKeyring *keyring)
882 long tv_sec, tv_usec;
884 _dbus_get_current_time (&tv_sec, &tv_usec);
887 while (i < keyring->n_keys)
889 DBusKey *key = &keyring->keys[i];
891 _dbus_verbose ("Key %d is %ld seconds old\n",
892 i, tv_sec - key->creation_time);
894 if ((tv_sec - NEW_KEY_TIMEOUT_SECONDS) < key->creation_time)
904 * Gets a recent key to use for authentication.
905 * If no recent key exists, creates one. Returns
906 * the key ID. If a key can't be written to the keyring
907 * file so no recent key can be created, returns -1.
908 * All valid keys are > 0.
910 * @param keyring the keyring
911 * @param error error on failure
912 * @returns key ID to use for auth, or -1 on failure
915 _dbus_keyring_get_best_key (DBusKeyring *keyring,
920 key = find_recent_key (keyring);
924 /* All our keys are too old, or we've never loaded the
925 * keyring. Create a new one.
927 if (!_dbus_keyring_reload (keyring, TRUE,
931 key = find_recent_key (keyring);
936 dbus_set_error_const (error,
938 "No recent-enough key found in keyring, and unable to create a new key");
944 * Checks whether the keyring is for the given username.
946 * @param keyring the keyring
947 * @param username the username to check
949 * @returns #TRUE if the keyring belongs to the given user
952 _dbus_keyring_is_for_user (DBusKeyring *keyring,
953 const DBusString *username)
955 return _dbus_string_equal (&keyring->username,
960 * Gets the hex-encoded secret key for the given ID.
961 * Returns #FALSE if not enough memory. Returns #TRUE
962 * but empty key on any other error such as unknown
965 * @param keyring the keyring
966 * @param key_id the key ID
967 * @param hex_key string to append hex-encoded key to
968 * @returns #TRUE if we had enough memory
971 _dbus_keyring_get_hex_key (DBusKeyring *keyring,
977 key = find_key_by_id (keyring->keys,
981 return TRUE; /* had enough memory, so TRUE */
983 return _dbus_string_hex_encode (&key->secret, 0,
985 _dbus_string_get_length (hex_key));
988 /** @} */ /* end of exposed API */
990 #ifdef DBUS_BUILD_TESTS
991 #include "dbus-test.h"
995 _dbus_keyring_test (void)
1007 /* Context validation */
1009 _dbus_string_init_const (&context, "foo");
1010 _dbus_assert (_dbus_keyring_validate_context (&context));
1011 _dbus_string_init_const (&context, "org_freedesktop_blah");
1012 _dbus_assert (_dbus_keyring_validate_context (&context));
1014 _dbus_string_init_const (&context, "");
1015 _dbus_assert (!_dbus_keyring_validate_context (&context));
1016 _dbus_string_init_const (&context, ".foo");
1017 _dbus_assert (!_dbus_keyring_validate_context (&context));
1018 _dbus_string_init_const (&context, "bar.foo");
1019 _dbus_assert (!_dbus_keyring_validate_context (&context));
1020 _dbus_string_init_const (&context, "bar/foo");
1021 _dbus_assert (!_dbus_keyring_validate_context (&context));
1022 _dbus_string_init_const (&context, "bar\\foo");
1023 _dbus_assert (!_dbus_keyring_validate_context (&context));
1024 _dbus_string_init_const (&context, "foo\xfa\xf0");
1025 _dbus_assert (!_dbus_keyring_validate_context (&context));
1026 _dbus_string_init_const (&context, "foo\x80");
1027 _dbus_assert (!_dbus_keyring_validate_context (&context));
1028 _dbus_string_init_const (&context, "foo\x7f");
1029 _dbus_assert (_dbus_keyring_validate_context (&context));
1030 _dbus_string_init_const (&context, "foo bar");
1031 _dbus_assert (!_dbus_keyring_validate_context (&context));
1033 if (!_dbus_string_init (&context, _DBUS_INT_MAX))
1034 _dbus_assert_not_reached ("no memory");
1035 if (!_dbus_string_append_byte (&context, '\0'))
1036 _dbus_assert_not_reached ("no memory");
1037 _dbus_assert (!_dbus_keyring_validate_context (&context));
1038 _dbus_string_free (&context);
1040 /* Now verify that if we create a key in keyring 1,
1041 * it is properly loaded in keyring 2
1044 _dbus_string_init_const (&context, "org_freedesktop_dbus_testsuite");
1045 dbus_error_init (&error);
1046 ring1 = _dbus_keyring_new_homedir (NULL, &context,
1048 _dbus_assert (ring1);
1049 _dbus_assert (error.name == NULL);
1051 id = _dbus_keyring_get_best_key (ring1, &error);
1054 fprintf (stderr, "Could not load keyring: %s\n", error.message);
1055 dbus_error_free (&error);
1059 ring2 = _dbus_keyring_new_homedir (NULL, &context, &error);
1060 _dbus_assert (ring2);
1061 _dbus_assert (error.name == NULL);
1063 if (ring1->n_keys != ring2->n_keys)
1065 fprintf (stderr, "Different number of keys in keyrings\n");
1069 /* We guarantee we load and save keeping keys in a fixed
1073 while (i < ring1->n_keys)
1075 if (ring1->keys[i].id != ring2->keys[i].id)
1077 fprintf (stderr, "Keyring 1 has first key ID %d and keyring 2 has %d\n",
1078 ring1->keys[i].id, ring2->keys[i].id);
1082 if (ring1->keys[i].creation_time != ring2->keys[i].creation_time)
1084 fprintf (stderr, "Keyring 1 has first key time %ld and keyring 2 has %ld\n",
1085 ring1->keys[i].creation_time, ring2->keys[i].creation_time);
1089 if (!_dbus_string_equal (&ring1->keys[i].secret,
1090 &ring2->keys[i].secret))
1092 fprintf (stderr, "Keyrings 1 and 2 have different secrets for same ID/timestamp\n");
1099 printf (" %d keys in test\n", ring1->n_keys);
1101 _dbus_keyring_unref (ring1);
1102 _dbus_keyring_unref (ring2);
1108 _dbus_keyring_unref (ring1);
1110 _dbus_keyring_unref (ring2);
1115 #endif /* DBUS_BUILD_TESTS */