From: Aki Tuomi Date: Tue, 20 Oct 2015 05:41:25 +0000 (+0300) Subject: Use DNSName in GSS-TSIG code X-Git-Tag: dnsdist-1.0.0-alpha1~252^2~8^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1635f12b2eb22702835733511001063806b82bbe;p=pdns Use DNSName in GSS-TSIG code --- diff --git a/pdns/gss_context.cc b/pdns/gss_context.cc index 1f88996c0..10d103ed1 100644 --- a/pdns/gss_context.cc +++ b/pdns/gss_context.cc @@ -20,13 +20,13 @@ bool GssContext::supported() { return false; } GssContext::GssContext() { d_error = GSS_CONTEXT_UNSUPPORTED; d_type = GSS_CONTEXT_NONE; } -GssContext::GssContext(const std::string& label) { d_error = GSS_CONTEXT_UNSUPPORTED; d_type = GSS_CONTEXT_NONE; } +GssContext::GssContext(const DNSName& label) { d_error = GSS_CONTEXT_UNSUPPORTED; d_type = GSS_CONTEXT_NONE; } void GssContext::setLocalPrincipal(const std::string& name) {} bool GssContext::getLocalPrincipal(std::string& name) { return false; } void GssContext::setPeerPrincipal(const std::string& name) {} bool GssContext::getPeerPrincipal(std::string& name) { return false; } void GssContext::generateLabel(const std::string& suffix) {} -void GssContext::setLabel(const std::string& label) {} +void GssContext::setLabel(const DNSName& label) {} bool GssContext::init(const std::string &input, std::string& output) { return false; } bool GssContext::accept(const std::string &input, std::string& output) { return false; } bool GssContext::destroy() { return false; } @@ -116,7 +116,7 @@ std::map > s_gss_init_creds; class GssSecContext : boost::noncopyable { public: - GssSecContext(const std::string& label, boost::shared_ptr cred) { + GssSecContext(boost::shared_ptr cred) { if (cred->valid() == false) throw PDNSException("Invalid credential " + cred->d_nameS); d_cred = cred; d_state = GssStateInitial; @@ -153,12 +153,11 @@ public: }; -std::map > s_gss_sec_context; +std::map > s_gss_sec_context; bool GssContext::supported() { return true; } void GssContext::initialize() { - d_label = ""; d_peerPrincipal = ""; d_localPrincipal = ""; d_error = GSS_CONTEXT_NO_ERROR; @@ -170,9 +169,9 @@ GssContext::GssContext() { generateLabel("pdns.tsig"); } -GssContext::GssContext(const std::string& label) { +GssContext::GssContext(const DNSName& label) { initialize(); - setLabel(toLowerCanonic(label)); + setLabel(label); } void GssContext::generateLabel(const std::string& suffix) { @@ -181,7 +180,7 @@ void GssContext::generateLabel(const std::string& suffix) { setLabel(oss.str()); } -void GssContext::setLabel(const std::string& label) { +void GssContext::setLabel(const DNSName& label) { d_label = label; if (s_gss_sec_context.find(d_label) != s_gss_sec_context.end()) { d_ctx = s_gss_sec_context[d_label]; @@ -227,7 +226,7 @@ bool GssContext::init(const std::string &input, std::string& output) { } } else { // make context - s_gss_sec_context[d_label] = boost::make_shared(d_label, cred); + s_gss_sec_context[d_label] = boost::make_shared(cred); s_gss_sec_context[d_label]->d_type = d_type; d_ctx = s_gss_sec_context[d_label]; d_ctx->d_state = GssSecContext::GssStateNegotiate; @@ -298,7 +297,7 @@ bool GssContext::accept(const std::string &input, std::string& output) { } } else { // make context - s_gss_sec_context[d_label] = boost::make_shared(d_label, cred); + s_gss_sec_context[d_label] = boost::make_shared(cred); s_gss_sec_context[d_label]->d_type = d_type; d_ctx = s_gss_sec_context[d_label]; d_ctx->d_state = GssSecContext::GssStateNegotiate; @@ -434,7 +433,7 @@ void GssContext::processError(const std::string& method, OM_uint32 maj, OM_uint3 bool gss_add_signature(const DNSName& context, const std::string& message, std::string& mac) { string tmp_mac; - GssContext gssctx(context.toStringNoDot()); + GssContext gssctx(context); if (!gssctx.valid()) { L<d_tsig_algo); if (p->d_tsig_algo == TSIG_GSS) { - GssContext gssctx(keyname.toStringNoDot()); + GssContext gssctx(keyname); if (!gssctx.getPeerPrincipal(p->d_peer_principal)) { L<d_time - now) > trc->d_fudge) { cerr<<"TSIG (key '"<d_time - now)<<" > 'fudge' "<d_fudge< q) } else { getTSIGHashEnum(trc.d_algoName, q->d_tsig_algo); if (q->d_tsig_algo == TSIG_GSS) { - GssContext gssctx(keyname.toStringNoDot()); + GssContext gssctx(keyname); if (!gssctx.getPeerPrincipal(q->d_peer_principal)) { L<d_inception = time((time_t*)NULL); tkey_out->d_expiration = tkey_out->d_inception+15; - GssContext ctx(name.toStringNoDot()); + GssContext ctx(name); if (tkey_in.d_mode == 3) { // establish context if (tkey_in.d_algo == DNSName("gss-tsig.")) {