Subject: SOCKS5
To: None <netbsd-help@netbsd.org>
From: Ivan Dolezal <ivan.dolezal@vsb.cz>
List: netbsd-help
Date: 05/03/2002 13:40:22
Hello,

as source packages are unavailable at master sites, I used older source 
that I had downloaded some time ago... they are actually newer: v1.0r10 
(the tree contains 1.0.2).

Now to the point: as I am a newbie to NetBSD, I tried to socksize an 
'ftp' daemon (for testing purposes, later I will need to socksize 'sup').

I compiled the SOCKS library, I put /usr/local/lib into /etc/ld.so.conf 
, I wrote the script:

export SOCKS5_USER=xxxxxx [that is to remain secret for the reader]
export SOCKS5_PASSWD=xxxxxx
export SOCKS5_SERVER=xxxxxx
LD_PRELOAD=/usr/local/lib/libsocks5_sh.so $LD_PRELOAD
export LD_PRELOAD
export LD_LIBRARY_PATH=/usr/local/lib
export LD_RUN_PATH=/usr/local/lib
exec "$@"


Calling it with ftp argument did start ftp client (I intend to use it 
later for sup). However, when I was trying to open an FTP server (that I 
could connect at the same time thru the same SOCKS server and the same 
version of SOCKS client thru a Linux machine), no connection was made. 
netstat -f inet from a different terminal didn't show any attempt to 
make any connection.

Trying ktruss showed this... As you may see, I did force it to download 
the SOCKS library first, but I couldn't make it run.

ross:~ # ktruss ./socksuj.sh ftp
                                                    = 0
   6465 ktruss   emul(netbsd)
   6465 ktruss   execve("./socksuj.sh", 0x1fffff890, 0x1fffff8a8) Err#8 
ENOEXEC
   6465 ktruss   execve("/bin/sh", 0x120128040, 0x1fffff8a8) JUSTRETURN
   6465 sh       emul(netbsd)
ftp>   6465 sh       getpid                             = 6465
...
   6465 sh       open("./socksuj.sh", 0, 0x50020)   = 3
...
   6465 ftp      open("/etc/ld.so.conf", 0, 0x160117301) = 3
...
   6465 ftp      open("/usr/local/lib/libsocks5_sh.so", 0, 0x7) = 3
   6465 ftp      __fstat13(0x3, 0x1fffff698)        = 0
   6465 ftp      read(0x3, 0x1ffffd608, 0x2000)     = 8192
   6465 ftp      mmap(0, 0x130000, 0x5, 0x2, 0x3, 0, 0) = 5907800064
   6465 ftp      mmap(0x160348000, 0x4000, 0x7, 0x12, 0x3, 0, 0x2a000) = 
59090206
72
   6465 ftp      mmap(0x16034c000, 0x2000, 0x7, 0x1012, 
0xffffffffffffffff, 0, 0)
  = 5909037056
   6465 ftp      munmap(0x16024a000, 0xfe000)       = 0
   6465 ftp      close(0x3)                         = 0

ftp> open ftp.cesnet.cz

from the dump it was obvious that it tried to connect via FTP directly 
to cesnet.cz, ignoring the SOCKS library.



What am I doing wrong? I didn't find any hints on the web, so I will be 
very grateful for an instructive information. Thank you in advance.


Ivan