Set secure_delete pragma for SQLite3 connections
secure_delete makes SQLite3 overwrite deleted data with zeros, thus actually deleting it from the filesystem. Ubuntu and FreeBSD enable it by defualt, but some distributions, such as Debian, have it disabled by default, so it is better to set it explicitly. The performance impact should be negligible as Gajim uses the database rarely.
This commit is contained in:
parent
e20f044001
commit
22d799a75e
|
@ -158,9 +158,15 @@ class Logger:
|
|||
self._create(CACHE_SQL_STATEMENT, self._cache_db_path)
|
||||
|
||||
@staticmethod
|
||||
def _create(statement, path):
|
||||
def _connect(*args, **kwargs):
|
||||
con = sqlite.connect(*args, **kwargs)
|
||||
con.execute("PRAGMA secure_delete=1")
|
||||
return con
|
||||
|
||||
@classmethod
|
||||
def _create(cls, statement, path):
|
||||
log.info(_('Creating %s'), path)
|
||||
con = sqlite.connect(path)
|
||||
con = cls._connect(path)
|
||||
os.chmod(path, 0o600)
|
||||
|
||||
try:
|
||||
|
@ -181,11 +187,11 @@ class Logger:
|
|||
|
||||
def _migrate_databases(self):
|
||||
try:
|
||||
con = sqlite.connect(self._log_db_path)
|
||||
con = self._connect(self._log_db_path)
|
||||
self._migrate_logs(con)
|
||||
con.close()
|
||||
|
||||
con = sqlite.connect(self._cache_db_path)
|
||||
con = self._connect(self._cache_db_path)
|
||||
self._migrate_cache(con)
|
||||
con.close()
|
||||
except Exception:
|
||||
|
@ -272,7 +278,7 @@ class Logger:
|
|||
app.ged.raise_event(event, None, str(error))
|
||||
|
||||
def _connect_databases(self):
|
||||
self._con = sqlite.connect(
|
||||
self._con = self._connect(
|
||||
self._log_db_path, timeout=20.0, isolation_level='IMMEDIATE')
|
||||
|
||||
self._con.row_factory = self.namedtuple_factory
|
||||
|
|
|
@ -131,6 +131,7 @@ class HistoryManager:
|
|||
|
||||
self.con = sqlite3.connect(
|
||||
log_db_path, timeout=20.0, isolation_level='IMMEDIATE')
|
||||
self.con.execute("PRAGMA secure_delete=1")
|
||||
self.cur = self.con.cursor()
|
||||
|
||||
self._init_jids_listview()
|
||||
|
|
Loading…
Reference in New Issue