Use non-cacheable memory for passwords
authorKevin Wasserman <krwasserman@hotmail.com>
Wed, 18 Sep 2013 17:52:48 +0000 (13:52 -0400)
committerKevin Wasserman <krwasserman@hotmail.com>
Wed, 18 Sep 2013 17:52:48 +0000 (13:52 -0400)
When available, use gnome keyring memory utilities to allocate
non-cacheable memory to store passwords in memory.

Makefile.am
src/moonshot-id.vala

index 0d37532..7857056 100644 (file)
@@ -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
index f783810..4a38fd6 100644 (file)
@@ -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;
+  }
 }