]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3749: IDENT lookup using wrong ports to identify the user
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 9 Feb 2013 06:31:57 +0000 (23:31 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 9 Feb 2013 06:31:57 +0000 (23:31 -0700)
src/ident/Ident.cc

index d9d7b89c51ff124f437a8dbc539c3b56e674772a..f2116b869a394929f7534afdb56ac6e99c506043 100644 (file)
@@ -61,6 +61,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;
@@ -149,14 +150,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, &state->queryMsg, writeCall);
     AsyncCall::Pointer readCall = commCbCall(5,4, "Ident::ReadReply",
                                   CommIoCbPtrFun(Ident::ReadReply, state));
     comm_read(conn, state->buf, IDENT_BUFSIZE, readCall);
@@ -266,6 +262,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);