Tobias DiPasquale on 11 Nov 2004 00:16:02 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] setting up a socket service...


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Nov 10, 2004, at 4:48 PM, George Gallen wrote:
I want to setup a socket service.

The program just needs to listen on a port#, when
  a connection is established (can only be one at a time) it needs to
  run a command locally, then send back the results of that command.

How do setup xinetd to run the program on command.

I thought about just having a program just listen, do when connected, release, repeat
but if the program stops running, obviously the service stops as well.

I'm going to go out on a limb and ask what this is for. The reason I ask is that, with the above description, two things are evident:


1. Its quite easy to monopolize and DoS this service.
2. Are you _SURE_ you want clients to connect and send commands? Why isn't RPC good enough for this?


Having said that:

daemontools is an excellent solution for creating arbitrary network services easily. The daemonization and respawning are handled by daemontools, as is log rotation and expiry via multilog. Check out http://cr.yp.to/daemontools.html for more information on that software.

Alternatively, you could run the program under xinetd by simply adding a file in /etc/xinetd.d. Here's an example:

# cat > /etc/xinetd.d/yourservice <<EOF
service yourservice
{
	type			= INTERNAL UNLISTED
	id			= yourservice-stream
	socket_type	= stream
	protocol		= tcp
	user			= root
	wait			= yes
	server		= /usr/local/bin/yourservicebinary
	server-args	= --some-kind-of-argument
	only_from		= 127.0.0.1
}
EOF

xinetd.conf(5) has all the specifics on what goes where in this file. Yours will probably look like the above somewhat. Check out the existing files for examples, too.

- --
Tobias DiPasquale
202A 04C4 2CE6 B985 8520  88D6 CD25 1A6C B9B5 1595
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (Darwin)

iD8DBQFBkq8hzSUabLm1FZURAg0nAJ4hvW5jrQMO5NmeJezrJJ7KnEnjfACfd9y2
XO5gJdbwn3LblJj4GPeQ9q8=
=hU/r
-----END PGP SIGNATURE-----

___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug