#include <tests_common.h>
-AccessProvider::AccessProvider(const std::string &mySubject)
- : m_mySubject(mySubject), m_inSwitchContext(false)
+namespace {
+
+std::string toSmackLabel(const std::string &ownerId) {
+ if (ownerId.empty())
+ return ownerId;
+
+ if (ownerId[0] == '/') {
+ return ownerId.substr(1, std::string::npos);
+ }
+
+ return "User::App::" + ownerId;
+}
+
+} // anonymous namespace
+
+AccessProvider::AccessProvider(const std::string &ownerId)
+ : m_mySubject(toSmackLabel(ownerId))
+ , m_inSwitchContext(false)
{
RUNNER_ASSERT_MSG(m_mySubject.size() > 0, "No smack label provided to AccessProvider!");
allowJournaldLogs();
}
-AccessProvider::AccessProvider(const std::string &mySubject, int uid, int gid)
- : m_mySubject(mySubject), m_inSwitchContext(false)
+AccessProvider::AccessProvider(const std::string &ownerId, int uid, int gid)
+ : m_mySubject(toSmackLabel(ownerId))
+ , m_inSwitchContext(false)
{
RUNNER_ASSERT_MSG(m_mySubject.size() > 0, "No smack label provided to AccessProvider!");
allowJournaldLogs();
class AccessProvider {
public:
- explicit AccessProvider(const std::string &mySubject);
- AccessProvider(const std::string &mySubject, int uid, int gid);
+ explicit AccessProvider(const std::string &ownerId);
+ AccessProvider(const std::string &ownerId, int uid, int gid);
virtual ~AccessProvider() {}
AccessProvider(const AccessProvider &second) = delete;