From: Amos Jeffries Date: Fri, 1 Feb 2013 09:33:43 +0000 (-0700) Subject: Bug 3749: IDENT lookup using wrong ports to identify the user X-Git-Tag: SQUID_3_3_1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3552930dad925030a305b7fe8478cba92b484ef9;p=thirdparty%2Fsquid.git Bug 3749: IDENT lookup using wrong ports to identify the user --- diff --git a/src/ident/Ident.cc b/src/ident/Ident.cc index 9c996c6b73..87634f2056 100644 --- a/src/ident/Ident.cc +++ b/src/ident/Ident.cc @@ -59,6 +59,7 @@ typedef struct _IdentClient { typedef struct _IdentStateData { hash_link hash; /* must be first */ Comm::ConnectionPointer conn; + MemBuf queryMsg; ///< the lookup message sent to IDENT server IdentClient *clients; char buf[IDENT_BUFSIZE]; } IdentStateData; @@ -147,14 +148,9 @@ Ident::ConnectDone(const Comm::ConnectionPointer &conn, comm_err_t status, int x comm_add_close_handler(conn->fd, Ident::Close, state); - MemBuf mb; - mb.init(); - mb.Printf("%d, %d\r\n", - conn->remote.GetPort(), - conn->local.GetPort()); AsyncCall::Pointer writeCall = commCbCall(5,4, "Ident::WriteFeedback", CommIoCbPtrFun(Ident::WriteFeedback, state)); - Comm::Write(conn, &mb, writeCall); + Comm::Write(conn, &queryMsg, writeCall); AsyncCall::Pointer readCall = commCbCall(5,4, "Ident::ReadReply", CommIoCbPtrFun(Ident::ReadReply, state)); comm_read(conn, state->buf, IDENT_BUFSIZE, readCall); @@ -264,6 +260,10 @@ Ident::Start(const Comm::ConnectionPointer &conn, IDCB * callback, void *data) state->conn->local.SetPort(0); state->conn->remote.SetPort(IDENT_PORT); + // build our query from the original connection details + state->queryMsg.init(); + state->queryMsg.printf("%d, %d\r\n", conn->remote.GetPort(), conn->local.GetPort()); + ClientAdd(state, callback, data); hash_join(ident_hash, &state->hash);