Keystore 2.0: Revise database.

* Make grants persistent.
* Moved some utility functions to db_utils.rs.
* KeystoreDB::new() now takes a path argument that indicates where the
  the database files are to be expected.
* A new test module test::utils.rs introduces TempDir which creates a
  new temporary directory that is cleaned up with all of its content
  when the TempDir opject is dropped.

Test: keystore2_test
Change-Id: I056c404fd9d592ddc8b531394b1c6cc17a0fd736
diff --git a/keystore2/src/globals.rs b/keystore2/src/globals.rs
index 0654b29..3ef75c8 100644
--- a/keystore2/src/globals.rs
+++ b/keystore2/src/globals.rs
@@ -25,5 +25,12 @@
     /// used by only one thread. So we store one database connection per
     /// thread in this thread local key.
     pub static DB: RefCell<KeystoreDB> =
-            RefCell::new(KeystoreDB::new().expect("Failed to open database."));
+            RefCell::new(
+                KeystoreDB::new(
+                    // Keystore changes to the database directory on startup
+                    // (see keystor2_main.rs).
+                    &std::env::current_dir()
+                    .expect("Could not get the current working directory.")
+                )
+                .expect("Failed to open database."));
 }