I don't mean to be a swaggerer, but, i just need to correct a small part of the *excellent* piece by Kishor :-)
There is one important file..called /etc/services, that lists all the services your box is offering to the outside world.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Actually, the "/etc/services" file simply lists the ports and protocol names. Its purpose is to provide mappings between the protocol names like telnet, ftp etc., to their respective port numbers. It *does not* mean that the services are actually running.
Pleeease, please, please *do not feel hurt*, Kishor, since that is not my aim. I am sorry if you feel otherwise. In any case, thank you for taking the initiative to start the discussion :-))
Fart
----- Original Message ----- From: Fart Crimson keeg3@yahoo.com
There is one important file..called /etc/services, that lists all
the
services your box is offering to the outside world.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Actually, the "/etc/services" file simply lists the ports and protocol names
rite../etc/services just lists the services...its the /etc/inetd.conf that defines which ones will be run(IF ur running inetd that is) sorry for the misleading sentence.Didnt mean it that way though. thanks for pointing it out!
regards, kishor PS: The day i feel 'bad' about corrections, i might as well pack up and leave this field!
_________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com
Sometime Today, Kishor Bhagwat assembled some asciibets to say:
rite../etc/services just lists the services...its the /etc/inetd.conf that defines which ones will be run(IF ur running
And that's not the only file. Many daemons may run standalone as well. To continue with the subject, anyone interested should probably read /usr/[share/]doc/tcp_wrappers/*
In brief:
tcp wrappers basically implement some sort of control at the tcp layer.
Inetd:
Inetd (now xinetd) is what is known as a super server. It listens on many different ports. These would be configured in /etc/inetd.conf. When a connection comes in on one of these ports, inetd starts the daemon that is supposed to service that service.
For example:
When one telnets to a machine, inetd is listening on port 23. When the connection comes in, inetd will start the telnet daemon.
The advantage of such a set up is twofold.
1. Only one server runs all the time, and others are spawned only when required. The overhead of spawning a new process isn't that much, since if the server were running on its own, it would have to spawn a child anyway.
2. Other servers do not have to have complex socket code built into them. They communicate through stdio. Inetd connects the socket to the child process' stdin and stdout descriptors before spawning.
So where does tcpd come in?
Instead of directly starting the server, inetd can start tcpd, and tell tcpd to start the correct server after performing any checks, etc. that it wants. If one opens /etc/inetd.conf, one will find against the telnet and ftp lines that the daemon to be spawned is tcpd with in.telned/in.ftpd as arguments.
telnet stream tcp nowait root /usr/sbin/tcpd in.telnetd
Don't worry about the other values on the line, you'll figure them out soon enough.
Now, in execve parlance, the first argument passed in the argument vector corresponds to argv[0], i.e., the name that the program should call itself. tcpd takes this hint, and calls itself in.telnetd (which is what will show up if you do list running processes). It performs its checks, and then execs in.telnetd, passing all file descriptors on.
Thus, we have tcpd, which has a single access control file, doing checks for most daemons. Further more, since tcpd comes into the picture only while a connection is being estabilished, and leaves the scene thereafter, there is no overhead involved (except for that during checking, which is what we want).
Now, not all servers are started through inetd. Many, like sendmail, apache, and sshd, run as standalone servers. These servers can have tcpd compiled into them using libwrap.a and tcpd.h. They will then automatically check with hosts.allow and hosts.deny.
Now all these options must be selected while compiling tcpd and libwrap, but the defaults are decently secure anyway.
For info on the hosts.{allow,deny} files, check the man pages on hosts_access(5) and hosts_options(5). Also check the man pages on tcpd(8).
To check the configuration of your tcpd wrappers, use /sbin/tcpdchk. Give it the -v flag for more information.
Philip