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

Method validateConf

src/Daemon/LDAPHandler.cpp:236–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234 }
235
236 void LDAPHandler::validateConf()
237 {
238 USBGUARD_LOG(Debug) << "Validating LDAP conf";
239 // required
240 std::vector<std::string> v = {"URI", "BASE", "ROOTDN", "ROOTPW"};
241
242 for (auto s: v) {
243 if (_parsedOptions[s] == "") {
244 USBGUARD_LOG(Debug) << "Option " << s << " is missing!";
245 throw Exception("LDAP conf validation", "validateConf", "Too few options");
246 }
247 }
248
249 if (_parsedOptions["USBGUARDBASE"] == "") {
250 _parsedOptions["USBGUARDBASE"] = "ou=USBGuard," + _parsedOptions["BASE"];
251 USBGUARD_LOG(Debug) << "Option " << "USBGUARDBASE" << " is missing!";
252 USBGUARD_LOG(Debug) << _parsedOptions["USBGUARDBASE"];
253 USBGUARD_LOG(Debug) << "Using defult: " << _parsedOptions["USBGUARDBASE"];
254 }
255
256 if (_parsedOptions["RULEQUERY"] == "") {
257 _parsedOptions["RULEQUERY"] = "(&" "(cn=Rule*)" /*TODO add option for setting cn prefix*/
258 /* */"(|" "(&" "(USBGuardHost=" + _hostname + ")"
259 /* */"(!" "(USBGuardHost=!" + _hostname + "))"
260 /* */")"
261 /* */"(&" "(USBGuardHost=\\*)"
262 /* */"(!" "(USBGuardHost=!" + _hostname + "))"
263 /* */")"
264 /* */")"
265 /* */")";
266 USBGUARD_LOG(Debug) << "Option " << "RULEQUERY" << " is missing!";
267 USBGUARD_LOG(Debug) << "Using default: " << _parsedOptions["RULEQUERY"];
268 }
269
270 if (_parsedOptions["UPDATEINTERVAL"] != "") {
271 size_t index = 0;
272 _updateInterval = std::stol(_parsedOptions["UPDATEINTERVAL"], &index) * 60 * 60 * 1000;
273
274 if (_parsedOptions["UPDATEINTERVAL"][index] != 0) {
275 throw Exception("validateConf", "stol", "cannot convert UPDATEINTERVAL to number: " + _parsedOptions["UPDATEINTERVAL"]);
276 }
277 }
278
279 USBGUARD_LOG(Debug) << "Map after validation:";
280
281 for (auto x: _parsedOptions) {
282 USBGUARD_LOG(Debug) << "--> " << x.first << " -> " << x.second << " <--";
283 }
284 }
285}
286
287#endif

Callers

nothing calls this directly

Calls 1

ExceptionFunction · 0.85

Tested by

no test coverage detected