mirror of
https://github.com/bjc/prosody.git
synced 2025-04-01 20:27:39 +03:00
util.sql: SQLCipher support
This enables use of encrypted databases if LuaDBI or LuaSQLite3 has been linked against SQLCipher. Using `LD_PRELOAD` may work as well. Requires SQLCipher >= 4.0.0 due to the use of UPSERT
This commit is contained in:
parent
2d4ea8ac9b
commit
654edd37bb
3 changed files with 13 additions and 0 deletions
1
CHANGES
1
CHANGES
|
@ -46,6 +46,7 @@ TRUNK
|
|||
- New 'keyval+' combined keyval/map store type
|
||||
- Performance improvements in internal archive stores
|
||||
- Ability to use SQLite3 storage using LuaSQLite3 instead of LuaDBI
|
||||
- SQLCipher support
|
||||
|
||||
### Module API
|
||||
|
||||
|
|
|
@ -84,6 +84,12 @@ function engine:connect()
|
|||
dbh:autocommit(false); -- don't commit automatically
|
||||
self.conn = dbh;
|
||||
self.prepared = {};
|
||||
if params.password then
|
||||
local ok, err = self:execute(("PRAGMA key='%s'"):format(dbh:quote(params.password)));
|
||||
if not ok then
|
||||
return ok, err;
|
||||
end
|
||||
end
|
||||
local ok, err = self:set_encoding();
|
||||
if not ok then
|
||||
return ok, err;
|
||||
|
|
|
@ -114,6 +114,12 @@ function engine:connect()
|
|||
if not dbh then return nil, err; end
|
||||
self.conn = dbh;
|
||||
self.prepared = {};
|
||||
if params.password then
|
||||
local ok, err = self:execute(("PRAGMA key='%s'"):format((params.password:gsub("'", "''"))));
|
||||
if not ok then
|
||||
return ok, err;
|
||||
end
|
||||
end
|
||||
local ok, err = self:set_encoding();
|
||||
if not ok then
|
||||
return ok, err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue