• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/dbus-1.6.8/dbus/

Lines Matching defs:keyring

2 /* dbus-keyring.c Store secret cookies in your homedir
25 #include "dbus-keyring.h"
32 * @defgroup DBusKeyring keyring class
80 * Maximum number of keys in the keyring before
119 DBusCredentials *credentials; /**< Credentials containing user the keyring is for */
125 DBusKeyring *keyring;
127 keyring = dbus_new0 (DBusKeyring, 1);
128 if (keyring == NULL)
131 if (!_dbus_string_init (&keyring->directory))
134 if (!_dbus_string_init (&keyring->filename))
137 if (!_dbus_string_init (&keyring->filename_lock))
140 keyring->refcount = 1;
141 keyring->keys = NULL;
142 keyring->n_keys = 0;
144 return keyring;
147 _dbus_string_free (&keyring->filename);
149 _dbus_string_free (&keyring->directory);
151 dbus_free (keyring);
196 _dbus_keyring_lock (DBusKeyring *keyring)
205 if (_dbus_create_file_exclusively (&keyring->filename_lock,
225 if (!_dbus_delete_file (&keyring->filename_lock, &error))
233 if (!_dbus_create_file_exclusively (&keyring->filename_lock,
247 _dbus_keyring_unlock (DBusKeyring *keyring)
251 if (!_dbus_delete_file (&keyring->filename_lock, &error))
380 * Reloads the keyring file, optionally adds one new key to the file,
382 * resaves the file. Stores the keys from the file in keyring->keys.
388 * @param keyring the keyring
394 _dbus_keyring_reload (DBusKeyring *keyring,
410 if (!_dbus_check_dir_is_private_to_user (&keyring->directory, error))
435 if (!_dbus_keyring_lock (keyring))
438 "Could not lock keyring file to add to it");
447 &keyring->filename,
450 _dbus_verbose ("Failed to load keyring file: %s\n",
452 /* continue with empty keyring file, so we recreate it */
459 _dbus_warn ("Secret keyring file contains non-ASCII! Ignoring existing contents\n");
463 /* FIXME this is badly inefficient for large keyring files
464 * (not that large keyring files exist outside of test suites)
551 _dbus_verbose ("invalid hex encoding in keyring file\n");
605 if (!_dbus_string_save_to_file (&contents, &keyring->filename,
610 if (keyring->keys)
611 free_keys (keyring->keys, keyring->n_keys);
612 keyring->keys = keys;
613 keyring->n_keys = n_keys;
621 _dbus_keyring_unlock (keyring);
661 * Increments reference count of the keyring
663 * @param keyring the keyring
664 * @returns the keyring
667 _dbus_keyring_ref (DBusKeyring *keyring)
669 keyring->refcount += 1;
671 return keyring;
678 * @param keyring the keyring
681 _dbus_keyring_unref (DBusKeyring *keyring)
683 keyring->refcount -= 1;
685 if (keyring->refcount == 0)
687 if (keyring->credentials)
688 _dbus_credentials_unref (keyring->credentials);
690 _dbus_string_free (&keyring->filename);
691 _dbus_string_free (&keyring->filename_lock);
692 _dbus_string_free (&keyring->directory);
693 free_keys (keyring->keys, keyring->n_keys);
694 dbus_free (keyring);
699 * Creates a new keyring that lives in the ~/.dbus-keyrings directory
703 * @param username username to get keyring for, or #NULL
704 * @param context which keyring to get
706 * @returns the keyring or #NULL on error
714 DBusKeyring *keyring;
724 "Unable to create DBus keyring when setuid");
728 keyring = NULL;
760 keyring = _dbus_keyring_new ();
761 if (keyring == NULL)
764 _dbus_assert (keyring->credentials == NULL);
765 keyring->credentials = our_credentials;
774 "Invalid context in keyring creation");
778 /* Save keyring dir in the keyring object */
780 &keyring->directory, 0))
783 /* Create keyring->filename based on keyring dir and context */
784 if (!_dbus_string_copy (&keyring->directory, 0,
785 &keyring->filename, 0))
788 if (!_dbus_concat_dir_and_file (&keyring->filename,
793 if (!_dbus_string_copy (&keyring->filename, 0,
794 &keyring->filename_lock, 0))
797 if (!_dbus_string_append (&keyring->filename_lock, ".lock"))
800 /* Reload keyring */
802 if (!_dbus_keyring_reload (keyring, FALSE, &tmp_error))
804 _dbus_verbose ("didn't load an existing keyring: %s\n",
810 * but the keyring will probably always be empty
814 if (!_dbus_create_directory (&keyring->directory,
817 _dbus_verbose ("Creating keyring directory: %s\n",
824 return keyring;
833 if (keyring)
834 _dbus_keyring_unref (keyring);
913 find_recent_key (DBusKeyring *keyring)
921 while (i < keyring->n_keys)
923 DBusKey *key = &keyring->keys[i];
940 * the key ID. If a key can't be written to the keyring
944 * @param keyring the keyring
949 _dbus_keyring_get_best_key (DBusKeyring *keyring,
956 key = find_recent_key (keyring);
961 * keyring. Create a new one.
963 if (!_dbus_keyring_reload (keyring, TRUE,
967 key = find_recent_key (keyring);
974 "No recent-enough key found in keyring, and unable to create a new key");
980 * Checks whether the keyring is for the same user as the given credentials.
982 * @param keyring the keyring
985 * @returns #TRUE if the keyring belongs to the given user
988 _dbus_keyring_is_for_credentials (DBusKeyring *keyring,
991 return _dbus_credentials_same_user (keyring->credentials,
1001 * @param keyring the keyring
1007 _dbus_keyring_get_hex_key (DBusKeyring *keyring,
1013 key = find_key_by_id (keyring->keys,
1014 keyring->n_keys,
1076 /* Now verify that if we create a key in keyring 1,
1077 * it is properly loaded in keyring 2
1090 fprintf (stderr, "Could not load keyring: %s\n", error.message);
1113 fprintf (stderr, "Keyring 1 has first key ID %d and keyring 2 has %d\n",
1120 fprintf (stderr, "Keyring 1 has first key time %ld and keyring 2 has %ld\n",