EPkgIdExists,
EGetPkgId,
EGetPrivilegeGroups,
+ EGetUserApps,
};
class PrivilegeDb {
{ QueryType::EPkgIdExists, "SELECT * FROM pkg WHERE name=?" },
{ QueryType::EGetPkgId, " SELECT pkg_name FROM app_pkg_view WHERE app_name = ?" },
{ QueryType::EGetPrivilegeGroups, " SELECT name FROM privilege_group_view WHERE privilege_name = ?" },
+ { QueryType::EGetUserApps, "SELECT name FROM app WHERE uid=?" },
};
/**
+ * Container for initialized DataCommands, prepared for binding.
+ */
+ std::vector<DB::SqlConnection::DataCommandAutoPtr> m_commands;
+
+ /**
+ * Fills empty m_commands map with sql commands prepared for binding.
+ *
+ * Because the "sqlite3_prepare_v2" function takes many cpu cycles, the PrivilegeDb
+ * is optimized to call it only once for one query type.
+ * Designed to be used in the singleton contructor.
+ */
+ void initDataCommands();
+
+ /**
* Check if pkgId is already registered in database
*
* @param pkgId - package identifier
void GetPrivilegeGroups(const std::string &privilege,
std::vector<std::string> &grp_names);
+ /**
+ * Retrieve list of apps assigned to user
+ *
+ * @param uid - user identifier
+ * @param[out] apps - list of apps assigned to user,
+ * this parameter do not need to be empty, but
+ * it is being overwritten during function call.
+ * @exception DB::SqlConnection::Exception::InternalError on internal error
+ */
+ void GetUserApps(uid_t uid, std::vector<std::string> &apps);
};
} //namespace SecurityManager