<?Pub UDT _bookmark _target?><chapter id="anis2-22217"><?Pub Tag atict:info tracking="on" ref="0"?><?Pub Tag atict:user user="sharonr" fullname="Sharon Veach"?><?Pub Tag atict:user
user="mseif" fullname=""?><title>Administering NIS (Tasks)</title><highlights><para>This chapter describes how to administer NIS. The following topics are
covered.</para><itemizedlist><listitem><para><olink targetptr="anis2-32914" remap="internal">Password Files and Namespace
Security</olink></para>
</listitem><listitem><para><olink targetptr="anis2-38485" remap="internal">Administering NIS Users</olink></para>
</listitem><listitem><para><olink targetptr="anis2-11278" remap="internal">Working With NIS Maps</olink></para>
</listitem><listitem><para><olink targetptr="anis2-1010" remap="internal">Updating and Modifying Existing
Maps</olink></para>
</listitem><listitem><para><olink targetptr="anis2-34392" remap="internal">Adding a Slave Server</olink></para>
</listitem><listitem><para><olink targetptr="anis2-25789" remap="internal">Using NIS With C2 Security</olink></para>
</listitem><listitem><para><olink targetptr="anis2-16615" remap="internal">Changing a Machine's NIS Domain</olink></para>
</listitem><listitem><para><olink targetptr="anis2-21536" remap="internal">Using NIS in Conjunction With
DNS</olink></para>
</listitem><listitem><para><olink targetptr="anis2-22142" remap="internal">Turning Off NIS Services</olink></para>
</listitem>
</itemizedlist><note><para>The NIS service is managed by the Service Management Facility.
Administrative actions on this service, such as enabling, disabling, or restarting,
can be performed by using the <command>svcadm</command> command. See <olink targetptr="cnis1-55" remap="internal">NIS and the Service Management Facility</olink> for more
information about using SMF with NIS. For an overview of SMF, refer to <olink targetdoc="sysadv1" targetptr="hbrunlevels-25516" remap="external">Chapter 16, <citetitle remap="chapter">Managing Services (Overview),</citetitle> in <citetitle remap="book">System Administration Guide: Basic Administration</citetitle></olink>.
Also refer to the<olink targetdoc="group-refman" targetptr="svcadm-1m" remap="external"><citerefentry><refentrytitle>svcadm</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> and <olink targetdoc="group-refman" targetptr="svcs-1" remap="external"><citerefentry><refentrytitle>svcs</refentrytitle><manvolnum>1</manvolnum></citerefentry></olink> man pages for more details.</para><para>NIS services can also be started and stopped by using the <command>ypstart</command> and <command>ypstop</command> commands. See the <olink targetdoc="group-refman" targetptr="ypstart-1m" remap="external"><citerefentry><refentrytitle>ypstart</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> and <olink targetdoc="group-refman" targetptr="ypstop-1m" remap="external"><citerefentry><refentrytitle>ypstop</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man pages
for more information.</para>
</note>
</highlights><sect1 id="anis2-32914"><title>Password Files and Namespace Security</title><indexterm><primary>NIS</primary><secondary>security</secondary>
</indexterm><indexterm><primary>security</primary><secondary>NIS, and</secondary>
</indexterm><indexterm><primary>password data</primary><secondary>NIS, and</secondary>
</indexterm><para>For security reasons, follow these guidelines.</para><itemizedlist><listitem><para>It is best to limit access to the NIS maps on the master server.</para>
</listitem><listitem><para><indexterm><primary>NIS</primary><secondary>root entry</secondary></indexterm><indexterm><primary>security</primary><secondary>root in NIS maps</secondary></indexterm><indexterm><primary>password data</primary><secondary>root in NIS maps</secondary></indexterm>The files used to build the NIS password maps
should not contain an entry for <literal>root</literal> to protect against
unauthorized access. To accomplish this, the password files used to build
the password maps should have the <literal>root</literal> entry removed from
them and be located in a directory other than the master server's <filename>/etc</filename> directory.
This directory should be secured against unauthorized access.</para>
</listitem>
</itemizedlist><para><indexterm><primary><filename>/var/yp</filename> directories</primary><secondary>NIS security</secondary></indexterm><indexterm><primary><filename>Makefile</filename> file</primary><secondary>NIS security</secondary></indexterm>For
example, the master server password input files could be stored in a directory
such as <filename>/var/yp</filename>, or any directory of your choice, as
long as the file itself is not a link to another file and is specified in
the Makefile. When you use either the Service Management Facility or the <command>ypstart</command> script to start the NIS service, the correct directory option
is set according to the configuration specified in your <filename>Makefile</filename>.</para><note><para><indexterm><primary><filename>passwd</filename> file</primary><secondary>Solaris 1.x formats</secondary></indexterm><indexterm><primary><filename>shadow</filename> file</primary><secondary>Solaris 1.x formats</secondary></indexterm>In addition to the older Solaris 1 version <filename>passwd</filename> file
format, this implementation of NIS accepts the Solaris 2 <filename>passwd</filename> and <filename>shadow</filename> file formats as input for building the NIS password maps.</para>
</note>
</sect1><sect1 id="anis2-38485"><title>Administering NIS Users</title><indexterm><primary>NIS</primary><secondary>users, administering</secondary>
</indexterm><indexterm><primary>users</primary><secondary>NIS</secondary>
</indexterm><para>This section includes information about setting user passwords, adding
new users to an NIS domain, and assigning users to <literal>netgroups</literal>.</para><task id="anis2-1"><title>How to Add a New NIS User to an NIS Domain</title><procedure><step id="anis2-step-33"><para>On the master NIS server, become superuser
or assume an equivalent role.</para><para>Roles contain authorizations and
privileged commands. For more information about roles, see <olink targetdoc="sysadv6" targetptr="rbactask-1" remap="external">Chapter 9, <citetitle remap="chapter">Using Role-Based Access Control (Tasks),</citetitle> in <citetitle remap="book">System Administration Guide: Security Services</citetitle></olink>.</para>
</step><step id="anis2-step-4"><para><indexterm><primary><command>useradd</command></primary></indexterm><indexterm><primary>NIS</primary><secondary><command>useradd</command></secondary></indexterm><indexterm><primary>users</primary><secondary><command>useradd</command></secondary></indexterm>Create the new user's login ID with the <command>useradd</command> command.</para><screen># <userinput>useradd <replaceable>userID</replaceable></userinput></screen><para><replaceable>userID</replaceable> is the login ID of the new user. This
command creates entries in the <filename>/etc/passwd</filename> and <filename>/etc/shadow</filename> files on the master NIS server.</para>
</step><step id="anis2-step-5"><para>Create the new user's initial password.</para><para>To create an initial password that the new user can use to log in, run
the <command>passwd</command> command.</para><screen># <userinput>passwd <replaceable>userID</replaceable></userinput></screen><para>Where <replaceable>userID</replaceable> is the login ID of the new user.
You will be prompted for the password to assign to this user.</para><para><indexterm><primary><command>useradd</command></primary><secondary>password is locked</secondary></indexterm><indexterm><primary>NIS</primary><secondary>user password locked</secondary></indexterm>This step is necessary because the
password entry created by the <command>useradd</command> command is locked,
which means that the new user cannot log in. By specifying an initial password,
you unlock the entry.</para>
</step><step id="anis2-step-6"><para><indexterm><primary><filename>passwd</filename> maps</primary><secondary>users, adding</secondary></indexterm>If necessary, copy
the new entry into the server's <filename>passwd</filename> map input files.</para><para>The map source files on your master server should be in a directory
other than <filename>/etc</filename>. Copy and paste the new lines from the <filename>/etc/passwd</filename> and <filename>/etc/shadow</filename> files into the <filename>passwd</filename> map input files on the server. See <olink targetptr="anis2-32914" remap="internal">Password Files and Namespace Security</olink> for
additional information.</para><para>For example, if you added the new user <literal>brown</literal>, the
line from <filename>/etc/passwd</filename> that you would copy to your <literal>passwd</literal> input file would look like the following.</para><screen>brown:x:123:10:User brown:/home/brown:/bin/csh:</screen><para>The line for <literal>brown</literal> that you would copy from <filename>/etc/shadow</filename> would look like:</para><screen>brown:W12345GkHic:6445::::::</screen>
</step><step id="anis2-step-7"><para>Make sure that the <filename>Makefile</filename> correctly
specifies the directory where the password input file resides.</para>
</step><step id="anis2-step-88"><para>If appropriate, delete the new user's entries
from <filename>/etc/passwd</filename> and <filename>/etc/shadow</filename> input
files.</para><para><indexterm><primary><command>userdel</command></primary></indexterm><indexterm><primary>NIS</primary><secondary><command>userdel</command></secondary></indexterm><indexterm><primary>users</primary><secondary><command>userdel</command> (NIS)</secondary></indexterm>For security reasons, do not keep user entries in
the NIS master server <filename>/etc/passwd</filename> and <filename>/etc/shadow</filename> files.
After copying the entries for the new user to the NIS map source files that
are stored in some other directory, use the <command>userdel</command> command
on the master server to delete the new user.</para><para>For example, to delete the new user <literal>brown</literal> from the
master server's <filename>/etc</filename> files, you would enter the following.</para><screen># <userinput>userdel brown</userinput></screen><para><indexterm><primary><command>userdel</command></primary></indexterm>For
more information about <command>userdel</command>, see the <command>userdel</command> man
page.</para>
</step><step id="anis2-step-999"><para><indexterm><primary>NIS</primary><secondary>updating <literal>passwd</literal> maps</secondary></indexterm><indexterm><primary>users</primary><secondary>updating <filename>passwd</filename> maps</secondary></indexterm>Update
the NIS <literal>passwd</literal> maps.</para><para>After you have updated
the <filename>passwd</filename> input file on the master server, update the <filename>passwd</filename> maps by running <command>make</command> in the directory
containing the source file.</para><screen># <userinput>userdel brown</userinput>
# <userinput>cd /var/yp</userinput>
# <userinput>/usr/ccs/bin/make passwd</userinput></screen>
</step><step id="anis2-step-1000"><para>Tell the new user the initial password you
have assigned to his or her login ID.</para><para>After logging in, the new
user can run <filename>passwd</filename> at any time to establish a different
password.</para>
</step>
</procedure>
</task><sect2 id="anis2-11"><title>Setting User Passwords</title><indexterm><primary>NIS</primary><secondary>passwords, user</secondary>
</indexterm><indexterm><primary>users</primary><secondary>passwords (NIS)</secondary>
</indexterm><indexterm><primary>passwords</primary><secondary>NIS, and</secondary>
</indexterm><para><indexterm><primary><command>passwd</command></primary></indexterm>Users
run <command>passwd</command> to change their passwords.</para><para>% <userinput>passwd <replaceable>username</replaceable></userinput></para><para><indexterm><primary>passwords</primary><secondary><command>rpc.yppasswdd</command> (NIS)</secondary></indexterm><indexterm><primary>NIS</primary><secondary><command>rpc.yppasswdd</command></secondary></indexterm><indexterm><primary><command>rpc.yppasswdd</command></primary></indexterm>Before users can change their passwords, you must start the <command>rpc.yppasswdd</command> daemon on the master server to update the password
file.</para><para>The <command>rpc.yppasswdd</command> daemon starts automatically on
the master server. Notice that when the <option>m</option> option is given
to <command>rpc.yppasswdd</command>, a <command>make</command> is forced in <filename>/var/yp</filename> immediately following a modification of the file. If you
want to avoid having this <command>make</command> take place each time the <filename>passwd</filename> file is changed, remove the <option>m</option> option from
the <command>rpc.yppasswd</command> command in the <command>ypstart</command> script
and control the pushing of the <filename>passwd</filename> maps through the <filename>crontab</filename> file.</para><note><para><indexterm><primary><filename>ypstart</filename> script</primary></indexterm><indexterm><primary><filename>passwd.adjunct</filename> file</primary></indexterm><indexterm><primary><command>rpc.yppasswdd</command></primary></indexterm>No arguments should follow the <command>rpc.yppasswd</command> <option>m</option> command. Although you can edit the <filename>ypstart</filename> script
file to achieve a different action, it is not recommended that you modify
this file other than optionally removing the <option>m</option> option. All
commands and daemons invoked by this file with the proper set of command line
parameters. If you choose to edit this file, be especially careful when editing
the <command>rpc.yppasswdd</command> command. If you add an explicit call
to the <filename>passwd.adjunct</filename> file, the exact <envar>$PWDIR/security/passwd.adjunct</envar> path must be used; otherwise, incorrect processing results.</para>
</note>
</sect2><sect2 id="anis2-14244"><title>NIS Netgroups</title><indexterm><primary>NIS</primary><secondary>netgroups</secondary>
</indexterm><indexterm><primary>users</primary><secondary>netgroups</secondary>
</indexterm><indexterm><primary>groups</primary><secondary>netgroups (NIS)</secondary>
</indexterm><para>NIS netgroups are groups (sets) of users or machines that you define
for your administrative purposes. For example, you can create netgroups that
do the following.</para><itemizedlist><listitem><para>Define a set of users who can access a specific machine</para>
</listitem><listitem><para>Define a set of NFS client machines to be given some specific
file system access</para>
</listitem><listitem><para>Define a set of users who are to have administrator privileges
on all the machines in a particular NIS domain</para>
</listitem>
</itemizedlist><para>Each netgroup is given a netgroup name. Netgroups do not directly set
permissions or access rights. Instead, the netgroup names are used by other
NIS maps in places where a user name or machine name would normally be used.
For example, suppose you created a netgroup of network administrators called <literal>netadmins</literal>. To grant all members of the <literal>netadmins</literal> group
access to a given machine, you need only add a <literal>netadmin</literal> entry
to that machine's  <filename>/etc/passwd</filename> file. Netgroup names can
also be added to the <filename>/etc/netgroup</filename> file and propagated
to the NIS <literal>netgroup</literal> map. See <olink targetdoc="group-refman" targetptr="netgroup-4" remap="external"><citerefentry><refentrytitle>netgroup</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> for more detailed information
on using netgroups.</para><para><indexterm><primary><filename>netgroup</filename> file</primary></indexterm><indexterm><primary><filename>netgroup.byuser</filename> file</primary></indexterm><indexterm><primary><filename>netgroup.byhost</filename> file</primary></indexterm>On a network using NIS, the <filename>netgroup</filename> input
file on the master NIS server is used for generating three maps: <filename>netgroup</filename>, <filename>netgroup.byuser</filename>, and <filename>netgroup.byhost</filename>.
The  <filename>netgroup</filename> map contains the basic information in the <filename>netgroup</filename> input file. The two other NIS maps contain information
in a format that speeds lookups of netgroup information, given the machine
or user.</para><para>Entries in the <literal>netgroup</literal> input file are in the format: <replaceable>name ID</replaceable>, where <replaceable>name</replaceable> is the name you
give to a netgroup, and <replaceable>ID</replaceable> identifies a machine
or user who belongs to the netgroup. You can specify as many IDs (members)
to a netgroup as you want, separated by commas. For example, to create a netgroup
with three members, the <filename>netgroup</filename> input file entry would
be in the format:  <replaceable>name</replaceable> <replaceable>ID</replaceable>, <replaceable>ID</replaceable>, <replaceable>ID</replaceable>. The member IDs in a <filename>netgroup</filename> input file entry are in the following format.</para><screen>([-|<replaceable>machine</replaceable>], [-|<replaceable>user</replaceable>], [<replaceable>domain</replaceable>])</screen><para>Where <replaceable>machine</replaceable> is a machine name, <replaceable>user</replaceable> is a user ID, and <replaceable>domain</replaceable> is the
machine or user's NIS domain. The <emphasis>domain</emphasis> element is optional
and should only be used to identify machines or users in some other NIS domain.
The <replaceable>machine</replaceable> and <replaceable>user</replaceable> element
of each member's entry are required, but a dash (<literal>-</literal>) is
used to denote a null. There is no necessary relationship between the machine
and user elements in an entry.</para><para><indexterm><primary><filename>netgroup</filename> file</primary><secondary>entries, example</secondary></indexterm>The following are two sample <filename>netgroup</filename> input file entries, each of which create a netgroup named <literal>admins</literal> composed of the users <literal>hauri</literal> and <literal>juanita</literal> who is in the remote domain <literal>sales</literal> and the machines <literal>altair</literal> and <literal>sirius</literal>.</para><screen>admins (altair, hauri), (sirius,juanita,sales)</screen><screen>admins (altair,-), (sirius,-), (-,hauri), (-,juanita,sales)</screen><para><indexterm><primary>NIS</primary><secondary>netgroups</secondary></indexterm><indexterm><primary>users</primary><secondary>netgroups</secondary></indexterm><indexterm><primary>groups</primary><secondary>netgroups (NIS)</secondary></indexterm>Various programs use the netgroup NIS maps for permission checking
during login, remote mount, remote login, and remote shell creation. These
programs include <command>mountd</command>, <command>login</command>, <command>rlogin</command>, and <command>rsh</command> . The <command>login</command> command
consults the netgroup maps for user classifications if it encounters netgroup
names in the <command>passwd</command> database. The <command>mountd</command> daemon
consults the netgroup maps for machine classifications if it encounters netgroup
names in the <filename>/etc/dfs/dfstab</filename> file. <command>rlogin</command> and <command>rsh</command> In fact, any program that uses the <command>ruserok</command> interface
consults the netgroup maps for both machine and user classifications if they
encounter netgroup names in the <filename>/etc/hosts.equiv</filename> or <filename>.rhosts</filename> files.</para><para>If you add a new NIS user or machine to your network, be sure to add
them to appropriate netgroups in the <filename>netgroup</filename> input file.
Then use the <command>make</command> and <command>yppush</command> commands
to create the netgroup maps and push them to all of your NIS servers. See <olink targetdoc="group-refman" targetptr="netgroup-4" remap="external"><citerefentry><refentrytitle>netgroup</refentrytitle><manvolnum>4</manvolnum></citerefentry></olink> for detailed
information on using netgroups and netgroup input file syntax.</para>
</sect2>
</sect1><sect1 id="anis2-11278"><title>Working With NIS Maps</title><indexterm><primary>NIS maps</primary><secondary>administering</secondary>
</indexterm><para>This section contains the following information:</para><itemizedlist><listitem><para><olink targetptr="anis2-41232" remap="internal">Obtaining Map Information</olink></para>
</listitem><listitem><para><olink targetptr="anis2-42736" remap="internal">Changing a Map's Master Server</olink></para>
</listitem><listitem><para><olink targetptr="anis2-40083" remap="internal">Modifying Configuration Files</olink></para>
</listitem><listitem><para><olink targetptr="anis2-20638" remap="internal">Modifying and Using the Makefile</olink></para>
</listitem>
</itemizedlist><sect2 id="anis2-41232"><title>Obtaining Map Information</title><indexterm><primary>NIS maps</primary><secondary>displaying contents</secondary>
</indexterm><para>Users can obtain information from and about the maps at any time by
using the <command>ypcat</command>, <command>ypwhich</command>, and <command>ypmatch</command> commands. In the examples that follow, <replaceable>mapname</replaceable> refers
both to the official name of a map and to its nickname, if any.</para><para>To list all the values in a map, type the following.</para><screen>% <userinput>ypcat <replaceable>mapname</replaceable></userinput></screen><para>To list both the keys and the values (if any) in a map, type the following.</para><screen>% <userinput>ypcat</userinput> <option>k</option> <userinput><replaceable>mapname</replaceable></userinput></screen><para>To list all the map nicknames, type any of the following commands.</para><screen>% <userinput>ypcat</userinput> <option>x</option><userinput></userinput>
% <userinput>ypmatch</userinput> <option>x</option><userinput></userinput>
% <userinput>ypwhich</userinput> <option>x</option><userinput></userinput></screen><para>To list all the available maps and their master(s), type the following.</para><screen>% <userinput>ypwhich</userinput> <option>m</option><userinput></userinput></screen><para>To list the master server for a particular map, type the following.</para><screen>% <userinput>ypwhich</userinput> <option>m</option> <userinput><replaceable>mapname</replaceable></userinput></screen><para>To match a key with an entry in a map, type the following.</para><screen>% <userinput>ypmatch <replaceable>key</replaceable> <replaceable>mapname</replaceable></userinput></screen><para>If the item you are looking for is not a key in a map, type the following.</para><screen>% <userinput>ypcat <replaceable>mapname</replaceable> | grep <replaceable>item</replaceable></userinput></screen><para>where <replaceable>item</replaceable> is the information for which you
are searching. To obtain information about other domains, use the <option>d
domainname</option> options of these commands.</para><para>If the machine requesting information for a domain other than its default
does not have a binding for the requested domain, <command>ypbind</command>consults
the <filename>/var/yp/binding/</filename><replaceable>domainname</replaceable><filename>/ypservers</filename> file for a list of servers for that domain. If this
file does not exist it issues an RPC broadcast for a server. In this case,
there must be a server for the requested domain on the same subnet as the
requesting machine. </para>
</sect2><sect2 id="anis2-42736"><title>Changing a Map's Master Server</title><indexterm><primary>NIS maps</primary><secondary>changing server</secondary>
</indexterm><para><indexterm><primary><command>makedbm</command></primary><secondary>changing map server</secondary></indexterm><indexterm><primary><command>ypxfr</command> command</primary><secondary> changing map server</secondary></indexterm>To change
the master server for a selected map, you first have to build the map on the
new NIS master. Since the old master server name occurs as a key-value pair
in the existing map (this pair is inserted automatically by <command>makedbm</command>),
copying the map to the new master or transferring a copy to the new master
with <command>ypxfr</command> is insufficient. You have to reassociate the
key with the new master server name. If the map has an ASCII source file,
you should copy this file to the new master.</para><task id="anis2-proc-12"><title>How to Change a Map's Master Server</title><procedure><step id="anis2-step-1011"><para>On the new master, become superuser or assume
an equivalent role.</para><para>Roles contain authorizations and privileged
commands. For more information about roles, see <olink targetdoc="sysadv6" targetptr="rbactask-1" remap="external">Chapter 9, <citetitle remap="chapter">Using Role-Based Access Control (Tasks),</citetitle> in <citetitle remap="book">System Administration Guide: Security Services</citetitle></olink>.</para>
</step><step id="anis2-step-13"><para>Change directories.</para><screen>newmaster# <userinput>cd /var/yp</userinput></screen>
</step><step id="anis2-step-14"><para><indexterm><primary><filename>Makefile</filename> file</primary><secondary>changing a map's master server</secondary></indexterm>The <filename>Makefile</filename> must have an entry for the new map before you specify
the map to make. If this is not the case, edit the <filename>Makefile</filename> now,
using a map called <literal>sites.byname</literal>.</para>
</step><step id="anis2-step-15"><para>To update or remake the map, type the following.</para><screen>newmaster# <userinput>make sites.byname</userinput></screen>
</step><step id="anis2-step-16"><para>If the old master remains an NIS server, remote
log in (<command>rlogin</command>) to the old master and edit <filename>Makefile</filename>.
Make sure you comment out the section of the <filename>Makefile</filename> that
made <filename>sites.byname</filename> so that it is no longer made there.</para>
</step><step id="anis2-step-17"><para><indexterm><primary><filename>sites.byname</filename> file</primary><secondary>changing map server</secondary></indexterm><indexterm><primary><command>ndbm</command> file</primary><secondary>changing map server</secondary></indexterm><indexterm><primary><command>makedbm</command></primary><secondary>changing map server</secondary></indexterm>If <filename>sites.byname</filename> only
exists as an <command>ndbm</command> file, remake it on the new master by
disassembling a copy from any NIS server, then running the disassembled version
through <command>makedbm</command>.</para><screen>newmaster# <userinput>cd /var/yp</userinput>
newmaster# <userinput>ypcat sites.byname | makedbm</userinput> <option></option><replaceable>domain</replaceable><option></option><userinput>/sites.byname</userinput></screen><para><indexterm><primary><command>yppush</command> command</primary><secondary>changing map server</secondary></indexterm>After making the map on the new master,
you must send a copy of the new map to the other slave servers. Do not use <command>yppush</command>, because the other slaves will try to get new copies from
the old master, rather than the new one. A typical method for circumventing
this is to transfer a copy of the map from the new master back to the old
master. To do this, become superuser, or assume an equivalent role, on the
old master server and type the following.</para><screen>oldmaster# <userinput>/usr/lib/netsvc/yp/ypxfr</userinput> <option>h</option> <userinput>newmaster sites.byname</userinput></screen><para>Now it is safe to run <command>yppush</command>. Any remaining slave
servers still believe that the old master is the current master and will attempt
to get the current version of the map from the old master. When clients do
so, they will get the new map, which names the new master as the current master.</para><para><indexterm><primary><command>ypxfr</command> command</primary><secondary>changing map server</secondary></indexterm>If this method fails, you can log in as
root on each NIS server and execute the <command>ypxfr</command> command shown
above.</para>
</step>
</procedure>
</task>
</sect2><sect2 id="anis2-40083"><title>Modifying Configuration Files</title><indexterm><primary>NIS</primary><secondary>modifying configuration files</secondary>
</indexterm><indexterm><primary>NIS maps</primary><secondary>modifying configuration files</secondary>
</indexterm><para>NIS intelligently parses the setup files. Although this makes NIS administration
easier, it does make the behavior of NIS more sensitive to changes in the
setup and configuration files.</para><para>Use the procedures in this section when modifying any of the following.</para><itemizedlist><listitem><para><indexterm><primary><filename>/var/yp/Makefile</filename></primary><secondary>maps</secondary><tertiary>supported list</tertiary></indexterm><indexterm><primary><filename>Makefile</filename> file</primary><secondary>maps</secondary><tertiary>supported list</tertiary></indexterm><filename>/var/yp/Makefile</filename> to
add or delete supported maps</para>
</listitem><listitem><para>Adding or deleting <filename>/etc/resolv.conf</filename> to
allow or deny DNS forwarding</para>
</listitem><listitem><para><indexterm><primary><filename>$PWDIR/security/passwd.adjunct</filename></primary></indexterm><indexterm><primary><filename>passwd.adjunct</filename> file</primary></indexterm>Adding or deleting <filename>$PWDIR/security/passwd.adjunct</filename> to
allow or deny C2 security (<envar>$PWDIR</envar> is defined in <filename>/var/yp/Makefile</filename>)</para>
</listitem>
</itemizedlist><task id="anis2-proc-18"><title>How to Modify Configuration Files</title><tasksummary><para>You do not have to stop and start NIS when changing NIS maps or the
map source files.</para><para>Keep the following in mind.</para><itemizedlist><listitem><para>Deleting a map or source file from an NIS master server does
not automatically result in corresponding deletions from slave servers. You
must delete maps and source files from slave servers by hand.</para>
</listitem><listitem><para>New maps do not automatically get pushed to existing slave
servers. You must run <command>ypxfr</command> from the slaves.</para>
</listitem>
</itemizedlist>
</tasksummary><procedure><step id="anis2-step-1002"><para>Become superuser or assume an equivalent
role.</para><para>Roles contain authorizations and privileged commands. For
more information about roles, see <olink targetdoc="sysadv6" targetptr="rbactask-1" remap="external">Chapter 9, <citetitle remap="chapter">Using Role-Based Access Control (Tasks),</citetitle> in <citetitle remap="book">System Administration Guide: Security Services</citetitle></olink>.</para>
</step><step id="anis2-step-19"><para>Stop the NIS server.</para><screen># <userinput>svcadm disable network/nis/server</userinput></screen>
</step><step id="anis2-step-20"><para>Make the necessary changes to your files.</para>
</step><step id="anis2-step-21"><para>Start the NIS server.</para><screen># <userinput>svcadm enable network/nis/server</userinput></screen>
</step>
</procedure>
</task>
</sect2><sect2 id="anis2-20638"><title>Modifying and Using the <filename>Makefile</filename></title><indexterm><primary>NIS maps</primary><secondary><filename>Makefile</filename> and</secondary>
</indexterm><para>You can modify the <filename>Makefile</filename> provided by default
in <filename>/var/yp</filename> to suit your needs. You can add or delete
maps, and you can change the names of some of the directories.</para><tip><para>Keep an unmodified copy of the original <filename>Makefile</filename> for
future reference.</para>
</tip><sect3 id="anis2-1013"><title>Working With the <filename>Makefile</filename></title><para>To add a new NIS map, you must get copies of the <command>ndbm</command> files
for the map into the <filename>/var/yp/</filename><replaceable>domainname</replaceable> directory
on each of the NIS servers in the domain. This is normally done for you by
the <command>Makefile</command>. After deciding which NIS server is the master
of the map, modify the <filename>Makefile</filename> on the master server
so that you can conveniently rebuild the map. Different servers can be masters
of different maps, but in most cases this leads to administrative confusion.
Try to set only one server as the master of all maps.</para><para><indexterm><primary>NIS</primary><secondary><filename>Makefile</filename> filtering</secondary></indexterm><indexterm><primary>NIS maps</primary><secondary><filename>Makefile</filename> filtering</secondary></indexterm>Typically a human-readable
text file is filtered through <command>awk</command>, <command>sed</command>,
or <command>grep</command> to make it suitable for input to <command>makedbm</command>.
Refer to the default <filename>Makefile</filename> for examples. See the <olink targetdoc="group-refman" targetptr="make-1s" remap="external"><citerefentry><refentrytitle>make</refentrytitle><manvolnum>1S</manvolnum></citerefentry></olink> for general information about
the <command>make</command> command.</para><para><indexterm><primary><command>make</command></primary><secondary><filename>Makefile</filename> syntax</secondary></indexterm>Use the mechanisms already in place
in the <filename>Makefile</filename> when deciding how to create dependencies
that <command>make</command> will recognize. Be aware that <command>make</command> is
very sensitive to the presence or absence of tabs at the beginning of lines
within the dependency rules. A missing tab can invalidate an entry that is
otherwise well formed.</para><para>Adding an entry to the <filename>Makefile</filename> involves the following.</para><itemizedlist><listitem><para>Adding the name of the database to the <literal>all</literal> rule</para>
</listitem><listitem><para>Writing the <literal>time</literal> rule</para>
</listitem><listitem><para>Adding the rule for the database</para>
</listitem>
</itemizedlist><para><indexterm><primary><filename>Makefile</filename> file</primary><secondary>automounter maps and</secondary></indexterm><indexterm><primary><filename>auto_direct.time</filename> maps</primary></indexterm><indexterm><primary><filename>auto_home.time</filename> maps</primary></indexterm>For example, in order
for the <filename>Makefile</filename> to work on automounter input files,
you would have to add the <filename>auto_direct.time</filename> and <filename>auto_home.time</filename> maps to the NIS database.</para><para>To add these maps to the NIS database you need to modify the <filename>Makefile</filename>.</para>
</sect3><sect3 id="anis2-33"><title>Changing <filename>Makefile</filename> Macros/Variables</title><indexterm><primary>NIS maps</primary><secondary><filename>Makefile</filename> variables, changing</secondary>
</indexterm><indexterm><primary>NIS maps</primary><secondary><filename>Makefile</filename> macros, changing</secondary>
</indexterm><para>You can change the settings of the variables defined at the top of the <filename>Makefile</filename> by changing the value to the right of the equal sign (=).
For instance, if you do not want to use the files located in <filename>/etc</filename> as
input for the maps, but you would rather use files located in another directory,
such as <filename>/var/etc/domainname</filename>, you should change <envar>DIR</envar> from <literal>DIR=/etc</literal> to <literal>DIR=/var/etc/</literal><replaceable>domainname</replaceable>.
You should also change <literal>PWDIR</literal> from <literal>PWDIR=/etc</literal> to <literal>PWDIR=/var/etc/</literal><replaceable>domainname</replaceable>.</para><para>The variables are the following.</para><itemizedlist><listitem><para><indexterm><primary>NIS maps</primary><secondary><filename>Makefile</filename>, DIR variable</secondary></indexterm><replaceable>DIR</replaceable>=
The directory containing all of the NIS input files except <filename>passwd</filename> and <filename>shadow</filename>. The default value is <filename>/etc</filename>. Since it
is not good practice to use the files in the master server's <filename>/etc</filename> directory
as NIS input files, you should change this value.</para>
</listitem><listitem><para><indexterm><primary>NIS maps</primary><secondary><filename>Makefile</filename>, PWDIR variable</secondary></indexterm><replaceable>PWDIR</replaceable>=
The directory containing the <filename>passwd</filename> and <filename>shadow</filename> NIS
input files. Since it is not good practice to use the files in the master
server's <filename>/etc</filename> directory as NIS input files, you should
change this value.</para>
</listitem><listitem><para><indexterm><primary>NIS maps</primary><secondary><filename>Makefile</filename>, DOM variable</secondary></indexterm><replaceable>DOM</replaceable>=
The NIS domain name. The default value of <literal>DOM</literal> is set using
the <command>domainname</command> command. However, most NIS commands use
the current machine's domain which is set in the machine's <filename>/etc/defaultdomain</filename> file.</para>
</listitem>
</itemizedlist>
</sect3>
</sect2><sect2 id="anis2-1014"><title>Modifying <filename>Makefile</filename> Entries</title><para>The following procedure describes how to add and delete databases from
the <filename>Makefile</filename>.</para><task id="anis2-proc-22"><title>How to Modify the <filename>Makefile</filename> to
Use Specific Databases</title><procedure><step id="anis2-step-9"><para>Become superuser or assume an equivalent role.</para><para>Roles contain authorizations and privileged commands. For more information
about roles, see <olink targetdoc="sysadv6" targetptr="rbactask-1" remap="external">Chapter 9, <citetitle remap="chapter">Using Role-Based Access Control (Tasks),</citetitle> in <citetitle remap="book">System Administration Guide: Security Services</citetitle></olink>.</para>
</step><step id="anis2-step-23"><para>Modify the line that starts with the word <literal>all</literal> by adding the name(s) of the database you want to add:</para><screen>all: passwd group hosts ethers networks rpc services protocols \
	netgroup bootparams aliases netid netmasks \
	audit_user auth_attr exec_attr prof_attr \
  auto_direct auto_home auto_direct.time auto_home.time</screen><para>The order of the entries is not relevant, but the blank space at the
beginning of the continuation lines must be a Tab, not spaces.</para>
</step><step id="anis2-step-24"><para>Add the following lines at the end of the <filename>Makefile</filename>:</para><screen>auto_direct: auto_direct.time
auto_home: auto_home.time</screen>
</step><step id="anis2-step-25"><para>Add an entry for <literal>auto_direct.time</literal> in
the middle of the file.</para><screen>auto_direct.time: $(DIR)/auto_direct
 @(while read L; do echo $$L; done &lt; $(DIR)/auto_direct
 $(CHKPIPE)) | \ (sed -e "/^#/d" -e "s/#.*$$//" -e "/^ *$$/d"
 $(CHKPIPE)) | \ $(MAKEDBM) - $(YPDBDIR)/$(DOM)/auto_direct;
 @touch auto_direct.time;
 @echo "updated auto_direct";
 @if [ ! $(NOPUSH) ]; then $(YPPUSH) auto_direct; fi
 @if [ ! $(NOPUSH) ]; then echo "pushed auto_direct"; fi</screen><para>where</para><itemizedlist><listitem><para><indexterm><primary>NIS maps</primary><secondary><literal>CHKPIPE</literal> in Makefile</secondary></indexterm><indexterm><primary><literal>CHKPIPE</literal></primary></indexterm><literal>CHKPIPE</literal> makes certain that
the operations to the left of the pipe (<literal>|</literal>) are successfully
completed before piping the results to next commands. If the operations to
the left of the pipe do not successfully complete, the process is terminated
with a <literal>NIS make terminated</literal>  message.</para>
</listitem><listitem><para><indexterm><primary><command>yppush</command> command</primary><secondary><filename>Makefile</filename> and</secondary></indexterm><indexterm><primary><command>NOPUSH</command> in <filename>Makefile</filename></primary></indexterm><indexterm><primary>NIS maps</primary><secondary><command>NOPUSH</command> in <filename>Makefile</filename></secondary></indexterm><indexterm><primary>NIS maps</primary><secondary><command>yppush</command> in <filename>Makefile</filename></secondary></indexterm><command>NOPUSH</command> prevents the <command>makefile</command> from
calling <command>yppush</command> to transfer the new map to the slave servers.
If <command>NOPUSH</command> is not set, the push is done automatically.</para>
</listitem>
</itemizedlist><para><indexterm><primary><command>makedbm</command></primary></indexterm>The <literal>while</literal> loop at the beginning is designed to eliminate any backslash-extended
lines in the input file. The <command>sed</command> script eliminates comment
and empty lines.</para><para>The same procedure should be followed for all other automounter maps,
such as <filename>auto_home</filename>, or any other nondefault maps.</para>
</step><step id="anis2-step-26"><para>Run <command>make</command>.</para><screen># <userinput>make <replaceable>mapname</replaceable></userinput></screen><para>Where <emphasis>mapname</emphasis> is the name of the map you want to
make.</para>
</step>
</procedure>
</task><task id="anis2-proc-28"><title>How to Modify the <filename>Makefile</filename> to
Delete Databases</title><tasksummary><para>If you do not want the <command>Makefile</command> to produce maps for
a specific database, edit the <filename>Makefile</filename> as follows.</para>
</tasksummary><procedure><step id="anis2-step-29"><para>Delete the name of the database from the <literal>all</literal> rule.</para>
</step><step id="anis2-step-30"><para>Delete or comment out the database rule for
the database you want to delete.</para><para><indexterm><primary><filename>hosts</filename> database</primary></indexterm>For example, to delete the <filename>hosts</filename> database,
the <literal>hosts.time</literal> entry should be removed.</para>
</step><step id="anis2-step-31"><para>Remove the time rule.</para><para>For example,
to delete the <filename>hosts</filename> database, the <literal>hosts: hosts.time</literal> entry should be removed.</para>
</step><step id="anis2-step-32"><para>Remove the map from the master and slave servers.</para>
</step>
</procedure>
</task>
</sect2>
</sect1><sect1 id="anis2-1010"><title>Updating and Modifying Existing Maps</title><para>After you have installed NIS, you might discover that some maps require
frequent updating while others never need to change. For example, the <filename>passwd.byname</filename> map can change frequently on a large company's network, while
the <filename>auto_master</filename> map changes little, if at all.</para><para>As mentioned in <olink targetptr="anis1-6" remap="internal">Default NIS Maps</olink>,
the default location of the default NIS maps is on the master server in <filename>/var/yp/</filename><parameter>domainname</parameter>, where <parameter>domainname</parameter> is the name of the NIS domain. When you need to update a map,
you can use one of two updating procedures, depending on whether or not it
is a default map.</para><itemizedlist><listitem><para><indexterm><primary><command>ypinit</command> command</primary><secondary>default maps</secondary></indexterm>A default map is a map in the
default set created by <command>ypinit</command> from the network databases.</para>
</listitem><listitem><para><indexterm><primary>NIS maps</primary><secondary>nondefault</secondary></indexterm>Nondefault maps can be any of the following.</para><itemizedlist><listitem><para>Maps included with an application purchased from a vendor</para>
</listitem><listitem><para>Maps created specifically for your site</para>
</listitem><listitem><para>Maps created from a nontext file</para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist><para>The following sections explain how to use various updating tools. In
practice, you might decide to only use them if you add nondefault maps or
change the set of NIS servers after the system is already up and running.</para><task id="anis2-20918"><title>How to Update Maps Supplied With the Default
Set</title><tasksummary><para>Use the following procedure for updating maps supplied with the default
set.</para>
</tasksummary><procedure><step id="anis2-step-36"><para>Become a superuser on the master server.</para><para>Always modify NIS maps only on the master server.</para>
</step><step id="anis2-step-37"><para>Edit the source file for the map you want to
change, whether that file resides in <filename>/etc</filename> or in some
other directory of your choice.</para>
</step><step id="anis2-step-38"><para>Type the following.</para><screen># <userinput>cd /var/yp</userinput>
# <userinput>make <replaceable>mapname</replaceable></userinput></screen><para><indexterm><primary><command>make</command></primary><secondary>after updating maps</secondary></indexterm>The <command>make</command> command then
updates your map according to the changes you made in its corresponding file.
It also propagates the changes among the other servers.</para>
</step>
</procedure>
</task><sect2><title>Maintaining Updated Maps</title><para>The following sections describe additional procedures after you have
completed updating maps that are supplied with the default set.</para><sect3><title>Propagating an NIS Map</title><para>After a map is changed, the <filename>Makefile</filename> uses <command>yppush</command> to propagate a new map to the slave servers (unless <systemitem class="macro">NOPUSH</systemitem> is set in the <filename>Makefile</filename>).
It does this by informing the <command>ypserv</command> daemon and sending
a map transfer request. The <command>ypserv</command> daemon on the slave
then starts a <command>ypxfr</command> process, which in turn contacts the <command>ypxfrd</command> daemon on the master server. Some basic checks are made (for
example did the map really change?) and then the map is transferred. <command>ypxfr</command> on the slave then sends a response to the <command>yppush</command> process
indicating whether the transfer succeeded.</para><note><para><indexterm><primary><filename>crontab</filename> file</primary></indexterm>The above procedure will <emphasis>not</emphasis> work for newly
created maps that do not yet exist on the slave servers. New maps must be
sent to the slave servers by running <command>ypxfr</command> on the slaves.</para>
</note><para>Occasionally, maps fail to propagate and you must to use <command>ypxfr</command> manually
to send new map information. You can choose to use <command>ypxfr</command> in
two different ways: periodically through the root <filename>crontab</filename> file,
or interactively on the command line. These approaches are discussed in the
following sections. </para>
</sect3><sect3><title>Using <filename>cron</filename> for Map Transfers</title><para>Maps have different rates of change. For instance, some might not change
for months at a time, such as <filename>protocols.byname</filename> among
the default maps and <filename>auto_master</filename> among the nondefault
maps; but <filename>passwd.byname</filename> can change several times a day.
Scheduling map transfer using the <command>crontab</command> command allows
you to set specific propagation times for individual maps.</para><para>To periodically run <command>ypxfr</command> at a rate appropriate for
the map, the root <filename>crontab</filename> file on each slave server should
contain the appropriate <command>ypxfr</command> entries. <command>ypxfr</command> contacts
the master server and transfers the map only if the copy on the master server
is more recent than the local copy.</para><note><para><indexterm><primary>NIS</primary><secondary><filename>passwd</filename> maps auto update</secondary></indexterm><indexterm><primary><command>rpc.yppasswdd</command></primary><secondary><command>passwd</command> updates maps</secondary></indexterm><indexterm><primary><command>passwd</command></primary><secondary>NIS map auto updated</secondary></indexterm>If your master server runs <command>rpc.yppasswdd</command> with
the default <option>m</option> option, then each time someone changes their <literal>yp</literal> password, the <command>passwd</command> daemon runs <command>make</command>,
which rebuilds the <filename>passwd</filename> maps.</para>
</note>
</sect3><sect3><title>Using Shell Scripts With <command>cron</command> and <command>ypxfr</command></title><para>As an alternative to creating separate <filename>crontab</filename> entries
for each map, you might prefer to have the root <filename>crontab</filename> command
run a shell script that periodically updates all maps. Sample map-updating
shell scripts are n the <filename>/usr/lib/netsvc/yp</filename> directory.
The script names are <command>ypxfr_1perday</command>, <command>ypxfr_1perhour</command>,
and <command>ypxfr_2perday</command>. You can modify or replace these shell
scripts to fit your site requirements. <olink targetptr="anis2-28903" remap="internal">Example&nbsp;6&ndash;1</olink> shows the default <command>ypxfr_1perday</command> shell script.</para><example id="anis2-28903"><title><literal>ypxfr_1perday</literal> Shell Script</title><screen>#! /bin/sh
#
# ypxfr_1perday.sh - Do daily yp map check/updates
PATH=/bin:/usr/bin:/usr/lib/netsvc/yp:$PATH
export PATH
# set -xv
ypxfr group.byname
ypxfr group.bygid
ypxfr protocols.byname
ypxfr protocols.bynumber
ypxfr networks.byname
ypxfr networks.byaddr
ypxfr services.byname
ypxfr ypservers</screen>
</example><para>This shell script updates the maps once per day, if the root <command>crontab</command> is executed daily. You can also have scripts that update maps once
a week, once a month, once every hour, and so forth, but be aware of the performance
degradation implied in frequently propagating the maps.</para><para>Run the same shell scripts as root on each slave server configured for
the NIS domain. Alter the exact time of execution from one server to another
to avoid bogging down the master.</para><para>If you want to transfer the map from a particular slave server, use
the <option>h</option> <replaceable>machine</replaceable> option of <command>ypxfr</command> within the shell script. Here is the syntax of the commands you
put in the script.</para><screen># <userinput>/usr/lib/netsvc/yp/ypxfr</userinput> <option>h</option> <userinput><replaceable>machine</replaceable> [</userinput> <option>c</option> <userinput>] <replaceable>mapname</replaceable></userinput></screen><para>Where <replaceable>machine</replaceable> is the name of the server with
the maps you want to transfer, and <replaceable>mapname</replaceable> is the
name of the requested map. If you use the <option>h</option> option without
specifying a machine, <command>ypxfr</command> tries to get the map from the
master server. If <command>ypserv</command> is not running locally at the
time <command>ypxfr</command> is executed, you must use the <option>c</option> flag
so that <command>ypxfr</command> does not send a clear current map request
to the local <command>ypserver</command>.</para><para>You can use the <option>s</option> <replaceable>domain</replaceable> option
to transfer maps from another domain to your local domain. These maps should
be the same across domains. For example, two domains might share the same <filename>services.byname</filename> and <filename>services.byaddr</filename> maps.
Alternatively, you can use <command>rcp</command>, or <command>rdist</command> for
more control, to transfer files across domains.</para>
</sect3><sect3><title>Directly Invoking <command>ypxfr</command></title><para>The second method of invoking <command>ypxfr</command> is to run it
as a command. Typically, you do this only in exceptional situations &ndash;
for example, when setting up a temporary NIS server to create a test environment
or when trying to quickly get an NIS server that has been out of service consistent
with the other servers.</para>
</sect3><sect3><title>Logging <command>ypxfr</command> Activity</title><para>The transfer attempts and results of <command>ypxfr</command> can be
captured in a log file. If a file called <filename>/var/yp/ypxfr.log</filename> exists,
results are appended to it. No attempt to limit the size of the log file is
made. To prevent it from growing indefinitely, empty it from time to time
by typing the following.</para><screen># <userinput>cd /var/yp</userinput>
# <userinput>cp ypxfr.log ypxfr.log.old</userinput>
# <userinput>cat /dev/null &gt; /var/yp/ypxfr.log</userinput></screen><para>You can have <command>crontab</command> execute these commands once
a week. To turn off logging, remove the log file.</para>
</sect3>
</sect2><sect2 id="anis2-1003"><title>Modifying Default Maps</title><para>To update a nondefault map, you must do the following.</para><orderedlist><listitem><para>Create or edit its corresponding text file.</para>
</listitem><listitem><para>Build (or rebuild) the new or updated map. There are two ways
to build a map.</para><itemizedlist><listitem><para><indexterm><primary><filename>Makefile</filename> file</primary><secondary>non-default maps</secondary><tertiary>modifying</tertiary></indexterm>Use the Makefile. Using the Makefile is the preferred method of
building a non-default map. If the map has an entry in the <filename>Makefile</filename>,
run <command>make</command> <replaceable>name</replaceable> where <replaceable>name</replaceable> is the name of map you want to build. If the map does not have
a <filename>Makefile</filename> entry, try to create one following the instructions
in <olink targetptr="anis2-20638" remap="internal">Modifying and Using the Makefile</olink>.</para>
</listitem><listitem><para>Use the <command>/usr/sbin/makedbm</command> program. <olink targetdoc="group-refman" targetptr="makedbm-1m" remap="external"><citerefentry><refentrytitle>makedbm</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> fully describes
this command.</para>
</listitem>
</itemizedlist>
</listitem>
</orderedlist>
</sect2><sect2 id="anis2-1004"><title>Using <filename>makedbm</filename> to Modify
a Non-Default Map</title><indexterm><primary><command>/usr/sbin/makedbm</command></primary><secondary>non-default maps, modifying</secondary>
</indexterm><para><indexterm><primary><command>makedbm</command></primary></indexterm>There
are two different methods for using <command>makedbm</command> to modify maps
if you do not have an input file:</para><itemizedlist><listitem><para>Redirect the <command>makedbm</command> <option>u</option> output
to a temporary file, modify the file, then use the modified file as input
to <command>makedbm</command>.</para>
</listitem><listitem><para><indexterm><primary><command>sed</command></primary></indexterm><indexterm><primary><command>awk</command></primary></indexterm>Have the output of <command>makedbm</command> <option>u</option> operated on within a pipeline that feeds
into <command>makedbm</command>. This is appropriate if you can update the
disassembled map with either <command>awk</command>, <command>sed</command>,
or a <command>cat</command> append.</para>
</listitem>
</itemizedlist>
</sect2><sect2 id="anis2-1005"><title>Creating New Maps from Text Files</title><indexterm><primary>NIS maps</primary><secondary>new maps, creating from files</secondary>
</indexterm><para>Assume that a text file <filename>/var/yp/mymap.asc</filename> was created
with an editor or a shell script on the master. You want to create an NIS
map from this file and locate it in the <replaceable>homedomain</replaceable> subdirectory.
To do this, type the following on the master server.</para><screen># <userinput>cd /var/yp</userinput>
# <userinput>makedbm <replaceable>mymap</replaceable>.asc <replaceable>homedomain</replaceable>/<replaceable>mymap</replaceable></userinput></screen><para><indexterm><primary><command>ypxfr</command> command</primary><secondary>distributing new maps to slave servers</secondary></indexterm>The <replaceable>mymap</replaceable> map
now exists on the master server in the directory <replaceable>homedomain</replaceable>.
To distribute the new map to slave servers run <command>ypxfr</command>.</para>
</sect2><sect2 id="anis2-1006"><title>Adding Entries to a File-Based Map</title><para><indexterm><primary><filename>/var/yp/</filename></primary></indexterm><indexterm><primary><filename>.asc</filename></primary></indexterm><indexterm><primary><command>dbm</command></primary></indexterm>Adding entries to <literal>mymap</literal> is
simple. First, you must modify the text file <filename>/var/yp/</filename><replaceable>mymap</replaceable>.<filename>asc</filename>. If you modify the actual <command>dbm</command> files without modifying the corresponding text file, the modifications
are lost. Then run <command>makedbm</command> as shown above. </para>
</sect2><sect2 id="anis2-1007"><title>Creating Maps From Standard Input</title><indexterm><primary>NIS maps</primary><secondary>new maps, creating from keyboard</secondary>
</indexterm><para><indexterm><primary><command>makedbm</command></primary></indexterm>When
no original text file exists, create the NIS map from the keyboard by typing
input to <command>makedbm</command>, as shown below (end with Control-D).</para><screen>ypmaster# <userinput>cd /var/yp</userinput>
ypmaster# <userinput>makedbm</userinput> <option></option><replaceable>homedomain</replaceable><option></option><userinput>/mymap<replaceable>key1 value1</replaceable> <replaceable>key2 value2</replaceable> <replaceable>key3 value3</replaceable></userinput></screen>
</sect2><sect2 id="anis2-1008"><title>Modifying Maps Made From Standard Input</title><para><indexterm><primary><command>makedbm</command></primary></indexterm>If
you later need to modify the map, you can use <command>makedbm</command> to
disassemble the map and create a temporary text intermediate file. To disassemble
the map and create a temporary file, type the following.</para><screen>% <userinput>cd /var/yp</userinput>
% <userinput>makedbm</userinput> <option>u</option> <userinput><replaceable>homedomain</replaceable>/<replaceable>mymap</replaceable> &gt; <replaceable>mymap</replaceable>.temp</userinput></screen><para>The resulting temporary file <replaceable>mymap</replaceable><filename>.temp</filename> has one entry per line. You can edit this file as needed, using
any text editor.</para><para>To update the map, give the name of the modified temporary file to <command>makedbm</command> by typing the following.</para><screen>% <userinput>makedbm <replaceable>mymap</replaceable>.temp <replaceable>homedomain</replaceable>/<replaceable>mymap</replaceable></userinput>
% <userinput>rm <replaceable>mymap</replaceable>.temp</userinput></screen><para>Then propagate the map to the slave servers, by becoming root and typing
the following.</para><screen># <userinput>yppush <replaceable>mymap</replaceable></userinput></screen><para>The preceding paragraphs explained how to use <command>makedbm</command> to
create maps; however, almost everything you actually have to do can be done
by <command>ypinit</command> and <filename>Makefile</filename> unless you
add nondefault maps to the database or change the set of NIS servers after
the system is already up and running.</para><para><indexterm><primary><command>dbm</command></primary></indexterm>Whether
you use the <filename>Makefile</filename> in <filename>/var/yp</filename> or
some other procedure the goal is the same. Anew pair of well-formed <command>dbm</command> files
must end up in the maps directory on the master server.</para>
</sect2>
</sect1><sect1 id="anis2-34392"><title>Adding a Slave Server</title><indexterm><primary>NIS slave servers</primary><secondary>adding</secondary>
</indexterm><para>After NIS is running, you might need to create an NIS slave server that
you did not include in the initial list given to <command>ypinit</command>.</para><para>To add an NIS slave server:</para><task id="anis2-proc-51"><title>How to Add a Slave Server</title><procedure><step id="anis2-step-52"><para>On the master server, become superuser or assume
an equivalent role.</para><para>Roles contain authorizations and privileged
commands. For more information about roles, see <olink targetdoc="sysadv6" targetptr="rbactask-1" remap="external">Chapter 9, <citetitle remap="chapter">Using Role-Based Access Control (Tasks),</citetitle> in <citetitle remap="book">System Administration Guide: Security Services</citetitle></olink>.</para>
</step><step id="anis2-step-53"><para>Change to the NIS domain directory.</para><screen># <userinput>cd /var/yp/<replaceable>domainname</replaceable></userinput></screen>
</step><step id="anis2-step-54"><para><indexterm><primary><filename>ypservers</filename> file</primary><secondary>adding slave server</secondary></indexterm><indexterm><primary>NIS</primary><secondary><filename>ypservers</filename> file</secondary></indexterm><indexterm><primary>servers</primary><secondary><filename>ypservers</filename> file</secondary></indexterm>Disassemble the <filename>ypservers</filename> file.</para><screen># <userinput>makedbm</userinput> <option>u</option> <userinput>ypservers &gt;/tmp/temp_file</userinput></screen><para><indexterm><primary><command>makedbm</command> command</primary><secondary>adding slave servers</secondary></indexterm>The <command>makedbm</command> command
converts <filename>ypservers</filename> from <command>ndbm</command> format
to a temporary ASCII file <filename>/tmp/temp_file</filename>.</para>
</step><step id="anis2-step-55"><para>Edit the <filename>/tmp/temp_file</filename> file
using a text editor. Add the name of the new slave server to the list of servers.
Then save and close the file.</para>
</step><step id="anis2-step-56"><para><indexterm><primary><filename>ypservers</filename> file</primary><secondary>creating</secondary></indexterm>Run the <command>makedbm</command> command
with <filename>temp_file</filename> as the input file and <filename>ypservers</filename> as
the output file.</para><screen># <userinput>makedbm /tmp/temp_file ypservers</userinput></screen><para><command>makedbm</command> then converts <filename>ypservers</filename> back
into <command>ndbm</command> format.</para>
</step><step id="anis2-step-57"><para>Verify that the <filename>ypservers</filename> map
is correct (since there is no ASCII file for <filename>ypservers</filename>)
by typing the following on the slave.</para><screen>slave3# <userinput>makedbm</userinput> <option>u</option> <userinput>ypservers</userinput></screen><para>The <command>makedbm</command> command displays each entry in <filename>ypservers</filename> on your screen.</para><note><para>If a machine name is not in <filename>ypservers</filename>, it
will not receive updates to the map files because <command>yppush</command> consults
this map for the list of slave servers.</para>
</note>
</step><step id="anis2-step-1012"><para>On the new NIS slave, become superuser or
assume an equivalent role.</para><para>Roles contain authorizations and privileged
commands. For more information about roles, see <olink targetdoc="sysadv6" targetptr="rbactask-1" remap="external">Chapter 9, <citetitle remap="chapter">Using Role-Based Access Control (Tasks),</citetitle> in <citetitle remap="book">System Administration Guide: Security Services</citetitle></olink>.</para>
</step><step id="anis2-step-58"><para>Set up the new slave server's NIS domain directory.</para><para><indexterm><primary><command>ypinit</command> command</primary><secondary>adding slave servers</secondary></indexterm><indexterm><primary><command>ypbind</command> daemon</primary><secondary>adding slave servers</secondary></indexterm>Copy the NIS map set from the master server, then start the NIS
client. When running the <command>ypinit</command> command, follow the prompts
and list the NIS servers in order of preference.</para><screen>slave3# <userinput>cd /var/yp</userinput>
slave3# <userinput>ypinit</userinput> <option>c</option><userinput></userinput>
slave3# <userinput>svcadm enable network/nis/client</userinput></screen>
</step><step id="anis2-step-59"><para><indexterm><primary>NIS slave servers</primary><secondary>initializing</secondary></indexterm>Initialize this machine as
a slave.</para><screen>slave3# <userinput>/usr/sbin/ypinit</userinput> <option>s</option> <userinput><replaceable>ypmaster</replaceable></userinput></screen><para>where <replaceable>ypmaster</replaceable> is the machine name of the
existing NIS master server.</para>
</step><step id="anis2-step-60"><para><indexterm><primary><command>svcadm</command></primary><secondary>with NIS</secondary></indexterm>Stop the machine running as an
NIS client.</para><screen># <userinput>svcadm disable network/nis/client</userinput></screen>
</step><step id="anis2-step-61"><para>Start NIS slave service.</para><screen># <userinput>svcadm enable network/nis/server</userinput></screen>
</step>
</procedure>
</task>
</sect1><sect1 id="anis2-25789"><title>Using NIS With C2 Security</title><indexterm><primary>NIS</primary><secondary>C2 security</secondary>
</indexterm><indexterm><primary>security</primary><secondary>C2 security</secondary><tertiary>NIS and</tertiary>
</indexterm><para><indexterm><primary><filename>PWDIR/security/passwd.adjunct</filename> file</primary></indexterm><indexterm><primary><filename>passwd.adjunct</filename> file</primary></indexterm>If the $<filename>PWDIR/security/passwd.adjunct</filename> file
is present, C2 security is started automatically. (<envar>$PWDIR</envar> 
is defined in <filename>/var/yp/Makefile</filename>.) The C2 security mode
uses the <filename>passwd.adjunct</filename> file to create the <literal>passwd.adjunct</literal> NIS map. In this implementation, NIS allows you to use both the <filename>passwd.adjunct</filename> file and <filename>shadow</filename> file to manage
security. The <filename>passwd.adjunct</filename> file is processed only when
you type the following.</para><screen># <userinput>make passwd.adjunct</userinput></screen><para><indexterm><primary><command>make</command></primary><secondary>C2 security and</secondary></indexterm>The <filename>make passwd</filename> command processes
the passwd map only, not the passwd.adjunct map when you run <command>make</command> manually
in the C2 security mode. </para>
</sect1><sect1 id="anis2-manualbind-1"><title>Binding to a Specific NIS Server</title><indexterm><primary>NIS</primary><secondary>binding manually</secondary>
</indexterm><para>Use the following steps to bind to an NIS server that you specify. For
more information, see the <olink targetdoc="refman" targetptr="ypinit-1m" remap="external"><citerefentry><refentrytitle>ypinit</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>, <olink targetdoc="refman" targetptr="ypstart-1m" remap="external"><citerefentry><refentrytitle>ypstart</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>, and <olink targetdoc="refman" targetptr="svcadm-1m" remap="external"><citerefentry><refentrytitle>svcadm</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink> man pages.</para><orderedlist><listitem><para>Add the hostname of the NIS server and its IP address to the <filename>/etc/hosts</filename> file.</para>
</listitem><listitem><para>Run the <command>domainname</command> command to populate
the <filename>/etc/defaultdomain</filename> file.</para><screen># <userinput>/usr/bin/domainname <replaceable>name-of-NIS-domain</replaceable></userinput></screen>
</listitem><listitem><para>Prompt for the NIS server host name.</para><screen># <userinput>/usr/sbin/ypinit -c</userinput>
Server name: <lineannotation>Type the NIS server hostname</lineannotation></screen>
</listitem><listitem><para>Restart the NIS services by performing one of the following
steps.</para><itemizedlist><listitem><para>For the services to persist across reboots, run the <command>svcadm</command> command:</para><screen># svcadm enable -r svc:/network/nis/client</screen>
</listitem><listitem><para>For the services to persist until reboot only, run the <command>ypstop</command> and <command>ypstart</command> commands:</para><screen># <userinput>/usr/lib/netsvc/yp/ypstop</userinput>
# <userinput>/usr/lib/netsvc/yp/ypstart</userinput></screen>
</listitem>
</itemizedlist>
</listitem>
</orderedlist>
</sect1><sect1 id="anis2-16615"><title>Changing a Machine's
NIS Domain</title><indexterm><primary>NIS domains</primary><secondary> changing</secondary>
</indexterm><indexterm><primary>NIS hosts</primary><secondary> changing domain of</secondary>
</indexterm><indexterm><primary>hosts (machines)</primary><secondary>NIS domains, changing</secondary>
</indexterm><para>To change the NIS domain name of a machine, do the following.</para><task id="anis2-proc-62"><title>How to Change a Machine's NIS Domain Name</title><procedure><step id="anis2-step-10"><para>Become superuser or assume an equivalent role.</para><para>Roles contain authorizations and privileged commands. For more information
about roles, see <olink targetdoc="sysadv6" targetptr="rbactask-1" remap="external">Chapter 9, <citetitle remap="chapter">Using Role-Based Access Control (Tasks),</citetitle> in <citetitle remap="book">System Administration Guide: Security Services</citetitle></olink>.</para>
</step><step id="anis2-step-63"><para>Edit the machine's <filename>/etc/defaultdomain</filename> file,
exchanging its present contents with the new domain name for the machine.</para><para>For example, if the current domain name is <literal>sales.doc.com</literal>,
you might change it to <literal>research.doc.com</literal>.</para>
</step><step id="anis2-step-64"><para>Run <command>domainname</command> `<command>cat
/etc/defaultdomain</command>'</para>
</step><step id="anis2-step-65"><para>Set the machine up as an NIS client, slave,
or master server.</para><para>See for <olink targetptr="cnis1-25208" remap="internal">Chapter&nbsp;5,
Setting Up and Configuring NIS Service</olink> for details.</para>
</step>
</procedure>
</task>
</sect1><sect1 id="anis2-21536"><title>Using NIS in Conjunction With DNS</title><indexterm><primary>NIS</primary><secondary>DNS and</secondary>
</indexterm><indexterm><primary>DNS</primary><secondary>NIS and</secondary>
</indexterm><para>Typically, NIS clients are configured with the <filename>nsswitch.conf</filename> file
to use only NIS for machine name and address lookups. If this type of lookup
fails, an NIS server can forward these lookups to DNS.</para><task id="anis2-proc-1"><title>How to Configure Machine Name and Address Lookup
Through NIS and DNS</title><procedure><step id="anis2-step-11"><para>Become superuser or assume an equivalent role.</para><para>Roles contain authorizations and privileged commands. For more information
about roles, see <olink targetdoc="sysadv6" targetptr="rbactask-1" remap="external">Chapter 9, <citetitle remap="chapter">Using Role-Based Access Control (Tasks),</citetitle> in <citetitle remap="book">System Administration Guide: Security Services</citetitle></olink>.</para>
</step><step id="anis2-step-8"><para>The two map files, <filename>hosts.byname</filename> and <filename>hosts.byaddr</filename> must include the <filename>YP_INTERDOMAIN</filename> key.
To test this key, edit the <filename>Makefile</filename> and modify the following
lines.</para><screen>#B=<option>b</option>
B=</screen><para>to</para><screen>B=<option>b</option>
#B=</screen><para><command>makedbm</command> will now start with the <option>b</option> flag
when it makes the maps, and the <filename>YP_INTERDOMAIN</filename> key will
be inserted into the <filename>ndbm</filename> files.</para>
</step><step id="anis2-step-2"><para>Run the <command>make</command> command to rebuild
maps.</para><screen># <userinput>/usr/ccs/bin/make hosts</userinput></screen>
</step><step id="anis2-step-3"><para>Check that all the NIS server's <filename>/etc/resolv.conf</filename> files point to valid nameservers.</para><note><para>If you have NIS servers that are not running Solaris, Release
2, make sure <filename>YP_INTERDOMAIN</filename> exists in the hosts maps.</para>
</note>
</step><step id="anis2-step-44"><para>To enable DNS forwarding, restart each server.</para><screen># <userinput>svcadm restart network/nis/server:<replaceable>&lt;instance&gt;</replaceable></userinput></screen><para>In this implementation of NIS, <filename>ypserv</filename> automatically
starts with the <option>d</option> option to forward requests to DNS.</para>
</step>
</procedure>
</task><sect2 id="anis2-6"><title>Dealing with Mixed NIS Domains</title><para>If the master and slave servers are not both running Solaris 2, refer
to the following table for how to avoid potential problems. The notation &ldquo;4.0.3+&rdquo;
refers to that and later releases of SunOS. <command>makedm</command> <option>b</option> is
a reference to the &ldquo;B&rdquo; variable in the <filename>Makefile</filename>.</para><table frame="topbot" id="anis2-tbl-7"><title>NIS/DNS in Heterogeneous NIS
Domains</title><tgroup cols="4" colsep="0" rowsep="0"><?PubTbl tgroup clmarg="11.00px"?><colspec colname="colspec3" colwidth="34.85*"/><colspec colname="colspec0" colwidth="59.58*"/><colspec colname="colspec2" colwidth="55.17*"/><colspec colname="colspec1" colwidth="50.38*"/><thead><row valign="bottom"><entry colname="colspec3" morerows="1" colsep="1" align="center"><para>Slave</para>
</entry><entry namest="colspec0" nameend="colspec1" align="center"><para>Master</para>
</entry>
</row><row valign="bottom"><entry colname="colspec0" colsep="1" rowsep="1" align="center"><para>4.0.3+</para>
</entry><entry namest="colspec2" nameend="colspec1" rowsep="1" align="center"><para>Solaris NIS</para>
</entry>
</row>
</thead><tbody><row><entry colname="colspec3" colsep="1" rowsep="0"><para><emphasis role="strong">4.0.3+</emphasis></para>
</entry><entry colname="colspec0" colsep="1" rowsep="0"><para>Master: <command>makedbm <option>b</option></command></para><para>Slave: <command>ypxfr</command></para>
</entry><entry colname="colspec2" rowsep="0"><para>Master: <command>makedbm <option>b</option></command></para><para>Slave: <command>ypxfr <option>b</option></command></para>
</entry><entry colname="colspec1" rowsep="0"><para>Master: <command>ypserv <option>d</option></command></para><para>Slave: <command>ypxfr <option>b</option></command></para>
</entry>
</row><row><entry colname="colspec3" colsep="1" rowsep="0"><para><emphasis role="strong">Solaris NIS</emphasis></para>
</entry><entry colsep="1" rowsep="0"><para>Master: <command>makedbm <option>b</option></command></para><para>Slave: <command>ypxfr</command></para>
</entry><entry colname="colspec2" rowsep="0"><para>Master: <command>makedbm <option>b</option></command></para><para>Slave: <command>ypxfr</command></para>
</entry><entry rowsep="0"><para>Master: <command>ypserv <option>d</option></command></para><para>Slave:<command>ypxfr</command> with <filename>resolv.conf</filename> or <command>ypxfr <option>b</option></command></para>
</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
</sect1><sect1 id="anis2-22142"><title>Turning Off NIS Services</title><indexterm><primary>NIS</primary><secondary>halting</secondary>
</indexterm><indexterm><primary>NIS</primary><secondary>stopping</secondary>
</indexterm><para>If <command>ypserv</command> on the NIS master is disabled, you can
no longer update any of the NIS maps.</para><itemizedlist><listitem><para>To disable NIS on a client, type the following.</para><screen># <userinput>svcadm disable network/nis/client</userinput></screen>
</listitem><listitem><para>To disable NIS on a specific slave or master server, type
the following on the server.</para><screen># <userinput>svcadm disable network/nis/server</userinput></screen>
</listitem>
</itemizedlist>
</sect1>
</chapter><?Pub *0000077085 0?>