Commit 6c87af26 authored by Ray Strode's avatar Ray Strode

Add smartcard plugin

This plugin listens for smartcard insertion and removal events and
then locks the screen or forces a log out (depending on gconf) when
the card used for login is removed.
parent c246fd81
......@@ -251,6 +251,52 @@ AM_CONDITIONAL(HAVE_PULSE, test "x$have_pulse" = "xtrue")
AC_SUBST(PULSE_CFLAGS)
AC_SUBST(PULSE_LIBS)
dnl ==============================================
dnl smartcard section
dnl ==============================================
have_smartcard_support=false
AC_ARG_ENABLE(smartcard-support,
AC_HELP_STRING([--disable-smartcard-support],
[turn off smartcard support]),
[case "${enableval}" in
yes) WANT_SMARTCARD_SUPPORT=yes ;;
no) WANT_SMARTCARD_SUPPORT=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-smartcard-support) ;;
esac],
[WANT_SMARTCARD_SUPPORT=yes])
if test x$WANT_SMARTCARD_SUPPORT = xyes ; then
NSS_REQUIRED_VERSION=3.11.2
PKG_CHECK_MODULES(NSS, nss >= $NSS_REQUIRED_VERSION,
[have_smartcard_support=true
AC_DEFINE(SMARTCARD_SUPPORT, 1, [Define if smartcard support should be enabled])],
[have_smartcard_support=false])
fi
AM_CONDITIONAL(SMARTCARD_SUPPORT, test "x$have_smartcard_support" = "xtrue")
AC_SUBST(NSS_CFLAGS)
AC_SUBST(NSS_LIBS)
AC_ARG_WITH(nssdb,
AC_HELP_STRING([--with-nssdb],
[where system NSS database is]))
NSS_DATABASE=""
if test "x$have_smartcard_support" = "xtrue"; then
if ! test -z "$with_nssdb" ; then
NSS_DATABASE="$with_nssdb"
else
NSS_DATABASE="${sysconfdir}/pki/nssdb"
fi
else
if ! test -z "$with_nssdb" ; then
AC_MSG_WARN([nssdb specified when smartcard support is disabled])
fi
fi
AC_SUBST(NSS_DATABASE)
# ---------------------------------------------------------------------------
# Enable Profiling
# ---------------------------------------------------------------------------
......@@ -350,6 +396,7 @@ plugins/keyboard/Makefile
plugins/media-keys/Makefile
plugins/media-keys/cut-n-paste/Makefile
plugins/mouse/Makefile
plugins/smartcard/Makefile
plugins/sound/Makefile
plugins/typing-break/Makefile
plugins/xrandr/Makefile
......@@ -390,5 +437,9 @@ echo "
Libnotify support: ${have_libnotify}
PulseAudio support: ${have_pulse}
Smartcard support: ${have_smartcard_support}
${NSS_DATABASE:+\
System nssdb: ${NSS_DATABASE}
}\
Profiling support: ${enable_profiling}
"
......@@ -11,6 +11,7 @@ schemas_in_files = \
desktop_gnome_keybindings.schemas.in \
apps_gnome_settings_daemon_xrandr.schemas.in \
desktop_gnome_peripherals_touchpad.schemas.in \
desktop_gnome_peripherals_smartcard.schemas.in \
$(NULL)
schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
......
<?xml version="1.0"?>
<gconfschemafile>
<schemalist>
<schema>
<key>/schemas/desktop/gnome/peripherals/smartcard/removal_action</key>
<applyto>/desktop/gnome/peripherals/smartcard/removal_action</applyto>
<owner>gnome</owner>
<type>string</type>
<default>none</default>
<locale name="C">
<short>Smartcard removal action</short>
<long>Set this to one of "none", "lock_screen", or "force_logout". The action will
get performed when the smartcard used for log in is removed.</long>
</locale>
</schema>
</schemalist>
</gconfschemafile>
......@@ -208,7 +208,39 @@
<long></long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnome_settings_daemon/plugins/smartcard/active</key>
<applyto>/apps/gnome_settings_daemon/plugins/smartcard/active</applyto>
<owner>gnome-settings-daemon</owner>
<type>bool</type>
<default>TRUE</default>
<locale name="C">
<short>Enable smartcard plugin</short>
<long>Set to True to enable the plugin to manage locking screen on smartcard removal.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnome_settings_daemon/plugins/smartcard/active</key>
<applyto>/apps/gnome_settings_daemon/plugins/smartcard/active</applyto>
<owner>gnome-settings-daemon</owner>
<type>bool</type>
<default>TRUE</default>
<locale name="C">
<short>Enable smartcard plugin</short>
<long>Set to True to enable the plugin to manage locking screen on smartcard removal.</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnome_settings_daemon/plugins/smartcard/priority</key>
<applyto>/apps/gnome_settings_daemon/plugins/smartcard/priority</applyto>
<owner>gnome-settings-daemon</owner>
<type>int</type>
<default>8</default>
<locale name="C">
<short></short>
<long></long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnome_settings_daemon/plugins/sound/active</key>
<applyto>/apps/gnome_settings_daemon/plugins/sound/active</applyto>
......
......@@ -12,6 +12,7 @@ SUBDIRS = \
keyboard \
media-keys \
mouse \
smartcard \
sound \
typing-break \
xrandr \
......
if SMARTCARD_SUPPORT
plugin_LTLIBRARIES = \
libsmartcard.la
libsmartcard_la_SOURCES = \
gsd-smartcard-plugin.h \
gsd-smartcard-plugin.c \
gsd-smartcard.h \
gsd-smartcard.c \
gsd-smartcard-manager.h \
gsd-smartcard-manager.c
libsmartcard_la_CPPFLAGS = \
-I$(top_srcdir)/gnome-settings-daemon \
-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
-DLIBDIR=\""$(libdir)"\" \
-DGSD_SMARTCARD_MANAGER_NSS_DB=\""$(NSS_DATABASE)"\" \
$(AM_CPPFLAGS)
libsmartcard_la_CFLAGS = \
$(SETTINGS_PLUGIN_CFLAGS) \
$(GNOME_CFLAGS) \
$(NSS_CFLAGS) \
$(AM_CFLAGS)
libsmartcard_la_LDFLAGS = \
$(GSD_PLUGIN_LDFLAGS)
libsmartcard_la_LIBADD = \
$(SETTINGS_PLUGIN_LIBS) \
$(NSS_LIBS)
plugin_in_files = \
smartcard.gnome-settings-plugin.in
plugin_DATA = $(plugin_in_files:.gnome-settings-plugin.in=.gnome-settings-plugin)
EXTRA_DIST = \
$(plugin_in_files)
CLEANFILES = \
$(plugin_DATA)
DISTCLEANFILES = \
$(plugin_DATA)
@GSD_INTLTOOL_PLUGIN_RULE@
endif
This diff is collapsed.
/* gsd-smartcard-manager.h - object for monitoring smartcard insertion and
* removal events
*
* Copyright (C) 2006, 2009 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by: Ray Strode
*/
#ifndef GSD_SMARTCARD_MANAGER_H
#define GSD_SMARTCARD_MANAGER_H
#define GSD_SMARTCARD_ENABLE_INTERNAL_API
#include "gsd-smartcard.h"
#include <glib.h>
#include <glib-object.h>
G_BEGIN_DECLS
#define GSD_TYPE_SMARTCARD_MANAGER (gsd_smartcard_manager_get_type ())
#define GSD_SMARTCARD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GSD_TYPE_SMARTCARD_MANAGER, GsdSmartcardManager))
#define GSD_SMARTCARD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GSD_TYPE_SMARTCARD_MANAGER, GsdSmartcardManagerClass))
#define GSD_IS_SMARTCARD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SC_TYPE_SMARTCARD_MANAGER))
#define GSD_IS_SMARTCARD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SC_TYPE_SMARTCARD_MANAGER))
#define GSD_SMARTCARD_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GSD_TYPE_SMARTCARD_MANAGER, GsdSmartcardManagerClass))
#define GSD_SMARTCARD_MANAGER_ERROR (gsd_smartcard_manager_error_quark ())
typedef struct _GsdSmartcardManager GsdSmartcardManager;
typedef struct _GsdSmartcardManagerClass GsdSmartcardManagerClass;
typedef struct _GsdSmartcardManagerPrivate GsdSmartcardManagerPrivate;
typedef enum _GsdSmartcardManagerError GsdSmartcardManagerError;
struct _GsdSmartcardManager {
GObject parent;
/*< private > */
GsdSmartcardManagerPrivate *priv;
};
struct _GsdSmartcardManagerClass {
GObjectClass parent_class;
/* Signals */
void (*smartcard_inserted) (GsdSmartcardManager *manager,
GsdSmartcard *token);
void (*smartcard_removed) (GsdSmartcardManager *manager,
GsdSmartcard *token);
void (*error) (GsdSmartcardManager *manager,
GError *error);
};
enum _GsdSmartcardManagerError {
GSD_SMARTCARD_MANAGER_ERROR_GENERIC = 0,
GSD_SMARTCARD_MANAGER_ERROR_WITH_NSS,
GSD_SMARTCARD_MANAGER_ERROR_LOADING_DRIVER,
GSD_SMARTCARD_MANAGER_ERROR_WATCHING_FOR_EVENTS,
GSD_SMARTCARD_MANAGER_ERROR_REPORTING_EVENTS
};
GType gsd_smartcard_manager_get_type (void) G_GNUC_CONST;
GQuark gsd_smartcard_manager_error_quark (void) G_GNUC_CONST;
GsdSmartcardManager *gsd_smartcard_manager_new (const char *module);
gboolean gsd_smartcard_manager_start (GsdSmartcardManager *manager,
GError **error);
void gsd_smartcard_manager_stop (GsdSmartcardManager *manager);
char *gsd_smartcard_manager_get_module_path (GsdSmartcardManager *manager);
gboolean gsd_smartcard_manager_login_card_is_inserted (GsdSmartcardManager *manager);
G_END_DECLS
#endif /* GSD_SMARTCARD_MANAGER_H */
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "config.h"
#include <glib/gi18n-lib.h>
#include <gmodule.h>
#include <glib.h>
#include <glib-object.h>
#include <dbus/dbus-glib.h>
#include <gconf/gconf-client.h>
#include "gnome-settings-plugin.h"
#include "gsd-smartcard-plugin.h"
#include "gsd-smartcard-manager.h"
struct GsdSmartcardPluginPrivate {
GsdSmartcardManager *manager;
DBusGConnection *bus_connection;
guint32 is_active : 1;
};
typedef enum
{
GSD_SMARTCARD_REMOVE_ACTION_NONE,
GSD_SMARTCARD_REMOVE_ACTION_LOCK_SCREEN,
GSD_SMARTCARD_REMOVE_ACTION_FORCE_LOGOUT,
} GsdSmartcardRemoveAction;
#define SCREENSAVER_DBUS_NAME "org.gnome.ScreenSaver"
#define SCREENSAVER_DBUS_PATH "/"
#define SCREENSAVER_DBUS_INTERFACE "org.gnome.ScreenSaver"
#define SM_DBUS_NAME "org.gnome.SessionManager"
#define SM_DBUS_PATH "/org/gnome/SessionManager"
#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
#define SM_LOGOUT_MODE_FORCE 2
#define GSD_SMARTCARD_KEY "/desktop/gnome/peripherals/smartcard"
#define KEY_REMOVE_ACTION GSD_SMARTCARD_KEY "/removal_action"
#define GSD_SMARTCARD_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_SMARTCARD_PLUGIN, GsdSmartcardPluginPrivate))
GNOME_SETTINGS_PLUGIN_REGISTER (GsdSmartcardPlugin, gsd_smartcard_plugin);
static void
simulate_user_activity (GsdSmartcardPlugin *plugin)
{
DBusGProxy *screensaver_proxy;
g_debug ("GsdSmartcardPlugin telling screensaver about smart card insertion");
screensaver_proxy = dbus_g_proxy_new_for_name (plugin->priv->bus_connection,
SCREENSAVER_DBUS_NAME,
SCREENSAVER_DBUS_PATH,
SCREENSAVER_DBUS_INTERFACE);
dbus_g_proxy_call_no_reply (screensaver_proxy,
"SimulateUserActivity",
G_TYPE_INVALID, G_TYPE_INVALID);
g_object_unref (screensaver_proxy);
}
static void
lock_screen (GsdSmartcardPlugin *plugin)
{
DBusGProxy *screensaver_proxy;
g_debug ("GsdSmartcardPlugin telling screensaver to lock screen");
screensaver_proxy = dbus_g_proxy_new_for_name (plugin->priv->bus_connection,
SCREENSAVER_DBUS_NAME,
SCREENSAVER_DBUS_PATH,
SCREENSAVER_DBUS_INTERFACE);
dbus_g_proxy_call_no_reply (screensaver_proxy,
"Lock",
G_TYPE_INVALID, G_TYPE_INVALID);
g_object_unref (screensaver_proxy);
}
static void
force_logout (GsdSmartcardPlugin *plugin)
{
DBusGProxy *sm_proxy;
GError *error;
gboolean res;
g_debug ("GsdSmartcardPlugin telling session manager to force logout");
sm_proxy = dbus_g_proxy_new_for_name (plugin->priv->bus_connection,
SM_DBUS_NAME,
SM_DBUS_PATH,
SM_DBUS_INTERFACE);
error = NULL;
res = dbus_g_proxy_call (sm_proxy,
"Logout",
&error,
G_TYPE_UINT, SM_LOGOUT_MODE_FORCE,
G_TYPE_INVALID, G_TYPE_INVALID);
if (! res) {
g_warning ("GsdSmartcardPlugin Unable to force logout: %s", error->message);
g_error_free (error);
}
g_object_unref (sm_proxy);
}
static void
gsd_smartcard_plugin_init (GsdSmartcardPlugin *plugin)
{
plugin->priv = GSD_SMARTCARD_PLUGIN_GET_PRIVATE (plugin);
g_debug ("GsdSmartcardPlugin initializing");
plugin->priv->manager = gsd_smartcard_manager_new (NULL);
}
static void
gsd_smartcard_plugin_finalize (GObject *object)
{
GsdSmartcardPlugin *plugin;
g_return_if_fail (object != NULL);
g_return_if_fail (GSD_IS_SMARTCARD_PLUGIN (object));
g_debug ("GsdSmartcardPlugin finalizing");
plugin = GSD_SMARTCARD_PLUGIN (object);
g_return_if_fail (plugin->priv != NULL);
if (plugin->priv->manager != NULL) {
g_object_unref (plugin->priv->manager);
}
G_OBJECT_CLASS (gsd_smartcard_plugin_parent_class)->finalize (object);
}
static void
smartcard_inserted_cb (GsdSmartcardManager *card_monitor,
GsdSmartcard *card,
GsdSmartcardPlugin *plugin)
{
char *name;
name = gsd_smartcard_get_name (card);
g_debug ("GsdSmartcardPlugin smart card '%s' inserted", name);
g_free (name);
simulate_user_activity (plugin);
}
static gboolean
user_logged_in_with_smartcard (void)
{
return g_getenv ("PKCS11_LOGIN_TOKEN_NAME") != NULL;
}
static GsdSmartcardRemoveAction
get_configured_remove_action (GsdSmartcardPlugin *plugin)
{
GConfClient *client;
char *remove_action_string;
GsdSmartcardRemoveAction remove_action;
client = gconf_client_get_default ();
remove_action_string = gconf_client_get_string (client,
KEY_REMOVE_ACTION, NULL);
if (remove_action_string == NULL) {
g_warning ("GsdSmartcardPlugin unable to get smartcard remove action");
remove_action = GSD_SMARTCARD_REMOVE_ACTION_NONE;
} else if (strcmp (remove_action_string, "none") == 0) {
remove_action = GSD_SMARTCARD_REMOVE_ACTION_NONE;
} else if (strcmp (remove_action_string, "lock_screen") == 0) {
remove_action = GSD_SMARTCARD_REMOVE_ACTION_LOCK_SCREEN;
} else if (strcmp (remove_action_string, "force_logout") == 0) {
remove_action = GSD_SMARTCARD_REMOVE_ACTION_FORCE_LOGOUT;
} else {
g_warning ("GsdSmartcardPlugin unknown smartcard remove action");
remove_action = GSD_SMARTCARD_REMOVE_ACTION_NONE;
}
g_object_unref (client);
return remove_action;
}
static void
process_smartcard_removal (GsdSmartcardPlugin *plugin)
{
GsdSmartcardRemoveAction remove_action;
g_debug ("GsdSmartcardPlugin processing smartcard removal");
remove_action = get_configured_remove_action (plugin);
switch (remove_action)
{
case GSD_SMARTCARD_REMOVE_ACTION_NONE:
return;
case GSD_SMARTCARD_REMOVE_ACTION_LOCK_SCREEN:
lock_screen (plugin);
break;
case GSD_SMARTCARD_REMOVE_ACTION_FORCE_LOGOUT:
force_logout (plugin);
break;
}
}
static void
smartcard_removed_cb (GsdSmartcardManager *card_monitor,
GsdSmartcard *card,
GsdSmartcardPlugin *plugin)
{
char *name;
name = gsd_smartcard_get_name (card);
g_debug ("GsdSmartcardPlugin smart card '%s' removed", name);
g_free (name);
if (!gsd_smartcard_is_login_card (card)) {
g_debug ("GsdSmartcardPlugin removed smart card was not used to login");
return;
}
process_smartcard_removal (plugin);
}
static void
impl_activate (GnomeSettingsPlugin *plugin)
{
GError *error;
GsdSmartcardPlugin *smartcard_plugin = GSD_SMARTCARD_PLUGIN (plugin);
if (smartcard_plugin->priv->is_active) {
g_debug ("GsdSmartcardPlugin Not activating smartcard plugin, because it's "
"already active");
return;
}
if (!user_logged_in_with_smartcard ()) {
g_debug ("GsdSmartcardPlugin Not activating smartcard plugin, because user didn't use "
" smartcard to log in");
smartcard_plugin->priv->is_active = FALSE;
return;
}
g_debug ("GsdSmartcardPlugin Activating smartcard plugin");
error = NULL;
smartcard_plugin->priv->bus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (smartcard_plugin->priv->bus_connection == NULL) {
g_warning ("GsdSmartcardPlugin Unable to connect to session bus: %s", error->message);
return;
}
if (!gsd_smartcard_manager_start (smartcard_plugin->priv->manager, &error)) {
g_warning ("GsdSmartcardPlugin Unable to start smartcard manager: %s", error->message);
g_error_free (error);
}
g_signal_connect (smartcard_plugin->priv->manager,
"smartcard-removed",
G_CALLBACK (smartcard_removed_cb), smartcard_plugin);
g_signal_connect (smartcard_plugin->priv->manager,
"smartcard-inserted",
G_CALLBACK (smartcard_inserted_cb), smartcard_plugin);
if (!gsd_smartcard_manager_login_card_is_inserted (smartcard_plugin->priv->manager)) {
g_debug ("GsdSmartcardPlugin processing smartcard removal immediately user logged in with smartcard "
"and it's not inserted");
process_smartcard_removal (smartcard_plugin);
}
smartcard_plugin->priv->is_active = TRUE;
}
static void
impl_deactivate (GnomeSettingsPlugin *plugin)
{
GsdSmartcardPlugin *smartcard_plugin = GSD_SMARTCARD_PLUGIN (plugin);
if (!smartcard_plugin->priv->is_active) {
g_debug ("GsdSmartcardPlugin Not deactivating smartcard plugin, "
"because it's already inactive");
return;
}
g_debug ("GsdSmartcardPlugin Deactivating smartcard plugin");
gsd_smartcard_manager_stop (smartcard_plugin->priv->manager);
g_signal_handlers_disconnect_by_func (smartcard_plugin->priv->manager,
smartcard_removed_cb, smartcard_plugin);
g_signal_handlers_disconnect_by_func (smartcard_plugin->priv->manager,
smartcard_inserted_cb, smartcard_plugin);
smartcard_plugin->priv->bus_connection = NULL;
smartcard_plugin->priv->is_active = FALSE;
}
static void
gsd_smartcard_plugin_class_init (GsdSmartcardPluginClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GnomeSettingsPluginClass *plugin_class = GNOME_SETTINGS_PLUGIN_CLASS (klass);
object_class->finalize = gsd_smartcard_plugin_finalize;
plugin_class->activate = impl_activate;
plugin_class->deactivate = impl_deactivate;
g_type_class_add_private (klass, sizeof (GsdSmartcardPluginPrivate));
}
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
*
* Copyright (C) 2010 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef __GSD_SMARTCARD_PLUGIN_H__
#define __GSD_SMARTCARD_PLUGIN_H__
#include <glib.h>
#include <glib-object.h>
#include <gmodule.h>
#include "gnome-settings-plugin.h"
G_BEGIN_DECLS
#define GSD_TYPE_SMARTCARD_PLUGIN (gsd_smartcard_plugin_get_type ())
#define GSD_SMARTCARD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_SMARTCARD_PLUGIN, GsdSmartcardPlugin))
#define GSD_SMARTCARD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GSD_TYPE_SMARTCARD_PLUGIN, GsdSmartcardPluginClass))
#define GSD_IS_SMARTCARD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_SMARTCARD_PLUGIN))
#define GSD_IS_SMARTCARD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_SMARTCARD_PLUGIN))
#define GSD_SMARTCARD_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_SMARTCARD_PLUGIN, GsdSmartcardPluginClass))
typedef struct GsdSmartcardPluginPrivate GsdSmartcardPluginPrivate;
typedef struct
{
GnomeSettingsPlugin parent;
GsdSmartcardPluginPrivate *priv;
} GsdSmartcardPlugin;
typedef struct
{
GnomeSettingsPluginClass parent_class;
} GsdSmartcardPluginClass;
GType gsd_smartcard_plugin_get_type (void) G_GNUC_CONST;
/* All the plugins must implement this function */
G_MODULE_EXPORT GType register_gnome_settings_plugin (GTypeModule *module);
G_END_DECLS
#endif /* __GSD_SMARTCARD_PLUGIN_H__ */
/* gsd-smartcard.c - smartcard object
*
* Copyright (C) 2006 Ray Strode <rstrode@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#define GSD_SMARTCARD_ENABLE_INTERNAL_API
#include "gsd-smartcard.h"
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <glib.h>
#include <glib/gi18n.h>
#include <cert.h>
#include <nss.h>
#include <pk11func.h>
#include <prerror.h>
#include <secmod.h>
#include <secerr.h>
struct _GsdSmartcardPrivate {
SECMODModule *module;
GsdSmartcardState state;
CK_SLOT_ID slot_id;
int slot_series;
PK11SlotInfo *slot;
char *name;
CERTCertificate *signing_certificate;
CERTCertificate *encryption_certificate;