#include <aul_cmd.h>
#include <aul_svc.h>
#include <aul_sock.h>
+#include <aul_proc.h>
#include <aul_svc_priv_key.h>
#include <bundle_internal.h>
#include <pkgmgr-info.h>
constexpr const char PRIVILEGE_APPDEBUGGING[] =
"http://tizen.org/privilege/internal/appdebugging";
constexpr const unsigned int PENDING_REQUEST_TIMEOUT = 30000; // msec
+constexpr const char kPathSrpAppLauncher[] = "/usr/bin/srp-app-launcher";
class CheckerInfo {
public:
},
};
+static bool IsSrpAppLauncher(pid_t pid, uid_t uid) {
+ if (uid >= REGULAR_UID_MIN) return false;
+
+ char buf[PATH_MAX];
+ int ret = aul_proc_get_cmdline(pid, buf, sizeof(buf));
+ if (ret != AUL_R_OK) {
+ _E("aul_proc_get_cmdline() is failed. pid=%d", pid);
+ return false;
+ }
+
+ _D("cmdline=%s", buf);
+ return std::string(buf) == kPathSrpAppLauncher;
+}
+
+static bool IsRobotApp(const std::shared_ptr<tizen_base::Bundle>& b,
+ uid_t uid) {
+ auto appid = b->GetString(AUL_K_APPID);
+ if (appid.empty()) return false;
+
+ auto app_info = amd::AppInfoManager::GetInst().FindAppInfo(uid, appid);
+ if (app_info == nullptr) return false;
+
+ if (app_info->GetComponentType() == APP_TYPE_ROBOT) {
+ _W("The target application is a robot app");
+ return true;
+ }
+
+ _W("component_type: %s", app_info->GetComponentType().c_str());
+ return false;
+}
+
static int CynaraAppControlChecker(caller_info_h info, request_h request,
void* user_data) {
auto* req = static_cast<amd::Request*>(request);
if (b == nullptr)
return AMD_CYNARA_ALLOWED;
+ if (IsRobotApp(b, req->GetTargetUID())) {
+ if (!IsSrpAppLauncher(req->GetPID(), req->GetUID())) {
+ _E("Caller must be srp-app-launcher");
+ return AMD_CYNARA_DENIED;
+ }
+ }
+
int ret = CheckAppDebuggingPrivilege(request);
if (ret != AMD_CYNARA_CONTINUE)
return ret;