Esempio n. 1
0
void remmina_plugin_glibsecret_delete_password(RemminaFile *remminafile, const gchar *key)
{
	TRACE_CALL(__func__);
	GError *r = NULL;
	const gchar *path;

	path = remmina_plugin_service->file_get_path(remminafile);
	secret_password_clear_sync(&remmina_file_secret_schema, NULL, &r, "filename", path, "key", key, NULL);
	if (r == NULL) {
		remmina_plugin_service->log_printf("[glibsecret] password \"%s\" deleted for file %s\n", key, path);
	}else  {
		remmina_plugin_service->log_printf("[glibsecret] password \"%s\" cannot be deleted for file %s\n", key, path);
	}
}
Esempio n. 2
0
gboolean
goa_utils_delete_credentials_sync (GoaProvider   *provider,
                                   GoaAccount    *object,
                                   GCancellable  *cancellable,
                                   GError       **error)
{
  gboolean ret;
  gchar *password_key;
  const gchar *id;
  GError *sec_error = NULL;

  g_return_val_if_fail (GOA_IS_PROVIDER (provider), FALSE);
  g_return_val_if_fail (GOA_IS_ACCOUNT (object), FALSE);
  g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), FALSE);
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);

  ret = FALSE;

  password_key = NULL;

  id = goa_account_get_id (object);

  password_key = g_strdup_printf ("%s:gen%d:%s",
                                  goa_provider_get_provider_type (GOA_PROVIDER (provider)),
                                  goa_provider_get_credentials_generation (GOA_PROVIDER (provider)),
                                  id);

  secret_password_clear_sync (&secret_password_schema,
                              cancellable,
                              &sec_error,
                              "goa-identity", password_key,
                              NULL);
  if (sec_error != NULL)
    {
      g_warning ("secret_password_clear_sync() failed: %s", sec_error->message);
      g_set_error_literal (error,
                           GOA_ERROR,
                           GOA_ERROR_FAILED, /* TODO: more specific */
                           _("Failed to delete credentials from the keyring"));
      g_error_free (sec_error);
      goto out;
    }

  g_debug ("Cleared keyring credentials for id: %s", id);
  ret = TRUE;

 out:
  g_free (password_key);
  return ret;
}
Esempio n. 3
0
/* Try and remove the cached password for key grip.  Returns -1 on
   error, 0 if the key is not found and 1 if the password was
   removed.  */
int
password_cache_clear (const char *keygrip)
{
#ifdef HAVE_LIBSECRET
  GError *error = NULL;
  int removed = secret_password_clear_sync (gpg_schema (), NULL, &error,
					    "keygrip", keygrip, NULL);
  if (error != NULL)
    {
      fprintf (stderr, "Failed to clear password for key %s with secret service: %s\n",
	     keygrip, error->message);
      g_debug("%s", error->message);
      g_error_free (error);
      return -1;
    }
  if (removed)
    return 1;
  return 0;
#else
  return -1;
#endif
}
Esempio n. 4
0
static int _clear_string_value( const SecretSchema * s,const char * k )
{
	return secret_password_clear_sync( s,NULL,NULL,"string",k,NULL ) ;
}
Esempio n. 5
0
static int _clear_integer_value( const SecretSchema * s,int k )
{
	return secret_password_clear_sync( s,NULL,NULL,"integer",k,NULL ) ;
}