void AbstractRequestHandler::PostExec() {
}
+void AbstractRequestHandler::SetUID(uid_t uid) {
+ uid_ = uid;
+}
+
+uid_t AbstractRequestHandler::GetUID() {
+ return uid_;
+}
+
} // namespace request_handler
} // namespace pkgmgr_server
bool CreateCacheRequestHandler::HandleRequest(unsigned char* data, int size,
const std::string& locale) {
- // TODO(ilho159.kim) need to get logined user id
- psd::CacheDBHandler db(5001, GetPID());
+ psd::CacheDBHandler db(GetUID(), GetPID());
db.SetLocale(locale);
int ret = db.Execute();
#include "worker_thread.hh"
#include <sqlite3.h>
+#include <sys/types.h>
#include <malloc.h>
+#include <tzplatform_config.h>
+
#include "abstract_parcelable.hh"
#include "request_handler_factory.hh"
#include "server/database/db_handle_provider.hh"
#define SQLITE_ENABLE_MEMORY_MANAGEMENT
#endif
+namespace {
+
+uid_t globaluser_uid = -1;
+
+uid_t GetGlobalUID() {
+ if (globaluser_uid == (uid_t)-1)
+ globaluser_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+
+ return globaluser_uid;
+}
+
+uid_t ConvertUID(uid_t uid) {
+ if (uid < REGULAR_USER)
+ return GetGlobalUID();
+ else
+ return uid;
+}
+
+} // namespace
+
namespace pkgmgr_server {
WorkerThread::WorkerThread(unsigned int num) : stop_all_(false) {
try {
handler->PreExec();
-
+ handler->SetUID(ConvertUID(req->GetSenderUID()));
handler->SetPID(req->GetSenderPID());
if (!handler->HandleRequest(req->GetData(), req->GetSize(),
locale_.GetObject()))