/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2016-2020 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.
#define CONF_DIR "/usr/share/security-manager/policy/"
#define CONF_GROUP_FILE "privilege-group.list"
+#define CONF_SYSTEMD_PRIVS_FILE "privilege-managed-by-systemd-for-daemons.list"
#define CONF_USER_TEMPLATE_FILE "usertype-%s.profile"
namespace SecurityManagerTest {
return result;
}
+PolicyConfiguration::PrivVector PolicyConfiguration::getSystemdManagedPrivs()
+{
+ PolicyConfiguration::PrivVector result;
+ std::ifstream file(CONF_DIR CONF_SYSTEMD_PRIVS_FILE);
+ if (!file.is_open()) {
+ RUNNER_ASSERT_MSG(file.is_open(),
+ "Unable to read config file " << CONF_DIR CONF_SYSTEMD_PRIVS_FILE);
+ }
+ std::string line;
+ std::regex r("^(http(.*))");
+ while (std::getline(file, line)) {
+ std::smatch m;
+ if (std::regex_search(line, m, r))
+ result.emplace_back(m[1]);
+ }
+ return result;
+}
+
void PolicyConfiguration::loadPrivGroupMap(void) {
std::string pgPath(CONF_DIR CONF_GROUP_FILE);
std::ifstream file(pgPath);