xref: /titanic_50/usr/src/cmd/ldap/ns_ldap/idsconfig.sh (revision 6a634c9dca3093f3922e4b7ab826d7bdf17bf78e)
17c478bd9Sstevel@tonic-gate#!/bin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
645916cd2Sjpk# Common Development and Distribution License (the "License").
745916cd2Sjpk# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
227c478bd9Sstevel@tonic-gate#
234f4e8bf0SMilan Jurik# idsconfig -- script to setup iDS 5.x/6.x/7.x for Native LDAP II.
247c478bd9Sstevel@tonic-gate#
25*07925104Sgww# Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
267c478bd9Sstevel@tonic-gate#
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate#
297c478bd9Sstevel@tonic-gate# display_msg(): Displays message corresponding to the tag passed in.
307c478bd9Sstevel@tonic-gate#
317c478bd9Sstevel@tonic-gatedisplay_msg()
327c478bd9Sstevel@tonic-gate{
337c478bd9Sstevel@tonic-gate    case "$1" in
347c478bd9Sstevel@tonic-gate    usage) cat <<EOF
357c478bd9Sstevel@tonic-gate $PROG: [ -v ] [ -i input file ] [ -o output file ]
367c478bd9Sstevel@tonic-gate   i <input file>     Get setup info from input file.
377c478bd9Sstevel@tonic-gate   o <output file>    Generate a server configuration output file.
387c478bd9Sstevel@tonic-gate   v                  Verbose mode
397c478bd9Sstevel@tonic-gateEOF
407c478bd9Sstevel@tonic-gate    ;;
417c478bd9Sstevel@tonic-gate    backup_server) cat <<EOF
427c478bd9Sstevel@tonic-gateIt is strongly recommended that you BACKUP the directory server
437c478bd9Sstevel@tonic-gatebefore running $PROG.
447c478bd9Sstevel@tonic-gate
457c478bd9Sstevel@tonic-gateHit Ctrl-C at any time before the final confirmation to exit.
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gateEOF
487c478bd9Sstevel@tonic-gate    ;;
497c478bd9Sstevel@tonic-gate    setup_complete) cat <<EOF
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate$PROG: Setup of iDS server ${IDS_SERVER} is complete.
527c478bd9Sstevel@tonic-gate
537c478bd9Sstevel@tonic-gateEOF
547c478bd9Sstevel@tonic-gate    ;;
557c478bd9Sstevel@tonic-gate    display_vlv_list) cat <<EOF
567c478bd9Sstevel@tonic-gate
57e1dd0a2fSth160488Note: idsconfig has created entries for VLV indexes. 
58e1dd0a2fSth160488
59e1dd0a2fSth160488      For DS5.x, use the directoryserver(1m) script on ${IDS_SERVER}
60e1dd0a2fSth160488      to stop the server.  Then, using directoryserver, follow the
61e1dd0a2fSth160488      directoryserver examples below to create the actual VLV indexes.
62e1dd0a2fSth160488
634f4e8bf0SMilan Jurik      For DS6.x or later, use dsadm command delivered with DS on ${IDS_SERVER}
64e1dd0a2fSth160488      to stop the server.  Then, using dsadm, follow the
65e1dd0a2fSth160488      dsadm examples below to create the actual VLV indexes.
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gateEOF
687c478bd9Sstevel@tonic-gate    ;;
697c478bd9Sstevel@tonic-gate    cred_level_menu) cat <<EOF
707c478bd9Sstevel@tonic-gateThe following are the supported credential levels:
717c478bd9Sstevel@tonic-gate  1  anonymous
727c478bd9Sstevel@tonic-gate  2  proxy
737c478bd9Sstevel@tonic-gate  3  proxy anonymous
74cb5caa98Sdjl  4  self
757c478bd9Sstevel@tonic-gateEOF
767c478bd9Sstevel@tonic-gate    ;;
777c478bd9Sstevel@tonic-gate    auth_method_menu) cat <<EOF
787c478bd9Sstevel@tonic-gateThe following are the supported Authentication Methods:
797c478bd9Sstevel@tonic-gate  1  none
807c478bd9Sstevel@tonic-gate  2  simple
817c478bd9Sstevel@tonic-gate  3  sasl/DIGEST-MD5
827c478bd9Sstevel@tonic-gate  4  tls:simple
837c478bd9Sstevel@tonic-gate  5  tls:sasl/DIGEST-MD5
84cb5caa98Sdjl  6  sasl/GSSAPI
857c478bd9Sstevel@tonic-gateEOF
867c478bd9Sstevel@tonic-gate    ;;
877c478bd9Sstevel@tonic-gate    srvauth_method_menu) cat <<EOF
887c478bd9Sstevel@tonic-gateThe following are the supported Authentication Methods:
897c478bd9Sstevel@tonic-gate  1  simple
907c478bd9Sstevel@tonic-gate  2  sasl/DIGEST-MD5
917c478bd9Sstevel@tonic-gate  3  tls:simple
927c478bd9Sstevel@tonic-gate  4  tls:sasl/DIGEST-MD5
93cb5caa98Sdjl  5  sasl/GSSAPI
947c478bd9Sstevel@tonic-gateEOF
957c478bd9Sstevel@tonic-gate    ;;
967c478bd9Sstevel@tonic-gate    prompt_ssd_menu) cat <<EOF
977c478bd9Sstevel@tonic-gate  A  Add a Service Search Descriptor
987c478bd9Sstevel@tonic-gate  D  Delete a SSD
997c478bd9Sstevel@tonic-gate  M  Modify a SSD
1007c478bd9Sstevel@tonic-gate  P  Display all SSD's
1017c478bd9Sstevel@tonic-gate  H  Help
1027c478bd9Sstevel@tonic-gate  X  Clear all SSD's
1037c478bd9Sstevel@tonic-gate
1047c478bd9Sstevel@tonic-gate  Q  Exit menu
1057c478bd9Sstevel@tonic-gateEOF
1067c478bd9Sstevel@tonic-gate    ;;
107017e8b01Svl199446    summary_menu)
108017e8b01Svl199446
109017e8b01Svl199446	SUFFIX_INFO=
110017e8b01Svl199446	DB_INFO=
111017e8b01Svl199446
112017e8b01Svl199446	[ -n "${NEED_CREATE_SUFFIX}" ] &&
113017e8b01Svl199446	{
114017e8b01Svl199446		SUFFIX_INFO=`cat <<EOF
115017e8b01Svl199446
116017e8b01Svl199446         Suffix to create          : $LDAP_SUFFIX
117017e8b01Svl199446EOF
118017e8b01Svl199446`
119017e8b01Svl199446		[ -n "${NEED_CREATE_BACKEND}" ] &&
120017e8b01Svl199446			DB_INFO=`cat <<EOF
121017e8b01Svl199446
122017e8b01Svl199446         Database to create        : $IDS_DATABASE
123017e8b01Svl199446EOF
124017e8b01Svl199446`
125017e8b01Svl199446	}
126017e8b01Svl199446
127017e8b01Svl199446	cat <<EOF
1287c478bd9Sstevel@tonic-gate              Summary of Configuration
1297c478bd9Sstevel@tonic-gate
1307c478bd9Sstevel@tonic-gate  1  Domain to serve               : $LDAP_DOMAIN
131017e8b01Svl199446  2  Base DN to setup              : $LDAP_BASEDN$SUFFIX_INFO$DB_INFO
1327c478bd9Sstevel@tonic-gate  3  Profile name to create        : $LDAP_PROFILE_NAME
1337c478bd9Sstevel@tonic-gate  4  Default Server List           : $LDAP_SERVER_LIST
1347c478bd9Sstevel@tonic-gate  5  Preferred Server List         : $LDAP_PREF_SRVLIST
1357c478bd9Sstevel@tonic-gate  6  Default Search Scope          : $LDAP_SEARCH_SCOPE
1367c478bd9Sstevel@tonic-gate  7  Credential Level              : $LDAP_CRED_LEVEL
1377c478bd9Sstevel@tonic-gate  8  Authentication Method         : $LDAP_AUTHMETHOD
1387c478bd9Sstevel@tonic-gate  9  Enable Follow Referrals       : $LDAP_FOLLOWREF
1397c478bd9Sstevel@tonic-gate 10  iDS Time Limit                : $IDS_TIMELIMIT
1407c478bd9Sstevel@tonic-gate 11  iDS Size Limit                : $IDS_SIZELIMIT
1417c478bd9Sstevel@tonic-gate 12  Enable crypt password storage : $NEED_CRYPT
1427c478bd9Sstevel@tonic-gate 13  Service Auth Method pam_ldap  : $LDAP_SRV_AUTHMETHOD_PAM
1437c478bd9Sstevel@tonic-gate 14  Service Auth Method keyserv   : $LDAP_SRV_AUTHMETHOD_KEY
1447c478bd9Sstevel@tonic-gate 15  Service Auth Method passwd-cmd: $LDAP_SRV_AUTHMETHOD_CMD
1457c478bd9Sstevel@tonic-gate 16  Search Time Limit             : $LDAP_SEARCH_TIME_LIMIT
1467c478bd9Sstevel@tonic-gate 17  Profile Time to Live          : $LDAP_PROFILE_TTL
1477c478bd9Sstevel@tonic-gate 18  Bind Limit                    : $LDAP_BIND_LIMIT
148dd1104fbSMichen Chang 19  Enable shadow update          : $LDAP_ENABLE_SHADOW_UPDATE
149dd1104fbSMichen Chang 20  Service Search Descriptors Menu
1507c478bd9Sstevel@tonic-gate
1517c478bd9Sstevel@tonic-gateEOF
1527c478bd9Sstevel@tonic-gate    ;;
153017e8b01Svl199446    sfx_not_suitable) cat <<EOF
154017e8b01Svl199446
155017e8b01Svl199446Sorry, suffix ${LDAP_SUFFIX} is not suitable for Base DN ${LDAP_BASEDN}
156017e8b01Svl199446
157017e8b01Svl199446EOF
158017e8b01Svl199446    ;;
159017e8b01Svl199446    obj_not_found) cat <<EOF
160017e8b01Svl199446
161017e8b01Svl199446Sorry, ${PROG} can't find an objectclass for "$_ATT" attribute
162017e8b01Svl199446
163017e8b01Svl199446EOF
164017e8b01Svl199446    ;;
165017e8b01Svl199446    sfx_config_incons) cat <<EOF
166017e8b01Svl199446
167017e8b01Svl199446Sorry, there is no suffix mapping for ${LDAP_SUFFIX},
168017e8b01Svl199446while ldbm database exists, server configuration needs to be fixed manually,
169017e8b01Svl199446look at cn=mapping tree,cn=config and cn=ldbm database,cn=plugins,cn=config
170017e8b01Svl199446
171017e8b01Svl199446EOF
172017e8b01Svl199446    ;;
173017e8b01Svl199446    ldbm_db_exist) cat <<EOF
174017e8b01Svl199446
175017e8b01Svl199446Database "${IDS_DATABASE}" already exists,
176017e8b01Svl199446however "${IDS_DATABASE_AVAIL}" name is available
177017e8b01Svl199446
178017e8b01Svl199446EOF
179017e8b01Svl199446    ;;
180017e8b01Svl199446    unable_find_db_name) cat <<EOF
181017e8b01Svl199446    
182017e8b01Svl199446Unable to find any available database name close to "${IDS_DATABASE}"
183017e8b01Svl199446
184017e8b01Svl199446EOF
185017e8b01Svl199446    ;;
186017e8b01Svl199446    create_ldbm_db_error) cat <<EOF
187017e8b01Svl199446
188017e8b01Svl199446ERROR: unable to create suffix ${LDAP_SUFFIX}
189017e8b01Svl199446       due to server error that occurred during creation of ldbm database
190017e8b01Svl199446
191017e8b01Svl199446EOF
192017e8b01Svl199446    ;;
193017e8b01Svl199446    create_suffix_entry_error) cat <<EOF
194017e8b01Svl199446
195017e8b01Svl199446ERROR: unable to create entry ${LDAP_SUFFIX} of ${LDAP_SUFFIX_OBJ} class
196017e8b01Svl199446
197017e8b01Svl199446EOF
198017e8b01Svl199446    ;;
1997c478bd9Sstevel@tonic-gate    ldap_suffix_list) cat <<EOF
2007c478bd9Sstevel@tonic-gate
2017c478bd9Sstevel@tonic-gateNo valid suffixes (naming contexts) were found for LDAP base DN:
2027c478bd9Sstevel@tonic-gate${LDAP_BASEDN}
2037c478bd9Sstevel@tonic-gate
2047c478bd9Sstevel@tonic-gateAvailable suffixes are:
2057c478bd9Sstevel@tonic-gate${LDAP_SUFFIX_LIST}
2067c478bd9Sstevel@tonic-gate
2077c478bd9Sstevel@tonic-gateEOF
2087c478bd9Sstevel@tonic-gate    ;;
2097c478bd9Sstevel@tonic-gate    sorry) cat <<EOF
2107c478bd9Sstevel@tonic-gate
2117c478bd9Sstevel@tonic-gateHELP - No help is available for this topic.
2127c478bd9Sstevel@tonic-gate
2137c478bd9Sstevel@tonic-gateEOF
2147c478bd9Sstevel@tonic-gate    ;;
215017e8b01Svl199446    create_suffix_help) cat <<EOF
216017e8b01Svl199446
217017e8b01Svl199446HELP - Our Base DN is ${LDAP_BASEDN}
218017e8b01Svl199446       and we need to create a Directory Suffix,
219017e8b01Svl199446       which can be equal to Base DN itself or be any of Base DN parents.
220017e8b01Svl199446       All intermediate entries up to suffix will be created on demand.
221017e8b01Svl199446
222017e8b01Svl199446EOF
223017e8b01Svl199446    ;;
224017e8b01Svl199446    enter_ldbm_db_help) cat <<EOF
225017e8b01Svl199446
226017e8b01Svl199446HELP - ldbm database is an internal database for storage of our suffix data.
227017e8b01Svl199446       Database name must be alphanumeric due to Directory Server restriction.
228017e8b01Svl199446
229017e8b01Svl199446EOF
230017e8b01Svl199446    ;;
2317c478bd9Sstevel@tonic-gate    backup_help) cat <<EOF
2327c478bd9Sstevel@tonic-gate
2337c478bd9Sstevel@tonic-gateHELP - Since idsconfig modifies the directory server configuration,
2347c478bd9Sstevel@tonic-gate       it is strongly recommended that you backup the server prior
2357c478bd9Sstevel@tonic-gate       to running this utility.  This is especially true if the server
2367c478bd9Sstevel@tonic-gate       being configured is a production server.
2377c478bd9Sstevel@tonic-gate
2387c478bd9Sstevel@tonic-gateEOF
2397c478bd9Sstevel@tonic-gate    ;;
2407c478bd9Sstevel@tonic-gate    port_help) cat <<EOF
2417c478bd9Sstevel@tonic-gate
2427c478bd9Sstevel@tonic-gateHELP - Enter the port number the directory server is configured to
2437c478bd9Sstevel@tonic-gate       use for LDAP.
2447c478bd9Sstevel@tonic-gate
2457c478bd9Sstevel@tonic-gateEOF
2467c478bd9Sstevel@tonic-gate    ;;
2477c478bd9Sstevel@tonic-gate    domain_help) cat <<EOF
2487c478bd9Sstevel@tonic-gate
2497c478bd9Sstevel@tonic-gateHELP - This is the DNS domain name this server will be serving.  You
2507c478bd9Sstevel@tonic-gate       must provide this name even if the server is not going to be populated
2517c478bd9Sstevel@tonic-gate       with hostnames.  Any unqualified hostname stored in the directory
2527c478bd9Sstevel@tonic-gate       will be fully qualified using this DNS domain name.
2537c478bd9Sstevel@tonic-gate
2547c478bd9Sstevel@tonic-gateEOF
2557c478bd9Sstevel@tonic-gate    ;;
2567c478bd9Sstevel@tonic-gate    basedn_help) cat <<EOF
2577c478bd9Sstevel@tonic-gate
2587c478bd9Sstevel@tonic-gateHELP - This parameter defines the default location in the directory tree for
2597c478bd9Sstevel@tonic-gate       the naming services entries.  You can override this default by using 
2607c478bd9Sstevel@tonic-gate       serviceSearchDescriptors (SSD). You will be given the option to set up 
2617c478bd9Sstevel@tonic-gate       an SSD later on in the setup.
2627c478bd9Sstevel@tonic-gate
2637c478bd9Sstevel@tonic-gateEOF
2647c478bd9Sstevel@tonic-gate    ;;
2657c478bd9Sstevel@tonic-gate    profile_help) cat <<EOF
2667c478bd9Sstevel@tonic-gate
2677c478bd9Sstevel@tonic-gateHELP - Name of the configuration profile with which the clients will be
2687c478bd9Sstevel@tonic-gate       configured. A directory server can store various profiles for multiple 
2697c478bd9Sstevel@tonic-gate       groups of clients.  The initialization tool, (ldapclient(1M)), assumes 
2707c478bd9Sstevel@tonic-gate       "default" unless another is specified.
2717c478bd9Sstevel@tonic-gate
2727c478bd9Sstevel@tonic-gateEOF
2737c478bd9Sstevel@tonic-gate    ;;
2747c478bd9Sstevel@tonic-gate    def_srvlist_help) cat <<EOF
2757c478bd9Sstevel@tonic-gate
2767c478bd9Sstevel@tonic-gateHELP - Provide a list of directory servers to serve clients using this profile.
2777c478bd9Sstevel@tonic-gate       All these servers should contain consistent data and provide similar 
2787c478bd9Sstevel@tonic-gate       functionality.  This list is not ordered, and clients might change the 
2797c478bd9Sstevel@tonic-gate       order given in this list. Note that this is a space separated list of 
2807c478bd9Sstevel@tonic-gate       *IP addresses* (not host names).  Providing port numbers is optional.
2817c478bd9Sstevel@tonic-gate
2827c478bd9Sstevel@tonic-gateEOF
2837c478bd9Sstevel@tonic-gate    ;;
2847c478bd9Sstevel@tonic-gate    pref_srvlist_help) cat <<EOF
2857c478bd9Sstevel@tonic-gate
2867c478bd9Sstevel@tonic-gateHELP - Provide a list of directory servers to serve this client profile. 
2877c478bd9Sstevel@tonic-gate       Unlike the default server list, which is not ordered, the preferred 
2887c478bd9Sstevel@tonic-gate       servers must be entered IN THE ORDER you wish to have them contacted. 
2897c478bd9Sstevel@tonic-gate       If you do specify a preferred server list, clients will always contact 
2907c478bd9Sstevel@tonic-gate       them before attempting to contact any of the servers on the default 
2917c478bd9Sstevel@tonic-gate       server list. Note that you must enter the preferred server list as a 
2927c478bd9Sstevel@tonic-gate       space-separated list of *IP addresses* (not host names).  Providing port 
2937c478bd9Sstevel@tonic-gate       numbers is optional.
2947c478bd9Sstevel@tonic-gate
2957c478bd9Sstevel@tonic-gateEOF
2967c478bd9Sstevel@tonic-gate    ;;
2977c478bd9Sstevel@tonic-gate    srch_scope_help) cat <<EOF
2987c478bd9Sstevel@tonic-gate
2997c478bd9Sstevel@tonic-gateHELP - Default search scope to be used for all searches unless they are
3007c478bd9Sstevel@tonic-gate       overwritten using serviceSearchDescriptors.  The valid options
3017c478bd9Sstevel@tonic-gate       are "one", which would specify the search will only be performed 
3027c478bd9Sstevel@tonic-gate       at the base DN for the given service, or "sub", which would specify 
3037c478bd9Sstevel@tonic-gate       the search will be performed through *all* levels below the base DN 
3047c478bd9Sstevel@tonic-gate       for the given service.
3057c478bd9Sstevel@tonic-gate
3067c478bd9Sstevel@tonic-gateEOF
3077c478bd9Sstevel@tonic-gate    ;;
3087c478bd9Sstevel@tonic-gate    cred_lvl_help) cat <<EOF
3097c478bd9Sstevel@tonic-gate
3107c478bd9Sstevel@tonic-gateHELP - This parameter defines what credentials the clients use to
3117c478bd9Sstevel@tonic-gate       authenticate to the directory server.  This list might contain
3127c478bd9Sstevel@tonic-gate       multiple credential levels and is ordered.  If a proxy level
3137c478bd9Sstevel@tonic-gate       is configured, you will also be prompted to enter a bind DN
3147c478bd9Sstevel@tonic-gate       for the proxy agent along with a password.  This proxy agent
3157c478bd9Sstevel@tonic-gate       will be created if it does not exist.
3167c478bd9Sstevel@tonic-gate
3177c478bd9Sstevel@tonic-gateEOF
3187c478bd9Sstevel@tonic-gate    ;;
3197c478bd9Sstevel@tonic-gate    auth_help) cat <<EOF
3207c478bd9Sstevel@tonic-gate
3217c478bd9Sstevel@tonic-gateHELP - The default authentication method(s) to be used by all services
3227c478bd9Sstevel@tonic-gate       in the client using this profile.  This is a ordered list of
3237c478bd9Sstevel@tonic-gate       authentication methods separated by a ';'.  The supported methods
3247c478bd9Sstevel@tonic-gate       are provided in a menu.  Note that sasl/DIGEST-MD5 binds require
3257c478bd9Sstevel@tonic-gate       passwords to be stored un-encrypted on the server.
3267c478bd9Sstevel@tonic-gate
3277c478bd9Sstevel@tonic-gateEOF
3287c478bd9Sstevel@tonic-gate    ;;
3297c478bd9Sstevel@tonic-gate    srvauth_help) cat <<EOF
3307c478bd9Sstevel@tonic-gate
3317c478bd9Sstevel@tonic-gateHELP - The authentication methods to be used by a given service.  Currently
3327c478bd9Sstevel@tonic-gate       3 services support this feature: pam_ldap, keyserv, and passwd-cmd.
3337c478bd9Sstevel@tonic-gate       The authentication method specified in this attribute overrides
3347c478bd9Sstevel@tonic-gate       the default authentication method defined in the profile.  This
3357c478bd9Sstevel@tonic-gate       feature can be used to select stronger authentication methods for
3367c478bd9Sstevel@tonic-gate       services which require increased security.
3377c478bd9Sstevel@tonic-gate
3387c478bd9Sstevel@tonic-gateEOF
3397c478bd9Sstevel@tonic-gate    ;;
3407c478bd9Sstevel@tonic-gate    pam_ldap_help) cat <<EOF
3417c478bd9Sstevel@tonic-gate
3427c478bd9Sstevel@tonic-gateHELP - The authentication method(s) to be used by pam_ldap when contacting
3437c478bd9Sstevel@tonic-gate       the directory server.  This is a ordered list, and, if provided, will
3447c478bd9Sstevel@tonic-gate       override the default authentication method parameter.
3457c478bd9Sstevel@tonic-gate
3467c478bd9Sstevel@tonic-gateEOF
3477c478bd9Sstevel@tonic-gate    ;;
3487c478bd9Sstevel@tonic-gate    keyserv_help) cat <<EOF
3497c478bd9Sstevel@tonic-gate
3507c478bd9Sstevel@tonic-gateHELP - The authentication method(s) to be used by newkey(1M) and chkey(1)
3517c478bd9Sstevel@tonic-gate       when contacting the directory server.  This is a ordered list and
3527c478bd9Sstevel@tonic-gate       if provided will override the default authentication method
3537c478bd9Sstevel@tonic-gate       parameter.
3547c478bd9Sstevel@tonic-gate
3557c478bd9Sstevel@tonic-gateEOF
3567c478bd9Sstevel@tonic-gate    ;;
3577c478bd9Sstevel@tonic-gate    passwd-cmd_help) cat <<EOF
3587c478bd9Sstevel@tonic-gate
3597c478bd9Sstevel@tonic-gateHELP - The authentication method(s) to be used by passwd(1) command when
3607c478bd9Sstevel@tonic-gate       contacting the directory server.  This is a ordered list and if
3617c478bd9Sstevel@tonic-gate       provided will override the default authentication method parameter.
3627c478bd9Sstevel@tonic-gate
3637c478bd9Sstevel@tonic-gateEOF
3647c478bd9Sstevel@tonic-gate    ;;
3657c478bd9Sstevel@tonic-gate    referrals_help) cat <<EOF
3667c478bd9Sstevel@tonic-gate
3677c478bd9Sstevel@tonic-gateHELP - This parameter indicates whether the client should follow
3687c478bd9Sstevel@tonic-gate       ldap referrals if it encounters one during naming lookups.
3697c478bd9Sstevel@tonic-gate
3707c478bd9Sstevel@tonic-gateEOF
3717c478bd9Sstevel@tonic-gate    ;;
3727c478bd9Sstevel@tonic-gate    tlim_help) cat <<EOF
3737c478bd9Sstevel@tonic-gate
3747c478bd9Sstevel@tonic-gateHELP - The server time limit value indicates the maximum amount of time the
3757c478bd9Sstevel@tonic-gate       server would spend on a query from the client before abandoning it.
3767c478bd9Sstevel@tonic-gate       A value of '-1' indicates no limit.
3777c478bd9Sstevel@tonic-gate
3787c478bd9Sstevel@tonic-gateEOF
3797c478bd9Sstevel@tonic-gate    ;;
3807c478bd9Sstevel@tonic-gate    slim_help) cat <<EOF
3817c478bd9Sstevel@tonic-gate
3827c478bd9Sstevel@tonic-gateHELP - The server sizelimit value indicates the maximum number of entries
3837c478bd9Sstevel@tonic-gate       the server would return in respond to a query from the client.  A
3847c478bd9Sstevel@tonic-gate       value of '-1' indicates no limit.
3857c478bd9Sstevel@tonic-gate
3867c478bd9Sstevel@tonic-gateEOF
3877c478bd9Sstevel@tonic-gate    ;;
3887c478bd9Sstevel@tonic-gate    crypt_help) cat <<EOF
3897c478bd9Sstevel@tonic-gate
3907c478bd9Sstevel@tonic-gateHELP - By default iDS does not store userPassword attribute values using
3917c478bd9Sstevel@tonic-gate       unix "crypt" format.  If you need to keep your passwords in the crypt
3927c478bd9Sstevel@tonic-gate       format for NIS/NIS+ and pam_unix compatibility, choose 'yes'.  If
3937c478bd9Sstevel@tonic-gate       passwords are stored using any other format than crypt, pam_ldap
3947c478bd9Sstevel@tonic-gate       MUST be used by clients to authenticate users to the system. Note 
3957c478bd9Sstevel@tonic-gate       that if you wish to use sasl/DIGEST-MD5 in conjunction with pam_ldap,
3967c478bd9Sstevel@tonic-gate       user passwords must be stored in the clear format.
3977c478bd9Sstevel@tonic-gate
3987c478bd9Sstevel@tonic-gateEOF
3997c478bd9Sstevel@tonic-gate    ;;
4007c478bd9Sstevel@tonic-gate    srchtime_help) cat <<EOF
4017c478bd9Sstevel@tonic-gate
4027c478bd9Sstevel@tonic-gateHELP - The search time limit the client will enforce for directory
4037c478bd9Sstevel@tonic-gate       lookups.
4047c478bd9Sstevel@tonic-gate
4057c478bd9Sstevel@tonic-gateEOF
4067c478bd9Sstevel@tonic-gate    ;;
4077c478bd9Sstevel@tonic-gate    profttl_help) cat <<EOF
4087c478bd9Sstevel@tonic-gate
4097c478bd9Sstevel@tonic-gateHELP - The time to live value for profile.  The client will refresh its
4107c478bd9Sstevel@tonic-gate       cached version of the configuration profile at this TTL interval.
4117c478bd9Sstevel@tonic-gate
4127c478bd9Sstevel@tonic-gateEOF
4137c478bd9Sstevel@tonic-gate    ;;
4147c478bd9Sstevel@tonic-gate    bindlim_help) cat <<EOF
4157c478bd9Sstevel@tonic-gate
4167c478bd9Sstevel@tonic-gateHELP - The time limit for the bind operation to the directory.  This
4177c478bd9Sstevel@tonic-gate       value controls the responsiveness of the client in case a server
4187c478bd9Sstevel@tonic-gate       becomes unavailable.  The smallest timeout value for a given
4197c478bd9Sstevel@tonic-gate       network architecture/conditions would work best.  This is very
4207c478bd9Sstevel@tonic-gate       similar to setting TCP timeout, but only for LDAP bind operation.
4217c478bd9Sstevel@tonic-gate
4227c478bd9Sstevel@tonic-gateEOF
4237c478bd9Sstevel@tonic-gate    ;;
4247c478bd9Sstevel@tonic-gate    ssd_help) cat <<EOF
4257c478bd9Sstevel@tonic-gate
4267c478bd9Sstevel@tonic-gateHELP - Using Service Search Descriptors (SSD), you can override the
4277c478bd9Sstevel@tonic-gate       default configuration for a given service.  The SSD can be
4287c478bd9Sstevel@tonic-gate       used to override the default search base DN, the default search
4297c478bd9Sstevel@tonic-gate       scope, and the default search filter to be used for directory
4307c478bd9Sstevel@tonic-gate       lookups.  SSD are supported for all services (databases)
4317c478bd9Sstevel@tonic-gate       defined in nsswitch.conf(4).  The default base DN is defined
4327c478bd9Sstevel@tonic-gate       in ldap(1).
4337c478bd9Sstevel@tonic-gate
4347c478bd9Sstevel@tonic-gate       Note: SSD are powerful tools in defining configuration profiles
4357c478bd9Sstevel@tonic-gate             and provide a great deal of flexibility.  However, care
4367c478bd9Sstevel@tonic-gate             must be taken in creating them.  If you decide to make use
4377c478bd9Sstevel@tonic-gate             of SSDs, consult the documentation first.
4387c478bd9Sstevel@tonic-gate
4397c478bd9Sstevel@tonic-gateEOF
4407c478bd9Sstevel@tonic-gate    ;;
4417c478bd9Sstevel@tonic-gate    ssd_menu_help) cat <<EOF
4427c478bd9Sstevel@tonic-gate
4437c478bd9Sstevel@tonic-gateHELP - Using this menu SSD can be added, updated, or deleted from
4447c478bd9Sstevel@tonic-gate       the profile.
4457c478bd9Sstevel@tonic-gate
4467c478bd9Sstevel@tonic-gate       A - This option creates a new SSD by prompting for the
4477c478bd9Sstevel@tonic-gate           service name, base DN, and scope.  Service name is
4487c478bd9Sstevel@tonic-gate           any valid service as defined in ldap(1).  base is
4497c478bd9Sstevel@tonic-gate           either the distinguished name to the container where
4507c478bd9Sstevel@tonic-gate           this service will use, or a relative DN followed
4517c478bd9Sstevel@tonic-gate           by a ','.
4527c478bd9Sstevel@tonic-gate       D - Delete a previously created SSD.
4537c478bd9Sstevel@tonic-gate       M - Modify a previously created SSD.
4547c478bd9Sstevel@tonic-gate       P - Display a list of all the previously created SSD.
4557c478bd9Sstevel@tonic-gate       X - Delete all of the previously created SSD.
4567c478bd9Sstevel@tonic-gate
4577c478bd9Sstevel@tonic-gate       Q - Exit the menu and continue with the server configuration.
4587c478bd9Sstevel@tonic-gate
4597c478bd9Sstevel@tonic-gateEOF
4607c478bd9Sstevel@tonic-gate    ;;
4617c478bd9Sstevel@tonic-gate    ldap_suffix_list_help) cat <<EOF
4627c478bd9Sstevel@tonic-gate
4637c478bd9Sstevel@tonic-gateHELP - No valid suffixes (naming contexts) are available on server 
4647c478bd9Sstevel@tonic-gate       ${IDS_SERVER}:${IDS_PORT}.
4657c478bd9Sstevel@tonic-gate       You must set an LDAP Base DN that can be contained in 
4667c478bd9Sstevel@tonic-gate       an existing suffix.
4677c478bd9Sstevel@tonic-gate
4687c478bd9Sstevel@tonic-gateEOF
4697c478bd9Sstevel@tonic-gate    ;;
470dd1104fbSMichen Chang    enable_shadow_update_help) cat <<EOF
471dd1104fbSMichen Chang
472dd1104fbSMichen ChangHELP - Enter 'y' to set up the LDAP server for shadow update.
473dd1104fbSMichen Chang       The setup will add an administrator identity/credential
474dd1104fbSMichen Chang       and modify the necessary access controls for the client
475dd1104fbSMichen Chang       to update shadow(4) data on the LDAP server. If sasl/GSSAPI
476dd1104fbSMichen Chang       is in use, the Kerberos host principal will be used as the
477dd1104fbSMichen Chang       administrator identity.
478dd1104fbSMichen Chang
479dd1104fbSMichen Chang       Shadow data is used for password aging and account locking.
480dd1104fbSMichen Chang       Please refer to the shadow(4) manual page for details.
481dd1104fbSMichen Chang
482dd1104fbSMichen ChangEOF
483dd1104fbSMichen Chang    ;;
484dd1104fbSMichen Chang    add_admin_cred_help) cat <<EOF
485dd1104fbSMichen Chang
486dd1104fbSMichen ChangHELP - Start the setup to add an administrator identity/credential
487dd1104fbSMichen Chang       and to modify access controls for the client to update
488dd1104fbSMichen Chang       shadow(4) data on the LDAP server.
489dd1104fbSMichen Chang
490dd1104fbSMichen Chang       Shadow data is used for password aging and account locking.
491dd1104fbSMichen Chang       Please refer to the shadow(4) manual page for details.
492dd1104fbSMichen Chang
493dd1104fbSMichen ChangEOF
494dd1104fbSMichen Chang    ;;
495dd1104fbSMichen Chang    use_host_principal_help) cat <<EOF
496dd1104fbSMichen Chang
497dd1104fbSMichen ChangHELP - A profile with a 'sasl/GSSAPI' authentication method and a 'self'
498dd1104fbSMichen Chang       credential level is detected, enter 'y' to modify the necessary
499dd1104fbSMichen Chang       access controls for allowing the client to update shadow(4) data
500dd1104fbSMichen Chang       on the LDAP server.
501dd1104fbSMichen Chang
502dd1104fbSMichen Chang       Shadow data is used for password aging and account locking.
503dd1104fbSMichen Chang       Please refer to the shadow(4) manual page for details.
504dd1104fbSMichen Chang
505dd1104fbSMichen ChangEOF
506dd1104fbSMichen Chang    ;;
5077c478bd9Sstevel@tonic-gate    esac
5087c478bd9Sstevel@tonic-gate}
5097c478bd9Sstevel@tonic-gate
5107c478bd9Sstevel@tonic-gate
5117c478bd9Sstevel@tonic-gate#
5127c478bd9Sstevel@tonic-gate# get_ans(): gets an answer from the user.
5137c478bd9Sstevel@tonic-gate#		$1  instruction/comment/description/question
5147c478bd9Sstevel@tonic-gate#		$2  default value
5157c478bd9Sstevel@tonic-gate#
5167c478bd9Sstevel@tonic-gateget_ans()
5177c478bd9Sstevel@tonic-gate{
5187c478bd9Sstevel@tonic-gate    if [ -z "$2" ]
5197c478bd9Sstevel@tonic-gate    then
5207c478bd9Sstevel@tonic-gate	${ECHO} "$1 \c"
5217c478bd9Sstevel@tonic-gate    else
5227c478bd9Sstevel@tonic-gate	${ECHO} "$1 [$2] \c"
5237c478bd9Sstevel@tonic-gate    fi
5247c478bd9Sstevel@tonic-gate
5257c478bd9Sstevel@tonic-gate    read ANS
5267c478bd9Sstevel@tonic-gate    if [ -z "$ANS" ]
5277c478bd9Sstevel@tonic-gate    then
5287c478bd9Sstevel@tonic-gate	ANS=$2
5297c478bd9Sstevel@tonic-gate    fi
5307c478bd9Sstevel@tonic-gate}
5317c478bd9Sstevel@tonic-gate
5327c478bd9Sstevel@tonic-gate
5337c478bd9Sstevel@tonic-gate#
5347c478bd9Sstevel@tonic-gate# get_ans_req(): gets an answer (required) from the user, NULL value not allowed.
5357c478bd9Sstevel@tonic-gate#		$@  instruction/comment/description/question
5367c478bd9Sstevel@tonic-gate#
5377c478bd9Sstevel@tonic-gateget_ans_req()
5387c478bd9Sstevel@tonic-gate{
5397c478bd9Sstevel@tonic-gate    ANS=""                  # Set ANS to NULL.
5407c478bd9Sstevel@tonic-gate    while [ "$ANS" = "" ]
5417c478bd9Sstevel@tonic-gate    do
5427c478bd9Sstevel@tonic-gate	get_ans "$@"
5437c478bd9Sstevel@tonic-gate	[ "$ANS" = "" ] && ${ECHO} "NULL value not allowed!"
5447c478bd9Sstevel@tonic-gate    done
5457c478bd9Sstevel@tonic-gate}
5467c478bd9Sstevel@tonic-gate
5477c478bd9Sstevel@tonic-gate
5487c478bd9Sstevel@tonic-gate#
5497c478bd9Sstevel@tonic-gate# get_number(): Querys and verifies that number entered is numeric.
5507c478bd9Sstevel@tonic-gate#               Function will repeat prompt user for number value.
5517c478bd9Sstevel@tonic-gate#               $1  Message text.
5527c478bd9Sstevel@tonic-gate#		$2  default value.
5537c478bd9Sstevel@tonic-gate#               $3  Help argument.
5547c478bd9Sstevel@tonic-gate#
5557c478bd9Sstevel@tonic-gateget_number()
5567c478bd9Sstevel@tonic-gate{
5577c478bd9Sstevel@tonic-gate    ANS=""                  # Set ANS to NULL.
5587c478bd9Sstevel@tonic-gate    NUM=""
5597c478bd9Sstevel@tonic-gate
5607c478bd9Sstevel@tonic-gate    get_ans "$1" "$2"
5617c478bd9Sstevel@tonic-gate
5627c478bd9Sstevel@tonic-gate    # Verify that value is numeric.
5637c478bd9Sstevel@tonic-gate    while not_numeric $ANS
5647c478bd9Sstevel@tonic-gate    do
5657c478bd9Sstevel@tonic-gate	case "$ANS" in
5667c478bd9Sstevel@tonic-gate	    [Hh] | help | Help | \?) display_msg ${3:-sorry} ;;
5677c478bd9Sstevel@tonic-gate	    * ) ${ECHO} "Invalid value: \"${ANS}\". \c"
5687c478bd9Sstevel@tonic-gate	     ;;
5697c478bd9Sstevel@tonic-gate	esac
5707c478bd9Sstevel@tonic-gate	# Get a new value.
5717c478bd9Sstevel@tonic-gate	get_ans "Enter a numeric value:" "$2"
5727c478bd9Sstevel@tonic-gate    done
5737c478bd9Sstevel@tonic-gate    NUM=$ANS
5747c478bd9Sstevel@tonic-gate}
5757c478bd9Sstevel@tonic-gate
5767c478bd9Sstevel@tonic-gate
5777c478bd9Sstevel@tonic-gate#
5787c478bd9Sstevel@tonic-gate# get_negone_num(): Only allows a -1 or positive integer.
5797c478bd9Sstevel@tonic-gate#                   Used for values where -1 has special meaning.
5807c478bd9Sstevel@tonic-gate#
5817c478bd9Sstevel@tonic-gate#                   $1 - Prompt message.
5827c478bd9Sstevel@tonic-gate#                   $2 - Default value (require).
5837c478bd9Sstevel@tonic-gate#                   $3 - Optional help argument.
5847c478bd9Sstevel@tonic-gateget_negone_num()
5857c478bd9Sstevel@tonic-gate{
5867c478bd9Sstevel@tonic-gate    while :
5877c478bd9Sstevel@tonic-gate    do
5887c478bd9Sstevel@tonic-gate	get_number "$1" "$2" "$3"
5897c478bd9Sstevel@tonic-gate	if is_negative $ANS
5907c478bd9Sstevel@tonic-gate	then
5917c478bd9Sstevel@tonic-gate	    if [ "$ANS" = "-1" ]; then
5927c478bd9Sstevel@tonic-gate		break  # -1 is OK, so break.
5937c478bd9Sstevel@tonic-gate	    else       # Need to re-enter number.
5947c478bd9Sstevel@tonic-gate		${ECHO} "Invalid number: please enter -1 or positive number."
5957c478bd9Sstevel@tonic-gate	    fi
5967c478bd9Sstevel@tonic-gate	else
5977c478bd9Sstevel@tonic-gate	    break      # Positive number
5987c478bd9Sstevel@tonic-gate	fi
5997c478bd9Sstevel@tonic-gate    done
6007c478bd9Sstevel@tonic-gate}
6017c478bd9Sstevel@tonic-gate
6027c478bd9Sstevel@tonic-gate
6037c478bd9Sstevel@tonic-gate#
6047c478bd9Sstevel@tonic-gate# get_passwd(): Reads a password from the user and verify with second.
6057c478bd9Sstevel@tonic-gate#		$@  instruction/comment/description/question
6067c478bd9Sstevel@tonic-gate#
6077c478bd9Sstevel@tonic-gateget_passwd()
6087c478bd9Sstevel@tonic-gate{
6097c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In get_passwd()"
6107c478bd9Sstevel@tonic-gate
6117c478bd9Sstevel@tonic-gate    # Temporary PASSWD variables
6127c478bd9Sstevel@tonic-gate    _PASS1=""
6137c478bd9Sstevel@tonic-gate    _PASS2=""
6147c478bd9Sstevel@tonic-gate
6157c478bd9Sstevel@tonic-gate    /usr/bin/stty -echo     # Turn echo OFF
6167c478bd9Sstevel@tonic-gate
6177c478bd9Sstevel@tonic-gate    # Endless loop that continues until passwd and re-entered passwd
6187c478bd9Sstevel@tonic-gate    # match.
6197c478bd9Sstevel@tonic-gate    while :
6207c478bd9Sstevel@tonic-gate    do
6217c478bd9Sstevel@tonic-gate	ANS=""                  # Set ANS to NULL.
6227c478bd9Sstevel@tonic-gate
6237c478bd9Sstevel@tonic-gate	# Don't allow NULL for first try.
6247c478bd9Sstevel@tonic-gate	while [ "$ANS" = "" ]
6257c478bd9Sstevel@tonic-gate	do
6267c478bd9Sstevel@tonic-gate	    get_ans "$@"
6277c478bd9Sstevel@tonic-gate	    [ "$ANS" = "" ] && ${ECHO} "" && ${ECHO} "NULL passwd not allowed!"
6287c478bd9Sstevel@tonic-gate	done
6297c478bd9Sstevel@tonic-gate	_PASS1=$ANS         # Store first try.
6307c478bd9Sstevel@tonic-gate
6317c478bd9Sstevel@tonic-gate	# Get second try.
6327c478bd9Sstevel@tonic-gate	${ECHO} ""
6337c478bd9Sstevel@tonic-gate	get_ans "Re-enter passwd:"
6347c478bd9Sstevel@tonic-gate	_PASS2=$ANS
6357c478bd9Sstevel@tonic-gate
6367c478bd9Sstevel@tonic-gate	# Test if passwords are identical.
6377c478bd9Sstevel@tonic-gate	if [ "$_PASS1" = "$_PASS2" ]; then
6387c478bd9Sstevel@tonic-gate	    break
6397c478bd9Sstevel@tonic-gate	fi
6407c478bd9Sstevel@tonic-gate
6417c478bd9Sstevel@tonic-gate	# Move cursor down to next line and print ERROR message.
6427c478bd9Sstevel@tonic-gate	${ECHO} ""
6437c478bd9Sstevel@tonic-gate	${ECHO} "ERROR: passwords don't match; try again."
6447c478bd9Sstevel@tonic-gate    done
6457c478bd9Sstevel@tonic-gate
6467c478bd9Sstevel@tonic-gate    /usr/bin/stty echo      # Turn echo ON
6477c478bd9Sstevel@tonic-gate
6487c478bd9Sstevel@tonic-gate    ${ECHO} ""
6497c478bd9Sstevel@tonic-gate}
6507c478bd9Sstevel@tonic-gate
6517c478bd9Sstevel@tonic-gate
6527c478bd9Sstevel@tonic-gate#
6537c478bd9Sstevel@tonic-gate# get_passwd_nochk(): Reads a password from the user w/o check.
6547c478bd9Sstevel@tonic-gate#		$@  instruction/comment/description/question
6557c478bd9Sstevel@tonic-gate#
6567c478bd9Sstevel@tonic-gateget_passwd_nochk()
6577c478bd9Sstevel@tonic-gate{
6587c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In get_passwd_nochk()"
6597c478bd9Sstevel@tonic-gate
6607c478bd9Sstevel@tonic-gate    /usr/bin/stty -echo     # Turn echo OFF
6617c478bd9Sstevel@tonic-gate
6627c478bd9Sstevel@tonic-gate    get_ans "$@"
6637c478bd9Sstevel@tonic-gate
6647c478bd9Sstevel@tonic-gate    /usr/bin/stty echo      # Turn echo ON
6657c478bd9Sstevel@tonic-gate
6667c478bd9Sstevel@tonic-gate    ${ECHO} ""
6677c478bd9Sstevel@tonic-gate}
6687c478bd9Sstevel@tonic-gate
6697c478bd9Sstevel@tonic-gate
6707c478bd9Sstevel@tonic-gate#
6717c478bd9Sstevel@tonic-gate# get_menu_choice(): Get a menu choice from user.  Continue prompting
6727c478bd9Sstevel@tonic-gate#                    till the choice is in required range.
6737c478bd9Sstevel@tonic-gate#   $1 .. Message text.
6747c478bd9Sstevel@tonic-gate#   $2 .. min value
6757c478bd9Sstevel@tonic-gate#   $3 .. max value
6767c478bd9Sstevel@tonic-gate#   $4 .. OPTIONAL: default value
6777c478bd9Sstevel@tonic-gate#
6787c478bd9Sstevel@tonic-gate#   Return value:
6797c478bd9Sstevel@tonic-gate#     MN_CH will contain the value selected.
6807c478bd9Sstevel@tonic-gate#
6817c478bd9Sstevel@tonic-gateget_menu_choice()
6827c478bd9Sstevel@tonic-gate{
6837c478bd9Sstevel@tonic-gate    # Check for req parameter.
6847c478bd9Sstevel@tonic-gate    if [ $# -lt 3 ]; then
6857c478bd9Sstevel@tonic-gate	${ECHO} "get_menu_choice(): Did not get required parameters."
6867c478bd9Sstevel@tonic-gate	return 1
6877c478bd9Sstevel@tonic-gate    fi
6887c478bd9Sstevel@tonic-gate
6897c478bd9Sstevel@tonic-gate    while :
6907c478bd9Sstevel@tonic-gate    do
6917c478bd9Sstevel@tonic-gate	get_ans "$1" "$4"
6927c478bd9Sstevel@tonic-gate	MN_CH=$ANS
6937c478bd9Sstevel@tonic-gate	is_negative $MN_CH
6947c478bd9Sstevel@tonic-gate	if [ $? -eq 1 ]; then
6957c478bd9Sstevel@tonic-gate	    if [ $MN_CH -ge $2 ]; then
6967c478bd9Sstevel@tonic-gate		if [ $MN_CH -le $3 ]; then
6977c478bd9Sstevel@tonic-gate		    return
6987c478bd9Sstevel@tonic-gate		fi
6997c478bd9Sstevel@tonic-gate	    fi
7007c478bd9Sstevel@tonic-gate	fi
7017c478bd9Sstevel@tonic-gate	${ECHO} "Invalid choice: $MN_CH"
7027c478bd9Sstevel@tonic-gate    done
7037c478bd9Sstevel@tonic-gate}
7047c478bd9Sstevel@tonic-gate
7057c478bd9Sstevel@tonic-gate
7067c478bd9Sstevel@tonic-gate#
7077c478bd9Sstevel@tonic-gate# get_confirm(): Get confirmation from the user. (Y/Yes or N/No)
7087c478bd9Sstevel@tonic-gate#                $1 - Message
7097c478bd9Sstevel@tonic-gate#                $2 - default value.
7107c478bd9Sstevel@tonic-gate#
7117c478bd9Sstevel@tonic-gateget_confirm()
7127c478bd9Sstevel@tonic-gate{
7137c478bd9Sstevel@tonic-gate    _ANSWER=
7147c478bd9Sstevel@tonic-gate
7157c478bd9Sstevel@tonic-gate    while :
7167c478bd9Sstevel@tonic-gate    do
7177c478bd9Sstevel@tonic-gate	# Display Internal ERROR if $2 not set.
7187c478bd9Sstevel@tonic-gate	if [ -z "$2" ]
7197c478bd9Sstevel@tonic-gate	then
7207c478bd9Sstevel@tonic-gate	    ${ECHO} "INTERNAL ERROR: get_confirm requires 2 args, 3rd is optional."
7217c478bd9Sstevel@tonic-gate	    exit 2
7227c478bd9Sstevel@tonic-gate	fi
7237c478bd9Sstevel@tonic-gate
7247c478bd9Sstevel@tonic-gate	# Display prompt.
7257c478bd9Sstevel@tonic-gate	${ECHO} "$1 [$2] \c"
7267c478bd9Sstevel@tonic-gate
7277c478bd9Sstevel@tonic-gate	# Get the ANSWER.
7287c478bd9Sstevel@tonic-gate	read _ANSWER
7297c478bd9Sstevel@tonic-gate	if [ "$_ANSWER" = "" ] && [ -n "$2" ] ; then
7307c478bd9Sstevel@tonic-gate	    _ANSWER=$2
7317c478bd9Sstevel@tonic-gate	fi
7327c478bd9Sstevel@tonic-gate	case "$_ANSWER" in
7337c478bd9Sstevel@tonic-gate	    [Yy] | yes | Yes | YES) return 1 ;;
7347c478bd9Sstevel@tonic-gate	    [Nn] | no  | No  | NO)  return 0 ;;
7357c478bd9Sstevel@tonic-gate	    [Hh] | help | Help | \?) display_msg ${3:-sorry};;
7367c478bd9Sstevel@tonic-gate	    * ) ${ECHO} "Please enter y or n."  ;;
7377c478bd9Sstevel@tonic-gate	esac
7387c478bd9Sstevel@tonic-gate    done
7397c478bd9Sstevel@tonic-gate}
7407c478bd9Sstevel@tonic-gate
7417c478bd9Sstevel@tonic-gate
7427c478bd9Sstevel@tonic-gate#
7437c478bd9Sstevel@tonic-gate# get_confirm_nodef(): Get confirmation from the user. (Y/Yes or N/No)
7447c478bd9Sstevel@tonic-gate#                      No default value supported.
7457c478bd9Sstevel@tonic-gate#
7467c478bd9Sstevel@tonic-gateget_confirm_nodef()
7477c478bd9Sstevel@tonic-gate{
7487c478bd9Sstevel@tonic-gate    _ANSWER=
7497c478bd9Sstevel@tonic-gate
7507c478bd9Sstevel@tonic-gate    while :
7517c478bd9Sstevel@tonic-gate    do
7527c478bd9Sstevel@tonic-gate	${ECHO} "$@ \c"
7537c478bd9Sstevel@tonic-gate	read _ANSWER
7547c478bd9Sstevel@tonic-gate	case "$_ANSWER" in
7557c478bd9Sstevel@tonic-gate	    [Yy] | yes | Yes | YES) return 1 ;;
7567c478bd9Sstevel@tonic-gate	    [Nn] | no  | No  | NO)  return 0 ;;
7577c478bd9Sstevel@tonic-gate	    * ) ${ECHO} "Please enter y or n."  ;;
7587c478bd9Sstevel@tonic-gate	esac
7597c478bd9Sstevel@tonic-gate    done
7607c478bd9Sstevel@tonic-gate}
7617c478bd9Sstevel@tonic-gate
7627c478bd9Sstevel@tonic-gate
7637c478bd9Sstevel@tonic-gate#
7647c478bd9Sstevel@tonic-gate# is_numeric(): Tells is a string is numeric.
7657c478bd9Sstevel@tonic-gate#    0 = Numeric
7667c478bd9Sstevel@tonic-gate#    1 = NOT Numeric
7677c478bd9Sstevel@tonic-gate#
7687c478bd9Sstevel@tonic-gateis_numeric()
7697c478bd9Sstevel@tonic-gate{
7707c478bd9Sstevel@tonic-gate    # Check for parameter.
7717c478bd9Sstevel@tonic-gate    if [ $# -ne 1 ]; then
7727c478bd9Sstevel@tonic-gate	return 1
7737c478bd9Sstevel@tonic-gate    fi
7747c478bd9Sstevel@tonic-gate
7757c478bd9Sstevel@tonic-gate    # Determine if numeric.
7767c478bd9Sstevel@tonic-gate    expr "$1" + 1 > /dev/null 2>&1
7777c478bd9Sstevel@tonic-gate    if [ $? -ge 2 ]; then
7787c478bd9Sstevel@tonic-gate	return 1
7797c478bd9Sstevel@tonic-gate    fi
7807c478bd9Sstevel@tonic-gate
7817c478bd9Sstevel@tonic-gate    # Made it here, it's Numeric.
7827c478bd9Sstevel@tonic-gate    return 0
7837c478bd9Sstevel@tonic-gate}
7847c478bd9Sstevel@tonic-gate
7857c478bd9Sstevel@tonic-gate
7867c478bd9Sstevel@tonic-gate#
7877c478bd9Sstevel@tonic-gate# not_numeric(): Reverses the return values of is_numeric.  Useful
7887c478bd9Sstevel@tonic-gate#                 for if and while statements that want to test for
7897c478bd9Sstevel@tonic-gate#                 non-numeric data.
7907c478bd9Sstevel@tonic-gate#    0 = NOT Numeric
7917c478bd9Sstevel@tonic-gate#    1 = Numeric
7927c478bd9Sstevel@tonic-gate#
7937c478bd9Sstevel@tonic-gatenot_numeric()
7947c478bd9Sstevel@tonic-gate{
7957c478bd9Sstevel@tonic-gate    is_numeric $1
7967c478bd9Sstevel@tonic-gate    if [ $? -eq 0 ]; then
7977c478bd9Sstevel@tonic-gate       return 1
7987c478bd9Sstevel@tonic-gate    else
7997c478bd9Sstevel@tonic-gate       return 0
8007c478bd9Sstevel@tonic-gate    fi
8017c478bd9Sstevel@tonic-gate}
8027c478bd9Sstevel@tonic-gate
8037c478bd9Sstevel@tonic-gate
8047c478bd9Sstevel@tonic-gate#
8057c478bd9Sstevel@tonic-gate# is_negative(): Tells is a Numeric value is less than zero.
8067c478bd9Sstevel@tonic-gate#    0 = Negative Numeric
8077c478bd9Sstevel@tonic-gate#    1 = Positive Numeric
8087c478bd9Sstevel@tonic-gate#    2 = NOT Numeric
8097c478bd9Sstevel@tonic-gate#
8107c478bd9Sstevel@tonic-gateis_negative()
8117c478bd9Sstevel@tonic-gate{
8127c478bd9Sstevel@tonic-gate    # Check for parameter.
8137c478bd9Sstevel@tonic-gate    if [ $# -ne 1 ]; then
8147c478bd9Sstevel@tonic-gate	return 1
8157c478bd9Sstevel@tonic-gate    fi
8167c478bd9Sstevel@tonic-gate
8177c478bd9Sstevel@tonic-gate    # Determine if numeric.  Can't use expr because -0 is
8187c478bd9Sstevel@tonic-gate    # considered positive??
8197c478bd9Sstevel@tonic-gate    if is_numeric $1; then
8207c478bd9Sstevel@tonic-gate	case "$1" in
8217c478bd9Sstevel@tonic-gate	    -*)  return 0 ;;   # Negative Numeric
8227c478bd9Sstevel@tonic-gate	    *)   return 1 ;;   # Positive Numeric
8237c478bd9Sstevel@tonic-gate	esac
8247c478bd9Sstevel@tonic-gate    else
8257c478bd9Sstevel@tonic-gate	return 2
8267c478bd9Sstevel@tonic-gate    fi
8277c478bd9Sstevel@tonic-gate}
8287c478bd9Sstevel@tonic-gate
8297c478bd9Sstevel@tonic-gate
8307c478bd9Sstevel@tonic-gate#
8317c478bd9Sstevel@tonic-gate# check_domainname(): check validity of a domain name.  Currently we check
8327c478bd9Sstevel@tonic-gate#                     that it has at least two components.
8337c478bd9Sstevel@tonic-gate#		$1  the domain name to be checked
8347c478bd9Sstevel@tonic-gate#
8357c478bd9Sstevel@tonic-gatecheck_domainname()
8367c478bd9Sstevel@tonic-gate{
8377c478bd9Sstevel@tonic-gate    if [ ! -z "$1" ]
8387c478bd9Sstevel@tonic-gate    then
8397c478bd9Sstevel@tonic-gate	t=`expr "$1" : '[^.]\{1,\}[.][^.]\{1,\}'`
8407c478bd9Sstevel@tonic-gate	if [ "$t" = 0 ]
8417c478bd9Sstevel@tonic-gate	then
8427c478bd9Sstevel@tonic-gate	    return 1
8437c478bd9Sstevel@tonic-gate	fi
8447c478bd9Sstevel@tonic-gate    fi
8457c478bd9Sstevel@tonic-gate    return 0
8467c478bd9Sstevel@tonic-gate}
8477c478bd9Sstevel@tonic-gate
8487c478bd9Sstevel@tonic-gate
8497c478bd9Sstevel@tonic-gate#
8507c478bd9Sstevel@tonic-gate# check_baseDN(): check validity of the baseDN name.
8517c478bd9Sstevel@tonic-gate#		$1  the baseDN name to be checked
8527c478bd9Sstevel@tonic-gate#
8537c478bd9Sstevel@tonic-gate#     NOTE: The check_baseDN function does not catch all invalid DN's.
8547c478bd9Sstevel@tonic-gate#           Its purpose is to reduce the number of invalid DN's to
8557c478bd9Sstevel@tonic-gate#           get past the input routine.  The invalid DN's will be
8567c478bd9Sstevel@tonic-gate#           caught by the LDAP server when they are attempted to be
8577c478bd9Sstevel@tonic-gate#           created.
8587c478bd9Sstevel@tonic-gate#
8597c478bd9Sstevel@tonic-gatecheck_baseDN()
8607c478bd9Sstevel@tonic-gate{
8617c478bd9Sstevel@tonic-gate    ck_DN=$1
8627c478bd9Sstevel@tonic-gate    ${ECHO} "  Checking LDAP Base DN ..."
8637c478bd9Sstevel@tonic-gate    if [ ! -z "$ck_DN" ]; then
8647c478bd9Sstevel@tonic-gate        [ $DEBUG -eq 1 ] && ${ECHO} "Checking baseDN: $ck_DN"
8657c478bd9Sstevel@tonic-gate        # Check for = (assignment operator)
8667c478bd9Sstevel@tonic-gate        ${ECHO} "$ck_DN" | ${GREP} "=" > /dev/null 2>&1
8677c478bd9Sstevel@tonic-gate        if [ $? -ne 0 ]; then
8687c478bd9Sstevel@tonic-gate            [ $DEBUG -eq 1 ] && ${ECHO} "check_baseDN: No '=' in baseDN."
8697c478bd9Sstevel@tonic-gate            return 1
8707c478bd9Sstevel@tonic-gate        fi
8717c478bd9Sstevel@tonic-gate
8727c478bd9Sstevel@tonic-gate        # Check all keys.
8737c478bd9Sstevel@tonic-gate        while :
8747c478bd9Sstevel@tonic-gate        do
8757c478bd9Sstevel@tonic-gate            # Get first key.
8767c478bd9Sstevel@tonic-gate            dkey=`${ECHO} $ck_DN | cut -d'=' -f1`
8777c478bd9Sstevel@tonic-gate
8787c478bd9Sstevel@tonic-gate            # Check that the key string is valid
8797c478bd9Sstevel@tonic-gate	    check_attrName $dkey
8807c478bd9Sstevel@tonic-gate	    if [ $? -ne 0 ]; then
8817c478bd9Sstevel@tonic-gate                [ $DEBUG -eq 1 ] && ${ECHO} "check_baseDN: invalid key=${dkey}"
8827c478bd9Sstevel@tonic-gate                return 1
8837c478bd9Sstevel@tonic-gate            fi
8847c478bd9Sstevel@tonic-gate
8857c478bd9Sstevel@tonic-gate            [ $DEBUG -eq 1 ] && ${ECHO} "check_baseDN: valid key=${dkey}"
8867c478bd9Sstevel@tonic-gate
8877c478bd9Sstevel@tonic-gate            # Remove first key from DN
8887c478bd9Sstevel@tonic-gate            ck_DN=`${ECHO} $ck_DN | cut -s -d',' -f2-`
8897c478bd9Sstevel@tonic-gate
8907c478bd9Sstevel@tonic-gate            # Break loop if nothing left.
8917c478bd9Sstevel@tonic-gate            if [ "$ck_DN" = "" ]; then
8927c478bd9Sstevel@tonic-gate                break
8937c478bd9Sstevel@tonic-gate            fi
8947c478bd9Sstevel@tonic-gate        done
8957c478bd9Sstevel@tonic-gate    fi
8967c478bd9Sstevel@tonic-gate    return 0
8977c478bd9Sstevel@tonic-gate}
8987c478bd9Sstevel@tonic-gate
8997c478bd9Sstevel@tonic-gate
9007c478bd9Sstevel@tonic-gate#
9017c478bd9Sstevel@tonic-gate# domain_2_dc(): Convert a domain name into dc string.
9027c478bd9Sstevel@tonic-gate#    $1  .. Domain name.
9037c478bd9Sstevel@tonic-gate#
9047c478bd9Sstevel@tonic-gatedomain_2_dc()
9057c478bd9Sstevel@tonic-gate{
9067c478bd9Sstevel@tonic-gate    _DOM=$1           # Domain parameter.
9077c478bd9Sstevel@tonic-gate    _DOM_2_DC=""      # Return value from function.
9087c478bd9Sstevel@tonic-gate    _FIRST=1          # Flag for first time.
9097c478bd9Sstevel@tonic-gate
9107c478bd9Sstevel@tonic-gate    export _DOM_2_DC  # Make visible for others.
9117c478bd9Sstevel@tonic-gate
9127c478bd9Sstevel@tonic-gate    # Convert "."'s to spaces for "for" loop.
9137c478bd9Sstevel@tonic-gate    domtmp="`${ECHO} ${_DOM} | tr '.' ' '`"
9147c478bd9Sstevel@tonic-gate    for i in $domtmp; do
9157c478bd9Sstevel@tonic-gate	if [ $_FIRST -eq 1 ]; then
9167c478bd9Sstevel@tonic-gate	    _DOM_2_DC="dc=${i}"
9177c478bd9Sstevel@tonic-gate	    _FIRST=0
9187c478bd9Sstevel@tonic-gate	else
9197c478bd9Sstevel@tonic-gate	    _DOM_2_DC="${_DOM_2_DC},dc=${i}"
9207c478bd9Sstevel@tonic-gate	fi
9217c478bd9Sstevel@tonic-gate    done
9227c478bd9Sstevel@tonic-gate}
9237c478bd9Sstevel@tonic-gate
9247c478bd9Sstevel@tonic-gate
9257c478bd9Sstevel@tonic-gate#
9267c478bd9Sstevel@tonic-gate# is_root_user(): Check to see if logged in as root user.
9277c478bd9Sstevel@tonic-gate#
9287c478bd9Sstevel@tonic-gateis_root_user()
9297c478bd9Sstevel@tonic-gate{
9307c478bd9Sstevel@tonic-gate    case `id` in
9317c478bd9Sstevel@tonic-gate	uid=0\(root\)*) return 0 ;;
9327c478bd9Sstevel@tonic-gate	* )             return 1 ;;
9337c478bd9Sstevel@tonic-gate    esac
9347c478bd9Sstevel@tonic-gate}
9357c478bd9Sstevel@tonic-gate
9367c478bd9Sstevel@tonic-gate
9377c478bd9Sstevel@tonic-gate#
9387c478bd9Sstevel@tonic-gate# parse_arg(): Parses the command line arguments and sets the
9397c478bd9Sstevel@tonic-gate#              appropriate variables.
9407c478bd9Sstevel@tonic-gate#
9417c478bd9Sstevel@tonic-gateparse_arg()
9427c478bd9Sstevel@tonic-gate{
9437c478bd9Sstevel@tonic-gate    while getopts "dvhi:o:" ARG
9447c478bd9Sstevel@tonic-gate    do
9457c478bd9Sstevel@tonic-gate	case $ARG in
9467c478bd9Sstevel@tonic-gate	    d)      DEBUG=1;;
9477c478bd9Sstevel@tonic-gate	    v)      VERB="";;
9487c478bd9Sstevel@tonic-gate	    i)      INPUT_FILE=$OPTARG;;
9497c478bd9Sstevel@tonic-gate	    o)      OUTPUT_FILE=$OPTARG;;
9507c478bd9Sstevel@tonic-gate	    \?)	display_msg usage
9517c478bd9Sstevel@tonic-gate		    exit 1;;
9527c478bd9Sstevel@tonic-gate	    *)	${ECHO} "**ERROR: Supported option missing handler!"
9537c478bd9Sstevel@tonic-gate		    display_msg usage
9547c478bd9Sstevel@tonic-gate		    exit 1;;
9557c478bd9Sstevel@tonic-gate	esac
9567c478bd9Sstevel@tonic-gate    done
9577c478bd9Sstevel@tonic-gate    return `expr $OPTIND - 1`
9587c478bd9Sstevel@tonic-gate}
9597c478bd9Sstevel@tonic-gate
9607c478bd9Sstevel@tonic-gate
9617c478bd9Sstevel@tonic-gate#
9627c478bd9Sstevel@tonic-gate# init(): initializes variables and options
9637c478bd9Sstevel@tonic-gate#
9647c478bd9Sstevel@tonic-gateinit()
9657c478bd9Sstevel@tonic-gate{
9667c478bd9Sstevel@tonic-gate    # General variables.
9677c478bd9Sstevel@tonic-gate    PROG=`basename $0`	# Program name
9687c478bd9Sstevel@tonic-gate    PID=$$              # Program ID
9697c478bd9Sstevel@tonic-gate    VERB='> /dev/null 2>&1'	# NULL or "> /dev/null"
9707c478bd9Sstevel@tonic-gate    ECHO="/bin/echo"	# print message on screen
9717c478bd9Sstevel@tonic-gate    EVAL="eval"		# eval or echo
9727c478bd9Sstevel@tonic-gate    EGREP="/usr/bin/egrep"
9737c478bd9Sstevel@tonic-gate    GREP="/usr/bin/grep"
9747c478bd9Sstevel@tonic-gate    DEBUG=0             # Set Debug OFF
9757c478bd9Sstevel@tonic-gate    BACKUP=no_ldap	# backup suffix
9767c478bd9Sstevel@tonic-gate    HOST=""		# NULL or <hostname>
977cb5caa98Sdjl    NAWK="/usr/bin/nawk"
978dd1104fbSMichen Chang    RM="/usr/bin/rm"
979b57459abSJulian Pullen    WC="/usr/bin/wc"
980b57459abSJulian Pullen    CAT="/usr/bin/cat"
981b57459abSJulian Pullen    SED="/usr/bin/sed"
982ad848a7fSMilan Jurik    MV="/usr/bin/mv"
9837c478bd9Sstevel@tonic-gate
9847c478bd9Sstevel@tonic-gate    DOM=""              # Set to NULL
9857c478bd9Sstevel@tonic-gate    # If DNS domain (resolv.conf) exists use that, otherwise use domainname.
9867c478bd9Sstevel@tonic-gate    if [ -f /etc/resolv.conf ]; then
9877c478bd9Sstevel@tonic-gate        DOM=`/usr/xpg4/bin/grep -i -E '^domain|^search' /etc/resolv.conf \
9887c478bd9Sstevel@tonic-gate	    | awk '{ print $2 }' | tail -1`
9897c478bd9Sstevel@tonic-gate    fi
9907c478bd9Sstevel@tonic-gate
9917c478bd9Sstevel@tonic-gate    # If for any reason the DOM did not get set (error'd resolv.conf) set
9927c478bd9Sstevel@tonic-gate    # DOM to the domainname command's output.
9937c478bd9Sstevel@tonic-gate    if [ "$DOM" = "" ]; then
9947c478bd9Sstevel@tonic-gate        DOM=`domainname`	# domain from domainname command.
9957c478bd9Sstevel@tonic-gate    fi
9967c478bd9Sstevel@tonic-gate
9977c478bd9Sstevel@tonic-gate    STEP=1
9987c478bd9Sstevel@tonic-gate    INTERACTIVE=1       # 0 = on, 1 = off (For input file mode)
9997c478bd9Sstevel@tonic-gate    DEL_OLD_PROFILE=0   # 0 (default), 1 = delete old profile.
10007c478bd9Sstevel@tonic-gate
10017c478bd9Sstevel@tonic-gate    # idsconfig specific variables.
10027c478bd9Sstevel@tonic-gate    INPUT_FILE=""
10037c478bd9Sstevel@tonic-gate    OUTPUT_FILE=""
1004dd1104fbSMichen Chang    LDAP_ENABLE_SHADOW_UPDATE="FALSE"
10057c478bd9Sstevel@tonic-gate    NEED_PROXY=0        # 0 = No Proxy,    1 = Create Proxy.
1006dd1104fbSMichen Chang    NEED_ADMIN=0        # 0 = No Admin,    1 = Create Admin.
1007dd1104fbSMichen Chang    NEED_HOSTACL=0      # 0 = No Host ACL, 1 = Create Host ACL.
1008dd1104fbSMichen Chang    EXISTING_PROFILE=0
10097c478bd9Sstevel@tonic-gate    LDAP_PROXYAGENT=""
1010dd1104fbSMichen Chang    LDAP_ADMINDN=""
10117c478bd9Sstevel@tonic-gate    LDAP_SUFFIX=""
10127c478bd9Sstevel@tonic-gate    LDAP_DOMAIN=$DOM	# domainname on Server (default value)
10137c478bd9Sstevel@tonic-gate    GEN_CMD=""
1014b57459abSJulian Pullen    PROXY_ACI_NAME="LDAP_Naming_Services_proxy_password_read"
10157c478bd9Sstevel@tonic-gate
10167c478bd9Sstevel@tonic-gate    # LDAP COMMANDS
10177c478bd9Sstevel@tonic-gate    LDAPSEARCH="/bin/ldapsearch -r"
10187c478bd9Sstevel@tonic-gate    LDAPMODIFY=/bin/ldapmodify
10197c478bd9Sstevel@tonic-gate    LDAPADD=/bin/ldapadd
10207c478bd9Sstevel@tonic-gate    LDAPDELETE=/bin/ldapdelete
10217c478bd9Sstevel@tonic-gate    LDAP_GEN_PROFILE=/usr/sbin/ldap_gen_profile
10227c478bd9Sstevel@tonic-gate
10237c478bd9Sstevel@tonic-gate    # iDS specific information
10247c478bd9Sstevel@tonic-gate    IDS_SERVER=""
10257c478bd9Sstevel@tonic-gate    IDS_PORT=389
10267c478bd9Sstevel@tonic-gate    NEED_TIME=0
10277c478bd9Sstevel@tonic-gate    NEED_SIZE=0
10287c478bd9Sstevel@tonic-gate    NEED_SRVAUTH_PAM=0
10297c478bd9Sstevel@tonic-gate    NEED_SRVAUTH_KEY=0
10307c478bd9Sstevel@tonic-gate    NEED_SRVAUTH_CMD=0
10317c478bd9Sstevel@tonic-gate    IDS_TIMELIMIT=""
10327c478bd9Sstevel@tonic-gate    IDS_SIZELIMIT=""
10337c478bd9Sstevel@tonic-gate
10347c478bd9Sstevel@tonic-gate    # LDAP PROFILE related defaults
10357c478bd9Sstevel@tonic-gate    LDAP_ROOTDN="cn=Directory Manager"   # Provide common default.
10367c478bd9Sstevel@tonic-gate    LDAP_ROOTPWD=""                      # NULL passwd as default (i.e. invalid)
10377c478bd9Sstevel@tonic-gate    LDAP_PROFILE_NAME="default"
10387c478bd9Sstevel@tonic-gate    LDAP_BASEDN=""
10397c478bd9Sstevel@tonic-gate    LDAP_SERVER_LIST=""
10407c478bd9Sstevel@tonic-gate    LDAP_AUTHMETHOD=""
10417c478bd9Sstevel@tonic-gate    LDAP_FOLLOWREF="FALSE"
10427c478bd9Sstevel@tonic-gate    NEED_CRYPT=""
10437c478bd9Sstevel@tonic-gate    LDAP_SEARCH_SCOPE="one"
10447c478bd9Sstevel@tonic-gate    LDAP_SRV_AUTHMETHOD_PAM=""
10457c478bd9Sstevel@tonic-gate    LDAP_SRV_AUTHMETHOD_KEY=""
10467c478bd9Sstevel@tonic-gate    LDAP_SRV_AUTHMETHOD_CMD=""
10477c478bd9Sstevel@tonic-gate    LDAP_SEARCH_TIME_LIMIT=30
10487c478bd9Sstevel@tonic-gate    LDAP_PREF_SRVLIST=""
10497c478bd9Sstevel@tonic-gate    LDAP_PROFILE_TTL=43200
10507c478bd9Sstevel@tonic-gate    LDAP_CRED_LEVEL="proxy"
10517c478bd9Sstevel@tonic-gate    LDAP_BIND_LIMIT=10
10527c478bd9Sstevel@tonic-gate
10537c478bd9Sstevel@tonic-gate    # Prevent new files from being read by group or others.
10547c478bd9Sstevel@tonic-gate    umask 077
10557c478bd9Sstevel@tonic-gate
10567c478bd9Sstevel@tonic-gate    # Service Search Descriptors
10577c478bd9Sstevel@tonic-gate    LDAP_SERV_SRCH_DES=""
10587c478bd9Sstevel@tonic-gate
10597c478bd9Sstevel@tonic-gate    # Set and create TMPDIR.
10607c478bd9Sstevel@tonic-gate    TMPDIR="/tmp/idsconfig.${PID}"
10617c478bd9Sstevel@tonic-gate    if mkdir -m 700 ${TMPDIR}
10627c478bd9Sstevel@tonic-gate    then
10637c478bd9Sstevel@tonic-gate	# Cleanup on exit.
10647c478bd9Sstevel@tonic-gate	trap 'rm -rf ${TMPDIR}; /usr/bin/stty echo; exit' 1 2 3 6 15
10657c478bd9Sstevel@tonic-gate    else
10667c478bd9Sstevel@tonic-gate	echo "ERROR: unable to create a safe temporary directory."
10677c478bd9Sstevel@tonic-gate	exit 1
10687c478bd9Sstevel@tonic-gate    fi
10697c478bd9Sstevel@tonic-gate    LDAP_ROOTPWF=${TMPDIR}/rootPWD
10707c478bd9Sstevel@tonic-gate
10717c478bd9Sstevel@tonic-gate    # Set the SSD file name after setting TMPDIR.
10727c478bd9Sstevel@tonic-gate    SSD_FILE=${TMPDIR}/ssd_list
10737c478bd9Sstevel@tonic-gate
1074cb5caa98Sdjl    # GSSAPI setup
10754f4e8bf0SMilan Jurik    GSSAPI_ENABLE=0
1076cb5caa98Sdjl    LDAP_KRB_REALM=""
1077cb5caa98Sdjl    SCHEMA_UPDATED=0
1078cb5caa98Sdjl
10797c478bd9Sstevel@tonic-gate    export DEBUG VERB ECHO EVAL EGREP GREP STEP TMPDIR
10807c478bd9Sstevel@tonic-gate    export IDS_SERVER IDS_PORT LDAP_ROOTDN LDAP_ROOTPWD LDAP_SERVER_LIST
10817c478bd9Sstevel@tonic-gate    export LDAP_BASEDN LDAP_ROOTPWF
10827c478bd9Sstevel@tonic-gate    export LDAP_DOMAIN LDAP_SUFFIX LDAP_PROXYAGENT LDAP_PROXYAGENT_CRED
10837c478bd9Sstevel@tonic-gate    export NEED_PROXY
1084dd1104fbSMichen Chang    export LDAP_ENABLE_SHADOW_UPDATE LDAP_ADMINDN LDAP_ADMIN_CRED
1085dd1104fbSMichen Chang    export NEED_ADMIN NEED_HOSTACL EXISTING_PROFILE
10867c478bd9Sstevel@tonic-gate    export LDAP_PROFILE_NAME LDAP_BASEDN LDAP_SERVER_LIST
10877c478bd9Sstevel@tonic-gate    export LDAP_AUTHMETHOD LDAP_FOLLOWREF LDAP_SEARCH_SCOPE LDAP_SEARCH_TIME_LIMIT
10887c478bd9Sstevel@tonic-gate    export LDAP_PREF_SRVLIST LDAP_PROFILE_TTL LDAP_CRED_LEVEL LDAP_BIND_LIMIT
10897c478bd9Sstevel@tonic-gate    export NEED_SRVAUTH_PAM NEED_SRVAUTH_KEY NEED_SRVAUTH_CMD
10907c478bd9Sstevel@tonic-gate    export LDAP_SRV_AUTHMETHOD_PAM LDAP_SRV_AUTHMETHOD_KEY LDAP_SRV_AUTHMETHOD_CMD
10917c478bd9Sstevel@tonic-gate    export LDAP_SERV_SRCH_DES SSD_FILE
10924f4e8bf0SMilan Jurik    export GEN_CMD GSSAPI_ENABLE LDAP_KRB_REALM SCHEMA_UPDATED
10937c478bd9Sstevel@tonic-gate}
10947c478bd9Sstevel@tonic-gate
10957c478bd9Sstevel@tonic-gate
10967c478bd9Sstevel@tonic-gate#
10977c478bd9Sstevel@tonic-gate# disp_full_debug(): List of all debug variables usually interested in.
10987c478bd9Sstevel@tonic-gate#                    Grouped to avoid MASSIVE code duplication.
10997c478bd9Sstevel@tonic-gate#
11007c478bd9Sstevel@tonic-gatedisp_full_debug()
11017c478bd9Sstevel@tonic-gate{
11027c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  IDS_SERVER = $IDS_SERVER"
11037c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  IDS_PORT = $IDS_PORT"
11047c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_ROOTDN = $LDAP_ROOTDN"
11057c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_ROOTPWD = $LDAP_ROOTPWD"
11067c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_DOMAIN = $LDAP_DOMAIN"
11077c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_SUFFIX = $LDAP_SUFFIX"
11087c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_BASEDN = $LDAP_BASEDN"
11097c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_PROFILE_NAME = $LDAP_PROFILE_NAME"
11107c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_SERVER_LIST = $LDAP_SERVER_LIST"
11117c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_PREF_SRVLIST = $LDAP_PREF_SRVLIST"
11127c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_SEARCH_SCOPE = $LDAP_SEARCH_SCOPE"
11137c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_CRED_LEVEL = $LDAP_CRED_LEVEL"
11147c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_AUTHMETHOD = $LDAP_AUTHMETHOD"
11157c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_FOLLOWREF = $LDAP_FOLLOWREF"
11167c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  IDS_TIMELIMIT = $IDS_TIMELIMIT"
11177c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  IDS_SIZELIMIT = $IDS_SIZELIMIT"
11187c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  NEED_CRYPT = $NEED_CRYPT"
11197c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  NEED_SRVAUTH_PAM = $NEED_SRVAUTH_PAM"
11207c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  NEED_SRVAUTH_KEY = $NEED_SRVAUTH_KEY"
11217c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  NEED_SRVAUTH_CMD = $NEED_SRVAUTH_CMD"
11227c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_SRV_AUTHMETHOD_PAM = $LDAP_SRV_AUTHMETHOD_PAM"
11237c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_SRV_AUTHMETHOD_KEY = $LDAP_SRV_AUTHMETHOD_KEY"
11247c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_SRV_AUTHMETHOD_CMD = $LDAP_SRV_AUTHMETHOD_CMD"
11257c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_SEARCH_TIME_LIMIT = $LDAP_SEARCH_TIME_LIMIT"
11267c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_PROFILE_TTL = $LDAP_PROFILE_TTL"
11277c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_BIND_LIMIT = $LDAP_BIND_LIMIT"
1128dd1104fbSMichen Chang    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_ENABLE_SHADOW_UPDATE = $LDAP_ENABLE_SHADOW_UPDATE"
11297c478bd9Sstevel@tonic-gate
11307c478bd9Sstevel@tonic-gate    # Only display proxy stuff if needed.
1131dd1104fbSMichen Chang    [ $DEBUG -eq 1 ] && ${ECHO} "  NEED_PROXY = $NEED_PROXY"
11327c478bd9Sstevel@tonic-gate    if [ $NEED_PROXY -eq  1 ]; then
11337c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_PROXYAGENT = $LDAP_PROXYAGENT"
11347c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_PROXYAGENT_CRED = $LDAP_PROXYAGENT_CRED"
1135dd1104fbSMichen Chang    fi
1136dd1104fbSMichen Chang
1137dd1104fbSMichen Chang    # Only display admin credential if needed.
1138dd1104fbSMichen Chang    [ $DEBUG -eq 1 ] && ${ECHO} "  NEED_ADMIN = $NEED_ADMIN"
1139dd1104fbSMichen Chang    [ $DEBUG -eq 1 ] && ${ECHO} "  NEED_HOSTACL = $NEED_HOSTACL"
1140dd1104fbSMichen Chang    if [ $NEED_ADMIN -eq  1 ]; then
1141dd1104fbSMichen Chang	[ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_ADMINDN = $LDAP_ADMINDN"
1142dd1104fbSMichen Chang	[ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_ADMIN_CRED = $LDAP_ADMIN_CRED"
11437c478bd9Sstevel@tonic-gate    fi
11447c478bd9Sstevel@tonic-gate
11457c478bd9Sstevel@tonic-gate    # Service Search Descriptors are a special case.
11467c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_SERV_SRCH_DES = $LDAP_SERV_SRCH_DES"
11477c478bd9Sstevel@tonic-gate}
11487c478bd9Sstevel@tonic-gate
11497c478bd9Sstevel@tonic-gate
11507c478bd9Sstevel@tonic-gate#
11517c478bd9Sstevel@tonic-gate# load_config_file(): Loads the config file.
11527c478bd9Sstevel@tonic-gate#
11537c478bd9Sstevel@tonic-gateload_config_file()
11547c478bd9Sstevel@tonic-gate{
11557c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In load_config_file()"
11567c478bd9Sstevel@tonic-gate
11577c478bd9Sstevel@tonic-gate    # Remove SSD lines from input file before sourcing.
11587c478bd9Sstevel@tonic-gate    # The SSD lines must be removed because some forms of the
11597c478bd9Sstevel@tonic-gate    # data could cause SHELL errors.
11607c478bd9Sstevel@tonic-gate    ${GREP} -v "LDAP_SERV_SRCH_DES=" ${INPUT_FILE} > ${TMPDIR}/inputfile.noSSD
11617c478bd9Sstevel@tonic-gate
11627c478bd9Sstevel@tonic-gate    # Source the input file.
11637c478bd9Sstevel@tonic-gate    . ${TMPDIR}/inputfile.noSSD
11647c478bd9Sstevel@tonic-gate
11657c478bd9Sstevel@tonic-gate    # If LDAP_SUFFIX is no set, try to utilize LDAP_TREETOP since older
11667c478bd9Sstevel@tonic-gate    # config files use LDAP_TREETOP
11677c478bd9Sstevel@tonic-gate    LDAP_SUFFIX="${LDAP_SUFFIX:-$LDAP_TREETOP}"
11687c478bd9Sstevel@tonic-gate
11697c478bd9Sstevel@tonic-gate    # Save password to temporary file.
11707c478bd9Sstevel@tonic-gate    save_password
11717c478bd9Sstevel@tonic-gate
11727c478bd9Sstevel@tonic-gate    # Create the SSD file.
11737c478bd9Sstevel@tonic-gate    create_ssd_file
11747c478bd9Sstevel@tonic-gate
11757c478bd9Sstevel@tonic-gate    # Display FULL debugging info.
11767c478bd9Sstevel@tonic-gate    disp_full_debug
11777c478bd9Sstevel@tonic-gate}
11787c478bd9Sstevel@tonic-gate
11797c478bd9Sstevel@tonic-gate#
11807c478bd9Sstevel@tonic-gate# save_password(): Save password to temporary file.
11817c478bd9Sstevel@tonic-gate#
11827c478bd9Sstevel@tonic-gatesave_password()
11837c478bd9Sstevel@tonic-gate{
11847c478bd9Sstevel@tonic-gate    cat > ${LDAP_ROOTPWF} <<EOF
11857c478bd9Sstevel@tonic-gate${LDAP_ROOTPWD}
11867c478bd9Sstevel@tonic-gateEOF
11877c478bd9Sstevel@tonic-gate}
11887c478bd9Sstevel@tonic-gate
11897c478bd9Sstevel@tonic-gate######################################################################
11907c478bd9Sstevel@tonic-gate# FUNCTIONS  FOR prompt_config_info() START HERE.
11917c478bd9Sstevel@tonic-gate######################################################################
11927c478bd9Sstevel@tonic-gate
11937c478bd9Sstevel@tonic-gate#
11947c478bd9Sstevel@tonic-gate# get_ids_server(): Prompt for iDS server name.
11957c478bd9Sstevel@tonic-gate#
11967c478bd9Sstevel@tonic-gateget_ids_server()
11977c478bd9Sstevel@tonic-gate{
11987c478bd9Sstevel@tonic-gate    while :
11997c478bd9Sstevel@tonic-gate    do
12007c478bd9Sstevel@tonic-gate	# Prompt for server name.
1201cb5caa98Sdjl	get_ans "Enter the JES Directory Server's  hostname to setup:" "$IDS_SERVER"
1202cb5caa98Sdjl	IDS_SERVER="$ANS"
12037c478bd9Sstevel@tonic-gate
12047c478bd9Sstevel@tonic-gate	# Ping server to see if live.  If valid break out of loop.
12057c478bd9Sstevel@tonic-gate	ping $IDS_SERVER > /dev/null 2>&1
12067c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
12077c478bd9Sstevel@tonic-gate	    break
12087c478bd9Sstevel@tonic-gate	fi
12097c478bd9Sstevel@tonic-gate
12107c478bd9Sstevel@tonic-gate	# Invalid server, enter a new name.
12117c478bd9Sstevel@tonic-gate	${ECHO} "ERROR: Server '${IDS_SERVER}' is invalid or unreachable."
12127c478bd9Sstevel@tonic-gate	IDS_SERVER=""
12137c478bd9Sstevel@tonic-gate    done
12147c478bd9Sstevel@tonic-gate
12157c478bd9Sstevel@tonic-gate    # Set SERVER_ARGS and LDAP_ARGS since values might of changed.
12167c478bd9Sstevel@tonic-gate    SERVER_ARGS="-h ${IDS_SERVER} -p ${IDS_PORT}"
12177c478bd9Sstevel@tonic-gate    LDAP_ARGS="${SERVER_ARGS} ${AUTH_ARGS}"
12187c478bd9Sstevel@tonic-gate    export SERVER_ARGS
12197c478bd9Sstevel@tonic-gate
12207c478bd9Sstevel@tonic-gate}
12217c478bd9Sstevel@tonic-gate
12227c478bd9Sstevel@tonic-gate#
12237c478bd9Sstevel@tonic-gate# get_ids_port(): Prompt for iDS port number.
12247c478bd9Sstevel@tonic-gate#
12257c478bd9Sstevel@tonic-gateget_ids_port()
12267c478bd9Sstevel@tonic-gate{
12277c478bd9Sstevel@tonic-gate    # Get a valid iDS port number.
12287c478bd9Sstevel@tonic-gate    while :
12297c478bd9Sstevel@tonic-gate    do
12307c478bd9Sstevel@tonic-gate	# Enter port number.
12317c478bd9Sstevel@tonic-gate	get_number "Enter the port number for iDS (h=help):" "$IDS_PORT" "port_help"
12327c478bd9Sstevel@tonic-gate	IDS_PORT=$ANS
12337c478bd9Sstevel@tonic-gate	# Do a simple search to check hostname and port number.
12347c478bd9Sstevel@tonic-gate	# If search returns SUCCESS, break out, host and port must
12357c478bd9Sstevel@tonic-gate	# be valid.
12367c478bd9Sstevel@tonic-gate	${LDAPSEARCH} -h ${IDS_SERVER} -p ${IDS_PORT} -b "" -s base "objectclass=*" > /dev/null 2>&1
12377c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
12387c478bd9Sstevel@tonic-gate	    break
12397c478bd9Sstevel@tonic-gate	fi
12407c478bd9Sstevel@tonic-gate
12417c478bd9Sstevel@tonic-gate	# Invalid host/port pair, Re-enter.
12427c478bd9Sstevel@tonic-gate	${ECHO} "ERROR: Invalid host or port: ${IDS_SERVER}:${IDS_PORT}, Please re-enter!"
12437c478bd9Sstevel@tonic-gate	get_ids_server
12447c478bd9Sstevel@tonic-gate    done
12457c478bd9Sstevel@tonic-gate
12467c478bd9Sstevel@tonic-gate    # Set SERVER_ARGS and LDAP_ARGS since values might of changed.
12477c478bd9Sstevel@tonic-gate    SERVER_ARGS="-h ${IDS_SERVER} -p ${IDS_PORT}"
12487c478bd9Sstevel@tonic-gate    LDAP_ARGS="${SERVER_ARGS} ${AUTH_ARGS}"
12497c478bd9Sstevel@tonic-gate    export SERVER_ARGS
12507c478bd9Sstevel@tonic-gate}
12517c478bd9Sstevel@tonic-gate
12527c478bd9Sstevel@tonic-gate
12537c478bd9Sstevel@tonic-gate#
12547c478bd9Sstevel@tonic-gate# chk_ids_version(): Read the slapd config file and set variables
12557c478bd9Sstevel@tonic-gate#
12567c478bd9Sstevel@tonic-gatechk_ids_version()
12577c478bd9Sstevel@tonic-gate{
12587c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In chk_ids_version()"
12597c478bd9Sstevel@tonic-gate
12607c478bd9Sstevel@tonic-gate    # check iDS version number.
12617c478bd9Sstevel@tonic-gate    eval "${LDAPSEARCH} ${SERVER_ARGS} -b cn=monitor -s base \"objectclass=*\" version | ${GREP} \"^version=\" | cut -f2 -d'/' | cut -f1 -d' ' > ${TMPDIR}/checkDSver 2>&1"
12627c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
12637c478bd9Sstevel@tonic-gate	${ECHO} "ERROR: Can not determine the version number of iDS!"
12647c478bd9Sstevel@tonic-gate	exit 1
12657c478bd9Sstevel@tonic-gate    fi
12667c478bd9Sstevel@tonic-gate    IDS_VER=`cat ${TMPDIR}/checkDSver`
12677c478bd9Sstevel@tonic-gate    IDS_MAJVER=`${ECHO} ${IDS_VER} | cut -f1 -d.`
12687c478bd9Sstevel@tonic-gate    IDS_MINVER=`${ECHO} ${IDS_VER} | cut -f2 -d.`
12694f4e8bf0SMilan Jurik    case "${IDS_MAJVER}" in
12704f4e8bf0SMilan Jurik        5|6|7)  : ;;
12714f4e8bf0SMilan Jurik        *)   ${ECHO} "ERROR: $PROG only works with JES DS version 5.x, 6.x or 7.x, not ${IDS_VER}."; exit 1;;
12724f4e8bf0SMilan Jurik    esac
12734f4e8bf0SMilan Jurik
12747c478bd9Sstevel@tonic-gate    if [ $DEBUG -eq 1 ]; then
12757c478bd9Sstevel@tonic-gate	${ECHO} "  IDS_MAJVER = $IDS_MAJVER"
12767c478bd9Sstevel@tonic-gate	${ECHO} "  IDS_MINVER = $IDS_MINVER"
12777c478bd9Sstevel@tonic-gate    fi
12787c478bd9Sstevel@tonic-gate}
12797c478bd9Sstevel@tonic-gate
12807c478bd9Sstevel@tonic-gate
12817c478bd9Sstevel@tonic-gate#
12827c478bd9Sstevel@tonic-gate# get_dirmgr_dn(): Get the directory manger DN.
12837c478bd9Sstevel@tonic-gate#
12847c478bd9Sstevel@tonic-gateget_dirmgr_dn()
12857c478bd9Sstevel@tonic-gate{
12867c478bd9Sstevel@tonic-gate    get_ans "Enter the directory manager DN:" "$LDAP_ROOTDN"
12877c478bd9Sstevel@tonic-gate    LDAP_ROOTDN=$ANS
12887c478bd9Sstevel@tonic-gate
12897c478bd9Sstevel@tonic-gate    # Update ENV variables using DN.
12907c478bd9Sstevel@tonic-gate    AUTH_ARGS="-D \"${LDAP_ROOTDN}\" -j ${LDAP_ROOTPWF}"
12917c478bd9Sstevel@tonic-gate    LDAP_ARGS="${SERVER_ARGS} ${AUTH_ARGS}"
12927c478bd9Sstevel@tonic-gate    export AUTH_ARGS LDAP_ARGS
12937c478bd9Sstevel@tonic-gate}
12947c478bd9Sstevel@tonic-gate
12957c478bd9Sstevel@tonic-gate
12967c478bd9Sstevel@tonic-gate#
12977c478bd9Sstevel@tonic-gate# get_dirmgr_pw(): Get the Root DN passwd. (Root DN found in slapd.conf)
12987c478bd9Sstevel@tonic-gate#
12997c478bd9Sstevel@tonic-gateget_dirmgr_pw()
13007c478bd9Sstevel@tonic-gate{
13017c478bd9Sstevel@tonic-gate    while :
13027c478bd9Sstevel@tonic-gate    do
13037c478bd9Sstevel@tonic-gate	# Get passwd.
13047c478bd9Sstevel@tonic-gate	get_passwd_nochk "Enter passwd for ${LDAP_ROOTDN} :"
13057c478bd9Sstevel@tonic-gate	LDAP_ROOTPWD=$ANS
13067c478bd9Sstevel@tonic-gate
13077c478bd9Sstevel@tonic-gate	# Store password in file.
13087c478bd9Sstevel@tonic-gate	save_password
13097c478bd9Sstevel@tonic-gate
13107c478bd9Sstevel@tonic-gate	# Update ENV variables using DN's PW.
13117c478bd9Sstevel@tonic-gate	AUTH_ARGS="-D \"${LDAP_ROOTDN}\" -j ${LDAP_ROOTPWF}"
13127c478bd9Sstevel@tonic-gate	LDAP_ARGS="${SERVER_ARGS} ${AUTH_ARGS}"
13137c478bd9Sstevel@tonic-gate	export AUTH_ARGS LDAP_ARGS
13147c478bd9Sstevel@tonic-gate
13157c478bd9Sstevel@tonic-gate	# Verify that ROOTDN and ROOTPWD are valid.
13167c478bd9Sstevel@tonic-gate	eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"\" -s base \"objectclass=*\" > ${TMPDIR}/checkDN 2>&1"
13177c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]; then
13187c478bd9Sstevel@tonic-gate	    eval "${GREP} credential ${TMPDIR}/checkDN ${VERB}"
13197c478bd9Sstevel@tonic-gate	    if [ $? -eq 0 ]; then
13207c478bd9Sstevel@tonic-gate		${ECHO} "ERROR: Root DN passwd is invalid."
13217c478bd9Sstevel@tonic-gate	    else
13227c478bd9Sstevel@tonic-gate		${ECHO} "ERROR: Invalid Root DN <${LDAP_ROOTDN}>."
13237c478bd9Sstevel@tonic-gate		get_dirmgr_dn
13247c478bd9Sstevel@tonic-gate	    fi
13257c478bd9Sstevel@tonic-gate	else
13267c478bd9Sstevel@tonic-gate	    break         # Both are valid.
13277c478bd9Sstevel@tonic-gate	fi
13287c478bd9Sstevel@tonic-gate    done
13297c478bd9Sstevel@tonic-gate
13307c478bd9Sstevel@tonic-gate
13317c478bd9Sstevel@tonic-gate}
13327c478bd9Sstevel@tonic-gate
13337c478bd9Sstevel@tonic-gate
13347c478bd9Sstevel@tonic-gate#
13357c478bd9Sstevel@tonic-gate# get_domain(): Get the Domain that will be served by the LDAP server.
13367c478bd9Sstevel@tonic-gate#               $1 - Help argument.
13377c478bd9Sstevel@tonic-gate#
13387c478bd9Sstevel@tonic-gateget_domain()
13397c478bd9Sstevel@tonic-gate{
13407c478bd9Sstevel@tonic-gate    # Use LDAP_DOMAIN as default.
13417c478bd9Sstevel@tonic-gate    get_ans "Enter the domainname to be served (h=help):" $LDAP_DOMAIN
13427c478bd9Sstevel@tonic-gate
13437c478bd9Sstevel@tonic-gate    # Check domainname, and have user re-enter if not valid.
13447c478bd9Sstevel@tonic-gate    check_domainname $ANS
13457c478bd9Sstevel@tonic-gate    while [ $? -ne 0 ]
13467c478bd9Sstevel@tonic-gate    do
13477c478bd9Sstevel@tonic-gate	case "$ANS" in
13487c478bd9Sstevel@tonic-gate	    [Hh] | help | Help | \?) display_msg ${1:-sorry} ;;
13497c478bd9Sstevel@tonic-gate	    * ) ${ECHO} "Invalid domainname: \"${ANS}\"."
13507c478bd9Sstevel@tonic-gate	     ;;
13517c478bd9Sstevel@tonic-gate	esac
13527c478bd9Sstevel@tonic-gate	get_ans "Enter domainname to be served (h=help):" $DOM
13537c478bd9Sstevel@tonic-gate
13547c478bd9Sstevel@tonic-gate	check_domainname $ANS
13557c478bd9Sstevel@tonic-gate    done
13567c478bd9Sstevel@tonic-gate
13577c478bd9Sstevel@tonic-gate    # Set the domainname to valid name.
13587c478bd9Sstevel@tonic-gate    LDAP_DOMAIN=$ANS
13597c478bd9Sstevel@tonic-gate}
13607c478bd9Sstevel@tonic-gate
13617c478bd9Sstevel@tonic-gate
13627c478bd9Sstevel@tonic-gate#
13637c478bd9Sstevel@tonic-gate# get_basedn(): Query for the Base DN.
13647c478bd9Sstevel@tonic-gate#
13657c478bd9Sstevel@tonic-gateget_basedn()
13667c478bd9Sstevel@tonic-gate{
13677c478bd9Sstevel@tonic-gate    # Set the $_DOM_2_DC and assign to LDAP_BASEDN as default.
13687c478bd9Sstevel@tonic-gate    # Then call get_basedn().  This method remakes the default
13697c478bd9Sstevel@tonic-gate    # each time just in case the domain changed.
13707c478bd9Sstevel@tonic-gate    domain_2_dc $LDAP_DOMAIN
13717c478bd9Sstevel@tonic-gate    LDAP_BASEDN=$_DOM_2_DC
13727c478bd9Sstevel@tonic-gate
13737c478bd9Sstevel@tonic-gate    # Get Base DN.
13747c478bd9Sstevel@tonic-gate    while :
13757c478bd9Sstevel@tonic-gate    do
1376017e8b01Svl199446	get_ans_req "Enter LDAP Base DN (h=help):" "${_DOM_2_DC}"
13777c478bd9Sstevel@tonic-gate	check_baseDN "$ANS"
13787c478bd9Sstevel@tonic-gate	while [ $? -ne 0 ]
13797c478bd9Sstevel@tonic-gate	do
13807c478bd9Sstevel@tonic-gate	    case "$ANS" in
13817c478bd9Sstevel@tonic-gate		[Hh] | help | Help | \?) display_msg basedn_help ;;
13827c478bd9Sstevel@tonic-gate		* ) ${ECHO} "Invalid base DN: \"${ANS}\"."
13837c478bd9Sstevel@tonic-gate		;;
13847c478bd9Sstevel@tonic-gate	    esac
13857c478bd9Sstevel@tonic-gate
13867c478bd9Sstevel@tonic-gate	    # Re-Enter the BaseDN
1387017e8b01Svl199446	    get_ans_req "Enter LDAP Base DN (h=help):" "${_DOM_2_DC}"
13887c478bd9Sstevel@tonic-gate	    check_baseDN "$ANS"
13897c478bd9Sstevel@tonic-gate	done
13907c478bd9Sstevel@tonic-gate
1391017e8b01Svl199446	# Set base DN and check its suffix
13927c478bd9Sstevel@tonic-gate	LDAP_BASEDN=${ANS}
1393017e8b01Svl199446	check_basedn_suffix ||
1394017e8b01Svl199446	{
1395017e8b01Svl199446		cleanup
1396017e8b01Svl199446		exit 1
13977c478bd9Sstevel@tonic-gate	}
13987c478bd9Sstevel@tonic-gate
1399017e8b01Svl199446	# suffix may need to be created, in that case get suffix from user
1400017e8b01Svl199446	[ -n "${NEED_CREATE_SUFFIX}" ] &&
1401017e8b01Svl199446	{
1402017e8b01Svl199446		get_suffix || continue
1403017e8b01Svl199446	}
1404017e8b01Svl199446
1405017e8b01Svl199446	# suffix is ok, break out of the base dn inquire loop
1406017e8b01Svl199446	break
1407017e8b01Svl199446    done
1408017e8b01Svl199446}
14097c478bd9Sstevel@tonic-gate
1410dd1104fbSMichen Chang#
1411dd1104fbSMichen Chang# get_want_shadow_update(): Ask user if want to enable shadow update?
1412dd1104fbSMichen Chang#
1413dd1104fbSMichen Changget_want_shadow_update()
1414dd1104fbSMichen Chang{
1415dd1104fbSMichen Chang    MSG="Do you want to enable shadow update (y/n/h)?"
1416dd1104fbSMichen Chang    get_confirm "$MSG" "n" "enable_shadow_update_help"
1417dd1104fbSMichen Chang    if [ $? -eq 1 ]; then
1418dd1104fbSMichen Chang	LDAP_ENABLE_SHADOW_UPDATE="TRUE"
1419dd1104fbSMichen Chang    else
1420dd1104fbSMichen Chang	LDAP_ENABLE_SHADOW_UPDATE="FALSE"
1421dd1104fbSMichen Chang    fi
1422dd1104fbSMichen Chang}
1423dd1104fbSMichen Chang
1424cb5caa98Sdjlget_krb_realm() {
1425cb5caa98Sdjl
1426cb5caa98Sdjl    # To upper cases
1427cb5caa98Sdjl    LDAP_KRB_REALM=`${ECHO} ${LDAP_DOMAIN} | ${NAWK} '{ print toupper($0) }'`
1428cb5caa98Sdjl    get_ans_req "Enter Kerberos Realm:" "$LDAP_KRB_REALM"
1429cb5caa98Sdjl    # To upper cases
1430cb5caa98Sdjl    LDAP_KRB_REALM=`${ECHO} ${ANS} | ${NAWK} '{ print toupper($0) }'`
1431cb5caa98Sdjl}
1432cb5caa98Sdjl
1433cb5caa98Sdjl# $1: DN
1434cb5caa98Sdjl# $2: ldif file
1435cb5caa98Sdjladd_entry_by_DN() {
1436cb5caa98Sdjl
1437cb5caa98Sdjl    ${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} -b \"${1}\" -s base \"objectclass=*\" ${VERB}"
1438cb5caa98Sdjl    if [ $? -eq 0 ]; then
1439cb5caa98Sdjl	    ${ECHO} "  ${1} already exists"
1440cb5caa98Sdjl	    return 0
1441cb5caa98Sdjl    else
1442cb5caa98Sdjl	${EVAL} "${LDAPADD} ${LDAP_ARGS} -f ${2} ${VERB}"
1443cb5caa98Sdjl	if [ $? -eq 0 ]; then
1444cb5caa98Sdjl		${ECHO} "  ${1} is added"
1445cb5caa98Sdjl	    	return 0
1446cb5caa98Sdjl	else
1447cb5caa98Sdjl		${ECHO} "  ERROR: failed to add ${1}"
1448cb5caa98Sdjl		return 1
1449cb5caa98Sdjl	fi
1450cb5caa98Sdjl    fi
1451cb5caa98Sdjl
1452cb5caa98Sdjl}
14537c478bd9Sstevel@tonic-gate#
1454cb5caa98Sdjl# Kerberos princiapl to DN mapping rules
1455cb5caa98Sdjl#
1456cb5caa98Sdjl# Add rules for host credentails and user credentials
1457cb5caa98Sdjl#
1458cb5caa98Sdjladd_id_mapping_rules() {
1459cb5caa98Sdjl
1460cb5caa98Sdjl    ${ECHO} "  Adding Kerberos principal to DN mapping rules..."
1461cb5caa98Sdjl
1462cb5caa98Sdjl    _C_DN="cn=GSSAPI,cn=identity mapping,cn=config"
1463cb5caa98Sdjl    ( cat << EOF
1464cb5caa98Sdjldn: cn=GSSAPI,cn=identity mapping,cn=config
1465cb5caa98SdjlobjectClass: top
1466cb5caa98SdjlobjectClass: nsContainer
1467cb5caa98Sdjlcn: GSSAPI
1468cb5caa98SdjlEOF
1469cb5caa98Sdjl) > ${TMPDIR}/GSSAPI_container.ldif
1470cb5caa98Sdjl
1471cb5caa98Sdjl    add_entry_by_DN "${_C_DN}" "${TMPDIR}/GSSAPI_container.ldif"
1472cb5caa98Sdjl    if [ $? -ne 0 ];
1473cb5caa98Sdjl    then
1474cb5caa98Sdjl    	${RM} ${TMPDIR}/GSSAPI_container.ldif
1475cb5caa98Sdjl	return
1476cb5caa98Sdjl    fi
1477cb5caa98Sdjl
1478cb5caa98Sdjl    _H_CN="host_auth_${LDAP_KRB_REALM}"
1479cb5caa98Sdjl    _H_DN="cn=${_H_CN}, ${_C_DN}"
1480cb5caa98Sdjl    ( cat << EOF
1481cb5caa98Sdjldn: ${_H_DN}
1482cb5caa98SdjlobjectClass: top
1483cb5caa98SdjlobjectClass: nsContainer
1484cb5caa98SdjlobjectClass: dsIdentityMapping
1485cb5caa98SdjlobjectClass: dsPatternMatching
1486cb5caa98Sdjlcn: ${_H_CN}
1487cb5caa98SdjldsMatching-pattern: \${Principal}
1488cb5caa98SdjldsMatching-regexp: host\/(.*).${LDAP_DOMAIN}@${LDAP_KRB_REALM}
1489cb5caa98SdjldsSearchBaseDN: ou=hosts,${LDAP_BASEDN}
1490cb5caa98SdjldsSearchFilter: (&(objectClass=ipHost)(cn=\$1))
1491cb5caa98SdjldsSearchScope: one
1492cb5caa98Sdjl
1493cb5caa98SdjlEOF
1494cb5caa98Sdjl) > ${TMPDIR}/${_H_CN}.ldif
1495cb5caa98Sdjl
1496cb5caa98Sdjl    add_entry_by_DN "${_H_DN}" "${TMPDIR}/${_H_CN}.ldif"
1497cb5caa98Sdjl
1498cb5caa98Sdjl    _U_CN="user_auth_${LDAP_KRB_REALM}"
1499cb5caa98Sdjl    _U_DN="cn=${_U_CN}, ${_C_DN}"
1500cb5caa98Sdjl    ( cat << EOF
1501cb5caa98Sdjldn: ${_U_DN}
1502cb5caa98SdjlobjectClass: top
1503cb5caa98SdjlobjectClass: nsContainer
1504cb5caa98SdjlobjectClass: dsIdentityMapping
1505cb5caa98SdjlobjectClass: dsPatternMatching
1506cb5caa98Sdjlcn: ${_U_CN}
1507cb5caa98SdjldsMatching-pattern: \${Principal}
1508cb5caa98SdjldsMatching-regexp: (.*)@${LDAP_KRB_REALM}
1509cb5caa98SdjldsMappedDN: uid=\$1,ou=People,${LDAP_BASEDN}
1510cb5caa98Sdjl
1511cb5caa98SdjlEOF
1512cb5caa98Sdjl) > ${TMPDIR}/${_U_CN}.ldif
1513cb5caa98Sdjl
1514cb5caa98Sdjl    add_entry_by_DN "${_U_DN}" "${TMPDIR}/${_U_CN}.ldif"
1515cb5caa98Sdjl
1516cb5caa98Sdjl}
1517cb5caa98Sdjl
1518cb5caa98Sdjl
1519cb5caa98Sdjl#
1520cb5caa98Sdjl# Modify ACL to allow root to read all the password and only self can read
1521cb5caa98Sdjl# its own password when sasl/GSSAPI bind is used
1522cb5caa98Sdjl#
1523cb5caa98Sdjlmodify_userpassword_acl_for_gssapi() {
1524cb5caa98Sdjl
1525cb5caa98Sdjl    _P_DN="ou=People,${LDAP_BASEDN}"
1526cb5caa98Sdjl    _H_DN="ou=Hosts,${LDAP_BASEDN}"
1527cb5caa98Sdjl    _P_ACI="self-read-pwd"
1528cb5caa98Sdjl
1529cb5caa98Sdjl    ${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} -b \"${_P_DN}\" -s base \"objectclass=*\" > /dev/null 2>&1"
1530cb5caa98Sdjl    if [ $? -ne 0 ]; then
1531cb5caa98Sdjl	    ${ECHO} "  ${_P_DN} does not exist"
1532cb5caa98Sdjl	# Not Found. Create a new entry
1533cb5caa98Sdjl	( cat << EOF
1534cb5caa98Sdjldn: ${_P_DN}
1535cb5caa98Sdjlou: People
1536cb5caa98SdjlobjectClass: top
1537cb5caa98SdjlobjectClass: organizationalUnit
1538cb5caa98SdjlEOF
1539cb5caa98Sdjl) > ${TMPDIR}/gssapi_people.ldif
1540cb5caa98Sdjl
1541cb5caa98Sdjl	add_entry_by_DN "${_P_DN}" "${TMPDIR}/gssapi_people.ldif"
1542cb5caa98Sdjl    else
1543cb5caa98Sdjl	${ECHO} "  ${_P_DN} already exists"
1544cb5caa98Sdjl    fi
1545cb5caa98Sdjl
1546cb5caa98Sdjl    ${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} -b \"${_P_DN}\" -s base \"objectclass=*\" aci > ${TMPDIR}/chk_gssapi_aci 2>&1"
1547cb5caa98Sdjl
1548cb5caa98Sdjl    if [ $? -eq 0 ]; then
1549cb5caa98Sdjl	    ${EVAL} "${GREP} ${_P_ACI} ${TMPDIR}/chk_gssapi_aci > /dev/null 2>&1"
1550cb5caa98Sdjl	    if [ $? -eq 0 ]; then
1551cb5caa98Sdjl		${ECHO} "  userpassword ACL ${_P_ACI} already exists."
1552cb5caa98Sdjl		return
1553cb5caa98Sdjl	    else
1554cb5caa98Sdjl		${ECHO} "  userpassword ACL ${_P_ACI} not found. Create a new one."
1555cb5caa98Sdjl	    fi
1556cb5caa98Sdjl    else
1557cb5caa98Sdjl	${ECHO} "  Error searching aci for ${_P_DN}"
1558cb5caa98Sdjl	cat ${TMPDIR}/chk_gssapi_aci
1559cb5caa98Sdjl	cleanup
1560cb5caa98Sdjl	exit 1
1561cb5caa98Sdjl    fi
1562cb5caa98Sdjl    ( cat << EOF
1563cb5caa98Sdjldn: ${_P_DN}
1564cb5caa98Sdjlchangetype: modify
1565cb5caa98Sdjladd: aci
1566cb5caa98Sdjlaci: (targetattr="userPassword")(version 3.0; acl self-read-pwd; allow (read,search) userdn="ldap:///self" and authmethod="sasl GSSAPI";)
1567cb5caa98Sdjl-
1568cb5caa98Sdjladd: aci
1569cb5caa98Sdjlaci: (targetattr="userPassword")(version 3.0; acl host-read-pwd; allow (read,search) userdn="ldap:///cn=*+ipHostNumber=*,ou=Hosts,${LDAP_BASEDN}" and authmethod="sasl GSSAPI";)
1570cb5caa98SdjlEOF
1571cb5caa98Sdjl) > ${TMPDIR}/user_gssapi.ldif
1572cb5caa98Sdjl    LDAP_TYPE_OR_VALUE_EXISTS=20
1573cb5caa98Sdjl    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/user_gssapi.ldif ${VERB}"
1574cb5caa98Sdjl
1575cb5caa98Sdjl    case $? in
1576cb5caa98Sdjl    0)
1577cb5caa98Sdjl	${ECHO} "  ${_P_DN} uaserpassword ACL is updated."
1578cb5caa98Sdjl	;;
1579cb5caa98Sdjl    20)
1580cb5caa98Sdjl	${ECHO} "  ${_P_DN} uaserpassword ACL already exists."
1581cb5caa98Sdjl	;;
1582cb5caa98Sdjl    *)
1583cb5caa98Sdjl	${ECHO} "  ERROR: update of userpassword ACL for ${_P_DN} failed!"
1584cb5caa98Sdjl	cleanup
1585cb5caa98Sdjl	exit 1
1586cb5caa98Sdjl	;;
1587cb5caa98Sdjl    esac
1588cb5caa98Sdjl}
1589cb5caa98Sdjl#
1590cb5caa98Sdjl# $1: objectclass or attributetyp
1591cb5caa98Sdjl# $2: name
1592cb5caa98Sdjlsearch_update_schema() {
1593cb5caa98Sdjl
1594cb5caa98Sdjl    ATTR="${1}es"
1595cb5caa98Sdjl
1596cb5caa98Sdjl    ${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} -b cn=schema -s base \"objectclass=*\" ${ATTR} | ${GREP} -i \"${2}\" ${VERB}"
1597cb5caa98Sdjl    if [ $? -ne 0 ]; then
1598cb5caa98Sdjl	${ECHO} "${1} ${2} does not exist."
1599cb5caa98Sdjl        update_schema_attr
1600cb5caa98Sdjl        update_schema_obj
1601cb5caa98Sdjl	SCHEMA_UPDATED=1
1602cb5caa98Sdjl    else
1603cb5caa98Sdjl	${ECHO} "${1} ${2} already exists. Schema has been updated"
1604cb5caa98Sdjl    fi
1605cb5caa98Sdjl}
1606cb5caa98Sdjl
1607cb5caa98Sdjl#
1608cb5caa98Sdjl# Set up GSSAPI if necessary
1609cb5caa98Sdjl#
1610cb5caa98Sdjlgssapi_setup() {
1611cb5caa98Sdjl
16124f4e8bf0SMilan Jurik	GSSAPI_ENABLE=0
16134f4e8bf0SMilan Jurik
1614dd1104fbSMichen Chang	# assume sasl/GSSAPI is supported by the ldap server and may be used
1615dd1104fbSMichen Chang	GSSAPI_AUTH_MAY_BE_USED=1
16164f4e8bf0SMilan Jurik
1617cb5caa98Sdjl	${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} -b \"\" -s base \"objectclass=*\" supportedSASLMechanisms | ${GREP} GSSAPI ${VERB}"
1618cb5caa98Sdjl	if [ $? -ne 0 ]; then
1619dd1104fbSMichen Chang		GSSAPI_AUTH_MAY_BE_USED=0
1620cb5caa98Sdjl		${ECHO} "  sasl/GSSAPI is not supported by this LDAP server"
1621cb5caa98Sdjl		return
1622cb5caa98Sdjl	fi
1623cb5caa98Sdjl
1624cb5caa98Sdjl	get_confirm "GSSAPI is supported. Do you want to set up gssapi:(y/n)" "n"
1625cb5caa98Sdjl	if [ $? -eq 0 ]; then
16264f4e8bf0SMilan Jurik		GSSAPI_ENABLE=0
1627cb5caa98Sdjl		${ECHO}
1628cb5caa98Sdjl		${ECHO} "GSSAPI is not set up."
1629dd1104fbSMichen Chang		${ECHO} "sasl/GSSAPI bind may not work if it's not set up first."
1630cb5caa98Sdjl	else
16314f4e8bf0SMilan Jurik		GSSAPI_ENABLE=1
1632cb5caa98Sdjl		get_krb_realm
1633cb5caa98Sdjl	fi
1634cb5caa98Sdjl
1635cb5caa98Sdjl}
16364f4e8bf0SMilan Jurik#
16377c478bd9Sstevel@tonic-gate# get_profile_name(): Enter the profile name.
16387c478bd9Sstevel@tonic-gate#
16397c478bd9Sstevel@tonic-gateget_profile_name()
16407c478bd9Sstevel@tonic-gate{
16417c478bd9Sstevel@tonic-gate    # Reset Delete Old Profile since getting new profile name.
16427c478bd9Sstevel@tonic-gate    DEL_OLD_PROFILE=0
16437c478bd9Sstevel@tonic-gate
16447c478bd9Sstevel@tonic-gate    # Loop until valid profile name, or replace.
16457c478bd9Sstevel@tonic-gate    while :
16467c478bd9Sstevel@tonic-gate    do
16477c478bd9Sstevel@tonic-gate	# Prompt for profile name.
16487c478bd9Sstevel@tonic-gate	get_ans "Enter the profile name (h=help):" "$LDAP_PROFILE_NAME"
16497c478bd9Sstevel@tonic-gate
16507c478bd9Sstevel@tonic-gate	# Check for Help.
16517c478bd9Sstevel@tonic-gate	case "$ANS" in
16527c478bd9Sstevel@tonic-gate	    [Hh] | help | Help | \?) display_msg profile_help
16537c478bd9Sstevel@tonic-gate				     continue ;;
16547c478bd9Sstevel@tonic-gate	    * )  ;;
16557c478bd9Sstevel@tonic-gate	esac
16567c478bd9Sstevel@tonic-gate
16577c478bd9Sstevel@tonic-gate	# Search to see if profile name already exists.
16587c478bd9Sstevel@tonic-gate	eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"cn=${ANS},ou=profile,${LDAP_BASEDN}\" -s base \"objectclass=*\" ${VERB}"
16597c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
1660dd1104fbSMichen Chang
1661dd1104fbSMichen Chang	    cat << EOF
1662dd1104fbSMichen Chang
1663dd1104fbSMichen ChangProfile '${ANS}' already exists, it is possible to enable
1664dd1104fbSMichen Changshadow update now. idsconfig will exit after shadow update
1665dd1104fbSMichen Changis enabled. You can also continue to overwrite the profile 
1666dd1104fbSMichen Changor create a new one and be given the chance to enable
1667dd1104fbSMichen Changshadow update later.
1668dd1104fbSMichen Chang
1669dd1104fbSMichen ChangEOF
1670dd1104fbSMichen Chang
1671dd1104fbSMichen Chang	    MSG="Just enable shadow update (y/n/h)?"
1672dd1104fbSMichen Chang	    get_confirm "$MSG" "n" "enable_shadow_update_help"
1673dd1104fbSMichen Chang	    if [ $? -eq 1 ]; then
1674dd1104fbSMichen Chang	        [ $DEBUG -eq 1 ] && ${ECHO} "set up shadow update"
1675dd1104fbSMichen Chang	        LDAP_ENABLE_SHADOW_UPDATE=TRUE
1676dd1104fbSMichen Chang		# display alternate messages
1677dd1104fbSMichen Chang		EXISTING_PROFILE=1
1678dd1104fbSMichen Chang	        # Set Profile Name.
1679dd1104fbSMichen Chang	        LDAP_PROFILE_NAME=$ANS
1680dd1104fbSMichen Chang	        return 0  # set up credentials for shadow update.
1681dd1104fbSMichen Chang	    fi
1682dd1104fbSMichen Chang
1683dd1104fbSMichen Chang	    get_confirm_nodef "Are you sure you want to overwrite profile cn=${ANS}?"
16847c478bd9Sstevel@tonic-gate	    if [ $? -eq 1 ]; then
16857c478bd9Sstevel@tonic-gate		DEL_OLD_PROFILE=1
16867c478bd9Sstevel@tonic-gate		return 0  # Replace old profile name.
16877c478bd9Sstevel@tonic-gate	    else
16887c478bd9Sstevel@tonic-gate		${ECHO} "Please re-enter a new profile name."
16897c478bd9Sstevel@tonic-gate	    fi
16907c478bd9Sstevel@tonic-gate	else
16917c478bd9Sstevel@tonic-gate	    break  # Unique profile name.
16927c478bd9Sstevel@tonic-gate	fi
16937c478bd9Sstevel@tonic-gate    done
16947c478bd9Sstevel@tonic-gate
16957c478bd9Sstevel@tonic-gate    # Set Profile Name.
16967c478bd9Sstevel@tonic-gate    LDAP_PROFILE_NAME=$ANS
16977c478bd9Sstevel@tonic-gate}
16987c478bd9Sstevel@tonic-gate
16997c478bd9Sstevel@tonic-gate
17007c478bd9Sstevel@tonic-gate#
17017c478bd9Sstevel@tonic-gate# get_srv_list(): Get the default server list.
17027c478bd9Sstevel@tonic-gate#
17037c478bd9Sstevel@tonic-gateget_srv_list()
17047c478bd9Sstevel@tonic-gate{
17057c478bd9Sstevel@tonic-gate    # If LDAP_SERVER_LIST is NULL, then set, otherwise leave alone.
17067c478bd9Sstevel@tonic-gate    if [ -z "${LDAP_SERVER_LIST}" ]; then
17077c478bd9Sstevel@tonic-gate	LDAP_SERVER_LIST=`getent hosts ${IDS_SERVER} | awk '{print $1}'`
17087c478bd9Sstevel@tonic-gate        if [ ${IDS_PORT} -ne 389 ]; then
17097c478bd9Sstevel@tonic-gate	    LDAP_SERVER_LIST="${LDAP_SERVER_LIST}:${IDS_PORT}"
17107c478bd9Sstevel@tonic-gate	fi
17117c478bd9Sstevel@tonic-gate    fi
17127c478bd9Sstevel@tonic-gate
17137c478bd9Sstevel@tonic-gate    # Prompt for new LDAP_SERVER_LIST.
17147c478bd9Sstevel@tonic-gate    while :
17157c478bd9Sstevel@tonic-gate    do
17167c478bd9Sstevel@tonic-gate	get_ans "Default server list (h=help):" $LDAP_SERVER_LIST
17177c478bd9Sstevel@tonic-gate
17187c478bd9Sstevel@tonic-gate	# If help continue, otherwise break.
17197c478bd9Sstevel@tonic-gate	case "$ANS" in
17207c478bd9Sstevel@tonic-gate	    [Hh] | help | Help | \?) display_msg def_srvlist_help ;;
17217c478bd9Sstevel@tonic-gate	    * ) break ;;
17227c478bd9Sstevel@tonic-gate	esac
17237c478bd9Sstevel@tonic-gate    done
17247c478bd9Sstevel@tonic-gate    LDAP_SERVER_LIST=$ANS
17257c478bd9Sstevel@tonic-gate}
17267c478bd9Sstevel@tonic-gate
17277c478bd9Sstevel@tonic-gate
17287c478bd9Sstevel@tonic-gate#
17297c478bd9Sstevel@tonic-gate# get_pref_srv(): The preferred server list (Overrides the server list)
17307c478bd9Sstevel@tonic-gate#
17317c478bd9Sstevel@tonic-gateget_pref_srv()
17327c478bd9Sstevel@tonic-gate{
17337c478bd9Sstevel@tonic-gate    while :
17347c478bd9Sstevel@tonic-gate    do
17357c478bd9Sstevel@tonic-gate	get_ans "Preferred server list (h=help):" $LDAP_PREF_SRVLIST
17367c478bd9Sstevel@tonic-gate
17377c478bd9Sstevel@tonic-gate	# If help continue, otherwise break.
17387c478bd9Sstevel@tonic-gate	case "$ANS" in
17397c478bd9Sstevel@tonic-gate	    [Hh] | help | Help | \?) display_msg pref_srvlist_help ;;
17407c478bd9Sstevel@tonic-gate	    * ) break ;;
17417c478bd9Sstevel@tonic-gate	esac
17427c478bd9Sstevel@tonic-gate    done
17437c478bd9Sstevel@tonic-gate    LDAP_PREF_SRVLIST=$ANS
17447c478bd9Sstevel@tonic-gate}
17457c478bd9Sstevel@tonic-gate
17467c478bd9Sstevel@tonic-gate
17477c478bd9Sstevel@tonic-gate#
17487c478bd9Sstevel@tonic-gate# get_search_scope(): Get the search scope from the user.
17497c478bd9Sstevel@tonic-gate#
17507c478bd9Sstevel@tonic-gateget_search_scope()
17517c478bd9Sstevel@tonic-gate{
17527c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In get_search_scope()"
17537c478bd9Sstevel@tonic-gate
17547c478bd9Sstevel@tonic-gate    _MENU_CHOICE=0
17557c478bd9Sstevel@tonic-gate    while :
17567c478bd9Sstevel@tonic-gate    do
17577c478bd9Sstevel@tonic-gate	get_ans "Choose desired search scope (one, sub, h=help): " "one"
17587c478bd9Sstevel@tonic-gate	_MENU_CHOICE=$ANS
17597c478bd9Sstevel@tonic-gate	case "$_MENU_CHOICE" in
17607c478bd9Sstevel@tonic-gate	    one) LDAP_SEARCH_SCOPE="one"
17617c478bd9Sstevel@tonic-gate	       return 1 ;;
17627c478bd9Sstevel@tonic-gate	    sub) LDAP_SEARCH_SCOPE="sub"
17637c478bd9Sstevel@tonic-gate	       return 2 ;;
17647c478bd9Sstevel@tonic-gate	    h) display_msg srch_scope_help ;;
17657c478bd9Sstevel@tonic-gate	    *) ${ECHO} "Please enter \"one\", \"sub\", or \"h\"." ;;
17667c478bd9Sstevel@tonic-gate	esac
17677c478bd9Sstevel@tonic-gate    done
17687c478bd9Sstevel@tonic-gate
17697c478bd9Sstevel@tonic-gate}
17707c478bd9Sstevel@tonic-gate
17717c478bd9Sstevel@tonic-gate
17727c478bd9Sstevel@tonic-gate#
17737c478bd9Sstevel@tonic-gate# get_cred_level(): Function to display menu to user and get the
17747c478bd9Sstevel@tonic-gate#                  credential level.
17757c478bd9Sstevel@tonic-gate#
17767c478bd9Sstevel@tonic-gateget_cred_level()
17777c478bd9Sstevel@tonic-gate{
17787c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In get_cred_level()"
17797c478bd9Sstevel@tonic-gate
17807c478bd9Sstevel@tonic-gate    _MENU_CHOICE=0
17817c478bd9Sstevel@tonic-gate    display_msg cred_level_menu
17827c478bd9Sstevel@tonic-gate    while :
17837c478bd9Sstevel@tonic-gate    do
17844f4e8bf0SMilan Jurik	if [ $GSSAPI_ENABLE -eq 1 ]; then
17854f4e8bf0SMilan Jurik	    ${ECHO} '"self" is needed for GSSAPI profile'
17864f4e8bf0SMilan Jurik	fi
17877c478bd9Sstevel@tonic-gate	get_ans "Choose Credential level [h=help]:" "1"
17887c478bd9Sstevel@tonic-gate	_MENU_CHOICE=$ANS
17897c478bd9Sstevel@tonic-gate	case "$_MENU_CHOICE" in
17907c478bd9Sstevel@tonic-gate	    1) LDAP_CRED_LEVEL="anonymous"
17917c478bd9Sstevel@tonic-gate	       return 1 ;;
17927c478bd9Sstevel@tonic-gate	    2) LDAP_CRED_LEVEL="proxy"
17937c478bd9Sstevel@tonic-gate	       return 2 ;;
17947c478bd9Sstevel@tonic-gate	    3) LDAP_CRED_LEVEL="proxy anonymous"
17957c478bd9Sstevel@tonic-gate	       return 3 ;;
1796cb5caa98Sdjl	    4) LDAP_CRED_LEVEL="self"
1797cb5caa98Sdjl	       return 4 ;;
17987c478bd9Sstevel@tonic-gate	    h) display_msg cred_lvl_help ;;
17994f4e8bf0SMilan Jurik	    *) ${ECHO} "Please enter 1, 2, 3 or 4." ;;
18007c478bd9Sstevel@tonic-gate	esac
18017c478bd9Sstevel@tonic-gate    done
18027c478bd9Sstevel@tonic-gate}
18037c478bd9Sstevel@tonic-gate
18047c478bd9Sstevel@tonic-gate
18057c478bd9Sstevel@tonic-gate#
18067c478bd9Sstevel@tonic-gate# srvauth_menu_handler(): Enter the Service Authentication method.
18077c478bd9Sstevel@tonic-gate#
18087c478bd9Sstevel@tonic-gatesrvauth_menu_handler()
18097c478bd9Sstevel@tonic-gate{
18107c478bd9Sstevel@tonic-gate    # Display Auth menu
18117c478bd9Sstevel@tonic-gate    display_msg srvauth_method_menu
18127c478bd9Sstevel@tonic-gate
18137c478bd9Sstevel@tonic-gate    # Get a Valid choice.
18147c478bd9Sstevel@tonic-gate    while :
18157c478bd9Sstevel@tonic-gate    do
18167c478bd9Sstevel@tonic-gate	# Display appropriate prompt and get answer.
18177c478bd9Sstevel@tonic-gate	if [ $_FIRST -eq 1 ]; then
18187c478bd9Sstevel@tonic-gate	    get_ans "Choose Service Authentication Method:" "1"
18197c478bd9Sstevel@tonic-gate	else
18207c478bd9Sstevel@tonic-gate	    get_ans "Choose Service Authentication Method (0=reset):"
18217c478bd9Sstevel@tonic-gate	fi
18227c478bd9Sstevel@tonic-gate
18237c478bd9Sstevel@tonic-gate	# Determine choice.
18247c478bd9Sstevel@tonic-gate	_MENU_CHOICE=$ANS
18257c478bd9Sstevel@tonic-gate	case "$_MENU_CHOICE" in
18267c478bd9Sstevel@tonic-gate	    1) _AUTHMETHOD="simple"
18277c478bd9Sstevel@tonic-gate		break ;;
18287c478bd9Sstevel@tonic-gate	    2) _AUTHMETHOD="sasl/DIGEST-MD5"
18297c478bd9Sstevel@tonic-gate		break ;;
18307c478bd9Sstevel@tonic-gate	    3) _AUTHMETHOD="tls:simple"
18317c478bd9Sstevel@tonic-gate		break ;;
18327c478bd9Sstevel@tonic-gate	    4) _AUTHMETHOD="tls:sasl/DIGEST-MD5"
18337c478bd9Sstevel@tonic-gate		break ;;
1834cb5caa98Sdjl	    5) _AUTHMETHOD="sasl/GSSAPI"
1835cb5caa98Sdjl		break ;;
18367c478bd9Sstevel@tonic-gate	    0) _AUTHMETHOD=""
18377c478bd9Sstevel@tonic-gate		_FIRST=1
18387c478bd9Sstevel@tonic-gate		break ;;
1839cb5caa98Sdjl	    *) ${ECHO} "Please enter 1-5 or 0 to reset." ;;
18407c478bd9Sstevel@tonic-gate	esac
18417c478bd9Sstevel@tonic-gate    done
18427c478bd9Sstevel@tonic-gate}
18437c478bd9Sstevel@tonic-gate
18447c478bd9Sstevel@tonic-gate
18457c478bd9Sstevel@tonic-gate#
18467c478bd9Sstevel@tonic-gate# auth_menu_handler(): Enter the Authentication method.
18477c478bd9Sstevel@tonic-gate#
18487c478bd9Sstevel@tonic-gateauth_menu_handler()
18497c478bd9Sstevel@tonic-gate{
18507c478bd9Sstevel@tonic-gate    # Display Auth menu
18517c478bd9Sstevel@tonic-gate    display_msg auth_method_menu
18527c478bd9Sstevel@tonic-gate
18537c478bd9Sstevel@tonic-gate    # Get a Valid choice.
18547c478bd9Sstevel@tonic-gate    while :
18557c478bd9Sstevel@tonic-gate    do
18564f4e8bf0SMilan Jurik	if [ $GSSAPI_ENABLE -eq 1 ]; then
18574f4e8bf0SMilan Jurik	    ${ECHO} '"sasl/GSSAPI" is needed for GSSAPI profile'
18584f4e8bf0SMilan Jurik	fi
18597c478bd9Sstevel@tonic-gate	# Display appropriate prompt and get answer.
18607c478bd9Sstevel@tonic-gate	if [ $_FIRST -eq 1 ]; then
18617c478bd9Sstevel@tonic-gate	    get_ans "Choose Authentication Method (h=help):" "1"
18627c478bd9Sstevel@tonic-gate	else
18637c478bd9Sstevel@tonic-gate	    get_ans "Choose Authentication Method (0=reset, h=help):"
18647c478bd9Sstevel@tonic-gate	fi
18657c478bd9Sstevel@tonic-gate
18667c478bd9Sstevel@tonic-gate	# Determine choice.
18677c478bd9Sstevel@tonic-gate	_MENU_CHOICE=$ANS
18687c478bd9Sstevel@tonic-gate	case "$_MENU_CHOICE" in
18697c478bd9Sstevel@tonic-gate	    1) _AUTHMETHOD="none"
18707c478bd9Sstevel@tonic-gate		break ;;
18717c478bd9Sstevel@tonic-gate	    2) _AUTHMETHOD="simple"
18727c478bd9Sstevel@tonic-gate		break ;;
18737c478bd9Sstevel@tonic-gate	    3) _AUTHMETHOD="sasl/DIGEST-MD5"
18747c478bd9Sstevel@tonic-gate		break ;;
18757c478bd9Sstevel@tonic-gate	    4) _AUTHMETHOD="tls:simple"
18767c478bd9Sstevel@tonic-gate		break ;;
18777c478bd9Sstevel@tonic-gate	    5) _AUTHMETHOD="tls:sasl/DIGEST-MD5"
18787c478bd9Sstevel@tonic-gate		break ;;
1879cb5caa98Sdjl	    6) _AUTHMETHOD="sasl/GSSAPI"
1880cb5caa98Sdjl		break ;;
18817c478bd9Sstevel@tonic-gate	    0) _AUTHMETHOD=""
18827c478bd9Sstevel@tonic-gate		_FIRST=1
18837c478bd9Sstevel@tonic-gate		break ;;
18847c478bd9Sstevel@tonic-gate	    h) display_msg auth_help ;;
1885cb5caa98Sdjl	    *) ${ECHO} "Please enter 1-6, 0=reset, or h=help." ;;
18867c478bd9Sstevel@tonic-gate	esac
18877c478bd9Sstevel@tonic-gate    done
18887c478bd9Sstevel@tonic-gate}
18897c478bd9Sstevel@tonic-gate
18907c478bd9Sstevel@tonic-gate
18917c478bd9Sstevel@tonic-gate#
18927c478bd9Sstevel@tonic-gate# get_auth(): Enter the Authentication method.
18937c478bd9Sstevel@tonic-gate#
18947c478bd9Sstevel@tonic-gateget_auth()
18957c478bd9Sstevel@tonic-gate{
18967c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In get_auth()"
18977c478bd9Sstevel@tonic-gate
18987c478bd9Sstevel@tonic-gate    _FIRST=1          # Flag for first time.
18997c478bd9Sstevel@tonic-gate    _MENU_CHOICE=0
19007c478bd9Sstevel@tonic-gate    _AUTHMETHOD=""    # Tmp method.
19017c478bd9Sstevel@tonic-gate
19027c478bd9Sstevel@tonic-gate    while :
19037c478bd9Sstevel@tonic-gate    do
19047c478bd9Sstevel@tonic-gate	# Call Menu handler
19057c478bd9Sstevel@tonic-gate	auth_menu_handler
19067c478bd9Sstevel@tonic-gate
19077c478bd9Sstevel@tonic-gate	# Add Auth Method to list.
19087c478bd9Sstevel@tonic-gate        if [ $_FIRST -eq 1 ]; then
19097c478bd9Sstevel@tonic-gate	    LDAP_AUTHMETHOD="${_AUTHMETHOD}"
19107c478bd9Sstevel@tonic-gate	    _FIRST=0
19117c478bd9Sstevel@tonic-gate	else
19127c478bd9Sstevel@tonic-gate	    LDAP_AUTHMETHOD="${LDAP_AUTHMETHOD};${_AUTHMETHOD}"
19137c478bd9Sstevel@tonic-gate	fi
19147c478bd9Sstevel@tonic-gate
19157c478bd9Sstevel@tonic-gate	# Display current Authentication Method.
19167c478bd9Sstevel@tonic-gate	${ECHO} ""
19177c478bd9Sstevel@tonic-gate	${ECHO} "Current authenticationMethod: ${LDAP_AUTHMETHOD}"
19187c478bd9Sstevel@tonic-gate	${ECHO} ""
19197c478bd9Sstevel@tonic-gate
19207c478bd9Sstevel@tonic-gate	# Prompt for another Auth Method, or break out.
19217c478bd9Sstevel@tonic-gate	get_confirm_nodef "Do you want to add another Authentication Method?"
19227c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
19237c478bd9Sstevel@tonic-gate	    break;
19247c478bd9Sstevel@tonic-gate	fi
19257c478bd9Sstevel@tonic-gate    done
19267c478bd9Sstevel@tonic-gate}
19277c478bd9Sstevel@tonic-gate
19287c478bd9Sstevel@tonic-gate
19297c478bd9Sstevel@tonic-gate#
19307c478bd9Sstevel@tonic-gate# get_followref(): Whether or not to follow referrals.
19317c478bd9Sstevel@tonic-gate#
19327c478bd9Sstevel@tonic-gateget_followref()
19337c478bd9Sstevel@tonic-gate{
19347c478bd9Sstevel@tonic-gate    get_confirm "Do you want the clients to follow referrals (y/n/h)?" "n" "referrals_help"
19357c478bd9Sstevel@tonic-gate    if [ $? -eq 1 ]; then
19367c478bd9Sstevel@tonic-gate	LDAP_FOLLOWREF="TRUE"
19377c478bd9Sstevel@tonic-gate    else
19387c478bd9Sstevel@tonic-gate	LDAP_FOLLOWREF="FALSE"
19397c478bd9Sstevel@tonic-gate    fi
19407c478bd9Sstevel@tonic-gate}
19417c478bd9Sstevel@tonic-gate
19427c478bd9Sstevel@tonic-gate
19437c478bd9Sstevel@tonic-gate#
19447c478bd9Sstevel@tonic-gate# get_timelimit(): Set the time limit. -1 is max time.
19457c478bd9Sstevel@tonic-gate#
19467c478bd9Sstevel@tonic-gateget_timelimit()
19477c478bd9Sstevel@tonic-gate{
19487c478bd9Sstevel@tonic-gate    # Get current timeout value from cn=config.
19497c478bd9Sstevel@tonic-gate    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"cn=config\" -s base \"objectclass=*\" nsslapd-timelimit > ${TMPDIR}/chk_timeout 2>&1"
19507c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
19517c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: Could not reach LDAP server to check current timeout!"
19527c478bd9Sstevel@tonic-gate	cleanup
19537c478bd9Sstevel@tonic-gate	exit 1
19547c478bd9Sstevel@tonic-gate    fi
19557c478bd9Sstevel@tonic-gate    CURR_TIMELIMIT=`${GREP} timelimit ${TMPDIR}/chk_timeout | cut -f2 -d=`
19567c478bd9Sstevel@tonic-gate
19577c478bd9Sstevel@tonic-gate    get_negone_num "Enter the time limit for iDS (current=${CURR_TIMELIMIT}):" "-1"
19587c478bd9Sstevel@tonic-gate    IDS_TIMELIMIT=$NUM
19597c478bd9Sstevel@tonic-gate}
19607c478bd9Sstevel@tonic-gate
19617c478bd9Sstevel@tonic-gate
19627c478bd9Sstevel@tonic-gate#
19637c478bd9Sstevel@tonic-gate# get_sizelimit(): Set the size limit. -1 is max size.
19647c478bd9Sstevel@tonic-gate#
19657c478bd9Sstevel@tonic-gateget_sizelimit()
19667c478bd9Sstevel@tonic-gate{
19677c478bd9Sstevel@tonic-gate    # Get current sizelimit value from cn=config.
19687c478bd9Sstevel@tonic-gate    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"cn=config\" -s base \"objectclass=*\" nsslapd-sizelimit > ${TMPDIR}/chk_sizelimit 2>&1"
19697c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
19707c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: Could not reach LDAP server to check current sizelimit!"
19717c478bd9Sstevel@tonic-gate	cleanup
19727c478bd9Sstevel@tonic-gate	exit 1
19737c478bd9Sstevel@tonic-gate    fi
19747c478bd9Sstevel@tonic-gate    CURR_SIZELIMIT=`${GREP} sizelimit ${TMPDIR}/chk_sizelimit | cut -f2 -d=`
19757c478bd9Sstevel@tonic-gate
19767c478bd9Sstevel@tonic-gate    get_negone_num "Enter the size limit for iDS (current=${CURR_SIZELIMIT}):" "-1"
19777c478bd9Sstevel@tonic-gate    IDS_SIZELIMIT=$NUM
19787c478bd9Sstevel@tonic-gate}
19797c478bd9Sstevel@tonic-gate
19807c478bd9Sstevel@tonic-gate
19817c478bd9Sstevel@tonic-gate#
19827c478bd9Sstevel@tonic-gate# get_want_crypt(): Ask user if want to store passwords in crypt?
19837c478bd9Sstevel@tonic-gate#
19847c478bd9Sstevel@tonic-gateget_want_crypt()
19857c478bd9Sstevel@tonic-gate{
19867c478bd9Sstevel@tonic-gate    get_confirm "Do you want to store passwords in \"crypt\" format (y/n/h)?" "n" "crypt_help"
19877c478bd9Sstevel@tonic-gate    if [ $? -eq 1 ]; then
19887c478bd9Sstevel@tonic-gate	NEED_CRYPT="TRUE"
19897c478bd9Sstevel@tonic-gate    else
19907c478bd9Sstevel@tonic-gate	NEED_CRYPT="FALSE"
19917c478bd9Sstevel@tonic-gate    fi
19927c478bd9Sstevel@tonic-gate}
19937c478bd9Sstevel@tonic-gate
19947c478bd9Sstevel@tonic-gate
19957c478bd9Sstevel@tonic-gate#
19967c478bd9Sstevel@tonic-gate# get_srv_authMethod_pam(): Get the Service Auth Method for pam_ldap from user.
19977c478bd9Sstevel@tonic-gate#
19987c478bd9Sstevel@tonic-gate#  NOTE: This function is base on get_auth().
19997c478bd9Sstevel@tonic-gate#
20007c478bd9Sstevel@tonic-gateget_srv_authMethod_pam()
20017c478bd9Sstevel@tonic-gate{
20027c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In get_srv_authMethod_pam()"
20037c478bd9Sstevel@tonic-gate
20047c478bd9Sstevel@tonic-gate    _FIRST=1          # Flag for first time.
20057c478bd9Sstevel@tonic-gate    _MENU_CHOICE=0
20067c478bd9Sstevel@tonic-gate    _AUTHMETHOD=""    # Tmp method.
20077c478bd9Sstevel@tonic-gate
20087c478bd9Sstevel@tonic-gate    while :
20097c478bd9Sstevel@tonic-gate    do
20107c478bd9Sstevel@tonic-gate	# Call Menu handler
20117c478bd9Sstevel@tonic-gate	srvauth_menu_handler
20127c478bd9Sstevel@tonic-gate
20137c478bd9Sstevel@tonic-gate	# Add Auth Method to list.
20147c478bd9Sstevel@tonic-gate        if [ $_FIRST -eq 1 ]; then
20157c478bd9Sstevel@tonic-gate	    if [ "$_AUTHMETHOD" = "" ]; then
20167c478bd9Sstevel@tonic-gate		LDAP_SRV_AUTHMETHOD_PAM=""
20177c478bd9Sstevel@tonic-gate	    else
20187c478bd9Sstevel@tonic-gate		LDAP_SRV_AUTHMETHOD_PAM="pam_ldap:${_AUTHMETHOD}"
20197c478bd9Sstevel@tonic-gate	    fi
20207c478bd9Sstevel@tonic-gate	    _FIRST=0
20217c478bd9Sstevel@tonic-gate	else
20227c478bd9Sstevel@tonic-gate	    LDAP_SRV_AUTHMETHOD_PAM="${LDAP_SRV_AUTHMETHOD_PAM};${_AUTHMETHOD}"
20237c478bd9Sstevel@tonic-gate	fi
20247c478bd9Sstevel@tonic-gate
20257c478bd9Sstevel@tonic-gate	# Display current Authentication Method.
20267c478bd9Sstevel@tonic-gate	${ECHO} ""
20277c478bd9Sstevel@tonic-gate	${ECHO} "Current authenticationMethod: ${LDAP_SRV_AUTHMETHOD_PAM}"
20287c478bd9Sstevel@tonic-gate	${ECHO} ""
20297c478bd9Sstevel@tonic-gate
20307c478bd9Sstevel@tonic-gate	# Prompt for another Auth Method, or break out.
20317c478bd9Sstevel@tonic-gate	get_confirm_nodef "Do you want to add another Authentication Method?"
20327c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
20337c478bd9Sstevel@tonic-gate	    break;
20347c478bd9Sstevel@tonic-gate	fi
20357c478bd9Sstevel@tonic-gate    done
20367c478bd9Sstevel@tonic-gate
20377c478bd9Sstevel@tonic-gate    # Check in case user reset string and exited loop.
20387c478bd9Sstevel@tonic-gate    if [ "$LDAP_SRV_AUTHMETHOD_PAM" = "" ]; then
20397c478bd9Sstevel@tonic-gate	NEED_SRVAUTH_PAM=0
20407c478bd9Sstevel@tonic-gate    fi
20417c478bd9Sstevel@tonic-gate}
20427c478bd9Sstevel@tonic-gate
20437c478bd9Sstevel@tonic-gate
20447c478bd9Sstevel@tonic-gate#
20457c478bd9Sstevel@tonic-gate# get_srv_authMethod_key(): Get the Service Auth Method for keyserv from user.
20467c478bd9Sstevel@tonic-gate#
20477c478bd9Sstevel@tonic-gate#  NOTE: This function is base on get_auth().
20487c478bd9Sstevel@tonic-gate#
20497c478bd9Sstevel@tonic-gateget_srv_authMethod_key()
20507c478bd9Sstevel@tonic-gate{
20517c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In get_srv_authMethod_key()"
20527c478bd9Sstevel@tonic-gate
20537c478bd9Sstevel@tonic-gate    _FIRST=1          # Flag for first time.
20547c478bd9Sstevel@tonic-gate    _MENU_CHOICE=0
20557c478bd9Sstevel@tonic-gate    _AUTHMETHOD=""    # Tmp method.
20567c478bd9Sstevel@tonic-gate
20577c478bd9Sstevel@tonic-gate    while :
20587c478bd9Sstevel@tonic-gate    do
20597c478bd9Sstevel@tonic-gate	# Call Menu handler
20607c478bd9Sstevel@tonic-gate	srvauth_menu_handler
20617c478bd9Sstevel@tonic-gate
20627c478bd9Sstevel@tonic-gate	# Add Auth Method to list.
20637c478bd9Sstevel@tonic-gate        if [ $_FIRST -eq 1 ]; then
20647c478bd9Sstevel@tonic-gate	    if [ "$_AUTHMETHOD" = "" ]; then
20657c478bd9Sstevel@tonic-gate		LDAP_SRV_AUTHMETHOD_KEY=""
20667c478bd9Sstevel@tonic-gate	    else
20677c478bd9Sstevel@tonic-gate		LDAP_SRV_AUTHMETHOD_KEY="keyserv:${_AUTHMETHOD}"
20687c478bd9Sstevel@tonic-gate	    fi
20697c478bd9Sstevel@tonic-gate	    _FIRST=0
20707c478bd9Sstevel@tonic-gate	else
20717c478bd9Sstevel@tonic-gate	    LDAP_SRV_AUTHMETHOD_KEY="${LDAP_SRV_AUTHMETHOD_KEY};${_AUTHMETHOD}"
20727c478bd9Sstevel@tonic-gate	fi
20737c478bd9Sstevel@tonic-gate
20747c478bd9Sstevel@tonic-gate	# Display current Authentication Method.
20757c478bd9Sstevel@tonic-gate	${ECHO} ""
20767c478bd9Sstevel@tonic-gate	${ECHO} "Current authenticationMethod: ${LDAP_SRV_AUTHMETHOD_KEY}"
20777c478bd9Sstevel@tonic-gate	${ECHO} ""
20787c478bd9Sstevel@tonic-gate
20797c478bd9Sstevel@tonic-gate	# Prompt for another Auth Method, or break out.
20807c478bd9Sstevel@tonic-gate	get_confirm_nodef "Do you want to add another Authentication Method?"
20817c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
20827c478bd9Sstevel@tonic-gate	    break;
20837c478bd9Sstevel@tonic-gate	fi
20847c478bd9Sstevel@tonic-gate    done
20857c478bd9Sstevel@tonic-gate
20867c478bd9Sstevel@tonic-gate    # Check in case user reset string and exited loop.
20877c478bd9Sstevel@tonic-gate    if [ "$LDAP_SRV_AUTHMETHOD_KEY" = "" ]; then
20887c478bd9Sstevel@tonic-gate	NEED_SRVAUTH_KEY=0
20897c478bd9Sstevel@tonic-gate    fi
20907c478bd9Sstevel@tonic-gate}
20917c478bd9Sstevel@tonic-gate
20927c478bd9Sstevel@tonic-gate
20937c478bd9Sstevel@tonic-gate#
20947c478bd9Sstevel@tonic-gate# get_srv_authMethod_cmd(): Get the Service Auth Method for passwd-cmd from user.
20957c478bd9Sstevel@tonic-gate#
20967c478bd9Sstevel@tonic-gate#  NOTE: This function is base on get_auth().
20977c478bd9Sstevel@tonic-gate#
20987c478bd9Sstevel@tonic-gateget_srv_authMethod_cmd()
20997c478bd9Sstevel@tonic-gate{
21007c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In get_srv_authMethod_cmd()"
21017c478bd9Sstevel@tonic-gate
21027c478bd9Sstevel@tonic-gate    _FIRST=1          # Flag for first time.
21037c478bd9Sstevel@tonic-gate    _MENU_CHOICE=0
21047c478bd9Sstevel@tonic-gate    _AUTHMETHOD=""    # Tmp method.
21057c478bd9Sstevel@tonic-gate
21067c478bd9Sstevel@tonic-gate    while :
21077c478bd9Sstevel@tonic-gate    do
21087c478bd9Sstevel@tonic-gate	# Call Menu handler
21097c478bd9Sstevel@tonic-gate	srvauth_menu_handler
21107c478bd9Sstevel@tonic-gate
21117c478bd9Sstevel@tonic-gate	# Add Auth Method to list.
21127c478bd9Sstevel@tonic-gate        if [ $_FIRST -eq 1 ]; then
21137c478bd9Sstevel@tonic-gate	    if [ "$_AUTHMETHOD" = "" ]; then
21147c478bd9Sstevel@tonic-gate		LDAP_SRV_AUTHMETHOD_CMD=""
21157c478bd9Sstevel@tonic-gate	    else
21167c478bd9Sstevel@tonic-gate		LDAP_SRV_AUTHMETHOD_CMD="passwd-cmd:${_AUTHMETHOD}"
21177c478bd9Sstevel@tonic-gate	    fi
21187c478bd9Sstevel@tonic-gate	    _FIRST=0
21197c478bd9Sstevel@tonic-gate	else
21207c478bd9Sstevel@tonic-gate	    LDAP_SRV_AUTHMETHOD_CMD="${LDAP_SRV_AUTHMETHOD_CMD};${_AUTHMETHOD}"
21217c478bd9Sstevel@tonic-gate	fi
21227c478bd9Sstevel@tonic-gate
21237c478bd9Sstevel@tonic-gate	# Display current Authentication Method.
21247c478bd9Sstevel@tonic-gate	${ECHO} ""
21257c478bd9Sstevel@tonic-gate	${ECHO} "Current authenticationMethod: ${LDAP_SRV_AUTHMETHOD_CMD}"
21267c478bd9Sstevel@tonic-gate	${ECHO} ""
21277c478bd9Sstevel@tonic-gate
21287c478bd9Sstevel@tonic-gate	# Prompt for another Auth Method, or break out.
21297c478bd9Sstevel@tonic-gate	get_confirm_nodef "Do you want to add another Authentication Method?"
21307c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
21317c478bd9Sstevel@tonic-gate	    break;
21327c478bd9Sstevel@tonic-gate	fi
21337c478bd9Sstevel@tonic-gate    done
21347c478bd9Sstevel@tonic-gate
21357c478bd9Sstevel@tonic-gate    # Check in case user reset string and exited loop.
21367c478bd9Sstevel@tonic-gate    if [ "$LDAP_SRV_AUTHMETHOD_CMD" = "" ]; then
21377c478bd9Sstevel@tonic-gate	NEED_SRVAUTH_CMD=0
21387c478bd9Sstevel@tonic-gate    fi
21397c478bd9Sstevel@tonic-gate}
21407c478bd9Sstevel@tonic-gate
21417c478bd9Sstevel@tonic-gate
21427c478bd9Sstevel@tonic-gate#
21437c478bd9Sstevel@tonic-gate# get_srch_time(): Amount of time to search.
21447c478bd9Sstevel@tonic-gate#
21457c478bd9Sstevel@tonic-gateget_srch_time()
21467c478bd9Sstevel@tonic-gate{
21477c478bd9Sstevel@tonic-gate    get_negone_num "Client search time limit in seconds (h=help):" "$LDAP_SEARCH_TIME_LIMIT" "srchtime_help"
21487c478bd9Sstevel@tonic-gate    LDAP_SEARCH_TIME_LIMIT=$NUM
21497c478bd9Sstevel@tonic-gate}
21507c478bd9Sstevel@tonic-gate
21517c478bd9Sstevel@tonic-gate
21527c478bd9Sstevel@tonic-gate#
21537c478bd9Sstevel@tonic-gate# get_prof_ttl(): The profile time to live (TTL)
21547c478bd9Sstevel@tonic-gate#
21557c478bd9Sstevel@tonic-gateget_prof_ttl()
21567c478bd9Sstevel@tonic-gate{
21577c478bd9Sstevel@tonic-gate    get_negone_num "Profile Time To Live in seconds (h=help):" "$LDAP_PROFILE_TTL" "profttl_help"
21587c478bd9Sstevel@tonic-gate    LDAP_PROFILE_TTL=$NUM
21597c478bd9Sstevel@tonic-gate}
21607c478bd9Sstevel@tonic-gate
21617c478bd9Sstevel@tonic-gate
21627c478bd9Sstevel@tonic-gate#
21637c478bd9Sstevel@tonic-gate# get_bind_limit(): Bind time limit
21647c478bd9Sstevel@tonic-gate#
21657c478bd9Sstevel@tonic-gateget_bind_limit()
21667c478bd9Sstevel@tonic-gate{
21677c478bd9Sstevel@tonic-gate    get_negone_num "Bind time limit in seconds (h=help):" "$LDAP_BIND_LIMIT" "bindlim_help"
21687c478bd9Sstevel@tonic-gate    LDAP_BIND_LIMIT=$NUM
21697c478bd9Sstevel@tonic-gate}
21707c478bd9Sstevel@tonic-gate
21717c478bd9Sstevel@tonic-gate
21727c478bd9Sstevel@tonic-gate######################################################################
21737c478bd9Sstevel@tonic-gate# FUNCTIONS  FOR Service Search Descriptor's START HERE.
21747c478bd9Sstevel@tonic-gate######################################################################
21757c478bd9Sstevel@tonic-gate
21767c478bd9Sstevel@tonic-gate
21777c478bd9Sstevel@tonic-gate#
21787c478bd9Sstevel@tonic-gate# add_ssd(): Get SSD's from user and add to file.
21797c478bd9Sstevel@tonic-gate#
21807c478bd9Sstevel@tonic-gateadd_ssd()
21817c478bd9Sstevel@tonic-gate{
21827c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In add_ssd()"
21837c478bd9Sstevel@tonic-gate
21847c478bd9Sstevel@tonic-gate    # Enter the service id.  Loop til unique.
21857c478bd9Sstevel@tonic-gate    while :
21867c478bd9Sstevel@tonic-gate    do
21877c478bd9Sstevel@tonic-gate	get_ans "Enter the service id:"
21887c478bd9Sstevel@tonic-gate	_SERV_ID=$ANS
21897c478bd9Sstevel@tonic-gate
21907c478bd9Sstevel@tonic-gate	# Grep for name existing.
21917c478bd9Sstevel@tonic-gate	${GREP} -i "^$ANS:" ${SSD_FILE} > /dev/null 2>&1
21927c478bd9Sstevel@tonic-gate	if [ $? -eq 1 ]; then
21937c478bd9Sstevel@tonic-gate	    break
21947c478bd9Sstevel@tonic-gate	fi
21957c478bd9Sstevel@tonic-gate
21967c478bd9Sstevel@tonic-gate	# Name exists, print message, let user decide.
21977c478bd9Sstevel@tonic-gate	${ECHO} "ERROR: Service id ${ANS} already exists."
21987c478bd9Sstevel@tonic-gate    done
21997c478bd9Sstevel@tonic-gate
22007c478bd9Sstevel@tonic-gate    get_ans "Enter the base:"
22017c478bd9Sstevel@tonic-gate    _BASE=$ANS
22027c478bd9Sstevel@tonic-gate
22037c478bd9Sstevel@tonic-gate    # Get the scope and verify that its one or sub.
22047c478bd9Sstevel@tonic-gate    while :
22057c478bd9Sstevel@tonic-gate    do
22067c478bd9Sstevel@tonic-gate	get_ans "Enter the scope:"
22077c478bd9Sstevel@tonic-gate	_SCOPE=$ANS
22087c478bd9Sstevel@tonic-gate	case `${ECHO} ${_SCOPE} | tr '[A-Z]' '[a-z]'` in
22097c478bd9Sstevel@tonic-gate	    one) break ;;
22107c478bd9Sstevel@tonic-gate	    sub) break ;;
22117c478bd9Sstevel@tonic-gate	    *)   ${ECHO} "${_SCOPE} is Not valid - Enter 'one' or 'sub'" ;;
22127c478bd9Sstevel@tonic-gate	esac
22137c478bd9Sstevel@tonic-gate    done
22147c478bd9Sstevel@tonic-gate
22157c478bd9Sstevel@tonic-gate    # Build SSD to add to file.
22167c478bd9Sstevel@tonic-gate    _SSD="${_SERV_ID}:${_BASE}?${_SCOPE}"
22177c478bd9Sstevel@tonic-gate
22187c478bd9Sstevel@tonic-gate    # Add the SSD to the file.
22197c478bd9Sstevel@tonic-gate    ${ECHO} "${_SSD}" >> ${SSD_FILE}
22207c478bd9Sstevel@tonic-gate}
22217c478bd9Sstevel@tonic-gate
22227c478bd9Sstevel@tonic-gate
22237c478bd9Sstevel@tonic-gate#
22247c478bd9Sstevel@tonic-gate# delete_ssd(): Delete a SSD from the list.
22257c478bd9Sstevel@tonic-gate#
22267c478bd9Sstevel@tonic-gatedelete_ssd()
22277c478bd9Sstevel@tonic-gate{
22287c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In delete_ssd()"
22297c478bd9Sstevel@tonic-gate
22307c478bd9Sstevel@tonic-gate    # Get service id name from user for SSD to delete.
22317c478bd9Sstevel@tonic-gate    get_ans_req "Enter service id to delete:"
22327c478bd9Sstevel@tonic-gate
22337c478bd9Sstevel@tonic-gate    # Make sure service id exists.
22347c478bd9Sstevel@tonic-gate    ${GREP} "$ANS" ${SSD_FILE} > /dev/null 2>&1
22357c478bd9Sstevel@tonic-gate    if [ $? -eq 1 ]; then
22367c478bd9Sstevel@tonic-gate	${ECHO} "Invalid service id: $ANS not present in list."
22377c478bd9Sstevel@tonic-gate	return
22387c478bd9Sstevel@tonic-gate    fi
22397c478bd9Sstevel@tonic-gate
22407c478bd9Sstevel@tonic-gate    # Create temporary back SSD file.
22417c478bd9Sstevel@tonic-gate    cp ${SSD_FILE} ${SSD_FILE}.bak
22427c478bd9Sstevel@tonic-gate    if [ $? -eq 1 ]; then
22437c478bd9Sstevel@tonic-gate	${ECHO} "ERROR: could not create file: ${SSD_FILE}.bak"
22447c478bd9Sstevel@tonic-gate	exit 1
22457c478bd9Sstevel@tonic-gate    fi
22467c478bd9Sstevel@tonic-gate
22477c478bd9Sstevel@tonic-gate    # Use ${GREP} to remove the SSD.  Read from temp file
22487c478bd9Sstevel@tonic-gate    # and write to the orig file.
22497c478bd9Sstevel@tonic-gate    ${GREP} -v "$ANS" ${SSD_FILE}.bak > ${SSD_FILE}
22507c478bd9Sstevel@tonic-gate}
22517c478bd9Sstevel@tonic-gate
22527c478bd9Sstevel@tonic-gate
22537c478bd9Sstevel@tonic-gate#
22547c478bd9Sstevel@tonic-gate# modify_ssd(): Allow user to modify a SSD.
22557c478bd9Sstevel@tonic-gate#
22567c478bd9Sstevel@tonic-gatemodify_ssd()
22577c478bd9Sstevel@tonic-gate{
22587c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In modify_ssd()"
22597c478bd9Sstevel@tonic-gate
22607c478bd9Sstevel@tonic-gate    # Prompt user for service id.
22617c478bd9Sstevel@tonic-gate    get_ans_req "Enter service id to modify:"
22627c478bd9Sstevel@tonic-gate
22637c478bd9Sstevel@tonic-gate    # Put into temp _LINE.
22647c478bd9Sstevel@tonic-gate    _LINE=`${GREP} "^$ANS:" ${SSD_FILE}`
22657c478bd9Sstevel@tonic-gate    if [ "$_LINE" = "" ]; then
22667c478bd9Sstevel@tonic-gate	${ECHO} "Invalid service id: $ANS"
22677c478bd9Sstevel@tonic-gate	return
22687c478bd9Sstevel@tonic-gate    fi
22697c478bd9Sstevel@tonic-gate
22707c478bd9Sstevel@tonic-gate    # Display current filter for user to see.
22717c478bd9Sstevel@tonic-gate    ${ECHO} ""
22727c478bd9Sstevel@tonic-gate    ${ECHO} "Current SSD: $_LINE"
22737c478bd9Sstevel@tonic-gate    ${ECHO} ""
22747c478bd9Sstevel@tonic-gate
22757c478bd9Sstevel@tonic-gate    # Get the defaults.
22767c478bd9Sstevel@tonic-gate    _CURR_BASE=`${ECHO} $_LINE | cut -d: -f2 | cut -d'?' -f 1`
22777c478bd9Sstevel@tonic-gate    _CURR_SCOPE=`${ECHO} $_LINE | cut -d: -f2 | cut -d'?' -f 2`
22787c478bd9Sstevel@tonic-gate
22797c478bd9Sstevel@tonic-gate    # Create temporary back SSD file.
22807c478bd9Sstevel@tonic-gate    cp ${SSD_FILE} ${SSD_FILE}.bak
22817c478bd9Sstevel@tonic-gate    if [ $? -eq 1 ]; then
22827c478bd9Sstevel@tonic-gate	${ECHO} "ERROR: could not create file: ${SSD_FILE}.bak"
22837c478bd9Sstevel@tonic-gate	cleanup
22847c478bd9Sstevel@tonic-gate	exit 1
22857c478bd9Sstevel@tonic-gate    fi
22867c478bd9Sstevel@tonic-gate
22877c478bd9Sstevel@tonic-gate    # Removed the old line.
22887c478bd9Sstevel@tonic-gate    ${GREP} -v "^$ANS:" ${SSD_FILE}.bak > ${SSD_FILE} 2>&1
22897c478bd9Sstevel@tonic-gate
22907c478bd9Sstevel@tonic-gate    # New Entry
22917c478bd9Sstevel@tonic-gate    _SERV_ID=$ANS
22927c478bd9Sstevel@tonic-gate    get_ans_req "Enter the base:" "$_CURR_BASE"
22937c478bd9Sstevel@tonic-gate    _BASE=$ANS
22947c478bd9Sstevel@tonic-gate    get_ans_req "Enter the scope:" "$_CURR_SCOPE"
22957c478bd9Sstevel@tonic-gate    _SCOPE=$ANS
22967c478bd9Sstevel@tonic-gate
22977c478bd9Sstevel@tonic-gate    # Build the new SSD.
22987c478bd9Sstevel@tonic-gate    _SSD="${_SERV_ID}:${_BASE}?${_SCOPE}"
22997c478bd9Sstevel@tonic-gate
23007c478bd9Sstevel@tonic-gate    # Add the SSD to the file.
23017c478bd9Sstevel@tonic-gate    ${ECHO} "${_SSD}" >> ${SSD_FILE}
23027c478bd9Sstevel@tonic-gate}
23037c478bd9Sstevel@tonic-gate
23047c478bd9Sstevel@tonic-gate
23057c478bd9Sstevel@tonic-gate#
23067c478bd9Sstevel@tonic-gate# display_ssd(): Display the current SSD list.
23077c478bd9Sstevel@tonic-gate#
23087c478bd9Sstevel@tonic-gatedisplay_ssd()
23097c478bd9Sstevel@tonic-gate{
23107c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In display_ssd()"
23117c478bd9Sstevel@tonic-gate
23127c478bd9Sstevel@tonic-gate    ${ECHO} ""
23137c478bd9Sstevel@tonic-gate    ${ECHO} "Current Service Search Descriptors:"
23147c478bd9Sstevel@tonic-gate    ${ECHO} "=================================="
23157c478bd9Sstevel@tonic-gate    cat ${SSD_FILE}
23167c478bd9Sstevel@tonic-gate    ${ECHO} ""
23177c478bd9Sstevel@tonic-gate    ${ECHO} "Hit return to continue."
23187c478bd9Sstevel@tonic-gate    read __A
23197c478bd9Sstevel@tonic-gate}
23207c478bd9Sstevel@tonic-gate
23217c478bd9Sstevel@tonic-gate
23227c478bd9Sstevel@tonic-gate#
23237c478bd9Sstevel@tonic-gate# prompt_ssd(): Get SSD's from user.
23247c478bd9Sstevel@tonic-gate#
23257c478bd9Sstevel@tonic-gateprompt_ssd()
23267c478bd9Sstevel@tonic-gate{
23277c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In prompt_ssd()"
23287c478bd9Sstevel@tonic-gate    # See if user wants SSD's?
23297c478bd9Sstevel@tonic-gate    get_confirm "Do you wish to setup Service Search Descriptors (y/n/h)?" "n" "ssd_help"
23307c478bd9Sstevel@tonic-gate    [ "$?" -eq 0 ] && return
23317c478bd9Sstevel@tonic-gate
23327c478bd9Sstevel@tonic-gate    # Display menu for SSD choices.
23337c478bd9Sstevel@tonic-gate    while :
23347c478bd9Sstevel@tonic-gate    do
23357c478bd9Sstevel@tonic-gate	display_msg prompt_ssd_menu
23367c478bd9Sstevel@tonic-gate	get_ans "Enter menu choice:" "Quit"
23377c478bd9Sstevel@tonic-gate	case "$ANS" in
23387c478bd9Sstevel@tonic-gate	    [Aa] | add) add_ssd ;;
23397c478bd9Sstevel@tonic-gate	    [Dd] | delete) delete_ssd ;;
23407c478bd9Sstevel@tonic-gate	    [Mm] | modify) modify_ssd ;;
23417c478bd9Sstevel@tonic-gate	    [Pp] | print | display) display_ssd ;;
23427c478bd9Sstevel@tonic-gate	    [Xx] | reset | clear) reset_ssd_file ;;
23437c478bd9Sstevel@tonic-gate	    [Hh] | Help | help)	display_msg ssd_menu_help
23447c478bd9Sstevel@tonic-gate				${ECHO} " Press return to continue."
23457c478bd9Sstevel@tonic-gate				read __A ;;
23467c478bd9Sstevel@tonic-gate	    [Qq] | Quit | quit)	return ;;
23477c478bd9Sstevel@tonic-gate	    *)    ${ECHO} "Invalid choice: $ANS please re-enter from menu." ;;
23487c478bd9Sstevel@tonic-gate	esac
23497c478bd9Sstevel@tonic-gate    done
23507c478bd9Sstevel@tonic-gate}
23517c478bd9Sstevel@tonic-gate
23527c478bd9Sstevel@tonic-gate
23537c478bd9Sstevel@tonic-gate#
23547c478bd9Sstevel@tonic-gate# reset_ssd_file(): Blank out current SSD file.
23557c478bd9Sstevel@tonic-gate#
23567c478bd9Sstevel@tonic-gatereset_ssd_file()
23577c478bd9Sstevel@tonic-gate{
23587c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In reset_ssd_file()"
23597c478bd9Sstevel@tonic-gate
23607c478bd9Sstevel@tonic-gate    rm -f ${SSD_FILE}
23617c478bd9Sstevel@tonic-gate    touch ${SSD_FILE}
23627c478bd9Sstevel@tonic-gate}
23637c478bd9Sstevel@tonic-gate
23647c478bd9Sstevel@tonic-gate
23657c478bd9Sstevel@tonic-gate#
23667c478bd9Sstevel@tonic-gate# create_ssd_file(): Create a temporary file for SSD's.
23677c478bd9Sstevel@tonic-gate#
23687c478bd9Sstevel@tonic-gatecreate_ssd_file()
23697c478bd9Sstevel@tonic-gate{
23707c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In create_ssd_file()"
23717c478bd9Sstevel@tonic-gate
23727c478bd9Sstevel@tonic-gate    # Build a list of SSD's and store in temp file.
23737c478bd9Sstevel@tonic-gate    ${GREP} "LDAP_SERV_SRCH_DES=" ${INPUT_FILE} | \
23747c478bd9Sstevel@tonic-gate	sed 's/LDAP_SERV_SRCH_DES=//' \
23757c478bd9Sstevel@tonic-gate	> ${SSD_FILE}
23767c478bd9Sstevel@tonic-gate}
23777c478bd9Sstevel@tonic-gate
23787c478bd9Sstevel@tonic-gate
23797c478bd9Sstevel@tonic-gate#
23807c478bd9Sstevel@tonic-gate# ssd_2_config(): Append the SSD file to the output file.
23817c478bd9Sstevel@tonic-gate#
23827c478bd9Sstevel@tonic-gatessd_2_config()
23837c478bd9Sstevel@tonic-gate{
23847c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In ssd_2_config()"
23857c478bd9Sstevel@tonic-gate
23867c478bd9Sstevel@tonic-gate    # Convert to config file format using sed.
23877c478bd9Sstevel@tonic-gate    sed -e "s/^/LDAP_SERV_SRCH_DES=/" ${SSD_FILE} >> ${OUTPUT_FILE}
23887c478bd9Sstevel@tonic-gate}
23897c478bd9Sstevel@tonic-gate
23907c478bd9Sstevel@tonic-gate
23917c478bd9Sstevel@tonic-gate#
23927c478bd9Sstevel@tonic-gate# ssd_2_profile(): Add SSD's to the GEN_CMD string.
23937c478bd9Sstevel@tonic-gate#
23947c478bd9Sstevel@tonic-gatessd_2_profile()
23957c478bd9Sstevel@tonic-gate{
23967c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In ssd_2_profile()"
23977c478bd9Sstevel@tonic-gate
23987c478bd9Sstevel@tonic-gate    GEN_TMPFILE=${TMPDIR}/ssd_tmpfile
23997c478bd9Sstevel@tonic-gate    touch ${GEN_TMPFILE}
24007c478bd9Sstevel@tonic-gate
24017c478bd9Sstevel@tonic-gate    # Add and convert each SSD to string.
24027c478bd9Sstevel@tonic-gate    while read SSD_LINE
24037c478bd9Sstevel@tonic-gate    do
24047c478bd9Sstevel@tonic-gate	${ECHO} " -a \"serviceSearchDescriptor=${SSD_LINE}\"\c" >> ${GEN_TMPFILE}
24057c478bd9Sstevel@tonic-gate    done <${SSD_FILE}
24067c478bd9Sstevel@tonic-gate
24077c478bd9Sstevel@tonic-gate    # Add SSD's to GEN_CMD.
24087c478bd9Sstevel@tonic-gate    GEN_CMD="${GEN_CMD} `cat ${GEN_TMPFILE}`"
24097c478bd9Sstevel@tonic-gate}
24107c478bd9Sstevel@tonic-gate
2411dd1104fbSMichen Chang#
2412dd1104fbSMichen Chang# get_adminDN(): Get the admin DN.
2413dd1104fbSMichen Chang#
2414dd1104fbSMichen Changget_adminDN()
2415dd1104fbSMichen Chang{
2416dd1104fbSMichen Chang    LDAP_ADMINDN="cn=admin,ou=profile,${LDAP_BASEDN}"  # default
2417dd1104fbSMichen Chang    get_ans "Enter DN for the administrator:" "$LDAP_ADMINDN"
2418dd1104fbSMichen Chang    LDAP_ADMINDN=$ANS
2419dd1104fbSMichen Chang    [ $DEBUG -eq 1 ] && ${ECHO} "LDAP_ADMINDN = $LDAP_ADMINDN"
2420dd1104fbSMichen Chang}
2421dd1104fbSMichen Chang
2422dd1104fbSMichen Chang#
2423dd1104fbSMichen Chang# get_admin_pw(): Get the admin passwd.
2424dd1104fbSMichen Chang#
2425dd1104fbSMichen Changget_admin_pw()
2426dd1104fbSMichen Chang{
2427dd1104fbSMichen Chang    get_passwd "Enter passwd for the administrator:"
2428dd1104fbSMichen Chang    LDAP_ADMIN_CRED=$ANS
2429dd1104fbSMichen Chang    [ $DEBUG -eq 1 ] && ${ECHO} "LDAP_ADMIN_CRED = $LDAP_ADMIN_CRED"
2430dd1104fbSMichen Chang}
2431dd1104fbSMichen Chang
2432dd1104fbSMichen Chang#
2433dd1104fbSMichen Chang# add_admin(): Add an admin entry for nameservice for updating shadow data.
2434dd1104fbSMichen Chang#
2435dd1104fbSMichen Changadd_admin()
2436dd1104fbSMichen Chang{
2437dd1104fbSMichen Chang    [ $DEBUG -eq 1 ] && ${ECHO} "In add_admin()"
2438dd1104fbSMichen Chang
2439dd1104fbSMichen Chang    # Check if the admin user already exists.
2440dd1104fbSMichen Chang    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_ADMINDN}\" -s base \"objectclass=*\" ${VERB}"
2441dd1104fbSMichen Chang    if [ $? -eq 0 ]; then
2442dd1104fbSMichen Chang	MSG="Administrator ${LDAP_ADMINDN} already exists."
2443dd1104fbSMichen Chang	if [ $EXISTING_PROFILE -eq 1 ]; then
2444dd1104fbSMichen Chang	    ${ECHO} "  NOT ADDED: $MSG"
2445dd1104fbSMichen Chang	else
2446dd1104fbSMichen Chang	    ${ECHO} "  ${STEP}. $MSG"
2447dd1104fbSMichen Chang	    STEP=`expr $STEP + 1`
2448dd1104fbSMichen Chang	fi
2449dd1104fbSMichen Chang	return 0
2450dd1104fbSMichen Chang    fi
2451dd1104fbSMichen Chang
2452dd1104fbSMichen Chang    # Get cn and sn names from LDAP_ADMINDN.
2453dd1104fbSMichen Chang    cn_tmp=`${ECHO} ${LDAP_ADMINDN} | cut -f1 -d, | cut -f2 -d=`
2454dd1104fbSMichen Chang
2455dd1104fbSMichen Chang    # Create the tmp file to add.
2456dd1104fbSMichen Chang    ( cat <<EOF
2457dd1104fbSMichen Changdn: ${LDAP_ADMINDN}
2458dd1104fbSMichen Changcn: ${cn_tmp}
2459dd1104fbSMichen Changsn: ${cn_tmp}
2460dd1104fbSMichen Changobjectclass: top
2461dd1104fbSMichen Changobjectclass: person
2462dd1104fbSMichen Changuserpassword: ${LDAP_ADMIN_CRED}
2463dd1104fbSMichen ChangEOF
2464dd1104fbSMichen Chang) > ${TMPDIR}/admin
2465dd1104fbSMichen Chang
2466dd1104fbSMichen Chang    # Add the entry.
2467dd1104fbSMichen Chang    ${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/admin ${VERB}"
2468dd1104fbSMichen Chang    if [ $? -ne 0 ]; then
2469dd1104fbSMichen Chang	${ECHO} "  ERROR: Adding administrator identity failed!"
2470dd1104fbSMichen Chang	cleanup
2471dd1104fbSMichen Chang	exit 1
2472dd1104fbSMichen Chang    fi
2473dd1104fbSMichen Chang
2474dd1104fbSMichen Chang    ${RM} -f ${TMPDIR}/admin
2475dd1104fbSMichen Chang
2476dd1104fbSMichen Chang    # Display message that the administrator identity is added.
2477dd1104fbSMichen Chang    MSG="Administrator identity ${LDAP_ADMINDN}"
2478dd1104fbSMichen Chang    if [ $EXISTING_PROFILE -eq 1 ]; then
2479dd1104fbSMichen Chang	${ECHO} "  ADDED: $MSG."
2480dd1104fbSMichen Chang    else
2481dd1104fbSMichen Chang	${ECHO} "  ${STEP}. $MSG added."
2482dd1104fbSMichen Chang	STEP=`expr $STEP + 1`
2483dd1104fbSMichen Chang    fi
2484dd1104fbSMichen Chang}
2485dd1104fbSMichen Chang
2486dd1104fbSMichen Chang#
2487b57459abSJulian Pullen# allow_admin_read_write_shadow(): Give Admin read/write permission
2488b57459abSJulian Pullen# to shadow data.
2489dd1104fbSMichen Chang#
2490b57459abSJulian Pullenallow_admin_read_write_shadow()
2491dd1104fbSMichen Chang{
2492b57459abSJulian Pullen    [ $DEBUG -eq 1 ] && ${ECHO} "In allow_admin_read_write_shadow()"
2493dd1104fbSMichen Chang
2494dd1104fbSMichen Chang    # Set ACI Name
2495dd1104fbSMichen Chang    ADMIN_ACI_NAME="LDAP_Naming_Services_admin_shadow_write"
2496dd1104fbSMichen Chang
2497dd1104fbSMichen Chang    # Search for ACI_NAME
2498dd1104fbSMichen Chang    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_BASEDN}\" \
2499dd1104fbSMichen Chang    -s base objectclass=* aci > ${TMPDIR}/chk_adminwrite_aci 2>&1"
2500b57459abSJulian Pullen
2501b57459abSJulian Pullen    # if an ACI with ${ADMIN_ACI_NAME} and "write,compare,read,search"
2502b57459abSJulian Pullen    # and ${LDAP_ADMINDN} already exists, we are done
2503b57459abSJulian Pullen    ${EGREP} ".*${ADMIN_ACI_NAME}.*write,compare,read,search.*${LDAP_ADMINDN}.*" \
2504b57459abSJulian Pullen    	${TMPDIR}/chk_adminwrite_aci 2>&1 > /dev/null
2505dd1104fbSMichen Chang    if [ $? -eq 0 ]; then
2506dd1104fbSMichen Chang	MSG="Admin ACI ${ADMIN_ACI_NAME} already exists for ${LDAP_BASEDN}."
2507dd1104fbSMichen Chang	if [ $EXISTING_PROFILE -eq 1 ]; then
2508dd1104fbSMichen Chang	    ${ECHO} "  NOT SET: $MSG"
2509dd1104fbSMichen Chang	else
2510dd1104fbSMichen Chang	    ${ECHO} "  ${STEP}. $MSG"
2511dd1104fbSMichen Chang	    STEP=`expr $STEP + 1`
2512dd1104fbSMichen Chang	fi
2513dd1104fbSMichen Chang	return 0
2514dd1104fbSMichen Chang    fi
2515dd1104fbSMichen Chang
2516b57459abSJulian Pullen    # If an ACI with ${ADMIN_ACI_NAME} and "(write)" and ${LDAP_ADMINDN}
2517b57459abSJulian Pullen    # already exists, delete it first.
2518b57459abSJulian Pullen    find_and_delete_ACI ".*${ADMIN_ACI_NAME}.*(write).*${LDAP_ADMINDN}.*" \
2519b57459abSJulian Pullen	${TMPDIR}/chk_adminwrite_aci ${ADMIN_ACI_NAME}
2520b57459abSJulian Pullen
2521dd1104fbSMichen Chang    # Create the tmp file to add.
2522dd1104fbSMichen Chang    ( cat <<EOF
2523dd1104fbSMichen Changdn: ${LDAP_BASEDN}
2524dd1104fbSMichen Changchangetype: modify
2525dd1104fbSMichen Changadd: aci
2526b57459abSJulian Pullenaci: (target="ldap:///${LDAP_BASEDN}")(targetattr="shadowLastChange
2527b57459abSJulian Pullen ||shadowMin||shadowMax||shadowWarning||shadowInactive||shadowExpire
2528b57459abSJulian Pullen ||shadowFlag||userPassword||loginShell||homeDirectory||gecos")
2529b57459abSJulian Pullen  (version 3.0; acl ${ADMIN_ACI_NAME}; allow (write,compare,read,search)
2530b57459abSJulian Pullen  userdn = "ldap:///${LDAP_ADMINDN}";)
2531dd1104fbSMichen ChangEOF
2532dd1104fbSMichen Chang) > ${TMPDIR}/admin_write
2533dd1104fbSMichen Chang
2534dd1104fbSMichen Chang    # Add the entry.
2535dd1104fbSMichen Chang    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/admin_write ${VERB}"
2536dd1104fbSMichen Chang    if [ $? -ne 0 ]; then
2537b57459abSJulian Pullen	${ECHO} "  ERROR: Allow ${LDAP_ADMINDN} read/write access to shadow data failed!"
2538dd1104fbSMichen Chang	cleanup
2539dd1104fbSMichen Chang	exit 1
2540dd1104fbSMichen Chang    fi
2541dd1104fbSMichen Chang
2542dd1104fbSMichen Chang    ${RM} -f ${TMPDIR}/admin_write
2543dd1104fbSMichen Chang    # Display message that the administrator ACL is set.
2544b57459abSJulian Pullen    MSG="Give ${LDAP_ADMINDN} read/write access to shadow data."
2545dd1104fbSMichen Chang    if [ $EXISTING_PROFILE -eq 1 ]; then
2546dd1104fbSMichen Chang	${ECHO} "  ACI SET: $MSG"
2547dd1104fbSMichen Chang    else
2548dd1104fbSMichen Chang	${ECHO} "  ${STEP}. $MSG"
2549dd1104fbSMichen Chang	STEP=`expr $STEP + 1`
2550dd1104fbSMichen Chang    fi
2551dd1104fbSMichen Chang}
2552dd1104fbSMichen Chang
2553dd1104fbSMichen Chang#
2554b57459abSJulian Pullen# allow_host_read_write_shadow(): Give host principal read/write permission
2555dd1104fbSMichen Chang# for shadow data.
2556dd1104fbSMichen Chang#
2557b57459abSJulian Pullenallow_host_read_write_shadow()
2558dd1104fbSMichen Chang{
2559b57459abSJulian Pullen    [ $DEBUG -eq 1 ] && ${ECHO} "In allow_host_read_write_shadow()"
2560dd1104fbSMichen Chang
2561dd1104fbSMichen Chang    # Set ACI Name
2562dd1104fbSMichen Chang    HOST_ACI_NAME="LDAP_Naming_Services_host_shadow_write"
2563dd1104fbSMichen Chang
2564dd1104fbSMichen Chang    # Search for ACI_NAME
2565dd1104fbSMichen Chang    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_BASEDN}\" -s base objectclass=* aci > ${TMPDIR}/chk_hostwrite_aci 2>&1"
2566dd1104fbSMichen Chang    ${GREP} "${HOST_ACI_NAME}" ${TMPDIR}/chk_hostwrite_aci > /dev/null 2>&1
2567dd1104fbSMichen Chang    if [ $? -eq 0 ]; then
2568dd1104fbSMichen Chang	MSG="Host ACI ${HOST_ACI_NAME} already exists for ${LDAP_BASEDN}."
2569dd1104fbSMichen Chang	if [ $EXISTING_PROFILE -eq 1 ]; then
2570dd1104fbSMichen Chang	    ${ECHO} "  NOT ADDED: $MSG"
2571dd1104fbSMichen Chang	else
2572dd1104fbSMichen Chang	    ${ECHO} "  ${STEP}. $MSG"
2573dd1104fbSMichen Chang	    STEP=`expr $STEP + 1`
2574dd1104fbSMichen Chang	fi
2575dd1104fbSMichen Chang	return 0
2576dd1104fbSMichen Chang    fi
2577dd1104fbSMichen Chang
2578dd1104fbSMichen Chang    # Create the tmp file to add.
2579dd1104fbSMichen Chang    ( cat <<EOF
2580dd1104fbSMichen Changdn: ${LDAP_BASEDN}
2581dd1104fbSMichen Changchangetype: modify
2582dd1104fbSMichen Changadd: aci
2583b57459abSJulian Pullenaci: (target="ldap:///${LDAP_BASEDN}")(targetattr="shadowLastChange||shadowMin||shadowMax||shadowWarning||shadowInactive||shadowExpire||shadowFlag||userPassword||loginShell||homeDirectory||gecos")(version 3.0; acl ${HOST_ACI_NAME}; allow (write,compare,read,search) authmethod="sasl GSSAPI" and userdn = "ldap:///cn=*+ipHostNumber=*,ou=Hosts,${LDAP_BASEDN}";)
2584dd1104fbSMichen ChangEOF
2585b57459abSJulian Pullen) > ${TMPDIR}/host_read_write
2586dd1104fbSMichen Chang
2587dd1104fbSMichen Chang    # Add the entry.
2588b57459abSJulian Pullen    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/host_read_write ${VERB}"
2589dd1104fbSMichen Chang    if [ $? -ne 0 ]; then
2590dd1104fbSMichen Chang	${ECHO} "  ERROR: Allow Host Principal to write shadow data failed!"
2591dd1104fbSMichen Chang	cleanup
2592dd1104fbSMichen Chang	exit 1
2593dd1104fbSMichen Chang    fi
2594dd1104fbSMichen Chang
2595b57459abSJulian Pullen    ${RM} -f ${TMPDIR}/host_read_write
2596b57459abSJulian Pullen    MSG="Give host principal read/write permission for shadow."
2597dd1104fbSMichen Chang    if [ $EXISTING_PROFILE -eq 1 ]; then
2598dd1104fbSMichen Chang	${ECHO} "  ACI SET: $MSG"
2599dd1104fbSMichen Chang    else
2600dd1104fbSMichen Chang	${ECHO} "  ${STEP}. $MSG"
2601dd1104fbSMichen Chang	STEP=`expr $STEP + 1`
2602dd1104fbSMichen Chang    fi
2603dd1104fbSMichen Chang}
2604dd1104fbSMichen Chang
2605dd1104fbSMichen Chang#
2606dd1104fbSMichen Chang# Set up shadow update
2607dd1104fbSMichen Chang#
2608dd1104fbSMichen Changsetup_shadow_update() {
2609dd1104fbSMichen Chang    [ $DEBUG -eq 1 ] && ${ECHO} "In setup_shadow_update()"
2610dd1104fbSMichen Chang
2611dd1104fbSMichen Chang    # get content of the profile
2612dd1104fbSMichen Chang    PROFILE_OUT=${TMPDIR}/prof_tmpfile
2613dd1104fbSMichen Chang    ${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} -b \"cn=${LDAP_PROFILE_NAME},ou=profile,${LDAP_BASEDN}\" -s base \"objectclass=*\" > $PROFILE_OUT 2>&1"
2614dd1104fbSMichen Chang    ${GREP} -i cn $PROFILE_OUT >/dev/null 2>&1
2615dd1104fbSMichen Chang    if [ $? -ne 0 ]; then
2616dd1104fbSMichen Chang	[ $DEBUG -eq 1 ] && ${ECHO} "Profile ${LDAP_PROFILE_NAME} does not exist"
2617dd1104fbSMichen Chang	${RM} ${PROFILE_OUT}
2618dd1104fbSMichen Chang	return
2619dd1104fbSMichen Chang    fi
2620dd1104fbSMichen Chang
2621dd1104fbSMichen Chang    # Search to see if authenticationMethod has 'GSSAPI' and
2622dd1104fbSMichen Chang    # credentialLevel has 'self'. If so, ask to use the
2623dd1104fbSMichen Chang    # host principal for shadow update
2624dd1104fbSMichen Chang    if [ $GSSAPI_AUTH_MAY_BE_USED -eq 1 ]; then
2625dd1104fbSMichen Chang	if ${GREP} authenticationMethod $PROFILE_OUT | ${GREP} GSSAPI >/dev/null 2>&1
2626dd1104fbSMichen Chang	then
2627dd1104fbSMichen Chang	    if ${GREP} credentialLevel $PROFILE_OUT | ${GREP} self >/dev/null 2>&1
2628dd1104fbSMichen Chang	    then
2629dd1104fbSMichen Chang		NEED_HOSTACL=1
2630dd1104fbSMichen Chang	    fi
2631dd1104fbSMichen Chang	fi
2632dd1104fbSMichen Chang	${RM} ${PROFILE_OUT}
2633dd1104fbSMichen Chang	[ $DEBUG -eq 1 ] && ${ECHO} "NEED_HOSTACL = $NEED_HOSTACL"
2634dd1104fbSMichen Chang
2635dd1104fbSMichen Chang	if [ $NEED_HOSTACL -eq 1 ]; then
2636dd1104fbSMichen Chang	    MSG="Use host principal for shadow data update (y/n/h)?"
2637dd1104fbSMichen Chang	    get_confirm "$MSG" "y" "use_host_principal_help"
2638dd1104fbSMichen Chang	    if [ $? -eq 1 ]; then
2639b57459abSJulian Pullen		delete_proxy_read_pw
2640b57459abSJulian Pullen		allow_host_read_write_shadow
2641b57459abSJulian Pullen		deny_non_host_shadow_access
2642dd1104fbSMichen Chang	        ${ECHO} ""
2643dd1104fbSMichen Chang		${ECHO} "  Shadow update has been enabled."
2644dd1104fbSMichen Chang	    else
2645dd1104fbSMichen Chang	        ${ECHO} ""
2646dd1104fbSMichen Chang    		${ECHO} "  Shadow update may not work."
2647dd1104fbSMichen Chang	    fi
2648dd1104fbSMichen Chang	    return
2649dd1104fbSMichen Chang	fi
2650dd1104fbSMichen Chang    fi
2651dd1104fbSMichen Chang
2652dd1104fbSMichen Chang    MSG="Add the administrator identity (y/n/h)?"
2653dd1104fbSMichen Chang    get_confirm "$MSG" "y" "add_admin_cred_help"
2654dd1104fbSMichen Chang    if [ $? -eq 1 ]; then
2655dd1104fbSMichen Chang	get_adminDN
2656dd1104fbSMichen Chang	get_admin_pw
2657dd1104fbSMichen Chang	add_admin
2658b57459abSJulian Pullen	delete_proxy_read_pw
2659b57459abSJulian Pullen	allow_admin_read_write_shadow
2660b57459abSJulian Pullen	deny_non_admin_shadow_access
2661dd1104fbSMichen Chang        ${ECHO} ""
2662dd1104fbSMichen Chang	${ECHO} "  Shadow update has been enabled."
2663dd1104fbSMichen Chang	return
2664dd1104fbSMichen Chang    fi
2665dd1104fbSMichen Chang
2666dd1104fbSMichen Chang    ${ECHO} "  No administrator identity specified, shadow update may not work."
2667dd1104fbSMichen Chang}
2668dd1104fbSMichen Chang
26697c478bd9Sstevel@tonic-gate
26707c478bd9Sstevel@tonic-gate#
26717c478bd9Sstevel@tonic-gate# prompt_config_info(): This function prompts the user for the config
26727c478bd9Sstevel@tonic-gate# info that is not specified in the input file.
26737c478bd9Sstevel@tonic-gate#
26747c478bd9Sstevel@tonic-gateprompt_config_info()
26757c478bd9Sstevel@tonic-gate{
26767c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In prompt_config_info()"
26777c478bd9Sstevel@tonic-gate
26787c478bd9Sstevel@tonic-gate    # Prompt for iDS server name.
26797c478bd9Sstevel@tonic-gate    get_ids_server
26807c478bd9Sstevel@tonic-gate
26817c478bd9Sstevel@tonic-gate    # Prompt for iDS port number.
26827c478bd9Sstevel@tonic-gate    get_ids_port
26837c478bd9Sstevel@tonic-gate
26847c478bd9Sstevel@tonic-gate    # Check iDS version for compatibility.
26857c478bd9Sstevel@tonic-gate    chk_ids_version
26867c478bd9Sstevel@tonic-gate
26877c478bd9Sstevel@tonic-gate    # Check if the server supports the VLV.
26887c478bd9Sstevel@tonic-gate    chk_vlv_indexes
26897c478bd9Sstevel@tonic-gate
26907c478bd9Sstevel@tonic-gate    # Get the Directory manager DN and passwd.
26917c478bd9Sstevel@tonic-gate    get_dirmgr_dn
26927c478bd9Sstevel@tonic-gate    get_dirmgr_pw
26937c478bd9Sstevel@tonic-gate
26947c478bd9Sstevel@tonic-gate    #
26957c478bd9Sstevel@tonic-gate    # LDAP CLIENT PROFILE SPECIFIC INFORMATION.
26967c478bd9Sstevel@tonic-gate    #   (i.e. The fields that show up in the profile.)
26977c478bd9Sstevel@tonic-gate    #
26987c478bd9Sstevel@tonic-gate    get_domain "domain_help"
26997c478bd9Sstevel@tonic-gate
27007c478bd9Sstevel@tonic-gate    get_basedn
27017c478bd9Sstevel@tonic-gate
2702cb5caa98Sdjl    gssapi_setup
2703cb5caa98Sdjl
27047c478bd9Sstevel@tonic-gate    get_profile_name
2705dd1104fbSMichen Chang
2706dd1104fbSMichen Chang    if [ "$LDAP_ENABLE_SHADOW_UPDATE" = "TRUE" ];then
2707dd1104fbSMichen Chang	setup_shadow_update
2708b57459abSJulian Pullen	cleanup
2709dd1104fbSMichen Chang	exit 0
2710dd1104fbSMichen Chang    fi
2711dd1104fbSMichen Chang
27127c478bd9Sstevel@tonic-gate    get_srv_list
27137c478bd9Sstevel@tonic-gate    get_pref_srv
27147c478bd9Sstevel@tonic-gate    get_search_scope
27157c478bd9Sstevel@tonic-gate
27167c478bd9Sstevel@tonic-gate    # If cred is "anonymous", make auth == "none"
27177c478bd9Sstevel@tonic-gate    get_cred_level
27187c478bd9Sstevel@tonic-gate    if [ "$LDAP_CRED_LEVEL" != "anonymous" ]; then
27197c478bd9Sstevel@tonic-gate	get_auth
27207c478bd9Sstevel@tonic-gate    fi
27217c478bd9Sstevel@tonic-gate
27227c478bd9Sstevel@tonic-gate    get_followref
27237c478bd9Sstevel@tonic-gate
27247c478bd9Sstevel@tonic-gate    # Query user about timelimt.
27257c478bd9Sstevel@tonic-gate    get_confirm "Do you want to modify the server timelimit value (y/n/h)?" "n" "tlim_help"
27267c478bd9Sstevel@tonic-gate    NEED_TIME=$?
27277c478bd9Sstevel@tonic-gate    [ $NEED_TIME -eq 1 ] && get_timelimit
27287c478bd9Sstevel@tonic-gate
27297c478bd9Sstevel@tonic-gate    # Query user about sizelimit.
27307c478bd9Sstevel@tonic-gate    get_confirm "Do you want to modify the server sizelimit value (y/n/h)?" "n" "slim_help"
27317c478bd9Sstevel@tonic-gate    NEED_SIZE=$?
27327c478bd9Sstevel@tonic-gate    [ $NEED_SIZE -eq 1 ] && get_sizelimit
27337c478bd9Sstevel@tonic-gate
27347c478bd9Sstevel@tonic-gate    # Does the user want to store passwords in crypt format?
27357c478bd9Sstevel@tonic-gate    get_want_crypt
27367c478bd9Sstevel@tonic-gate
27377c478bd9Sstevel@tonic-gate    # Prompt for any Service Authentication Methods?
27387c478bd9Sstevel@tonic-gate    get_confirm "Do you want to setup a Service Authentication Methods (y/n/h)?" "n" "srvauth_help"
27397c478bd9Sstevel@tonic-gate    if [ $? -eq 1 ]; then
27407c478bd9Sstevel@tonic-gate	# Does the user want to set Service Authentication Method for pam_ldap?
27417c478bd9Sstevel@tonic-gate	get_confirm "Do you want to setup a Service Auth. Method for \"pam_ldap\" (y/n/h)?" "n" "pam_ldap_help"
27427c478bd9Sstevel@tonic-gate	NEED_SRVAUTH_PAM=$?
27437c478bd9Sstevel@tonic-gate	[ $NEED_SRVAUTH_PAM -eq 1 ] && get_srv_authMethod_pam
27447c478bd9Sstevel@tonic-gate
27457c478bd9Sstevel@tonic-gate	# Does the user want to set Service Authentication Method for keyserv?
27467c478bd9Sstevel@tonic-gate	get_confirm "Do you want to setup a Service Auth. Method for \"keyserv\" (y/n/h)?" "n" "keyserv_help"
27477c478bd9Sstevel@tonic-gate	NEED_SRVAUTH_KEY=$?
27487c478bd9Sstevel@tonic-gate	[ $NEED_SRVAUTH_KEY -eq 1 ] && get_srv_authMethod_key
27497c478bd9Sstevel@tonic-gate
27507c478bd9Sstevel@tonic-gate	# Does the user want to set Service Authentication Method for passwd-cmd?
27517c478bd9Sstevel@tonic-gate	get_confirm "Do you want to setup a Service Auth. Method for \"passwd-cmd\" (y/n/h)?" "n" "passwd-cmd_help"
27527c478bd9Sstevel@tonic-gate	NEED_SRVAUTH_CMD=$?
27537c478bd9Sstevel@tonic-gate	[ $NEED_SRVAUTH_CMD -eq 1 ] && get_srv_authMethod_cmd
27547c478bd9Sstevel@tonic-gate    fi
27557c478bd9Sstevel@tonic-gate
2756cb5caa98Sdjl
27577c478bd9Sstevel@tonic-gate    # Get Timeouts
27587c478bd9Sstevel@tonic-gate    get_srch_time
27597c478bd9Sstevel@tonic-gate    get_prof_ttl
27607c478bd9Sstevel@tonic-gate    get_bind_limit
27617c478bd9Sstevel@tonic-gate
2762dd1104fbSMichen Chang    # Ask whether to enable shadow update
2763dd1104fbSMichen Chang    get_want_shadow_update
2764dd1104fbSMichen Chang
27657c478bd9Sstevel@tonic-gate    # Reset the sdd_file and prompt user for SSD.  Will use menus
27667c478bd9Sstevel@tonic-gate    # to build an SSD File.
27677c478bd9Sstevel@tonic-gate    reset_ssd_file
27687c478bd9Sstevel@tonic-gate    prompt_ssd
27697c478bd9Sstevel@tonic-gate
27707c478bd9Sstevel@tonic-gate    # Display FULL debugging info.
27717c478bd9Sstevel@tonic-gate    disp_full_debug
27727c478bd9Sstevel@tonic-gate
27737c478bd9Sstevel@tonic-gate    # Extra blank line to separate prompt lines from steps.
27747c478bd9Sstevel@tonic-gate    ${ECHO} " "
27757c478bd9Sstevel@tonic-gate}
27767c478bd9Sstevel@tonic-gate
27777c478bd9Sstevel@tonic-gate
27787c478bd9Sstevel@tonic-gate######################################################################
27797c478bd9Sstevel@tonic-gate# FUNCTIONS  FOR display_summary() START HERE.
27807c478bd9Sstevel@tonic-gate######################################################################
27817c478bd9Sstevel@tonic-gate
27827c478bd9Sstevel@tonic-gate
27837c478bd9Sstevel@tonic-gate#
27847c478bd9Sstevel@tonic-gate# get_proxyagent(): Get the proxyagent DN.
27857c478bd9Sstevel@tonic-gate#
27867c478bd9Sstevel@tonic-gateget_proxyagent()
27877c478bd9Sstevel@tonic-gate{
27887c478bd9Sstevel@tonic-gate    LDAP_PROXYAGENT="cn=proxyagent,ou=profile,${LDAP_BASEDN}"  # default
27897c478bd9Sstevel@tonic-gate    get_ans "Enter DN for proxy agent:" "$LDAP_PROXYAGENT"
27907c478bd9Sstevel@tonic-gate    LDAP_PROXYAGENT=$ANS
27917c478bd9Sstevel@tonic-gate}
27927c478bd9Sstevel@tonic-gate
27937c478bd9Sstevel@tonic-gate
27947c478bd9Sstevel@tonic-gate#
27957c478bd9Sstevel@tonic-gate# get_proxy_pw(): Get the proxyagent passwd.
27967c478bd9Sstevel@tonic-gate#
27977c478bd9Sstevel@tonic-gateget_proxy_pw()
27987c478bd9Sstevel@tonic-gate{
27997c478bd9Sstevel@tonic-gate    get_passwd "Enter passwd for proxyagent:"
28007c478bd9Sstevel@tonic-gate    LDAP_PROXYAGENT_CRED=$ANS
28017c478bd9Sstevel@tonic-gate}
28027c478bd9Sstevel@tonic-gate
28037c478bd9Sstevel@tonic-gate#
28047c478bd9Sstevel@tonic-gate# display_summary(): Display a summary of values entered and let the
28057c478bd9Sstevel@tonic-gate#                    user modify values at will.
28067c478bd9Sstevel@tonic-gate#
28077c478bd9Sstevel@tonic-gatedisplay_summary()
28087c478bd9Sstevel@tonic-gate{
28097c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In display_summary()"
28107c478bd9Sstevel@tonic-gate
28117c478bd9Sstevel@tonic-gate    # Create lookup table for function names.  First entry is dummy for
28127c478bd9Sstevel@tonic-gate    # shift.
28137c478bd9Sstevel@tonic-gate    TBL1="dummy"
28147c478bd9Sstevel@tonic-gate    TBL2="get_domain get_basedn get_profile_name"
28157c478bd9Sstevel@tonic-gate    TBL3="get_srv_list get_pref_srv get_search_scope get_cred_level"
28167c478bd9Sstevel@tonic-gate    TBL4="get_auth get_followref"
28177c478bd9Sstevel@tonic-gate    TBL5="get_timelimit get_sizelimit get_want_crypt"
28187c478bd9Sstevel@tonic-gate    TBL6="get_srv_authMethod_pam get_srv_authMethod_key get_srv_authMethod_cmd"
28197c478bd9Sstevel@tonic-gate    TBL7="get_srch_time get_prof_ttl get_bind_limit"
2820dd1104fbSMichen Chang    TBL8="get_want_shadow_update"
2821dd1104fbSMichen Chang    TBL9="prompt_ssd"
2822dd1104fbSMichen Chang    FUNC_TBL="$TBL1 $TBL2 $TBL3 $TBL4 $TBL5 $TBL6 $TBL7 $TBL8 $TBL9"
28237c478bd9Sstevel@tonic-gate
28247c478bd9Sstevel@tonic-gate    # Since menu prompt string is long, set here.
2825dd1104fbSMichen Chang    _MENU_PROMPT="Enter config value to change: (1-20 0=commit changes)"
28267c478bd9Sstevel@tonic-gate
28277c478bd9Sstevel@tonic-gate    # Infinite loop.  Test for 0, and break in loop.
28287c478bd9Sstevel@tonic-gate    while :
28297c478bd9Sstevel@tonic-gate    do
28307c478bd9Sstevel@tonic-gate	# Display menu and get value in range.
28317c478bd9Sstevel@tonic-gate	display_msg summary_menu
2832dd1104fbSMichen Chang	get_menu_choice "${_MENU_PROMPT}" "0" "20" "0"
28337c478bd9Sstevel@tonic-gate	_CH=$MN_CH
28347c478bd9Sstevel@tonic-gate
28357c478bd9Sstevel@tonic-gate	# Make sure where not exiting.
28367c478bd9Sstevel@tonic-gate	if [ $_CH -eq 0 ]; then
28377c478bd9Sstevel@tonic-gate	    break       # Break out of loop if 0 selected.
28387c478bd9Sstevel@tonic-gate	fi
28397c478bd9Sstevel@tonic-gate
28407c478bd9Sstevel@tonic-gate	# Call appropriate function from function table.
28417c478bd9Sstevel@tonic-gate	set $FUNC_TBL
28427c478bd9Sstevel@tonic-gate	shift $_CH
28437c478bd9Sstevel@tonic-gate	$1          # Call the appropriate function.
28447c478bd9Sstevel@tonic-gate    done
28457c478bd9Sstevel@tonic-gate
28467c478bd9Sstevel@tonic-gate    # If cred level is still see if user wants a change?
28477c478bd9Sstevel@tonic-gate    if ${ECHO} "$LDAP_CRED_LEVEL" | ${GREP} "proxy" > /dev/null 2>&1
28487c478bd9Sstevel@tonic-gate    then
28497c478bd9Sstevel@tonic-gate	if [ "$LDAP_AUTHMETHOD" != "none" ]; then
28507c478bd9Sstevel@tonic-gate	    NEED_PROXY=1    # I assume integer test is faster?
28517c478bd9Sstevel@tonic-gate	    get_proxyagent
28527c478bd9Sstevel@tonic-gate	    get_proxy_pw
28537c478bd9Sstevel@tonic-gate	else
28547c478bd9Sstevel@tonic-gate	    ${ECHO} "WARNING: Since Authentication method is 'none'."
28557c478bd9Sstevel@tonic-gate	    ${ECHO} "         Credential level will be set to 'anonymous'."
28567c478bd9Sstevel@tonic-gate	    LDAP_CRED_LEVEL="anonymous"
28577c478bd9Sstevel@tonic-gate	fi
28587c478bd9Sstevel@tonic-gate    fi
28597c478bd9Sstevel@tonic-gate
2860dd1104fbSMichen Chang    # If shadow update is enabled, set up administrator credential
2861dd1104fbSMichen Chang    if [ "$LDAP_ENABLE_SHADOW_UPDATE" = "TRUE" ]; then
2862dd1104fbSMichen Chang	NEED_ADMIN=1
2863dd1104fbSMichen Chang	if ${ECHO} "$LDAP_CRED_LEVEL" | ${GREP} "self" > /dev/null 2>&1; then
2864dd1104fbSMichen Chang	    if ${ECHO} "$LDAP_AUTHMETHOD" | ${GREP} "GSSAPI" > /dev/null 2>&1; then
2865dd1104fbSMichen Chang		NEED_HOSTACL=1
2866dd1104fbSMichen Chang		NEED_ADMIN=0
2867dd1104fbSMichen Chang	    fi
2868dd1104fbSMichen Chang	fi
2869dd1104fbSMichen Chang        [ $DEBUG -eq 1 ] && ${ECHO} "NEED_HOSTACL = $NEED_HOSTACL"
2870dd1104fbSMichen Chang        [ $DEBUG -eq 1 ] && ${ECHO} "NEED_ADMIN   = $NEED_ADMIN"
2871dd1104fbSMichen Chang	if [ $NEED_ADMIN -eq 1 ]; then
2872dd1104fbSMichen Chang	    get_adminDN
2873dd1104fbSMichen Chang	    get_admin_pw
2874dd1104fbSMichen Chang	fi
2875dd1104fbSMichen Chang    fi
2876dd1104fbSMichen Chang
28777c478bd9Sstevel@tonic-gate    # Display FULL debugging info.
28787c478bd9Sstevel@tonic-gate    disp_full_debug
28797c478bd9Sstevel@tonic-gate
28807c478bd9Sstevel@tonic-gate    # Final confirmation message. (ARE YOU SURE!)
28817c478bd9Sstevel@tonic-gate    ${ECHO} " "
28827c478bd9Sstevel@tonic-gate    get_confirm_nodef "WARNING: About to start committing changes. (y=continue, n=EXIT)"
28837c478bd9Sstevel@tonic-gate    if [ $? -eq 0 ]; then
28847c478bd9Sstevel@tonic-gate	${ECHO} "Terminating setup without making changes at users request."
2885017e8b01Svl199446	cleanup
28867c478bd9Sstevel@tonic-gate	exit 1
28877c478bd9Sstevel@tonic-gate    fi
28887c478bd9Sstevel@tonic-gate
28897c478bd9Sstevel@tonic-gate    # Print newline
28907c478bd9Sstevel@tonic-gate    ${ECHO} " "
28917c478bd9Sstevel@tonic-gate}
28927c478bd9Sstevel@tonic-gate
28937c478bd9Sstevel@tonic-gate
28947c478bd9Sstevel@tonic-gate#
28957c478bd9Sstevel@tonic-gate# create_config_file(): Write config data to config file specified.
28967c478bd9Sstevel@tonic-gate#
28977c478bd9Sstevel@tonic-gatecreate_config_file()
28987c478bd9Sstevel@tonic-gate{
28997c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In create_config_file()"
29007c478bd9Sstevel@tonic-gate
29017c478bd9Sstevel@tonic-gate    # If output file exists, delete it.
29027c478bd9Sstevel@tonic-gate    [ -f $OUTPUT_FILE ] && rm $OUTPUT_FILE
29037c478bd9Sstevel@tonic-gate
29047c478bd9Sstevel@tonic-gate    # Create output file.
29057c478bd9Sstevel@tonic-gate    cat > $OUTPUT_FILE <<EOF
29067c478bd9Sstevel@tonic-gate#!/bin/sh
29077c478bd9Sstevel@tonic-gate# $OUTPUT_FILE - This file contains configuration information for
29087c478bd9Sstevel@tonic-gate#                Native LDAP.  Use the idsconfig tool to load it.
29097c478bd9Sstevel@tonic-gate#
29107c478bd9Sstevel@tonic-gate# WARNING: This file was generated by idsconfig, and is intended to
29117c478bd9Sstevel@tonic-gate#          be loaded by idsconfig as is.  DO NOT EDIT THIS FILE!
29127c478bd9Sstevel@tonic-gate#
29137c478bd9Sstevel@tonic-gateIDS_SERVER="$IDS_SERVER"
29147c478bd9Sstevel@tonic-gateIDS_PORT=$IDS_PORT
29157c478bd9Sstevel@tonic-gateIDS_TIMELIMIT=$IDS_TIMELIMIT
29167c478bd9Sstevel@tonic-gateIDS_SIZELIMIT=$IDS_SIZELIMIT
29177c478bd9Sstevel@tonic-gateLDAP_ROOTDN="$LDAP_ROOTDN"
29187c478bd9Sstevel@tonic-gateLDAP_ROOTPWD=$LDAP_ROOTPWD
29197c478bd9Sstevel@tonic-gateLDAP_DOMAIN="$LDAP_DOMAIN"
29207c478bd9Sstevel@tonic-gateLDAP_SUFFIX="$LDAP_SUFFIX"
29214f4e8bf0SMilan JurikGSSAPI_ENABLE=$GSSAPI_ENABLE
2922cb5caa98SdjlLDAP_KRB_REALM="$LDAP_KRB_REALM"
29237c478bd9Sstevel@tonic-gate
29247c478bd9Sstevel@tonic-gate# Internal program variables that need to be set.
29257c478bd9Sstevel@tonic-gateNEED_PROXY=$NEED_PROXY
29267c478bd9Sstevel@tonic-gateNEED_TIME=$NEED_TIME
29277c478bd9Sstevel@tonic-gateNEED_SIZE=$NEED_SIZE
29287c478bd9Sstevel@tonic-gateNEED_CRYPT=$NEED_CRYPT
2929dd1104fbSMichen ChangNEED_ADMIN=$NEED_ADMIN
2930dd1104fbSMichen ChangNEED_HOSTACL=$NEED_HOSTACL
2931dd1104fbSMichen ChangEXISTING_PROFILE=$EXISTING_PROFILE
29327c478bd9Sstevel@tonic-gate
29337c478bd9Sstevel@tonic-gate# LDAP PROFILE related defaults
29347c478bd9Sstevel@tonic-gateLDAP_PROFILE_NAME="$LDAP_PROFILE_NAME"
29357c478bd9Sstevel@tonic-gateDEL_OLD_PROFILE=1
29367c478bd9Sstevel@tonic-gateLDAP_BASEDN="$LDAP_BASEDN"
29377c478bd9Sstevel@tonic-gateLDAP_SERVER_LIST="$LDAP_SERVER_LIST"
29387c478bd9Sstevel@tonic-gateLDAP_AUTHMETHOD="$LDAP_AUTHMETHOD"
29397c478bd9Sstevel@tonic-gateLDAP_FOLLOWREF=$LDAP_FOLLOWREF
29407c478bd9Sstevel@tonic-gateLDAP_SEARCH_SCOPE="$LDAP_SEARCH_SCOPE"
29417c478bd9Sstevel@tonic-gateNEED_SRVAUTH_PAM=$NEED_SRVAUTH_PAM
29427c478bd9Sstevel@tonic-gateNEED_SRVAUTH_KEY=$NEED_SRVAUTH_KEY
29437c478bd9Sstevel@tonic-gateNEED_SRVAUTH_CMD=$NEED_SRVAUTH_CMD
29447c478bd9Sstevel@tonic-gateLDAP_SRV_AUTHMETHOD_PAM="$LDAP_SRV_AUTHMETHOD_PAM"
29457c478bd9Sstevel@tonic-gateLDAP_SRV_AUTHMETHOD_KEY="$LDAP_SRV_AUTHMETHOD_KEY"
29467c478bd9Sstevel@tonic-gateLDAP_SRV_AUTHMETHOD_CMD="$LDAP_SRV_AUTHMETHOD_CMD"
29477c478bd9Sstevel@tonic-gateLDAP_SEARCH_TIME_LIMIT=$LDAP_SEARCH_TIME_LIMIT
29487c478bd9Sstevel@tonic-gateLDAP_PREF_SRVLIST="$LDAP_PREF_SRVLIST"
29497c478bd9Sstevel@tonic-gateLDAP_PROFILE_TTL=$LDAP_PROFILE_TTL
29507c478bd9Sstevel@tonic-gateLDAP_CRED_LEVEL="$LDAP_CRED_LEVEL"
29517c478bd9Sstevel@tonic-gateLDAP_BIND_LIMIT=$LDAP_BIND_LIMIT
29527c478bd9Sstevel@tonic-gate
29537c478bd9Sstevel@tonic-gate# Proxy Agent
29547c478bd9Sstevel@tonic-gateLDAP_PROXYAGENT="$LDAP_PROXYAGENT"
29557c478bd9Sstevel@tonic-gateLDAP_PROXYAGENT_CRED=$LDAP_PROXYAGENT_CRED
29567c478bd9Sstevel@tonic-gate
2957dd1104fbSMichen Chang# enableShadowUpdate flag and Administrator credential
2958dd1104fbSMichen ChangLDAP_ENABLE_SHADOW_UPDATE=$LDAP_ENABLE_SHADOW_UPDATE
2959dd1104fbSMichen ChangLDAP_ADMINDN="$LDAP_ADMINDN"
2960dd1104fbSMichen ChangLDAP_ADMIN_CRED=$LDAP_ADMIN_CRED
2961dd1104fbSMichen Chang
29627c478bd9Sstevel@tonic-gate# Export all the variables (just in case)
29637c478bd9Sstevel@tonic-gateexport IDS_HOME IDS_PORT LDAP_ROOTDN LDAP_ROOTPWD LDAP_SERVER_LIST LDAP_BASEDN
29647c478bd9Sstevel@tonic-gateexport LDAP_DOMAIN LDAP_SUFFIX LDAP_PROXYAGENT LDAP_PROXYAGENT_CRED
29657c478bd9Sstevel@tonic-gateexport NEED_PROXY
2966dd1104fbSMichen Changexport LDAP_ENABLE_SHADOW_UPDATE LDAP_ADMINDN LDAP_ADMIN_CRED
2967dd1104fbSMichen Changexport NEED_ADMIN NEED_HOSTACL EXISTING_PROFILE
29687c478bd9Sstevel@tonic-gateexport LDAP_PROFILE_NAME LDAP_BASEDN LDAP_SERVER_LIST 
29697c478bd9Sstevel@tonic-gateexport LDAP_AUTHMETHOD LDAP_FOLLOWREF LDAP_SEARCH_SCOPE LDAP_SEARCH_TIME_LIMIT
29707c478bd9Sstevel@tonic-gateexport LDAP_PREF_SRVLIST LDAP_PROFILE_TTL LDAP_CRED_LEVEL LDAP_BIND_LIMIT
29717c478bd9Sstevel@tonic-gateexport NEED_SRVAUTH_PAM NEED_SRVAUTH_KEY NEED_SRVAUTH_CMD
29727c478bd9Sstevel@tonic-gateexport LDAP_SRV_AUTHMETHOD_PAM LDAP_SRV_AUTHMETHOD_KEY LDAP_SRV_AUTHMETHOD_CMD
29734f4e8bf0SMilan Jurikexport LDAP_SERV_SRCH_DES SSD_FILE GSSAPI_ENABLE LDAP_KRB_REALM
29747c478bd9Sstevel@tonic-gate
29757c478bd9Sstevel@tonic-gate# Service Search Descriptors start here if present:
29767c478bd9Sstevel@tonic-gateEOF
29777c478bd9Sstevel@tonic-gate    # Add service search descriptors.
29787c478bd9Sstevel@tonic-gate    ssd_2_config "${OUTPUT_FILE}"
29797c478bd9Sstevel@tonic-gate
2980017e8b01Svl199446    # Add LDAP suffix preferences
2981017e8b01Svl199446    print_suffix_config >> "${OUTPUT_FILE}"
2982017e8b01Svl199446
29837c478bd9Sstevel@tonic-gate    # Add the end of FILE tag.
29847c478bd9Sstevel@tonic-gate    ${ECHO} "" >> ${OUTPUT_FILE}
29857c478bd9Sstevel@tonic-gate    ${ECHO} "# End of $OUTPUT_FILE" >> ${OUTPUT_FILE}
29867c478bd9Sstevel@tonic-gate}
29877c478bd9Sstevel@tonic-gate
29887c478bd9Sstevel@tonic-gate
29897c478bd9Sstevel@tonic-gate#
29907c478bd9Sstevel@tonic-gate# chk_vlv_indexes(): Do ldapsearch to see if server supports VLV.
29917c478bd9Sstevel@tonic-gate#
29927c478bd9Sstevel@tonic-gatechk_vlv_indexes()
29937c478bd9Sstevel@tonic-gate{
29947c478bd9Sstevel@tonic-gate    # Do ldapsearch to see if server supports VLV.
29957c478bd9Sstevel@tonic-gate    ${LDAPSEARCH} ${SERVER_ARGS} -b "" -s base "objectclass=*" > ${TMPDIR}/checkVLV 2>&1
29967c478bd9Sstevel@tonic-gate    eval "${GREP} 2.16.840.1.113730.3.4.9 ${TMPDIR}/checkVLV ${VERB}"
29977c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
29987c478bd9Sstevel@tonic-gate	${ECHO} "ERROR: VLV is not supported on LDAP server!"
29997c478bd9Sstevel@tonic-gate	cleanup
30007c478bd9Sstevel@tonic-gate	exit 1
30017c478bd9Sstevel@tonic-gate    fi
30027c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  VLV controls found on LDAP server."
30037c478bd9Sstevel@tonic-gate}
30047c478bd9Sstevel@tonic-gate
30057c478bd9Sstevel@tonic-gate#
30067c478bd9Sstevel@tonic-gate# get_backend(): this function gets the relevant backend
30077c478bd9Sstevel@tonic-gate#                (database) for LDAP_BASED.
30087c478bd9Sstevel@tonic-gate#                Description: set IDS_DATABASE; exit on failure.
30097c478bd9Sstevel@tonic-gate#                Prerequisite: LDAP_BASEDN and LDAP_SUFFIX are
30107c478bd9Sstevel@tonic-gate#                valid.
30117c478bd9Sstevel@tonic-gate#
30127c478bd9Sstevel@tonic-gate#                backend is retrieved from suffixes and subsuffixes
30137c478bd9Sstevel@tonic-gate#                defined under "cn=mapping tree,cn=config". The
30147c478bd9Sstevel@tonic-gate#                nsslapd-state attribute of these suffixes entries
30157c478bd9Sstevel@tonic-gate#                is filled with either Backend, Disabled or referrals
30167c478bd9Sstevel@tonic-gate#                related values. We only want those that have a true
30177c478bd9Sstevel@tonic-gate#                backend database to select the relevant backend.
30187c478bd9Sstevel@tonic-gate#
30197c478bd9Sstevel@tonic-gateget_backend()
30207c478bd9Sstevel@tonic-gate{
30217c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In get_backend()"
30227c478bd9Sstevel@tonic-gate
30237c478bd9Sstevel@tonic-gate    cur_suffix=${LDAP_BASEDN}
30247c478bd9Sstevel@tonic-gate    prev_suffix=
30257c478bd9Sstevel@tonic-gate    IDS_DATABASE=
30267c478bd9Sstevel@tonic-gate    while [ "${cur_suffix}" != "${prev_suffix}" ]
30277c478bd9Sstevel@tonic-gate    do
30287c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "testing LDAP suffix: ${cur_suffix}"
30297c478bd9Sstevel@tonic-gate	eval "${LDAPSEARCH} ${LDAP_ARGS} " \
30307c478bd9Sstevel@tonic-gate		"-b \"cn=\\\"${cur_suffix}\\\",cn=mapping tree,cn=config\" " \
30317c478bd9Sstevel@tonic-gate		"-s base nsslapd-state=Backend nsslapd-backend 2>&1 " \
30327c478bd9Sstevel@tonic-gate		"| ${GREP} 'nsslapd-backend=' " \
30337c478bd9Sstevel@tonic-gate		"> ${TMPDIR}/ids_database_name 2>&1"
30347c478bd9Sstevel@tonic-gate	NUM_DBS=`wc -l ${TMPDIR}/ids_database_name | awk '{print $1}'`
30357c478bd9Sstevel@tonic-gate	case ${NUM_DBS} in
30367c478bd9Sstevel@tonic-gate	0) # not a suffix, or suffix not activated; try next
30377c478bd9Sstevel@tonic-gate	    prev_suffix=${cur_suffix}
30387c478bd9Sstevel@tonic-gate	    cur_suffix=`${ECHO} ${cur_suffix} | cut -f2- -d','`
30397c478bd9Sstevel@tonic-gate	    ;;
30407c478bd9Sstevel@tonic-gate	1) # suffix found; get database name
30417c478bd9Sstevel@tonic-gate	    IDS_DATABASE=`cat ${TMPDIR}/ids_database_name | cut -d= -f2`
30427c478bd9Sstevel@tonic-gate	    ;;
30437c478bd9Sstevel@tonic-gate	*) # can not handle more than one database per suffix
30447c478bd9Sstevel@tonic-gate	    ${ECHO} "ERROR: More than one database is configured "
30457c478bd9Sstevel@tonic-gate	    ${ECHO} "       for $LDAP_SUFFIX!"
30467c478bd9Sstevel@tonic-gate	    ${ECHO} "       $PROG can not configure suffixes where "
30477c478bd9Sstevel@tonic-gate	    ${ECHO} "       more than one database is used for one suffix."
30487c478bd9Sstevel@tonic-gate	    cleanup
30497c478bd9Sstevel@tonic-gate	    exit 1
30507c478bd9Sstevel@tonic-gate	    ;;
30517c478bd9Sstevel@tonic-gate	esac
30527c478bd9Sstevel@tonic-gate	if [ -n "${IDS_DATABASE}" ]; then
30537c478bd9Sstevel@tonic-gate	    break
30547c478bd9Sstevel@tonic-gate	fi
30557c478bd9Sstevel@tonic-gate    done
30567c478bd9Sstevel@tonic-gate
30577c478bd9Sstevel@tonic-gate    if [ -z "${IDS_DATABASE}" ]; then
30587c478bd9Sstevel@tonic-gate	# should not happen, since LDAP_BASEDN is supposed to be valid
30597c478bd9Sstevel@tonic-gate	${ECHO} "Could not find a valid backend for ${LDAP_BASEDN}."
30607c478bd9Sstevel@tonic-gate	${ECHO} "Exiting."
30617c478bd9Sstevel@tonic-gate	cleanup
30627c478bd9Sstevel@tonic-gate	exit 1
30637c478bd9Sstevel@tonic-gate    fi
30647c478bd9Sstevel@tonic-gate
30657c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "IDS_DATABASE: ${IDS_DATABASE}"
30667c478bd9Sstevel@tonic-gate}
30677c478bd9Sstevel@tonic-gate
30687c478bd9Sstevel@tonic-gate#
30697c478bd9Sstevel@tonic-gate# validate_suffix(): This function validates ${LDAP_SUFFIX}
30707c478bd9Sstevel@tonic-gate#                  THIS FUNCTION IS FOR THE LOAD CONFIG FILE OPTION.
30717c478bd9Sstevel@tonic-gate#
30727c478bd9Sstevel@tonic-gatevalidate_suffix()
30737c478bd9Sstevel@tonic-gate{
30747c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In validate_suffix()"
30757c478bd9Sstevel@tonic-gate
30767c478bd9Sstevel@tonic-gate    # Check LDAP_SUFFIX is not null
30777c478bd9Sstevel@tonic-gate    if [ -z "${LDAP_SUFFIX}" ]; then
30787c478bd9Sstevel@tonic-gate	${ECHO} "Invalid suffix (null suffix)"
30797c478bd9Sstevel@tonic-gate	cleanup
30807c478bd9Sstevel@tonic-gate	exit 1
30817c478bd9Sstevel@tonic-gate    fi
30827c478bd9Sstevel@tonic-gate
30837c478bd9Sstevel@tonic-gate    # Check LDAP_SUFFIX and LDAP_BASEDN are consistent
30847c478bd9Sstevel@tonic-gate    # Convert to lower case for basename.
30857c478bd9Sstevel@tonic-gate    format_string "${LDAP_BASEDN}"
30867c478bd9Sstevel@tonic-gate    LOWER_BASEDN="${FMT_STR}"
30877c478bd9Sstevel@tonic-gate    format_string "${LDAP_SUFFIX}"
30887c478bd9Sstevel@tonic-gate    LOWER_SUFFIX="${FMT_STR}"
30897c478bd9Sstevel@tonic-gate
30907c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "LOWER_BASEDN: ${LOWER_BASEDN}"
30917c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "LOWER_SUFFIX: ${LOWER_SUFFIX}"
30927c478bd9Sstevel@tonic-gate
30937c478bd9Sstevel@tonic-gate    if [ "${LOWER_BASEDN}" != "${LOWER_SUFFIX}" ]; then
30947c478bd9Sstevel@tonic-gate    	sub_basedn=`basename "${LOWER_BASEDN}" "${LOWER_SUFFIX}"`
30957c478bd9Sstevel@tonic-gate    	if [ "$sub_basedn" = "${LOWER_BASEDN}" ]; then
30967c478bd9Sstevel@tonic-gate	    ${ECHO} "Invalid suffix ${LOWER_SUFFIX}"
30977c478bd9Sstevel@tonic-gate	    ${ECHO} "for Base DN ${LOWER_BASEDN}"
30987c478bd9Sstevel@tonic-gate	    cleanup
30997c478bd9Sstevel@tonic-gate	    exit 1
31007c478bd9Sstevel@tonic-gate	fi
31017c478bd9Sstevel@tonic-gate    fi
3102017e8b01Svl199446
3103017e8b01Svl199446    # Check LDAP_SUFFIX does exist
3104017e8b01Svl199446    ${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_SUFFIX}\" -s base \"objectclass=*\" > ${TMPDIR}/checkSuffix 2>&1" && return 0
3105017e8b01Svl199446
3106017e8b01Svl199446    # Well, suffix does not exist, try to prepare create it ...
3107017e8b01Svl199446    NEED_CREATE_SUFFIX=1
3108017e8b01Svl199446    prep_create_sfx_entry ||
3109017e8b01Svl199446    {
3110017e8b01Svl199446	cleanup
3111017e8b01Svl199446	exit 1
3112017e8b01Svl199446    }
3113017e8b01Svl199446    [ -n "${NEED_CREATE_BACKEND}" ] &&
3114017e8b01Svl199446    {
3115017e8b01Svl199446	# try to use id attr value of the suffix as a database name
3116017e8b01Svl199446	IDS_DATABASE=${_VAL}
3117017e8b01Svl199446	prep_create_sfx_backend
3118017e8b01Svl199446	case $? in
3119017e8b01Svl199446	1)	# cann't use the name we want, so we can either exit or use
3120017e8b01Svl199446		# some another available name - doing the last ...
3121017e8b01Svl199446		IDS_DATABASE=${IDS_DATABASE_AVAIL}
3122017e8b01Svl199446		;;
3123017e8b01Svl199446	2)	# unable to determine database name
3124017e8b01Svl199446		cleanup
3125017e8b01Svl199446		exit 1
3126017e8b01Svl199446		;;
3127017e8b01Svl199446	esac
3128017e8b01Svl199446    }
3129017e8b01Svl199446
3130017e8b01Svl199446    [ $DEBUG -eq 1 ] && ${ECHO} "Suffix $LDAP_SUFFIX, Database $IDS_DATABASE"
31317c478bd9Sstevel@tonic-gate}
31327c478bd9Sstevel@tonic-gate
31337c478bd9Sstevel@tonic-gate#
31347c478bd9Sstevel@tonic-gate# validate_info(): This function validates the basic info collected
31357c478bd9Sstevel@tonic-gate#                  So that some problems are caught right away.
31367c478bd9Sstevel@tonic-gate#                  THIS FUNCTION IS FOR THE LOAD CONFIG FILE OPTION.
31377c478bd9Sstevel@tonic-gate#
31387c478bd9Sstevel@tonic-gatevalidate_info()
31397c478bd9Sstevel@tonic-gate{
31407c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In validate_info()"
31417c478bd9Sstevel@tonic-gate
31427c478bd9Sstevel@tonic-gate    # Set SERVER_ARGS, AUTH_ARGS, and LDAP_ARGS for the config file.
31437c478bd9Sstevel@tonic-gate    SERVER_ARGS="-h ${IDS_SERVER} -p ${IDS_PORT}"
31447c478bd9Sstevel@tonic-gate    AUTH_ARGS="-D \"${LDAP_ROOTDN}\" -j ${LDAP_ROOTPWF}"
31457c478bd9Sstevel@tonic-gate    LDAP_ARGS="${SERVER_ARGS} ${AUTH_ARGS}"
31467c478bd9Sstevel@tonic-gate    export SERVER_ARGS
31477c478bd9Sstevel@tonic-gate
31487c478bd9Sstevel@tonic-gate    # Check the Root DN and Root DN passwd.
31497c478bd9Sstevel@tonic-gate    # Use eval instead of $EVAL because not part of setup. (validate)
31507c478bd9Sstevel@tonic-gate    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"\" -s base \"objectclass=*\" > ${TMPDIR}/checkDN 2>&1"
31517c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
31527c478bd9Sstevel@tonic-gate	eval "${GREP} credential ${TMPDIR}/checkDN ${VERB}"
31537c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
31547c478bd9Sstevel@tonic-gate	    ${ECHO} "ERROR: Root DN passwd is invalid."
31557c478bd9Sstevel@tonic-gate	else
31567c478bd9Sstevel@tonic-gate	    ${ECHO} "ERROR2: Invalid Root DN <${LDAP_ROOTDN}>."
31577c478bd9Sstevel@tonic-gate	fi
31587c478bd9Sstevel@tonic-gate	cleanup
31597c478bd9Sstevel@tonic-gate	exit 1
31607c478bd9Sstevel@tonic-gate    fi
31617c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  RootDN ... OK"
31627c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  RootDN passwd ... OK"
31637c478bd9Sstevel@tonic-gate
31647c478bd9Sstevel@tonic-gate    # Check if the server supports the VLV.
31657c478bd9Sstevel@tonic-gate    chk_vlv_indexes
31667c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  VLV indexes ... OK"
31677c478bd9Sstevel@tonic-gate
31687c478bd9Sstevel@tonic-gate    # Check LDAP suffix
31697c478bd9Sstevel@tonic-gate    validate_suffix
31707c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP suffix ... OK"
31717c478bd9Sstevel@tonic-gate}
31727c478bd9Sstevel@tonic-gate
31737c478bd9Sstevel@tonic-gate#
31747c478bd9Sstevel@tonic-gate# format_string(): take a string as argument and set FMT_STR
31757c478bd9Sstevel@tonic-gate# to be the same string formatted as follow:
31767c478bd9Sstevel@tonic-gate# - only lower case characters
31777c478bd9Sstevel@tonic-gate# - no unnecessary spaces around , and =
31787c478bd9Sstevel@tonic-gate#
31797c478bd9Sstevel@tonic-gateformat_string()
31807c478bd9Sstevel@tonic-gate{
31817c478bd9Sstevel@tonic-gate    FMT_STR=`${ECHO} "$1" | tr '[A-Z]' '[a-z]' |
31827c478bd9Sstevel@tonic-gate	sed -e 's/[ ]*,[ ]*/,/g' -e 's/[ ]*=[ ]*/=/g'`
31837c478bd9Sstevel@tonic-gate}
31847c478bd9Sstevel@tonic-gate
31857c478bd9Sstevel@tonic-gate#
3186017e8b01Svl199446# prepare for the suffix entry creation
3187017e8b01Svl199446#
3188017e8b01Svl199446# input  : LDAP_BASEDN, LDAP_SUFFIX - base dn and suffix;
3189017e8b01Svl199446# in/out : LDAP_SUFFIX_OBJ, LDAP_SUFFIX_ACI - initially may come from config.
3190017e8b01Svl199446# output : NEED_CREATE_BACKEND - backend for this suffix needs to be created;
3191017e8b01Svl199446#          _RDN, _ATT, _VAL - suffix's RDN, id attribute name and its value.
3192017e8b01Svl199446# return : 0 - success, otherwise error.
3193017e8b01Svl199446#
3194017e8b01Svl199446prep_create_sfx_entry()
3195017e8b01Svl199446{
3196017e8b01Svl199446    [ $DEBUG -eq 1 ] && ${ECHO} "In prep_create_sfx_entry()"
3197017e8b01Svl199446
3198017e8b01Svl199446    # check whether suffix corresponds to base dn
3199017e8b01Svl199446    format_string "${LDAP_BASEDN}"
3200017e8b01Svl199446    ${ECHO} ",${FMT_STR}" | ${GREP} ",${LDAP_SUFFIX}$" >/dev/null 2>&1 ||
3201017e8b01Svl199446    {
3202017e8b01Svl199446	display_msg sfx_not_suitable
3203017e8b01Svl199446	return 1
3204017e8b01Svl199446    }
3205017e8b01Svl199446
3206017e8b01Svl199446    # parse LDAP_SUFFIX
3207017e8b01Svl199446    _RDN=`${ECHO} "${LDAP_SUFFIX}" | cut -d, -f1`
3208017e8b01Svl199446    _ATT=`${ECHO} "${_RDN}" | cut -d= -f1`
3209017e8b01Svl199446    _VAL=`${ECHO} "${_RDN}" | cut -d= -f2-`
3210017e8b01Svl199446
3211017e8b01Svl199446    # find out an objectclass for suffix entry if it is not defined yet
3212017e8b01Svl199446    [ -z "${LDAP_SUFFIX_OBJ}" ] &&
3213017e8b01Svl199446    {
3214017e8b01Svl199446	get_objectclass ${_ATT}
3215017e8b01Svl199446	[ -z "${_ATTR_NAME}" ] &&
3216017e8b01Svl199446	{
3217017e8b01Svl199446		display_msg obj_not_found
3218017e8b01Svl199446		return 1
3219017e8b01Svl199446	}
3220017e8b01Svl199446	LDAP_SUFFIX_OBJ=${_ATTR_NAME}
3221017e8b01Svl199446    }
3222017e8b01Svl199446    [ $DEBUG -eq 1 ] && ${ECHO} "Suffix entry object is ${LDAP_SUFFIX_OBJ}"
3223017e8b01Svl199446
3224017e8b01Svl199446    # find out an aci for suffix entry if it is not defined yet
3225017e8b01Svl199446    [ -z "${LDAP_SUFFIX_ACI}" ] &&
3226017e8b01Svl199446    {
3227017e8b01Svl199446	# set Directory Server default aci
3228017e8b01Svl199446	LDAP_SUFFIX_ACI=`cat <<EOF
3229017e8b01Svl199446aci: (targetattr != "userPassword || passwordHistory || passwordExpirationTime
3230017e8b01Svl199446 || passwordExpWarned || passwordRetryCount || retryCountResetTime ||
3231017e8b01Svl199446 accountUnlockTime || passwordAllowChangeTime")
3232017e8b01Svl199446 (
3233017e8b01Svl199446   version 3.0;
3234017e8b01Svl199446   acl "Anonymous access";
3235017e8b01Svl199446   allow (read, search, compare) userdn = "ldap:///anyone";
3236017e8b01Svl199446 )
3237017e8b01Svl199446aci: (targetattr != "nsroledn || aci || nsLookThroughLimit || nsSizeLimit ||
3238017e8b01Svl199446 nsTimeLimit || nsIdleTimeout || passwordPolicySubentry ||
3239017e8b01Svl199446 passwordExpirationTime || passwordExpWarned || passwordRetryCount ||
3240017e8b01Svl199446 retryCountResetTime || accountUnlockTime || passwordHistory ||
3241017e8b01Svl199446 passwordAllowChangeTime")
3242017e8b01Svl199446 (
3243017e8b01Svl199446   version 3.0;
3244017e8b01Svl199446   acl "Allow self entry modification except for some attributes";
3245017e8b01Svl199446   allow (write) userdn = "ldap:///self";
3246017e8b01Svl199446 )
3247017e8b01Svl199446aci: (targetattr = "*")
3248017e8b01Svl199446 (
3249017e8b01Svl199446   version 3.0;
3250017e8b01Svl199446   acl "Configuration Administrator";
3251017e8b01Svl199446   allow (all) userdn = "ldap:///uid=admin,ou=Administrators,
3252017e8b01Svl199446                         ou=TopologyManagement,o=NetscapeRoot";
3253017e8b01Svl199446 )
3254017e8b01Svl199446aci: (targetattr ="*")
3255017e8b01Svl199446 (
3256017e8b01Svl199446   version 3.0;
3257017e8b01Svl199446   acl "Configuration Administrators Group";
3258017e8b01Svl199446   allow (all) groupdn = "ldap:///cn=Configuration Administrators,
3259017e8b01Svl199446                          ou=Groups,ou=TopologyManagement,o=NetscapeRoot";
3260017e8b01Svl199446 )
3261017e8b01Svl199446EOF
3262017e8b01Svl199446`
3263017e8b01Svl199446    }
3264017e8b01Svl199446    [ $DEBUG -eq 1 ] && cat <<EOF
3265017e8b01Svl199446DEBUG: ACI for ${LDAP_SUFFIX} is
3266017e8b01Svl199446${LDAP_SUFFIX_ACI}
3267017e8b01Svl199446EOF
3268017e8b01Svl199446
3269017e8b01Svl199446    NEED_CREATE_BACKEND=
3270017e8b01Svl199446
3271017e8b01Svl199446    # check the suffix mapping tree ...
3272017e8b01Svl199446    # if mapping exists, suffix should work, otherwise DS inconsistent
3273017e8b01Svl199446    # NOTE: -b 'cn=mapping tree,cn=config' -s one 'cn=\"$1\"' won't work
3274017e8b01Svl199446    #       in case of 'cn' value in LDAP is not quoted by '"',
3275017e8b01Svl199446    #       -b 'cn=\"$1\",cn=mapping tree,cn=config' works in all cases
3276017e8b01Svl199446    ${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} \
3277017e8b01Svl199446	-b 'cn=\"${LDAP_SUFFIX}\",cn=mapping tree,cn=config' \
3278017e8b01Svl199446	-s base 'objectclass=*' dn ${VERB}" &&
3279017e8b01Svl199446    {
3280017e8b01Svl199446	[ $DEBUG -eq 1 ] && ${ECHO} "Suffix mapping already exists"
3281017e8b01Svl199446	# get_backend() either gets IDS_DATABASE or exits
3282017e8b01Svl199446	get_backend
3283017e8b01Svl199446	return 0
3284017e8b01Svl199446    }
3285017e8b01Svl199446
3286017e8b01Svl199446    # no suffix mapping, just in case check ldbm backends consistency -
3287017e8b01Svl199446    # there are must be NO any databases pointing to LDAP_SUFFIX
3288017e8b01Svl199446    [ -n "`${EVAL} \"${LDAPSEARCH} ${LDAP_ARGS} \
3289017e8b01Svl199446	-b 'cn=ldbm database,cn=plugins,cn=config' \
3290017e8b01Svl199446	-s one 'nsslapd-suffix=${LDAP_SUFFIX}' dn\" 2>/dev/null`" ] &&
3291017e8b01Svl199446    {
3292017e8b01Svl199446	display_msg sfx_config_incons
3293017e8b01Svl199446	return 1
3294017e8b01Svl199446    }
3295017e8b01Svl199446
3296017e8b01Svl199446    # ok, no suffix mapping, no ldbm database
3297017e8b01Svl199446    [ $DEBUG -eq 1 ] && ${ECHO} "DEBUG: backend needs to be created ..."
3298017e8b01Svl199446    NEED_CREATE_BACKEND=1
3299017e8b01Svl199446    return 0
3300017e8b01Svl199446}
3301017e8b01Svl199446
3302017e8b01Svl199446#
3303017e8b01Svl199446# prepare for the suffix backend creation
3304017e8b01Svl199446#
3305017e8b01Svl199446# input  : IDS_DATABASE - requested ldbm db name (must be not null)
3306017e8b01Svl199446# in/out : IDS_DATABASE_AVAIL - available ldbm db name
3307017e8b01Svl199446# return : 0 - ldbm db name ok
3308017e8b01Svl199446#          1 - IDS_DATABASE exists,
3309017e8b01Svl199446#              so IDS_DATABASE_AVAIL contains available name
3310017e8b01Svl199446#          2 - unable to find any available name
3311017e8b01Svl199446#
3312017e8b01Svl199446prep_create_sfx_backend()
3313017e8b01Svl199446{
3314017e8b01Svl199446    [ $DEBUG -eq 1 ] && ${ECHO} "In prep_create_sfx_backend()"
3315017e8b01Svl199446
3316017e8b01Svl199446    # check if requested name available
3317017e8b01Svl199446    [ "${IDS_DATABASE}" = "${IDS_DATABASE_AVAIL}" ] && return 0
3318017e8b01Svl199446
3319017e8b01Svl199446    # get the list of database names start with a requested name
3320017e8b01Svl199446    _LDBM_DBS=`${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} \
3321017e8b01Svl199446	-b 'cn=ldbm database,cn=plugins,cn=config' \
3322017e8b01Svl199446	-s one 'cn=${IDS_DATABASE}*' cn"` 2>/dev/null
3323017e8b01Svl199446
3324017e8b01Svl199446    # find available db name based on a requested name
3325017e8b01Svl199446    _i=""; _i_MAX=10
3326017e8b01Svl199446    while [ ${_i:-0} -lt ${_i_MAX} ]
3327017e8b01Svl199446    do
3328017e8b01Svl199446	_name="${IDS_DATABASE}${_i}"
3329017e8b01Svl199446	${ECHO} "${_LDBM_DBS}" | ${GREP} -i "^cn=${_name}$" >/dev/null 2>&1 ||
3330017e8b01Svl199446	{
3331017e8b01Svl199446		IDS_DATABASE_AVAIL="${_name}"
3332017e8b01Svl199446		break
3333017e8b01Svl199446	}
3334017e8b01Svl199446	_i=`expr ${_i:-0} + 1`
3335017e8b01Svl199446    done
3336017e8b01Svl199446
3337017e8b01Svl199446    [ "${IDS_DATABASE}" = "${IDS_DATABASE_AVAIL}" ] && return 0
3338017e8b01Svl199446
3339017e8b01Svl199446    [ -n "${IDS_DATABASE_AVAIL}" ] &&
3340017e8b01Svl199446    {
3341017e8b01Svl199446	display_msg ldbm_db_exist
3342017e8b01Svl199446	return 1
3343017e8b01Svl199446    }
3344017e8b01Svl199446
3345017e8b01Svl199446    display_msg unable_find_db_name
3346017e8b01Svl199446    return 2
3347017e8b01Svl199446}
3348017e8b01Svl199446
3349017e8b01Svl199446#
3350017e8b01Svl199446# add suffix if needed,
3351017e8b01Svl199446#     suffix entry and backend MUST be prepared by
3352017e8b01Svl199446#     prep_create_sfx_entry and prep_create_sfx_backend correspondingly
3353017e8b01Svl199446#
3354017e8b01Svl199446# input  : NEED_CREATE_SUFFIX, LDAP_SUFFIX, LDAP_SUFFIX_OBJ, _ATT, _VAL
3355017e8b01Svl199446#          LDAP_SUFFIX_ACI, NEED_CREATE_BACKEND, IDS_DATABASE
3356017e8b01Svl199446# return : 0 - suffix successfully created, otherwise error occured
3357017e8b01Svl199446#
3358017e8b01Svl199446add_suffix()
3359017e8b01Svl199446{
3360017e8b01Svl199446    [ $DEBUG -eq 1 ] && ${ECHO} "In add_suffix()"
3361017e8b01Svl199446
3362017e8b01Svl199446    [ -n "${NEED_CREATE_SUFFIX}" ] || return 0
3363017e8b01Svl199446
3364017e8b01Svl199446    [ -n "${NEED_CREATE_BACKEND}" ] &&
3365017e8b01Svl199446    {
3366017e8b01Svl199446	${EVAL} "${LDAPADD} ${LDAP_ARGS} ${VERB}" <<EOF
3367017e8b01Svl199446dn: cn="${LDAP_SUFFIX}",cn=mapping tree,cn=config
3368017e8b01Svl199446objectclass: top
3369017e8b01Svl199446objectclass: extensibleObject
3370017e8b01Svl199446objectclass: nsMappingTree
3371017e8b01Svl199446cn: ${LDAP_SUFFIX}
3372017e8b01Svl199446nsslapd-state: backend
3373017e8b01Svl199446nsslapd-backend: ${IDS_DATABASE}
3374017e8b01Svl199446
3375017e8b01Svl199446dn: cn=${IDS_DATABASE},cn=ldbm database,cn=plugins,cn=config
3376017e8b01Svl199446objectclass: top
3377017e8b01Svl199446objectclass: extensibleObject
3378017e8b01Svl199446objectclass: nsBackendInstance
3379017e8b01Svl199446cn: ${IDS_DATABASE}
3380017e8b01Svl199446nsslapd-suffix: ${LDAP_SUFFIX}
3381017e8b01Svl199446EOF
3382017e8b01Svl199446	[ $? -ne 0 ] &&
3383017e8b01Svl199446	{
3384017e8b01Svl199446		display_msg create_ldbm_db_error
3385017e8b01Svl199446		return 1
3386017e8b01Svl199446	}
3387017e8b01Svl199446
3388017e8b01Svl199446	${ECHO} "  ${STEP}. Database ${IDS_DATABASE} successfully created"
3389017e8b01Svl199446	STEP=`expr $STEP + 1`
3390017e8b01Svl199446    }
3391017e8b01Svl199446
3392017e8b01Svl199446    ${EVAL} "${LDAPADD} ${LDAP_ARGS} ${VERB}" <<EOF
3393017e8b01Svl199446dn: ${LDAP_SUFFIX}
3394017e8b01Svl199446objectclass: ${LDAP_SUFFIX_OBJ}
3395017e8b01Svl199446${_ATT}: ${_VAL}
3396017e8b01Svl199446${LDAP_SUFFIX_ACI}
3397017e8b01Svl199446EOF
3398017e8b01Svl199446    [ $? -ne 0 ] &&
3399017e8b01Svl199446    {
3400017e8b01Svl199446	display_msg create_suffix_entry_error
3401017e8b01Svl199446	return 1
3402017e8b01Svl199446    }
3403017e8b01Svl199446
3404017e8b01Svl199446    ${ECHO} "  ${STEP}. Suffix ${LDAP_SUFFIX} successfully created"
3405017e8b01Svl199446    STEP=`expr $STEP + 1`
3406017e8b01Svl199446    return 0
3407017e8b01Svl199446}
3408017e8b01Svl199446
3409017e8b01Svl199446#
3410017e8b01Svl199446# interactively get suffix and related info from a user
3411017e8b01Svl199446#
3412017e8b01Svl199446# input  : LDAP_BASEDN - Base DN
3413017e8b01Svl199446# output : LDAP_SUFFIX - Suffix, _ATT, _VAL - id attribute and its value;
3414017e8b01Svl199446#          LDAP_SUFFIX_OBJ, LDAP_SUFFIX_ACI - objectclass and aci;
3415017e8b01Svl199446#          NEED_CREATE_BACKEND - tells whether backend needs to be created;
3416017e8b01Svl199446#          IDS_DATABASE - prepared ldbm db name
3417017e8b01Svl199446# return : 0 - user gave a correct suffix
3418017e8b01Svl199446#          1 - suffix given by user cann't be created
3419017e8b01Svl199446#
3420017e8b01Svl199446get_suffix()
3421017e8b01Svl199446{
3422017e8b01Svl199446    [ $DEBUG -eq 1 ] && ${ECHO} "In get_suffix()"
3423017e8b01Svl199446
3424017e8b01Svl199446    while :
3425017e8b01Svl199446    do
3426017e8b01Svl199446	get_ans "Enter suffix to be created (b=back/h=help):" ${LDAP_BASEDN}
3427017e8b01Svl199446	case "${ANS}" in
3428017e8b01Svl199446	[Hh] | Help | help | \? ) display_msg create_suffix_help ;;
3429017e8b01Svl199446	[Bb] | Back | back | \< ) return 1 ;;
3430017e8b01Svl199446	* )
3431017e8b01Svl199446		format_string "${ANS}"
3432017e8b01Svl199446		LDAP_SUFFIX=${FMT_STR}
3433017e8b01Svl199446		prep_create_sfx_entry || continue
3434017e8b01Svl199446
3435017e8b01Svl199446		[ -n "${NEED_CREATE_BACKEND}" ] &&
3436017e8b01Svl199446		{
3437017e8b01Svl199446		    IDS_DATABASE_AVAIL= # reset the available db name
3438017e8b01Svl199446
3439017e8b01Svl199446		    reenter_suffix=
3440017e8b01Svl199446		    while :
3441017e8b01Svl199446		    do
3442017e8b01Svl199446			get_ans "Enter ldbm database name (b=back/h=help):" \
3443017e8b01Svl199446				${IDS_DATABASE_AVAIL:-${_VAL}}
3444017e8b01Svl199446			case "${ANS}" in
3445017e8b01Svl199446			[Hh] | \? ) display_msg enter_ldbm_db_help ;;
3446017e8b01Svl199446			[Bb] | \< ) reenter_suffix=1; break ;;
3447017e8b01Svl199446			* )
3448017e8b01Svl199446				IDS_DATABASE="${ANS}"
3449017e8b01Svl199446				prep_create_sfx_backend && break
3450017e8b01Svl199446			esac
3451017e8b01Svl199446		    done
3452017e8b01Svl199446		    [ -n "${reenter_suffix}" ] && continue
3453017e8b01Svl199446
3454017e8b01Svl199446		    [ $DEBUG -eq 1 ] && cat <<EOF
3455017e8b01Svl199446DEBUG: backend name for suffix ${LDAP_SUFFIX} will be ${IDS_DATABASE}
3456017e8b01Svl199446EOF
3457017e8b01Svl199446		}
3458017e8b01Svl199446
3459017e8b01Svl199446		# eventually everything is prepared
3460017e8b01Svl199446		return 0
3461017e8b01Svl199446		;;
3462017e8b01Svl199446	esac
3463017e8b01Svl199446    done
3464017e8b01Svl199446}
3465017e8b01Svl199446
3466017e8b01Svl199446#
3467017e8b01Svl199446# print out a script which sets LDAP suffix related preferences
3468017e8b01Svl199446#
3469017e8b01Svl199446print_suffix_config()
3470017e8b01Svl199446{
3471017e8b01Svl199446    cat <<EOF2
3472017e8b01Svl199446# LDAP suffix related preferences used only if needed
3473017e8b01Svl199446IDS_DATABASE="${IDS_DATABASE}"
3474017e8b01Svl199446LDAP_SUFFIX_OBJ="$LDAP_SUFFIX_OBJ"
3475017e8b01Svl199446LDAP_SUFFIX_ACI=\`cat <<EOF
3476017e8b01Svl199446${LDAP_SUFFIX_ACI}
3477017e8b01Svl199446EOF
3478017e8b01Svl199446\`
3479017e8b01Svl199446export IDS_DATABASE LDAP_SUFFIX_OBJ LDAP_SUFFIX_ACI
3480017e8b01Svl199446EOF2
3481017e8b01Svl199446}
3482017e8b01Svl199446
3483017e8b01Svl199446#
34847c478bd9Sstevel@tonic-gate# check_basedn_suffix(): check that there is an existing
34857c478bd9Sstevel@tonic-gate# valid suffix to hold current base DN
34867c478bd9Sstevel@tonic-gate# return:
3487017e8b01Svl199446#   0: valid suffix found or new one should be created,
3488017e8b01Svl199446#      NEED_CREATE_SUFFIX flag actually indicates that
3489017e8b01Svl199446#   1: some error occures
34907c478bd9Sstevel@tonic-gate#
34917c478bd9Sstevel@tonic-gatecheck_basedn_suffix()
34927c478bd9Sstevel@tonic-gate{
34937c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In check_basedn_suffix()"
34947c478bd9Sstevel@tonic-gate
3495017e8b01Svl199446    NEED_CREATE_SUFFIX=
3496017e8b01Svl199446
34977c478bd9Sstevel@tonic-gate    # find out existing suffixes
34987c478bd9Sstevel@tonic-gate    discover_serv_suffix
34997c478bd9Sstevel@tonic-gate
35007c478bd9Sstevel@tonic-gate    ${ECHO} "  Validating LDAP Base DN and Suffix ..."
35017c478bd9Sstevel@tonic-gate
35027c478bd9Sstevel@tonic-gate    # check that LDAP Base DN might be added
35037c478bd9Sstevel@tonic-gate    cur_ldap_entry=${LDAP_BASEDN}
35047c478bd9Sstevel@tonic-gate    prev_ldap_entry=
35057c478bd9Sstevel@tonic-gate    while [ "${cur_ldap_entry}" != "${prev_ldap_entry}" ]
35067c478bd9Sstevel@tonic-gate    do
35077c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "testing LDAP entry: ${cur_ldap_entry}"
35087c478bd9Sstevel@tonic-gate	${LDAPSEARCH} ${SERVER_ARGS} -b "${cur_ldap_entry}" \
35097c478bd9Sstevel@tonic-gate		-s one "objectclass=*" > /dev/null 2>&1
35107c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
35117c478bd9Sstevel@tonic-gate	    break
35127c478bd9Sstevel@tonic-gate	else
35137c478bd9Sstevel@tonic-gate	    prev_ldap_entry=${cur_ldap_entry}
35147c478bd9Sstevel@tonic-gate	    cur_ldap_entry=`${ECHO} ${cur_ldap_entry} | cut -f2- -d','`
35157c478bd9Sstevel@tonic-gate	fi
35167c478bd9Sstevel@tonic-gate    done
35177c478bd9Sstevel@tonic-gate
35187c478bd9Sstevel@tonic-gate    if [ "${cur_ldap_entry}" = "${prev_ldap_entry}" ]; then
3519017e8b01Svl199446	${ECHO} "  No valid suffixes were found for Base DN ${LDAP_BASEDN}"
3520017e8b01Svl199446
3521017e8b01Svl199446	NEED_CREATE_SUFFIX=1
3522017e8b01Svl199446	return 0
3523017e8b01Svl199446
35247c478bd9Sstevel@tonic-gate    else
35257c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "found valid LDAP entry: ${cur_ldap_entry}"
35267c478bd9Sstevel@tonic-gate
35277c478bd9Sstevel@tonic-gate	# Now looking for relevant suffix for this entry.
35287c478bd9Sstevel@tonic-gate	# LDAP_SUFFIX will then be used to add necessary
35297c478bd9Sstevel@tonic-gate	# base objects. See add_base_objects().
35307c478bd9Sstevel@tonic-gate	format_string "${cur_ldap_entry}"
35317c478bd9Sstevel@tonic-gate	lower_entry="${FMT_STR}"
35327c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "final suffix list: ${LDAP_SUFFIX_LIST}"
35337c478bd9Sstevel@tonic-gate	oIFS=$IFS
35347c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "setting IFS to new line"
35357c478bd9Sstevel@tonic-gate	IFS='
35367c478bd9Sstevel@tonic-gate'
35377c478bd9Sstevel@tonic-gate	for suff in ${LDAP_SUFFIX_LIST}
35387c478bd9Sstevel@tonic-gate	do
35397c478bd9Sstevel@tonic-gate	    [ $DEBUG -eq 1 ] && ${ECHO} "testing suffix: ${suff}"
35407c478bd9Sstevel@tonic-gate	    format_string "${suff}"
35417c478bd9Sstevel@tonic-gate	    lower_suff="${FMT_STR}"
35427c478bd9Sstevel@tonic-gate	    if [ "${lower_entry}" = "${lower_suff}" ]; then
35437c478bd9Sstevel@tonic-gate		LDAP_SUFFIX="${suff}"
35447c478bd9Sstevel@tonic-gate		break
35457c478bd9Sstevel@tonic-gate	    else
35467c478bd9Sstevel@tonic-gate		dcstmp=`basename "${lower_entry}" "${lower_suff}"`
35477c478bd9Sstevel@tonic-gate		if [ "${dcstmp}" = "${lower_entry}" ]; then
35487c478bd9Sstevel@tonic-gate		    # invalid suffix, try next one
35497c478bd9Sstevel@tonic-gate		    continue
35507c478bd9Sstevel@tonic-gate		else
35517c478bd9Sstevel@tonic-gate		    # valid suffix found
35527c478bd9Sstevel@tonic-gate		    LDAP_SUFFIX="${suff}"
35537c478bd9Sstevel@tonic-gate		    break
35547c478bd9Sstevel@tonic-gate		fi
35557c478bd9Sstevel@tonic-gate	    fi
35567c478bd9Sstevel@tonic-gate	done
35577c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "setting IFS to original value"
35587c478bd9Sstevel@tonic-gate	IFS=$oIFS
35597c478bd9Sstevel@tonic-gate
35607c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "LDAP_SUFFIX: ${LDAP_SUFFIX}"
35617c478bd9Sstevel@tonic-gate
35627c478bd9Sstevel@tonic-gate	if [ -z "${LDAP_SUFFIX}" ]; then
35637c478bd9Sstevel@tonic-gate	    # should not happen, since we found the entry
35647c478bd9Sstevel@tonic-gate	    ${ECHO} "Could not find a valid suffix for ${LDAP_BASEDN}."
35657c478bd9Sstevel@tonic-gate	    ${ECHO} "Exiting."
35667c478bd9Sstevel@tonic-gate	    return 1
35677c478bd9Sstevel@tonic-gate	fi
35687c478bd9Sstevel@tonic-gate
35697c478bd9Sstevel@tonic-gate	# Getting relevant database (backend)
35707c478bd9Sstevel@tonic-gate	# IDS_DATABASE will then be used to create indexes.
35717c478bd9Sstevel@tonic-gate	get_backend
35727c478bd9Sstevel@tonic-gate
35737c478bd9Sstevel@tonic-gate	return 0
35747c478bd9Sstevel@tonic-gate    fi
35757c478bd9Sstevel@tonic-gate}
35767c478bd9Sstevel@tonic-gate
35777c478bd9Sstevel@tonic-gate#
35787c478bd9Sstevel@tonic-gate# discover_serv_suffix(): This function queries the server to find
35797c478bd9Sstevel@tonic-gate#    suffixes available
35807c478bd9Sstevel@tonic-gate#  return: 0: OK, suffix found
35817c478bd9Sstevel@tonic-gate#          1: suffix not determined
35827c478bd9Sstevel@tonic-gatediscover_serv_suffix()
35837c478bd9Sstevel@tonic-gate{
35847c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In discover_serv_suffix()"
35857c478bd9Sstevel@tonic-gate
35867c478bd9Sstevel@tonic-gate    # Search the server for the TOP of the TREE.
35877c478bd9Sstevel@tonic-gate    ${LDAPSEARCH} ${SERVER_ARGS} -b "" -s base "objectclass=*" > ${TMPDIR}/checkTOP 2>&1
35887c478bd9Sstevel@tonic-gate    ${GREP} -i namingcontexts ${TMPDIR}/checkTOP | \
35897c478bd9Sstevel@tonic-gate	${GREP} -i -v NetscapeRoot > ${TMPDIR}/treeTOP
35907c478bd9Sstevel@tonic-gate    NUM_TOP=`wc -l ${TMPDIR}/treeTOP | awk '{print $1}'`
35917c478bd9Sstevel@tonic-gate    case $NUM_TOP in
35927c478bd9Sstevel@tonic-gate	0)
3593017e8b01Svl199446	    [ $DEBUG -eq 1 ] && ${ECHO} "DEBUG: No suffix found in LDAP tree"
35947c478bd9Sstevel@tonic-gate	    return 1
35957c478bd9Sstevel@tonic-gate	    ;;
35967c478bd9Sstevel@tonic-gate	*)  # build the list of suffixes; take out 'namingContexts=' in
35977c478bd9Sstevel@tonic-gate	    # each line of ${TMPDIR}/treeTOP
35987c478bd9Sstevel@tonic-gate	    LDAP_SUFFIX_LIST=`cat ${TMPDIR}/treeTOP |
35997c478bd9Sstevel@tonic-gate		awk '{ printf("%s\n",substr($0,16,length-15)) }'`
36007c478bd9Sstevel@tonic-gate	    ;;
36017c478bd9Sstevel@tonic-gate    esac
36027c478bd9Sstevel@tonic-gate
36037c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "  LDAP_SUFFIX_LIST = $LDAP_SUFFIX_LIST"
36047c478bd9Sstevel@tonic-gate    return 0
36057c478bd9Sstevel@tonic-gate}
36067c478bd9Sstevel@tonic-gate
36077c478bd9Sstevel@tonic-gate
36087c478bd9Sstevel@tonic-gate#
36097c478bd9Sstevel@tonic-gate# modify_cn(): Change the cn from MUST to MAY in ipNetwork.
36107c478bd9Sstevel@tonic-gate#
36117c478bd9Sstevel@tonic-gatemodify_cn()
36127c478bd9Sstevel@tonic-gate{
36137c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In modify_cn()"
36147c478bd9Sstevel@tonic-gate
36157c478bd9Sstevel@tonic-gate    ( cat <<EOF
36167c478bd9Sstevel@tonic-gatedn: cn=schema
36177c478bd9Sstevel@tonic-gatechangetype: modify
36187c478bd9Sstevel@tonic-gateadd: objectclasses
36191d473207SMilan Jurikobjectclasses: ( 1.3.6.1.1.1.2.7 NAME 'ipNetwork' DESC 'Standard LDAP objectclass' SUP top STRUCTURAL MUST ipNetworkNumber MAY ( ipNetmaskNumber $ manager $ cn $ l $ description ) X-ORIGIN 'RFC 2307' )
36207c478bd9Sstevel@tonic-gateEOF
36217c478bd9Sstevel@tonic-gate) > ${TMPDIR}/ipNetwork_cn
36227c478bd9Sstevel@tonic-gate
36237c478bd9Sstevel@tonic-gate    # Modify the cn for ipNetwork.
36247c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/ipNetwork_cn ${VERB}"
36257c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
36267c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: update of cn for ipNetwork failed!"
36277c478bd9Sstevel@tonic-gate	cleanup
36287c478bd9Sstevel@tonic-gate	exit 1
36297c478bd9Sstevel@tonic-gate    fi
36307c478bd9Sstevel@tonic-gate}
36317c478bd9Sstevel@tonic-gate
36327c478bd9Sstevel@tonic-gate
36337c478bd9Sstevel@tonic-gate# modify_timelimit(): Modify timelimit to user value.
36347c478bd9Sstevel@tonic-gatemodify_timelimit()
36357c478bd9Sstevel@tonic-gate{
36367c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In modify_timelimit()"
36377c478bd9Sstevel@tonic-gate
36387c478bd9Sstevel@tonic-gate    # Here doc to modify timelimit.
36397c478bd9Sstevel@tonic-gate    ( cat <<EOF
36407c478bd9Sstevel@tonic-gatedn: cn=config
36417c478bd9Sstevel@tonic-gatechangetype: modify
36427c478bd9Sstevel@tonic-gatereplace: nsslapd-timelimit
36437c478bd9Sstevel@tonic-gatensslapd-timelimit: ${IDS_TIMELIMIT}
36447c478bd9Sstevel@tonic-gateEOF
36457c478bd9Sstevel@tonic-gate) > ${TMPDIR}/ids_timelimit
36467c478bd9Sstevel@tonic-gate
36477c478bd9Sstevel@tonic-gate    # Add the entry.
36487c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/ids_timelimit ${VERB}"
36497c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
36507c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: update of nsslapd-timelimit failed!"
36517c478bd9Sstevel@tonic-gate	cleanup
36527c478bd9Sstevel@tonic-gate	exit 1
36537c478bd9Sstevel@tonic-gate    fi
36547c478bd9Sstevel@tonic-gate
36557c478bd9Sstevel@tonic-gate    # Display messages for modifications made in patch.
36567c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Changed timelimit to ${IDS_TIMELIMIT} in cn=config."
36577c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
36587c478bd9Sstevel@tonic-gate}
36597c478bd9Sstevel@tonic-gate
36607c478bd9Sstevel@tonic-gate
36617c478bd9Sstevel@tonic-gate# modify_sizelimit(): Modify sizelimit to user value.
36627c478bd9Sstevel@tonic-gatemodify_sizelimit()
36637c478bd9Sstevel@tonic-gate{
36647c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In modify_sizelimit()"
36657c478bd9Sstevel@tonic-gate
36667c478bd9Sstevel@tonic-gate    # Here doc to modify sizelimit.
36677c478bd9Sstevel@tonic-gate    ( cat <<EOF
36687c478bd9Sstevel@tonic-gatedn: cn=config
36697c478bd9Sstevel@tonic-gatechangetype: modify
36707c478bd9Sstevel@tonic-gatereplace: nsslapd-sizelimit
36717c478bd9Sstevel@tonic-gatensslapd-sizelimit: ${IDS_SIZELIMIT}
36727c478bd9Sstevel@tonic-gateEOF
36737c478bd9Sstevel@tonic-gate) > ${TMPDIR}/ids_sizelimit
36747c478bd9Sstevel@tonic-gate
36757c478bd9Sstevel@tonic-gate    # Add the entry.
36767c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/ids_sizelimit ${VERB}"
36777c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
36787c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: update of nsslapd-sizelimit failed!"
36797c478bd9Sstevel@tonic-gate	cleanup
36807c478bd9Sstevel@tonic-gate	exit 1
36817c478bd9Sstevel@tonic-gate    fi
36827c478bd9Sstevel@tonic-gate
36837c478bd9Sstevel@tonic-gate    # Display messages for modifications made in patch.
36847c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Changed sizelimit to ${IDS_SIZELIMIT} in cn=config."
36857c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
36867c478bd9Sstevel@tonic-gate}
36877c478bd9Sstevel@tonic-gate
36887c478bd9Sstevel@tonic-gate
36897c478bd9Sstevel@tonic-gate# modify_pwd_crypt(): Modify the passwd storage scheme to support CRYPT.
36907c478bd9Sstevel@tonic-gatemodify_pwd_crypt()
36917c478bd9Sstevel@tonic-gate{
36927c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In modify_pwd_crypt()"
36937c478bd9Sstevel@tonic-gate
36947c478bd9Sstevel@tonic-gate    # Here doc to modify passwordstoragescheme.
36957c478bd9Sstevel@tonic-gate    # IDS 5.2 moved passwordchangesceme off to a new data structure.
36967c478bd9Sstevel@tonic-gate    if [ $IDS_MAJVER -le 5 ] && [ $IDS_MINVER -le 1 ]; then
36977c478bd9Sstevel@tonic-gate	( cat <<EOF
36987c478bd9Sstevel@tonic-gatedn: cn=config
36997c478bd9Sstevel@tonic-gatechangetype: modify
37007c478bd9Sstevel@tonic-gatereplace: passwordstoragescheme
37017c478bd9Sstevel@tonic-gatepasswordstoragescheme: crypt
37027c478bd9Sstevel@tonic-gateEOF
37037c478bd9Sstevel@tonic-gate	) > ${TMPDIR}/ids_crypt
37047c478bd9Sstevel@tonic-gate    else
37057c478bd9Sstevel@tonic-gate	( cat <<EOF
37067c478bd9Sstevel@tonic-gatedn: cn=Password Policy,cn=config
37077c478bd9Sstevel@tonic-gatechangetype: modify
37087c478bd9Sstevel@tonic-gatereplace: passwordstoragescheme
37097c478bd9Sstevel@tonic-gatepasswordstoragescheme: crypt
37107c478bd9Sstevel@tonic-gateEOF
37117c478bd9Sstevel@tonic-gate	) > ${TMPDIR}/ids_crypt
37127c478bd9Sstevel@tonic-gate    fi
37137c478bd9Sstevel@tonic-gate
37147c478bd9Sstevel@tonic-gate    # Add the entry.
37157c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/ids_crypt ${VERB}"
37167c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
37177c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: update of passwordstoragescheme failed!"
37187c478bd9Sstevel@tonic-gate	cleanup
37197c478bd9Sstevel@tonic-gate	exit 1
37207c478bd9Sstevel@tonic-gate    fi
37217c478bd9Sstevel@tonic-gate
37227c478bd9Sstevel@tonic-gate    # Display messages for modifications made in patch.
37237c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Changed passwordstoragescheme to \"crypt\" in cn=config."
37247c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
37257c478bd9Sstevel@tonic-gate}
37267c478bd9Sstevel@tonic-gate
37277c478bd9Sstevel@tonic-gate
37287c478bd9Sstevel@tonic-gate#
37297c478bd9Sstevel@tonic-gate# add_eq_indexes(): Add indexes to improve search performance.
37307c478bd9Sstevel@tonic-gate#
37317c478bd9Sstevel@tonic-gateadd_eq_indexes()
37327c478bd9Sstevel@tonic-gate{
37337c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In add_eq_indexes()"
37347c478bd9Sstevel@tonic-gate
37357c478bd9Sstevel@tonic-gate    # Set eq indexes to add.
37367c478bd9Sstevel@tonic-gate    _INDEXES="uidNumber ipNetworkNumber gidnumber oncrpcnumber automountKey"
37377c478bd9Sstevel@tonic-gate
3738cb5caa98Sdjl    if [ -z "${IDS_DATABASE}" ]; then
3739cb5caa98Sdjl	get_backend
3740cb5caa98Sdjl    fi
3741a58015d1Svl199446
37427c478bd9Sstevel@tonic-gate    # Set _EXT to use as shortcut.
37437c478bd9Sstevel@tonic-gate    _EXT="cn=index,cn=${IDS_DATABASE},cn=ldbm database,cn=plugins,cn=config"
37447c478bd9Sstevel@tonic-gate
37457c478bd9Sstevel@tonic-gate    # Display message to id current step.
37467c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Processing eq,pres indexes:"
37477c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
37487c478bd9Sstevel@tonic-gate
37497c478bd9Sstevel@tonic-gate    # For loop to create indexes.
37507c478bd9Sstevel@tonic-gate    for i in ${_INDEXES}; do
37517c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "  Adding index for ${i}"
37527c478bd9Sstevel@tonic-gate
37537c478bd9Sstevel@tonic-gate	# Check if entry exists first, if so, skip to next.
3754a58015d1Svl199446	${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} -b \"cn=${i},${_EXT}\" -s base \
3755a58015d1Svl199446	    \"objectclass=*\" > /dev/null 2>&1"
37567c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
37577c478bd9Sstevel@tonic-gate	    # Display index skipped.
37587c478bd9Sstevel@tonic-gate	    ${ECHO} "      ${i} (eq,pres) skipped already exists"
37597c478bd9Sstevel@tonic-gate	    continue
37607c478bd9Sstevel@tonic-gate	fi
37617c478bd9Sstevel@tonic-gate
37627c478bd9Sstevel@tonic-gate	# Here doc to create LDIF.
37637c478bd9Sstevel@tonic-gate	( cat <<EOF
37647c478bd9Sstevel@tonic-gatedn: cn=${i},${_EXT}
37657c478bd9Sstevel@tonic-gateobjectClass: top
37667c478bd9Sstevel@tonic-gateobjectClass: nsIndex
37677c478bd9Sstevel@tonic-gatecn: ${i}
37687c478bd9Sstevel@tonic-gatensSystemIndex: false
37697c478bd9Sstevel@tonic-gatensIndexType: pres
37707c478bd9Sstevel@tonic-gatensIndexType: eq
37717c478bd9Sstevel@tonic-gateEOF
37727c478bd9Sstevel@tonic-gate) > ${TMPDIR}/index_${i}
37737c478bd9Sstevel@tonic-gate
37747c478bd9Sstevel@tonic-gate	# Add the index.
37757c478bd9Sstevel@tonic-gate	${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/index_${i} ${VERB}"
37767c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]; then
37777c478bd9Sstevel@tonic-gate	    ${ECHO} "  ERROR: Adding EQ,PRES index for ${i} failed!"
37787c478bd9Sstevel@tonic-gate	    cleanup
37797c478bd9Sstevel@tonic-gate	    exit 1
37807c478bd9Sstevel@tonic-gate	fi
37817c478bd9Sstevel@tonic-gate
37827c478bd9Sstevel@tonic-gate	# Build date for task name.
37837c478bd9Sstevel@tonic-gate	_YR=`date '+%y'`
37847c478bd9Sstevel@tonic-gate	_MN=`date '+%m'`
37857c478bd9Sstevel@tonic-gate	_DY=`date '+%d'`
37867c478bd9Sstevel@tonic-gate	_H=`date '+%H'`
37877c478bd9Sstevel@tonic-gate	_M=`date '+%M'`
37887c478bd9Sstevel@tonic-gate	_S=`date '+%S'`
37897c478bd9Sstevel@tonic-gate
37907c478bd9Sstevel@tonic-gate	# Build task name
37917c478bd9Sstevel@tonic-gate	TASKNAME="${i}_${_YR}_${_MN}_${_DY}_${_H}_${_M}_${_S}"
37927c478bd9Sstevel@tonic-gate
37937c478bd9Sstevel@tonic-gate	# Build the task entry to add.
37947c478bd9Sstevel@tonic-gate	( cat <<EOF
37957c478bd9Sstevel@tonic-gatedn: cn=${TASKNAME}, cn=index, cn=tasks, cn=config
37967c478bd9Sstevel@tonic-gatechangetype: add
37977c478bd9Sstevel@tonic-gateobjectclass: top
37987c478bd9Sstevel@tonic-gateobjectclass: extensibleObject
37997c478bd9Sstevel@tonic-gatecn: ${TASKNAME}
38007c478bd9Sstevel@tonic-gatensInstance: ${IDS_DATABASE}
38017c478bd9Sstevel@tonic-gatensIndexAttribute: ${i}
38027c478bd9Sstevel@tonic-gateEOF
38037c478bd9Sstevel@tonic-gate) > ${TMPDIR}/task_${i}
38047c478bd9Sstevel@tonic-gate
38057c478bd9Sstevel@tonic-gate	# Add the task.
38067c478bd9Sstevel@tonic-gate	${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/task_${i} ${VERB}"
38077c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]; then
38087c478bd9Sstevel@tonic-gate	    ${ECHO} "  ERROR: Adding task for ${i} failed!"
38097c478bd9Sstevel@tonic-gate	    cleanup
38107c478bd9Sstevel@tonic-gate	    exit 1
38117c478bd9Sstevel@tonic-gate	fi
38127c478bd9Sstevel@tonic-gate
38137c478bd9Sstevel@tonic-gate	# Wait for task to finish, display current status.
38147c478bd9Sstevel@tonic-gate	while :
38157c478bd9Sstevel@tonic-gate	do
3816a58015d1Svl199446	    ${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} \
3817a58015d1Svl199446	        -b \"cn=${TASKNAME}, cn=index, cn=tasks, cn=config\" -s base \
3818a58015d1Svl199446	        \"objectclass=*\" nstaskstatus > \"${TMPDIR}/istask_${i}\" 2>&1"
3819a58015d1Svl199446	    ${GREP} "${TASKNAME}" "${TMPDIR}/istask_${i}" > /dev/null 2>&1
38207c478bd9Sstevel@tonic-gate	    if [ $? -ne 0 ]; then
38217c478bd9Sstevel@tonic-gate		break
38227c478bd9Sstevel@tonic-gate	    fi
3823a58015d1Svl199446	    TASK_STATUS=`${GREP} -i nstaskstatus "${TMPDIR}/istask_${i}" |
3824a58015d1Svl199446	        head -1 | cut -d: -f2`
38257c478bd9Sstevel@tonic-gate	    ${ECHO} "      ${i} (eq,pres)  $TASK_STATUS                  \r\c"
38267c478bd9Sstevel@tonic-gate	    ${ECHO} "$TASK_STATUS" | ${GREP} "Finished" > /dev/null 2>&1
38277c478bd9Sstevel@tonic-gate	    if [ $? -eq 0 ]; then
38287c478bd9Sstevel@tonic-gate		break
38297c478bd9Sstevel@tonic-gate	    fi
38307c478bd9Sstevel@tonic-gate	    sleep 2
38317c478bd9Sstevel@tonic-gate	done
38327c478bd9Sstevel@tonic-gate
38337c478bd9Sstevel@tonic-gate	# Print newline because of \c.
38347c478bd9Sstevel@tonic-gate	${ECHO} " "
38357c478bd9Sstevel@tonic-gate    done
38367c478bd9Sstevel@tonic-gate}
38377c478bd9Sstevel@tonic-gate
38387c478bd9Sstevel@tonic-gate
38397c478bd9Sstevel@tonic-gate#
38407c478bd9Sstevel@tonic-gate# add_sub_indexes(): Add indexes to improve search performance.
38417c478bd9Sstevel@tonic-gate#
38427c478bd9Sstevel@tonic-gateadd_sub_indexes()
38437c478bd9Sstevel@tonic-gate{
38447c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In add_sub_indexes()"
38457c478bd9Sstevel@tonic-gate
38467c478bd9Sstevel@tonic-gate    # Set eq indexes to add.
38477c478bd9Sstevel@tonic-gate    _INDEXES="ipHostNumber membernisnetgroup nisnetgrouptriple"
38487c478bd9Sstevel@tonic-gate
38497c478bd9Sstevel@tonic-gate    # Set _EXT to use as shortcut.
38507c478bd9Sstevel@tonic-gate    _EXT="cn=index,cn=${IDS_DATABASE},cn=ldbm database,cn=plugins,cn=config"
38517c478bd9Sstevel@tonic-gate
38527c478bd9Sstevel@tonic-gate
38537c478bd9Sstevel@tonic-gate    # Display message to id current step.
38547c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Processing eq,pres,sub indexes:"
38557c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
38567c478bd9Sstevel@tonic-gate
38577c478bd9Sstevel@tonic-gate    # For loop to create indexes.
38587c478bd9Sstevel@tonic-gate    for i in ${_INDEXES}; do
38597c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "  Adding index for ${i}"
38607c478bd9Sstevel@tonic-gate
38617c478bd9Sstevel@tonic-gate	# Check if entry exists first, if so, skip to next.
3862a58015d1Svl199446	${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} -b \"cn=${i},${_EXT}\" \
3863a58015d1Svl199446	    -s base \"objectclass=*\" > /dev/null 2>&1"
38647c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
38657c478bd9Sstevel@tonic-gate	    # Display index skipped.
38667c478bd9Sstevel@tonic-gate	    ${ECHO} "      ${i} (eq,pres,sub) skipped already exists"
38677c478bd9Sstevel@tonic-gate	    continue
38687c478bd9Sstevel@tonic-gate	fi
38697c478bd9Sstevel@tonic-gate
38707c478bd9Sstevel@tonic-gate	# Here doc to create LDIF.
38717c478bd9Sstevel@tonic-gate	( cat <<EOF
38727c478bd9Sstevel@tonic-gatedn: cn=${i},${_EXT}
38737c478bd9Sstevel@tonic-gateobjectClass: top
38747c478bd9Sstevel@tonic-gateobjectClass: nsIndex
38757c478bd9Sstevel@tonic-gatecn: ${i}
38767c478bd9Sstevel@tonic-gatensSystemIndex: false
38777c478bd9Sstevel@tonic-gatensIndexType: pres
38787c478bd9Sstevel@tonic-gatensIndexType: eq
38797c478bd9Sstevel@tonic-gatensIndexType: sub
38807c478bd9Sstevel@tonic-gateEOF
38817c478bd9Sstevel@tonic-gate) > ${TMPDIR}/index_${i}
38827c478bd9Sstevel@tonic-gate
38837c478bd9Sstevel@tonic-gate	# Add the index.
38847c478bd9Sstevel@tonic-gate	${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/index_${i} ${VERB}"
38857c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]; then
38867c478bd9Sstevel@tonic-gate	    ${ECHO} "  ERROR: Adding EQ,PRES,SUB index for ${i} failed!"
38877c478bd9Sstevel@tonic-gate	    cleanup
38887c478bd9Sstevel@tonic-gate	    exit 1
38897c478bd9Sstevel@tonic-gate	fi
38907c478bd9Sstevel@tonic-gate
38917c478bd9Sstevel@tonic-gate	# Build date for task name.
38927c478bd9Sstevel@tonic-gate	_YR=`date '+%y'`
38937c478bd9Sstevel@tonic-gate	_MN=`date '+%m'`
38947c478bd9Sstevel@tonic-gate	_DY=`date '+%d'`
38957c478bd9Sstevel@tonic-gate	_H=`date '+%H'`
38967c478bd9Sstevel@tonic-gate	_M=`date '+%M'`
38977c478bd9Sstevel@tonic-gate	_S=`date '+%S'`
38987c478bd9Sstevel@tonic-gate
38997c478bd9Sstevel@tonic-gate	# Build task name
39007c478bd9Sstevel@tonic-gate	TASKNAME="${i}_${_YR}_${_MN}_${_DY}_${_H}_${_M}_${_S}"
39017c478bd9Sstevel@tonic-gate
39027c478bd9Sstevel@tonic-gate	# Build the task entry to add.
39037c478bd9Sstevel@tonic-gate	( cat <<EOF
39047c478bd9Sstevel@tonic-gatedn: cn=${TASKNAME}, cn=index, cn=tasks, cn=config
39057c478bd9Sstevel@tonic-gatechangetype: add
39067c478bd9Sstevel@tonic-gateobjectclass: top
39077c478bd9Sstevel@tonic-gateobjectclass: extensibleObject
39087c478bd9Sstevel@tonic-gatecn: ${TASKNAME}
39097c478bd9Sstevel@tonic-gatensInstance: ${IDS_DATABASE}
39107c478bd9Sstevel@tonic-gatensIndexAttribute: ${i}
39117c478bd9Sstevel@tonic-gateEOF
39127c478bd9Sstevel@tonic-gate) > ${TMPDIR}/task_${i}
39137c478bd9Sstevel@tonic-gate
39147c478bd9Sstevel@tonic-gate	# Add the task.
39157c478bd9Sstevel@tonic-gate	${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/task_${i} ${VERB}"
39167c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]; then
39177c478bd9Sstevel@tonic-gate	    ${ECHO} "  ERROR: Adding task for ${i} failed!"
39187c478bd9Sstevel@tonic-gate	    cleanup
39197c478bd9Sstevel@tonic-gate	    exit 1
39207c478bd9Sstevel@tonic-gate	fi
39217c478bd9Sstevel@tonic-gate
39227c478bd9Sstevel@tonic-gate	# Wait for task to finish, display current status.
39237c478bd9Sstevel@tonic-gate	while :
39247c478bd9Sstevel@tonic-gate	do
3925a58015d1Svl199446	    ${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} \
3926a58015d1Svl199446	        -b \"cn=${TASKNAME}, cn=index, cn=tasks, cn=config\" -s base \
3927a58015d1Svl199446	        \"objectclass=*\" nstaskstatus > \"${TMPDIR}/istask_${i}\" 2>&1"
3928a58015d1Svl199446	    ${GREP} "${TASKNAME}" "${TMPDIR}/istask_${i}" > /dev/null 2>&1
39297c478bd9Sstevel@tonic-gate	    if [ $? -ne 0 ]; then
39307c478bd9Sstevel@tonic-gate		break
39317c478bd9Sstevel@tonic-gate	    fi
3932a58015d1Svl199446	    TASK_STATUS=`${GREP} -i nstaskstatus "${TMPDIR}/istask_${i}" |
3933a58015d1Svl199446	        head -1 | cut -d: -f2`
39347c478bd9Sstevel@tonic-gate	    ${ECHO} "      ${i} (eq,pres,sub)  $TASK_STATUS                  \r\c"
39357c478bd9Sstevel@tonic-gate	    ${ECHO} "$TASK_STATUS" | ${GREP} "Finished" > /dev/null 2>&1
39367c478bd9Sstevel@tonic-gate	    if [ $? -eq 0 ]; then
39377c478bd9Sstevel@tonic-gate		break
39387c478bd9Sstevel@tonic-gate	    fi
39397c478bd9Sstevel@tonic-gate	    sleep 2
39407c478bd9Sstevel@tonic-gate	done
39417c478bd9Sstevel@tonic-gate
39427c478bd9Sstevel@tonic-gate	# Print newline because of \c.
39437c478bd9Sstevel@tonic-gate	${ECHO} " "
39447c478bd9Sstevel@tonic-gate    done
39457c478bd9Sstevel@tonic-gate}
39467c478bd9Sstevel@tonic-gate
39477c478bd9Sstevel@tonic-gate
39487c478bd9Sstevel@tonic-gate#
39497c478bd9Sstevel@tonic-gate# add_vlv_indexes(): Add VLV indexes to improve search performance.
39507c478bd9Sstevel@tonic-gate#
39517c478bd9Sstevel@tonic-gateadd_vlv_indexes()
39527c478bd9Sstevel@tonic-gate{
39537c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In add_vlv_indexes()"
39547c478bd9Sstevel@tonic-gate
39557c478bd9Sstevel@tonic-gate    # Set eq indexes to add.
39567c478bd9Sstevel@tonic-gate    # Note semi colon separators because some filters contain colons
39577c478bd9Sstevel@tonic-gate    _INDEX1="${LDAP_DOMAIN}.getgrent;${LDAP_DOMAIN}_group_vlv_index;ou=group;objectClass=posixGroup"
39587c478bd9Sstevel@tonic-gate    _INDEX2="${LDAP_DOMAIN}.gethostent;${LDAP_DOMAIN}_hosts_vlv_index;ou=hosts;objectClass=ipHost"
39597c478bd9Sstevel@tonic-gate    _INDEX3="${LDAP_DOMAIN}.getnetent;${LDAP_DOMAIN}_networks_vlv_index;ou=networks;objectClass=ipNetwork"
39607c478bd9Sstevel@tonic-gate    _INDEX4="${LDAP_DOMAIN}.getpwent;${LDAP_DOMAIN}_passwd_vlv_index;ou=people;objectClass=posixAccount"
39617c478bd9Sstevel@tonic-gate    _INDEX5="${LDAP_DOMAIN}.getrpcent;${LDAP_DOMAIN}_rpc_vlv_index;ou=rpc;objectClass=oncRpc"
39627c478bd9Sstevel@tonic-gate    _INDEX6="${LDAP_DOMAIN}.getspent;${LDAP_DOMAIN}_shadow_vlv_index;ou=people;objectClass=shadowAccount"
39637c478bd9Sstevel@tonic-gate
39647c478bd9Sstevel@tonic-gate    # Indexes added during NIS to LDAP transition
39657c478bd9Sstevel@tonic-gate    _INDEX7="${LDAP_DOMAIN}.getauhoent;${LDAP_DOMAIN}_auho_vlv_index;automountmapname=auto_home;objectClass=automount"
39667c478bd9Sstevel@tonic-gate    _INDEX8="${LDAP_DOMAIN}.getsoluent;${LDAP_DOMAIN}_solu_vlv_index;ou=people;objectClass=SolarisUserAttr"
39677c478bd9Sstevel@tonic-gate    _INDEX10="${LDAP_DOMAIN}.getauthent;${LDAP_DOMAIN}_auth_vlv_index;ou=SolarisAuthAttr;objectClass=SolarisAuthAttr"
39687c478bd9Sstevel@tonic-gate    _INDEX11="${LDAP_DOMAIN}.getexecent;${LDAP_DOMAIN}_exec_vlv_index;ou=SolarisProfAttr;&(objectClass=SolarisExecAttr)(SolarisKernelSecurityPolicy=*)"
39697c478bd9Sstevel@tonic-gate    _INDEX12="${LDAP_DOMAIN}.getprofent;${LDAP_DOMAIN}_prof_vlv_index;ou=SolarisProfAttr;&(objectClass=SolarisProfAttr)(SolarisAttrLongDesc=*)"
39707c478bd9Sstevel@tonic-gate    _INDEX13="${LDAP_DOMAIN}.getmailent;${LDAP_DOMAIN}_mail_vlv_index;ou=aliases;objectClass=mailGroup"
39717c478bd9Sstevel@tonic-gate    _INDEX14="${LDAP_DOMAIN}.getbootent;${LDAP_DOMAIN}__boot_vlv_index;ou=ethers;&(objectClass=bootableDevice)(bootParameter=*)"
39727c478bd9Sstevel@tonic-gate    _INDEX15="${LDAP_DOMAIN}.getethent;${LDAP_DOMAIN}_ethers_vlv_index;ou=ethers;&(objectClass=ieee802Device)(macAddress=*)"
39737c478bd9Sstevel@tonic-gate    _INDEX16="${LDAP_DOMAIN}.getngrpent;${LDAP_DOMAIN}_netgroup_vlv_index;ou=netgroup;objectClass=nisNetgroup"
39747c478bd9Sstevel@tonic-gate    _INDEX17="${LDAP_DOMAIN}.getipnent;${LDAP_DOMAIN}_ipn_vlv_index;ou=networks;&(objectClass=ipNetwork)(cn=*)"
39757c478bd9Sstevel@tonic-gate    _INDEX18="${LDAP_DOMAIN}.getmaskent;${LDAP_DOMAIN}_mask_vlv_index;ou=networks;&(objectClass=ipNetwork)(ipNetmaskNumber=*)"
39767c478bd9Sstevel@tonic-gate    _INDEX19="${LDAP_DOMAIN}.getprent;${LDAP_DOMAIN}_pr_vlv_index;ou=printers;objectClass=printerService"
39777c478bd9Sstevel@tonic-gate    _INDEX20="${LDAP_DOMAIN}.getip4ent;${LDAP_DOMAIN}_ip4_vlv_index;ou=hosts;&(objectClass=ipHost)(ipHostNumber=*.*)"
39787c478bd9Sstevel@tonic-gate    _INDEX21="${LDAP_DOMAIN}.getip6ent;${LDAP_DOMAIN}_ip6_vlv_index;ou=hosts;&(objectClass=ipHost)(ipHostNumber=*:*)"
39797c478bd9Sstevel@tonic-gate
39807c478bd9Sstevel@tonic-gate    _INDEXES="$_INDEX1 $_INDEX2 $_INDEX3 $_INDEX4 $_INDEX5 $_INDEX6 $_INDEX7 $_INDEX8 $_INDEX9 $_INDEX10 $_INDEX11 $_INDEX12 $_INDEX13 $_INDEX14 $_INDEX15 $_INDEX16 $_INDEX17 $_INDEX18 $_INDEX19 $_INDEX20 $_INDEX21 "
39817c478bd9Sstevel@tonic-gate
39827c478bd9Sstevel@tonic-gate
39837c478bd9Sstevel@tonic-gate    # Set _EXT to use as shortcut.
39847c478bd9Sstevel@tonic-gate    _EXT="cn=${IDS_DATABASE},cn=ldbm database,cn=plugins,cn=config"
39857c478bd9Sstevel@tonic-gate
39867c478bd9Sstevel@tonic-gate
39877c478bd9Sstevel@tonic-gate    # Display message to id current step.
39887c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Processing VLV indexes:"
39897c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
39907c478bd9Sstevel@tonic-gate
39917c478bd9Sstevel@tonic-gate    # Reset temp file for vlvindex commands.
3992e1dd0a2fSth160488    [ -f ${TMPDIR}/ds5_vlvindex_list ] &&  rm ${TMPDIR}/ds5_vlvindex_list
3993e1dd0a2fSth160488    touch ${TMPDIR}/ds5_vlvindex_list
3994e1dd0a2fSth160488    [ -f ${TMPDIR}/ds6_vlvindex_list ] &&  rm ${TMPDIR}/ds6_vlvindex_list
3995e1dd0a2fSth160488    touch ${TMPDIR}/ds6_vlvindex_list
39967c478bd9Sstevel@tonic-gate
39977c478bd9Sstevel@tonic-gate    # Get the instance name from iDS server.
39987c478bd9Sstevel@tonic-gate    _INSTANCE="<server-instance>"    # Default to old output.
39997c478bd9Sstevel@tonic-gate
40007c478bd9Sstevel@tonic-gate    eval "${LDAPSEARCH} -v ${LDAP_ARGS} -b \"cn=config\" -s base \"objectclass=*\" nsslapd-instancedir | ${GREP} 'nsslapd-instancedir=' | cut -d'=' -f2- > ${TMPDIR}/instance_name 2>&1"
40017c478bd9Sstevel@tonic-gate
40027c478bd9Sstevel@tonic-gate    ${GREP} "slapd-" ${TMPDIR}/instance_name > /dev/null 2>&1 # Check if seems right?
40037c478bd9Sstevel@tonic-gate    if [ $? -eq 0 ]; then # If success, grab name after "slapd-".
40047c478bd9Sstevel@tonic-gate	_INST_DIR=`cat ${TMPDIR}/instance_name`
40057c478bd9Sstevel@tonic-gate	_INSTANCE=`basename "${_INST_DIR}" | cut -d'-' -f2-`
40067c478bd9Sstevel@tonic-gate    fi
40077c478bd9Sstevel@tonic-gate
40087c478bd9Sstevel@tonic-gate    # For loop to create indexes.
40097c478bd9Sstevel@tonic-gate    for p in ${_INDEXES}; do
40107c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "  Adding index for ${i}"
40117c478bd9Sstevel@tonic-gate
40127c478bd9Sstevel@tonic-gate	# Break p (pair) into i and j parts.
40137c478bd9Sstevel@tonic-gate        i=`${ECHO} $p | cut -d';' -f1`
40147c478bd9Sstevel@tonic-gate        j=`${ECHO} $p | cut -d';' -f2`
40157c478bd9Sstevel@tonic-gate        k=`${ECHO} $p | cut -d';' -f3`
40167c478bd9Sstevel@tonic-gate        m=`${ECHO} $p | cut -d';' -f4`
40177c478bd9Sstevel@tonic-gate
40187c478bd9Sstevel@tonic-gate	# Set _jEXT to use as shortcut.
40197c478bd9Sstevel@tonic-gate	_jEXT="cn=${j},${_EXT}"
40207c478bd9Sstevel@tonic-gate
40217c478bd9Sstevel@tonic-gate	# Check if entry exists first, if so, skip to next.
40227c478bd9Sstevel@tonic-gate	${LDAPSEARCH} ${SERVER_ARGS} -b "cn=${i},${_jEXT}" -s base "objectclass=*" > /dev/null 2>&1
40237c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
40247c478bd9Sstevel@tonic-gate	    # Display index skipped.
40257c478bd9Sstevel@tonic-gate	    ${ECHO} "      ${i} vlv_index skipped already exists"
40267c478bd9Sstevel@tonic-gate	    continue
40277c478bd9Sstevel@tonic-gate	fi
40287c478bd9Sstevel@tonic-gate
40297c478bd9Sstevel@tonic-gate	# Compute the VLV Scope from the LDAP_SEARCH_SCOPE.
40307c478bd9Sstevel@tonic-gate	# NOTE: A value of "base (0)" does not make sense.
40317c478bd9Sstevel@tonic-gate        case "$LDAP_SEARCH_SCOPE" in
40327c478bd9Sstevel@tonic-gate            sub) VLV_SCOPE="2" ;;
40337c478bd9Sstevel@tonic-gate            *)   VLV_SCOPE="1" ;;
40347c478bd9Sstevel@tonic-gate        esac
40357c478bd9Sstevel@tonic-gate
40367c478bd9Sstevel@tonic-gate	# Here doc to create LDIF.
40377c478bd9Sstevel@tonic-gate	( cat <<EOF
40387c478bd9Sstevel@tonic-gatedn: ${_jEXT}
40397c478bd9Sstevel@tonic-gateobjectClass: top
40407c478bd9Sstevel@tonic-gateobjectClass: vlvSearch
40417c478bd9Sstevel@tonic-gatecn: ${j}
40427c478bd9Sstevel@tonic-gatevlvbase: ${k},${LDAP_BASEDN}
40437c478bd9Sstevel@tonic-gatevlvscope: ${VLV_SCOPE}
40447c478bd9Sstevel@tonic-gatevlvfilter: (${m})
40457c478bd9Sstevel@tonic-gateaci: (target="ldap:///${_jEXT}")(targetattr="*")(version 3.0; acl "Config";allow(read,search,compare)userdn="ldap:///anyone";)
40467c478bd9Sstevel@tonic-gate
40477c478bd9Sstevel@tonic-gatedn: cn=${i},${_jEXT}
40487c478bd9Sstevel@tonic-gatecn: ${i}
40497c478bd9Sstevel@tonic-gatevlvSort: cn uid
40507c478bd9Sstevel@tonic-gateobjectclass: top
40517c478bd9Sstevel@tonic-gateobjectclass: vlvIndex
40527c478bd9Sstevel@tonic-gateEOF
40537c478bd9Sstevel@tonic-gate) > ${TMPDIR}/vlv_index_${i}
40547c478bd9Sstevel@tonic-gate
40557c478bd9Sstevel@tonic-gate	# Add the index.
40567c478bd9Sstevel@tonic-gate	${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/vlv_index_${i} ${VERB}"
40577c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]; then
40587c478bd9Sstevel@tonic-gate	    ${ECHO} "  ERROR: Adding VLV index for ${i} failed!"
40597c478bd9Sstevel@tonic-gate	    cleanup
40607c478bd9Sstevel@tonic-gate	    exit 1
40617c478bd9Sstevel@tonic-gate	fi
40627c478bd9Sstevel@tonic-gate
40637c478bd9Sstevel@tonic-gate	# Print message that index was created.
40647c478bd9Sstevel@tonic-gate	${ECHO} "      ${i} vlv_index   Entry created"
40657c478bd9Sstevel@tonic-gate
40667c478bd9Sstevel@tonic-gate	# Add command to list of vlvindex commands to run.
4067e1dd0a2fSth160488	${ECHO} "  directoryserver -s ${_INSTANCE} vlvindex -n ${IDS_DATABASE} -T ${i}" >> ${TMPDIR}/ds5_vlvindex_list
4068e1dd0a2fSth160488	${ECHO} "  <install-path>/bin/dsadm reindex -l -t ${i} <directory-instance-path> ${LDAP_SUFFIX}" >> ${TMPDIR}/ds6_vlvindex_list
40697c478bd9Sstevel@tonic-gate    done
40707c478bd9Sstevel@tonic-gate}
40717c478bd9Sstevel@tonic-gate
40727c478bd9Sstevel@tonic-gate
40737c478bd9Sstevel@tonic-gate#
40747c478bd9Sstevel@tonic-gate# display_vlv_cmds(): Display VLV index commands to run on server.
40757c478bd9Sstevel@tonic-gate#
40767c478bd9Sstevel@tonic-gatedisplay_vlv_cmds()
40777c478bd9Sstevel@tonic-gate{
4078e1dd0a2fSth160488    if [ -s "${TMPDIR}/ds5_vlvindex_list" -o \
4079e1dd0a2fSth160488	 -s "${TMPDIR}/ds6_vlvindex_list" ]; then
40807c478bd9Sstevel@tonic-gate	display_msg display_vlv_list
4081e1dd0a2fSth160488    fi
4082e1dd0a2fSth160488
4083e1dd0a2fSth160488    if [ -s "${TMPDIR}/ds5_vlvindex_list" ]; then
4084e1dd0a2fSth160488	cat ${TMPDIR}/ds5_vlvindex_list
4085e1dd0a2fSth160488    fi
4086e1dd0a2fSth160488
4087e1dd0a2fSth160488    cat << EOF
4088e1dd0a2fSth160488
4089e1dd0a2fSth160488
4090e1dd0a2fSth160488EOF
4091e1dd0a2fSth160488
4092e1dd0a2fSth160488    if [ -s "${TMPDIR}/ds6_vlvindex_list" ]; then
4093e1dd0a2fSth160488	cat ${TMPDIR}/ds6_vlvindex_list
40947c478bd9Sstevel@tonic-gate    fi
40957c478bd9Sstevel@tonic-gate}
40967c478bd9Sstevel@tonic-gate
4097ad848a7fSMilan Jurik#
4098ad848a7fSMilan Jurik# keep_backward_compatibility(): Modify schema for the backward compatibility if
4099ad848a7fSMilan Jurik# there are the incompatible attributes already
4100ad848a7fSMilan Jurik#
4101ad848a7fSMilan Jurikkeep_backward_compatibility()
4102ad848a7fSMilan Jurik{
4103ad848a7fSMilan Jurik    ${EVAL} "${LDAPSEARCH} ${SERVER_ARGS} -b cn=schema -s base \
4104ad848a7fSMilan Jurik        \"objectclass=*\" attributeTypes | ${GREP} -i memberGid-oid ${VERB}"
4105ad848a7fSMilan Jurik    if [ $? -eq 0 ]; then
4106ad848a7fSMilan Jurik        ${SED} -e 's/1\.3\.6\.1\.4\.1\.42\.2\.27\.5\.1\.30\ /memberGid-oid\ /' \
4107ad848a7fSMilan Jurik            ${TMPDIR}/schema_attr > ${TMPDIR}/schema_attr.new
4108ad848a7fSMilan Jurik        ${MV} ${TMPDIR}/schema_attr.new ${TMPDIR}/schema_attr
4109ad848a7fSMilan Jurik    fi
4110ad848a7fSMilan Jurik
4111ad848a7fSMilan Jurik    ${EVAL} "${LDAPSEARCH} ${SERVER_ARGS} -b cn=schema -s base \
4112ad848a7fSMilan Jurik        \"objectclass=*\" attributeTypes | ${GREP} -i rfc822mailMember-oid \
4113ad848a7fSMilan Jurik        ${VERB}"
4114ad848a7fSMilan Jurik    if [ $? -eq 0 ]; then
4115ad848a7fSMilan Jurik        ${SED} -e \
4116ad848a7fSMilan Jurik            's/1\.3\.6\.1\.4\.1\.42\.2\.27\.2\.1\.15\ /rfc822mailMember-oid\ /' \
4117ad848a7fSMilan Jurik            ${TMPDIR}/schema_attr > ${TMPDIR}/schema_attr.new
4118ad848a7fSMilan Jurik        ${MV} ${TMPDIR}/schema_attr.new ${TMPDIR}/schema_attr
4119ad848a7fSMilan Jurik    fi
4120ad848a7fSMilan Jurik}
41217c478bd9Sstevel@tonic-gate
41227c478bd9Sstevel@tonic-gate#
41237c478bd9Sstevel@tonic-gate# update_schema_attr(): Update Schema to support Naming.
41247c478bd9Sstevel@tonic-gate#
41257c478bd9Sstevel@tonic-gateupdate_schema_attr()
41267c478bd9Sstevel@tonic-gate{
41277c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In update_schema_attr()"
41287c478bd9Sstevel@tonic-gate
41297c478bd9Sstevel@tonic-gate    ( cat <<EOF
41307c478bd9Sstevel@tonic-gatedn: cn=schema
41317c478bd9Sstevel@tonic-gatechangetype: modify
41327c478bd9Sstevel@tonic-gateadd: attributetypes
41331d473207SMilan Jurikattributetypes: ( 1.3.6.1.1.1.1.28 NAME 'nisPublickey' DESC 'NIS public key' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41341d473207SMilan Jurikattributetypes: ( 1.3.6.1.1.1.1.29 NAME 'nisSecretkey' DESC 'NIS secret key' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41351d473207SMilan Jurikattributetypes: ( 1.3.6.1.1.1.1.30 NAME 'nisDomain' DESC 'NIS domain' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41361d473207SMilan Jurikattributetypes: ( 1.3.6.1.1.1.1.31 NAME 'automountMapName' DESC 'automount Map Name' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
41371d473207SMilan Jurikattributetypes: ( 1.3.6.1.1.1.1.32 NAME 'automountKey' DESC 'automount Key Value' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
41381d473207SMilan Jurikattributetypes: ( 1.3.6.1.1.1.1.33 NAME 'automountInformation' DESC 'automount information' EQUALITY caseExactIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
41391d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.1.1.12 NAME 'nisNetIdUser' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
41401d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.1.1.13 NAME 'nisNetIdGroup' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
41411d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.1.1.14 NAME 'nisNetIdHost' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
41421d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.2.1.15 NAME 'rfc822mailMember' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
41431d473207SMilan Jurikattributetypes: ( 2.16.840.1.113730.3.1.30 NAME 'mgrpRFC822MailMember' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41441d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.15 NAME 'SolarisLDAPServers' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41451d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.16 NAME 'SolarisSearchBaseDN' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
41461d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.17 NAME 'SolarisCacheTTL' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41471d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.18 NAME 'SolarisBindDN' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
41481d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.19 NAME 'SolarisBindPassword' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
41491d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.20 NAME 'SolarisAuthMethod' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41501d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.21 NAME 'SolarisTransportSecurity' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41511d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.22 NAME 'SolarisCertificatePath' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
41521d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.23 NAME 'SolarisCertificatePassword' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
41531d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.24 NAME 'SolarisDataSearchDN' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41541d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.25 NAME 'SolarisSearchScope' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41551d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.26 NAME 'SolarisSearchTimeLimit' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
41561d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.27 NAME 'SolarisPreferredServer' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41571d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.28 NAME 'SolarisPreferredServerOnly' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41581d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.29 NAME 'SolarisSearchReferral' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41591d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.4 NAME 'SolarisAttrKeyValue' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41601d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.5 NAME 'SolarisAuditAlways' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41611d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.6 NAME 'SolarisAuditNever' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41621d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.7 NAME 'SolarisAttrShortDesc' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41631d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.8 NAME 'SolarisAttrLongDesc' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41641d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.9 NAME 'SolarisKernelSecurityPolicy' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41651d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.10 NAME 'SolarisProfileType' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41661d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.11 NAME 'SolarisProfileId' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
41671d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.12 NAME 'SolarisUserQualifier' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41681d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.13 NAME 'SolarisAttrReserved1' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41691d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.14 NAME 'SolarisAttrReserved2' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41701d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.1 NAME 'SolarisProjectID' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
41711d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.2 NAME 'SolarisProjectName' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
41721d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.3 NAME 'SolarisProjectAttr' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
41731d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.30 NAME 'memberGid' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
41741d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.0 NAME 'defaultServerList' DESC 'Default LDAP server host address used by a DUA' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41751d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.1 NAME 'defaultSearchBase' DESC 'Default LDAP base DN used by a DUA' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 SINGLE-VALUE )
41761d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.2 NAME 'preferredServerList' DESC 'Preferred LDAP server host addresses to be used by a DUA' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41771d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.3 NAME 'searchTimeLimit' DESC 'Maximum time in seconds a DUA should allow for a search to complete' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
41781d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.4 NAME 'bindTimeLimit' DESC 'Maximum time in seconds a DUA should allow for the bind operation to complete' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
41791d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.5 NAME 'followReferrals' DESC 'Tells DUA if it should follow referrals returned by a DSA search result' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41801d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.6 NAME 'authenticationMethod' DESC 'A keystring which identifies the type of authentication method used to contact the DSA' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41811d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.7 NAME 'profileTTL' DESC 'Time to live before a client DUA should re-read this configuration profile' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
41821d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.14 NAME 'serviceSearchDescriptor' DESC 'LDAP search descriptor list used by Naming-DUA' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
41831d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.9 NAME 'attributeMap' DESC 'Attribute mappings used by a Naming-DUA' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41841d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.10 NAME 'credentialLevel' DESC 'Identifies type of credentials a DUA should use when binding to the LDAP server' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41851d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.11 NAME 'objectclassMap' DESC 'Objectclass mappings used by a Naming-DUA' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41861d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.12 NAME 'defaultSearchScope' DESC 'Default search scope used by a DUA' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41877c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.13 NAME 'serviceCredentialLevel' DESC 'Search scope used by a service of the DUA' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 )
41887c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.6.1.4.1.11.1.3.1.1.15 NAME 'serviceAuthenticationMethod' DESC 'Authentication Method used by a service of the DUA' EQUALITY caseIgnoreMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41897c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1140 NAME 'printer-uri' DESC 'A URI supported by this printer.  This URI SHOULD be used as a relative distinguished name (RDN).  If printer-xri-supported is implemented, then this URI value MUST be listed in a member value of printer-xri-supported.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41907c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1107 NAME 'printer-xri-supported' DESC 'The unordered list of XRI (extended resource identifiers) supported by this printer.  Each member of the list consists of a URI (uniform resource identifier) followed by optional authentication and security metaparameters.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
41917c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1135 NAME 'printer-name' DESC 'The site-specific administrative name of this printer, more end-user friendly than a URI.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127}  SINGLE-VALUE )
41927c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1119 NAME 'printer-natural-language-configured' DESC 'The configured language in which error and status messages will be generated (by default) by this printer.  Also, a possible language for printer string attributes set by operator, system administrator, or manufacturer.  Also, the (declared) language of the "printer-name", "printer-location", "printer-info", and "printer-make-and-model" attributes of this printer. For example: "en-us" (US English) or "fr-fr" (French in France) Legal values of language tags conform to [RFC3066] "Tags for the Identification of Languages".' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127}  SINGLE-VALUE )
41937c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1136 NAME 'printer-location' DESC 'Identifies the location of the printer. This could include things like: "in Room 123A", "second floor of building XYZ".' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} SINGLE-VALUE )
41947c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1139 NAME 'printer-info' DESC 'Identifies the descriptive information about this printer.  This could include things like: "This printer can be used for printing color transparencies for HR presentations", or "Out of courtesy for others, please print only small (1-5 page) jobs at this printer", or even "This printer is going away on July 1, 1997, please find a new printer".' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} SINGLE-VALUE )
41957c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1134 NAME 'printer-more-info' DESC 'A URI used to obtain more information about this specific printer.  For example, this could be an HTTP type URI referencing an HTML page accessible to a Web Browser.  The information obtained from this URI is intended for end user consumption.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
41967c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1138 NAME 'printer-make-and-model' DESC 'Identifies the make and model of the device.  The device manufacturer MAY initially populate this attribute.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{127}  SINGLE-VALUE )
41977c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1133 NAME 'printer-ipp-versions-supported' DESC 'Identifies the IPP protocol version(s) that this printer supports, including major and minor versions, i.e., the version numbers for which this Printer implementation meets the conformance requirements.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} )
41987c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1132 NAME 'printer-multiple-document-jobs-supported' DESC 'Indicates whether or not the printer supports more than one document per job, i.e., more than one Send-Document or Send-Data operation with document data.' EQUALITY booleanMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )
41997c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1109 NAME 'printer-charset-configured' DESC 'The configured charset in which error and status messages will be generated (by default) by this printer.  Also, a possible charset for printer string attributes set by operator, system administrator, or manufacturer.  For example: "utf-8" (ISO 10646/Unicode) or "iso-8859-1" (Latin1).  Legal values are defined by the IANA Registry of Coded Character Sets and the "(preferred MIME name)" SHALL be used as the tag.  For coherence with IPP Model, charset tags in this attribute SHALL be lowercase normalized.  This attribute SHOULD be static (time of registration) and SHOULD NOT be dynamically refreshed attributetypes: (subsequently).' EQUALITY caseIgnoreMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{63} SINGLE-VALUE )
42007c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1131 NAME 'printer-charset-supported' DESC 'Identifies the set of charsets supported for attribute type values of type Directory String for this directory entry.  For example: "utf-8" (ISO 10646/Unicode) or "iso-8859-1" (Latin1).  Legal values are defined by the IANA Registry of Coded Character Sets and the preferred MIME name.' EQUALITY caseIgnoreMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{63} )
42017c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1137 NAME 'printer-generated-natural-language-supported' DESC 'Identifies the natural language(s) supported for this directory entry.  For example: "en-us" (US English) or "fr-fr" (French in France).  Legal values conform to [RFC3066], Tags for the Identification of Languages.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{63} )
42027c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1130 NAME 'printer-document-format-supported' DESC 'The possible document formats in which data may be interpreted and printed by this printer.  Legal values are MIME types come from the IANA Registry of Internet Media Types.' EQUALITY caseIgnoreMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} )
42037c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1129 NAME 'printer-color-supported' DESC 'Indicates whether this printer is capable of any type of color printing at all, including highlight color.' EQUALITY booleanMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.7 SINGLE-VALUE )
42047c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1128 NAME 'printer-compression-supported' DESC 'Compression algorithms supported by this printer.  For example: "deflate, gzip".  Legal values include; "none", "deflate" attributetypes: (public domain ZIP), "gzip" (GNU ZIP), "compress" (UNIX).' EQUALITY caseIgnoreMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{255} )
42057c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1127 NAME 'printer-pages-per-minute' DESC 'The nominal number of pages per minute which may be output by this printer (e.g., a simplex or black-and-white printer).  This attribute is informative, NOT a service guarantee.  Typically, it is the value used in marketing literature to describe this printer.' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
42067c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1126 NAME 'printer-pages-per-minute-color' DESC 'The nominal number of color pages per minute which may be output by this printer (e.g., a simplex or color printer).  This attribute is informative, NOT a service guarantee.  Typically, it is the value used in marketing literature to describe this printer.' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
42077c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1125 NAME 'printer-finishings-supported' DESC 'The possible finishing operations supported by this printer. Legal values include; "none", "staple", "punch", "cover", "bind", "saddle-stitch", "edge-stitch", "staple-top-left", "staple-bottom-left", "staple-top-right", "staple-bottom-right", "edge-stitch-left", "edge-stitch-top", "edge-stitch-right", "edge-stitch-bottom", "staple-dual-left", "staple-dual-top", "staple-dual-right", "staple-dual-bottom".' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{255} )
42087c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1124 NAME 'printer-number-up-supported' DESC 'The possible numbers of print-stream pages to impose upon a single side of an instance of a selected medium. Legal values include; 1, 2, and 4.  Implementations may support other values.' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.27 )
42097c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1123 NAME 'printer-sides-supported' DESC 'The number of impression sides (one or two) and the two-sided impression rotations supported by this printer.  Legal values include; "one-sided", "two-sided-long-edge", "two-sided-short-edge".' EQUALITY caseIgnoreMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} )
42107c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1122 NAME 'printer-media-supported' DESC 'The standard names/types/sizes (and optional color suffixes) of the media supported by this printer.  For example: "iso-a4",  "envelope", or "na-letter-white".  Legal values  conform to ISO 10175, Document Printing Application (DPA), and any IANA registered extensions.' EQUALITY caseIgnoreMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{255} )
42117c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1117 NAME 'printer-media-local-supported' DESC 'Site-specific names of media supported by this printer, in the language in "printer-natural-language-configured".  For example: "purchasing-form" (site-specific name) as opposed to (in "printer-media-supported"): "na-letter" (standard keyword from ISO 10175).' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{255} )
42127c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1121 NAME 'printer-resolution-supported' DESC 'List of resolutions supported for printing documents by this printer.  Each resolution value is a string with 3 fields:  1) Cross feed direction resolution (positive integer), 2) Feed direction resolution (positive integer), 3) Resolution unit.  Legal values are "dpi" (dots per inch) and "dpcm" (dots per centimeter).  Each resolution field is delimited by ">".  For example:  "300> 300> dpi>".' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{255} )
42137c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1120 NAME 'printer-print-quality-supported' DESC 'List of print qualities supported for printing documents on this printer.  For example: "draft, normal".  Legal values include; "unknown", "draft", "normal", "high".' EQUALITY caseIgnoreMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} )
42147c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1110 NAME 'printer-job-priority-supported' DESC 'Indicates the number of job priority levels supported.  An IPP conformant printer which supports job priority must always support a full range of priorities from "1" to "100" (to ensure consistent behavior), therefore this attribute describes the "granularity".  Legal values of this attribute are from "1" to "100".' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
42157c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1118 NAME 'printer-copies-supported' DESC 'The maximum number of copies of a document that may be printed as a single job.  A value of "0" indicates no maximum limit.  A value of "-1" indicates unknown.' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
42167c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1111 NAME 'printer-job-k-octets-supported' DESC 'The maximum size in kilobytes (1,024 octets actually) incoming print job that this printer will accept.  A value of "0" indicates no maximum limit.  A value of "-1" indicates unknown.' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE )
42177c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1112 NAME 'printer-current-operator' DESC 'The name of the current human operator responsible for operating this printer.  It is suggested that this string include information that would enable other humans to reach the operator, such as a phone number.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} SINGLE-VALUE )
42187c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1113 NAME 'printer-service-person' DESC 'The name of the current human service person responsible for servicing this printer.  It is suggested that this string include information that would enable other humans to reach the service person, such as a phone number.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127}  SINGLE-VALUE )
42197c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1114 NAME 'printer-delivery-orientation-supported' DESC 'The possible delivery orientations of pages as they are printed and ejected from this printer.  Legal values include; "unknown", "face-up", and "face-down".' EQUALITY caseIgnoreMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} )
42207c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1115 NAME 'printer-stacking-order-supported' DESC 'The possible stacking order of pages as they are printed and ejected from this printer. Legal values include; "unknown", "first-to-last", "last-to-first".' EQUALITY caseIgnoreMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} )
42217c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1116 NAME 'printer-output-features-supported' DESC 'The possible output features supported by this printer. Legal values include; "unknown", "bursting", "decollating", "page-collating", "offset-stacking".' EQUALITY caseIgnoreMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} )
42227c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.18.0.2.4.1108 NAME 'printer-aliases' DESC 'Site-specific administrative names of this printer in addition the printer name specified for printer-name.' EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX  1.3.6.1.4.1.1466.115.121.1.15{127} )
42231d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.63 NAME 'sun-printer-bsdaddr' DESC 'Sets the server, print queue destination name and whether the client generates protocol extensions. "Solaris" specifies a Solaris print server extension. The value is represented by the following value: server "," destination ", Solaris".' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE )
42241d473207SMilan Jurikattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.64 NAME 'sun-printer-kvp' DESC 'This attribute contains a set of key value pairs which may have meaning to the print subsystem or may be user defined. Each value is represented by the following: key "=" value.' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 )
42257c478bd9Sstevel@tonic-gateattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.57 NAME 'nisplusTimeZone' DESC 'tzone column from NIS+ timezone table' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
422645916cd2Sjpkattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.67 NAME 'ipTnetTemplateName' DESC 'Trusted Solaris network template template_name' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
422745916cd2Sjpkattributetypes: ( 1.3.6.1.4.1.42.2.27.5.1.68 NAME 'ipTnetNumber' DESC 'Trusted Solaris network template ip_address' SYNTAX 1.3.6.1.4.1.1466.115.121.1.26 SINGLE-VALUE )
42287c478bd9Sstevel@tonic-gateEOF
42297c478bd9Sstevel@tonic-gate) > ${TMPDIR}/schema_attr
42307c478bd9Sstevel@tonic-gate
4231ad848a7fSMilan Jurik    keep_backward_compatibility
4232ad848a7fSMilan Jurik
42337c478bd9Sstevel@tonic-gate    # Add the entry.
42347c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/schema_attr ${VERB}"
42357c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
42367c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: update of schema attributes failed!"
42377c478bd9Sstevel@tonic-gate	cleanup
42387c478bd9Sstevel@tonic-gate	exit 1
42397c478bd9Sstevel@tonic-gate    fi
42407c478bd9Sstevel@tonic-gate
42417c478bd9Sstevel@tonic-gate    # Display message that schema is updated.
42427c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Schema attributes have been updated."
42437c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
42447c478bd9Sstevel@tonic-gate}
42457c478bd9Sstevel@tonic-gate
42467c478bd9Sstevel@tonic-gate
42477c478bd9Sstevel@tonic-gate#
42487c478bd9Sstevel@tonic-gate# update_schema_obj(): Update the schema objectclass definitions.
42497c478bd9Sstevel@tonic-gate#
42507c478bd9Sstevel@tonic-gateupdate_schema_obj()
42517c478bd9Sstevel@tonic-gate{
42527c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In update_schema_obj()"
42537c478bd9Sstevel@tonic-gate
42547c478bd9Sstevel@tonic-gate    # Add the objectclass definitions.
42557c478bd9Sstevel@tonic-gate    ( cat <<EOF
42567c478bd9Sstevel@tonic-gatedn: cn=schema
42577c478bd9Sstevel@tonic-gatechangetype: modify
42587c478bd9Sstevel@tonic-gateadd: objectclasses
42591d473207SMilan Jurikobjectclasses: ( 1.3.6.1.1.1.2.14 NAME 'NisKeyObject' SUP top MUST ( cn $ nisPublickey $ nisSecretkey ) MAY ( uidNumber $ description ) )
42607c478bd9Sstevel@tonic-gate
42617c478bd9Sstevel@tonic-gatedn: cn=schema
42627c478bd9Sstevel@tonic-gatechangetype: modify
42637c478bd9Sstevel@tonic-gateadd: objectclasses
42641d473207SMilan Jurikobjectclasses: ( 1.3.6.1.1.1.2.15 NAME 'nisDomainObject' SUP top MUST nisDomain )
42657c478bd9Sstevel@tonic-gate
42667c478bd9Sstevel@tonic-gatedn: cn=schema
42677c478bd9Sstevel@tonic-gatechangetype: modify
42687c478bd9Sstevel@tonic-gateadd: objectclasses
42691d473207SMilan Jurikobjectclasses: ( 1.3.6.1.1.1.2.16 NAME 'automountMap' SUP top MUST automountMapName MAY description )
42707c478bd9Sstevel@tonic-gate
42717c478bd9Sstevel@tonic-gatedn: cn=schema
42727c478bd9Sstevel@tonic-gatechangetype: modify
42737c478bd9Sstevel@tonic-gateadd: objectclasses
42741d473207SMilan Jurikobjectclasses: ( 1.3.6.1.1.1.2.17 NAME 'automount' SUP top MUST ( automountKey $ automountInformation ) MAY description )
42757c478bd9Sstevel@tonic-gate
42767c478bd9Sstevel@tonic-gatedn: cn=schema
42777c478bd9Sstevel@tonic-gatechangetype: modify
42787c478bd9Sstevel@tonic-gateadd: objectclasses
42791d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.42.2.27.5.2.7 NAME 'SolarisNamingProfile' SUP top MUST ( cn $ SolarisLDAPservers $ SolarisSearchBaseDN ) MAY ( SolarisBindDN $ SolarisBindPassword $ SolarisAuthMethod $ SolarisTransportSecurity $ SolarisCertificatePath $ SolarisCertificatePassword $ SolarisDataSearchDN $ SolarisSearchScope $ SolarisSearchTimeLimit $ SolarisPreferredServer $ SolarisPreferredServerOnly $ SolarisCacheTTL $ SolarisSearchReferral ) )
42807c478bd9Sstevel@tonic-gate
42817c478bd9Sstevel@tonic-gatedn: cn=schema
42827c478bd9Sstevel@tonic-gatechangetype: modify
42837c478bd9Sstevel@tonic-gateadd: objectclasses
42841d473207SMilan Jurikobjectclasses: ( 2.16.840.1.113730.3.2.4 NAME 'mailGroup' SUP top MUST mail MAY ( cn $ mgrpRFC822MailMember ) )
42857c478bd9Sstevel@tonic-gate
42867c478bd9Sstevel@tonic-gatedn: cn=schema
42877c478bd9Sstevel@tonic-gatechangetype: modify
42887c478bd9Sstevel@tonic-gateadd: objectclasses
42891d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.42.2.27.1.2.5 NAME 'nisMailAlias' SUP top MUST cn MAY rfc822mailMember )
42907c478bd9Sstevel@tonic-gate
42917c478bd9Sstevel@tonic-gatedn: cn=schema
42927c478bd9Sstevel@tonic-gatechangetype: modify
42937c478bd9Sstevel@tonic-gateadd: objectclasses
42941d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.42.2.27.1.2.6 NAME 'nisNetId' SUP top MUST cn MAY ( nisNetIdUser $ nisNetIdGroup $ nisNetIdHost ) )
42957c478bd9Sstevel@tonic-gate
42967c478bd9Sstevel@tonic-gatedn: cn=schema
42977c478bd9Sstevel@tonic-gatechangetype: modify
42987c478bd9Sstevel@tonic-gateadd: objectclasses
42991d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.42.2.27.5.2.2 NAME 'SolarisAuditUser' SUP top AUXILIARY MAY ( SolarisAuditAlways $ SolarisAuditNever ) )
43007c478bd9Sstevel@tonic-gate
43017c478bd9Sstevel@tonic-gatedn: cn=schema
43027c478bd9Sstevel@tonic-gatechangetype: modify
43037c478bd9Sstevel@tonic-gateadd: objectclasses
43041d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.42.2.27.5.2.3 NAME 'SolarisUserAttr' SUP top AUXILIARY MAY ( SolarisUserQualifier $ SolarisAttrReserved1 $ SolarisAttrReserved2 $ SolarisAttrKeyValue ) )
43057c478bd9Sstevel@tonic-gate
43067c478bd9Sstevel@tonic-gatedn: cn=schema
43077c478bd9Sstevel@tonic-gatechangetype: modify
43087c478bd9Sstevel@tonic-gateadd: objectclasses
43091d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.42.2.27.5.2.4 NAME 'SolarisAuthAttr' SUP top MUST cn MAY ( SolarisAttrReserved1 $ SolarisAttrReserved2 $ SolarisAttrShortDesc $ SolarisAttrLongDesc $ SolarisAttrKeyValue ) )
43107c478bd9Sstevel@tonic-gate
43117c478bd9Sstevel@tonic-gatedn: cn=schema
43127c478bd9Sstevel@tonic-gatechangetype: modify
43137c478bd9Sstevel@tonic-gateadd: objectclasses
43141d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.42.2.27.5.2.5 NAME 'SolarisProfAttr' SUP top MUST cn MAY ( SolarisAttrReserved1 $ SolarisAttrReserved2 $ SolarisAttrLongDesc $ SolarisAttrKeyValue ) )
43157c478bd9Sstevel@tonic-gate
43167c478bd9Sstevel@tonic-gatedn: cn=schema
43177c478bd9Sstevel@tonic-gatechangetype: modify
43187c478bd9Sstevel@tonic-gateadd: objectclasses
43191d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.42.2.27.5.2.6 NAME 'SolarisExecAttr' SUP top AUXILIARY MAY ( SolarisKernelSecurityPolicy $ SolarisProfileType $ SolarisAttrReserved1 $ SolarisAttrReserved2 $ SolarisProfileID $ SolarisAttrKeyValue ) )
43207c478bd9Sstevel@tonic-gate
43217c478bd9Sstevel@tonic-gatedn: cn=schema
43227c478bd9Sstevel@tonic-gatechangetype: modify
43237c478bd9Sstevel@tonic-gateadd: objectclasses
43241d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.42.2.27.5.2.1 NAME 'SolarisProject' SUP top MUST ( SolarisProjectID $ SolarisProjectName ) MAY ( memberUid $ memberGid $ description $ SolarisProjectAttr ) )
43257c478bd9Sstevel@tonic-gate
43267c478bd9Sstevel@tonic-gatedn: cn=schema
43277c478bd9Sstevel@tonic-gatechangetype: modify
43287c478bd9Sstevel@tonic-gateadd: objectclasses
43291d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.11.1.3.1.2.4 NAME 'DUAConfigProfile' SUP top DESC 'Abstraction of a base configuration for a DUA' MUST cn MAY ( defaultServerList $ preferredServerList $ defaultSearchBase $ defaultSearchScope $ searchTimeLimit $ bindTimeLimit $ credentialLevel $ authenticationMethod $ followReferrals $ serviceSearchDescriptor $ serviceCredentialLevel $ serviceAuthenticationMethod $ objectclassMap $ attributeMap $ profileTTL ) )
43307c478bd9Sstevel@tonic-gate
43317c478bd9Sstevel@tonic-gatedn: cn=schema
43327c478bd9Sstevel@tonic-gatechangetype: modify
43337c478bd9Sstevel@tonic-gateadd: objectclasses
43341d473207SMilan Jurikobjectclasses: ( 1.3.18.0.2.6.2549 NAME 'slpService' DESC 'DUMMY definition' SUP top MUST objectclass )
43357c478bd9Sstevel@tonic-gate
43367c478bd9Sstevel@tonic-gatedn: cn=schema
43377c478bd9Sstevel@tonic-gatechangetype: modify
43387c478bd9Sstevel@tonic-gateadd: objectclasses
43391d473207SMilan Jurikobjectclasses: ( 1.3.18.0.2.6.254 NAME 'slpServicePrinter' DESC 'Service Location Protocol (SLP) information.' SUP slpService AUXILIARY )
43407c478bd9Sstevel@tonic-gate
43417c478bd9Sstevel@tonic-gatedn: cn=schema
43427c478bd9Sstevel@tonic-gatechangetype: modify
43437c478bd9Sstevel@tonic-gateadd: objectclasses
43441d473207SMilan Jurikobjectclasses: ( 1.3.18.0.2.6.258 NAME 'printerAbstract' DESC 'Printer related information.' SUP top ABSTRACT MAY ( printer-name $ printer-natural-language-configured $ printer-location $ printer-info $ printer-more-info $ printer-make-and-model $ printer-multiple-document-jobs-supported $ printer-charset-configured $ printer-charset-supported $ printer-generated-natural-language-supported $ printer-document-format-supported $ printer-color-supported $ printer-compression-supported $ printer-pages-per-minute $ printer-pages-per-minute-color $ printer-finishings-supported $ printer-number-up-supported $ printer-sides-supported $ printer-media-supported $ printer-media-local-supported $ printer-resolution-supported $ printer-print-quality-supported $ printer-job-priority-supported $ printer-copies-supported $ printer-job-k-octets-supported $ printer-current-operator $ printer-service-person $ printer-delivery-orientation-supported $ printer-stacking-order-supported $ printer-output-features-supported ) )
43457c478bd9Sstevel@tonic-gate
43467c478bd9Sstevel@tonic-gatedn: cn=schema
43477c478bd9Sstevel@tonic-gatechangetype: modify
43487c478bd9Sstevel@tonic-gateadd: objectclasses
43491d473207SMilan Jurikobjectclasses: ( 1.3.18.0.2.6.255 NAME 'printerService' DESC 'Printer information.' SUP printerAbstract STRUCTURAL MAY ( printer-uri $ printer-xri-supported ) )
43507c478bd9Sstevel@tonic-gate
43517c478bd9Sstevel@tonic-gatedn: cn=schema
43527c478bd9Sstevel@tonic-gatechangetype: modify
43537c478bd9Sstevel@tonic-gateadd: objectclasses
43541d473207SMilan Jurikobjectclasses: ( 1.3.18.0.2.6.257 NAME 'printerServiceAuxClass' DESC 'Printer information.' SUP printerAbstract AUXILIARY MAY ( printer-uri $ printer-xri-supported ) )
43557c478bd9Sstevel@tonic-gate
43567c478bd9Sstevel@tonic-gatedn: cn=schema
43577c478bd9Sstevel@tonic-gatechangetype: modify
43587c478bd9Sstevel@tonic-gateadd: objectclasses
43591d473207SMilan Jurikobjectclasses: ( 1.3.18.0.2.6.256 NAME 'printerIPP' DESC 'Internet Printing Protocol (IPP) information.' SUP top AUXILIARY MAY ( printer-ipp-versions-supported $ printer-multiple-document-jobs-supported ) )
43607c478bd9Sstevel@tonic-gate
43617c478bd9Sstevel@tonic-gatedn: cn=schema
43627c478bd9Sstevel@tonic-gatechangetype: modify
43637c478bd9Sstevel@tonic-gateadd: objectclasses
43641d473207SMilan Jurikobjectclasses: ( 1.3.18.0.2.6.253 NAME 'printerLPR' DESC 'LPR information.' SUP top AUXILIARY MUST printer-name MAY printer-aliases )
43657c478bd9Sstevel@tonic-gate
43667c478bd9Sstevel@tonic-gatedn: cn=schema
43677c478bd9Sstevel@tonic-gatechangetype: modify
43687c478bd9Sstevel@tonic-gateadd: objectclasses
43691d473207SMilan Jurikobjectclasses: ( 1.3.6.1.4.1.42.2.27.5.2.14 NAME 'sunPrinter' DESC 'Sun printer information' SUP top AUXILIARY MUST printer-name MAY ( sun-printer-bsdaddr $ sun-printer-kvp ) )
43707c478bd9Sstevel@tonic-gate
43717c478bd9Sstevel@tonic-gatedn: cn=schema
43727c478bd9Sstevel@tonic-gatechangetype: modify
43737c478bd9Sstevel@tonic-gateadd: objectclasses
43741d473207SMilan Jurikobjectclasses:	( 1.3.6.1.4.1.42.2.27.5.2.12 NAME 'nisplusTimeZoneData' DESC 'NIS+ timezone table data' SUP top STRUCTURAL MUST cn MAY ( nisplusTimeZone $ description ) )
437545916cd2Sjpk
437645916cd2Sjpkdn: cn=schema
437745916cd2Sjpkchangetype: modify
437845916cd2Sjpkadd: objectclasses
43791d473207SMilan Jurikobjectclasses:  ( 1.3.6.1.4.1.42.2.27.5.2.8 NAME 'ipTnetTemplate' DESC 'Object class for TSOL network templates' SUP top MUST ipTnetTemplateName MAY SolarisAttrKeyValue )
438045916cd2Sjpk
438145916cd2Sjpkdn: cn=schema
438245916cd2Sjpkchangetype: modify
438345916cd2Sjpkadd: objectclasses
43841d473207SMilan Jurikobjectclasses:	( 1.3.6.1.4.1.42.2.27.5.2.9 NAME 'ipTnetHost' DESC 'Associates an IP address or wildcard with a TSOL template_name' SUP top AUXILIARY MUST ipTnetNumber )
43857c478bd9Sstevel@tonic-gateEOF
43867c478bd9Sstevel@tonic-gate) > ${TMPDIR}/schema_obj
43877c478bd9Sstevel@tonic-gate
43887c478bd9Sstevel@tonic-gate    # Add the entry.
43897c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/schema_obj ${VERB}"
43907c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
43917c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: update of schema objectclass definitions failed!"
43927c478bd9Sstevel@tonic-gate	cleanup
43937c478bd9Sstevel@tonic-gate	exit 1
43947c478bd9Sstevel@tonic-gate    fi
43957c478bd9Sstevel@tonic-gate
43967c478bd9Sstevel@tonic-gate    # Display message that schema is updated.
43977c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Schema objectclass definitions have been added."
43987c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
43997c478bd9Sstevel@tonic-gate}
44007c478bd9Sstevel@tonic-gate
44017c478bd9Sstevel@tonic-gate#
44027c478bd9Sstevel@tonic-gate# modify_top_aci(): Modify the ACI for the top entry to disable self modify
44037c478bd9Sstevel@tonic-gate#                   of user attributes.
44047c478bd9Sstevel@tonic-gate#
44057c478bd9Sstevel@tonic-gatemodify_top_aci()
44067c478bd9Sstevel@tonic-gate{
44077c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In modify_top_aci()"
44087c478bd9Sstevel@tonic-gate
44097c478bd9Sstevel@tonic-gate    # Set ACI Name
44107c478bd9Sstevel@tonic-gate    ACI_NAME="LDAP_Naming_Services_deny_write_access"
44117c478bd9Sstevel@tonic-gate
44127c478bd9Sstevel@tonic-gate    # Search for ACI_NAME
44137c478bd9Sstevel@tonic-gate    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_BASEDN}\" -s base objectclass=* aci > ${TMPDIR}/chk_top_aci 2>&1"
44147c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
44157c478bd9Sstevel@tonic-gate	${ECHO} "Error searching aci for ${LDAP_BASEDN}"
44167c478bd9Sstevel@tonic-gate	cat ${TMPDIR}/chk_top_aci
44177c478bd9Sstevel@tonic-gate	cleanup
44187c478bd9Sstevel@tonic-gate	exit 1
44197c478bd9Sstevel@tonic-gate    fi
44207c478bd9Sstevel@tonic-gate    ${GREP} "${ACI_NAME}" ${TMPDIR}/chk_top_aci > /dev/null 2>&1
44217c478bd9Sstevel@tonic-gate    if [ $? -eq 0 ]; then
4422b57459abSJulian Pullen	${ECHO} "  ${STEP}. Top level ACI ${ACI_NAME} already exists for ${LDAP_BASEDN}."
44237c478bd9Sstevel@tonic-gate	STEP=`expr $STEP + 1`
44247c478bd9Sstevel@tonic-gate	return 0
44257c478bd9Sstevel@tonic-gate    fi
44267c478bd9Sstevel@tonic-gate
44277c478bd9Sstevel@tonic-gate    # Crate LDIF for top level ACI.
44287c478bd9Sstevel@tonic-gate    ( cat <<EOF
44297c478bd9Sstevel@tonic-gatedn: ${LDAP_BASEDN}
44307c478bd9Sstevel@tonic-gatechangetype: modify
44317c478bd9Sstevel@tonic-gateadd: aci
4432*07925104Sgwwaci: (targetattr = "cn||uid||uidNumber||gidNumber||homeDirectory||shadowLastChange||shadowMin||shadowMax||shadowWarning||shadowInactive||shadowExpire||shadowFlag||memberUid||SolarisAttrKeyValue||SolarisAttrReserved1||SolarisAttrReserved2||SolarisUserQualifier")(version 3.0; acl ${ACI_NAME}; deny (write) userdn = "ldap:///self";)
44337c478bd9Sstevel@tonic-gate-
44347c478bd9Sstevel@tonic-gateEOF
44357c478bd9Sstevel@tonic-gate) > ${TMPDIR}/top_aci
44367c478bd9Sstevel@tonic-gate
44377c478bd9Sstevel@tonic-gate    # Add the entry.
44387c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/top_aci ${VERB}"
44397c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
44407c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: Modify of top level ACI failed! (restricts self modify)"
44417c478bd9Sstevel@tonic-gate	cleanup
44427c478bd9Sstevel@tonic-gate	exit 1
44437c478bd9Sstevel@tonic-gate    fi
44447c478bd9Sstevel@tonic-gate
4445b57459abSJulian Pullen    # Display message that ACI is updated.
4446dd1104fbSMichen Chang    MSG="ACI for ${LDAP_BASEDN} modified to disable self modify."
4447dd1104fbSMichen Chang    if [ $EXISTING_PROFILE -eq 1 ];then
4448dd1104fbSMichen Chang	${ECHO} "  ACI SET: $MSG"
4449dd1104fbSMichen Chang    else
4450dd1104fbSMichen Chang	${ECHO} "  ${STEP}. $MSG"
44517c478bd9Sstevel@tonic-gate	STEP=`expr $STEP + 1`
4452dd1104fbSMichen Chang    fi
44537c478bd9Sstevel@tonic-gate}
44547c478bd9Sstevel@tonic-gate
44557c478bd9Sstevel@tonic-gate#
4456b57459abSJulian Pullen# find_and_delete_ACI(): Find an ACI in file $2 with a matching pattern $1.
4457b57459abSJulian Pullen# Delete the ACI and print a message using $3 as the ACI name. $3 is needed
4458b57459abSJulian Pullen# because it could have a different value than that of $1.
4459b57459abSJulian Pullenfind_and_delete_ACI()
4460b57459abSJulian Pullen{
4461b57459abSJulian Pullen    [ $DEBUG -eq 1 ] && ${ECHO} "In find_and_delete_ACI"
4462b57459abSJulian Pullen
4463b57459abSJulian Pullen    # if an ACI with pattern $1 exists in file $2, delete it from ${LDAP_BASEDN}
4464b57459abSJulian Pullen    ${EGREP} $1 $2 | ${SED} -e 's/aci=//' > ${TMPDIR}/grep_find_delete_aci 2>&1
4465b57459abSJulian Pullen    if [ -s ${TMPDIR}/grep_find_delete_aci ]; then
4466b57459abSJulian Pullen	aci_to_delete=`${CAT} ${TMPDIR}/grep_find_delete_aci`
4467b57459abSJulian Pullen
4468b57459abSJulian Pullen	# Create the tmp file to delete the ACI.
4469b57459abSJulian Pullen	( cat <<EOF
4470b57459abSJulian Pullendn: ${LDAP_BASEDN}
4471b57459abSJulian Pullenchangetype: modify
4472b57459abSJulian Pullendelete: aci
4473b57459abSJulian Pullenaci: ${aci_to_delete}
4474b57459abSJulian PullenEOF
4475b57459abSJulian Pullen	) > ${TMPDIR}/find_delete_aci
4476b57459abSJulian Pullen
4477b57459abSJulian Pullen	# Delete the ACI
4478b57459abSJulian Pullen	${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/find_delete_aci ${VERB}"
4479b57459abSJulian Pullen	if [ $? -ne 0 ]; then
4480b57459abSJulian Pullen	    ${ECHO} "  ERROR: Remove of $3 ACI failed!"
4481b57459abSJulian Pullen	    cleanup
4482b57459abSJulian Pullen	    exit 1
4483b57459abSJulian Pullen	fi
4484b57459abSJulian Pullen
4485b57459abSJulian Pullen	${RM} -f ${TMPDIR}/find_delete_aci
4486b57459abSJulian Pullen	# Display message that an ACL is deleted.
4487b57459abSJulian Pullen	MSG="ACI $3 deleted."
4488b57459abSJulian Pullen	if [ $EXISTING_PROFILE -eq 1 ]; then
4489b57459abSJulian Pullen	    ${ECHO} "  ACI DELETED: $MSG"
4490b57459abSJulian Pullen	else
4491b57459abSJulian Pullen	    ${ECHO} "  ${STEP}. $MSG"
4492b57459abSJulian Pullen	    STEP=`expr $STEP + 1`
4493b57459abSJulian Pullen	fi
4494b57459abSJulian Pullen    fi
4495b57459abSJulian Pullen}
4496b57459abSJulian Pullen
4497b57459abSJulian Pullen#
4498b57459abSJulian Pullen# Add an ACI to deny non-admin access to shadow data when
4499b57459abSJulian Pullen# shadow update is enabled.
4500b57459abSJulian Pullen#
4501b57459abSJulian Pullendeny_non_admin_shadow_access()
4502b57459abSJulian Pullen{
4503b57459abSJulian Pullen    [ $DEBUG -eq 1 ] && ${ECHO} "In deny_non_admin_shadow_access()"
4504b57459abSJulian Pullen
4505b57459abSJulian Pullen    # Set ACI Names
4506b57459abSJulian Pullen    ACI_TO_ADD="LDAP_Naming_Services_deny_non_admin_shadow_access"
4507b57459abSJulian Pullen    ACI_TO_DEL="LDAP_Naming_Services_deny_non_host_shadow_access"
4508b57459abSJulian Pullen
4509b57459abSJulian Pullen    # Search for ACI_TO_ADD
4510b57459abSJulian Pullen    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_BASEDN}\" -s base objectclass=* aci > ${TMPDIR}/chk_aci_non_admin 2>&1"
4511b57459abSJulian Pullen    if [ $? -ne 0 ]; then
4512b57459abSJulian Pullen	${ECHO} "Error searching aci for ${LDAP_BASEDN}"
4513b57459abSJulian Pullen	cleanup
4514b57459abSJulian Pullen	exit 1
4515b57459abSJulian Pullen    fi
4516b57459abSJulian Pullen
4517b57459abSJulian Pullen    # If an ACI with ${ACI_TO_ADD} already exists, we are done.
4518b57459abSJulian Pullen    ${EGREP} ${ACI_TO_ADD} ${TMPDIR}/chk_aci_non_admin 2>&1 > /dev/null
4519b57459abSJulian Pullen    if [ $? -eq 0 ]; then
4520b57459abSJulian Pullen	MSG="ACI ${ACI_TO_ADD} already set for ${LDAP_BASEDN}."
4521b57459abSJulian Pullen	if [ $EXISTING_PROFILE -eq 1 ]; then
4522b57459abSJulian Pullen	    ${ECHO} "  NOT SET: $MSG"
4523b57459abSJulian Pullen	else
4524b57459abSJulian Pullen	    ${ECHO} "  ${STEP}. $MSG"
4525b57459abSJulian Pullen	    STEP=`expr $STEP + 1`
4526b57459abSJulian Pullen	fi
4527b57459abSJulian Pullen	return 0
4528b57459abSJulian Pullen    fi
4529b57459abSJulian Pullen
4530b57459abSJulian Pullen    # The deny_non_admin_shadow_access and deny_non_host_shadow_access ACIs
4531b57459abSJulian Pullen    # should be mutually exclusive, so if the latter exists, delete it.
4532b57459abSJulian Pullen    find_and_delete_ACI ${ACI_TO_DEL} ${TMPDIR}/chk_aci_non_admin ${ACI_TO_DEL}
4533b57459abSJulian Pullen
4534b57459abSJulian Pullen    # Create the tmp file to add.
4535b57459abSJulian Pullen    ( cat <<EOF
4536b57459abSJulian Pullendn: ${LDAP_BASEDN}
4537b57459abSJulian Pullenchangetype: modify
4538b57459abSJulian Pullenadd: aci
4539b57459abSJulian Pullenaci: (target="ldap:///${LDAP_BASEDN}")(targetattr = "shadowLastChange||
4540b57459abSJulian Pullen shadowMin|| shadowMax||shadowWarning||shadowInactive||shadowExpire||
4541b57459abSJulian Pullen shadowFlag||userPassword") (version 3.0; acl ${ACI_TO_ADD};
4542b57459abSJulian Pullen deny (write,read,search,compare) userdn != "ldap:///${LDAP_ADMINDN}";)
4543b57459abSJulian PullenEOF
4544b57459abSJulian Pullen) > ${TMPDIR}/non_admin_aci_write
4545b57459abSJulian Pullen
4546b57459abSJulian Pullen    # Add the entry.
4547b57459abSJulian Pullen    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/non_admin_aci_write ${VERB}"
4548b57459abSJulian Pullen    if [ $? -ne 0 ]; then
4549b57459abSJulian Pullen	${ECHO} "  ERROR: Adding ACI ${ACI_TO_ADD} failed!"
4550b57459abSJulian Pullen	${CAT} ${TMPDIR}/non_admin_aci_write
4551b57459abSJulian Pullen	cleanup
4552b57459abSJulian Pullen	exit 1
4553b57459abSJulian Pullen    fi
4554b57459abSJulian Pullen
4555b57459abSJulian Pullen    ${RM} -f ${TMPDIR}/non_admin_aci_write
4556b57459abSJulian Pullen    # Display message that the non-admin access to shadow data is denied.
4557b57459abSJulian Pullen    MSG="Non-Admin access to shadow data denied."
4558b57459abSJulian Pullen    if [ $EXISTING_PROFILE -eq 1 ]; then
4559b57459abSJulian Pullen	${ECHO} "  ACI SET: $MSG"
4560b57459abSJulian Pullen    else
4561b57459abSJulian Pullen	${ECHO} "  ${STEP}. $MSG"
4562b57459abSJulian Pullen	STEP=`expr $STEP + 1`
4563b57459abSJulian Pullen    fi
4564b57459abSJulian Pullen}
4565b57459abSJulian Pullen
4566b57459abSJulian Pullen#
4567b57459abSJulian Pullen# Add an ACI to deny non-host access to shadow data when
4568b57459abSJulian Pullen# shadow update is enabled and auth Method if gssapi.
4569b57459abSJulian Pullen#
4570b57459abSJulian Pullendeny_non_host_shadow_access()
4571b57459abSJulian Pullen{
4572b57459abSJulian Pullen    [ $DEBUG -eq 1 ] && ${ECHO} "In deny_non_host_shadow_access()"
4573b57459abSJulian Pullen
4574b57459abSJulian Pullen    # Set ACI Names
4575b57459abSJulian Pullen    ACI_TO_ADD="LDAP_Naming_Services_deny_non_host_shadow_access"
4576b57459abSJulian Pullen    ACI_TO_DEL="LDAP_Naming_Services_deny_non_admin_shadow_access"
4577b57459abSJulian Pullen
4578b57459abSJulian Pullen    # Search for ACI_TO_ADD
4579b57459abSJulian Pullen    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_BASEDN}\" -s base objectclass=* aci > ${TMPDIR}/chk_aci_non_host 2>&1"
4580b57459abSJulian Pullen    if [ $? -ne 0 ]; then
4581b57459abSJulian Pullen	${ECHO} "Error searching aci for ${LDAP_BASEDN}"
4582b57459abSJulian Pullen	cleanup
4583b57459abSJulian Pullen	exit 1
4584b57459abSJulian Pullen    fi
4585b57459abSJulian Pullen
4586b57459abSJulian Pullen    # If an ACI with ${ACI_TO_ADD} already exists, we are done.
4587b57459abSJulian Pullen    ${EGREP} ${ACI_TO_ADD} ${TMPDIR}/chk_aci_non_host 2>&1 > /dev/null
4588b57459abSJulian Pullen    if [ $? -eq 0 ]; then
4589b57459abSJulian Pullen	MSG="ACI ${ACI_TO_ADD} already set for ${LDAP_BASEDN}."
4590b57459abSJulian Pullen	if [ $EXISTING_PROFILE -eq 1 ]; then
4591b57459abSJulian Pullen	    ${ECHO} "  NOT SET: $MSG"
4592b57459abSJulian Pullen	else
4593b57459abSJulian Pullen	    ${ECHO} "  ${STEP}. $MSG"
4594b57459abSJulian Pullen	    STEP=`expr $STEP + 1`
4595b57459abSJulian Pullen	fi
4596b57459abSJulian Pullen	return 0
4597b57459abSJulian Pullen    fi
4598b57459abSJulian Pullen
4599b57459abSJulian Pullen    # The deny_non_admin_shadow_access and deny_non_host_shadow_access ACIs
4600b57459abSJulian Pullen    # should be mutually exclusive, so if the former exists, delete it.
4601b57459abSJulian Pullen    find_and_delete_ACI ${ACI_TO_DEL} ${TMPDIR}/chk_aci_non_host ${ACI_TO_DEL}
4602b57459abSJulian Pullen
4603b57459abSJulian Pullen    # Create the tmp file to add.
4604b57459abSJulian Pullen    ( cat <<EOF
4605b57459abSJulian Pullendn: ${LDAP_BASEDN}
4606b57459abSJulian Pullenchangetype: modify
4607b57459abSJulian Pullenadd: aci
4608b57459abSJulian Pullenaci: (target="ldap:///${LDAP_BASEDN}")(targetattr = "shadowLastChange||
4609b57459abSJulian Pullen shadowMin|| shadowMax||shadowWarning||shadowInactive||shadowExpire||
4610b57459abSJulian Pullen shadowFlag||userPassword") (version 3.0; acl ${ACI_TO_ADD};
4611b57459abSJulian Pullen  deny (write,read,search,compare)
4612b57459abSJulian Pullen  userdn != "ldap:///cn=*+ipHostNumber=*,ou=Hosts,${LDAP_BASEDN}";)
4613b57459abSJulian PullenEOF
4614b57459abSJulian Pullen) > ${TMPDIR}/non_host_aci_write
4615b57459abSJulian Pullen
4616b57459abSJulian Pullen    # Add the entry.
4617b57459abSJulian Pullen    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/non_host_aci_write ${VERB}"
4618b57459abSJulian Pullen    if [ $? -ne 0 ]; then
4619b57459abSJulian Pullen	${ECHO} "  ERROR: Adding ACI ${ACI_TO_ADD} failed!"
4620b57459abSJulian Pullen	${CAT} ${TMPDIR}/non_host_aci_write
4621b57459abSJulian Pullen	cleanup
4622b57459abSJulian Pullen	exit 1
4623b57459abSJulian Pullen    fi
4624b57459abSJulian Pullen
4625b57459abSJulian Pullen    ${RM} -f ${TMPDIR}/non_host_aci_write
4626b57459abSJulian Pullen    # Display message that the non-host access to shadow data is denied.
4627b57459abSJulian Pullen    MSG="Non-host access to shadow data is denied."
4628b57459abSJulian Pullen    if [ $EXISTING_PROFILE -eq 1 ]; then
4629b57459abSJulian Pullen	${ECHO} "  ACI SET: $MSG"
4630b57459abSJulian Pullen    else
4631b57459abSJulian Pullen	${ECHO} "  ${STEP}. $MSG"
4632b57459abSJulian Pullen	STEP=`expr $STEP + 1`
4633b57459abSJulian Pullen    fi
4634b57459abSJulian Pullen}
4635b57459abSJulian Pullen
4636b57459abSJulian Pullen#
46377c478bd9Sstevel@tonic-gate# add_vlv_aci(): Add access control information (aci) for VLV.
46387c478bd9Sstevel@tonic-gate#
46397c478bd9Sstevel@tonic-gateadd_vlv_aci()
46407c478bd9Sstevel@tonic-gate{
46417c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In add_vlv_aci()"
46427c478bd9Sstevel@tonic-gate
46437c478bd9Sstevel@tonic-gate    # Add the VLV ACI.
46447c478bd9Sstevel@tonic-gate    ( cat <<EOF
46457c478bd9Sstevel@tonic-gatedn: oid=2.16.840.1.113730.3.4.9,cn=features,cn=config
46467c478bd9Sstevel@tonic-gatechangetype: modify
46477c478bd9Sstevel@tonic-gatereplace: aci
46487c478bd9Sstevel@tonic-gateaci: (targetattr != "aci") (version 3.0; acl "VLV Request Control"; allow(read,search,compare) userdn = "ldap:///anyone";)
46497c478bd9Sstevel@tonic-gateEOF
46507c478bd9Sstevel@tonic-gate) > ${TMPDIR}/vlv_aci
46517c478bd9Sstevel@tonic-gate
46527c478bd9Sstevel@tonic-gate    # Add the entry.
46537c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/vlv_aci ${VERB}"
46547c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
46557c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: Add of VLV ACI failed!"
46567c478bd9Sstevel@tonic-gate	cleanup
46577c478bd9Sstevel@tonic-gate	exit 1
46587c478bd9Sstevel@tonic-gate    fi
46597c478bd9Sstevel@tonic-gate
46607c478bd9Sstevel@tonic-gate    # Display message that schema is updated.
46617c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Add of VLV Access Control Information (ACI)."
46627c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
46637c478bd9Sstevel@tonic-gate}
46647c478bd9Sstevel@tonic-gate
46657c478bd9Sstevel@tonic-gate
46667c478bd9Sstevel@tonic-gate#
46677c478bd9Sstevel@tonic-gate# set_nisdomain(): Add the NisDomainObject to the Base DN.
46687c478bd9Sstevel@tonic-gate#
46697c478bd9Sstevel@tonic-gateset_nisdomain()
46707c478bd9Sstevel@tonic-gate{
46717c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In set_nisdomain()"
46727c478bd9Sstevel@tonic-gate
46737c478bd9Sstevel@tonic-gate    # Check if nisDomain is already set.
4674017e8b01Svl199446    ${EVAL} "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_BASEDN}\" -s base \
4675017e8b01Svl199446	\"objectclass=*\"" > ${TMPDIR}/chk_nisdomain 2>&1
4676017e8b01Svl199446    ${EVAL} "${GREP} -i nisDomain ${TMPDIR}/chk_nisdomain ${VERB}"
46777c478bd9Sstevel@tonic-gate    if [ $? -eq 0 ]; then
46787c478bd9Sstevel@tonic-gate	${ECHO} "  ${STEP}. NisDomainObject for ${LDAP_BASEDN} was already set."
46797c478bd9Sstevel@tonic-gate	STEP=`expr $STEP + 1`
46807c478bd9Sstevel@tonic-gate	return 0
46817c478bd9Sstevel@tonic-gate    fi
46827c478bd9Sstevel@tonic-gate
46837c478bd9Sstevel@tonic-gate    # Add the new top level containers.
46847c478bd9Sstevel@tonic-gate    ( cat <<EOF
46857c478bd9Sstevel@tonic-gatedn: ${LDAP_BASEDN}
46867c478bd9Sstevel@tonic-gatechangetype: modify
46877c478bd9Sstevel@tonic-gateobjectclass: nisDomainObject
46887c478bd9Sstevel@tonic-gatenisdomain: ${LDAP_DOMAIN}
46897c478bd9Sstevel@tonic-gateEOF
46907c478bd9Sstevel@tonic-gate) > ${TMPDIR}/nis_domain
46917c478bd9Sstevel@tonic-gate
46927c478bd9Sstevel@tonic-gate    # Add the entry.
46937c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/nis_domain ${VERB}"
46947c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
46957c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: update of NisDomainObject in ${LDAP_BASEDN} failed."
46967c478bd9Sstevel@tonic-gate	cleanup
46977c478bd9Sstevel@tonic-gate	exit 1
46987c478bd9Sstevel@tonic-gate    fi
46997c478bd9Sstevel@tonic-gate
47007c478bd9Sstevel@tonic-gate    # Display message that schema is updated.
47017c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. NisDomainObject added to ${LDAP_BASEDN}."
47027c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
47037c478bd9Sstevel@tonic-gate}
47047c478bd9Sstevel@tonic-gate
47057c478bd9Sstevel@tonic-gate
47067c478bd9Sstevel@tonic-gate#
47077c478bd9Sstevel@tonic-gate# check_attrName(): Check that the attribute name is valid.
47087c478bd9Sstevel@tonic-gate#              $1   Key to check.
47097c478bd9Sstevel@tonic-gate#         Returns   0 : valid name	1 : invalid name
47107c478bd9Sstevel@tonic-gate#
47117c478bd9Sstevel@tonic-gatecheck_attrName()
47127c478bd9Sstevel@tonic-gate{
47137c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In check_attrName()"
47147c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "check_attrName: Input Param = $1"
47157c478bd9Sstevel@tonic-gate
47167c478bd9Sstevel@tonic-gate    ${ECHO} $1 | ${EGREP} '^[0-9]+(\.[0-9]+)*$' > /dev/null 2>&1
47177c478bd9Sstevel@tonic-gate    if [ $? -eq 0 ]; then
47187c478bd9Sstevel@tonic-gate	${EVAL} "${LDAPSEARCH} ${SERVER_ARGS} -b cn=schema -s base \"objectclass=*\" \
47197c478bd9Sstevel@tonic-gate			attributeTypes | ${EGREP} -i '^attributetypes[ ]*=[ ]*\([ ]*$1 ' ${VERB}"
47207c478bd9Sstevel@tonic-gate    else
47217c478bd9Sstevel@tonic-gate	${EVAL} "${LDAPSEARCH} ${SERVER_ARGS} -b cn=schema -s base \"objectclass=*\" \
47227c478bd9Sstevel@tonic-gate			attributeTypes | ${EGREP} -i \"'$1'\" ${VERB}"
47237c478bd9Sstevel@tonic-gate    fi
47247c478bd9Sstevel@tonic-gate
47257c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
47267c478bd9Sstevel@tonic-gate	return 1
47277c478bd9Sstevel@tonic-gate    else
47287c478bd9Sstevel@tonic-gate	return 0
47297c478bd9Sstevel@tonic-gate    fi
47307c478bd9Sstevel@tonic-gate}
47317c478bd9Sstevel@tonic-gate
47327c478bd9Sstevel@tonic-gate
47337c478bd9Sstevel@tonic-gate#
47347c478bd9Sstevel@tonic-gate# get_objectclass():   Determine the objectclass for the given attribute name
47357c478bd9Sstevel@tonic-gate#              $1   Attribute name to check.
47367c478bd9Sstevel@tonic-gate#      _ATTR_NAME   Return value, Object Name or NULL if unknown to idsconfig.
47377c478bd9Sstevel@tonic-gate#
47387c478bd9Sstevel@tonic-gate#      NOTE: An attribute name can be valid but still we might not be able
47397c478bd9Sstevel@tonic-gate#            to determine the objectclass from the table.
47407c478bd9Sstevel@tonic-gate#            In such cases, the user needs to create the necessary object(s).
47417c478bd9Sstevel@tonic-gate#
47427c478bd9Sstevel@tonic-gateget_objectclass()
47437c478bd9Sstevel@tonic-gate{
47447c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In get_objectclass()"
47457c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "get_objectclass: Input Param = $1"
47467c478bd9Sstevel@tonic-gate
47477c478bd9Sstevel@tonic-gate    # Set return value to NULL string.
47487c478bd9Sstevel@tonic-gate    _ATTR_NAME=""
47497c478bd9Sstevel@tonic-gate
47507c478bd9Sstevel@tonic-gate    # Test key for type:
47517c478bd9Sstevel@tonic-gate    case `${ECHO} ${1} | tr '[A-Z]' '[a-z]'` in
47527c478bd9Sstevel@tonic-gate	ou | organizationalunitname | 2.5.4.11) _ATTR_NAME="organizationalUnit" ;;
47537c478bd9Sstevel@tonic-gate	dc | domaincomponent | 0.9.2342.19200300.100.1.25) _ATTR_NAME="domain" ;;
47547c478bd9Sstevel@tonic-gate	 o | organizationname | 2.5.4.10) _ATTR_NAME="organization" ;;
47557c478bd9Sstevel@tonic-gate	 c | countryname | 2.5.4.6) _ATTR_NAME="country" ;;
47567c478bd9Sstevel@tonic-gate	 *)  _ATTR_NAME="" ;;
47577c478bd9Sstevel@tonic-gate    esac
47587c478bd9Sstevel@tonic-gate
47597c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "get_objectclass: _ATTR_NAME = $_ATTR_NAME"
47607c478bd9Sstevel@tonic-gate}
47617c478bd9Sstevel@tonic-gate
47627c478bd9Sstevel@tonic-gate
47637c478bd9Sstevel@tonic-gate#
47647c478bd9Sstevel@tonic-gate# add_base_objects(): Add any necessary base objects.
47657c478bd9Sstevel@tonic-gate#
47667c478bd9Sstevel@tonic-gateadd_base_objects()
47677c478bd9Sstevel@tonic-gate{
47687c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In add_base_objects()"
47697c478bd9Sstevel@tonic-gate
47707c478bd9Sstevel@tonic-gate    # Convert to lower case for basename.
47717c478bd9Sstevel@tonic-gate    format_string "${LDAP_BASEDN}"
47727c478bd9Sstevel@tonic-gate    LOWER_BASEDN="${FMT_STR}"
47737c478bd9Sstevel@tonic-gate    format_string "${LDAP_SUFFIX}"
47747c478bd9Sstevel@tonic-gate    LOWER_SUFFIX="${FMT_STR}"
47757c478bd9Sstevel@tonic-gate
47767c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "LOWER_BASEDN: ${LOWER_BASEDN}"
47777c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "LOWER_SUFFIX: ${LOWER_SUFFIX}"
47787c478bd9Sstevel@tonic-gate
47797c478bd9Sstevel@tonic-gate    # Create additional components.
47807c478bd9Sstevel@tonic-gate    if [ "${LOWER_BASEDN}" = "${LOWER_SUFFIX}" ]; then
47817c478bd9Sstevel@tonic-gate	[ $DEBUG -eq 1 ] && ${ECHO} "Base DN and Suffix equivalent"
47827c478bd9Sstevel@tonic-gate    else
47837c478bd9Sstevel@tonic-gate	# first, test that the suffix is valid
47847c478bd9Sstevel@tonic-gate	dcstmp=`basename "${LOWER_BASEDN}" "${LOWER_SUFFIX}"`
47857c478bd9Sstevel@tonic-gate	if [ "$dcstmp" = "${LOWER_BASEDN}" ]; then
47867c478bd9Sstevel@tonic-gate	    # should not happen since check_basedn_suffix() succeeded
47877c478bd9Sstevel@tonic-gate	    ${ECHO} "Invalid suffix ${LOWER_SUFFIX}"
47887c478bd9Sstevel@tonic-gate	    ${ECHO} "for Base DN ${LOWER_BASEDN}"
47897c478bd9Sstevel@tonic-gate	    cleanup
47907c478bd9Sstevel@tonic-gate	    exit 1
47917c478bd9Sstevel@tonic-gate	fi
47927c478bd9Sstevel@tonic-gate	# OK, suffix is valid, start working with LDAP_BASEDN
47937c478bd9Sstevel@tonic-gate	# field separator is ',' (i.e., space is a valid character)
47947c478bd9Sstevel@tonic-gate	dcstmp2="`${ECHO} ${LDAP_BASEDN} |
47957c478bd9Sstevel@tonic-gate		sed -e 's/[ ]*,[ ]*/,/g' -e 's/[ ]*=[ ]*/=/g'`"
47967c478bd9Sstevel@tonic-gate	dcs=""
47977c478bd9Sstevel@tonic-gate	# use dcstmp to count the loop, and dcstmp2 to get the correct
47987c478bd9Sstevel@tonic-gate	# string case
47997c478bd9Sstevel@tonic-gate	# dcs should be in reverse order, only for these components
48007c478bd9Sstevel@tonic-gate	# that need to be added
48017c478bd9Sstevel@tonic-gate	while [ -n "${dcstmp}" ]
48027c478bd9Sstevel@tonic-gate	do
48037c478bd9Sstevel@tonic-gate	    i2=`${ECHO} "$dcstmp2" | cut -f1 -d','`
48047c478bd9Sstevel@tonic-gate	    dk=`${ECHO} $i2 | awk -F= '{print $1}'`
48057c478bd9Sstevel@tonic-gate	    dc=`${ECHO} $i2 | awk -F= '{print $2}'`
48067c478bd9Sstevel@tonic-gate	    dcs="$dk=$dc,$dcs";
48077c478bd9Sstevel@tonic-gate	    dcstmp2=`${ECHO} "$dcstmp2" | cut -f2- -d','`
48087c478bd9Sstevel@tonic-gate	    dcstmp=`${ECHO} "$dcstmp" | cut -f2- -d','`
48097c478bd9Sstevel@tonic-gate	    [ $DEBUG -eq 1 ] && \
48107c478bd9Sstevel@tonic-gate		${ECHO} "dcs: ${dcs}\ndcstmp: ${dcstmp}\ndcstmp2: ${dcstmp2}\n"
48117c478bd9Sstevel@tonic-gate	done
48127c478bd9Sstevel@tonic-gate
48137c478bd9Sstevel@tonic-gate
48147c478bd9Sstevel@tonic-gate
48157c478bd9Sstevel@tonic-gate	lastdc=${LDAP_SUFFIX}
48167c478bd9Sstevel@tonic-gate	dc=`${ECHO} "${dcs}" | cut -f1 -d','`
48177c478bd9Sstevel@tonic-gate	dcstmp=`${ECHO} "${dcs}" | cut -f2- -d','`
48187c478bd9Sstevel@tonic-gate	while [ -n "${dc}" ]; do
48197c478bd9Sstevel@tonic-gate	    # Get Key and component from $dc.
48207c478bd9Sstevel@tonic-gate	    dk2=`${ECHO} $dc | awk -F= '{print $1}'`
48217c478bd9Sstevel@tonic-gate	    dc2=`${ECHO} $dc | awk -F= '{print $2}'`
48227c478bd9Sstevel@tonic-gate
48237c478bd9Sstevel@tonic-gate	    # At this point, ${dk2} is a valid attribute name
48247c478bd9Sstevel@tonic-gate
48257c478bd9Sstevel@tonic-gate	    # Check if entry exists first, if so, skip to next.
48267c478bd9Sstevel@tonic-gate	    ${LDAPSEARCH} ${SERVER_ARGS} -b "${dk2}=${dc2},$lastdc" -s base "objectclass=*" > /dev/null 2>&1
48277c478bd9Sstevel@tonic-gate	    if [ $? -eq 0 ]; then
48287c478bd9Sstevel@tonic-gate	        # Set the $lastdc to new dc.
48297c478bd9Sstevel@tonic-gate	        lastdc="${dk2}=${dc2},$lastdc"
48307c478bd9Sstevel@tonic-gate
48317c478bd9Sstevel@tonic-gate		# Process next component.
48327c478bd9Sstevel@tonic-gate		dc=`${ECHO} "${dcstmp}" | cut -f1 -d','`
48337c478bd9Sstevel@tonic-gate		dcstmp=`${ECHO} "${dcstmp}" | cut -f2- -d','`
48347c478bd9Sstevel@tonic-gate		continue
48357c478bd9Sstevel@tonic-gate
48367c478bd9Sstevel@tonic-gate	    fi
48377c478bd9Sstevel@tonic-gate
48387c478bd9Sstevel@tonic-gate	    # Determine the objectclass for the entry.
48397c478bd9Sstevel@tonic-gate            get_objectclass $dk2
48407c478bd9Sstevel@tonic-gate	    OBJ_Name=${_ATTR_NAME}
48417c478bd9Sstevel@tonic-gate	    if [ "${OBJ_Name}" = "" ]; then
48427c478bd9Sstevel@tonic-gate	        ${ECHO} "Cannot determine objectclass for $dk2"
48437c478bd9Sstevel@tonic-gate	        ${ECHO} "Please create ${dk2}=${dc2},$lastdc entry and rerun idsconfig"
48447c478bd9Sstevel@tonic-gate	        exit 1
48457c478bd9Sstevel@tonic-gate	    fi
48467c478bd9Sstevel@tonic-gate
48477c478bd9Sstevel@tonic-gate	    # Add the new container.
48487c478bd9Sstevel@tonic-gate	    ( cat <<EOF
48497c478bd9Sstevel@tonic-gatedn: ${dk2}=${dc2},$lastdc
48507c478bd9Sstevel@tonic-gate${dk2}: $dc2
48517c478bd9Sstevel@tonic-gateobjectClass: top
48527c478bd9Sstevel@tonic-gateobjectClass: ${OBJ_Name}
48537c478bd9Sstevel@tonic-gateEOF
48547c478bd9Sstevel@tonic-gate) > ${TMPDIR}/base_objects
48557c478bd9Sstevel@tonic-gate
48567c478bd9Sstevel@tonic-gate
48577c478bd9Sstevel@tonic-gate	    # Set the $lastdc to new dc.
48587c478bd9Sstevel@tonic-gate	    lastdc="${dk2}=${dc2},$lastdc"
48597c478bd9Sstevel@tonic-gate
48607c478bd9Sstevel@tonic-gate	    # Add the entry.
48617c478bd9Sstevel@tonic-gate	    ${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/base_objects ${VERB}"
48627c478bd9Sstevel@tonic-gate	    if [ $? -ne 0 ]; then
48637c478bd9Sstevel@tonic-gate		${ECHO} "  ERROR: update of base objects ${dc} failed."
48647c478bd9Sstevel@tonic-gate		cleanup
48657c478bd9Sstevel@tonic-gate		exit 1
48667c478bd9Sstevel@tonic-gate	    fi
48677c478bd9Sstevel@tonic-gate
48687c478bd9Sstevel@tonic-gate	    # Display message that schema is updated.
48697c478bd9Sstevel@tonic-gate	    ${ECHO} "  ${STEP}. Created DN component ${dc}."
48707c478bd9Sstevel@tonic-gate	    STEP=`expr $STEP + 1`
48717c478bd9Sstevel@tonic-gate
48727c478bd9Sstevel@tonic-gate	    # Process next component.
48737c478bd9Sstevel@tonic-gate	    dc=`${ECHO} "${dcstmp}" | cut -f1 -d','`
48747c478bd9Sstevel@tonic-gate	    dcstmp=`${ECHO} "${dcstmp}" | cut -f2- -d','`
48757c478bd9Sstevel@tonic-gate	done
48767c478bd9Sstevel@tonic-gate    fi
48777c478bd9Sstevel@tonic-gate}
48787c478bd9Sstevel@tonic-gate
48797c478bd9Sstevel@tonic-gate
48807c478bd9Sstevel@tonic-gate#
48817c478bd9Sstevel@tonic-gate# add_new_containers(): Add the top level classes.
48827c478bd9Sstevel@tonic-gate#
48837c478bd9Sstevel@tonic-gate#    $1 = Base DN
48847c478bd9Sstevel@tonic-gate#
48857c478bd9Sstevel@tonic-gateadd_new_containers()
48867c478bd9Sstevel@tonic-gate{
48877c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In add_new_containers()"
48887c478bd9Sstevel@tonic-gate
48897c478bd9Sstevel@tonic-gate    for ou in people group rpc protocols networks netgroup \
4890a58015d1Svl199446	aliases hosts services ethers profile printers projects \
489145916cd2Sjpk	SolarisAuthAttr SolarisProfAttr Timezone ipTnet ; do
48927c478bd9Sstevel@tonic-gate
48937c478bd9Sstevel@tonic-gate	# Check if nismaps already exist.
48947c478bd9Sstevel@tonic-gate	eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"ou=${ou},${LDAP_BASEDN}\" -s base \"objectclass=*\" ${VERB}"
48957c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
48967c478bd9Sstevel@tonic-gate	    continue
48977c478bd9Sstevel@tonic-gate	fi
48987c478bd9Sstevel@tonic-gate
48997c478bd9Sstevel@tonic-gate	# Create TMP file to add.
49007c478bd9Sstevel@tonic-gate	( cat <<EOF
49017c478bd9Sstevel@tonic-gatedn: ou=${ou},${LDAP_BASEDN}
49027c478bd9Sstevel@tonic-gateou: ${ou}
49037c478bd9Sstevel@tonic-gateobjectClass: top
49047c478bd9Sstevel@tonic-gateobjectClass: organizationalUnit
49057c478bd9Sstevel@tonic-gateEOF
49067c478bd9Sstevel@tonic-gate) > ${TMPDIR}/toplevel.${ou}
49077c478bd9Sstevel@tonic-gate
49087c478bd9Sstevel@tonic-gate	# Add the entry.
49097c478bd9Sstevel@tonic-gate	${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/toplevel.${ou} ${VERB}"
49107c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]; then
49117c478bd9Sstevel@tonic-gate	    ${ECHO} "  ERROR: Add of ou=${ou} container failed!"
49127c478bd9Sstevel@tonic-gate	    cleanup
49137c478bd9Sstevel@tonic-gate	    exit 1
49147c478bd9Sstevel@tonic-gate	fi
49157c478bd9Sstevel@tonic-gate    done
49167c478bd9Sstevel@tonic-gate
49177c478bd9Sstevel@tonic-gate    # Display message that top level OU containers complete.
49187c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Top level \"ou\" containers complete."
49197c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
49207c478bd9Sstevel@tonic-gate}
49217c478bd9Sstevel@tonic-gate
49227c478bd9Sstevel@tonic-gate
49237c478bd9Sstevel@tonic-gate#
49247c478bd9Sstevel@tonic-gate# add_auto_maps(): Add the automount map entries.
49257c478bd9Sstevel@tonic-gate#
49267c478bd9Sstevel@tonic-gate# auto_home, auto_direct, auto_master, auto_shared
49277c478bd9Sstevel@tonic-gate#
49287c478bd9Sstevel@tonic-gateadd_auto_maps()
49297c478bd9Sstevel@tonic-gate{
49307c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In add_auto_maps()"
49317c478bd9Sstevel@tonic-gate
49327c478bd9Sstevel@tonic-gate    # Set AUTO_MAPS for maps to create.
49337c478bd9Sstevel@tonic-gate    AUTO_MAPS="auto_home auto_direct auto_master auto_shared"
49347c478bd9Sstevel@tonic-gate
49357c478bd9Sstevel@tonic-gate    for automap in $AUTO_MAPS; do
49367c478bd9Sstevel@tonic-gate	# Check if automaps already exist.
49377c478bd9Sstevel@tonic-gate	eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"automountMapName=${automap},${LDAP_BASEDN}\" -s base \"objectclass=*\" ${VERB}"
49387c478bd9Sstevel@tonic-gate	if [ $? -eq 0 ]; then
49397c478bd9Sstevel@tonic-gate	    continue
49407c478bd9Sstevel@tonic-gate	fi
49417c478bd9Sstevel@tonic-gate
49427c478bd9Sstevel@tonic-gate	# Create the tmp file to add.
49437c478bd9Sstevel@tonic-gate	( cat <<EOF
49447c478bd9Sstevel@tonic-gatedn: automountMapName=${automap},${LDAP_BASEDN}
49457c478bd9Sstevel@tonic-gateautomountMapName: ${automap}
49467c478bd9Sstevel@tonic-gateobjectClass: top
49477c478bd9Sstevel@tonic-gateobjectClass: automountMap
49487c478bd9Sstevel@tonic-gateEOF
49497c478bd9Sstevel@tonic-gate) > ${TMPDIR}/automap.${automap}
49507c478bd9Sstevel@tonic-gate
49517c478bd9Sstevel@tonic-gate	# Add the entry.
49527c478bd9Sstevel@tonic-gate	${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/automap.${automap} ${VERB}"
49537c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]; then
49547c478bd9Sstevel@tonic-gate	    ${ECHO} "  ERROR: Add of automap ${automap} failed!"
49557c478bd9Sstevel@tonic-gate	    cleanup
49567c478bd9Sstevel@tonic-gate	    exit 1
49577c478bd9Sstevel@tonic-gate	fi
49587c478bd9Sstevel@tonic-gate    done
49597c478bd9Sstevel@tonic-gate
49607c478bd9Sstevel@tonic-gate    # Display message that automount entries are updated.
49617c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. automount maps: $AUTO_MAPS processed."
49627c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
49637c478bd9Sstevel@tonic-gate}
49647c478bd9Sstevel@tonic-gate
49657c478bd9Sstevel@tonic-gate
49667c478bd9Sstevel@tonic-gate#
49677c478bd9Sstevel@tonic-gate# add_proxyagent(): Add entry for nameservice to use to access server.
49687c478bd9Sstevel@tonic-gate#
49697c478bd9Sstevel@tonic-gateadd_proxyagent()
49707c478bd9Sstevel@tonic-gate{
49717c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In add_proxyagent()"
49727c478bd9Sstevel@tonic-gate
49731d473207SMilan Jurik    # Check if proxy agent already exists.
49747c478bd9Sstevel@tonic-gate    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_PROXYAGENT}\" -s base \"objectclass=*\" ${VERB}"
49757c478bd9Sstevel@tonic-gate    if [ $? -eq 0 ]; then
49767c478bd9Sstevel@tonic-gate	${ECHO} "  ${STEP}. Proxy Agent ${LDAP_PROXYAGENT} already exists."
49777c478bd9Sstevel@tonic-gate	STEP=`expr $STEP + 1`
49787c478bd9Sstevel@tonic-gate	return 0
49797c478bd9Sstevel@tonic-gate    fi
49807c478bd9Sstevel@tonic-gate
49817c478bd9Sstevel@tonic-gate    # Get cn and sn names from LDAP_PROXYAGENT.
49827c478bd9Sstevel@tonic-gate    cn_tmp=`${ECHO} ${LDAP_PROXYAGENT} | cut -f1 -d, | cut -f2 -d=`
49837c478bd9Sstevel@tonic-gate
49847c478bd9Sstevel@tonic-gate    # Create the tmp file to add.
49857c478bd9Sstevel@tonic-gate    ( cat <<EOF
49867c478bd9Sstevel@tonic-gatedn: ${LDAP_PROXYAGENT}
49877c478bd9Sstevel@tonic-gatecn: ${cn_tmp}
49887c478bd9Sstevel@tonic-gatesn: ${cn_tmp}
49897c478bd9Sstevel@tonic-gateobjectclass: top
49907c478bd9Sstevel@tonic-gateobjectclass: person
49917c478bd9Sstevel@tonic-gateuserpassword: ${LDAP_PROXYAGENT_CRED}
49927c478bd9Sstevel@tonic-gateEOF
49937c478bd9Sstevel@tonic-gate) > ${TMPDIR}/proxyagent
49947c478bd9Sstevel@tonic-gate
49957c478bd9Sstevel@tonic-gate    # Add the entry.
49967c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/proxyagent ${VERB}"
49977c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
49987c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: Adding proxyagent failed!"
49997c478bd9Sstevel@tonic-gate	cleanup
50007c478bd9Sstevel@tonic-gate	exit 1
50017c478bd9Sstevel@tonic-gate    fi
50027c478bd9Sstevel@tonic-gate
50037c478bd9Sstevel@tonic-gate    # Display message that schema is updated.
50047c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Proxy Agent ${LDAP_PROXYAGENT} added."
50057c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
50067c478bd9Sstevel@tonic-gate}
50077c478bd9Sstevel@tonic-gate
50087c478bd9Sstevel@tonic-gate#
50097c478bd9Sstevel@tonic-gate# allow_proxy_read_pw(): Give Proxy Agent read permission for password.
50107c478bd9Sstevel@tonic-gate#
50117c478bd9Sstevel@tonic-gateallow_proxy_read_pw()
50127c478bd9Sstevel@tonic-gate{
50137c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In allow_proxy_read_pw()"
50147c478bd9Sstevel@tonic-gate
50157c478bd9Sstevel@tonic-gate    # Search for ACI_NAME
50167c478bd9Sstevel@tonic-gate    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_BASEDN}\" -s base objectclass=* aci > ${TMPDIR}/chk_proxyread_aci 2>&1"
50177c478bd9Sstevel@tonic-gate    ${GREP} "${PROXY_ACI_NAME}" ${TMPDIR}/chk_proxyread_aci > /dev/null 2>&1
50187c478bd9Sstevel@tonic-gate    if [ $? -eq 0 ]; then
50197c478bd9Sstevel@tonic-gate	${ECHO} "  ${STEP}. Proxy ACI ${PROXY_ACI_NAME=} already exists for ${LDAP_BASEDN}."
50207c478bd9Sstevel@tonic-gate	STEP=`expr $STEP + 1`
50217c478bd9Sstevel@tonic-gate	return 0
50227c478bd9Sstevel@tonic-gate    fi
50237c478bd9Sstevel@tonic-gate
50247c478bd9Sstevel@tonic-gate    # Create the tmp file to add.
50257c478bd9Sstevel@tonic-gate    ( cat <<EOF
50267c478bd9Sstevel@tonic-gatedn: ${LDAP_BASEDN}
50277c478bd9Sstevel@tonic-gatechangetype: modify
50287c478bd9Sstevel@tonic-gateadd: aci
5029b57459abSJulian Pullenaci: (target="ldap:///${LDAP_BASEDN}")(targetattr="userPassword")
5030b57459abSJulian Pullen  (version 3.0; acl ${PROXY_ACI_NAME}; allow (compare,read,search)
5031b57459abSJulian Pullen  userdn = "ldap:///${LDAP_PROXYAGENT}";)
50327c478bd9Sstevel@tonic-gateEOF
50337c478bd9Sstevel@tonic-gate) > ${TMPDIR}/proxy_read
50347c478bd9Sstevel@tonic-gate
50357c478bd9Sstevel@tonic-gate    # Add the entry.
50367c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/proxy_read ${VERB}"
50377c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
50387c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: Allow ${LDAP_PROXYAGENT} to read password failed!"
50397c478bd9Sstevel@tonic-gate	cleanup
50407c478bd9Sstevel@tonic-gate	exit 1
50417c478bd9Sstevel@tonic-gate    fi
50427c478bd9Sstevel@tonic-gate
50437c478bd9Sstevel@tonic-gate    # Display message that schema is updated.
50447c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Give ${LDAP_PROXYAGENT} read permission for password."
50457c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
50467c478bd9Sstevel@tonic-gate}
50477c478bd9Sstevel@tonic-gate
5048b57459abSJulian Pullen#  Delete Proxy Agent read permission for password.
5049b57459abSJulian Pullendelete_proxy_read_pw()
5050b57459abSJulian Pullen{
5051b57459abSJulian Pullen    [ $DEBUG -eq 1 ] && ${ECHO} "In delete_proxy_read_pw()"
5052b57459abSJulian Pullen
5053b57459abSJulian Pullen    # Search for ACI_NAME
5054b57459abSJulian Pullen    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"${LDAP_BASEDN}\" -s base objectclass=* aci > ${TMPDIR}/chk_proxyread_aci 2>&1"
5055b57459abSJulian Pullen    ${GREP} "${PROXY_ACI_NAME}" ${TMPDIR}/chk_proxyread_aci | \
5056b57459abSJulian Pullen	${SED} -e 's/aci=//' > ${TMPDIR}/grep_proxyread_aci 2>&1
5057b57459abSJulian Pullen    if [ $? -ne 0 ]; then
5058b57459abSJulian Pullen	${ECHO} "Proxy ACI ${PROXY_ACI_NAME} does not exist for ${LDAP_BASEDN}."
5059b57459abSJulian Pullen	return 0
5060b57459abSJulian Pullen    fi
5061b57459abSJulian Pullen
5062b57459abSJulian Pullen    # We need to remove proxy agent's read access to user passwords,
5063b57459abSJulian Pullen    # but We do not know the value of the ${LDAP_PROXYAGENT} here, so
5064b57459abSJulian Pullen    # 1. if only one match found, delete it
5065b57459abSJulian Pullen    # 2. if more than one matches found, ask the user which one to delete
5066b57459abSJulian Pullen    HOWMANY=`${WC} -l ${TMPDIR}/grep_proxyread_aci | ${NAWK} '{print $1}'`
5067b57459abSJulian Pullen    if [ $HOWMANY -eq 0 ]; then
5068b57459abSJulian Pullen	${ECHO} "Proxy ACI ${PROXY_ACI_NAME} does not exist for ${LDAP_BASEDN}."
5069b57459abSJulian Pullen	return 0
5070b57459abSJulian Pullen    fi
5071b57459abSJulian Pullen    if [ $HOWMANY -eq 1 ];then
5072b57459abSJulian Pullen	proxy_aci=`${CAT} ${TMPDIR}/grep_proxyread_aci`
5073b57459abSJulian Pullen    else
5074b57459abSJulian Pullen	    ${CAT} << EOF
5075b57459abSJulian Pullen
5076b57459abSJulian PullenProxy agent is not allowed to read user passwords when shadow
5077b57459abSJulian Pullenupdate is enabled. There are more than one proxy agents found.
5078b57459abSJulian PullenPlease select the currently proxy agent being used, so that
5079b57459abSJulian Pullenidsconfig can remove its read access to user passwords.
5080b57459abSJulian Pullen
5081b57459abSJulian PullenThe proxy agents are:
5082b57459abSJulian Pullen
5083b57459abSJulian PullenEOF
5084b57459abSJulian Pullen	    # generate the proxy agent list
5085b57459abSJulian Pullen    	    ${SED} -e "s/.*ldap:\/\/\/.*ldap:\/\/\///" \
5086b57459abSJulian Pullen	    ${TMPDIR}/grep_proxyread_aci | ${SED} -e "s/\";)//" > \
5087b57459abSJulian Pullen	    	${TMPDIR}/proxy_agent_list
5088b57459abSJulian Pullen
5089b57459abSJulian Pullen	    # print the proxy agent list
5090b57459abSJulian Pullen	    ${NAWK} '{print NR ": " $0}' ${TMPDIR}/proxy_agent_list
5091b57459abSJulian Pullen
5092b57459abSJulian Pullen	    # ask the user to pick one
5093b57459abSJulian Pullen	    _MENU_PROMPT="Select the proxy agent (1-$HOWMANY): "
5094b57459abSJulian Pullen	    get_menu_choice "${_MENU_PROMPT}" "0" "$HOWMANY"
5095b57459abSJulian Pullen	    _CH=$MN_CH
5096b57459abSJulian Pullen	    proxy_aci=`${SED} -n "$_CH p" ${TMPDIR}/grep_proxyread_aci`
5097b57459abSJulian Pullen    fi
5098b57459abSJulian Pullen
5099b57459abSJulian Pullen    # Create the tmp file to delete the ACI.
5100b57459abSJulian Pullen    ( cat <<EOF
5101b57459abSJulian Pullendn: ${LDAP_BASEDN}
5102b57459abSJulian Pullenchangetype: modify
5103b57459abSJulian Pullendelete: aci
5104b57459abSJulian Pullenaci: ${proxy_aci}
5105b57459abSJulian PullenEOF
5106b57459abSJulian Pullen    ) > ${TMPDIR}/proxy_delete
5107b57459abSJulian Pullen
5108b57459abSJulian Pullen    # Delete the ACI
5109b57459abSJulian Pullen    ${EVAL} "${LDAPMODIFY} ${LDAP_ARGS} -f ${TMPDIR}/proxy_delete ${VERB}"
5110b57459abSJulian Pullen    if [ $? -ne 0 ]; then
5111b57459abSJulian Pullen	${ECHO} "  ERROR: Remove of ${PROXY_ACI_NAME} ACI failed!"
5112b57459abSJulian Pullen	cat ${TMPDIR}/proxy_delete
5113b57459abSJulian Pullen	cleanup
5114b57459abSJulian Pullen	exit 1
5115b57459abSJulian Pullen    fi
5116b57459abSJulian Pullen
5117b57459abSJulian Pullen    # Display message that ACI is updated.
5118b57459abSJulian Pullen    MSG="Removed ${PROXY_ACI_NAME} ACI for proxyagent read permission for password."
5119b57459abSJulian Pullen    ${ECHO} " "
5120b57459abSJulian Pullen    ${ECHO} "  ACI REMOVED: $MSG"
5121b57459abSJulian Pullen    ${ECHO} "  The ACI removed is $proxy_aci"
5122b57459abSJulian Pullen    ${ECHO} " "
5123b57459abSJulian Pullen}
5124b57459abSJulian Pullen
51257c478bd9Sstevel@tonic-gate#
51267c478bd9Sstevel@tonic-gate# add_profile(): Add client profile to server.
51277c478bd9Sstevel@tonic-gate#
51287c478bd9Sstevel@tonic-gateadd_profile()
51297c478bd9Sstevel@tonic-gate{
51307c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In add_profile()"
51317c478bd9Sstevel@tonic-gate
51327c478bd9Sstevel@tonic-gate    # If profile name already exists, DELETE it, and add new one.
51337c478bd9Sstevel@tonic-gate    eval "${LDAPSEARCH} ${LDAP_ARGS} -b \"cn=${LDAP_PROFILE_NAME},ou=profile,${LDAP_BASEDN}\" -s base \"objectclass=*\" ${VERB}"
51347c478bd9Sstevel@tonic-gate    if [ $? -eq 0 ]; then
51357c478bd9Sstevel@tonic-gate	# Create Delete file.
51367c478bd9Sstevel@tonic-gate	( cat <<EOF
51377c478bd9Sstevel@tonic-gatecn=${LDAP_PROFILE_NAME},ou=profile,${LDAP_BASEDN}
51387c478bd9Sstevel@tonic-gateEOF
51397c478bd9Sstevel@tonic-gate) > ${TMPDIR}/del_profile
51407c478bd9Sstevel@tonic-gate
51417c478bd9Sstevel@tonic-gate	# Check if DEL_OLD_PROFILE is set.  (If not ERROR)
51427c478bd9Sstevel@tonic-gate	if [ $DEL_OLD_PROFILE -eq 0 ]; then
51437c478bd9Sstevel@tonic-gate	    ${ECHO} "ERROR: Profile name ${LDAP_PROFILE_NAME} exists! Add failed!"
51447c478bd9Sstevel@tonic-gate	    exit 1
51457c478bd9Sstevel@tonic-gate	fi
51467c478bd9Sstevel@tonic-gate
51477c478bd9Sstevel@tonic-gate	# Delete the OLD profile.
51487c478bd9Sstevel@tonic-gate	${EVAL} "${LDAPDELETE} ${LDAP_ARGS} -f ${TMPDIR}/del_profile ${VERB}"
51497c478bd9Sstevel@tonic-gate	if [ $? -ne 0 ]; then
51507c478bd9Sstevel@tonic-gate	    ${ECHO} "  ERROR: Attempt to DELETE profile failed!"
51517c478bd9Sstevel@tonic-gate	    cleanup
51527c478bd9Sstevel@tonic-gate	    exit 1
51537c478bd9Sstevel@tonic-gate	fi
51547c478bd9Sstevel@tonic-gate    fi
51557c478bd9Sstevel@tonic-gate
51567c478bd9Sstevel@tonic-gate    # Build the "ldapclient genprofile" command string to execute.
51577c478bd9Sstevel@tonic-gate    GEN_CMD="ldapclient genprofile -a \"profileName=${LDAP_PROFILE_NAME}\""
51587c478bd9Sstevel@tonic-gate
51597c478bd9Sstevel@tonic-gate    # Add required argument defaultSearchBase.
51607c478bd9Sstevel@tonic-gate    GEN_CMD="${GEN_CMD} -a \"defaultSearchBase=${LDAP_BASEDN}\""
51617c478bd9Sstevel@tonic-gate
51627c478bd9Sstevel@tonic-gate    # Add optional parameters.
51637c478bd9Sstevel@tonic-gate    [ -n "$LDAP_SERVER_LIST" ] && \
51647c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"defaultServerList=${LDAP_SERVER_LIST}\""
51657c478bd9Sstevel@tonic-gate    [ -n "$LDAP_SEARCH_SCOPE" ] && \
51667c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"defaultSearchScope=${LDAP_SEARCH_SCOPE}\""
51677c478bd9Sstevel@tonic-gate    [ -n "$LDAP_CRED_LEVEL" ] && \
51687c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"credentialLevel=${LDAP_CRED_LEVEL}\""
51697c478bd9Sstevel@tonic-gate    [ -n "$LDAP_AUTHMETHOD" ] && \
51707c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"authenticationMethod=${LDAP_AUTHMETHOD}\""
51717c478bd9Sstevel@tonic-gate    [ -n "$LDAP_FOLLOWREF" ] && \
51727c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"followReferrals=${LDAP_FOLLOWREF}\""
51737c478bd9Sstevel@tonic-gate    [ -n "$LDAP_SEARCH_TIME_LIMIT" ] && \
51747c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"searchTimeLimit=${LDAP_SEARCH_TIME_LIMIT}\""
51757c478bd9Sstevel@tonic-gate    [ -n "$LDAP_PROFILE_TTL" ] && \
51767c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"profileTTL=${LDAP_PROFILE_TTL}\""
51777c478bd9Sstevel@tonic-gate    [ -n "$LDAP_BIND_LIMIT" ] && \
51787c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"bindTimeLimit=${LDAP_BIND_LIMIT}\""
51797c478bd9Sstevel@tonic-gate    [ -n "$LDAP_PREF_SRVLIST" ] && \
51807c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"preferredServerList=${LDAP_PREF_SRVLIST}\""
51817c478bd9Sstevel@tonic-gate    [ -n "$LDAP_SRV_AUTHMETHOD_PAM" ] && \
51827c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"serviceAuthenticationMethod=${LDAP_SRV_AUTHMETHOD_PAM}\""
51837c478bd9Sstevel@tonic-gate    [ -n "$LDAP_SRV_AUTHMETHOD_KEY" ] && \
51847c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"serviceAuthenticationMethod=${LDAP_SRV_AUTHMETHOD_KEY}\""
51857c478bd9Sstevel@tonic-gate    [ -n "$LDAP_SRV_AUTHMETHOD_CMD" ] && \
51867c478bd9Sstevel@tonic-gate	GEN_CMD="${GEN_CMD} -a \"serviceAuthenticationMethod=${LDAP_SRV_AUTHMETHOD_CMD}\""
51877c478bd9Sstevel@tonic-gate
51887c478bd9Sstevel@tonic-gate    # Check if there are any service search descriptors to ad.
51897c478bd9Sstevel@tonic-gate    if [ -s "${SSD_FILE}" ]; then
51907c478bd9Sstevel@tonic-gate	ssd_2_profile
51917c478bd9Sstevel@tonic-gate    fi
51927c478bd9Sstevel@tonic-gate
51937c478bd9Sstevel@tonic-gate    # Execute "ldapclient genprofile" to create profile.
51947c478bd9Sstevel@tonic-gate    eval ${GEN_CMD} > ${TMPDIR}/gen_profile 2> ${TMPDIR}/gen_profile_ERR
51957c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
51967c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: ldapclient genprofile failed!"
51977c478bd9Sstevel@tonic-gate	cleanup
51987c478bd9Sstevel@tonic-gate	exit 1
51997c478bd9Sstevel@tonic-gate    fi
52007c478bd9Sstevel@tonic-gate
52017c478bd9Sstevel@tonic-gate    # Add the generated profile..
52027c478bd9Sstevel@tonic-gate    ${EVAL} "${LDAPMODIFY} -a ${LDAP_ARGS} -f ${TMPDIR}/gen_profile ${VERB}"
52037c478bd9Sstevel@tonic-gate    if [ $? -ne 0 ]; then
52047c478bd9Sstevel@tonic-gate	${ECHO} "  ERROR: Attempt to add profile failed!"
52057c478bd9Sstevel@tonic-gate	cleanup
52067c478bd9Sstevel@tonic-gate	exit 1
52077c478bd9Sstevel@tonic-gate    fi
52087c478bd9Sstevel@tonic-gate
52097c478bd9Sstevel@tonic-gate    # Display message that schema is updated.
52107c478bd9Sstevel@tonic-gate    ${ECHO} "  ${STEP}. Generated client profile and loaded on server."
52117c478bd9Sstevel@tonic-gate    STEP=`expr $STEP + 1`
52127c478bd9Sstevel@tonic-gate}
52137c478bd9Sstevel@tonic-gate
52147c478bd9Sstevel@tonic-gate
52157c478bd9Sstevel@tonic-gate#
52167c478bd9Sstevel@tonic-gate# cleanup(): Remove the TMPDIR and all files in it.
52177c478bd9Sstevel@tonic-gate#
52187c478bd9Sstevel@tonic-gatecleanup()
52197c478bd9Sstevel@tonic-gate{
52207c478bd9Sstevel@tonic-gate    [ $DEBUG -eq 1 ] && ${ECHO} "In cleanup()"
52217c478bd9Sstevel@tonic-gate
52227c478bd9Sstevel@tonic-gate    rm -fr ${TMPDIR}
52237c478bd9Sstevel@tonic-gate}
52247c478bd9Sstevel@tonic-gate
52257c478bd9Sstevel@tonic-gate
52267c478bd9Sstevel@tonic-gate#
52277c478bd9Sstevel@tonic-gate# 			* * * MAIN * * *
52287c478bd9Sstevel@tonic-gate#
52297c478bd9Sstevel@tonic-gate# Description:
52307c478bd9Sstevel@tonic-gate# This script assumes that the iPlanet Directory Server (iDS) is
52317c478bd9Sstevel@tonic-gate# installed and that setup has been run.  This script takes the
52327c478bd9Sstevel@tonic-gate# iDS server from that point and sets up the infrastructure for
52337c478bd9Sstevel@tonic-gate# LDAP Naming Services.  After running this script, ldapaddent(1M)
52347c478bd9Sstevel@tonic-gate# or some other tools can be used to populate data.
52357c478bd9Sstevel@tonic-gate
52367c478bd9Sstevel@tonic-gate# Initialize the variables that need to be set to NULL, or some
52377c478bd9Sstevel@tonic-gate# other initial value before the rest of the functions can be called.
52387c478bd9Sstevel@tonic-gateinit
52397c478bd9Sstevel@tonic-gate
52407c478bd9Sstevel@tonic-gate# Parse command line arguments.
52417c478bd9Sstevel@tonic-gateparse_arg $*
52427c478bd9Sstevel@tonic-gateshift $?
52437c478bd9Sstevel@tonic-gate
52447c478bd9Sstevel@tonic-gate# Print extra line to separate from prompt.
52457c478bd9Sstevel@tonic-gate${ECHO} " "
52467c478bd9Sstevel@tonic-gate
52477c478bd9Sstevel@tonic-gate# Either Load the user specified config file
52487c478bd9Sstevel@tonic-gate# or prompt user for config info.
52497c478bd9Sstevel@tonic-gateif [ -n "$INPUT_FILE" ]
52507c478bd9Sstevel@tonic-gatethen
52517c478bd9Sstevel@tonic-gate    load_config_file
52527c478bd9Sstevel@tonic-gate    INTERACTIVE=0      # Turns off prompts that occur later.
52537c478bd9Sstevel@tonic-gate    validate_info      # Validate basic info in file.
52547c478bd9Sstevel@tonic-gate    chk_ids_version    # Check iDS version for compatibility.
52557c478bd9Sstevel@tonic-gateelse
52567c478bd9Sstevel@tonic-gate    # Display BACKUP warning to user.
52577c478bd9Sstevel@tonic-gate    display_msg backup_server
52587c478bd9Sstevel@tonic-gate    get_confirm "Do you wish to continue with server setup (y/n/h)?" "n" "backup_help"
52597c478bd9Sstevel@tonic-gate    if [ $? -eq 0 ]; then    # if No, cleanup and exit.
52607c478bd9Sstevel@tonic-gate	cleanup ; exit 1
52617c478bd9Sstevel@tonic-gate    fi
52627c478bd9Sstevel@tonic-gate
52637c478bd9Sstevel@tonic-gate    # Prompt for values.
52647c478bd9Sstevel@tonic-gate    prompt_config_info
52657c478bd9Sstevel@tonic-gate    display_summary    # Allow user to modify results.
52667c478bd9Sstevel@tonic-gate    INTERACTIVE=1      # Insures future prompting.
52677c478bd9Sstevel@tonic-gatefi
52687c478bd9Sstevel@tonic-gate
52697c478bd9Sstevel@tonic-gate# Modify slapd.oc.conf to ALLOW cn instead of REQUIRE.
52707c478bd9Sstevel@tonic-gatemodify_cn
52717c478bd9Sstevel@tonic-gate
52727c478bd9Sstevel@tonic-gate# Modify timelimit to user value.
52737c478bd9Sstevel@tonic-gate[ $NEED_TIME -eq 1 ] && modify_timelimit
52747c478bd9Sstevel@tonic-gate
52757c478bd9Sstevel@tonic-gate# Modify sizelimit to user value.
52767c478bd9Sstevel@tonic-gate[ $NEED_SIZE -eq 1 ] && modify_sizelimit
52777c478bd9Sstevel@tonic-gate
52787c478bd9Sstevel@tonic-gate# Modify the password storage scheme to support CRYPT.
52797c478bd9Sstevel@tonic-gateif [ "$NEED_CRYPT" = "TRUE" ]; then
52807c478bd9Sstevel@tonic-gate    modify_pwd_crypt
52817c478bd9Sstevel@tonic-gatefi
52827c478bd9Sstevel@tonic-gate
52837c478bd9Sstevel@tonic-gate# Update the schema (Attributes, Objectclass Definitions)
5284cb5caa98Sdjlif [ ${SCHEMA_UPDATED} -eq 0 ]; then
52857c478bd9Sstevel@tonic-gate        update_schema_attr
52867c478bd9Sstevel@tonic-gate        update_schema_obj
5287cb5caa98Sdjlfi
52887c478bd9Sstevel@tonic-gate
5289017e8b01Svl199446# Add suffix together with its root entry (if needed)
5290017e8b01Svl199446add_suffix ||
5291017e8b01Svl199446{
5292017e8b01Svl199446	cleanup
5293017e8b01Svl199446	exit 1
5294017e8b01Svl199446}
5295017e8b01Svl199446
52967c478bd9Sstevel@tonic-gate# Add base objects (if needed)
52977c478bd9Sstevel@tonic-gateadd_base_objects
52987c478bd9Sstevel@tonic-gate
52997c478bd9Sstevel@tonic-gate# Update the NisDomainObject.
53007c478bd9Sstevel@tonic-gate#   The Base DN might of just been created, so this MUST happen after
53017c478bd9Sstevel@tonic-gate#   the base objects have been added!
53027c478bd9Sstevel@tonic-gateset_nisdomain
53037c478bd9Sstevel@tonic-gate
53047c478bd9Sstevel@tonic-gate# Add top level classes (new containers)
53057c478bd9Sstevel@tonic-gateadd_new_containers
53067c478bd9Sstevel@tonic-gate
53077c478bd9Sstevel@tonic-gate# Add common nismaps.
53087c478bd9Sstevel@tonic-gateadd_auto_maps
53097c478bd9Sstevel@tonic-gate
53107c478bd9Sstevel@tonic-gate# Modify top ACI.
53117c478bd9Sstevel@tonic-gatemodify_top_aci
53127c478bd9Sstevel@tonic-gate
53137c478bd9Sstevel@tonic-gate# Add Access Control Information for VLV.
53147c478bd9Sstevel@tonic-gateadd_vlv_aci
53157c478bd9Sstevel@tonic-gate
53167c478bd9Sstevel@tonic-gate# if Proxy needed, Add Proxy Agent and give read permission for password.
53177c478bd9Sstevel@tonic-gateif [ $NEED_PROXY -eq 1 ]; then
53187c478bd9Sstevel@tonic-gate    add_proxyagent
5319b57459abSJulian Pullen    if [ "$LDAP_ENABLE_SHADOW_UPDATE" != "TRUE" ]; then
53207c478bd9Sstevel@tonic-gate	allow_proxy_read_pw
53217c478bd9Sstevel@tonic-gate    fi
5322b57459abSJulian Pullenfi
53237c478bd9Sstevel@tonic-gate
5324dd1104fbSMichen Chang# If admin needed for shadow update, Add the administrator identity and
5325b57459abSJulian Pullen# give read/write permission for shadow, and deny all others read/write
5326b57459abSJulian Pullen# access to it.
5327dd1104fbSMichen Changif [ $NEED_ADMIN -eq 1 ]; then
5328dd1104fbSMichen Chang    add_admin
5329b57459abSJulian Pullen    allow_admin_read_write_shadow
5330b57459abSJulian Pullen    # deny non-admin access to shadow data
5331b57459abSJulian Pullen    deny_non_admin_shadow_access
5332dd1104fbSMichen Changfi
5333dd1104fbSMichen Chang
53344f4e8bf0SMilan Jurikif [ $GSSAPI_ENABLE -eq 1 ]; then
53354f4e8bf0SMilan Jurik    add_id_mapping_rules
53364f4e8bf0SMilan Jurik    # do not modify ACI if "sasl/GSSAPI" and "self" are not selected
53374f4e8bf0SMilan Jurik    if [ "$LDAP_CRED_LEVEL" = "self" -a "$LDAP_AUTHMETHOD" = "sasl/GSSAPI" ]; then
53384f4e8bf0SMilan Jurik        modify_userpassword_acl_for_gssapi
53394f4e8bf0SMilan Jurik    else
53404f4e8bf0SMilan Jurik        ${ECHO} "  ACL for GSSAPI was not set because of incompatibility in profile."
53414f4e8bf0SMilan Jurik    fi
53424f4e8bf0SMilan Jurikfi
53434f4e8bf0SMilan Jurik
5344b57459abSJulian Pullen# If use host principal for shadow update, give read/write permission for
5345b57459abSJulian Pullen# shadow, and deny all others' read/write access to it.
5346dd1104fbSMichen Changif [ $NEED_HOSTACL -eq 1 ]; then
5347b57459abSJulian Pullen    allow_host_read_write_shadow
5348b57459abSJulian Pullen    # deny non-host access to shadow data
5349b57459abSJulian Pullen    deny_non_host_shadow_access
5350dd1104fbSMichen Changfi
5351dd1104fbSMichen Chang
5352b57459abSJulian Pullen
53537c478bd9Sstevel@tonic-gate# Generate client profile and add it to the server.
53547c478bd9Sstevel@tonic-gateadd_profile
53557c478bd9Sstevel@tonic-gate
53567c478bd9Sstevel@tonic-gate# Add Indexes to improve Search Performance.
53577c478bd9Sstevel@tonic-gateadd_eq_indexes
53587c478bd9Sstevel@tonic-gateadd_sub_indexes
53597c478bd9Sstevel@tonic-gateadd_vlv_indexes
53607c478bd9Sstevel@tonic-gate
53617c478bd9Sstevel@tonic-gate# Display setup complete message
53627c478bd9Sstevel@tonic-gatedisplay_msg setup_complete
53637c478bd9Sstevel@tonic-gate
53647c478bd9Sstevel@tonic-gate# Display VLV index commands to be executed on server.
53657c478bd9Sstevel@tonic-gatedisplay_vlv_cmds
53667c478bd9Sstevel@tonic-gate
53677c478bd9Sstevel@tonic-gate# Create config file if requested.
53687c478bd9Sstevel@tonic-gate[ -n "$OUTPUT_FILE" ] && create_config_file
53697c478bd9Sstevel@tonic-gate
53707c478bd9Sstevel@tonic-gate# Removed the TMPDIR and all files in it.
53717c478bd9Sstevel@tonic-gatecleanup
53727c478bd9Sstevel@tonic-gate
53737c478bd9Sstevel@tonic-gateexit 0
53747c478bd9Sstevel@tonic-gate# end of MAIN.
5375