Mailing List Archive

[Bug 2784] readsocket doesn't work as expected
https://bugs.exim.org/show_bug.cgi?id=2784

--- Comment #4 from Jeremy Harris <jgh146exb@wizmail.org> ---
Again, please show what goes on the wire, and say why you thing it is wrong.

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

--- Comment #5 from adsh@univ.kiev.ua ---
I do not know how else to explain the obvious things. Some and the same
requests in the telnet work, and in Exim - no.

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

--- Comment #6 from Lena <Lena@lena.kiev.ua> ---
Created attachment 1401
--> https://bugs.exim.org/attachment.cgi?id=1401&action=edit
tcpdump

I attached tcpdump of telnet (works) and readsocket (doesn't work, with both
shutdown=no and shutdown=yes). I cannot understand what exactly is the reason,
but telnet gets answer from the web-server, readsocket doesn't.

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

--- Comment #7 from Lena <Lena@lena.kiev.ua> ---
P.S. FreeBSD, Exim 4.94.2 from ports.

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

Lena <Lena@lena.kiev.ua> changed:

What |Removed |Added
----------------------------------------------------------------------------
Attachment #1401|0 |1
is obsolete| |

--- Comment #8 from Lena <Lena@lena.kiev.ua> ---
Created attachment 1402
--> https://bugs.exim.org/attachment.cgi?id=1402&action=edit
tcpdump

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

--- Comment #9 from Lena <Lena@lena.kiev.ua> ---
Created attachment 1403
--> https://bugs.exim.org/attachment.cgi?id=1403&action=edit
revert wb

In both cases shutdown=yes and shutdown=no, after sending the data, Exim 4.94.2
sends an additional packet with flag F and length 0. Telnet doesn't send such
packet.

Exim 4.93 expand.c :

/* Now we need to read from the socket, under a timeout. The function
that reads a file can be used. */

if (!do_tls)
fp = fdopen(cctx.sock, "rb");

Exim 4.94 lookups/readsock.c :

/* Now we need to read from the socket, under a timeout. The function
that reads a file can be used. If we're using a stdio buffered read,
and might need later write ops on the socket, the stdio must be in
writable mode or the underlying socket goes non-writable. */

if (!cctx->tls_ctx)
fp = fdopen(cctx->sock, lf.do_shutdown ? "rb" : "wb");


Can someone explain when/how/why we might need later write ops on the socket
(after the data from the second argument of "${readsocket" was sent)?

Exim 4.94.2 - doesn't work:

[root@lena ~]# exim -be '${readsocket{inet:i.ua:80}{GET / HTTP/1.0\r\nHost:
i.ua\r\n\r\n}{4s:shutdown=yes}{\n}{socket failure}}'

[root@lena ~]# exim -be '${readsocket{inet:i.ua:80}{GET / HTTP/1.0\r\nHost:
i.ua\r\n\r\n}{4s:shutdown=no}{\n}{socket failure}}'

[root@lena ~]#

After I reverted this change (patch attached), it works:

[root@lena ~]# exim -be '${readsocket{inet:i.ua:80}{GET / HTTP/1.0\r\nHost:
i.ua\r\n\r\n}{4s:shutdown=yes}{\n}{socket failure}}'

[root@lena ~]# exim -be '${readsocket{inet:i.ua:80}{GET / HTTP/1.0\r\nHost:
i.ua\r\n\r\n}{4s:shutdown=no}{\n}{socket failure}}'
HTTP/1.1 301 Moved Permanently
Date: Mon, 22 Nov 2021 13:13:56 GMT
Server: Apache/1.3.42 (Unix) mod_deflate/1.0.21
Location: https://www.i.ua
Connection: close
Content-Type: text/html; charset=windows-1251


[root@lena ~]#

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

--- Comment #10 from Jeremy Harris <jgh146exb@wizmail.org> ---
I don't recall either why the "wb" was needed, and that comment is
insufficient.
Mea culpa. But making it "rb" always breaks the ANSWER-11 subtest of
testsuite case 0373 (on Fedora 33).

Your results are interesting. The FIN packet is *expected* to be emitted
due to the closedown(SHUT_WR) preceding that fdopen(), but only if the
do_shutdown flag is set. Which is when the fdopen() should be using "rb"
anyway. You're seeing it in both cases... maybe it's not due to the
shutdown() but to the close() supposedly being done after the cat_file(),
and the latter is behaving differently in some fashion and giving a timing
difference. Do both pcaps have FINs for both directions, or is one getting
a RST? In fact, I need to run up a FreeBSD and play - what version?

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

--- Comment #11 from Jeremy Harris <jgh146exb@wizmail.org> ---
I see six FIN packets for 3 connections:

$ grep -F 'Flags [F.]' tcpdump.txt
21:23:49.931020 IP www.i.ua.http > lena.kiev.ua.25953: Flags [F.], seq 215, ack
31, win 114, options [nop,nop,TS val 1868708356 ecr 4080618673], length 0
21:23:49.931532 IP lena.kiev.ua.25953 > www.i.ua.http: Flags [F.], seq 31, ack
216, win 1027, options [nop,nop,TS val 4080618711 ecr 1868708356], length 0
21:36:07.406537 IP lena.kiev.ua.60973 > www.i.ua.http: Flags [F.], seq 31, ack
1, win 1027, options [nop,nop,TS val 2483698790 ecr 1869445813], length 0
21:36:07.442484 IP www.i.ua.http > lena.kiev.ua.60973: Flags [F.], seq 1, ack
32, win 114, options [nop,nop,TS val 1869445850 ecr 2483698790], length 0
21:46:00.965671 IP lena.kiev.ua.49418 > www.i.ua.http: Flags [F.], seq 31, ack
1, win 1027, options [nop,nop,TS val 1694771968 ecr 1870039358], length 0
21:46:01.001573 IP www.i.ua.http > lena.kiev.ua.49418: Flags [F.], seq 1, ack
32, win 114, options [nop,nop,TS val 1870039395 ecr 1694771968], length 0

Where's the extra?

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

--- Comment #12 from Lena <Lena@lena.kiev.ua> ---
FreeBSD 12.2 amd64, Exim 4.94.2.

When doesn't work (shutdown=no, wb):

21:36:07.406460 IP lena.kiev.ua.60973 > www.i.ua.http: Flags [P.], seq 1:31,
ack 1, win 1027, options [nop,nop,TS val 2483698790 ecr 1869445813], length 30:
HTTP: GET / HTTP/1.0
0x0000: 4500 0052 0000 4000 4006 9062 b92d 7142 E..R..@.@..b.-qB
0x0010: 5bc6 240e ee2d 0050 84c5 746e 5992 3b76 [..$..-.P..tnY.;v
0x0020: 8018 0403 d0c4 0000 0101 080a 940a 3c66 ..............<f
0x0030: 6f6d 7ab5 4745 5420 2f20 4854 5450 2f31 omz.GET./.HTTP/1
0x0040: 2e30 0d0a 486f 7374 3a20 692e 7561 0d0a .0..Host:.i.ua..
0x0050: 0d0a ..
21:36:07.406537 IP lena.kiev.ua.60973 > www.i.ua.http: Flags [F.], seq 31, ack
1, win 1027, options [nop,nop,TS val 2483698790 ecr 1869445813], length 0
0x0000: 4500 0034 0000 4000 4006 9080 b92d 7142 E..4..@.@....-qB
0x0010: 5bc6 240e ee2d 0050 84c5 748c 5992 3b76 [..$..-.P..t.Y.;v
0x0020: 8011 0403 9109 0000 0101 080a 940a 3c66 ..............<f
0x0030: 6f6d 7ab5 omz.
21:36:07.442199 IP www.i.ua.http > lena.kiev.ua.60973: Flags [.], ack 31, win
114, options [nop,nop,TS val 1869445849 ecr 2483698790], length 0
0x0000: 4528 0034 41af 4000 3306 5ba9 5bc6 240e E(.4A.@.3.[..[..$.
0x0010: b92d 7142 0050 ee2d 5992 3b76 84c5 748c .-qB.P.-Y.;v..t.
0x0020: 8010 0072 9477 0000 0101 080a 6f6d 7ad9 ...r.w......omz.
0x0030: 940a 3c66 ..<f

When works (shutdown=no, rb):

18:48:48.142727 IP lena.kiev.ua.14041 > www.i.ua.http: Flags [P.], seq 1:31,
ack 1, win 1027, options [nop,nop,TS val 2259081968 ecr 2032202607], length 30:
HTTP: GET / HTTP/1.0
0x0000: 4500 0052 0000 4000 4006 9062 b92d 7142 E..R..@.@..b.-qB
0x0010: 5bc6 240e 36d9 0050 d865 4ece 95be 1ef4 [..$.6..P.eN.....
0x0020: 8018 0403 26db 0000 0101 080a 86a6 daf0 ....&...........
0x0030: 7920 f36f 4745 5420 2f20 4854 5450 2f31 y..oGET./.HTTP/1
0x0040: 2e30 0d0a 486f 7374 3a20 692e 7561 0d0a .0..Host:.i.ua..
0x0050: 0d0a ..
18:48:48.178513 IP www.i.ua.http > lena.kiev.ua.14041: Flags [.], ack 31, win
114, options [nop,nop,TS val 2032202643 ecr 2259081968], length 0
0x0000: 4528 0034 ed67 4000 3306 aff0 5bc6 240e E(.4.g@.3...[.$.
0x0010: b92d 7142 0050 36d9 95be 1ef4 d865 4eec .-qB.P6......eN.
0x0020: 8010 0072 ea8d 0000 0101 080a 7920 f393 ...r........y...
0x0030: 86a6 daf0 ....

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

Jeremy Harris <jgh146exb@wizmail.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|-- |Exim 4.96
Status|NEW |ASSIGNED
Hardware|x86-64 |All
Assignee|unallocated@exim.org |jgh146exb@wizmail.org
OS|FreeBSD |All

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

--- Comment #13 from Jeremy Harris <jgh146exb@wizmail.org> ---
OK, the "wb" is obviously bogus. Will revert.

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##
[Bug 2784] readsocket doesn't work as expected [ In reply to ]
https://bugs.exim.org/show_bug.cgi?id=2784

Jeremy Harris <jgh146exb@wizmail.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |WAIT_FIX_CONFIRMATION

--- Comment #14 from Jeremy Harris <jgh146exb@wizmail.org> ---
05b70ebcdc addresses.

--
You are receiving this mail because:
You are on the CC list for the bug.
--
## List details at https://lists.exim.org/mailman/listinfo/exim-dev Exim details at http://www.exim.org/ ##