diff options
author | Rafal Krypa <r.krypa@samsung.com> | 2017-10-13 18:46:50 +0200 |
---|---|---|
committer | Gerrit Code Review <gerrit@review.ap-northeast-2.compute.internal> | 2017-10-25 13:21:32 +0000 |
commit | 9eca3bf51e42310b13afe5fc1a9f30cc8ae6f87c (patch) | |
tree | 0d44e18f3dc86a250bfd5030d54f662ae6c14cfd /src | |
parent | 250820e48a1de515fd32c62286a381b2aafbc3f7 (diff) | |
download | security-manager-9eca3bf51e42310b13afe5fc1a9f30cc8ae6f87c.tar.gz security-manager-9eca3bf51e42310b13afe5fc1a9f30cc8ae6f87c.tar.bz2 security-manager-9eca3bf51e42310b13afe5fc1a9f30cc8ae6f87c.zip |
When preparation of database connection fails, indicate this with a file fleg
A special file flag will be created by security-manager if it fails to
open its database or fails to initialize prepared statements.
This would indicate that database is either missing or broken. In such case
an empty file will be created at TZ_SYS_DB/.security-manager.db-broken
Change-Id: I6461b71134d6ce706d4295851a45840b3cf0be39
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/common/privilege_db.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/common/privilege_db.cpp b/src/common/privilege_db.cpp index 285b8b23..692d2e82 100644 --- a/src/common/privilege_db.cpp +++ b/src/common/privilege_db.cpp @@ -36,6 +36,7 @@ #include <dpl/log/log.h> #include "privilege_db.h" #include "tzplatform-config.h" +#include "filesystem.h" namespace SecurityManager { @@ -66,6 +67,12 @@ std::string getPrivilegeDbPath() return path; } +std::string getPrivilegeDbFailFlagPath() +{ + static std::string path = TizenPlatformConfig::makePath(TZ_SYS_DB, ".security-manager.db-broken"); + return path; +} + PrivilegeDb::PrivilegeDb() : PrivilegeDb(getPrivilegeDbPath()) { } @@ -79,9 +86,9 @@ PrivilegeDb::PrivilegeDb(const std::string &path) initDataCommands(); } catch (DB::SqlConnection::Exception::Base &e) { LogError("Database initialization error: " << e.DumpToString()); + FS::createFile(getPrivilegeDbFailFlagPath()); ThrowMsg(PrivilegeDb::Exception::IOError, "Database initialization error:" << e.DumpToString()); - }; } |