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

Method Authorize

src/sessionmgr/sessionmgr-session.cpp:514–612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

512
513
514const bool Session::Authorize(DBus::Authz::Request::Ptr authzreq)
515{
516 // Early sanity check to see if the backend VPN process is accesible or not
517 if (be_prx && be_target)
518 {
519 // Check if the backend is still alive
520 try
521 {
522 GVariant *r = be_prx->Call(be_target, "Ping", nullptr);
523 glib2::Utils::checkParams(__func__, r, "(b)");
524 if (!glib2::Value::Extract<bool>(r, 0))
525 {
526 sig_session->LogCritical("Backend VPN did not respond correctly "
527 "- "
528 + GetPath());
529 close_session(true);
530 throw DBus::Object::Method::Exception("Backend VPN process did not respond");
531 }
532 g_variant_unref(r);
533 }
534 catch (const DBus::Proxy::Exception &excp)
535 {
536 sig_session->LogCritical("Backend VPN did not respond: "
537 + std::string(excp.GetRawError())
538 + " - " + GetPath());
539 close_session(true);
540 throw DBus::Object::Method::Exception("Backend VPN process did not respond");
541 }
542 }
543 else
544 {
545 // If there are no backends available, cleanup the session
546 close_session(true);
547 return false;
548 }
549
550 switch (authzreq->operation)
551 {
552 case DBus::Object::Operation::METHOD_CALL:
553 {
554 // These methods are always restricted to the owner only;
555 // we don't provide sharing user admin rights to sessions
556 for (const auto &method : {"net.openvpn.v3.sessions.AccessGrant",
557 "net.openvpn.v3.sessions.AccessRevoke"})
558
559 {
560 if (method == authzreq->target)
561 {
562 return object_acl->CheckOwnerAccess(authzreq->caller);
563 }
564 }
565 if ("net.openvpn.v3.sessions.LogForward" == authzreq->target
566 && restrict_log_access)
567 {
568 return object_acl->CheckOwnerAccess(authzreq->caller);
569 }
570
571 return object_acl->CheckACL(authzreq->caller, {object_acl->GetOwner()});

Callers

nothing calls this directly

Calls 6

lookup_uidFunction · 0.85
CheckOwnerAccessMethod · 0.80
ExceptionClass · 0.70
LogCriticalMethod · 0.45
CheckACLMethod · 0.45
GetOwnerMethod · 0.45

Tested by

no test coverage detected