}
}
+RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_INTERNET)
+
+namespace
+{
+ [[nodiscard]] int ping() {
+ FILE *in;
+ RUNNER_ASSERT(in = popen("curl -o /dev/null example.com", "r"));
+ return pclose(in);
+ };
+}
+
+RUNNER_CHILD_TEST(security_manager_12a_internet_access_positive)
+{
+ TemporaryTestUser testUser("sm_test_12a_internet_access", GUM_USERTYPE_NORMAL);
+ testUser.create();
+ AppInstallHelperExt app("sm_test_12a", "sm_test_12a", testUser.getUid());
+ app.addPrivilege(PRIV_INTERNET);
+ ScopedInstaller appInstall(app);
+
+ pid_t pid = fork();
+ RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed");
+ if (pid != 0) {
+ // wait for child to exit before uninstallation
+ waitPid(pid);
+ Api::cleanupApp(app.getAppId(), testUser.getUid(), pid);
+ } else {
+ // child - the actual application
+ RUNNER_ASSERT_MSG(setLauncherSecurityAttributes(testUser) == 0, "launcher failed");
+ Api::prepareAppCandidate();
+ Api::prepareApp(app.getAppId());
+
+ RUNNER_ASSERT_MSG(ping() == 0, "No internet access while the privilege is present");
+ }
+}
+
+RUNNER_CHILD_TEST(security_manager_12b_internet_access_negative)
+{
+ TemporaryTestUser testUser("sm_test_12b_internet_access", GUM_USERTYPE_NORMAL);
+ testUser.create();
+ AppInstallHelperExt app("sm_test_12b", "sm_test_12b", testUser.getUid());
+ ScopedInstaller appInstall(app);
+
+ pid_t pid = fork();
+ RUNNER_ASSERT_ERRNO_MSG(pid >= 0, "Fork failed");
+ if (pid != 0) {
+ // wait for child to exit before uninstallation
+ waitPid(pid);
+ Api::cleanupApp(app.getAppId(), testUser.getUid(), pid);
+ } else {
+ // child - the actual application
+ RUNNER_ASSERT_MSG(setLauncherSecurityAttributes(testUser) == 0, "launcher failed");
+ Api::prepareAppCandidate();
+ Api::prepareApp(app.getAppId());
+
+ RUNNER_ASSERT_MSG(ping() != 0, "Internet access detected despite no privilege");
+ }
+}
+
RUNNER_TEST_GROUP_INIT(SECURITY_MANAGER_POLICY)
RUNNER_TEST(security_manager_20_user_cynara_policy)