Before this commit installation type was based on UID.
With this commit it is possible to set type of installation (global, local,
preloaded) during app installation request. If type is not specified,
and installation is performed by global user, default 'SM_APP_INSTALL_GLOBAL'
type of installation is set. Otherwise installation type is set to
'SM_APP_INSTALL_LOCAL'.
New API function avaliable:
* int security_manager_app_inst_req_set_install_type(app_inst_req *p_req,
const enum app_install_type type)
Change-Id: I745da8fc7a7393c360ed6d281a1f729d22bb89e6
}
(*pp_req)->uid = geteuid();
+ uid_t globalUid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+ if ((*pp_req)->uid == 0 || (*pp_req)->uid == globalUid)
+ (*pp_req)->installationType = static_cast<int>(SM_APP_INSTALL_GLOBAL);
+ else
+ (*pp_req)->installationType = static_cast<int>(SM_APP_INSTALL_LOCAL);
+
return SECURITY_MANAGER_SUCCESS;
}
}
SECURITY_MANAGER_API
+int security_manager_app_inst_req_set_install_type(app_inst_req *p_req, const enum app_install_type type)
+{
+ if (!p_req || (type <= SM_APP_INSTALL_NONE) || (type >= SM_APP_INSTALL_END))
+ return SECURITY_MANAGER_ERROR_INPUT_PARAM;
+
+ p_req->installationType = static_cast<int>(type);
+
+ return SECURITY_MANAGER_SUCCESS;
+}
+
+SECURITY_MANAGER_API
int security_manager_app_install(const app_inst_req *p_req)
{
using namespace SecurityManager;
p_req->appPaths,
p_req->uid,
p_req->tizenVersion,
- p_req->authorName);
+ p_req->authorName,
+ p_req->installationType);
//send buffer to server
retval = sendToServer(SERVICE_SOCKET, send.Pop(), recv);
{"normal", SM_USER_TYPE_NORMAL}
};
+static std::map <std::string, enum app_install_type> install_type_map = {
+ {"local", SM_APP_INSTALL_LOCAL},
+ {"global", SM_APP_INSTALL_GLOBAL},
+ {"preloaded", SM_APP_INSTALL_PRELOADED}
+};
+
static po::options_description getGenericOptions()
{
po::options_description opts("Generic options");
"user identifier number (required)")
("author-id,c", po::value<std::string>(),
"unique author's identifier (required for trusted_rw paths)")
+ ("install-type", po::value<std::string>(),
+ "type of installation (local, global, preloaded")
;
return opts;
}
}
if (vm.count("uid"))
req.uid = vm["uid"].as<uid_t>();
- if (vm.count("author-id")) {
+ if (vm.count("author-id"))
req.authorName = vm["author-id"].as<std::string>();
- }
+ if (vm.count("install-type"))
+ req.installationType = install_type_map.at(vm["install-type"].as<std::string>());
}
uid_t uid;
std::string tizenVersion;
std::string authorName;
+ int installationType;
};
struct user_req {
static bool isSubDir(const char *parent, const char *subdir);
- static bool getUserAppDir(const uid_t &uid, std::string &userAppDir);
+ static bool getUserAppDir(const uid_t &uid, const app_install_type &installType, std::string &userAppDir);
static bool installRequestAuthCheck(const app_inst_req &req, uid_t uid, std::string &appPath);
return (*subdir == '/' || *parent == *subdir);
}
-bool ServiceImpl::getUserAppDir(const uid_t &uid, std::string &userAppDir)
+bool ServiceImpl::getUserAppDir(const uid_t &uid, const app_install_type &installType, std::string &userAppDir)
{
struct tzplatform_context *tz_ctx = nullptr;
if (tzplatform_context_set_user(tz_ctxPtr.get(), uid))
return false;
- enum tzplatform_variable id =
- (uid == getGlobalUserId()) ? TZ_SYS_RW_APP : TZ_USER_APP;
+ enum tzplatform_variable id;
+
+ if (installType == SM_APP_INSTALL_LOCAL)
+ id = TZ_USER_APP;
+ else if (installType == SM_APP_INSTALL_GLOBAL)
+ id = TZ_SYS_RW_APP;
+ else
+ id = TZ_SYS_RO_APP;
+
const char *appDir = tzplatform_context_getenv(tz_ctxPtr.get(), id);
if (!appDir)
return false;
std::string userAppDir;
std::stringstream correctPath;
- if (uid != getGlobalUserId())
- LogDebug("Installation type: single user");
+ if (static_cast<app_install_type>(req.installationType) == SM_APP_INSTALL_LOCAL)
+ LogDebug("Installation type: local");
+ else if (static_cast<app_install_type>(req.installationType) == SM_APP_INSTALL_GLOBAL)
+ LogDebug("Installation type: global");
else
- LogDebug("Installation type: global installation");
+ LogDebug("Installation type: preloaded");
- if (!getUserAppDir(uid, userAppDir)) {
+ if (!getUserAppDir(uid, static_cast<app_install_type>(req.installationType), userAppDir)) {
LogError("Failed getting app dir for user uid: " << uid);
return false;
}
int security_manager_app_inst_req_set_author_id(app_inst_req *p_req, const char *author_id);
/*
+ * This function is used to set up installation type (global, local, preloaded).
+ * If type is not set and if installation is performed by global user, type is set to
+ * 'SM_APP_INSTALL_GLOBAL'. Otherwise installation type is set to 'SM_APP_INSTALL_LOCAL'.
+ *
+ * \param[in] Pointer handling app_inst_req structure
+ * \param[in] Installation type
+ * \return API return code or error code
+ *
+ */
+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 install application based on
* using filled up app_inst_req data structure
*
SECURITY_MANAGER_ENUM_END
};
+enum app_install_type : int {
+ SM_APP_INSTALL_NONE = 0,
+ SM_APP_INSTALL_LOCAL,
+ SM_APP_INSTALL_GLOBAL,
+ SM_APP_INSTALL_PRELOADED,
+ SM_APP_INSTALL_END
+};
+typedef enum app_install_type app_install_type;
+
/**
* This enum has values equivalent to gumd user type.
* The gum-utils help states that
Deserialization::Deserialize(buffer, req.uid);
Deserialization::Deserialize(buffer, req.tizenVersion);
Deserialization::Deserialize(buffer, req.authorName);
+ Deserialization::Deserialize(buffer, req.installationType);
Serialization::Serialize(send, serviceImpl.appInstall(req, uid));
}