MCPcopy Create free account
hub / github.com/OpenVPN/openvpn3-linux / method_attach

Method method_attach

src/log/log-service.cpp:358–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

356
357
358void ServiceHandler::method_attach(DBus::Object::Method::Arguments::Ptr args)
359{
360 cleanup_service_subscriptions();
361
362 LogMetaData::Ptr meta = internal::prepare_metadata(this, "Attach", args);
363 pid_t caller_pid = -1;
364 try
365 {
366 caller_pid = dbuscreds->GetPID(args->GetCallerBusName());
367 }
368 catch (const DBus::Credentials::Exception &excp)
369 {
370 log->LogCritical("Attach error: " + std::string(excp.what()), meta);
371 throw MethodError("Could not authenticate caller");
372 }
373
374 GVariant *params = args->GetMethodParameters();
375 auto interface = filter_ctrl_chars(
376 glib2::Value::Extract<std::string>(params, 0),
377 true);
378 auto tag = LogTag::Create(args->GetCallerBusName(), interface);
379
380 if (log_attach_subscr.find(tag->hash) != log_attach_subscr.end())
381 {
382 std::ostringstream msg;
383 msg << "Duplicated attach request: " << *tag
384 << ", pid: " << std::to_string(caller_pid);
385 log->LogWarn(msg.str());
386 throw MethodError("Already attached");
387 }
388
389 std::lock_guard<std::mutex> guard(attachmap_mtx);
390 log_attach_subscr[tag->hash] = AttachedService::Create(connection,
391 object_mgr,
392 log,
393 subscrmgr,
394 tag,
395 args->GetCallerBusName(),
396 interface);
397 std::ostringstream msg;
398 msg << "Attached: " << *tag << " " << tag->tag
399 << ", pid " << std::to_string(caller_pid);
400 log->LogVerb2(msg.str(), meta);
401 args->SetMethodReturn(nullptr);
402
403 // Since a service is now attached, the idle detector needs to consider
404 // this object's presence when checking if the service is idle or not.
405 // Normally this is not needed, since the service creates child objects.
406 // This does not happen in this case. The call below reverses the
407 // idle detector setting done in the contructor.
408 DisableIdleDetector(false);
409}
410
411
412void ServiceHandler::method_assign_session(DBus::Object::Method::Arguments::Ptr args)

Callers

nothing calls this directly

Calls 8

prepare_metadataFunction · 0.85
MethodErrorClass · 0.85
filter_ctrl_charsFunction · 0.85
LogCriticalMethod · 0.45
whatMethod · 0.45
LogWarnMethod · 0.45
strMethod · 0.45
LogVerb2Method · 0.45

Tested by

no test coverage detected