Subject: more customizing *-gw

From: Antuan Avdioukhine <[email-masked]>
Date: Thu, 22 Mar 2001 18:37:37 +0300 (MSK)

[To be removed from this list send the message "unsubscribe fwtk-users" in the
BODY of a mail message to [email-masked].]

Hi!

Some ago we read some letters about "unusual" customization of gateways
from fwtk. The problem is that gateways uses hard-codded tags when
selecting netperm-table configuration lines. That is why it is impossible
to make custom welcome messages for ftp/tn/rlogin-gw depending on
different addresses -- such customization cannot be performed using
*host-rules.

Here is a quick solution we're using last two years. I could post a patch,
but code I'm using is very different from one taken from fwtk bundle. So.
Let's do it with ftp-gw.c

1. First, we declare char[] variable. We store tagname in this
variable. Probably we have make this variable global, not in main(). Let
we name it 'myname[128]'.

2. Then we note that using xinetd or modern inetd we can change argv[0].
Using this knowledge first we do in main() we strncpy(myname, argv[0],
sizeof(myname)) for future use.

3. For more nice logging we may use myname in openlog near
main() begins. So change:

#ifndef LOG_DAEMON
    openlog("ftp-gw",LOG_PID);
#else
    openlog("ftp-gw",LOG_PID|LOG_NDELAY,LFAC);
#endif

to

#ifndef LOG_DAEMON
    openlog(myname,LOG_PID);
#else
    openlog(myname,LOG_PID|LOG_NDELAY,LFAC);
#endif

4. Next, we skip some lines locating the next code:

    if((confp = cfg_read("ftp-gw")) == (Cfg *)-1)
        exit(1);

This procedure opens netperm-table and fills confp structure. Changing
first of strings above to:

    if((confp = cfg_read(myname)) == (Cfg *)-1)

we got result we looking for -- ftp-gw will look for tags depending on
argv[0], not on hardcodded string.

Perfect. Now we just have to use different daemons for different
purposes. This is a taste of each own. I prefer xinetd and different
addresses to use. Someone may found different ports more useful.

Questions? None?! Fine! :-)

--
Antuan Avdioukhine (DEKA-RIPN)
InternetMedia Holding Ltd.
St.Petersburg, Russia. +7 (812) 320 8585