I'd like to create a custom NIS map in order to be able to look up my own information using ypmatch
and map between local and centralised usernames. How can this be achieved?
How to create a custom NIS map
nis
nis
I'd like to create a custom NIS map in order to be able to look up my own information using ypmatch
and map between local and centralised usernames. How can this be achieved?
Best Answer
First off, edit
/var/yp/Makefile
to add in the new map. You’ve probably got something like this:We need to add a new line for the new map. This is going to be the new username map, so call it usermap.
YPSRCDIR
is/etc
in my case, but obviously choose the path that suits you the best.Now find a line that starts
all:
. This is the list of maps to update. Add your new map to the end, so it’ll be something likeFurther down where there is a group of lines like this:
you should add in your own map:
The
byname
part is an indicator for what the map key is and isn’t that important for us.You now need to add a section to tell the makefile how to update your map:
This processes the file
/etc/usermap
and generates the map file. Essentially you just need to printkey\tvalue
into$(DBLOAD) …
. This example extracts data from the file assuming it is in the formatkey:value
.Now edit
/var/yp/nicknames
to add your new map:then run
make
in/var/yp
as normal.If you have a slave server you’ll probably have a timeout with the new map at this point. To get round this, you need to run
ypxfr
on the slave to get the map first: