> That's because inetd use dup2(2) to make the stdin descriptor the
> network socket descriptor. In effect, the program exec'd by inetd
> behaves as if it created, bound and listend on the network socket
> itself. However, stunnel actually needs to read and write from the
> network socket (unlike inetd) in order to encrypt and decrypt, and so
> it cannot simply pass the program that network socket descriptor.
>
> The only solution that I am aware of is to run stunnel as a daemon;
Actually, I am already doing that...
> stunnel can run similarly to inetd. Instead of
> client->inetd->stunnel->server you would have client->stunnel->server.
> stunnel _should_ then behave like inetd in dupping the socket
> descriptor, but don't hold me to that.
This is what I thought too; I have stunnel running as a daemon, so indeed
client->stunnel->server ... which seems to me very similar to inetd, so it
should be possible to get the client IP out on the server side.
> Also, maybe stunnel has config options to pass the client IP on the
> command line.
You're right, there was an option! I just discovered it now from their web
site, which has more information than the man pages. When invoking a
program using exec= (or -l, or -L) stunnel sets the environment variable
REMOTE_HOST to the remote IP address. This solves my problem!
--
Jem Berkes
http://www.sysdesign.ca/