NIS problem (and proposal for solutions)
Raffaele Biscosi
rbiscosi at gmx.de
Thu Oct 5 13:59:02 BST 2006
Hi,
I hope this is the right place for my concern. If not, please tell me. I also
hope that my explanation is clear and not too long winded...
I have installed NIS recently and noticed that it is important that entries
in /etc/hosts belonging to 127.0.0.1 maintain a certain order. It is
necessary that the first name for 127.0.0.1 be the systems name (uname -n).
Unfortuantely installation routines (namely netcfg) create a different order.
The /etc/hosts of a fresh installed ubuntu will look something like this:
127.0.0.1 localhost nis-srv
192.168.0.1 nis-srv
...
This order makes it impossible to properly configure a NIS environment with
slave servers. The point of failure is '/usr/lib/yp/yphelper'. This command
is used by NIS initialization scripts to determine the machines name (among
other things).
When 'yphelper' is called with parameter '--hostname' (like this is done in
the NIS makefile /var/yp/Makefile) it first determines the machine's hostname
using 'gethostname' (from libc) and passing the result to 'gethostbyname'
which in turn returns a hostent structure. Finally the content of structure
member 'h_name' is printed.
Thus if you call '/usr/lib/yp/yphelper --hostname' on a fresh installed ubuntu
system (be it dapper or breezy, that's what I tested) the result will
be 'localhost'.
The next step in NIS makefile consists of building the maps. These maps have a
key (YP_MASTER_NAME) to tell which NIS server is master for a certain map. In
our case YP_MASTER_NAME is set to 'localhost' instead of the master server's
real name. Transfer scripts for NIS maps rely on this field and fail since it
contains the wrong name.
I think there are two (and a half) ways to avoid this problem:
a) netcfg creates an /etc/hosts entry like "127.0.0.1 nis-srv localhost"
instead of "127.0.0.1 localhost nis-srv"
b) change function print_hostname in yphelper.c: If called with
parameter "--hostname" only, print the result of 'gethostname' and exit
instead of calling 'gethostbyname'
( c) Mention the problem in NIS-package README and let administrators do the
work )
Thanks,
Raffaele Biscosi
More information about the ubuntu-devel
mailing list