/*
- * Copyright (c) 2014-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2017 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
return m_privileges;
}
+void AppInstallHelper::addAppDefinedPrivilege(const std::string &privilege) {
+ m_appDefinedPrivileges.push_back(privilege);
+}
+
+std::vector<std::string> AppInstallHelper::getAppDefinedPrivileges() const {
+ return m_appDefinedPrivileges;
+}
+
void AppInstallHelper::revokeRules() const {
RUNNER_ASSERT_MSG(
0 == smack_revoke_subject(generateAppLabel().c_str()),
/*
- * Copyright (c) 2014-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2017 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void addPrivileges(const std::vector<std::string> &privileges);
std::vector<std::string> getPrivileges() const;
+ void addAppDefinedPrivilege(const std::string &privilege);
+ std::vector<std::string> getAppDefinedPrivileges() const;
+
// Smack
std::string generateAppLabel() const;
std::string generatePkgLabel() const;
TypePathsMap m_dirTypeMap;
TypePathsMap m_fileTypeMap;
std::vector<std::string> m_privileges;
+ std::vector<std::string> m_appDefinedPrivileges;
std::string m_author;
pid_t m_creatorPid;
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016-2017 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
for (const auto& typePaths : app.getFilesMap())
for (const auto& path : typePaths.second)
instReq.addPath(path, typePaths.first);
- for (const auto &priv : app.getPrivileges()) {
+ for (const auto &priv : app.getPrivileges())
instReq.addPrivilege(priv.c_str());
- }
+ for (const auto &priv : app.getAppDefinedPrivileges())
+ instReq.addAppDefinedPrivilege(priv);
+
SecurityManagerTest::Api::install(instReq);
}
/*
- * Copyright (c) 2014-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2017 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
m_privileges.push_back(privilege);
}
+void InstallRequest::addAppDefinedPrivilege(const std::string &privilege, lib_retcode expectedResult)
+{
+ int result = security_manager_app_inst_req_add_app_defined_privilege(m_req, privilege.c_str());
+ RUNNER_ASSERT_MSG((lib_retcode)result == expectedResult,
+ "adding app defined privilege returned wrong value."
+ << " Privilege: " << privilege << ";"
+ << " Result: " << result << ";"
+ << " Expected result: " << expectedResult);
+ m_appDefinedPrivileges.push_back(privilege);
+}
+
void InstallRequest::addPath(std::string path, app_install_path_type pathType, lib_retcode expectedResult)
{
int result = security_manager_app_inst_req_add_path(m_req, path.c_str(), pathType);
}
os << " ]";
}
+ if (!request.m_appDefinedPrivileges.empty()) {
+ os << "app defined privileges: [ " << request.m_appDefinedPrivileges[0];
+ for (size_t i = 1; i < request.m_appDefinedPrivileges.size(); ++i)
+ os << "; " << request.m_appDefinedPrivileges[i];
+ os << " ]";
+ }
+
if (!request.m_paths.empty()) {
os << "paths: [ " << "< " << request.m_paths[0].first << "; "
<< request.m_paths[0].second << " >";
/*
- * Copyright (c) 2014-2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2014-2017 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
void setAppId(std::string appId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
void setPkgId(std::string pkgId, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
void addPrivilege(const std::string &privilege, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
+ void addAppDefinedPrivilege(const std::string &privilege, lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
void addPath(std::string path, app_install_path_type pathType,
lib_retcode expectedResult = SECURITY_MANAGER_SUCCESS);
void setUid(const uid_t uid, lib_retcode expectedresult = SECURITY_MANAGER_SUCCESS);
std::string m_pkgId;
std::string m_authorId;
std::vector<std::string> m_privileges;
+ std::vector<std::string> m_appDefinedPrivileges;
std::vector<std::pair<std::string, app_install_path_type> > m_paths;
std::pair<bool, uid_t> m_uid;
};