#include <algorithm>
#include <cstring>
+#include <fcntl.h>
#include <ftw.h>
#include <grp.h>
#include <string>
runAccessTest(label, uid, gid, testPath, accessType);
}
+bool isAskuserDisabled() {
+ static bool isAskuserDisabled = false;
+ static bool isChecked = false;
+
+ if (isChecked)
+ return isAskuserDisabled;
+
+ std::string sysShare = TzPlatformConfig::getPath(TZ_SYS_SHARE);
+ std::string askDisableFile = sysShare + "/askuser_disable";
+
+ isAskuserDisabled = (access(askDisableFile.c_str(), F_OK) != -1);
+ isChecked = true;
+ return isAskuserDisabled;
+}
+
bool isPrivilegePrivacy(const std::string &priv) {
return (1 == privilege_info_is_privacy(priv.c_str()));
}
void runAccessTest(const AppInstallHelper &app, const std::string &testPath, int accessType);
void runSystemAccessTest(uid_t uid, gid_t gid, const std::string &testPath, int accessType);
+bool isAskuserDisabled();
bool isPrivilegePrivacy(const std::string &priv);
int countPrivacyPrivileges(const PrivilegeVector &privs);
int countPrivacyPrivileges(const std::vector<std::string> &privs);
#include <pwd.h>
#include <sys/types.h>
-#include <tzplatform_config.h>
#include <dpl/test/test_runner.h>
#include <memory.h>
return appDir;
}
+const std::string getPath(enum tzplatform_variable id) {
+ struct tzplatform_context *tzCtxPtr = nullptr;
+
+ RUNNER_ASSERT_MSG(0 == tzplatform_context_create(&tzCtxPtr), "Couldn't create tzplatform context");
+ TzPlatformContextPtr tzCtxPtrSmart(tzCtxPtr);
+
+ const char *path = tzplatform_context_getenv(tzCtxPtr, id);
+ RUNNER_ASSERT_MSG(nullptr != path,
+ "tzplatform_context_getenv failed for getting " << static_cast<int>(id));
+ return path;
+}
+
}
#include <string>
+#include <tzplatform_config.h>
+
#include <temp_test_user.h>
namespace TzPlatformConfig {
+const std::string getPath(enum tzplatform_variable id);
+
uid_t getGlobalUserId(void);
uid_t getGlobalGroupId(void);
unsigned expectedPolicyCount = countPrivacyPrivileges(app.getPrivileges());
- RUNNER_ASSERT_MSG(expectedPolicyCount > 0, "Application won't be installed with any privacy privileges, fix test");
+ // If askuser is disabled there will be no privacy policy to expect
+ RUNNER_ASSERT_MSG(isAskuserDisabled() || expectedPolicyCount > 0,
+ "Application won't be installed with any privacy privileges, fix test");
ScopedInstaller appInstall(app);
std::vector<PolicyEntry> policyEntries;
Api::getPolicyForSelf(filter, policyEntries);
+ if (isAskuserDisabled()) {
+ //further checks do not make sense, but we've checked if app has permission to perform policy fetch
+ continue;
+ }
RUNNER_ASSERT_MSG(policyEntries.size() != 0, "Policy is empty");
RUNNER_ASSERT_MSG(policyEntries.size() == 1,