diff options
author | Shaquille Johnson <ssjohnson@google.com> | 2023-12-28 15:25:08 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2023-12-28 15:25:08 +0000 |
commit | df2668bd96b8460031bdc8c8698cbd450533ef76 (patch) | |
tree | c39cc4c0e52a8d337ea31320847550735dc6694f | |
parent | d3159659689402aac4e37ff9b377d01ebfe0d480 (diff) | |
parent | 52b8c9321b728b7b113e4116569e25ab0c96d497 (diff) | |
download | security-df2668bd96b8460031bdc8c8698cbd450533ef76.tar.gz |
Merge "When wal flag not enabled set db back to default" into main
-rw-r--r-- | keystore2/aconfig/flags.aconfig | 2 | ||||
-rw-r--r-- | keystore2/legacykeystore/lib.rs | 6 | ||||
-rw-r--r-- | keystore2/src/database.rs | 13 |
3 files changed, 9 insertions, 12 deletions
diff --git a/keystore2/aconfig/flags.aconfig b/keystore2/aconfig/flags.aconfig index 7bdb0074..133c4abe 100644 --- a/keystore2/aconfig/flags.aconfig +++ b/keystore2/aconfig/flags.aconfig @@ -1,7 +1,7 @@ package: "android.security.keystore2" flag { - name: "wal_db_journalmode_v2" + name: "wal_db_journalmode_v3" namespace: "hardware_backed_security" description: "This flag controls changing journalmode to wal" bug: "191777960" diff --git a/keystore2/legacykeystore/lib.rs b/keystore2/legacykeystore/lib.rs index a665405e..f7a81983 100644 --- a/keystore2/legacykeystore/lib.rs +++ b/keystore2/legacykeystore/lib.rs @@ -46,12 +46,6 @@ impl DB { conn: Connection::open(db_file).context("Failed to initialize SQLite connection.")?, }; - if keystore2_flags::wal_db_journalmode_v2() { - // Update journal mode to WAL - db.conn - .pragma_update(None, "journal_mode", "WAL") - .context("Failed to connect in WAL mode for persistent db")?; - } db.init_tables().context("Trying to initialize legacy keystore db.")?; Ok(db) } diff --git a/keystore2/src/database.rs b/keystore2/src/database.rs index 93de4844..15ceed60 100644 --- a/keystore2/src/database.rs +++ b/keystore2/src/database.rs @@ -1014,6 +1014,14 @@ impl KeystoreDB { let mut persistent_path_str = "file:".to_owned(); persistent_path_str.push_str(&persistent_path.to_string_lossy()); + // Connect to database in specific mode + let persistent_path_mode = if keystore2_flags::wal_db_journalmode_v3() { + "?journal_mode=WAL".to_owned() + } else { + "?journal_mode=DELETE".to_owned() + }; + persistent_path_str.push_str(&persistent_path_mode); + Ok(persistent_path_str) } @@ -1036,11 +1044,6 @@ impl KeystoreDB { break; } - if keystore2_flags::wal_db_journalmode_v2() { - // Update journal mode to WAL - conn.pragma_update(None, "journal_mode", "WAL") - .context("Failed to connect in WAL mode for persistent db")?; - } // Drop the cache size from default (2M) to 0.5M conn.execute("PRAGMA persistent.cache_size = -500;", params![]) .context("Failed to decrease cache size for persistent db")?; |