>From adbbbb700d1f94e465bf2eb5d3a0698dc81f23bc Mon Sep 17 00:00:00 2001 From: Phil Mayers Date: Mon, 11 Oct 2010 16:14:50 +0100 Subject: [PATCH 4/4] remove newlines from RDEBUG macros; wrap virtual server fprintf in debug conditional --- src/main/soh.c | 36 ++++++++++++------------ src/modules/rlm_eap/types/rlm_eap_peap/peap.c | 15 +++++++--- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/main/soh.c b/src/main/soh.c index ea078f5..40284b7 100644 --- a/src/main/soh.c +++ b/src/main/soh.c @@ -117,7 +117,7 @@ static int eapsoh_mstlv(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *p, u * MS-SOH section 2.2.4.1 */ if (data_len < 18) { - RDEBUG("insufficient data for MS-Machine-Inventory-Packet\n"); + RDEBUG("insufficient data for MS-Machine-Inventory-Packet"); return 0; } data_len -= 18; @@ -172,7 +172,7 @@ static int eapsoh_mstlv(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *p, u /* MS-Packet-Info * MS-SOH 2.2.4.3 */ - RDEBUG("SoH MS-Packet-Info %s vers=%i\n", *p & 0x10 ? "request" : "response", *p & 0xf); + RDEBUG("SoH MS-Packet-Info %s vers=%i", *p & 0x10 ? "request" : "response", *p & 0xf); p++; data_len--; break; @@ -253,7 +253,7 @@ static int eapsoh_mstlv(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *p, u break; default: - RDEBUG("SoH Unknown MS TV %i stopping\n", c); + RDEBUG("SoH Unknown MS TV %i stopping", c); return 0; } } @@ -319,14 +319,14 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne hdr.tlv_vendor = soh_pull_be_32(data); data += 4; if (hdr.tlv_type != 7 || hdr.tlv_vendor != 0x137) { - RDEBUG("SoH payload is %i %08x not a ms-vendor packet\n", hdr.tlv_type, hdr.tlv_vendor); + RDEBUG("SoH payload is %i %08x not a ms-vendor packet", hdr.tlv_type, hdr.tlv_vendor); return -1; } hdr.soh_type = soh_pull_be_16(data); data += 2; hdr.soh_len = soh_pull_be_16(data); data += 2; if (hdr.soh_type != 1) { - RDEBUG("SoH tlv %04x is not a response\n", hdr.soh_type); + RDEBUG("SoH tlv %04x is not a response", hdr.soh_type); return -1; } @@ -339,13 +339,13 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne if (resp.outer_type!=7 || resp.vendor != 0x137) { - RDEBUG("SoH response outer type %i/vendor %08x not recognised\n", resp.outer_type, resp.vendor); + RDEBUG("SoH response outer type %i/vendor %08x not recognised", resp.outer_type, resp.vendor); return -1; } switch (resp.inner_type) { case 1: /* no mode sub-header */ - RDEBUG("SoH without mode subheader\n"); + RDEBUG("SoH without mode subheader"); break; case 2: mode.outer_type = soh_pull_be_16(data); data += 2; @@ -357,13 +357,13 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne data += 2; if (mode.outer_type != 7 || mode.vendor != 0x137 || mode.content_type != 0) { - RDEBUG("SoH mode subheader outer type %i/vendor %08x/content type %i invalid\n", mode.outer_type, mode.vendor, mode.content_type); + RDEBUG("SoH mode subheader outer type %i/vendor %08x/content type %i invalid", mode.outer_type, mode.vendor, mode.content_type); return -1; } - RDEBUG("SoH with mode subheader\n"); + RDEBUG("SoH with mode subheader"); break; default: - RDEBUG("SoH invalid inner type %i\n", resp.inner_type); + RDEBUG("SoH invalid inner type %i", resp.inner_type); return -1; } @@ -401,7 +401,7 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne */ curr_shid = soh_pull_be_24(data); curr_shid_c = data[3]; - RDEBUG("SoH System-Health-ID vendor %08x component=%i\n", curr_shid, curr_shid_c); + RDEBUG("SoH System-Health-ID vendor %08x component=%i", curr_shid, curr_shid_c); break; case 7: @@ -412,10 +412,10 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne * N bytes payload; for Microsoft component#0 this is the MS TV stuff */ if (curr_shid==0x137 && curr_shid_c==0) { - RDEBUG("SoH MS type-value payload\n"); + RDEBUG("SoH MS type-value payload"); eapsoh_mstlv(request, sohvp, data + 4, tlv.tlv_len - 4); } else { - RDEBUG("SoH unhandled vendor-specific TLV %08x/component=%i %i bytes payload\n", curr_shid, curr_shid_c, tlv.tlv_len); + RDEBUG("SoH unhandled vendor-specific TLV %08x/component=%i %i bytes payload", curr_shid, curr_shid_c, tlv.tlv_len); } break; @@ -425,7 +425,7 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne * * 1 byte integer */ - RDEBUG("SoH Health-Class %i\n", data[0]); + RDEBUG("SoH Health-Class %i", data[0]); curr_hc = data[0]; break; @@ -435,7 +435,7 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne * * 1 byte integer */ - RDEBUG("SoH Software-Version %i\n", data[0]); + RDEBUG("SoH Software-Version %i", data[0]); break; case 11: @@ -451,14 +451,14 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne * 1 bit - 1==product up-to-date * 1 bit - 1==product enabled */ - RDEBUG("SoH Health-Class-Status - current shid=%08x component=%i\n", curr_shid, curr_shid_c); + RDEBUG("SoH Health-Class-Status - current shid=%08x component=%i", curr_shid, curr_shid_c); if (curr_shid==0x137 && curr_shid_c==128) { const char *s, *t; uint32_t hcstatus = soh_pull_be_32(data); - RDEBUG("SoH Health-Class-Status microsoft DWORD=%08x\n", hcstatus); + RDEBUG("SoH Health-Class-Status microsoft DWORD=%08x", hcstatus); vp = pairmake("SoH-MS-Windows-Health-Status", NULL, T_OP_EQ); switch (curr_hc) { @@ -567,7 +567,7 @@ int soh_verify(REQUEST *request, VALUE_PAIR *sohvp, const uint8_t *data, unsigne break; default: - RDEBUG("SoH Unknown TLV %i len=%i\n", tlv.tlv_type, tlv.tlv_len); + RDEBUG("SoH Unknown TLV %i len=%i", tlv.tlv_type, tlv.tlv_len); break; } diff --git a/src/modules/rlm_eap/types/rlm_eap_peap/peap.c b/src/modules/rlm_eap/types/rlm_eap_peap/peap.c index 9ce9c46..e814541 100644 --- a/src/modules/rlm_eap/types/rlm_eap_peap/peap.c +++ b/src/modules/rlm_eap/types/rlm_eap_peap/peap.c @@ -813,14 +813,21 @@ int eappeap_process(EAP_HANDLER *handler, tls_session_t *tls_session) fake->packet->vps = eapsoh_verify(request, data, data_len); setup_fake_request(request, fake, t); - rad_assert(t->soh_virtual_server != NULL); - fake->server = t->soh_virtual_server; + if (t->soh_virtual_server != NULL) { + fake->server = t->soh_virtual_server; + } RDEBUG("Processing SoH request"); debug_pair_list(fake->packet->vps); - fprintf(fr_log_fp, "server %s {\n", fake->server); + if ((debug_flag > 0) && fr_log_fp) { + fprintf(fr_log_fp, "server %s {\n", + (fake->server == NULL) ? "" : fake->server); + } rad_authenticate(fake); - fprintf(fr_log_fp, "} # server %s\n", fake->server); + if ((debug_flag > 0) && fr_log_fp) { + fprintf(fr_log_fp, "} # server %s\n", + (fake->server == NULL) ? "" : fake->server); + } RDEBUG("Got SoH reply"); debug_pair_list(fake->reply->vps); -- 1.6.6.1