seahorse r2246 - in seahorse-plugins/trunk: . libseahorse



Author: sadam
Date: Wed Jun 25 22:07:47 2008
New Revision: 2246
URL: http://svn.gnome.org/viewvc/seahorse?rev=2246&view=rev

Log:
2008-06-25  Adam Schreiber  <sadam clemson edu>

    * libseahorse/seahorse-secure-memory.c: sync with seahorse/trunk


Modified:
   seahorse-plugins/trunk/ChangeLog
   seahorse-plugins/trunk/libseahorse/seahorse-secure-memory.c

Modified: seahorse-plugins/trunk/libseahorse/seahorse-secure-memory.c
==============================================================================
--- seahorse-plugins/trunk/libseahorse/seahorse-secure-memory.c	(original)
+++ seahorse-plugins/trunk/libseahorse/seahorse-secure-memory.c	Wed Jun 25 22:07:47 2008
@@ -94,16 +94,35 @@
     }
 }
 
+static gboolean
+seahorse_try_gk_secure_memory ()
+{
+    gpointer p;
+
+    p = gnome_keyring_memory_try_alloc (10);
+    if (p != NULL) {
+        gnome_keyring_memory_free (p);
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
 void
 seahorse_secure_memory_init ()
 {
-    GMemVTable vtable;
-    
-    memset (&vtable, 0, sizeof (vtable));
-    vtable.malloc = switch_malloc;
-    vtable.realloc = switch_realloc;
-    vtable.free = switch_free;
-    vtable.calloc = switch_calloc;
-    g_mem_set_vtable (&vtable);
+    if (seahorse_try_gk_secure_memory() == TRUE) {
+        GMemVTable vtable;
+
+        memset (&vtable, 0, sizeof (vtable));
+        vtable.malloc = switch_malloc;
+        vtable.realloc = switch_realloc;
+        vtable.free = switch_free;
+        vtable.calloc = switch_calloc;
+        g_mem_set_vtable (&vtable);
+    } else {
+        g_warning ("Unable to allocate secure memory from gnome-keyring.\n");
+        g_warning ("Proceeding using insecure memory for password fields.\n");
+    }
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]