cp %{SOURCE1001} .
%build
+%if %{profile} == "tv"
+ ADMIN_USER_GLOBAL_INSTALLATION_ONLY=OFF
+%else
+ ADMIN_USER_GLOBAL_INSTALLATION_ONLY=ON
+%endif
%cmake . -DCMAKE_BUILD_TYPE=%{?build_type:%build_type} \
-DTIZEN_FULL_VERSION=%{tizen_full_version} \
- -DUNITDIR=%{_unitdir}
+ -DUNITDIR=%{_unitdir} \
+ -DADMIN_USER_GLOBAL_INSTALLATION_ONLY:BOOL=${ADMIN_USER_GLOBAL_INSTALLATION_ONLY}
make %{?_smp_mflags}
%install
const char kStrEmpty[] = "";
const char kAppFWUser[] = "app_fw";
+const uid_t kGlobalUserUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
StepConfigure::StepConfigure(InstallerContext* context, PkgMgrPtr pkgmgr)
: Step(context),
return Status::ERROR;
}
- context_->uid.set(pkgmgr_->GetUid());
+ uid_t uid = pkgmgr_->GetUid();
+ context_->uid.set(uid);
if (getuid() == 0)
return Status::OK;
return Status::OPERATION_NOT_ALLOWED;
}
+#ifdef ADMIN_USER_GLOBAL_INSTALLATION_ONLY
+ // Set target uid as tizenglobalapp if admin user's request
+ if (IsAdminUser(uid))
+ context_->uid.set(kGlobalUserUid);
+#endif
+
return Status::OK;
}
return list;
}
+bool IsAdminUser(uid_t uid) {
+ GumUser* guser;
+ int count = 0;
+ do {
+ guser = gum_user_get_sync(uid, (getuid() == 0) ? TRUE : FALSE);
+ if (guser)
+ break;
+ count++;
+ LOG(WARNING) << "Failed to get gum user! ("
+ << count << "/" << kRetryMax << ")";
+ usleep(kRetryDelay);
+ } while (count < kRetryMax);
+ if (!guser)
+ return false;
+ GumUserType ut;
+ g_object_get(G_OBJECT(guser), "usertype", &ut, NULL);
+ bool is_admin;
+ if (ut == GUM_USERTYPE_ADMIN)
+ is_admin = true;
+ else
+ is_admin = false;
+ g_object_unref(guser);
+ return is_admin;
+}
+
boost::optional<gid_t> GetGidByGroupName(const char* groupname) {
boost::optional<gid_t> result;
char buf[kGRBufSize];
typedef std::vector<std::tuple<uid_t, gid_t, bf::path>> UserList;
UserList GetUserList();
+bool IsAdminUser(uid_t uid);
boost::optional<gid_t> GetGidByUid(uid_t uid);
std::string GetGroupNameByGid(gid_t gid);
std::string GetUsernameByUid(uid_t user);