Subject: Problems starting smap as daemon

From: Gerd Schering <[email-masked]>
Date: Wed, 06 Dec 2000 14:52:25 +0100

Hi,
I got the following problem with smap.

When I try to start it as a daemon via

	smap -daemon 1025,

I face the following effects:

- smap doesn't put itself into the background (and of course 
never detaches from the controlling tty as a real daemon should).

- it listens on port 25 instead of 1025

- it runs as root, despite the fact it was told not to so
by a corresponding netperm-table entry.

Having a look at the source I got the impression that
- it never will put itself into background
- it always runs on port 25 regardless what you tell it
- only childs will change userid and groupid if smap is startet with
"-daemon".

So whats wrong - the description in the man page, my source or me,
i.e. did I get something wrong?

Gerd
------------------------------------------------------
-- Gerd Schering
-- Email: [email-masked]
------------------------------------------------------

---

From: Joseph S D Yao <[email-masked]>
Date: Wed, 6 Dec 2000 17:37:34 -0500

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

> i.e. did I get something wrong?

Which version of FWTK are you using?  That will affect the answer.

For 'smap' in FWTK 2.1,
	The "-daemon" flag should have the desired effect.  You have
	to spell it correctly.  I haven't done this, but others have.
	The daemon listening to the port will run as root, but the
	forked-off children that actually do the work will run with the
	given UID and GID.
	(It may not put itself into background mode - you may have to do
	this with shell syntax.)
	The "-port" flag is needed to change the port number.  I.e.,
		smap -daemon -port 1025
	Making this change, of course, means that many MTAs will not be
	able to use this.

-- 
Joe Yao				[email-masked] - Joseph S. D. Yao
COSPO/OSIS Computer Support					EMT-B
-----------------------------------------------------------------------
This message is not an official statement of COSPO policies.

---

From: Ted Keller <[email-masked]>
Date: Wed, 6 Dec 2000 10:28:58 -0500 (EST)

Gerd,

It appears that smap hardcodes the port to port 25.  Hence it is always
listening there.

If I remember correctly, the chuid occurs after a new connection is made
and the smap program forks off a new copy.  You should see the child
process run under the netperm table entry.

For daemon mode - execute smap with the & character to detach it from the
terminal.

ted keller

---

From: Rick Murphy <[email-masked]>
Date: Wed, 06 Dec 2000 20:10:11 -0500

>- it listens on port 25 instead of 1025

The -daemon argument doesn't accept a port number. It would be easy to read 
the port number if you wanted. You're right, though, that it's fixed to 
port 25.

>by a corresponding netperm-table entry.

As you discovered, only smap's children change their user id.
This permits the children to 'follow' changes to the netperm-table right away.

The problem with smap not detaching from it's controlling terminal is fixed 
(I think) in Joe Yao's smap patch. It's fixed in my source, in any case.
         -Rick

---

From: Gerd Schering <[email-masked]>
Date: Thu, 07 Dec 2000 08:34:47 +0100

> (I think) in Joe Yao's smap patch. It's fixed in my source, in any case.

Is this source publicly available :-) ?

BTW, is/was there any reason not to use the library function do_daemon, 
that comes with the fwtk and is used to daemonize other proxies 
as plu-gw for example ?

Gerd

---

From: Joseph S D Yao <[email-masked]>
Date: Thu, 7 Dec 2000 12:12:10 -0500

I forgot to refer you to
<URL: http://www.fwtk.org/fwtk/patches/patches.html#2.2>
which refers to my patch set ... I think Ted's is also in there
somewhere.

---

From: Joseph S D Yao <[email-masked]>
Date: Thu, 7 Dec 2000 12:04:40 -0500

> It appears that smap hardcodes the port to port 25.  Hence it is always

Hmmn???

I'm sorry!  My reference copy has the so-called "Yao patch" collection.
This gives you the "-port" option.  The "-daemon" option is in the base
version, but [IMHO] incorrectly implemented.

Hrmm.  This appears to be some code I actually added.  Otherwise, I
can't attribute it.  ;-]