BEGIN EXCLUSIVE TRANSACTION;
-PRAGMA user_version = 7;
+PRAGMA user_version = 8;
CREATE TABLE IF NOT EXISTS pkg (
pkg_id INTEGER PRIMARY KEY,
name VARCHAR NOT NULL,
author_id INTEGER,
shared_ro INTEGER NOT NULL DEFAULT 0,
+is_hybrid INTEGER NOT NULL DEFAULT 0,
UNIQUE (name)
FOREIGN KEY (author_id) REFERENCES author (author_id)
);
app.version as version,
pkg.author_id,
pkg.name as pkg_name,
- author.name as author_name
+ author.name as author_name,
+ pkg.is_hybrid
FROM user_app
LEFT JOIN app USING (app_id)
LEFT JOIN pkg USING (pkg_id)
AND NEW.author_name IS NOT NULL
AND author_name!=NEW.author_name);
+ SELECT RAISE(ABORT, 'Hybrid flag set differently for existing package')
+ WHERE EXISTS (SELECT 1 FROM user_app_pkg_view
+ WHERE is_hybrid!=NEW.is_hybrid
+ AND pkg_name=NEW.pkg_name);
+
INSERT OR IGNORE INTO author(name) VALUES (NEW.author_name);
- INSERT OR IGNORE INTO pkg(name, author_id) VALUES (
+ INSERT OR IGNORE INTO pkg(name, author_id, is_hybrid) VALUES (
NEW.pkg_name,
- (SELECT author_id FROM author WHERE name=NEW.author_name));
+ (SELECT author_id FROM author WHERE name=NEW.author_name),
+ NEW.is_hybrid);
-- If pkg have already existed with empty author do update it
UPDATE pkg SET author_id=(SELECT author_id FROM author WHERE name=NEW.author_name)
--- /dev/null
+BEGIN EXCLUSIVE TRANSACTION;
+
+PRAGMA user_version = 8;
+
+ALTER TABLE pkg ADD is_hybrid INTEGER NOT NULL DEFAULT 0;
+
+COMMIT TRANSACTION;
}
SECURITY_MANAGER_API
+int security_manager_app_inst_req_set_hybrid(app_inst_req *p_req)
+{
+ if (!p_req)
+ return SECURITY_MANAGER_ERROR_INPUT_PARAM;
+
+ p_req->isHybrid = true;
+
+ return SECURITY_MANAGER_SUCCESS;
+}
+
+SECURITY_MANAGER_API
int security_manager_app_install(const app_inst_req *p_req)
{
using namespace SecurityManager;
p_req->uid,
p_req->tizenVersion,
p_req->authorName,
- p_req->installationType);
+ p_req->installationType,
+ p_req->isHybrid);
//send buffer to server
retval = sendToServer(SERVICE_SOCKET, send.Pop(), recv);
SecurityManager::DB::SqlConnection *mSqlConnection;
const std::map<StmtType, const char * const > Queries = {
- { StmtType::EAddApplication, "INSERT INTO user_app_pkg_view (app_name, pkg_name, uid, version, author_name) VALUES (?, ?, ?, ?, ?)" },
+ { StmtType::EAddApplication, "INSERT INTO user_app_pkg_view (app_name, pkg_name, uid, version, author_name, is_hybrid)"
+ " VALUES (?, ?, ?, ?, ?, ?)" },
{ StmtType::ERemoveApplication, "DELETE FROM user_app_pkg_view WHERE app_name=? AND uid=?" },
{ StmtType::EPkgNameExists, "SELECT count(*) FROM pkg WHERE name=?" },
{ StmtType::EAppNameExists, "SELECT count(*) FROM app WHERE name=?" },
* @param uid - user identifier for whom application is going to be installed
* @param targetTizenVer - target tizen version for application
* @param author - author identifier
+ * @param isHybrid - hybrid flag setting
* @exception DB::SqlConnection::Exception::InternalError on internal error
* @exception DB::SqlConnection::Exception::ConstraintError on constraint violation
*/
const std::string &pkgName,
uid_t uid,
const std::string &targetTizenVer,
- const std::string &authorId);
+ const std::string &authorId,
+ bool isHybrid);
/**
* Remove an application from the database
std::string tizenVersion;
std::string authorName;
int installationType = SM_APP_INSTALL_NONE;
+ bool isHybrid = false;
};
struct user_req {
const std::string &pkgName,
uid_t uid,
const std::string &targetTizenVer,
- const std::string &authorName)
+ const std::string &authorName,
+ bool isHybrid)
{
try_catch<void>([&] {
auto command = getStatement(StmtType::EAddApplication);
command->BindInteger(3, static_cast<unsigned int>(uid));
command->BindString(4, targetTizenVer);
authorName.empty() ? command->BindNull(5) : command->BindString(5, authorName);
+ command->BindInteger(6, isHybrid ? 1 : 0);
if (command->Step()) {
LogDebug("Unexpected SQLITE_ROW answer to query: " <<
- Queries.at(StmtType::EAddApplication));
+ Queries.at(StmtType::EAddApplication));
};
LogDebug("Added appName: " << appName << ", pkgName: " << pkgName);
PrivilegeDb::getInstance().BeginTransaction();
- PrivilegeDb::getInstance().AddApplication(req.appName, req.pkgName, req.uid, req.tizenVersion, req.authorName);
+ PrivilegeDb::getInstance().AddApplication(req.appName, req.pkgName, req.uid,
+ req.tizenVersion, req.authorName, req.isHybrid);
/* Get all application ids in the package to generate rules withing the package */
PrivilegeDb::getInstance().GetPkgApps(req.pkgName, pkgContents);
PrivilegeDb::getInstance().GetPkgAuthorId(req.pkgName, authorId);
int security_manager_app_inst_req_set_install_type(app_inst_req *p_req, const enum app_install_type type);
/**
+ * This function is used to flag package as hybrid. This must be done consequently for every
+ * application installed in package - if first application installed sets this flag, others also
+ * must set it, otherwise installation will fail, the same applies to non-hybrid packages -
+ * if first application doesn't set this flag, then no other application for this package can set
+ * it, otherwise its installation will fail.
+ *
+ * \param[in] p_req Pointer handling app_inst_req structure
+ * \return API return code or error code
+ *
+ */
+int security_manager_app_inst_req_set_hybrid(app_inst_req *p_req);
+
+/**
* This function is used to install application based on
* using filled up app_inst_req data structure
*
Deserialization::Deserialize(buffer, req.tizenVersion);
Deserialization::Deserialize(buffer, req.authorName);
Deserialization::Deserialize(buffer, req.installationType);
+ Deserialization::Deserialize(buffer, req.isHybrid);
Serialization::Serialize(send, serviceImpl.appInstall(creds, std::move(req)));
}