#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r720 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_users.sh 1.5 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2011,2015 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)66 1.5 src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_users.sh, hacmp.assist, 61haes_r720, 1525A_hacmp720 6/11/15 17:07:29 #============================================================================ # # Name: KLIB_HACMP_list_users # # Description: This is the main, FPATH function that is invoked by clmgr # to collect user names. It uses the "lsuser" utility # to generate the list of names unless a search is being # conducted. In the case of a search, the associated FPATH # function, KLIB_HACMP_get_user_attributes is invoked # in verbose mode. The resulting data set is then passed # through the "search_properties()" function to arrive at # a set of outputs that matches the provided search parameters. # # Inputs: See the "devDoc()" function at the bottom of this file. # # Outputs: The list array is populated with one user per entry. The # only other outputs are any error messages that might be # needed. # # Returns: Zero if no errors are detected. Otherwise, an appropriate # non-zero value is returned. Refer to the "RETURN" section # of the "devDoc()" function at the bottom of this file for # the standard return code values/meanings for clmgr. # #============================================================================ function KLIB_HACMP_list_users { LINENO=2 . $HALIBROOT/log_entry "$0()" "$CL" : version=1.5, src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_users.sh, hacmp.assist, 61haes_r720, 1525A_hacmp720 : INPUTS: $* typeset -n list=${1//\"/} shift if [[ -n ${1//\"/} && ${1//\"/} != *=* ]]; then typeset -u type=${1//\"/} shift fi [[ $CLMGR_LOGGING == 'med' ]] && set +x # Only trace param values #=================================== : Declare and initialize variables #=================================== typeset -A queries typeset -u attr= typeset LINE= LDAP_USERS= LOCAL_USERS= base= idx= value= typeset -i index=0 matches=0 rc=$RC_UNKNOWN #=================================================== : Check for any specified attribute=value pairs. : If any are found, use those to query the output. #=================================================== while (( $# > 0 )); do value="$1" if [[ $value == *=* ]]; then attr=${value%%=*} # "attr" makes this uppercase queries[$attr]="${value#*=}" fi shift done if (( ${#queries[*]} == 0 )); then # List all case $type in AV*) print "$0()[$LINENO]($SECONDS): cl_manageallowpasswd -V" >>$CLMGR_TMPLOG # Always log commands LOCAL_USERS=$(cl_manageallowpasswd -V 2>>$CLMGR_TMPLOG) rc=$? print "$0()[$LINENO]($SECONDS): cl_manageallowpasswd RC: $rc" >>$CLMGR_TMPLOG # Always log command result print -- "$LOCAL_USERS" |\ while read LINE; do if [[ -n $LINE ]]; then [[ $LINE == *([[:space:]])\#* ]] && continue [[ $LINE == *+([[:space:]])* ]] && continue list[$index]="$LINE" (( index++ )) fi done ;; AL*) print "$0()[$LINENO]($SECONDS): cl_manageallowpasswd -L" >>$CLMGR_TMPLOG # Always log commands LOCAL_USERS=$(cl_manageallowpasswd -L 2>>$CLMGR_TMPLOG) rc=$? print "$0()[$LINENO]($SECONDS): cl_manageallowpasswd RC: $rc" >>$CLMGR_TMPLOG # Always log command result print -- "$LOCAL_USERS" |\ while read LINE; do if [[ -n $LINE ]]; then [[ $LINE == *([[:space:]])\#* ]] && continue [[ $LINE == *+([[:space:]])* ]] && continue list[$index]="$LINE" (( index++ )) fi done ;; "") #==================== : Display all users #==================== print "$0()[$LINENO]($SECONDS): lsuser -R files -a ALL" >>$CLMGR_TMPLOG # Always log commands LOCAL_USERS=$(lsuser -R files -a ALL 2>/dev/null) rc=$? print "$0()[$LINENO]($SECONDS): lsuser (files) RC: $rc" >>$CLMGR_TMPLOG # Always log command result if (( $rc != RC_SUCCESS )); then rc=$RC_ERROR else print "$0()[$LINENO]($SECONDS): lsuser -R LDAP -a ALL" >>$CLMGR_TMPLOG # Always log commands LDAP_USERS=$(lsuser -R LDAP -a ALL 2>/dev/null) print "$0()[$LINENO]($SECONDS): lsuser (LDAP) RC: $rc" >>$CLMGR_TMPLOG # Always log command result fi print -- "$LOCAL_USERS" |\ while read LINE; do if [[ -n $LINE ]]; then [[ $LINE == *([[:space:]])\#* ]] && continue [[ $LINE == *+([[:space:]])* ]] && continue list[$index]="$LINE (files)" (( index++ )) fi done print -- "$LDAP_USERS" |\ while read LINE; do if [[ -n $LINE ]]; then [[ $LINE == *([[:space:]])\#* ]] && continue [[ $LINE == *+([[:space:]])* ]] && continue list[$index]="$LINE (LDAP)" (( index++ )) fi done ;; *) CL=$LINENO cl_dspmsg -s $CLMGR_SET $CLMGR_MSGS 110 '\nERROR: invalid value specified for "%1$s": "%2$s".\n' TYPE "$type" 1>&2 rc=$RC_INCORRECT_VALUE ;; esac else # A search was specified typeset -A allProperties CL=$LINENO CLMGR_VERBOSE=1 KLIB_HACMP_get_user_attributes "" allProperties CL=$LINENO search_properties queries allProperties rc=$? if (( $rc == RC_SUCCESS )); then for key in ${!allProperties[*]}; do [[ $key != NAME@(|+([0-9])) ]] && continue list[$index]=${allProperties[$key]} (( index++ )) done fi fi log_return_msg "$rc" "$0()" "$LINENO" return $? } # End of "KLIB_HACMP_list_users()" #============================================================================ # # Name: devDoc # # Description: This is a never-to-be-called, wrapper function that all the # clmgr FPATH functions implement in order to hide embedded # syntax from trace logging. This information is implemented # in POD format, and can be viewed in a number of ways using # POD tools. Some viewing suggestions for this function's POD- # formatted information are: # # perldoc # pod2text -c # pod2text -c --code # pod2html # # However, the more important use for this information is that # it is parsed by clmgr to display the syntax for this file's # operation. The information in the "SYNOPSIS" section is used # for this purpose. This feature was originally implemented # using the man page information. However, in a code review it # was pointed out that this approach had to be changed because # customers do not have to install the man pages! Therefore, a # built-in dependency on man page information would break the # automatic help feature of clmgr. So the SYNPOSIS section must # be used instead. # # IMPORTANT: As a result of this, it is imperative that the # information in this SYNOPSIS be kept in sync # with the man page information, which is owned # by the IDD team. # # Inputs: None. # # Outputs: None. # # Returns: n/a (not intended to be invoked) # #============================================================================ function devDoc { : <<'=cut' >/dev/null 2>&1 =head1 NAME KLIB_HACMP_list_users [ TYPE={AVAILABLE|ALLOWED} ] =head1 VERSION Version Number: 1.5 Last Extracted: 6/16/15 17:51:19 Last Changed: 6/11/15 17:07:29 Path, Component, Release(, Level): src/43haes/lib/ksh93/hacmp/KLIB_HACMP_list_users.sh, hacmp.assist, 61haes_r720, 1525A_hacmp720 =head1 SYNOPSIS clmgr query user NOTE: the alias for "user" is "ur". =head1 DESCRIPTION Displays the current set of AIX users. If the "TYPE" parameter is provided, then the display will include only those users who may or may not change passwords. =head1 ARGUMENTS 1. list [REQUIRED] [hash ref] An associative array within which data about the queried objects can be returned to the caller. 2. type [OPTIONAL] [set] Indicates which type of users to list, with respect to who is allowed to change passwords. Valid values: AVAILABLE, ALLOWED =head1 RETURN 0: no errors were detected; the operation appears to have been successful 1: a general error has occurred 2: a specified resource does not exist, or could not be found 3: some required input was missing 4: some detected input was incorrect in some way 5: a required dependency does not exist 6: a specified search failed to match any data =head1 COPYRIGHT COPYRIGHT International Business Machines Corp. 2011,2015 All Rights Reserved =cut } # End of "devDoc()" #============================================================================== # The following, comment block attempts to enforce coding standards when this # file is edited via emacs or vim. This block _must_ appear at the very end # of the file, or the editor will not find it, and it will be ignored. #============================================================================== # Local Variables: # indent-tabs-mode: nil # tab-width: 4 # End: #============================================================================== # vim: tabstop=4 shiftwidth=4 expandtab #==============================================================================