MCPcopy Create free account
hub / github.com/USBGuard/usbguard / loadConfiguration

Method loadConfiguration

src/Daemon/Daemon.cpp:187–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185 }
186
187 void Daemon::loadConfiguration(const std::string& path, const bool check_permissions)
188 {
189 USBGUARD_LOG(Info) << "Loading configuration from " << path;
190
191 if (check_permissions) {
192 checkFilePermissions(path, (S_IRUSR | S_IWUSR));
193 }
194
195 _config.open(path, /*readonly=*/true);
196 USBGUARD_LOG(Info) << "Loading NSSwitch...";
197 _nss.parseNSSwitch();
198
199 /* RuleFile */
200 if (_config.hasSettingValue("RuleFile")) {
201 const std::string& rulefile_path = _config.getSettingValue("RuleFile");
202
203 if (check_permissions) {
204 checkFilePermissions(rulefile_path, (S_IRUSR | S_IWUSR));
205 }
206
207 _nss.setRulesPath(rulefile_path);
208 }
209
210 /* RuleDir */
211 if (_config.hasSettingValue("RuleFolder")) {
212 std::string ruledir_path = _config.getSettingValue("RuleFolder");
213
214 /* Check proper ending in path and correct it if corrupted */
215 if (ruledir_path.back() != '/') {
216 ruledir_path.append("/");
217 }
218
219 ruledir_path = normalizePath(ruledir_path);
220
221 if (check_permissions) {
222 checkFolderPermissions(ruledir_path, (S_IRUSR | S_IWUSR));
223 }
224
225 _nss.setRulesDirPath(ruledir_path);
226 }
227
228 loadRules();
229
230 /* ImplicitPolicyTarget */
231 if (_config.hasSettingValue("ImplicitPolicyTarget")) {
232 const std::string& target_string = _config.getSettingValue("ImplicitPolicyTarget");
233 Rule::Target target = Rule::targetFromString(target_string);
234 setImplicitPolicyTarget(target);
235 }
236
237 /* PresentDevicePolicy */
238 if (_config.hasSettingValue("PresentDevicePolicy")) {
239 const std::string& policy_string = _config.getSettingValue("PresentDevicePolicy");
240 DevicePolicyMethod policy = Daemon::devicePolicyMethodFromString(policy_string);
241 setPresentDevicePolicyMethod(policy);
242 }
243
244 /* PresentControllerPolicy */

Callers 1

mainFunction · 0.80

Calls 14

normalizePathFunction · 0.85
tokenizeStringFunction · 0.85
ExceptionFunction · 0.85
parseNSSwitchMethod · 0.80
appendMethod · 0.80
setRulesDirPathMethod · 0.80
setBackendMethod · 0.80
setAuditFileMethod · 0.80
setHidePIIMethod · 0.80
openMethod · 0.45
hasSettingValueMethod · 0.45
setRulesPathMethod · 0.45

Tested by

no test coverage detected