Public bug reported:

The options "fdin=x,fdout=y" are used to create file descriptors in order to 
have scripts that are executed via EXEC communicate with the  socket.

After heaps of debugging, I noticed that the output file descriptor is never 
actually opened by socat (although it says otherwise).
Please see the output of socat and the corresponding script, which executes 
"filan" to display currently open FDs.

You can see that FD3 is open and input is processed. However, when
writing to FD4, the error message "Bad file descriptor" appears (not
shown in log). FD4 is clearly never opened (what would have been
expected behaviour)


 # socat -d -d -u TCP4-LISTEN:80,reuseaddr,fork,su=nobody 
EXEC:./script.sh,fdout=4,fdin=3 | tee connlog.log
2014/08/19 15:26:15 socat[26813] N listening on AF=2 0.0.0.0:80
2014/08/19 15:26:19 socat[26813] N accepting connection from AF=2 1.2.3.4:49874 
on AF=2 4.5.6.7:80
2014/08/19 15:26:19 socat[26813] N forked off child process 26815
2014/08/19 15:26:19 socat[26813] N listening on AF=2 0.0.0.0:80
2014/08/19 15:26:19 socat[26815] N forking off child, using socket for writing
2014/08/19 15:26:19 socat[26815] N forked off child process 26816
2014/08/19 15:26:19 socat[26815] N forked off child process 26816
2014/08/19 15:26:19 socat[26815] N starting data transfer loop with FDs [4,4] 
and [3,3]
2014/08/19 15:26:19 socat[26816] N execvp'ing "./script.sh"
[SCRIPT] Received http request.
  FD  type      device  inode   mode    links   uid     gid     rdev    size    
blksize blocks  atime                           mtime                           
ctime                           cloexec flags   sigown      sigio
   0: chrdev    0,12    5       020620  1       0       5       136,2   0       
1024    0       Tue Aug 19 15:26:08 2014        Tue Aug 19 15:26:16 2014        
Thu Jul 17 21:36:34 2014        0       x008002 0  0
        (no STREAMS modules)    /dev/pts/2      IFLAGS=00000500 OFLAGS=00000005 
CFLAGS=000000bf LFLAGS=00008a3b cc[0]=^C cc[1]=^\ cc[2]=x7F cc[3]=^U cc[4]=^D 
cc[5]=^@ cc[6]=^A cc[7]=^@ cc[8]=^Q cc[9]=^S cc[10]=^Z cc[11]=^@ cc[12]=^R 
cc[13]=^O cc[14]=^W cc[15]=^V cc[16]=^@ cc[17]=^@ cc[18]=^@ cc[19]=^@ cc[20]=^@ 
cc[21]=^@ cc[22]=^@ cc[23]=^@ cc[24]=^@ cc[25]=^@ cc[26]=^@ cc[27]=^@ cc[28]=^@ 
cc[29]=^@ cc[30]=^@ cc[31]=^@poll: OUT,
   1: pipe      0,8     17895603        010600  1       0       0       0,0     
0       4096    0       Tue Aug 19 15:26:19 2014        Tue Aug 19 15:26:19 
2014        Tue Aug 19 15:26:19 2014        0       x000001     0       0       
(no STREAMS modules)poll: OUT,
   2: chrdev    0,12    5       020620  1       0       5       136,2   0       
1024    0       Tue Aug 19 15:26:08 2014        Tue Aug 19 15:26:16 2014        
Thu Jul 17 21:36:34 2014        0       x008002 0  0
        (no STREAMS modules)    /dev/pts/2      IFLAGS=00000500 OFLAGS=00000005 
CFLAGS=000000bf LFLAGS=00008a3b cc[0]=^C cc[1]=^\ cc[2]=x7F cc[3]=^U cc[4]=^D 
cc[5]=^@ cc[6]=^A cc[7]=^@ cc[8]=^Q cc[9]=^S cc[10]=^Z cc[11]=^@ cc[12]=^R 
cc[13]=^O cc[14]=^W cc[15]=^V cc[16]=^@ cc[17]=^@ cc[18]=^@ cc[19]=^@ cc[20]=^@ 
cc[21]=^@ cc[22]=^@ cc[23]=^@ cc[24]=^@ cc[25]=^@ cc[26]=^@ cc[27]=^@ cc[28]=^@ 
cc[29]=^@ cc[30]=^@ cc[31]=^@poll: OUT,
   3: socket    0,7     17891857        0140777 1       65534   65534   0,0     
0       4096    0       Thu Jan  1 01:00:00 1970        Thu Jan  1 01:00:00 
1970        Thu Jan  1 01:00:00 1970        0       x000002     0       0       
(no STREAMS modules)DEBUG=0     REUSEADDR=0     TYPE=1  ERROR=0 DONTROUTE=0     
BROADCAST=0     SNDBUF=212992   RCVBUF=212992   KEEPALIVE=0     OOBINLINE=0     
NO_CHECK=0      PRIORITY=0 LINGER={0,0}     BSDCOMPAT=0     REUSEPORT=0     
PASSCRED=0      PEERCRED={26815,65534}  RCVLOWAT=1      SNDLOWAT=1      
RCVTIMEO={0,0}  SNDTIMEO={0,0}                          BINDTODEVICE={0,0}      
ATTACH_FILTER={0,0}                 AF=1 "<anon>" <-> AF=1 "<anon>" poll: 
IN,OUT,; FIONREAD=353; recvmsg=1, 


releases


# lsb_release -rd
Description:    Ubuntu 14.04 LTS
Release:        14.04

# apt-cache policy socat
socat:
  Installed: 1.7.2.3-1
  Candidate: 1.7.2.3-1


3) and 4) -> see above.


Thanks a lot for processing this bug.

** Affects: socat (Ubuntu)
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Ubuntu
Server Team, which is subscribed to socat in Ubuntu.
https://bugs.launchpad.net/bugs/1358748

Title:
  socat fdout option will not open output file descriptor

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/socat/+bug/1358748/+subscriptions

-- 
Ubuntu-server-bugs mailing list
Ubuntu-server-bugs@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs

Reply via email to