/etc/hosts symlink

Warren Young warren@etr-usa.com
Wed Sep 11 13:56:00 GMT 2002


A few days ago, someone posted to the main Cygwin list wanting an 
/etc/hosts file.  The right thing is for this to be a symlink to 
Windows' own hosts file, since the Winsock resolver uses that file, and 
Cygwin programs use Winsock.

Following is a Bourne shell script fragment which finds the native hosts 
file and makes a symlink to it if it can find it and if /etc/hosts 
doesn't already exist.

This fragment is meant to go into one of the postinstall scripts.  I'm 
not supplying a diff format patch because I don't have a strong opinion 
on which one it should go in.  I propose inetutils, though a case could 
be made for cygwin.  The question is, whether 'tis nobler to turn the 
cygwin package into a dumping ground for random postinstall things, or 
to require people to install inetutils in order to get the /etc/hosts 
symlink.

I suppose it could be a standalone script like mkpasswd, but I think 
it's better that this happen once and automatically.

2002-09-11  Warren Young <warren@etr-usa.com>

	* postinstall: Find Windows' native hosts file and make a
	symlink to it in Cygwin's /etc.


The fragment:

if [ -n "$SYSTEMROOT" ]
then
         ETCPATH1=`cygpath "$SYSTEMROOT"`
         ETCPATH="$ETCPATH1/system32/drivers/etc"
elif [ -n "$WINDIR" ]
then
         ETCPATH=`cygpath "$WINDIR"`
fi

if [ -d "$ETCPATH" -a ! -e /etc/hosts ]
then
         ln -s "$ETCPATH/hosts" /etc/hosts
fi



More information about the Cygwin-patches mailing list