feat(ulib): sqlite database file is created with mode 0600 by default

This commit is contained in:
DanyLE 2024-07-27 00:15:40 +02:00
parent 824769dee2
commit 0fcf2fc2ab
3 changed files with 497 additions and 439 deletions

View File

@ -1,5 +1,5 @@
# initialise autoconf and set up some basic information about the program were packaging # initialise autoconf and set up some basic information about the program were packaging
AC_INIT([silk], [0.2.0], [xsang.le@gmail.com]) AC_INIT([silk], [1.0.0], [xsang.le@gmail.com])
# Were going to use automake for this project # Were going to use automake for this project
# [subdir-objects] if needed # [subdir-objects] if needed

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
sqlite = require("sqlitedb") sqlite = require("sqlitedb")
ulib = require("ulib")
if sqlite == nil then if sqlite == nil then
return 0 return 0
end end
@ -8,7 +8,14 @@ require("silk.core.OOP")
sqlite.getdb = function(name) sqlite.getdb = function(name)
if name:find("%.db$") then if name:find("%.db$") then
return sqlite.db(name) local db = sqlite.db(name)
if db then
ret,err = ulib.chmod(name,"0600")
if not ret then
LOG_WARN("Unable to change mode of database file %s: %s", name, err)
end
end
return db
elseif name:find("/") then elseif name:find("/") then
LOG_ERROR("Invalid database name %s", name) LOG_ERROR("Invalid database name %s", name)
return nil return nil
@ -20,7 +27,15 @@ sqlite.getdb = function(name)
return nil return nil
end end
end end
return sqlite.db(__api__.dbpath .. "/" .. name .. ".db") local path = __api__.dbpath .. "/" .. name .. ".db"
local db = sqlite.db(path)
if db then
local ret,err = ulib.chmod(path,"0600")
if not ret then
LOG_WARN("Unable to change mode of database file %s: %s", path)
end
end
return db
end end
end end