MCPcopy Create free account
hub / github.com/apache/trafficserver / late_check_peer_credentials

Method late_check_peer_credentials

src/mgmt/rpc/server/IPCSocketServer.cc:446–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444}
445
446void
447IPCSocketServer::late_check_peer_credentials(int peedFd, TSRPCHandlerOptions const &options, swoc::Errata &errata) const
448{
449 // For privileged calls, ensure we have caller credentials and that the caller is privileged.
450 auto ecode = [](UnauthorizedErrorCode c) -> std::error_code {
451 return std::error_code(static_cast<unsigned>(c), std::generic_category());
452 };
453
454 if (has_peereid() && options.auth.restricted) {
455 uid_t euid = -1;
456 gid_t egid = -1;
457 if (get_peereid(peedFd, &euid, &egid) == -1) {
458 errata.assign(ecode(UnauthorizedErrorCode::PEER_CREDENTIALS_ERROR))
459 .note("Error getting peer credentials: {}", swoc::bwf::Errno{});
460 } else if (euid != 0 && euid != geteuid()) {
461 errata.assign(ecode(UnauthorizedErrorCode::PERMISSION_DENIED))
462 .note("Denied privileged API access for uid={} gid={}", euid, egid);
463 }
464 }
465}
466
467} // namespace rpc::comm
468

Callers

nothing calls this directly

Calls 5

has_peereidFunction · 0.85
get_peereidFunction · 0.85
ecodeFunction · 0.85
noteMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected