1*0Sstevel@tonic-gate#! /usr/bin/sh 2*0Sstevel@tonic-gate# 3*0Sstevel@tonic-gate# CDDL HEADER START 4*0Sstevel@tonic-gate# 5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the 6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only 7*0Sstevel@tonic-gate# (the "License"). You may not use this file except in compliance 8*0Sstevel@tonic-gate# with the License. 9*0Sstevel@tonic-gate# 10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing. 12*0Sstevel@tonic-gate# See the License for the specific language governing permissions 13*0Sstevel@tonic-gate# and limitations under the License. 14*0Sstevel@tonic-gate# 15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each 16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the 18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying 19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner] 20*0Sstevel@tonic-gate# 21*0Sstevel@tonic-gate# CDDL HEADER END 22*0Sstevel@tonic-gate# 23*0Sstevel@tonic-gate# 24*0Sstevel@tonic-gate# ident "%Z%%M% %I% %E% SMI" 25*0Sstevel@tonic-gate# 26*0Sstevel@tonic-gate# Copyright 2003 Sun Microsystems, Inc. All rights reserved. 27*0Sstevel@tonic-gate# Use is subject to license terms. 28*0Sstevel@tonic-gate# 29*0Sstevel@tonic-gate# ypmap2src -- script to generate source files from YP maps. 30*0Sstevel@tonic-gate# 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate# Please save a copy of this script before making any changes. 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gateusage() 37*0Sstevel@tonic-gate{ 38*0Sstevel@tonic-gateecho "Usage: $PROG [-t] [[-c custom-map-name] ...] [-d domain] -o output-directory [[source-file] ...]" 39*0Sstevel@tonic-gateecho " t - Generate source files from TRADITIONAL NIS MAPS, default is NIS2LDAP maps." 40*0Sstevel@tonic-gateecho " c - Name of the custom map for which source file needs to be generated." 41*0Sstevel@tonic-gateecho " d - Specify a different domain, default is local system domain name." 42*0Sstevel@tonic-gateecho " o - Specify the output directory where source files can be generated." 43*0Sstevel@tonic-gateecho "source-file - The name of the source file for which needs to be generated." 44*0Sstevel@tonic-gateexit 0 45*0Sstevel@tonic-gate} 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gateparse_argument() 48*0Sstevel@tonic-gate{ 49*0Sstevel@tonic-gatewhile getopts "tc:d:o:" ARG 50*0Sstevel@tonic-gatedo 51*0Sstevel@tonic-gate case $ARG in 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate t) N2LPREFIX="" 54*0Sstevel@tonic-gate MAP_LIST="$NIS_ONLY_MAP_LIST" 55*0Sstevel@tonic-gate ;; 56*0Sstevel@tonic-gate c) CUST_LIST="$CUST_LIST $OPTARG" 57*0Sstevel@tonic-gate ;; 58*0Sstevel@tonic-gate d) DOMAIN=$OPTARG 59*0Sstevel@tonic-gate MAPDIR=/var/yp/"$DOMAIN" 60*0Sstevel@tonic-gate ;; 61*0Sstevel@tonic-gate o) OUTDIR=$OPTARG 62*0Sstevel@tonic-gate ;; 63*0Sstevel@tonic-gate *) echo "ERROR : Invalid argument" 64*0Sstevel@tonic-gate usage 65*0Sstevel@tonic-gate exit 1 66*0Sstevel@tonic-gate ;; 67*0Sstevel@tonic-gate esac 68*0Sstevel@tonic-gatedone 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate# This is to handle if "-t" is supplied after "-c" 71*0Sstevel@tonic-gatefor MAP in $CUST_LIST 72*0Sstevel@tonic-gatedo 73*0Sstevel@tonic-gate CUST_MAP_LIST="$CUST_MAP_LIST ${N2LPREFIX}$MAP" 74*0Sstevel@tonic-gatedone 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gateif [ -z "$OUTDIR" ]; then 77*0Sstevel@tonic-gate echo "ERROR : output directory has to be specified." 78*0Sstevel@tonic-gate usage 79*0Sstevel@tonic-gate exit 1 80*0Sstevel@tonic-gatefi 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate# Set source list if supplied 83*0Sstevel@tonic-gateshift `expr $OPTIND - 1` 84*0Sstevel@tonic-gateCMDLINE_SRC_LIST="$@" 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo CMDLINE_SRC_LIST = $CMDLINE_SRC_LIST 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate# If source(s) supplied on command line, then generate ONLY those file(s). 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gateif [ "$CMDLINE_SRC_LIST" != "" ]; then 91*0Sstevel@tonic-gate MAP_LIST="" 92*0Sstevel@tonic-gate CMDLINE_SRCS=1 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate for SRC in $CMDLINE_SRC_LIST 95*0Sstevel@tonic-gate do 96*0Sstevel@tonic-gate [ $DEBUG -eq 1 ] && echo Parsing Command line SRC = $SRC 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate case $SRC in 99*0Sstevel@tonic-gate passwd ) 100*0Sstevel@tonic-gate MAP=${N2LPREFIX}passwd.byuid 101*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 102*0Sstevel@tonic-gate ;; 103*0Sstevel@tonic-gate group ) 104*0Sstevel@tonic-gate MAP=${N2LPREFIX}group.byname 105*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 106*0Sstevel@tonic-gate ;; 107*0Sstevel@tonic-gate hosts ) 108*0Sstevel@tonic-gate MAP=${N2LPREFIX}hosts.byaddr 109*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 110*0Sstevel@tonic-gate ;; 111*0Sstevel@tonic-gate ipnodes ) 112*0Sstevel@tonic-gate MAP=${N2LPREFIX}ipnodes.byaddr 113*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 114*0Sstevel@tonic-gate ;; 115*0Sstevel@tonic-gate ethers ) 116*0Sstevel@tonic-gate MAP=${N2LPREFIX}ethers.byname 117*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 118*0Sstevel@tonic-gate ;; 119*0Sstevel@tonic-gate networks ) 120*0Sstevel@tonic-gate MAP=${N2LPREFIX}networks.byaddr 121*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 122*0Sstevel@tonic-gate ;; 123*0Sstevel@tonic-gate rpc ) 124*0Sstevel@tonic-gate MAP=${N2LPREFIX}rpc.bynumber 125*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 126*0Sstevel@tonic-gate ;; 127*0Sstevel@tonic-gate services ) 128*0Sstevel@tonic-gate MAP=${N2LPREFIX}services.byname 129*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 130*0Sstevel@tonic-gate ;; 131*0Sstevel@tonic-gate protocols ) 132*0Sstevel@tonic-gate MAP=${N2LPREFIX}protocols.bynumber 133*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 134*0Sstevel@tonic-gate ;; 135*0Sstevel@tonic-gate netgroup ) 136*0Sstevel@tonic-gate MAP=${N2LPREFIX}netgroup 137*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 138*0Sstevel@tonic-gate ;; 139*0Sstevel@tonic-gate bootparams ) 140*0Sstevel@tonic-gate MAP=${N2LPREFIX}bootparams 141*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 142*0Sstevel@tonic-gate ;; 143*0Sstevel@tonic-gate aliases ) 144*0Sstevel@tonic-gate MAP=${N2LPREFIX}mail.aliases 145*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 146*0Sstevel@tonic-gate ;; 147*0Sstevel@tonic-gate publickey ) 148*0Sstevel@tonic-gate MAP=${N2LPREFIX}publickey.byname 149*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 150*0Sstevel@tonic-gate ;; 151*0Sstevel@tonic-gate netid ) 152*0Sstevel@tonic-gate MAP=${N2LPREFIX}netid.byname 153*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 154*0Sstevel@tonic-gate ;; 155*0Sstevel@tonic-gate netmasks ) 156*0Sstevel@tonic-gate MAP=${N2LPREFIX}netmasks.byaddr 157*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 158*0Sstevel@tonic-gate ;; 159*0Sstevel@tonic-gate passwd.adjunct ) 160*0Sstevel@tonic-gate MAP=${N2LPREFIX}passwd.adjunct.byname 161*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 162*0Sstevel@tonic-gate ;; 163*0Sstevel@tonic-gate group.adjunct ) 164*0Sstevel@tonic-gate MAP=${N2LPREFIX}group.adjunct.byname 165*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 166*0Sstevel@tonic-gate ;; 167*0Sstevel@tonic-gate timezone ) 168*0Sstevel@tonic-gate MAP=${N2LPREFIX}timezone.byname 169*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 170*0Sstevel@tonic-gate ;; 171*0Sstevel@tonic-gate auto.* ) 172*0Sstevel@tonic-gate MAP=${N2LPREFIX}${SRC} 173*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 174*0Sstevel@tonic-gate ;; 175*0Sstevel@tonic-gate auth_attr ) 176*0Sstevel@tonic-gate MAP=${N2LPREFIX}auth_attr 177*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 178*0Sstevel@tonic-gate ;; 179*0Sstevel@tonic-gate exec_attr ) 180*0Sstevel@tonic-gate MAP=${N2LPREFIX}exec_attr 181*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 182*0Sstevel@tonic-gate ;; 183*0Sstevel@tonic-gate prof_attr ) 184*0Sstevel@tonic-gate MAP=${N2LPREFIX}prof_attr 185*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 186*0Sstevel@tonic-gate ;; 187*0Sstevel@tonic-gate user_attr ) 188*0Sstevel@tonic-gate MAP=${N2LPREFIX}user_attr 189*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 190*0Sstevel@tonic-gate ;; 191*0Sstevel@tonic-gate audit_user ) 192*0Sstevel@tonic-gate MAP=${N2LPREFIX}audit_user 193*0Sstevel@tonic-gate MAP_LIST="$MAP_LIST $MAP" 194*0Sstevel@tonic-gate ;; 195*0Sstevel@tonic-gate *) # Not a default source, could be a custom source. 196*0Sstevel@tonic-gate # Then generate source files from all the available 197*0Sstevel@tonic-gate # DBM files for this custom source. 198*0Sstevel@tonic-gate 199*0Sstevel@tonic-gate MAPFOUND=0 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate for dbmfile in $MAPDIR/${N2LPREFIX}${SRC}.dir \ 202*0Sstevel@tonic-gate $MAPDIR/${N2LPREFIX}${SRC}.*.dir 203*0Sstevel@tonic-gate do 204*0Sstevel@tonic-gate MAP=`basename $dbmfile .dir` 205*0Sstevel@tonic-gate if [ -f $MAPDIR/${MAP}.pag ]; then 206*0Sstevel@tonic-gate MAPFOUND=1 207*0Sstevel@tonic-gate CUST_MAP_LIST="$CUST_MAP_LIST $MAP" 208*0Sstevel@tonic-gate fi 209*0Sstevel@tonic-gate done 210*0Sstevel@tonic-gate 211*0Sstevel@tonic-gate [ $MAPFOUND -eq 0 ] && \ 212*0Sstevel@tonic-gate echo ERROR : No maps found for $SRC. Skipping.. 213*0Sstevel@tonic-gate ;; 214*0Sstevel@tonic-gate esac 215*0Sstevel@tonic-gate done 216*0Sstevel@tonic-gate 217*0Sstevel@tonic-gatefi 218*0Sstevel@tonic-gate 219*0Sstevel@tonic-gate} 220*0Sstevel@tonic-gate 221*0Sstevel@tonic-gate 222*0Sstevel@tonic-gateis_root_user() 223*0Sstevel@tonic-gate{ 224*0Sstevel@tonic-gate case `id` in 225*0Sstevel@tonic-gate uid=0\(root\)*) return 0 226*0Sstevel@tonic-gate ;; 227*0Sstevel@tonic-gate * ) return 1 228*0Sstevel@tonic-gate ;; 229*0Sstevel@tonic-gate esac 230*0Sstevel@tonic-gate} 231*0Sstevel@tonic-gate 232*0Sstevel@tonic-gate 233*0Sstevel@tonic-gatecreate_passwd() 234*0Sstevel@tonic-gate{ 235*0Sstevel@tonic-gateSRCFILE=passwd 236*0Sstevel@tonic-gateSHADOW=shadow 237*0Sstevel@tonic-gate 238*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 239*0Sstevel@tonic-gate 240*0Sstevel@tonic-gate# Remove the YP operational lines 241*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 242*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 243*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 244*0Sstevel@tonic-gate 245*0Sstevel@tonic-gate# Remove the key 246*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 247*0Sstevel@tonic-gate 248*0Sstevel@tonic-gate# Sort the entries in ascending order of uid 249*0Sstevel@tonic-gatesort -n -t: -k3,3 $TMPDIR/${MAP}.cut > $TMPDIR/${MAP}.sort 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate# If passwd.adjunct is used, the actual password is stored in 252*0Sstevel@tonic-gate# this map, and the passwd map contains "##<uid>" as the passwd. 253*0Sstevel@tonic-gate# In that case, do not generate the shadow file. 254*0Sstevel@tonic-gate 255*0Sstevel@tonic-gateUID=`head -1 $TMPDIR/${MAP}.sort | cut -f1 -d:` 256*0Sstevel@tonic-gatePSWD=`head -1 $TMPDIR/${MAP}.sort | cut -f2 -d:` 257*0Sstevel@tonic-gateif [ "$PSWD" != "##${UID}" ]; then 258*0Sstevel@tonic-gate 259*0Sstevel@tonic-gate #Create the shadow file with blank passwd aging information 260*0Sstevel@tonic-gate cut -f 1,2 -d: $TMPDIR/${MAP}.sort | 261*0Sstevel@tonic-gate sed 's/$/:::::::/' > $OUTDIR/$SHADOW 262*0Sstevel@tonic-gate 263*0Sstevel@tonic-gate #Make the shadow file readable to root only 264*0Sstevel@tonic-gate chmod 400 $OUTDIR/$SHADOW 265*0Sstevel@tonic-gate 266*0Sstevel@tonic-gate #Create the passwd file with "x" as the passwd 267*0Sstevel@tonic-gate awk ' BEGIN { FS = ":"; OFS = ":"} 268*0Sstevel@tonic-gate {$2 = "x"; print}' $TMPDIR/${MAP}.sort > $OUTDIR/$SRCFILE 269*0Sstevel@tonic-gateelse 270*0Sstevel@tonic-gate cp $TMPDIR/${MAP}.sort $OUTDIR/$SRCFILE 271*0Sstevel@tonic-gatefi 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gate} 274*0Sstevel@tonic-gate 275*0Sstevel@tonic-gate 276*0Sstevel@tonic-gatecreate_group() 277*0Sstevel@tonic-gate{ 278*0Sstevel@tonic-gateSRCFILE=group 279*0Sstevel@tonic-gate 280*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 281*0Sstevel@tonic-gate 282*0Sstevel@tonic-gate# Remove the YP operational lines 283*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 284*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 285*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 286*0Sstevel@tonic-gate 287*0Sstevel@tonic-gate# Remove the key 288*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 289*0Sstevel@tonic-gate 290*0Sstevel@tonic-gate# Sort the entries in ascending order of gid 291*0Sstevel@tonic-gatesort -n -t: -k3,3 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 292*0Sstevel@tonic-gate} 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gate 295*0Sstevel@tonic-gatecreate_hosts() 296*0Sstevel@tonic-gate{ 297*0Sstevel@tonic-gateSRCFILE=hosts 298*0Sstevel@tonic-gate 299*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 300*0Sstevel@tonic-gate 301*0Sstevel@tonic-gate# Remove the YP operational lines 302*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 303*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 304*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 305*0Sstevel@tonic-gate 306*0Sstevel@tonic-gate# Remove the key 307*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 308*0Sstevel@tonic-gate 309*0Sstevel@tonic-gate# Sort the hosts ip addresses in ascending order 310*0Sstevel@tonic-gatesort -n -t. -k1,1 -k2,2 -k3,3 -k4,4 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 311*0Sstevel@tonic-gate} 312*0Sstevel@tonic-gate 313*0Sstevel@tonic-gate 314*0Sstevel@tonic-gatecreate_ipnodes() 315*0Sstevel@tonic-gate{ 316*0Sstevel@tonic-gateSRCFILE=ipnodes 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gate# Remove the YP operational lines 321*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 322*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 323*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 324*0Sstevel@tonic-gate 325*0Sstevel@tonic-gate# Remove the key 326*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 327*0Sstevel@tonic-gate 328*0Sstevel@tonic-gategrep -v "::" $TMPDIR/${MAP}.cut >$TMPDIR/${MAP}.V4 329*0Sstevel@tonic-gategrep "::" $TMPDIR/${MAP}.cut >$TMPDIR/${MAP}.V6 330*0Sstevel@tonic-gate 331*0Sstevel@tonic-gate# Sort the ip addresses in ascending order 332*0Sstevel@tonic-gatesort -n -t. -k1,1 -k2,2 -k3,3 -k4,4 $TMPDIR/${MAP}.V4 > $OUTDIR/$SRCFILE 333*0Sstevel@tonic-gate 334*0Sstevel@tonic-gate# V6 addresses due to hex chars, can't be sorted this way. 335*0Sstevel@tonic-gate# So just do the default string sort. 336*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.V6 >> $OUTDIR/$SRCFILE 337*0Sstevel@tonic-gate} 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate 340*0Sstevel@tonic-gatecreate_ethers() 341*0Sstevel@tonic-gate{ 342*0Sstevel@tonic-gateSRCFILE=ethers 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 345*0Sstevel@tonic-gate 346*0Sstevel@tonic-gate# Remove the YP operational lines 347*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 348*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 349*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 350*0Sstevel@tonic-gate 351*0Sstevel@tonic-gate# Remove the key 352*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 353*0Sstevel@tonic-gate 354*0Sstevel@tonic-gate# Sort ethernet addresses based on host names 355*0Sstevel@tonic-gatesort -b -k2 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 356*0Sstevel@tonic-gate} 357*0Sstevel@tonic-gate 358*0Sstevel@tonic-gate 359*0Sstevel@tonic-gatecreate_networks() 360*0Sstevel@tonic-gate{ 361*0Sstevel@tonic-gateSRCFILE=networks 362*0Sstevel@tonic-gate 363*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 364*0Sstevel@tonic-gate 365*0Sstevel@tonic-gate# Remove the YP operational lines 366*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 367*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 368*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 369*0Sstevel@tonic-gate 370*0Sstevel@tonic-gate# Remove the key 371*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 372*0Sstevel@tonic-gate 373*0Sstevel@tonic-gate# Sort networks based on their names 374*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 375*0Sstevel@tonic-gate} 376*0Sstevel@tonic-gate 377*0Sstevel@tonic-gate 378*0Sstevel@tonic-gatecreate_rpc() 379*0Sstevel@tonic-gate{ 380*0Sstevel@tonic-gateSRCFILE=rpc 381*0Sstevel@tonic-gate 382*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 383*0Sstevel@tonic-gate 384*0Sstevel@tonic-gate# Remove the YP operational lines 385*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 386*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 387*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 388*0Sstevel@tonic-gate 389*0Sstevel@tonic-gate# Remove the key 390*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 391*0Sstevel@tonic-gate 392*0Sstevel@tonic-gate# Sort entries in the increasing order of RPC number 393*0Sstevel@tonic-gatesort -n -k2 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 394*0Sstevel@tonic-gate} 395*0Sstevel@tonic-gate 396*0Sstevel@tonic-gate 397*0Sstevel@tonic-gatecreate_services() 398*0Sstevel@tonic-gate{ 399*0Sstevel@tonic-gateSRCFILE=services 400*0Sstevel@tonic-gate 401*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 402*0Sstevel@tonic-gate 403*0Sstevel@tonic-gate# Remove the YP operational lines 404*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 405*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 406*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 407*0Sstevel@tonic-gate 408*0Sstevel@tonic-gate# Remove the key 409*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 410*0Sstevel@tonic-gate 411*0Sstevel@tonic-gate# Sort entries in the increasing order of RPC number 412*0Sstevel@tonic-gatesort -n -k2 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 413*0Sstevel@tonic-gate} 414*0Sstevel@tonic-gate 415*0Sstevel@tonic-gate 416*0Sstevel@tonic-gatecreate_protocols() 417*0Sstevel@tonic-gate{ 418*0Sstevel@tonic-gateSRCFILE=protocols 419*0Sstevel@tonic-gate 420*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 421*0Sstevel@tonic-gate 422*0Sstevel@tonic-gate# Remove the YP operational lines 423*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 424*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 425*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 426*0Sstevel@tonic-gate 427*0Sstevel@tonic-gate# Remove the key 428*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 429*0Sstevel@tonic-gate 430*0Sstevel@tonic-gate# Sort entries in the increasing order of RPC number 431*0Sstevel@tonic-gatesort -n -k2 $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 432*0Sstevel@tonic-gate} 433*0Sstevel@tonic-gate 434*0Sstevel@tonic-gate 435*0Sstevel@tonic-gatecreate_netgroup() 436*0Sstevel@tonic-gate{ 437*0Sstevel@tonic-gateSRCFILE=netgroup 438*0Sstevel@tonic-gate 439*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 440*0Sstevel@tonic-gate 441*0Sstevel@tonic-gate# Remove the YP operational lines 442*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 443*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 444*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 445*0Sstevel@tonic-gate 446*0Sstevel@tonic-gatecp $TMPDIR/${MAP}.grep $OUTDIR/$SRCFILE 447*0Sstevel@tonic-gate} 448*0Sstevel@tonic-gate 449*0Sstevel@tonic-gate 450*0Sstevel@tonic-gatecreate_bootparams() 451*0Sstevel@tonic-gate{ 452*0Sstevel@tonic-gateSRCFILE=bootparams 453*0Sstevel@tonic-gate 454*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 455*0Sstevel@tonic-gate 456*0Sstevel@tonic-gate# Remove the YP operational lines 457*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 458*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 459*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 460*0Sstevel@tonic-gate 461*0Sstevel@tonic-gate# Sort the entries 462*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.grep > $OUTDIR/$SRCFILE 463*0Sstevel@tonic-gate} 464*0Sstevel@tonic-gate 465*0Sstevel@tonic-gate 466*0Sstevel@tonic-gatecreate_aliases() 467*0Sstevel@tonic-gate{ 468*0Sstevel@tonic-gateSRCFILE=aliases 469*0Sstevel@tonic-gate 470*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 471*0Sstevel@tonic-gate 472*0Sstevel@tonic-gate# Remove the YP operational lines 473*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 474*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 475*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 476*0Sstevel@tonic-gate 477*0Sstevel@tonic-gate# Replace first " " with ": " to make it similar to aliases 478*0Sstevel@tonic-gatesed 's/ /: /' $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.sed 479*0Sstevel@tonic-gate 480*0Sstevel@tonic-gate# Sort aliases entries alphabetically 481*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.sed > $OUTDIR/$SRCFILE 482*0Sstevel@tonic-gate} 483*0Sstevel@tonic-gate 484*0Sstevel@tonic-gate 485*0Sstevel@tonic-gatecreate_publickey() 486*0Sstevel@tonic-gate{ 487*0Sstevel@tonic-gateSRCFILE=publickey 488*0Sstevel@tonic-gate 489*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 490*0Sstevel@tonic-gate 491*0Sstevel@tonic-gate# Remove the YP operational lines 492*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 493*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 494*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 495*0Sstevel@tonic-gate 496*0Sstevel@tonic-gate# Sort entries alphabetically 497*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.grep > $OUTDIR/$SRCFILE 498*0Sstevel@tonic-gate} 499*0Sstevel@tonic-gate 500*0Sstevel@tonic-gate 501*0Sstevel@tonic-gatecreate_netid() 502*0Sstevel@tonic-gate{ 503*0Sstevel@tonic-gateSRCFILE=netid 504*0Sstevel@tonic-gate 505*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 506*0Sstevel@tonic-gate 507*0Sstevel@tonic-gate# Remove the YP operational lines 508*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 509*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 510*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 511*0Sstevel@tonic-gate 512*0Sstevel@tonic-gate# netid source files is used to add other domain 513*0Sstevel@tonic-gate# entries. So, filter out local domain entries 514*0Sstevel@tonic-gategrep -v "@${DOMAIN}" $TMPDIR/${MAP}.grep > $OUTDIR/$SRCFILE 515*0Sstevel@tonic-gate} 516*0Sstevel@tonic-gate 517*0Sstevel@tonic-gate 518*0Sstevel@tonic-gatecreate_netmasks() 519*0Sstevel@tonic-gate{ 520*0Sstevel@tonic-gateSRCFILE=netmasks 521*0Sstevel@tonic-gate 522*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 523*0Sstevel@tonic-gate 524*0Sstevel@tonic-gate# Remove the YP operational lines 525*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 526*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 527*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 528*0Sstevel@tonic-gate 529*0Sstevel@tonic-gate# Sort the network numbers in ascending order 530*0Sstevel@tonic-gatesort -n -t. -k1,1 -k2,2 -k3,3 -k4,4 $TMPDIR/${MAP}.grep > $OUTDIR/$SRCFILE 531*0Sstevel@tonic-gate} 532*0Sstevel@tonic-gate 533*0Sstevel@tonic-gate 534*0Sstevel@tonic-gatecreate_passwd_adjunct() 535*0Sstevel@tonic-gate{ 536*0Sstevel@tonic-gateSRCFILE=passwd.adjunct 537*0Sstevel@tonic-gate 538*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 539*0Sstevel@tonic-gate 540*0Sstevel@tonic-gate# Remove the YP operational lines. It has three of them. 541*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 542*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 543*0Sstevel@tonic-gate grep -v YP_MASTER_NAME | grep -v YP_SECURE > $TMPDIR/${MAP}.grep 544*0Sstevel@tonic-gate 545*0Sstevel@tonic-gate# Remove the key 546*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 547*0Sstevel@tonic-gate 548*0Sstevel@tonic-gate## Check if sorting is ok, or leave it as it is. 549*0Sstevel@tonic-gate# Sort the entries in alphabetical order 550*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 551*0Sstevel@tonic-gate} 552*0Sstevel@tonic-gate 553*0Sstevel@tonic-gate 554*0Sstevel@tonic-gatecreate_group_adjunct() 555*0Sstevel@tonic-gate{ 556*0Sstevel@tonic-gateSRCFILE=group.adjunct 557*0Sstevel@tonic-gate 558*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 559*0Sstevel@tonic-gate 560*0Sstevel@tonic-gate# Remove the YP operational lines. It has three of them. 561*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 562*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 563*0Sstevel@tonic-gate grep -v YP_MASTER_NAME | grep -v YP_SECURE > $TMPDIR/${MAP}.grep 564*0Sstevel@tonic-gate 565*0Sstevel@tonic-gate# Remove the key 566*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 567*0Sstevel@tonic-gate 568*0Sstevel@tonic-gate# Sort the entries in alphabetical order 569*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 570*0Sstevel@tonic-gate} 571*0Sstevel@tonic-gate 572*0Sstevel@tonic-gate 573*0Sstevel@tonic-gatecreate_timezone() 574*0Sstevel@tonic-gate{ 575*0Sstevel@tonic-gateSRCFILE=timezone 576*0Sstevel@tonic-gate 577*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 578*0Sstevel@tonic-gate 579*0Sstevel@tonic-gate# Remove the YP operational lines 580*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 581*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 582*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 583*0Sstevel@tonic-gate 584*0Sstevel@tonic-gate# Remove the key 585*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 586*0Sstevel@tonic-gate 587*0Sstevel@tonic-gate# Sort the entries in alphabetical order 588*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 589*0Sstevel@tonic-gate} 590*0Sstevel@tonic-gate 591*0Sstevel@tonic-gate 592*0Sstevel@tonic-gatecreate_auto_src() 593*0Sstevel@tonic-gate{ 594*0Sstevel@tonic-gateSRCFILE=$MAP 595*0Sstevel@tonic-gate 596*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 597*0Sstevel@tonic-gate 598*0Sstevel@tonic-gate# Remove the YP operational lines 599*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 600*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 601*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 602*0Sstevel@tonic-gate 603*0Sstevel@tonic-gate# Sort entries alphabetically 604*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.grep > $OUTDIR/$SRCFILE 605*0Sstevel@tonic-gate} 606*0Sstevel@tonic-gate 607*0Sstevel@tonic-gate 608*0Sstevel@tonic-gatecreate_auth_attr() 609*0Sstevel@tonic-gate{ 610*0Sstevel@tonic-gateSRCFILE=auth_attr 611*0Sstevel@tonic-gate 612*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 613*0Sstevel@tonic-gate 614*0Sstevel@tonic-gate# Remove the YP operational lines 615*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 616*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 617*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 618*0Sstevel@tonic-gate 619*0Sstevel@tonic-gate# Remove the key 620*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 621*0Sstevel@tonic-gate 622*0Sstevel@tonic-gate# Sort entries in the alphabetical order 623*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 624*0Sstevel@tonic-gate} 625*0Sstevel@tonic-gate 626*0Sstevel@tonic-gate 627*0Sstevel@tonic-gatecreate_exec_attr() 628*0Sstevel@tonic-gate{ 629*0Sstevel@tonic-gateSRCFILE=exec_attr 630*0Sstevel@tonic-gate 631*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 632*0Sstevel@tonic-gate 633*0Sstevel@tonic-gate# Remove the YP operational lines 634*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 635*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 636*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 637*0Sstevel@tonic-gate 638*0Sstevel@tonic-gate# Remove the key which is made of three fields. space is part of key 639*0Sstevel@tonic-gatecut -f 3- -d ":" $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut1 640*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.cut1 > $TMPDIR/${MAP}.cut2 641*0Sstevel@tonic-gate 642*0Sstevel@tonic-gate# Sort entries in the alphabetical order 643*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut2 > $OUTDIR/$SRCFILE 644*0Sstevel@tonic-gate} 645*0Sstevel@tonic-gate 646*0Sstevel@tonic-gate 647*0Sstevel@tonic-gatecreate_prof_attr() 648*0Sstevel@tonic-gate{ 649*0Sstevel@tonic-gateSRCFILE=prof_attr 650*0Sstevel@tonic-gate 651*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 652*0Sstevel@tonic-gate 653*0Sstevel@tonic-gate# Remove the YP operational lines 654*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 655*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 656*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 657*0Sstevel@tonic-gate 658*0Sstevel@tonic-gate# Remove the key. It is difficult here as space is part of the key. 659*0Sstevel@tonic-gate# From the "key key" part, extract "key", and then paste it with 660*0Sstevel@tonic-gate# the rest of the entry. 661*0Sstevel@tonic-gatecut -f1 -d: $TMPDIR/${MAP}.grep | 662*0Sstevel@tonic-gateawk '{ 663*0Sstevel@tonic-gate STR = $1 664*0Sstevel@tonic-gate for (i=2; i <= NF/2; i++) { 665*0Sstevel@tonic-gate STR = STR " " $i 666*0Sstevel@tonic-gate } 667*0Sstevel@tonic-gateprint STR 668*0Sstevel@tonic-gate}' > $TMPDIR/${MAP}.cut1 669*0Sstevel@tonic-gate 670*0Sstevel@tonic-gatecut -f2- -d: $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut2 671*0Sstevel@tonic-gatepaste -d ":" $TMPDIR/${MAP}.cut1 $TMPDIR/${MAP}.cut2 > $TMPDIR/${MAP}.cut 672*0Sstevel@tonic-gate 673*0Sstevel@tonic-gate# Sort entries in the alphabetical order 674*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 675*0Sstevel@tonic-gate} 676*0Sstevel@tonic-gate 677*0Sstevel@tonic-gate 678*0Sstevel@tonic-gatecreate_user_attr() 679*0Sstevel@tonic-gate{ 680*0Sstevel@tonic-gateSRCFILE=user_attr 681*0Sstevel@tonic-gate 682*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 683*0Sstevel@tonic-gate 684*0Sstevel@tonic-gate# Remove the YP operational lines 685*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 686*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 687*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 688*0Sstevel@tonic-gate 689*0Sstevel@tonic-gate# Remove the key 690*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 691*0Sstevel@tonic-gate 692*0Sstevel@tonic-gate# Sort entries in the alphabetical order 693*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 694*0Sstevel@tonic-gate} 695*0Sstevel@tonic-gate 696*0Sstevel@tonic-gate 697*0Sstevel@tonic-gatecreate_audit_user() 698*0Sstevel@tonic-gate{ 699*0Sstevel@tonic-gateSRCFILE=audit_user 700*0Sstevel@tonic-gate 701*0Sstevel@tonic-gatemakedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 702*0Sstevel@tonic-gate 703*0Sstevel@tonic-gate# Remove the YP operational lines. It has 3 of them. 704*0Sstevel@tonic-gategrep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 705*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 706*0Sstevel@tonic-gate grep -v YP_MASTER_NAME | grep -v YP_SECURE > $TMPDIR/${MAP}.grep 707*0Sstevel@tonic-gate 708*0Sstevel@tonic-gate# Remove the key 709*0Sstevel@tonic-gatecut -f 2- -d " " $TMPDIR/${MAP}.grep > $TMPDIR/${MAP}.cut 710*0Sstevel@tonic-gate 711*0Sstevel@tonic-gate# Sort entries in the alphabetical order 712*0Sstevel@tonic-gatesort $TMPDIR/${MAP}.cut > $OUTDIR/$SRCFILE 713*0Sstevel@tonic-gate} 714*0Sstevel@tonic-gate 715*0Sstevel@tonic-gate 716*0Sstevel@tonic-gate## MAIN ## 717*0Sstevel@tonic-gate 718*0Sstevel@tonic-gatePROG=`basename $0` 719*0Sstevel@tonic-gate 720*0Sstevel@tonic-gate# Only root can read the NIS maps, so no point allowing 721*0Sstevel@tonic-gate# non-root users to be able to run this script. 722*0Sstevel@tonic-gateis_root_user 723*0Sstevel@tonic-gateif [ $? -ne 0 ]; then 724*0Sstevel@tonic-gate echo "ERROR : Only root can run $PROG" 725*0Sstevel@tonic-gate exit 1 726*0Sstevel@tonic-gatefi 727*0Sstevel@tonic-gate 728*0Sstevel@tonic-gate# Prevent non-root users from reading/writing 729*0Sstevel@tonic-gateumask 077 730*0Sstevel@tonic-gate 731*0Sstevel@tonic-gate# Initialize default values. 732*0Sstevel@tonic-gateDOMAIN=`/usr/bin/domainname` 733*0Sstevel@tonic-gateMAPDIR=/var/yp/"$DOMAIN" # Default to local domain 734*0Sstevel@tonic-gateN2LPREFIX=LDAP_ 735*0Sstevel@tonic-gate 736*0Sstevel@tonic-gateNIS_ONLY_MAP_LIST="passwd.byuid 737*0Sstevel@tonic-gate group.byname 738*0Sstevel@tonic-gate hosts.byaddr 739*0Sstevel@tonic-gate ipnodes.byaddr 740*0Sstevel@tonic-gate ethers.byname 741*0Sstevel@tonic-gate networks.byaddr 742*0Sstevel@tonic-gate rpc.bynumber 743*0Sstevel@tonic-gate services.byname 744*0Sstevel@tonic-gate protocols.bynumber 745*0Sstevel@tonic-gate netgroup 746*0Sstevel@tonic-gate bootparams 747*0Sstevel@tonic-gate mail.aliases 748*0Sstevel@tonic-gate publickey.byname 749*0Sstevel@tonic-gate netid.byname 750*0Sstevel@tonic-gate netmasks.byaddr 751*0Sstevel@tonic-gate passwd.adjunct.byname 752*0Sstevel@tonic-gate group.adjunct.byname 753*0Sstevel@tonic-gate timezone.byname 754*0Sstevel@tonic-gate auth_attr 755*0Sstevel@tonic-gate exec_attr 756*0Sstevel@tonic-gate prof_attr 757*0Sstevel@tonic-gate user_attr 758*0Sstevel@tonic-gate audit_user" 759*0Sstevel@tonic-gate 760*0Sstevel@tonic-gateNIS2LDAP_MAP_LIST="${N2LPREFIX}passwd.byuid 761*0Sstevel@tonic-gate ${N2LPREFIX}group.byname 762*0Sstevel@tonic-gate ${N2LPREFIX}hosts.byaddr 763*0Sstevel@tonic-gate ${N2LPREFIX}ipnodes.byaddr 764*0Sstevel@tonic-gate ${N2LPREFIX}ethers.byname 765*0Sstevel@tonic-gate ${N2LPREFIX}networks.byaddr 766*0Sstevel@tonic-gate ${N2LPREFIX}rpc.bynumber 767*0Sstevel@tonic-gate ${N2LPREFIX}services.byname 768*0Sstevel@tonic-gate ${N2LPREFIX}protocols.bynumber 769*0Sstevel@tonic-gate ${N2LPREFIX}netgroup 770*0Sstevel@tonic-gate ${N2LPREFIX}bootparams 771*0Sstevel@tonic-gate ${N2LPREFIX}mail.aliases 772*0Sstevel@tonic-gate ${N2LPREFIX}publickey.byname 773*0Sstevel@tonic-gate ${N2LPREFIX}netid.byname 774*0Sstevel@tonic-gate ${N2LPREFIX}netmasks.byaddr 775*0Sstevel@tonic-gate ${N2LPREFIX}passwd.adjunct.byname 776*0Sstevel@tonic-gate ${N2LPREFIX}group.adjunct.byname 777*0Sstevel@tonic-gate ${N2LPREFIX}timezone.byname 778*0Sstevel@tonic-gate ${N2LPREFIX}auth_attr 779*0Sstevel@tonic-gate ${N2LPREFIX}exec_attr 780*0Sstevel@tonic-gate ${N2LPREFIX}prof_attr 781*0Sstevel@tonic-gate ${N2LPREFIX}user_attr 782*0Sstevel@tonic-gate ${N2LPREFIX}audit_user" 783*0Sstevel@tonic-gate 784*0Sstevel@tonic-gate 785*0Sstevel@tonic-gate# If auto maps exist, add them to the respective lists. 786*0Sstevel@tonic-gatefor dbmfile in $MAPDIR/auto.*.dir 787*0Sstevel@tonic-gatedo 788*0Sstevel@tonic-gate MAP=`basename $dbmfile .dir` 789*0Sstevel@tonic-gate if [ -f $MAPDIR/${MAP}.pag ]; then 790*0Sstevel@tonic-gate NIS_ONLY_MAP_LIST="$NIS_ONLY_MAP_LIST $MAP" 791*0Sstevel@tonic-gate fi 792*0Sstevel@tonic-gatedone 793*0Sstevel@tonic-gate 794*0Sstevel@tonic-gatefor dbmfile in $MAPDIR/${N2LPREFIX}auto.*.dir 795*0Sstevel@tonic-gatedo 796*0Sstevel@tonic-gate MAP=`basename $dbmfile .dir` 797*0Sstevel@tonic-gate if [ -f $MAPDIR/${MAP}.pag ]; then 798*0Sstevel@tonic-gate NIS2LDAP_MAP_LIST="$NIS2LDAP_MAP_LIST $MAP" 799*0Sstevel@tonic-gate fi 800*0Sstevel@tonic-gatedone 801*0Sstevel@tonic-gate 802*0Sstevel@tonic-gate# Default to N2L maps 803*0Sstevel@tonic-gateMAP_LIST="$NIS2LDAP_MAP_LIST" 804*0Sstevel@tonic-gate 805*0Sstevel@tonic-gate# Safe place to avoid anyone from reading sensitive data. 806*0Sstevel@tonic-gateTMPDIR="/var/tmp/ypmap2src" 807*0Sstevel@tonic-gate 808*0Sstevel@tonic-gateDEBUG=0 # Default to debug off 809*0Sstevel@tonic-gateDEBUG=1 810*0Sstevel@tonic-gateOUTDIR="" 811*0Sstevel@tonic-gateCUST_MAP_LIST="" 812*0Sstevel@tonic-gateCMDLINE_SRCS=0 813*0Sstevel@tonic-gate 814*0Sstevel@tonic-gate 815*0Sstevel@tonic-gateparse_argument $* 816*0Sstevel@tonic-gate 817*0Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo DOMAIN = $DOMAIN 818*0Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo OUTDIR = $OUTDIR 819*0Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo TMPDIR = $TMPDIR 820*0Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo CUST_MAP_LIST = $CUST_MAP_LIST 821*0Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo MAP_LIST = $MAP_LIST 822*0Sstevel@tonic-gate 823*0Sstevel@tonic-gate[ $DEBUG -eq 1 ] && echo MAPDIR = $MAPDIR 824*0Sstevel@tonic-gateif [ ! -d "$MAPDIR" ]; then 825*0Sstevel@tonic-gate echo ERROR : NIS Map directory $MAPDIR does not exist. 826*0Sstevel@tonic-gate exit 1 827*0Sstevel@tonic-gatefi 828*0Sstevel@tonic-gate 829*0Sstevel@tonic-gateif [ ! -d "$OUTDIR" ]; then 830*0Sstevel@tonic-gate echo output directory $OUTDIR does not exist. Creating it. 831*0Sstevel@tonic-gate mkdir -p $OUTDIR 832*0Sstevel@tonic-gate if [ $? -ne 0 ]; then 833*0Sstevel@tonic-gate echo ERROR : Failed to create output directory $OUTDIR 834*0Sstevel@tonic-gate exit 1 835*0Sstevel@tonic-gate fi 836*0Sstevel@tonic-gatefi 837*0Sstevel@tonic-gate 838*0Sstevel@tonic-gate# Cleanup if the temp directory has been leftover 839*0Sstevel@tonic-gate[ -d "$TMPDIR" ] && rm -rf $TMPDIR 840*0Sstevel@tonic-gatemkdir $TMPDIR 841*0Sstevel@tonic-gateif [ $? -ne 0 ]; then 842*0Sstevel@tonic-gate echo ERROR : Failed to create temp directory $TMPDIR 843*0Sstevel@tonic-gate exit 1 844*0Sstevel@tonic-gatefi 845*0Sstevel@tonic-gate 846*0Sstevel@tonic-gate 847*0Sstevel@tonic-gatefor MAP in $MAP_LIST 848*0Sstevel@tonic-gatedo 849*0Sstevel@tonic-gate [ $DEBUG -eq 1 ] && echo Processing MAP = $MAP 850*0Sstevel@tonic-gate 851*0Sstevel@tonic-gate if [ ! -f $MAPDIR/${MAP}.dir ] || [ ! -f $MAPDIR/${MAP}.pag ]; then 852*0Sstevel@tonic-gate 853*0Sstevel@tonic-gate [ $CMDLINE_SRCS -ne 0 ] && \ 854*0Sstevel@tonic-gate echo ERROR : Missing DBM file for $MAP in $MAPDIR . Skipping.. 855*0Sstevel@tonic-gate 856*0Sstevel@tonic-gate [ $DEBUG -eq 1 ] && [ $CMDLINE_SRCS -eq 0 ] && \ 857*0Sstevel@tonic-gate echo No DBM file for $MAP in $MAPDIR . Skipping.. 858*0Sstevel@tonic-gate continue 859*0Sstevel@tonic-gate fi 860*0Sstevel@tonic-gate 861*0Sstevel@tonic-gate case $MAP in 862*0Sstevel@tonic-gate ${N2LPREFIX}passwd.byuid ) 863*0Sstevel@tonic-gate create_passwd 864*0Sstevel@tonic-gate ;; 865*0Sstevel@tonic-gate ${N2LPREFIX}group.byname ) 866*0Sstevel@tonic-gate create_group 867*0Sstevel@tonic-gate ;; 868*0Sstevel@tonic-gate ${N2LPREFIX}hosts.byaddr ) 869*0Sstevel@tonic-gate create_hosts 870*0Sstevel@tonic-gate ;; 871*0Sstevel@tonic-gate ${N2LPREFIX}ipnodes.byaddr ) 872*0Sstevel@tonic-gate create_ipnodes 873*0Sstevel@tonic-gate ;; 874*0Sstevel@tonic-gate ${N2LPREFIX}ethers.byname ) 875*0Sstevel@tonic-gate create_ethers 876*0Sstevel@tonic-gate ;; 877*0Sstevel@tonic-gate ${N2LPREFIX}networks.byaddr ) 878*0Sstevel@tonic-gate create_networks 879*0Sstevel@tonic-gate ;; 880*0Sstevel@tonic-gate ${N2LPREFIX}rpc.bynumber ) 881*0Sstevel@tonic-gate create_rpc 882*0Sstevel@tonic-gate ;; 883*0Sstevel@tonic-gate ${N2LPREFIX}services.byname ) 884*0Sstevel@tonic-gate create_services 885*0Sstevel@tonic-gate ;; 886*0Sstevel@tonic-gate ${N2LPREFIX}protocols.bynumber ) 887*0Sstevel@tonic-gate create_protocols 888*0Sstevel@tonic-gate ;; 889*0Sstevel@tonic-gate ${N2LPREFIX}netgroup ) 890*0Sstevel@tonic-gate create_netgroup 891*0Sstevel@tonic-gate ;; 892*0Sstevel@tonic-gate ${N2LPREFIX}bootparams ) 893*0Sstevel@tonic-gate create_bootparams 894*0Sstevel@tonic-gate ;; 895*0Sstevel@tonic-gate ${N2LPREFIX}mail.aliases ) 896*0Sstevel@tonic-gate create_aliases 897*0Sstevel@tonic-gate ;; 898*0Sstevel@tonic-gate ${N2LPREFIX}publickey.byname ) 899*0Sstevel@tonic-gate create_publickey 900*0Sstevel@tonic-gate ;; 901*0Sstevel@tonic-gate ${N2LPREFIX}netid.byname ) 902*0Sstevel@tonic-gate create_netid 903*0Sstevel@tonic-gate ;; 904*0Sstevel@tonic-gate ${N2LPREFIX}netmasks.byaddr ) 905*0Sstevel@tonic-gate create_netmasks 906*0Sstevel@tonic-gate ;; 907*0Sstevel@tonic-gate ${N2LPREFIX}passwd.adjunct.byname ) 908*0Sstevel@tonic-gate create_passwd_adjunct 909*0Sstevel@tonic-gate ;; 910*0Sstevel@tonic-gate ${N2LPREFIX}group.adjunct.byname ) 911*0Sstevel@tonic-gate create_group_adjunct 912*0Sstevel@tonic-gate ;; 913*0Sstevel@tonic-gate ${N2LPREFIX}timezone.byname ) 914*0Sstevel@tonic-gate create_timezone 915*0Sstevel@tonic-gate ;; 916*0Sstevel@tonic-gate ${N2LPREFIX}auto.* ) 917*0Sstevel@tonic-gate create_auto_src 918*0Sstevel@tonic-gate ;; 919*0Sstevel@tonic-gate ${N2LPREFIX}auth_attr ) 920*0Sstevel@tonic-gate create_auth_attr 921*0Sstevel@tonic-gate ;; 922*0Sstevel@tonic-gate ${N2LPREFIX}exec_attr ) 923*0Sstevel@tonic-gate create_exec_attr 924*0Sstevel@tonic-gate ;; 925*0Sstevel@tonic-gate ${N2LPREFIX}prof_attr ) 926*0Sstevel@tonic-gate create_prof_attr 927*0Sstevel@tonic-gate ;; 928*0Sstevel@tonic-gate ${N2LPREFIX}user_attr ) 929*0Sstevel@tonic-gate create_user_attr 930*0Sstevel@tonic-gate ;; 931*0Sstevel@tonic-gate ${N2LPREFIX}audit_user ) 932*0Sstevel@tonic-gate create_audit_user 933*0Sstevel@tonic-gate ;; 934*0Sstevel@tonic-gate *) # Not a default map, could be a custom map. 935*0Sstevel@tonic-gate CUST_MAP_LIST="$CUST_MAP_LIST $MAP" 936*0Sstevel@tonic-gate ;; 937*0Sstevel@tonic-gate esac 938*0Sstevel@tonic-gatedone 939*0Sstevel@tonic-gate 940*0Sstevel@tonic-gate 941*0Sstevel@tonic-gatefor MAP in $CUST_MAP_LIST 942*0Sstevel@tonic-gatedo 943*0Sstevel@tonic-gate [ $DEBUG -eq 1 ] && echo Processing Custom MAP = $MAP 944*0Sstevel@tonic-gate 945*0Sstevel@tonic-gate if [ ! -f $MAPDIR/${MAP}.dir ] || [ ! -f $MAPDIR/${MAP}.pag ]; then 946*0Sstevel@tonic-gate echo ERROR : Missing DBM file for $MAP in $MAPDIR . Skipping.. 947*0Sstevel@tonic-gate continue 948*0Sstevel@tonic-gate fi 949*0Sstevel@tonic-gate 950*0Sstevel@tonic-gate makedbm -u $MAPDIR/$MAP > $TMPDIR/$MAP 951*0Sstevel@tonic-gate 952*0Sstevel@tonic-gate# Remove the YP operational lines. Assuming each custom map 953*0Sstevel@tonic-gate# has only these entries (three in n2l mode as shown below, and 954*0Sstevel@tonic-gate# two in vanilla NIS mode as it does not have "YP_DOMAIN_NAME". 955*0Sstevel@tonic-gate# But that does not require any changes in the code). Modify it 956*0Sstevel@tonic-gate# appropriately in other cases. 957*0Sstevel@tonic-gate 958*0Sstevel@tonic-gate grep -v YP_LAST_MODIFIED $TMPDIR/$MAP | 959*0Sstevel@tonic-gate grep -v "YP_DOMAIN_NAME $DOMAIN" | 960*0Sstevel@tonic-gate grep -v YP_MASTER_NAME > $TMPDIR/${MAP}.grep 961*0Sstevel@tonic-gate 962*0Sstevel@tonic-gate# If further processing (e.g., removing key, sorting etc.) 963*0Sstevel@tonic-gate# is required, then update the script appropriately. 964*0Sstevel@tonic-gate cp $TMPDIR/${MAP}.grep $OUTDIR/$MAP 965*0Sstevel@tonic-gate 966*0Sstevel@tonic-gatedone 967*0Sstevel@tonic-gate 968*0Sstevel@tonic-gate# Leave the temp directory if debug is set 969*0Sstevel@tonic-gate[ $DEBUG -eq 0 ] && rm -rf $TMPDIR 970*0Sstevel@tonic-gate 971*0Sstevel@tonic-gateexit 0 972