[comp.mail.sendmail] sendmail from inetd?

jgreco@archimedes.math.uwm.edu (Joe Greco) (01/03/91)

I was wondering if anybody has tried the following:

Can sendmail be run from inetd?  sendmail has the option to run SMTP on
stdin/out, and if  possible, I'd like to run it that way instead of "-bd".

Sendmail: v5.65 (mx, no IDA).
System: IBM 6152 RT's running a modified AOS4.3 (very close to BSD)

Why: The 6152's have 4Mb of RAM and perhaps 8Mb of swap.  I am trying to
optimize the little critters to run X11, which requires massive amounts of
memory.  The zone in which they reside will have MX records pointing to a
centralized mail server.  Ideally, sendmail would never be used, so it
shouldn't matter.  However, this is the Real World and we have too many
mailers around that don't know about MX records.  I don't want to lose the
mail-receiving capability of  the 6152's, because of this.

I realize that I'd also probably have to put in a cron job  to run the mail
queue every couple of  hours.

All machines in question are on the Internet.

Has anybody done anything like this?  Do any of the sendmail gurus see any
reason why this would not work, or any other pitfalls / problems?

Any comments at all?

... Joe

-------------------------------------------------------------------------------
Joe Greco - University of Wisconsin, Milwaukee - Department of Mathematics
jgreco@archimedes.math.uwm.edu		USnail: Joe Greco
Voice: 414/321-6184				9905 W. Montana Ave.
Data:  414/321-9287 (Happy Hacker's BBS) 	West Allis, WI  53227-3329
ICBM:  43 05 20 N 87 53 10 W
#include <witty_and_humorous_saying.h>
Disclaimer: I don't speak for the Math Department, the University, or myself.

jackv@turnkey.tcc.com (Jack F. Vogel) (01/03/91)

In article <8653@uwm.edu> jgreco@archimedes.math.uwm.edu (Joe Greco) writes:
>I was wondering if anybody has tried the following:
>
>Can sendmail be run from inetd?  sendmail has the option to run SMTP on
>stdin/out, and if  possible, I'd like to run it that way instead of "-bd".
 
>Sendmail: v5.65 (mx, no IDA).
>System: IBM 6152 RT's running a modified AOS4.3 (very close to BSD)
 
Odd that you should ask this! sendmail on AIX has this capability and my
question always was why someone would want to introduce this "feature":-}.
The quick answer to your question is 'NO' you cannot do this without code
change. AIX introduced a special option '-bn' to support this, the code
is not too extensive but unfortunately also not freely available. You also
would not want to use the AIX 2.2.1 binary since its hopelessly back-level
(doesn't do MX even). When I ported 5.61 to AIX 1.2 I carried this code
forward although its not used by default I believe. If this is really that
important to you send me email and I can give you a rough description of
what the code needs to do.

Disclaimer: I do not speak for my employer.

-- 
Jack F. Vogel			jackv@locus.com
AIX370 Technical Support	       - or -
Locus Computing Corp.		jackv@turnkey.TCC.COM

rsalz@bbn.com (Rich Salz) (01/03/91)

Don't bother.  Around here the only sendmail we run on our clients is
hourly, out of cron, to clear the mailq.  MX is the standard, if people
don't support standards, they lose.

Less obnoxiously, if you rewrite your mail (and news!) so that it looks like
	user@server.uwm.edu
and not
	user@client.server.uwm.edu
then nobody should be attempting to send to the clients anyway.
	/r$
-- 
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
Use a domain-based address or give alternate paths, or you may lose out.

huntting@csn.org (01/04/91)

jgreco@archimedes.math.uwm.edu (Joe Greco) writes:

>I was wondering if anybody has tried the following:

>Can sendmail be run from inetd?  sendmail has the option to run SMTP on
>stdin/out, and if  possible, I'd like to run it that way instead of "-bd".

I use this:

	smtp stream tcp nowait root /usr/lib/sendmail sendmail -bs

It works, but I don't know how if it's as secure as -bd.

>Sendmail: v5.65 (mx, no IDA).

No IDA?  Why, than's unamerican! :-)

brad
	huntting@boulder.colorado.edu
	huntting@csn.org

andy@jhunix.HCF.JHU.EDU (Andy S Poling) (01/04/91)

In article <8653@uwm.edu> jgreco@archimedes.math.uwm.edu (Joe Greco) writes:
>I was wondering if anybody has tried the following:
>
>Can sendmail be run from inetd?  sendmail has the option to run SMTP on
>stdin/out, and if  possible, I'd like to run it that way instead of "-bd".
[...]
>Has anybody done anything like this?  Do any of the sendmail gurus see any
>reason why this would not work, or any other pitfalls / problems?

Sure, I run it from tcplisten (which is very similiar to inetd, but less
flexible and doesn't do UDP).  I wrote smtpd.c (a name which inevitably has
already been used but who cares...), which is about 80 lines long, to exec
sendmail with command line arguments telling it to whom it is speaking.  I
had to do this to combat our machine's broken socket/streams implimentation.

It should take less than 5 minutes to convert it for use with inetd.  It
isn't exactly rocket science, but I'll provide a copy to anybody who's
interested.  Just drop me a line...

-Andy

--
Andy Poling                              Internet: andy@gollum.hcf.jhu.edu
UNIX Systems Programmer                  Bitnet: ANDY@JHUNIX
Homewood Academic Computing              Voice: (301)338-8096    
Johns Hopkins University                 UUCP: uunet!mimsy!aplcen!jhunix!andy

moore@betelgeuse.cs.utk.edu (Keith Moore) (01/06/91)

In article <1991Jan03.092822.20859@turnkey.tcc.com> jackv@turnkey.TCC.COM (Jack F. Vogel) writes:
>In article <8653@uwm.edu> jgreco@archimedes.math.uwm.edu (Joe Greco) writes:
>>I was wondering if anybody has tried the following:
>>
>>Can sendmail be run from inetd?  sendmail has the option to run SMTP on
>>stdin/out, and if  possible, I'd like to run it that way instead of "-bd".
> 
>>Sendmail: v5.65 (mx, no IDA).
>>System: IBM 6152 RT's running a modified AOS4.3 (very close to BSD)
> 
>Odd that you should ask this! sendmail on AIX has this capability and my
>question always was why someone would want to introduce this "feature":-}.
>The quick answer to your question is 'NO' you cannot do this without code
>change. 

That's rather odd.  Here's an excerpt from our local document on
adapting UNIX systems to the UTK environment:
------------------------------------------------------------------------------
[optional]  To avoid the overhead of always having sendmail running,
you can start sendmail from inetd and cron.  To do this:

1.  Create an executable shell script named /usr/etc/smtpd as
    follows:

#!/bin/sh
exec /usr/lib/sendmail -bs 1>&0 2>&0

2.  Add the following line to /etc/inetd.conf:

smtp stream tcp nowait root /usr/etc/smtpd

    (Syntax may be different for your system.  See man inetd for details)

3.  Add the following line to the crontab file:

15 * * * *      /usr/lib/sendmail -q

    (The exact syntax varies from system to system.)  This entry is required
    in case sendmail is not able to deliver messages immediately.  Normally
    the main sendmail process takes care of periodically retrying queued 
    messages; but since sendmail is not running all of the time now, we have 
    to do this explicitly from cron.  The above example runs the queue once
    per hour -- you might want to do it less often.

4.  Comment out the startup code for sendmail in /etc/rc.local (or whatever).

5.  If sendmail is running now, kill it.  Also send a HUP signal to inetd.

6.  Try it by telnet-ing to the local SMTP port and sending a piece of
    mail.
------------------------------------------------------------------------------
This works fine on 6150 RTs under 4.3, although we put the smtpd program in
/etc instead of /usr/etc.  It should work on any Berkeleyish system, modulo
differences in crontab and inetd syntax.

Of course it does have the overhead of firing up the shell and doing an extra 
exec, but the assumption is that you don't receive a message very often on 
your workstation. Our sendmail.cf file rewrites all outgoing mail to be
from user@cs.utk.edu, so replies go to the mail server rather than the
workstations.  For the occasional message that does get sent directly to
the workstation (ignoring MX records), the above hack works just fine.
Keith Moore / U.Tenn CS Dept / 107 Ayres Hall / Knoxville TN  37996-1301
Internet: moore@cs.utk.edu      BITNET: moore@utkvx
``Paranoia is a drug which is more dangerous than any controlled substance.''

rad@puffin.uss.tek.com (Richard Doty) (01/11/91)

To run sendmail from inetd, add this to inetd.conf:

   smtp stream tcp nowait root /usr/lib/sendmail sendmail -bs

The one deficiency I am aware of is that the load average sensing
built into sendmail is partially defeated because inetd always
accepts connections; if the load average is too high sendmail will
be started and then just decide not to accept the connection.

Richard.
rad@puffin.uss.tek.com