gnome-keyring API has evolved since this unmaintained tool was written.

Debugging can be made in by different means, remove.

ok jasper@
This commit is contained in:
ajacoutot 2010-10-04 06:26:05 +00:00
parent 07d16451ad
commit da9d33706f
5 changed files with 0 additions and 216 deletions

View File

@ -1,41 +0,0 @@
# $OpenBSD: Makefile,v 1.8 2010/07/25 08:15:32 ajacoutot Exp $
COMMENT= provide limited command-line access to the GNOME keyring
GNOME_PROJECT= gnome-keyring-query
GNOME_VERSION= 0.0.1
REVISION= 5
DISTFILES=
CATEGORIES= sysutils
# Public Domain
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
MODULES= x11/gnome \
devel/gettext
WANTLIB= c glib-2.0 pthread gnome-keyring
LIB_DEPENDS= :libgnome-keyring-*:x11/gnome/libgnome-keyring
CONFIGURE_STYLE= none
NO_REGRESS= Yes
do-extract:
@cp ${FILESDIR}/gnome-keyring-query.c ${WRKDIR}
do-build:
${CC} ${CFLAGS} -pthread `pkg-config --cflags --libs gnome-keyring-1 glib-2.0` \
-o ${WRKDIR}/gnome-keyring-query ${WRKDIR}/gnome-keyring-query.c
do-install:
${INSTALL_PROGRAM} ${WRKDIR}/gnome-keyring-query ${PREFIX}/bin/
${INSTALL_DATA_DIR} ${PREFIX}/share/doc/gnome-keyring-query
${INSTALL_DATA} ${FILESDIR}/README.OpenBSD \
${PREFIX}/share/doc/gnome-keyring-query
.include <bsd.port.mk>

View File

@ -1,7 +0,0 @@
$OpenBSD: README.OpenBSD,v 1.2 2009/02/10 21:01:23 ajacoutot Exp $
gnome-keyring-query provides limited command-line access to the GNOME keyring.
It is mostly usefull for debugging purposes.
For more information on how to use this tool, please refer to:
http://gentoo-wiki.com/HOWTO_Use_gnome-keyring_to_store_SSH_passphrases

View File

@ -1,159 +0,0 @@
/* $OpenBSD: gnome-keyring-query.c,v 1.2 2009/02/10 21:01:23 ajacoutot Exp $ */
/*
* This file was found on:
* http://gentoo-wiki.com/HOWTO_Use_gnome-keyring_to_store_SSH_passphrases
*
* It has been provided the PUBLIC DOMAIN, AS-IS, without warranty.
*/
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include "gnome-keyring.h"
#define APPLICATION_NAME "gnome-keyring-query"
#define MAX_PASSWORD_LENGTH 100
char * get_password(const char * name);
int set_password(const char * name, const char * password);
void usage()
{
puts("Usage:\n"
" " APPLICATION_NAME " <mode> <name>\n"
"Parameters:\n"
" mode - either 'get' or 'set' (without quotes)\n"
" name - a name to identify the key\n"
"Notes:\n"
" If mode is 'get', then the password is dumped to stdout.\n"
" If mode is 'set', then the password is read from stdin.\n");
exit(EXIT_FAILURE);
}
int main(int argc, char * argv[])
{
enum
{
MODE_GET, MODE_SET
} mode;
char * name;
char * password;
g_set_application_name(APPLICATION_NAME);
if (argc != 3)
usage();
if (g_ascii_strcasecmp(argv[1], "get") == 0)
mode = MODE_GET;
else if (g_ascii_strcasecmp(argv[1], "set") == 0)
mode = MODE_SET;
else
{
fprintf(stderr, "Invalid mode: %s\n", argv[1]);
exit(EXIT_FAILURE);
}
name = argv[2];
switch (mode)
{
case MODE_GET:
password = get_password(name);
if (!password)
{
fprintf(stderr, "Failed to get password: %s\n", name);
exit(EXIT_FAILURE);
}
puts(password);
g_free(password);
break;
case MODE_SET:
password = g_malloc(MAX_PASSWORD_LENGTH);
*password = '\0';
fgets(password, MAX_PASSWORD_LENGTH, stdin);
if (!set_password(name, password))
{
fprintf(stderr, "Failed to set password: %s\n", name);
exit(EXIT_FAILURE);
}
g_free(password);
break;
}
return 0;
}
char * get_password(const char * name)
{
GnomeKeyringAttributeList * attributes;
GnomeKeyringResult result;
GList * found_list;
GList * i;
GnomeKeyringFound * found;
char * password;
attributes = g_array_new(FALSE, FALSE, sizeof (GnomeKeyringAttribute));
gnome_keyring_attribute_list_append_string(attributes,
"name",
name);
gnome_keyring_attribute_list_append_string(attributes,
"magic",
APPLICATION_NAME);
result = gnome_keyring_find_items_sync(GNOME_KEYRING_ITEM_GENERIC_SECRET,
attributes,
&found_list);
gnome_keyring_attribute_list_free(attributes);
if (result != GNOME_KEYRING_RESULT_OK)
return NULL;
for (i = found_list; i != NULL; i = i->next)
{
found = i->data;
password = g_strdup(found->secret);
break;
}
gnome_keyring_found_list_free(found_list);
return password;
}
int set_password(const char * name, const char * password)
{
GnomeKeyringAttributeList * attributes;
GnomeKeyringResult result;
guint item_id;
attributes = g_array_new(FALSE, FALSE, sizeof (GnomeKeyringAttribute));
gnome_keyring_attribute_list_append_string(attributes,
"name",
name);
gnome_keyring_attribute_list_append_string(attributes,
"magic",
APPLICATION_NAME);
result = gnome_keyring_item_create_sync(NULL,
GNOME_KEYRING_ITEM_GENERIC_SECRET,
name,
attributes,
password,
TRUE,
&item_id);
gnome_keyring_attribute_list_free(attributes);
return (result == GNOME_KEYRING_RESULT_OK);
}

View File

@ -1,5 +0,0 @@
gnome-keyring-query has the capability to store and retrieve simple
name/passphrase pairs in the default keyring. Unlike applications like
Nautilus and Evolution, no additional fields are stored, with the
exception of a 'magic' field to distinguish keys created by
gnome-keyring-query from those created by other applications.

View File

@ -1,4 +0,0 @@
@comment $OpenBSD: PLIST,v 1.2 2008/10/30 12:26:37 jasper Exp $
@bin bin/gnome-keyring-query
share/doc/gnome-keyring-query/
share/doc/gnome-keyring-query/README.OpenBSD