From owner-freebsd-net Sat Nov 17 18:30:13 2001 Delivered-To: freebsd-net@freebsd.org Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by hub.freebsd.org (Postfix) with ESMTP id 14AB237B416 for ; Sat, 17 Nov 2001 18:30:09 -0800 (PST) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id SAA93695; Sat, 17 Nov 2001 18:29:18 -0800 (PST) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id fAI2THw01360; Sat, 17 Nov 2001 18:29:17 -0800 (PST) (envelope-from archie) From: Archie Cobbs Message-Id: <200111180229.fAI2THw01360@arch20m.dellroad.org> Subject: Re: Mpd and pap authentication In-Reply-To: <3BF6D769.9000902@ii.uib.no> "from Trond Davidsen at Nov 17, 2001 10:32:25 pm" To: Trond Davidsen Date: Sat, 17 Nov 2001 18:29:17 -0800 (PST) Cc: freebsd-net@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL82 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org Trond Davidsen writes: > there seems to be a bug in mpd in the handling of PAP > Authenticate-Ack's. RFC 1334 section 2.2.2 specifies the packet format > to look something like the following: > > | Code | Identifier | Length | Msg-Length | Message | > > Mpd leaves out the Msg-Length field, which confuses at least one ppp > implementation, namely pppd (used in FreeBSD, Linux, MacOSX, ...). Wacky.. :-) Try the patch below.. and thanks!! -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com Index: pap.c =================================================================== RCS file: /home/cvs/archie/mpd/src/pap.c,v retrieving revision 1.2 diff -u -r1.2 pap.c --- pap.c 2001/04/12 17:03:33 1.2 +++ pap.c 2001/11/18 02:28:21 @@ -29,7 +29,8 @@ */ static void PapSendRequest(PapInfo pap); - static void PapOutput(u_int code, u_int id, const u_char *buf, int len); + static void PapOutput(u_int code, u_int id, + const u_char *buf, int len, int add_len); static void PapTimeout(void *ptr); static char *PapCode(int code); @@ -104,7 +105,7 @@ memcpy(pkt + 1 + name_len + 1, auth.password, pass_len); /* Send it off */ - PapOutput(PAP_REQUEST, pap->next_id++, pkt, 1 + name_len + 1 + pass_len); + PapOutput(PAP_REQUEST, pap->next_id++, pkt, 1 + name_len + 1 + pass_len, 0); Freee(pkt); } @@ -199,14 +200,15 @@ whyFail = AUTH_FAIL_INVALID_LOGIN; badRequest: failMesg = AuthFailMsg(PROTO_PAP, 0, whyFail); - PapOutput(PAP_NAK, php.id, failMesg, strlen(failMesg)); + PapOutput(PAP_NAK, php.id, failMesg, strlen(failMesg), 1); AuthFinish(AUTH_PEER_TO_SELF, FALSE, NULL); break; } /* Login accepted */ Log(LG_AUTH, (" Response is valid")); - PapOutput(PAP_ACK, php.id, AUTH_MSG_WELCOME, strlen(AUTH_MSG_WELCOME)); + PapOutput(PAP_ACK, php.id, + AUTH_MSG_WELCOME, strlen(AUTH_MSG_WELCOME), 1); AuthFinish(AUTH_PEER_TO_SELF, TRUE, &auth); } break; @@ -255,14 +257,15 @@ */ static void -PapOutput(u_int code, u_int id, const u_char *buf, int len) +PapOutput(u_int code, u_int id, const u_char *buf, int len, int add_len) { struct fsmheader lh; Mbuf bp; int plen; /* Setup header */ - plen = sizeof(lh) + len; + add_len = !!add_len; + plen = sizeof(lh) + add_len + len; lh.id = id; lh.code = code; lh.length = htons(plen); @@ -270,7 +273,9 @@ /* Build packet */ bp = mballoc(MB_AUTH, plen); memcpy(MBDATA(bp), &lh, sizeof(lh)); - memcpy(MBDATA(bp) + sizeof(lh), buf, len); + if (add_len) + *(MBDATA(bp) + sizeof(lh)) = (u_char)len; + memcpy(MBDATA(bp) + sizeof(lh) + add_len, buf, len); /* Send it out */ Log(LG_AUTH, ("[%s] PAP: sending %s", lnk->name, PapCode(code))); To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message