delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/05/04/05:44:43

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <427899E3.200330DF@dessent.net>
Date: Wed, 04 May 2005 02:46:11 -0700
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: Re: echo "$(echo '\r')" oddity
References: <D1D50F9C5151D2119FF000104BB3F9B708E1B759 AT NL-ROT-MAIL02>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com

Jan Just Keijser wrote:

> socat (http://www.dest-unreach.org/socat/) is a multi-purpose relay tool
> that can be used to connect sockets to pipes and vice versa, or terminal
> pty's to TCP sockets etc etc. I have found it a very handy tool to build
> VPN-like things in a environment where you cannot or do not want to modify
> the existing networking infrastructure.

Thanks for the tip.  It indeed does look like a very powerful program, and I am quite
glad to have it in my tool chest now.

I built socat and tried the very same commands you did, and it seems to work fine.  I
normally run a CVS build of the Cygwin DLL but I switched to 1.5.16 and it works fine
with that version as well.

$ socat -t 0.1 exec:'openssl s_server -accept 12002 -quiet -cert cacert.pem -key
privkey.pem' pipe &
[1] 3276

$ socat -d -d -t 0.1 - openssl:localhost:12002,cafile=cacert.pem,verify=1
2005/05/04 02:19:30 socat[2460] N reading from and writing to stdio
2005/05/04 02:19:30 socat[2460] N opening connection to AF=2 127.0.0.1:12002
2005/05/04 02:19:30 socat[2460] N successfully connected from local address AF=2
127.0.0.1:4335
2005/05/04 02:19:30 socat[2460] N SSL connection using DHE-RSA-AES256-SHA
2005/05/04 02:19:30 socat[2460] N starting data transfer loop with FDs [0,1] and [3,3]
hello
hello
goodbye
goodbye
2005/05/04 02:19:34 socat[2460] N socket 1 (fd 0) is at EOF
2005/05/04 02:19:34 socat[2460] N socket 2 (fd 3) is at EOF
2005/05/04 02:19:34 socat[2460] W shutdown(3, 2): Bad file descriptor
2005/05/04 02:19:34 socat[2460] N exiting with status 0

The hello and goodbye I each typed once, the second one was echoed back to me.  I then
hit ^D.  If there was any network problems I would not have expected the ssl handshake
to succeed (I used a dummy cert on both sides as you can tell.)

> this command runs fine on Linux but under Cygwin there is no output echoed
> back from the openssl s_server application. More specifically, the socat
> server process (first line) does return the output but it looks like the
> output never reaches the client - to me, that sounds like a pipe flushing
> problem or a line-termination problem.

I can't quite parse this.  You say it returns the output but it never reaches the
client?  How do you know this?  Surely this swiss army knife of socat will have enough
verbose debugging information for you to find out what's going on.

> the command that I reported yesterday:
>   echo "$(echo '\r')"
> is now working under a newly-compiled version of bash 3.0 in which I
> commented out the offending section in subst.c.

I very much doubt that this has anything to do with the above.  Pipes and sockets are
always opened in binary mode by default.  Regular files default to binary mode as well,
unless you chose 'Dos' at setup.  Even if you did, that still would result in no change
in behavior with pipes or sockets -- that is why bash had to be patched to set textmode
explicitly on the subprocess' fd, becauase unless the application asks for that it will
never be done.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019