static const std::string ROOT_UID_STR("0");
+static const std::string CONNECTION_NAME_PREFIX("com.security_tests");
+
static const std::string connectionNameFromStr(const std::string &str)
{
- return "com.security_tests." + str;
+ return CONNECTION_NAME_PREFIX + "." + str;
}
static const std::string privilegeFromStr(const std::string &str)
RUNNER_TEST_GROUP_INIT(CYNARA_DBUS);
-static void testOwn(const std::string &testId, bool allow)
+static void testOwn(const std::string &testId,
+ const std::function<void(const std::string &)> &addBusconfigPolicyFunc,
+ bool allow)
{
SmackAccess access;
const std::string label(smackLabelFromStr(testId));
- addBusconfigPolicyOwn(testId);
+ addBusconfigPolicyFunc(testId);
addSmackAccessForDbus(access, label);
if (allow)
addCynaraPolicy(testId);
RUNNER_MULTIPROCESS_TEST_SMACK(tcc_1130_own_deny)
{
- testOwn("tcc1130", false);
+ testOwn("tcc1130", addBusconfigPolicyOwn, false);
}
RUNNER_MULTIPROCESS_TEST_SMACK(tcc_1170_own_allow)
{
- testOwn("tcc1170", true);
+ testOwn("tcc1170", addBusconfigPolicyOwn, true);
+}
+
+static void addBusconfigPolicyOwnPrefix(const std::string &id)
+{
+ BusConfigWriter writer;
+ writer.addPolicyCheck(privilegeFromStr(id), {{Attr::OWN_PREFIX, CONNECTION_NAME_PREFIX}});
+ writer.save();
+}
+
+RUNNER_CHILD_TEST_SMACK(tcc_1230_own_prefix_deny)
+{
+ testOwn("tcc1230", addBusconfigPolicyOwnPrefix, false);
+}
+
+RUNNER_CHILD_TEST_SMACK(tcc_1270_own_prefix_allow)
+{
+ testOwn("tcc1270", addBusconfigPolicyOwnPrefix, true);
}