Writing NIS server scripts
In order to target an NIS system, you must create or modify the following script files:
Configuring the psunix.cfg file
An NIS server derives its password database NIS maps from NIS source files. You must configure psunix
so that it can locate and update the NIS source files.
In the psunix.cfg
configuration file, configure passwd-path, group-path, shadow-path, and grpshadow-path to point to the NIS source files. A typical NIS instance does not use a shadow or gshadow file; this section may be commented out. The following is a sample excerpt from the psunix.cfg
file for an NIS target system:
database = { user = { # Specifies an alternate path to the password database file where all # user information is stored. If it is not specified (default # behavior), the location is /etc/passwd. # passwd-path = "/var/yp/maps/passwd"; }; group = { # Specifies an alternate path to the group database file where all # group information is stored. If it is not specified (default # behavior), the location is /etc/group. # group-path = "/var/yp/maps/group"; }; };
For transparent synchronization (pspasswd
) the configuration will be taken from the system (nsswitch.conf) since pspasswd
uses system calls to get user credentials and set passwords, it does not use the specified configuration lines found in psunix.cfg
.
Adding the PSLang override option
Copy the provided pslang-override-nis.psl
file located inside the conf directory in the psunix archive, into /usr/local/psunix/<instance>/. Edit the file to suit your requirements.
In the psunix.cfg
file, add a pslang-override-path option that points to the PSLang override file:
# This option allows users to script pslang code that either: # 1) overrides builtin psunix operations, or # 2) adds pre/post operations that augement the builtin operations. # # Please refer to the psunix conf/pslang-override-sample.psl for a # general example. # # Please refer to the psunix conf/pslang-override-nis.psl for a # NIS example. # pslang-override-path = "/usr/local/psunix/<instance>/pslang-override-nis.psl";
Adding a script to build the NIS maps
An NIS server builds the NIS maps using the make utility. Copy the following script into /usr/local/psunix/<instance>/make-nis.sh and edit accordingly. Ensure that the script includes the "hashbang" (#!) line with the full path to the interpreter program.
#!/bin/sh # This script runs make to build the nis maps. # Change the NISDIR to the path of the NIS makefile. NISDIR=/var/yp/maps/ NISTARGET=passwd # Change the NISTARGET to the make target(s) of interest. cd $NISDIR /usr/bin/make $NISTARGET
Ensure that the script has execution rights:
chmod u+x /usr/local/psunix/<instance>/make-nis.sh
Test the script to ensure it works.