You can invoke stunnel from inetd. Inetd is the unix
'super server'
that allows you to launch a program (for example the telnet daemon)
whenever a connection is established to a specified port.
Lets say we want to have stunnel listen on our machine on port
9999 to support a fictious protocol called
foobar.
We'd add the following line to the file /etc/inetd.conf
foobar stream tcp nowait root /usr/local/sbin/stunnel stunnel args(if you installed stunnel in a different location than
/usr/local/sbin,
use that path instead) and add the following line to
/etc/services
foobar 9999/tcp # The foobar service
You must then send the inetd process a
SIGHUP.
Find the process id for the inetd process by one of the
following commands:
ps -ef|grep inetd ps -axj|grep inetdand then type
kill -HUP process_id.
You may be able to use killall -HUP inetd on some
Unix versions (for example linux, *BSD, IRIX) to save yourself
from looking up the process id. Note that some unix variants
have a killall command that kills all processes
on the machine. That's not the killall you're
looking for...
For examples of the args you'd wish to use, see the next chapter, and the examples in chapter 6.
Notes:
Running in daemon mode is much prefered to running in
inetd mode. Why?
Lets say we want to have stunnel listen on our machine on port
9999 to support a fictious protocol called
foobar.
We'd add the following line to /etc/services
foobar 9999/tcp # The foobar serviceThen we launch stunnel from the command line (or a script) as follows:
/usr/local/sbin/stunnel -d foobar args
For examples of the args you'd wish to use, see the next chapter, and the examples in chapter 6.
The configure program should be able
to determine if the libwrap library (-lwrap) and
headers are available in standard locations.
You must put entries in /etc/hosts.allow to specify
which machines should be allowed access to stunnel.
These are of the form
service1: goodhost.example.com .trusteddomain.example.com service2: otherhost.example.com 192.168.0.1
Since you could be running more than one copy of
stunnel, and on various ports and IPs,
stunnel uses the following
rules to determine what service name to use in the
hosts.allow file:
-D 7) and look for a line similar to the following:
LOG7[XXXX:XXXX]: http bound to X.X.X.X:XXXXIn the example above,
stunnel will check the
hosts.allow file for service entries for
http.
There are more examples in chapter 6.
killing it. Stunnel accepts
the following signals, all of which tell it to log
the signal and terminate: TERM, QUIT, INT.