From de82297de1b0edaa42e4f75f786f6d795e604464 Mon Sep 17 00:00:00 2001 From: Kevin Wasserman Date: Wed, 18 Sep 2013 13:52:48 -0400 Subject: [PATCH] Use non-cacheable memory for passwords When available, use gnome keyring memory utilities to allocate non-cacheable memory to store passwords in memory. --- Makefile.am | 2 ++ src/moonshot-id.vala | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/Makefile.am b/Makefile.am index 0d37532..7857056 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,6 +66,7 @@ src_moonshot_LDFLAGS = -g -O0 src_moonshot_webp_VALAFLAGS = --vapidir=$(top_srcdir)/libmoonshot --pkg gtk+-2.0 --pkg gdk-2.0 --pkg libmoonshot $(AM_VALAFLAGS) src_moonshot_webp_CPPFLAGS = $(moonshot_CFLAGS) $(AM_CPPFLAGS) src_moonshot_webp_LDADD = $(moonshot_LIBS) ${top_builddir}/libmoonshot/libmoonshot.la +src_moonshot_webp_LDFLAGS = if OS_WIN32 @@ -99,6 +100,7 @@ if OS_LINUX AM_CPPFLAGS += -I/usr/include/gnome-keyring-1 AM_VALAFLAGS += --pkg moonshot-gnome-keyring --define=GNOME_KEYRING src_moonshot_LDFLAGS += -lgnome-keyring +src_moonshot_webp_LDFLAGS += -lgnome-keyring ## Installing mime type data mimedir = $(datadir)/mime/packages diff --git a/src/moonshot-id.vala b/src/moonshot-id.vala index f783810..4a38fd6 100644 --- a/src/moonshot-id.vala +++ b/src/moonshot-id.vala @@ -21,7 +21,24 @@ public class IdCard : Object public string display_name { get; set; default = ""; } public string username { get; set; default = ""; } +#if GNOME_KEYRING + private unowned string _password; + public string password { + get { + return _password; + } + set { + if (_password != null) { + GnomeKeyring.memory_free((void *)_password); + _password = null; + } + if (value != null) + _password = GnomeKeyring.memory_strdup(value); + } + } +#else public string password { get; set; default = null; } +#endif public string issuer { get; set; default = ""; } @@ -45,4 +62,8 @@ public class IdCard : Object card.display_name = NO_IDENTITY; return card; } + + ~IdCard() { + password = null; + } } -- 2.1.4