#!/bin/sh
##################################################################
# (C) Copyright 2001 The Free Standards Group  Inc
# ./tset/LSB-usersgroups/usersgroups/commands/commands-tc.sh
# commands-tc.sh : test case for users and groups COMMANDS
# This is 1.0
#
# commands-tc.sh,v
# Revision 1.0  2001/06/13 10:10:33  Apham
#	
# Revision 1.1 2001/01/19 15:25:57 Apham & Ahayden 
#		Added more descriptive comments.
#
# Revision 1.23 2002/05/10 16:24:59 lsarabia
# Update tp31, tp32, tp34 for SA(Spec Authority) ruling on Bug(524042).
# 
# $Revision: 1.28 $
#
# $Log: command_tests.sh,v $
# Revision 1.28  2005/01/19 17:11:55  krc
# Removed references to chapter 14 of the spec and added Reference the Commands and Utilities chapter in the Specification - krc
#
# Revision 1.27  2004/06/16 05:05:26  cyeoh
# Fixes problem with groups not always being correctly removed with cleanup of tests tp66 and tp69. Bug #224
#
# Revision 1.26  2002/06/13 14:21:21  krclsb
# Changed a typo grouprm to groupdel
# Kevin Caunt
#
# Revision 1.25  2002/06/11 06:31:08  cyeoh
# make encrypted password longer
#
# Revision 1.24  2002/05/31 05:17:03  cyeoh
# Make test password to be used more complex so it is not
# rejected by passwd as too simple
#
# Revision 1.23  2002/05/13 20:44:16  krclsb
# Checking in code for Lisa Sarabia
#  Update tp31, tp32, tp34 for SA(Spec Authority) ruling on Bug(524042).
#
# Revision 1.22  2002/01/17 01:05:41  cyeoh
# Fix logic in tp21 - was grepping for wrong user
#
# Revision 1.21  2001/11/21 01:14:08  cyeoh
# Fix spelling typo in CVS tag
#
# Revision 1.20  2001/11/21 01:13:13  cyeoh
# Merge changes in from Arnold Hayden (haydena@ibm.com)
#   Changed design of user* testcases to use unique usernames
#
# Revision 1.19  2001/09/06 05:57:20  cyeoh
# Apply patch from Arnold Hayden (haydena@ibm.com)
# Add CVS header vars
#
#
# Note:  all of the test cases are executed as root:  privilege
#	 given by the Makefile
# 
##################################################################
tet_startup="startup"			# startup function
tet_cleanup="cleanup"			# cleanup function
iclist="ic1 ic2 ic3 ic4 ic5 ic6 ic7 ic8 ic9 ic10 ic11 ic12 ic13 ic14 ic15 ic16 ic17 ic18 ic19 ic20 ic21 ic22 ic23 ic24 ic25 ic26 ic27 ic28 ic29 ic30 ic31 ic32 ic33 ic34 ic35 ic36 ic37 ic38 ic39 ic40 ic41 ic42 ic43 ic44 ic45 ic46 ic47 ic48 ic49 ic50 ic51 ic52 ic53 ic54 ic55 ic56 ic57 ic58 ic59 ic60 ic61 ic62 ic63 ic64 ic65 ic66 ic67 ic68 ic69 ic70 ic71 ic72 ic73"
ic1="tp1"
ic2="tp2"
ic3="tp3"
ic4="tp4"
ic5="tp5"
ic6="tp6"
ic7="tp7"
ic8="tp8"
ic9="tp9"
ic10="tp10"
ic11="tp11"
ic12="tp12"
ic13="tp13"
ic14="tp14"
ic15="tp15"
ic16="tp16"
ic17="tp17"
ic18="tp18"
ic19="tp19"
ic20="tp20"
ic21="tp21"
ic22="tp22"
ic23="tp23"
ic24="tp24"
ic25="tp25"
ic26="tp26"
ic27="tp27"
ic28="tp28"
ic29="tp29"
ic30="tp30"
ic31="tp31"
ic32="tp32"
ic33="tp33"
ic34="tp34"
ic35="tp35"
ic36="tp36"
ic37="tp37"
ic38="tp38"
ic39="tp39"
ic40="tp40"
ic41="tp41"
ic42="tp42"
ic43="tp43"
ic44="tp44"
ic45="tp45"
ic46="tp46"
ic47="tp47"
ic48="tp48"
ic49="tp49"
ic50="tp50"
ic51="tp51"
ic52="tp52"
ic53="tp53"
ic54="tp54"
ic55="tp55"
ic56="tp56"
ic57="tp57"
ic58="tp58"
ic59="tp59"
ic60="tp60"
ic61="tp61"
ic62="tp62"
ic63="tp63"
ic64="tp64"
ic65="tp65"
ic66="tp66"
ic67="tp67"
ic68="tp68"
ic69="tp69"
ic70="tp70"
ic71="tp71"
ic72="tp72"
ic73="tp73"

###########################################################################
#
# Command:    chgrp
# Standard:   LSB 
#
###########################################################################

###########################################################################
#
# - Assumptions:
# - 	1)Tester has super-user privilege.
# -	2)All the commands used in this script work.
# -
# - Strategy Statement:
# - 	Create a testfile.  Change its group name
# - 
# - Expected Results:
# -     the testfile's group should change appropriately.
# - 
# - Other Commands Used:
# -	 touch, ls -l, grep, cd
#
###########################################################################
tp1()
{
    tpstart "chgrp - change group ownership of a file. - Reference the Commands and Utilities chapter in the Specification "
    tet_infoline "The file's group should change to a new group accordingly."

#Call a function which adds a test user for testcases 29-34; 
#	found in .../test_sets/SRC/common/lsblib/usersgroups_funcs.sh
    add_test_user_tp29_34

#The assignment statement below need to change to appropriate value:
    OTHER_GROUP=vsxg1
    TESTID=chgrp    
    testFile=test.${TESTID}

#Begin to test chgrp with no option
    touch $testFile > /dev/null 2>&1
    chgrp $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp : fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y	
    else  
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp : fail.  Expected testFile's owner to change but did not."
	FAIL=Y	
     else 
        tet_infoline "chgrp : pass"
     fi
   fi
   rm -f $TestFile > /dev/null 2>&1
   tpresult
}

tp2()
{
    tpstart "Test chgrp -c: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "like verbose but report only when a change is made"
    TESTID=chgrp    
    testFile=test.${TESTID}
    OTHER_GROUP=vsxg1

#Test chgrp with option: -c
    touch $testFile > /dev/null 2>&1
    chgrp -c $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp -c: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp -c: fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chgrp -c: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp3()
{
    tpstart "Test chgrp --changes: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "like verbose but report only when a change is made"
    TESTID=chgrp    
    testFile=test.${TESTID}
    OTHER_GROUP=vsxg1

#Test chgrp with option:  --changes
    touch $testFile > /dev/null 2>&1
    chgrp --changes $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --changes: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP> /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --changes : fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chgrp --changes: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp4()
{
    tpstart "Test chgrp --dereference: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "affect the referent of each symbolic link."
    TESTID=chgrp    
    testFile=test.${TESTID}
    OTHER_GROUP=vsxg1

#Test chgrp with option: --dereference
    touch $testFile > /dev/null 2>&1
    chgrp --dereference $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
       tet_infoline "chgrp --dereference: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
       FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --dereference: fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chgrp --dereference: pass"
      fi
    fi  
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp5()
{
    tpstart "Test chgrp -h: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "affect symbolic links instead of any referenced file"
    TESTID=chgrp    
    testFile=test.${TESTID}
    OTHER_GROUP=vsxg1

#Test chgrp with option: -h 
    touch $testFile > /dev/null 2>&1
    chgrp -h $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp -h: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp -h: fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else 
        tet_infoline "chgrp -h: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}
  
tp6()
{
    tpstart "Test chgrp --no-dereference: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "affect symbolic links instead of any referenced file"
    TESTID=chgrp    
    testFile=test.${TESTID}
    OTHER_GROUP=vsxg1

#Test chgrp with option: --no-dereference
    touch $testFile > /dev/null 2>&1
    chgrp --no-dereference $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
   tet_infoline "chgrp --no-dereference: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --no-dereference: fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else    
        tet_infoline "chgrp --no-dereference: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp7()
{
    tpstart "chgrp -f: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "suppress most error messages."
    TESTID=chgrp    
    testFile=test.${TESTID}
    OTHER_GROUP=vsxg1

#Test chgrp with option: -f
    touch $testFile > /dev/null 2>&1
    chgrp -f $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp -f: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp -f : fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chgrp -f :pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp8()
{
    tpstart "chgrp --silent: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "suppress most error messages."

    TESTID=chgrp    
    testFile=test.${TESTID}
    OTHER_GROUP=vsxg1

#Test chgrp with option: --silent
    touch $testFile > /dev/null 2>&1
    chgrp --silent $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --silent: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --silent: fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chgrp --silent:pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp9()
{
    tpstart "chgrp --quiet: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "suppress most error messages."
    TESTID=chgrp    
    testFile=test.${TESTID}
    OTHER_GROUP=vsxg1

#Test chgrp with option: --quiet
    touch $testFile > /dev/null 2>&1
    chgrp --quiet $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --quiet: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --quiet: fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chgrp --quiet: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp10()
{
    tpstart "chgrp --reference=RFILE: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "used RFILE's group rather than the specified GROUP value."
    TESTID=chgrp    
    testFile=test.${TESTID}

#Test chgrp with option:  --reference
    touch tmp2.${TESTID} > /dev/null 2>&1
    chgrp --reference=tmp2.${TESTID} $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --reference=RFILE: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --reference=RFILE: fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chgrp -reference=RFILE: pass"
      fi
    fi
    rm -f $TestFile tmp2.${TESTID} > /dev/null 2>&1
    tpresult
}

tp11()
{
    tpstart "chgrp -v: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "output a diagnostic for every file processed."
    TESTID=chgrp    
    testFile=test.${TESTID}

    OTHER_GROUP=vsxg1

#Test chgrp with option: -v 
    touch $testFile > /dev/null 2>&1
    chgrp -v $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp -v: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp : fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chgrp -v: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp12()
{
    tpstart "chgrp --verbose: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "output a diagnostic for every file processed."
    TESTID=chgrp    
    testFile=test.${TESTID}
    OTHER_GROUP=vsxg1

    touch $testFile > /dev/null 2>&1

#Test chgrp with option: --verbose 
    chgrp --verbose $OTHER_GROUP $testFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --verbose: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $testFile | grep $OTHER_GROUP > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --verbose: fail.  Expected testFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chgrp --verbose: pass"
      fi
    fi
    rm -f $testFile
    tpresult
}

tp13()
{
    tpstart "chgrp --version: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "output version info."

#Test chgrp with option: --version
    chgrp --version > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chgrp --version: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else 
        tet_infoline "chgrp --version: pass"
    fi
    tpresult
}

tp14()
{
    tpstart "chgrp -R: change group ownership. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "Recursively change group ownership for all the files in"
    tet_infoline "the specified dir."
    OTHER_GROUP=vsxg1

#Test chgrp with option: -R
#Make a test dir with some files:
    Cur_DIR=$(pwd)
    TEST_DIR=$(pwd)/testdirxyz	    
    mkdir $TEST_DIR > /dev/null 2>&1
    if [ $? -ne 0 ]; then
	tet_infoline "chgrp -R: Un-resolve:  Cannot create a testing directory."
	tpresult UNRESOLVED
	return	
    else
	cd $TEST_DIR
	touch f1 f2 f3 > /dev/null 2>&1
	if [ $? -ne 0 ]; then
	  tet_infoline "Un-able to create test files"
	  tpresult UNRESOLVED
	  return
	else
    	  chgrp -R $OTHER_GROUP $TEST_DIR > /dev/null 2>&1
    	  TC_EXIT_VALUE=$?
    	  if [ ! $TC_EXIT_VALUE -eq 0 ]; then
            tet_infoline "chgrp -R: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
 	     FAIL=Y		
          else
#Check to see the testfile's owner is actually changed.
            ls -l $TEST_DIR | grep $OTHER_GROUP > /dev/null 2>&1
            if [ $? -eq 0 ]; then
             tet_infoline "chgrp -R: pass"
            else 
             tet_infoline "chgrp -R: fail.  Expected testFile's owner to change but did not."
 	     FAIL=Y		
            fi
          fi
 	fi
    fi
#Remove all temp files
	rm -fr $TEST_DIR > /dev/null 2>&1
	cd $Cur_DIR > /dev/null 2>&1
	tpresult
} # End of LSB-chgrp 

###########################################################################
#
# Command:    chown
# Standard:   LSB
#
###########################################################################

###########################################################################
#
# - Assumptions:
# - 	1)Tester has super-user privilege.
# - 	2)All the commands used in this script work.
# - 
# - Strategy Statement:
# - 	Create a testfile.  Change its user/group name
# - 
# - Expected Results:
# -     the testfile's user/group should change appropriately.
# - 	
# - Other Commands Used:
# -	touch, ls -l, grep, rm -f
#
###########################################################################
tp15()
 {
    tpstart "Test chown with no option - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "change file owner and group."

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP1=vsxg1
    OTHER_USER1=vsx1

    TESTID=chown    
    TestFile=test.${TESTID}
    

#Begin to test chown with no option
   touch $TestFile  > /dev/null 2>&1
    chown $OTHER_USER1:$OTHER_GROUP1 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown : fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else 
    
#Check to see the testfile's owner is actually changed.
     ls -l $TestFile | grep $OTHER_USER1 > /dev/null 2>&1
     TC_EXIT_VALUE=$?
     if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown : fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
     else 
      tet_infoline "chown : pass"
     fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}
#---------------------------------------------------------------
tp16()
 {
    tpstart "chown -c: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "like verbose but report only when a change is made."

#The 2 assignment statements below need to change to appropriate values:
    OTHER_GROUP2=vsxg2
    OTHER_USER2=vsx2

    TESTID=chown    
    TestFile=test.${TESTID}
    
#Test chown with option: -c
    touch $TestFile > /dev/null 2>&1
    chown -c $OTHER_USER2:$OTHER_GROUP2 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown -c: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER2 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown -c: fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chown -c: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}


tp17()
 {
    tpstart "chown --changes: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "like verbose but report only when a change is made."

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP1=vsxg1
    OTHER_USER1=vsx1

    TESTID=chown    
    TestFile=test.${TESTID}
    
    touch $TestFile > /dev/null 2>&1
    chown --changes $OTHER_USER1:$OTHER_GROUP1 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --changes: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER1 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --changes : fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chown --changes: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}   
#---------------------------------------------------------------
tp18()
 {
    tpstart "chown --dereference: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "affect the referent of each symbolic link."

#The 2 assignment statements below need to change to appropriate values:
    OTHER_GROUP2=vsxg2
    OTHER_USER2=vsx2

    TESTID=chown    
    TestFile=test.${TESTID}
    
#Test chown with option: --dereference
    touch $TestFile > /dev/null 2>&1
    chown --dereference $OTHER_USER2:$OTHER_GROUP2 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
       tet_infoline "chown --dereference: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER2 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --dereference: fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chown --dereference: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}
    
#---------------------------------------------------------------
tp19()
 {
    tpstart "chown -h: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "affect symbolic links."

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP1=vsxg1
    OTHER_USER1=vsx1

    TESTID=chown    
    TestFile=test.${TESTID}
    
#Test chown with option: -h --no-dereference
    touch $TestFile > /dev/null 2>&1
    chown -h $OTHER_USER1:$OTHER_GROUP1 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown -h: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER1 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown -h: fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      else 
        tet_infoline "chown -h: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp20()
 {
    tpstart "chown --no-dereference: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "affect symbolic links."

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP2=vsxg2
    OTHER_USER2=vsx2

    TESTID=chown    
    TestFile=test.${TESTID}
    
    touch $TestFile > /dev/null 2>&1
    chown --no-dereference $OTHER_USER2:$OTHER_GROUP2 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
     tet_infoline "chown --no-dereference: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
     FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER2 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --no-dereference: fail.  Expected TestFile's owner to change but did not."
     FAIL=Y
      else    
        tet_infoline "chown --no-dereference: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}
#---------------------------------------------------------------
tp21()
 {
    tpstart "chown --from=CUR_OWNER:CUR_GROUP: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "change the owner and/or group of each file"
    tet_infoline "only if its current owner and/or group"
    tet_infoline "match those specified."

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP1=vsxg1
    OTHER_USER1=vsx1
    OTHER_GROUP2=vsxg2
    OTHER_USER2=vsx2

    TESTID=chown    
    TestFile=test.${TESTID}
    
    
#Test chown with option: --from        ***BUG***NOT WORKING***
    rm -f $TestFile > /dev/null 2>&1
    touch $TestFile > /dev/null 2>&1
    chown $OTHER_USER2:$OTHER_GROUP2 $TestFile > /dev/null 2>&1
    chown --from=$OTHER_USER2:$OTHER_GROUP2 $OTHER_USER1:$OTHER_GROUP1 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --from=CUR_OWNER:CUR_GRP: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER1 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ $TC_EXIT_VALUE -ne 0 ]; then
        tet_infoline "chown --from=CUR_OWNER:CUR_GRP: fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chown --from=CUR_OWNER:CUR_GRP :pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}
    
#---------------------------------------------------------------
tp22()
 {
    tpstart "chown -f: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "suppress most error messages"

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP2=vsxg2
    OTHER_USER2=vsx2

    TESTID=chown    
    TestFile=test.${TESTID}
    
#Test chown with option: -f, --silent, --quiet
    touch $TestFile > /dev/null 2>&1
    chown -f $OTHER_USER2:$OTHER_GROUP2 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown -f: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER2 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown -f : fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chown -f :pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp23()
 {
    tpstart "chown --silent: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "suppress most error messages"

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP1=vsxg1
    OTHER_USER1=vsx1

    TESTID=chown    
    TestFile=test.${TESTID}
    
    touch $TestFile > /dev/null 2>&1
    chown --silent $OTHER_USER1:$OTHER_GROUP1 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --silent: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER1 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --silent: fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chown --silent:pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}
    
tp24()
 {
    tpstart "chown --quiet: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "suppress most error messages"

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP2=vsxg2
    OTHER_USER2=vsx2

    TESTID=chown    
    TestFile=test.${TESTID}
    
    touch $TestFile > /dev/null 2>&1
    chown --quiet $OTHER_USER2:$OTHER_GROUP2 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --quiet: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER2 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --quiet: fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chown --quiet: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}
#---------------------------------------------------------------
tp25()
 {
    tpstart "chown --reference=RFILE: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "use RFILE's owner and group."

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP1=vsxg1
    OTHER_USER1=vsx1

    TESTID=chown    
    TestFile=test.${TESTID}
    
#Test chown with option:  --reference
    touch $TestFile > /dev/null 2>&1
    chown $OTHER_USER1:$OTHER_GROUP1 $TestFile > /dev/null 2>&1
#Make sure chown works
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown is not working"
	tpresult UNRESOLVED
 	return
    else 
    
#Check to see the testfile's owner is actually changed.
     ls -l $TestFile | grep $OTHER_USER1 > /dev/null 2>&1
     TC_EXIT_VALUE=$?
     if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --reference: chown is not working"
	tpresult UNRESOLVED
 	return
     else 
#chown works: now test chown --reference

    touch tmp2.${TESTID} > /dev/null 2>&1
    chown --reference=$TestFile tmp2.${TESTID} > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --reference=RFILE: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l tmp2.${TESTID} | grep $OTHER_USER1 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown -reference=RFILE: pass"
      else
        tet_infoline "chown --reference=RFILE: fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      fi
     fi
    fi
   fi
    rm -f $TestFile tmp2.${TESTID} > /dev/null 2>&1
    tpresult
}
#---------------------------------------------------------------
tp26()
 {
    tpstart "chown -v: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "output a diagnostic message for every file processed."

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP1=vsxg1
    OTHER_USER1=vsx1

    TESTID=chown    
    TestFile=test.${TESTID}
    
#Test chown with option: -v, --verbose 
    touch $TestFile > /dev/null 2>&1
    chown -v $OTHER_USER1:$OTHER_GROUP1 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown -v: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER1 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown -v: fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chown -v: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}

tp27()
 {
    tpstart "chown --verbose: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "output a diagnostic message for every file processed."

#The four assignment statements below need to change to appropriate values:
    OTHER_GROUP2=vsxg2
    OTHER_USER2=vsx2

    TESTID=chown    
    TestFile=test.${TESTID}
    
    touch $TestFile > /dev/null 2>&1
    chown --verbose $OTHER_USER2:$OTHER_GROUP2 $TestFile > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --verbose: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else
#Check to see the testfile's owner is actually changed.
      ls -l $TestFile | grep $OTHER_USER2 > /dev/null 2>&1
      TC_EXIT_VALUE=$?
      if [ ! $TC_EXIT_VALUE -eq 0 ]; then
        tet_infoline "chown --verbose: fail.  Expected TestFile's owner to change but did not."
	FAIL=Y
      else
        tet_infoline "chown --verbose: pass"
      fi
    fi
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}
#---------------------------------------------------------------
tp28()
 {
    tpstart "chown -v: change file owner and group. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "output version info."
    TESTID=chown    
    TestFile=test.${TESTID}

#Test chown with option: --version
    touch $TestFile > /dev/null 2>&1
    chown --version > $TestFile 2> /dev/null 
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -ne 0 -o ! -s $TestFile ]; then
        tet_infoline "chown --version: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    else 
        tet_infoline "chown --version: pass"
    fi

#Remove all temp files
   rm -f $TestFile > /dev/null 2>&1
   tpresult
} # End of LSB-chown 

###########################################################################
#
# Command:    chsh
# Standard:   LSB
#
###########################################################################

###########################################################################
#
# - Assumptions:
# - 	1)Tester has super-user privilege.
# - 	2)All other commands used in this script work.
# - 
# - Strategy Statement:
# - 	Change a given user's login shell and check the result.
# - 
# - Expected Results:
# -     the user's login shell should change appropriately.
# - 	
# - Other Commands Used:
# -	while-do loop, break, uberpass -U -s, grep
# - uberpass is a c helper function that exists in 
# - 	.../test_sets/LSB.usersgroups/commands/misc/uberpass.c
# -
###########################################################################

tp29()
 {
    tpstart "chsh -s: change login shell. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "login shell should changed for the test user."

#Make sure the test user exists.
    OTHER_USER=vsxyy123
    user_exist_add $OTHER_USER
    if [ $? -ne 0 ]; then
	return
    fi
 
    NEW_LOGIN_SHELL=/bin/ksh
#make sure /bin/ksh exists
   cat /etc/shells | grep $NEW_LOGIN_SHELL > /dev/null 2>&1
   if [ $? -ne 0 ]; then
      NEW_LOGIN_SHELL=/bin/bash
   fi

#Begin to test chsh 
    OLD_SHELL=$(./uberpass -U -s $OTHER_USER)
    chsh -s $NEW_LOGIN_SHELL $OTHER_USER  > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -ne 0 ]; then
        tet_infoline "chsh : fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
   else 
#Wait until the data base is up to date
	NEW_SHELL=$(./uberpass -U -s $OTHER_USER)
	counter=0
	while [ "$OLD_SHELL" = "$NEW_SHELL" -a $counter -le 60 ]; do
		sleep 6 
		NEW_SHELL=$(./uberpass -U -s $OTHER_USER)
		echo "$counter : waiting for chsh to update to $NEW_LOGIN_SHELL: $NEW_SHELL"
		counter=`expr $counter + 1`
#in case the db is updated instantaneously
		if [ "$NEW_SHELL" = "$NEW_LOGIN_SHELL" ]; then
			counter=61
		fi
	done
	
#Check to see if output is correct 
      ./uberpass -U -s $OTHER_USER | grep "$NEW_LOGIN_SHELL" > /dev/null 2>&1
      if [ $? -eq 0 ]; then
        tet_infoline "chsh -s: pass"
      else
        tet_infoline "chsh -s: fail.  Login shell did not change." 
	FAIL=Y
      fi
   fi
   tpresult

} # End of LSB-chsh 

###########################################################################
#
# Command:    chfn
# Standard:   LSB 
#
###########################################################################

###########################################################################
#
# - Assumptions:
# - 	1)Tester has super-user privilege.
# -	2)All of the commands used in this script work.
# -		
# - Strategy Statement:
# - 	Execute chfn and test all its options.
# - 
# - Expected Results:
# -    	As specified in the spec. 
# - 
# - Other Commands/functions Used:
# -	grep, rm -f, uberpass -U -c.
# - uberpass is a c helper function that exists in 
# - 	.../test_sets/LSB.usersgroups/commands/misc/uberpass.c
#
###########################################################################

tp30()
 {
    tpstart "chfn -f: set the user's full name - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "User's fullname should change accordingly."

    OTHER_USER=vsxyy123
#Make sure the user exists.
    user_exist_add $OTHER_USER
    if [ $? -ne 0 ]; then
	return
    fi
 
#Test chfn with option: -f
    chfn -f "Longhorns_Rock" $OTHER_USER  > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -eq 0 ]; then
#Wait until the database is up to date
    PHRASE="Longhorns_Rock"
    check_update_db $OTHER_USER $PHRASE

#Check to see if output is correct 
      ./uberpass -U -c $OTHER_USER | grep "Longhorns_Rock" > /dev/null 2>&1
      if [ $? -eq 0 ]; then
        tet_infoline "chfn -f: pass"
      else
        tet_infoline "chfn -f: fail.  Full name did not change." 
	FAIL=Y
      fi
    else
        tet_infoline "chfn -f: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    fi
    tpresult
}
#---------------------------------------------------------------
tp31()
 {
    tpstart "chfn -r: set the user's room number. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "User's room number should change accordingly."
    tet_infoline "Note: Removed by SA(Spec Authority) ruling on Bug(524042)."
    tpresult NOTINUSE		# set result code

#original test code commented out.
#
#    OTHER_USER=vsxyy123
##Make sure the user exists.
#    user_exist_add $OTHER_USER
#    if [ $? -ne 0 ]; then
#	return
#    fi
# 
##Test chfn with option: -r
#    chfn -r "908_1E036" $OTHER_USER  > /dev/null 2>&1 
#    TC_EXIT_VALUE=$?
#    if [ $TC_EXIT_VALUE -eq 0 ]; then
#
##Wait until the database is up to date
#    PHRASE="908_1E036"
#    check_update_db $OTHER_USER $PHRASE
#
##Check to see if output is correct 
#      ./uberpass -U -c $OTHER_USER | grep "908_1E036" > /dev/null 2>&1
#      if [ ! $? -eq 0 ]; then
#        tet_infoline "chfn -r: fail.  Room number did not change." 
#	FAIL=Y
#      else
#        tet_infoline "chfn -r: pass"
#      fi
#    else
#        tet_infoline "chfn -r: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
#	FAIL=Y
#    fi
#    tpresult
}
#---------------------------------------------------------------
tp32()
 {
    tpstart "chfn -w: set the user's work phone number. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "User's work phone number should change accordingly."
    tet_infoline "Note: Removed by SA(Spec Authority) ruling on Bug(524042)."
    tpresult NOTINUSE		# set result code

#original test code commented out.
#    OTHER_USER=vsxyy123
##Make sure the user exists.
##Test chfn with option: -w
#    user_exist_add $OTHER_USER
#    if [ $? -ne 0 ]; then
#	return
#    fi
# 
#    chfn -w "512-888-8888" $OTHER_USER > /dev/null 2>&1
#    TC_EXIT_VALUE=$?
#    if [ $TC_EXIT_VALUE -eq 0 ]; then
#
##Wait until the database is up to date
#    PHRASE="512-888-8888"
#    check_update_db $OTHER_USER $PHRASE
#
##Check to see if output is correct 
#      ./uberpass -U -c $OTHER_USER | grep "512-888-8888" > /dev/null 2>&1
#      if [ ! $? -eq 0 ]; then
#        tet_infoline "chfn -w: fail.  Work phone number did not change." 
#	FAIL=Y
#      else
#        tet_infoline "chfn -w: pass"
#      fi
#    else
#        tet_infoline "chfn -w: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
#	FAIL=Y
#    fi
#    tpresult
}
#---------------------------------------------------------------
tp33()
 {
    tpstart "chfn -h: set the user's home phone number. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "User's home phone number should change accordingly."

    OTHER_USER=vsxyy123
#Make sure the user exists.
    user_exist_add $OTHER_USER
    if [ $? -ne 0 ]; then
	return
    fi
 
#Test chfn with option: -h
    chfn -h "512-888-8888" $OTHER_USER  > /dev/null 2>&1 
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -eq 0 ]; then

#Wait until the database is up to date
    PHRASE="512-888-8888"
    check_update_db $OTHER_USER $PHRASE

#Check to see if output is correct 
      ./uberpass -U -c  $OTHER_USER | grep "512-888-8888" > /dev/null 2>&1
      if [ ! $? -eq 0 ]; then
        tet_infoline "chfn -h: fail.  Home phone number did not change."
	FAIL=Y
      else
        tet_infoline "chfn -h: pass"
      fi
    else
        tet_infoline "chfn -h: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    fi
    tpresult
}
#---------------------------------------------------------------
tp34()
 {
    tpstart "chfn -o: set the user's finger info other field contents. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "User's other field contents should change accordingly."
    tet_infoline "Note: Removed by SA(Spec Authority) ruling on Bug(524042)."
    tpresult NOTINUSE		# set result code

#original test code commented out.
#    OTHER_USER=vsxyy123
##Make sure the user exists.
#    user_exist_add $OTHER_USER
#    if [ $? -ne 0 ]; then
#	return
#    fi
# 
##Test chfn with option: -o
#    chfn -o "Carpe_Diem" $OTHER_USER   > /dev/null 2>&1
#    TC_EXIT_VALUE=$?
#    if [ $TC_EXIT_VALUE -eq 0 ]; then
#
##Wait until the database is up to date
#    PHRASE="Carpe_Diem"
#    check_update_db $OTHER_USER $PHRASE
#
##Check to see if output is correct 
#      ./uberpass -U -c $OTHER_USER | grep "Carpe_Diem" > /dev/null 2>&1
#      if [ $? -eq 0 ]; then
#        tet_infoline "chfn -o: pass"
#      else
#        tet_infoline "chfn -o: fail.  Other info did not change." 
#	FAIL=Y
#      fi
#    else
#        tet_infoline "chfn -o: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
#	FAIL=Y
#    fi
#    remove_user $OTHER_USER
#    tpresult
} # End of LSB-chfn 

###########################################################################
#
# Command:    groups
# Standard:   LSB 
#
###########################################################################

###########################################################################
#
# - Assumptions:
# -     1)Tester needs to supply  a valid user name that exists on the 
# -		system.
# -	2)All other commands used in this script work.
# -	
# - Strategy Statement:
# - 	Execute groups and check its result.
# - 
# - Expected Results:
# -    	As specified in the spec. 
# - 
# - Other Commands Used:
# - 	grep, rm -f, uberpass -U -n
# - uberpass is a c helper function that exists in 
# - 	.../test_sets/LSB.usersgroups/commands/misc/uberpass.c
#
###########################################################################
tp35() 
{
    tpstart "groups - display groups the user is in. - Reference the Commands and Utilities chapter in the Specification"

#Add a test user 
    OTHER_USER=vsx42
    useradd -g supp19 $OTHER_USER > /dev/null 2>&1
    if [ $? -ne 0 ]; then
	tet_infoline "Un-able to add a test user: useradd -g "
	tpresult UNRESOLVED	
    	return
    fi
    
    groups $OTHER_USER  > /dev/null 2>&1 
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -eq 0 ]; then

#Check to see if output is correct 
      GROUPO=$(./uberpass -U -n $OTHER_USER ) 2>/dev/null
      groups $OTHER_USER | grep $GROUPO  > /dev/null 2>&1
      if [ $? -eq 0 ]; then
        tet_infoline "groups : pass"
      else
        tet_infoline "groups : fail.  Standard output is not the same as Expected output."
	FAIL=Y
      fi
    else
        tet_infoline "groups : fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	FAIL=Y
    fi
    remove_user $OTHER_USER
    tpresult
} # End of LSB-groups 


###########################################################################
#
# Command:    newgrp
# Standard:   LSB 
#
###########################################################################

###########################################################################
#
# - Assumptions:
# - 	1)Tester has super-user privilege.
# -	2)All of the commands used in this script work.
# - 
# - Strategy Statement:
# - 	Execute newgrp and test all its options.
# - 
# - Expected Results:
# -    	As specified in the spec. 
# - 
# - Other Commands Used:
# -	cat, grep, rm -f, groups, exit, cpt
# - cpt is a c helper function that exists in 
# - 	.../test_sets/LSB.usersgroups/commands/misc/cpt.c
#
###########################################################################

tp36()
 {
    tpstart "newgrp - change group ID. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "Should change to a new group."
    
#Add a test group 
    OTHER_GROUP=vsxg20
    groupadd $OTHER_GROUP
    if [ $? -ne 0 ]; then
	tet_infoline "Un-able to add a test group: groupadd "
	tpresult UNRESOLVED	
    	return
    fi
    
#Begin to test newgrp: 
	./cpt newgrp $OTHER_GROUP << EOF
groups > /tmp/groups.output
exit
EOF

#Check results:
    	cat /tmp/groups.output | grep $OTHER_GROUP > /dev/null 2>&1
	if [ $?  -eq 0 ]; then
           tet_infoline "newgrp : pass"
	else
	   tet_infoline "newgrp : fail.  Did not change the group's newgrp."
	   FAIL=Y
        fi

#Remove all temp files
    	remove_group $OTHER_GROUP
    	rm -f /tmp/groups.output > /dev/null 2>&1
	tpresult
} # End of LSB-newgrp 

tp37()
{
  tpstart "usermod -s :Modify a user account. - Reference the Commands and Utilities chapter in the Specification"

#pick the user to be removed by this script
user_to_add=vsx21
user_shell="/bin/foo"


#Tests usermod -s functionality
    useradd $user_to_add  > /dev/null 2>&1
	  if [ $? -eq 0 ]; then
	    usermod -s $user_shell $user_to_add > /dev/null 2>&1
		if [ $? -eq 0 ]; then
		  test_useradd_shell $user_to_add $user_shell
			if [ $? -eq 0 ]; then
			  tet_infoline "usermod -s PASS"
			  remove_user $user_to_add
			else
			  FAIL=Y
			  tet_infoline "usermod -s FAIL: Could not verify shell changed for user $user_name"
			  remove_user $user_to_add
			fi
		else
		  FAIL=Y
		  tet_infoline "usermod -s FAIL: Could not change shell for user $user_name"
		  remove_user $user_to_add
		fi
	  else
		tet_infoline "usermod -s UNRESOLVED: Can not add a test user $user_to_add"
		tpresult UNRESOLVED
		return 
	  fi
  tpresult
}
#---------------------------------------------------------------
tp38()
{
  tpstart "usermod -u :Modify a user account. - Reference the Commands and Utilities chapter in the Specification"

#pick the user to be removed by this script
user_to_add=vsx22
other_uid=$(unique_id)


#Tests usermod -u functionality
    useradd $user_to_add  > /dev/null 2>&1
	  if [ $? -eq 0 ]; then
	    usermod -u $other_uid $user_to_add > /dev/null 2>&1
		if [ $? -eq 0 ]; then
		  test_useradd_uid $user_to_add $other_uid
			if [ $? -eq 0 ]; then
			  tet_infoline "usermod -u PASS"
			  remove_user $user_to_add
			else
			  FAIL=Y
			  tet_infoline "usermod -u FAIL: Could not verify uid changed for user $user_name"
			  remove_user $user_to_add
			fi
		else
		  FAIL=Y
		  tet_infoline "usermod -u FAIL: Could not change uid for user $user_name"
		  remove_user $user_to_add
		fi
	  else
		tet_infoline "usermod -u UNRESOLVED: Can not add a test user $user_to_add"
		tpresult UNRESOLVED
		return 
	  fi
  tpresult
}
#---------------------------------------------------------------
tp39()
{
  tpstart "usermod -e :Modify a user account. - Reference the Commands and Utilities chapter in the Specification"
  
#pick the user to be removed by this script
user_to_add=vsx23
expiration_date="1970-1-2"

#Tests usermod -e functionality
    useradd $user_to_add  > /dev/null 2>&1
	  if [ $? -eq 0 ]; then
	    usermod -e $expiration_date $user_to_add > /dev/null 2>&1
		if [ $? -eq 0 ]; then
		  test_useradd_expire $user_to_add $expiration_date
			if [ $? -eq 0 ]; then
			  tet_infoline "usermod -e PASS"
			  remove_user $user_to_add
			else
			  FAIL=Y
			  tet_infoline "usermod -e FAIL: Could not verify expiration date changed for user $user_name"
			  remove_user $user_to_add
			fi
		else
		  FAIL=Y
		  tet_infoline "usermod -e FAIL: Could not change expiration date for user $user_name"
		  remove_user $user_to_add
		fi
	  else
		tet_infoline "usermod -e UNRESOLVED: Can not add a test user $user_to_add"
		tpresult UNRESOLVED
		return 
	  fi
  tpresult
}

###########################################################################
#
# Command:    passwd
# Standard:   LSB 
#
###########################################################################

###########################################################################
#
# - Assumptions:
# - 	1)Tester has super-user privilege.
# -	2)All of the commands used in this script work.
# - 
# - Strategy Statement:
# - 	Execute passwd and test all its options.
# - 
# - Expected Results:
# -    	As specified in the spec. 
# - 
# - Note:
# -	passwd -g, -gr and -gR are tested in 
# -		.../tset/LSB.usersgroups/command/passwd/passwd-tc.sh
# -
# - Other Commands Used:
# -	newgrp, cat, grep, rm -f, cpt, uberpass -S -p
# - cpt is a c helper function that exists in 
# - 	.../test_sets/LSB.usersgroups/commands/misc/cpt.c
# - uberpass is a c helper function that exists in 
# - 	.../test_sets/LSB.usersgroups/commands/misc/uberpass.c
#
###########################################################################
tp40()
 {
    tpstart "passwd - change a user password.  - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "Password for the user should be change."
    
#Add a test user
    OTHER_USER=vsx21
    useradd $OTHER_USER > /dev/null 2>&1
    if [ $? -ne 0 ]; then
	tet_infoline "Un-able to add a test user: useradd "
	tpresult UNRESOLVED	
    	return
    fi
    
#Test passwd with NO option: 
	OLD_PASSWORD=$(./uberpass -S -p $OTHER_USER)

   TestFile=test.passwd

cat > $TestFile << EOF
t3st1ng.
t3st1ng.
EOF

    ./cpt passwd $OTHER_USER < $TestFile > /dev/null 2>&1 
	if [ $? -eq 0 ]; then
		NEW_PASSWORD=$(./uberpass -S -p $OTHER_USER)
		if [ "$OLD_PASSWOR" = "$NEW_PASSWORD" ]; then
			FAIL=Y
			tet_infoline "user password did not change."
		else
			tet_infoline "passwd : PASS"	
		fi
	else
		tet_infoline "passwd : FAIL"	
		FAIL=Y
	fi

    remove_user $OTHER_USER
    rm -f $TestFile > /dev/null 2>&1
    tpresult
}
#---------------------------------------------------------------
tp41()
 {
    tpstart "passwd -x: set the max number of days a password remains valid.  - Reference the Commands and Utilities chapter in the Specification"

    
#Add a test user
    OTHER_USER=vsx21
    useradd -p texansabcdefg $OTHER_USER > /dev/null 2>&1
    if [ $? -ne 0 ]; then
	tet_infoline "Un-able to add a test user with a given password: useradd -p"
	tpresult UNRESOLVED	
    	return
    fi
    
#Test passwd with option: -x
    passwd -x 384 $OTHER_USER > /dev/null 2>&1 
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -eq 0 ]; then

#Check to makesure it does what it supposes to:
	./uberpass -S -x $OTHER_USER | grep 384 > /dev/null 2>&1
	if [ $? -eq 0 ]; then
          tet_infoline "passwd -x: pass"
	else
	  tet_infoline "passwd -x: fail.  Maximum number of days did not change."
	  FAIL=Y
	fi
    else
        tet_infoline "passwd -x: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	  FAIL=Y
    fi
    remove_user $OTHER_USER
    tpresult
}
#---------------------------------------------------------------
tp42()
 {
    tpstart "passwd -n: set the min number of days before a password may be changed.  - Reference the Commands and Utilities chapter in the Specification"
    
#Add a test user
    OTHER_USER=vsx21
    useradd -p texansabcdefg $OTHER_USER > /dev/null 2>&1
    if [ $? -ne 0 ]; then
	tet_infoline "Un-able to add a test user with a given password: useradd -p"
	tpresult UNRESOLVED	
    	return
    fi
    
#Test passwd with option: -n
    passwd -n 132 $OTHER_USER > /dev/null 2>&1 
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -eq 0 ]; then
#Check to makesure it does what it supposes to:
	./uberpass -S -n $OTHER_USER | grep 132 > /dev/null 2>&1
	if [ $? -eq 0 ]; then
          tet_infoline "passwd -n: pass"
	else
	  tet_infoline "passwd -n: fail.  Minimum number of days did not change."
	  FAIL=Y
	fi
    else
        tet_infoline "passwd -n: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	  FAIL=Y
    fi
    remove_user $OTHER_USER
    tpresult
}
#---------------------------------------------------------------
tp43()
 {
    tpstart "passwd -w: Set the number of days warning the user will receive before their password will expire. - Reference the Commands and Utilities chapter in the Specification"
    
#Add a test user
    OTHER_USER=vsx21
    useradd -p texansabcdefg $OTHER_USER > /dev/null 2>&1
    if [ $? -ne 0 ]; then
	tet_infoline "Un-able to add a test user with a given password: useradd -p"
	tpresult UNRESOLVED	
    	return
    fi
    
#Test passwd with option: -w
    passwd -w 13 $OTHER_USER > /dev/null 2>&1 
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -eq 0 ]; then
#Check to makesure it does what it supposes to:
	./uberpass -S -w $OTHER_USER | grep 13 > /dev/null 2>&1
	if [ $? -eq 0 ]; then
          tet_infoline "passwd -w: pass"
	else
	  tet_infoline "passwd-w: fail.  Number of days to warn user did not change."
	  FAIL=Y
	fi
    else
        tet_infoline "passwd -w: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	  FAIL=Y
    fi
    remove_user $OTHER_USER
    tpresult
}
#---------------------------------------------------------------
tp44()
 {
    tpstart "passwd -i: Disable an account after the password has been expired for the given number of days. - Reference the Commands and Utilities chapter in the Specification"
    
#Add a test user
    OTHER_USER=vsx21
    useradd -p texansabcdefg $OTHER_USER > /dev/null 2>&1
    if [ $? -ne 0 ]; then
	tet_infoline "Un-able to add a test user with a given password: useradd -p"
	tpresult UNRESOLVED	
    	return
    fi
    
#Test passwd with option: -i
    passwd -i 4 $OTHER_USER > /dev/null 2>&1
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -eq 0 ]; then
#Check to makesure it does what it supposes to:
	./uberpass -S -i $OTHER_USER | grep 4 > /dev/null 2>&1
	if [ $? -eq 0 ]; then
          tet_infoline "passwd -i: pass"
	else
	  tet_infoline "passwd-i: fail.  Number of inactive days did not change."
	  FAIL=Y
	fi
    else
        tet_infoline "passwd -i: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	  FAIL=Y
    fi
    remove_user $OTHER_USER
    tpresult
}
#---------------------------------------------------------------
tp45()
 {
    tpstart "passwd -l: Disable an account by changing its password. - Reference the Commands and Utilities chapter in the Specification"

#Add a test user
    OTHER_USER=vsx21
    useradd -p texansabcdefg $OTHER_USER > /dev/null 2>&1
    if [ $? -ne 0 ]; then
	tet_infoline "Un-able to add a test user with a given password: useradd -p"
	tpresult UNRESOLVED	
    	return
    fi
    
#Test passwd with option: -l
    OLD_PASSWD=$(./uberpass -S -p $OTHER_USER)

    passwd -l $OTHER_USER > /dev/null 2>&1 
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -eq 0 ]; then

#Check to makesure it does what it supposes to:
	NEW_PASSWD=$(./uberpass -S -p $OTHER_USER) > /dev/null 2>&1
	if [ "$OLD_PASSWD" = "$NEW_PASSWD" ]; then
          tet_infoline "passwd -l: fail.  Password did not change."
	  FAIL=Y
	else
          tet_infoline "passwd -l: pass"
	fi
    else
        tet_infoline "passwd -l: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	  FAIL=Y
    fi
    remove_user $OTHER_USER
    tpresult
}
#---------------------------------------------------------------
tp46()
 {
    tpstart "passwd -u: Re-enable an account. - Reference the Commands and Utilities chapter in the Specification"
    tet_infoline "The account's password should change back to "
    tet_infoline "its previous value."

#Add a test user
    OTHER_USER=vsx21
    useradd -p texansabcdefg $OTHER_USER > /dev/null 2>&1
    if [ $? -ne 0 ]; then
	tet_infoline "Un-able to add a test user with a given password: useradd -p"
	tpresult UNRESOLVED	
    	return
    fi
    
#Test passwd with option: -u
    OLD_PASSWD=$(./uberpass -S -p $OTHER_USER)
    passwd -l $OTHER_USER > /dev/null 2>&1
    if [ $? -ne 0 ]; then
	tet_infoline "Un-able to lock the user password: passwd -l"
	tpresult UNRESOLVED	
    	return
    fi

    passwd -u $OTHER_USER > /dev/null 2>&1 
    TC_EXIT_VALUE=$?
    if [ $TC_EXIT_VALUE -eq 0 ]; then

#Check to makesure it does what it supposes to:
	NEW_PASSWD=$(./uberpass -S -p $OTHER_USER)
	if [ "$OLD_PASSWD" = "$NEW_PASSWD" ]; then
          tet_infoline "passwd -u: pass"
	else
          tet_infoline "passwd -u: fail.  Password did not change."
	  FAIL=Y
	fi
    else
        tet_infoline "passwd -u: fail.  Expected exit code = 0; Received $TC_EXIT_VALUE."
	  FAIL=Y
    fi

    remove_user $OTHER_USER
    tpresult
} # End of LSB-passwd 


##########################################################################
#
# Command:	groupadd
# Standard:	LSB
#
##########################################################################

##########################################################################
#
#-Assumptions:
#-	1)Tester has super-user privileges.
#-	2)All commands in this script work.
#-	
#-Strategy Statement:
#-	Create a test group with certain properties.  Confirm the 
#-	existence of that group with specified properties.
#-
#-Expected results:
#-	Groups will be correctly created
#-
#-Notes:
#-	Root password is required
#-
#-Other commands used:
#	See $TET_EXECUTE/SRC/common/lsblib/usergroups_funcs.sh
#	for special functions
#
##########################################################################

tp47()
{
  tpstart "groupadd : Create a new group - Reference the Commands and Utilities chapter in the Specification"
#pick the group to be added by this script
#see note above for special function unique_group()
  group_to_add=vsxg20

#Tests bare groupadd functionality
#see note above for special functions execute_groupadd(), test_groupadd()
#and remove_group()

	execute_groupadd $group_to_add
	  if [ $? -eq 0 ]; then
		test_groupadd $group_to_add
		if [ $? -eq 0 ]; then
		  remove_group $group_to_add
		else
		  FAIL=Y
		  remove_group $group_to_add
		fi
	  elif [ $? -eq 1 ]; then
		  FAIL=Y
	  else
#Returns unresolved result
		tpresult UNRESOLVED
		return 3
	  fi

#Returns results	  
  tpresult
}
#---------------------------------------------------------------
tp48()
{
  tpstart "groupadd -g: Create a new group - Reference the Commands and Utilities chapter in the Specification"

#pick the group to be added by this script
#See note above for special functions unique_group() and unique_gid()

  group_to_add=vsxg20
  gid_to_add=4242


#Tests groupadd -g
#See note above for special functions execute_groupadd_gid(), 
#test_groupadd_gid(), and remove_group()

	execute_groupadd_gid $group_to_add $gid_to_add
	if [ $? -eq 0 ]; then
	  test_groupadd_gid $group_to_add $gid_to_add
	  if [ $? -eq 0 ]; then
		remove_group $group_to_add
	  else
		FAIL=Y
		remove_group $group_to_add
	  fi
	elif [ $? -eq 1 ]; then
	  FAIL=Y
#Returns unresolved error
	else
	  tpresult UNRESOLVED
	  return 3
	fi
#Returns results
  tpresult 
}
#---------------------------------------------------------------
tp49()
{
  tpstart "groupadd -g -o  : Create a new group - Reference the Commands and Utilities chapter in the Specification"
#pick the group to be added by this script
#See note above about special functions unique_group() and unique_gid()

  group_to_add=vsxg20
  gid_to_add=4242

#Tests groupadd -g -o
#See note above about special functions execute_groupadd_gid(), 
#test_groupadd_gid(), execute_groupadd_override(), 
#test_groupadd_override(), remove_group()

	execute_groupadd_gid $group_to_add $gid_to_add
	if [ $? -eq 0 ]; then
	  test_groupadd_gid $group_to_add $gid_to_add
	  if [ $? -eq 0 ]; then
            other_group=foo4
	    execute_groupadd_override $other_group $gid_to_add
	       if [ $? -eq 0 ]; then
		  test_groupadd_override $group_to_add $other_group $gid_to_add
		    if [ $? -eq 0 ]; then
		      remove_group $group_to_add
		      remove_group $other_group
		    else
		      FAIL=Y
		      remove_group $group_to_add
		      remove_group $other_group
		    fi
		elif [ $? -eq 1 ]; then
		    FAIL=Y	
		    remove_group $group_to_add
	        else
		  tpresult UNRESOLVED
		  remove_group $group_to_add
		  return 3
	        fi
	   else
	       tpresult UNRESOLVED
	       remove_group $group_to_add
	       return 3
	   fi
	else
	  tpresult UNRESOLVED
	  return 3
	fi
#Returns result unless an unresolved error is found above
  tpresult 
}

##########################################################################
#
# Command:	groupdel
# Standard:	LSB
#
##########################################################################

##########################################################################
#
#-Assumptions:
#-	1)Tester has super-user privileges.
#-	2)All commands in this script work.
#-	
#-Strategy Statement:
#-	Create a test group.  Confirm the group exists.  Remove the group.
#-	Confirm its removal.
#-
#-Expected results:
#-	Groups will be correctly removed.
#-
#-Notes:
#-	Root password is required.
#-
#-Other commands used:
#	See $TET_EXECUTE/SRC/common/lsblib/usergroups_funcs.sh
#	for special functions.
#
##########################################################################
tp50()
{

   	tpstart "groupdel : delete a group - Reference the Commands and Utilities chapter in the Specification"
#Pick a unique group
#See the above note about the special function unique_group()
	group_to_del=vsxg20

#Add the new group
#See the above note about the special function execute_groupadd()

	execute_groupadd $group_to_del
	if [ $? -ne 0 ]; then
		tpresult UNRESOLVED	
		return
	fi
#Remove the group
#Ditto for the special function group_dne()

	groupdel $group_to_del > /dev/null 2>&1
 	if [ $? -eq 0 ]; then
    		group_dne $group_to_del >/dev/null 2>&1
		if [ $? -eq 0 ]; then
			tet_infoline "groupdel: pass"
		else
			re_do=0
			FAIL=Y
			tet_infoline "groupdel: fail"
		fi
	elif [ $? -eq 8 ]; then
		tpresult UNRESOLVED	
		tet_infoline "Attempt to delete a primary group" 
		return
 	else 
		tet_infoline "groupdel: fail"
		FAIL=Y
		re_do=0
	fi
#try to remove the group again, just in case

  remove_group $group_to_del
  tpresult 
}
##########################################################################
#
# Command:	groupmod
# Standard:	LSB
# 
##########################################################################

##########################################################################
#
#-Assumptions:
#-	1)Tester has super-user privileges
#-	2)All commands in this script work
#-	
#-Strategy:
#-	Add a group.  Modify it.  Confirm that the correct modification 
#-	was executed.
#-
#-Expected Results:
#-	The group will be modified as expected.
#-
#-Notes:
#-	Root password is required.
#-
#-Other commands used:
#	See $TET_EXECUTE/SRC/common/lsblib/usergroups_funcs.sh
#	for special functions.
#
##########################################################################

tp51 ()
{
  	tpstart "groupmod : modify a group - Reference the Commands and Utilities chapter in the Specification"
	group_to_change=vsxg20

#Add the new group to test
#See comment above about special functions execute_groupadd()

	execute_groupadd $group_to_change 
	if [ $? -ne 0 ]; then
		tet_infoline "Un-able to add new group: $group_to_change"
		tpresult UNRESOLVED
		return 
	fi
#unique_group() is a special function. See note above.

	other_name=foo4

#Tests groupmod -n functionality
	groupmod -n $other_name $group_to_change  > /dev/null 2>&1
	if [ $? -eq 0 ]; then
#Check if groupname is changed.
#group_dne() and remove_group() are special functions.  See note above.

		group_dne $other_name
		if [ $? -eq 0 ]; then
			tet_infoline "groupmod -n :fail.  Could not change name"
			FAIL=Y
			remove_group $group_to_change
		else
			tet_infoline "groupmod -n :pass."
			remove_group $other_name
		fi
	else
		tet_infoline "groupmod -n : fail"
		FAIL=Y
		remove_group $group_to_change
	fi
	tpresult
}
#---------------------------------------------------------------
tp52()
{
  	tpstart "groupmod -g : modify a group - Reference the Commands and Utilities chapter in the Specification"
#unique_group() and unique_gid() are special functions.  See note above.
	group_to_change=vsxg20
	gid_to_change=4242

#Add the new group to test
#execute_groupadd() is a unique function.  See note above.
	execute_groupadd $group_to_change 
	if [ $? -ne 0 ]; then
		tet_infoline "Un-able to add new group"
		tpresult UNRESOLVED
		return 
	fi
		
#Tests groupmod -g functionality
	groupmod -g $gid_to_change $group_to_change  > /dev/null 2>&1
	if [ $? -eq 0 ]; then
#Check if groupgid is changed.
#gid_dne and remove_group are special functions.  See note above.
		gid_dne $gid_to_change
		if [ $? -eq 0 ]; then
			tet_infoline "groupmod -g :fail.  Could not change gid"
			FAIL=Y
		else
			tet_infoline "groupmod -g :pass."
		fi
	else
		tet_infoline "groupmod -g : fail"
		FAIL=Y
	fi
	remove_group $group_to_change
	tpresult
}

tp53()
{
  	tpstart "groupmod -g -o modify a group - Reference the Commands and Utilities chapter in the Specification"
#unique_group() and unique_gid() are special functions.  See note above.

	group_to_change=foo11
	gid_to_change=4211

#Add the new groups to test
#execute_groupadd_gid() is a unique function.  See note above.

	execute_groupadd_gid $group_to_change $gid_to_change
	if [ $? -ne 0 ]; then
		tet_infoline "Un-able to add new group: $group_to_change"
		tpresult UNRESOLVED
		return 
	fi
#unique_group() and unique_gid() are special functions.  See note above.
	
	other_group=foo12
	other_gid=4212

#execute_groupadd_gid() is a special function.  See note above.

	execute_groupadd_gid $other_group $other_gid
	if [ $? -ne 0 ]; then
		tet_infoline "Un-able to add new group: $other_group"
		tpresult UNRESOLVED
		remove_group $group_to_change
		return 
	fi
#modify the group

	groupmod -g $gid_to_change -o $other_group > /dev/null 2>&1
	if [ $? -eq 0 ]; then
		test_groupadd_override $group_to_change $other_group $gid_to_change
		if [ $? -eq 0 ]; then
			tet_infoline "groupmod -g -o: pass"
		else
			tet_infoline "groupmod -g -o: fail.  Did not override gid"
			FAIL=Y
		fi
	else
		tet_infoline "groupmod -g -o: fail"
		FAIL=Y
	fi
	
#remove_group() is a special function.  See note above.

	remove_group $group_to_change
	remove_group $other_group
	tpresult
}
##########################################################################
#
# Command:	useradd
# Standard:	LSB
#
##########################################################################

##########################################################################
#
#-Assumptions:
#-	1)Tester has super-user privileges.
#-	2)All commands used by this test function as designed.
#-
#-Strategy statement:
#-	Add user(s) with certain properties.  Confirm.  Remove user(s)
#-
#-Expected Results:
#-	All documented features of command will be verified.
#-
#-Notes:
#-	Root password is required
#-
#-Other Commands Used:
#-	See $TET_EXECUTE/SRC/common/lsblib/usergroups_funcs.sh
#-	for special functions.
#
##########################################################################

tp54()
{
  tpstart "useradd  :Create a new user. - Reference the Commands and Utilities chapter in the Specification"

#pick the user to be added by this script
#unique_name() is a special function.  See note above.

   user_to_add=vsx24

#Tests bare useradd functionality
#execute_useradd(), test_useradd(), and remove_user() are special 
#functions.  See note above.

    execute_useradd $user_to_add
	  if [ $? -eq 0 ]; then
	  test_useradd $user_to_add
		if [ $? -eq 0 ]; then
		  tet_infoline "useradd : PASS"
		  remove_user $user_to_add
		else
		  tet_infoline "useradd : FAIL"
		  remove_user $user_to_add
			FAIL=Y
		fi
	  elif [ $? -eq 1 ]; then
		  tet_infoline "useradd : FAIL"
		  FAIL=Y
	  else
		tet_infoline UNRESOLVED
		tpresult UNRESOLVED
		return 3
	  fi
  tpresult
}
#---------------------------------------------------------------
tp55()
{
  tpstart "useradd -d :Create a new user. - Reference the Commands and Utilities chapter in the Specification"
  

#pick the user to be added by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx25
other_home=/home/foo

#Tests bare useradd functionality
#execute_useradd_home(), test_useradd_home(), and remove_user() are 
#special functions.  See note above.

    execute_useradd_home $user_to_add $other_home
	  if [ $? -eq 0 ]; then
	  test_useradd_home $user_to_add $other_home
		if [ $? -eq 0 ]; then
		  tet_infoline "useradd -d: PASS"
		  remove_user $user_to_add
		else
		  remove_user $user_to_add
		  tet_infoline "useradd -d: FAIL"
			FAIL=Y
		fi
	  elif [ $? -eq 1 ]; then
		  tet_infoline "useradd -d: FAIL"
		  FAIL=Y
	  else
		tet_infoline UNRESOLVED
		tpresult UNRESOLVED
		return 3
	  fi
  tpresult
}
#---------------------------------------------------------------
tp56()
{
  tpstart "useradd -c :Create a new user. - Reference the Commands and Utilities chapter in the Specification"
  

#pick the user to be added by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx26
user_comment="LSB1.0"

#Tests bare useradd functionality
#execute_useradd_comment(), test_useradd_comment(), and remove_user() are 
#special functions.  See note above.

    execute_useradd_comment $user_to_add $user_comment
	  if [ $? -eq 0 ]; then
	    test_useradd_comment $user_to_add $user_comment
		if [ $? -eq 0 ]; then
		  tet_infoline "useradd -c: PASS"
		  remove_user $user_to_add
		else
		  remove_user $user_to_add
		  tet_infoline "useradd -c: FAIL"
			FAIL=Y
		fi
	  elif [ $? -eq 1 ]; then
		  tet_infoline "useradd -c: FAIL"
		  FAIL=Y
	  else
		tet_infoline UNRESOLVED
		tpresult UNRESOLVED
		return 3
	  fi
  tpresult
}
#---------------------------------------------------------------
tp57()
{
  tpstart "useradd -g :Create a new user. - Reference the Commands and Utilities chapter in the Specification"
  

#pick the user to be added by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx27
group_to_add=vsxg1

#Tests bare useradd functionality
#execute_useradd_gid(), test_useradd_gid(), and remove_user() are 
#special functions.  See note above.

    execute_useradd_gid $user_to_add $group_to_add
	  if [ $? -eq 0 ]; then
	    test_useradd_gid $user_to_add $group_to_add
		if [ $? -eq 0 ]; then
		  tet_infoline "useradd -g: PASS"
		  remove_user $user_to_add
		
		else
		  remove_user $user_to_add
		  tet_infoline "useradd -g: FAIL"
			FAIL=Y
		fi
	  elif [ $? -eq 1 ]; then
		  tet_infoline "useradd -g: FAIL"
		  FAIL=Y
	  else
		tet_infoline UNRESOLVED
		tpresult UNRESOLVED
		return 3
	  fi
  tpresult
}
#---------------------------------------------------------------
tp58()
{
  tpstart "usermod -p :Modify a user account. - Reference the Commands and Utilities chapter in the Specification"
  

#pick the user to be removed by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx28
user_passwd=fooBar

#Tests usermod -p functionality
#execute_useradd_passwd(), test_useradd_passwd(), and remove_user() are 
#special functions.  See note above.

    execute_useradd $user_to_add 
	  if [ $? -eq 0 ]; then
	    usermod -p $user_passwd $user_to_add > /dev/null 2>&1
		if [ $? -eq 0 ]; then
		  test_useradd_passwd $user_to_add $user_passwd
			if [ $? -eq 0 ]; then
			  tet_infoline "usermod -p PASS"
			  remove_user $user_to_add
			else
			  FAIL=Y
			  tet_infoline "usermod -p FAIL: Could not verify password changed for user $user_name"
			  remove_user $user_to_add
			fi
		else
		  FAIL=Y
		  tet_infoline "usermod -p FAIL: Could not change passwd for user $user_name"
		  remove_user $user_to_add
		fi
	  else
		tet_infoline "usermod -p UNRESOLVED: Can not add a test user $user_to_add"
		tpresult UNRESOLVED
		return 
	  fi
  tpresult
}
#---------------------------------------------------------------
tp59()
{
  tpstart "useradd -u :Create a new user. - Reference the Commands and Utilities chapter in the Specification"
  

#pick the user to be added by this script
#unique_name() and unique_id() are special functions.  See note above.

user_to_add=vsx29
user_uid=$(unique_id)

#Tests bare useradd functionality
#execute_useradd_uid(), test_useradd_uid(), and remove_user() are 
#special functions.  See note above.


    execute_useradd_uid $user_to_add $user_uid
	  if [ $? -eq 0 ]; then
	    test_useradd_uid $user_to_add $user_uid
		if [ $? -eq 0 ]; then
		  tet_infoline "useradd -u: PASS"
		  remove_user $user_to_add
		else
		  tet_infoline "useradd -u: FAIL"
			FAIL=Y
		fi
	  elif [ $? -eq 1 ]; then
		  FAIL=Y
	  else
		tet_infoline UNRESOLVED
		return 3
	  fi
  tpresult
}
#---------------------------------------------------------------
tp60()
{
  tpstart "useradd -e :Create a new user. - Reference the Commands and Utilities chapter in the Specification"
  

#pick the user to be added by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx30
expiration_date="1970-1-2"

#Tests bare useradd functionality
#execute_useradd_expire(), test_useradd_expire(), and remove_user() are 
#special functions.  See note above.

    execute_useradd_expire $user_to_add $expiration_date
	  if [ $? -eq 0 ]; then
	    test_useradd_expire $user_to_add $expiration_date
		if [ $? -eq 0 ]; then
		  tet_infoline "useradd -e: PASS"
		  remove_user $user_to_add
		else
		  remove_user $user_to_add
		  tet_infoline "useradd -e: FAIL"
			FAIL=Y
		fi
	  else
		  tet_infoline "useradd -e: FAIL"
		  FAIL=Y
	  fi
  tpresult
}
#---------------------------------------------------------------
tp61()
{
  tpstart "useradd -f :Create a new user. - Reference the Commands and Utilities chapter in the Specification"
  

#pick the user to be added by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx31
inactive_date=4	

#Tests bare useradd functionality
#execute_useradd_inactive(), test_useradd_inactive(), and remove_user() are 
#special functions.  See note above.

    execute_useradd_inactive $user_to_add $inactive_date
	  if [ $? -eq 0 ]; then
	    test_useradd_inactive $user_to_add $inactive_date
		if [ $? -eq 0 ]; then
		  tet_infoline "useradd -f: PASS"
		  remove_user $user_to_add
		else
		  remove_user $user_to_add
		  tet_infoline "useradd -f: FAIL"
			FAIL=Y
		fi
	  elif [ $? -eq 1 ]; then
		  tet_infoline "useradd -f: FAIL"
		  FAIL=Y
	  else
		tet_infoline UNRESOLVED
		return 3
	  fi
  tpresult
}
#---------------------------------------------------------------
tp62()
{
  tpstart "useradd -p :Create a new user. - Reference the Commands and Utilities chapter in the Specification"
  
#pick the user to be added by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx32
user_passwd=fooBar

#Tests bare useradd functionality
#execute_useradd_passwd(), test_useradd_passwd(), and remove_user() are 
#special functions.  See note above.

   execute_useradd_passwd $user_to_add $user_passwd
	  if [ $? -eq 0 ]; then
	    test_useradd_passwd $user_to_add $user_passwd
		if [ $? -eq 0 ]; then
		  tet_infoline "useradd -p: PASS"
		  remove_user $user_to_add
		else
		  remove_user $user_to_add
		  tet_infoline "useradd -p: FAIL"
			FAIL=Y
		fi
	  elif [ $? -eq 1 ]; then
		  tet_infoline "useradd -p: FAIL"
		  FAIL=Y
	  else
		tet_infoline UNRESOLVED
		return 3
	  fi
  tpresult
}
##########################################################################
#
# Command:	userdel
# Standard:	LSB
#
##########################################################################

##########################################################################
#
#-Assumptions:
#-	1)Tester has super-user privileges.
#-	2)All commands used by this test function as designed.
#-
#-Strategy statement:
#-	Add user. Remove user. Confirm removal.
#-
#-Expected Results:
#-	All documented features of command will be verified.
#-
#-Notes:
#-	Root password is required
#-
#-Other Commands Used:
#-	See $TET_EXECUTE/SRC/common/lsblib/usergroups_funcs.sh
#-	for special functions.
#
##########################################################################
tp63()
{
  tpstart "userdel :Delete a user account. - Reference the Commands and Utilities chapter in the Specification"

#pick the user to be removed by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx33

#Tests userdel functionality
#remove_user() and user_dne() are special functions.  See note above.
    useradd $user_to_add  > /dev/null 2>&1
	  if [ $? -eq 0 ]; then
	    remove_user $user_to_add
		if [ $? -eq 0 ]; then
			user_dne $user_to_add
				if [ $? -eq 0 ]; then
					tet_infoline "userdel PASS: User $username verified as deleted"
				else
					tet_infoline "userdel FAIL: Deletion could not be verified for user $user_name"
					FAIL=Y
				fi
		else
				tet_infoline "userdel FAIL: Can not delete a user $user_name"
				FAIL=Y
		fi
	  else
			tet_infoline "userdel UNRESOLVED: Can not add a test user $user_name"
			tpresult UNRESOLVED
			return
	  fi
  tpresult
}
##########################################################################
#
# Command:	usermod
# Standard:	LSB
#
##########################################################################

##########################################################################
#
#-Assumptions:
#-	1)Tester has super-user privileges.
#-	2)All commands used by this test function as designed.
#-
#-Strategy statement:
#-	Add user(s) with certain properties.  Confirm.  Remove user(s)
#-
#-Expected Results:
#-	All documented features of command will be verified.
#-
#-Notes:
#-	Root password is required
#-
#-Other Commands Used:
#-	See $TET_EXECUTE/SRC/common/lsblib/usergroups_funcs.sh
#-	for special functions.
#
##########################################################################
tp64()
{
  tpstart "usermod -d :Modify a user account. - Reference the Commands and Utilities chapter in the Specification"

#pick the user to be removed by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx34
other_home="/home/foo"

#Tests usermod -d functionality
#test_useradd_home() and remove_user() are special functions.  See note above.

	 useradd $user_to_add > /dev/null 2>&1
	  if [ $? -eq 0 ]; then
	    usermod -d $other_home $user_to_add > /dev/null 2>&1
		if [ $? -eq 0 ]; then
  		  test_useradd_home $user_to_add $other_home
			if [ $? -eq 0 ]; then
			  tet_infoline "usermod -d PASS"
			  remove_user $user_to_add
			else
			  FAIL=Y
			  tet_infoline "usermod -d FAIL: Could not verify home dir changed for user $user_name"
			  remove_user $user_to_add
			fi
		else
		  FAIL=Y
		  tet_infoline "usermod -d FAIL: Could not change home dir for user $user_name"
		  remove_user $user_to_add
		fi
	  else
		tet_infoline "usermod -d UNRESOLVED: Can not add a test user $user_to_add"
		tpresult UNRESOLVED
		return 3
	  fi
  tpresult
}
#---------------------------------------------------------------
tp65()
{
  tpstart "usermod -c :Modify a user account. - Reference the Commands and Utilities chapter in the Specification"

#pick the user to be removed by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx35
user_comment="LSB1.0"


#Tests usermod -c functionality
#test_useradd_comment() and remove_user() are special functions.  
#See note above.
    useradd $user_to_add  > /dev/null 2>&1
	  if [ $? -eq 0 ]; then
		usermod -c $user_comment $user_to_add > /dev/null 2>&1
		if [ $? -eq 0 ]; then
		  test_useradd_comment $user_to_add $user_comment
			if [ $? -eq 0 ]; then
			  tet_infoline "usermod -c PASS"
			  remove_user $user_to_add
			else
			  FAIL=Y
			  tet_infoline "usermod -c FAIL: Could not verify comment changed for user $user_name"
			  remove_user $user_to_add
			fi
		else
 		  FAIL=Y
		  tet_infoline "usermod -c FAIL: Could not change comment for user $user_name"
		  remove_user $user_to_add
		fi
	  else
		tet_infoline "usermod -c UNRESOLVED: Can not add a test user $user_to_add"
		tpresult UNRESOLVED
		return 
	  fi
  tpresult
}
#---------------------------------------------------------------
tp66()
{
  tpstart "usermod -g :Modify a user account. - Reference the Commands and Utilities chapter in the Specification"

#pick the user to be removed by this script
#unique_name() is a special function.  See note above.

user_to_add=vsx36
group_to_add=vsxg1


#Tests usermod -g functionality
#test_useradd_gid() and remove_user() are special functions.  
#See note above.
    useradd $user_to_add  > /dev/null 2>&1
	  if [ $? -eq 0 ]; then
	    usermod -g $group_to_add  $user_to_add > /dev/null 2>&1
		if [ $? -eq 0 ]; then
		  test_useradd_gid $user_to_add $group_to_add
			if [ $? -eq 0 ]; then
			  tet_infoline "usermod -g PASS"
			  remove_user $user_to_add
				# We also remove the group that may have been created during
				# the useradd
				groupdel $user_to_add > /dev/null 2>&1 || /bin/true
			else
			  FAIL=Y
			  tet_infoline "usermod -g FAIL: Could not verify group changed for user $user_name"
			  remove_user $user_to_add
			fi
		else
	 	  FAIL=Y
		  tet_infoline "usermod -g FAIL: Could not change group for user $user_name"
		  remove_user $user_to_add
		fi
	  else
		tet_infoline "usermod -g UNRESOLVED: Can not add a test user $user_to_add"
		tpresult UNRESOLVED
		return 
	  fi
  tpresult
}
#---------------------------------------------------------------
tp67()
{
  tpstart "usermod -f :Modify a user account. - Reference the Commands and Utilities chapter in the Specification"

#pick the user to be removed by this script
#unique_name() is a special function.  See note above.
user_to_add=vsx37
inactive_date=4	

#Tests usermod -f functionality
#test_useradd_inactive() and remove_user() are special functions.  
#See note above.
    useradd $user_to_add  > /dev/null 2>&1
	  if [ $? -eq 0 ]; then
	    usermod -f $inactive_date $user_to_add > /dev/null 2>&1
		if [ $? -eq 0 ]; then
		  test_useradd_inactive $user_to_add $inactive_date
			if [ $? -eq 0 ]; then
			  tet_infoline "usermod -f PASS"
			  remove_user $user_to_add
			else
			  FAIL=Y
			  tet_infoline "usermod -f FAIL: Could not verify inactive_date changed for user $user_name"
			  remove_user $user_to_add
			fi
		else
		  FAIL=Y
		  tet_infoline "usermod -f FAIL: Could not change inactive_date for user $user_name"
		  remove_user $user_to_add
		fi
	  else
		tet_infoline "usermod -f UNRESOLVED: Un-able to add a test user $user_to_add"
		tpresult UNRESOLVED
		return 
	  fi
  tpresult
}

#---------------------------------------------------------------
tp68()
{
	tpstart "userdel -r: remove user plus his/her home dir. - Reference the Commands and Utilities chapter in the Specification"
#make sure the home dir does not exist.
	prefix=/home/tmp
	home_dir=/home/tmp
	sub=0
	while [ -d $home_dir ]; do
		home_dir=$prefix$sub
		sub=`expr $sub + 1`
	done

#Create a home dir
	mkdir $home_dir > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		tet_infoline "UNRESOLVED: un-able to create dir: $home_dir"	
		tpresult UNRESOLVED
		return
	fi

#Create some files in home_dir
	HERE_IS=$(pwd)
	cd $home_dir > /dev/null 2>&1
	touch f1 f2 f3 > /dev/null 2>&1
	cd $HERE_IS > /dev/null 2>&1

#Create a new test user
	USER_TO_ADD=vsx38

	useradd -d $home_dir $USER_TO_ADD > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		tet_infoline "UNRESOLVED: un-able to add a test user: useradd -d $home_dir $USER_TO_ADD"	
		rm -fr $home_dir > /dev/null 2>&1
		tpresult UNRESOLVED
		return
	fi

	chown $USER_TO_ADD $home_dir  > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		tet_infoline "UNRESOLVED: un-able to change ownership of $home_dir to $USER_TO_ADD"	
		rm -fr $home_dir > /dev/null 2>&1
		tpresult UNRESOLVED
		return
	fi

#Test userdel -r :
	userdel -r $USER_TO_ADD > /dev/null 2>&1
	if [ $? -eq 0 ]; then
		if [ -d $home_dir ]; then
			FAIL=Y
			tet_infoline "userdel -r :FAIL.  Home dir did not remove."
			rm -fr $home_dir > /dev/null 2>&1
		else
			tet_infoline "PASS"
		fi
	else
		FAIL=Y
		tet_infoline "userdel -r : failed"
		rm -fr $home_dir > /dev/null 2>&1
	fi
	tpresult
}

#---------------------------------------------------------------
tp69()
{
	tpstart "usermod -l: change login name. - Reference the Commands and Utilities chapter in the Specification"
#Create a new test user
	USER_TO_ADD=vsx39

	useradd $USER_TO_ADD > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		tet_infoline "UNRESOLVED: un-able to add a test user: $USER_TO_ADD"	
		tpresult UNRESOLVED
		return
	fi

	OTHER_USER=vsx43

#Test usermod -l
	usermod -l $OTHER_USER $USER_TO_ADD > /dev/null 2>&1
	if [ $? -eq 0 ]; then
		./uberpass -U -n $OTHER_USER > /dev/null 2>&1
		if [ $? -eq 0 ]; then
			tet_infoline "PASS"
			# Rename the user to its original name. This means that
			# on systems where a group is automatically created with a user
			# that the group also gets removed.
			usermod -l $USER_TO_ADD $OTHER_USER > /dev/null 2>&1
			userdel  $USER_TO_ADD > /dev/null 2>&1
			if [ $? -ne 0 ]; then
				tet_infoline "WARNING: un-able to remove the added user: $OTHER_USER"
			fi
		else
			FAIL=Y
			tet_infoline "usermod -l: FAILED.  Login name did not change."
			userdel  $USER_TO_ADD > /dev/null 2>&1
			if [ $? -ne 0 ]; then
				tet_infoline "WARNING: un-able to remove the added user: $USER_TO_ADD"
			fi
		fi
	else
		FAIL=Y
		tet_infoline "usermod -l : FAILED."
	fi
	tpresult
}

tp70()
{
	tpstart "usermod -G : change supplementary groups. - Reference the Commands and Utilities chapter in the Specification"
#Create a new test user
	USER_TO_ADD=vsx40

	useradd $USER_TO_ADD > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		tet_infoline "UNRESOLVED: un-able to add a test user: $USER_TO_ADD"	
		tpresult UNRESOLVED
		return
	fi

#begin testing usermod -G
	usermod -G supp1,supp2,supp3 $USER_TO_ADD > /dev/null 2>&1
	if [ $? -eq 0 ]; then
#check to see if the supplemental groups get added
		count=1
		prefix=supp
		failed=0
		while [ $count -le 3 ]; do
			groups $USER_TO_ADD | grep "$prefix$count" > /dev/null 2>&1
			if [ $? -ne 0 ]; then
				failed=1
				count=4
			fi
			count=`expr $count + 1`
		done
		if [ $failed -eq 0 ]; then
			usermod -G supp4,supp5,supp6 $USER_TO_ADD > /dev/null 2>&1
			count=1
			prefix=supp
			while [ $count -le 3 ]; do
				groups $USER_TO_ADD | grep "$prefix$count" > /dev/null 2>&1
				if [ $? -eq 0 ]; then
					failed=1
					count=4
				fi
				count=`expr $count + 1`
			done
			if [ $failed -eq 0 ]; then
					tet_infoline "PASS"
			else
				FAIL=Y
				tet_infoline "usermod -G: FAILED.  Un-expected suppl groups show up."
			fi
		else
			FAIL=Y
			tet_infoline "usermod -G: FAILED.  Suppl groups were not added."
		fi
	else
		FAIL=Y
		tet_infoline "usermod -G : FAILED."
	fi
	userdel $USER_TO_ADD > /dev/null 2>&1
	tpresult
}

tp71()
{
	tpstart "useradd -G : add new user with specified supplementary groups. - Reference the Commands and Utilities chapter in the Specification"

#begin testing useradd -G
	USER_TO_ADD=vsx41

	useradd -G supp1,supp2,supp3 $USER_TO_ADD > /dev/null 2>&1
	if [ $? -eq 0 ]; then
#check to see if the supplementary groups get added
		count=1
		prefix=supp
		failed=0
		while [ $count -le 3 ]; do
			groups $USER_TO_ADD | grep "$prefix$count" > /dev/null 2>&1
			if [ $? -ne 0 ]; then
				failed=1
				count=4
			fi
			count=`expr $count + 1`
		done
		if [ $failed -eq 0 ]; then
			tet_infoline "PASS"
		else
			FAIL=Y
			tet_infoline "useradd -G: FAILED.  Suppl groups were not added."
		fi
	else
		FAIL=Y
		tet_infoline "useradd -G : FAILED."
	fi
	userdel $USER_TO_ADD > /dev/null 2>&1
	tpresult
}

tp72()
{
	tpstart "useradd -m -k : add a user with specified home dir. - Reference the Commands and Utilities chapter in the Specification"
#Creat a skeleton dir
	prefix=/home/skeleton_dir
	home_dir=$prefix
	sub=0
	while [ -d $home_dir ]; do
		home_dir=$prefix$sub
		sub=`expr $sub + 1`
	done

	mkdir $home_dir > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		tet_infoline "UNRESOLVED: un-able to create dir: $home_dir"	
		tpresult UNRESOLVED
		return
	fi

#Create some files in home_dir
	HERE_IS=$(pwd)
	cd $home_dir > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		tet_infoline "UNRESOLVED: un-able to cd to dir: $home_dir"	
		tpresult UNRESOLVED
		return
	fi

	touch f1 f2 f3 > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		tet_infoline "UNRESOLVED: un-able to create some test files in dir: $home_dir"	
		tpresult UNRESOLVED
		return
	fi

	cd $HERE_IS > /dev/null 2>&1

#begin to test useradd -m -k
	USER_TO_ADD=vsx50
	useradd -m -k $home_dir $USER_TO_ADD > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		FAIL=Y
		tet_infoline "useradd -m -k FAILED"
	else
#make sure the home dir is created correctly
		user_home_dir=$(./uberpass -U -d $USER_TO_ADD)
		diff -r -b $home_dir $user_home_dir > /dev/null 2>&1
		Exit_Stat=$?
		if [ $Exit_Stat -gt 1 ]; then
			tet_infoline "UNRESOLVED: diff -b -r might not be avialable to use."
			userdel -r $USER_TO_ADD > /dev/null 2>&1
			if [ $? -ne 0 ]; then
				tet_infoline "WARNING: un-able to remove an added test user and/or his/her home_dir."
			fi
			rm -fr $home_dir $user_home_dir > /dev/null 2>&1
			tpresult UNRESOLVED
			return
		elif [ $Exit_Stat -eq 1 ]; then
			FAIL=Y
			tet_infoline "useradd -m -k FAILED: home dir is not created correctly."
		elif [ $Exit_Stat -eq 0 ]; then
			tet_infoline "useradd -m -k PASSED."
		else
			tet_infoline "UNRESOLVED: 	Unknow exit status returned by diff -r -b $?"
			userdel -r $USER_TO_ADD > /dev/null 2>&1
			if [ $? -ne 0 ]; then
				tet_infoline "WARNING: un-able to remove an added test user and/or his/her home_dir."
			fi
			rm -fr $home_dir $user_home_dir > /dev/null 2>&1
			tpresult UNRESOLVED
			return
		fi
	fi

#Remove all temp files/dirs/user
	rm -fr $home_dir $user_home_dir > /dev/null 2>&1
	userdel -r $USER_TO_ADD > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		tet_infoline "WARNING: un-able to remove an added test user and/or his/her home_dir."
	fi
	tpresult
}

tp73()
{
	tpstart "useradd -m: add a user with home dir same as /etc/skel - Reference the Commands and Utilities chapter in the Specification"
#Check /etc/skel 
	skel_created=1
	if [ ! -d /etc/skel ]; then
		mkdir /etc/skel > /dev/null 2>&1
		if [ $? -ne 0 ]; then
			tet_infoline "/ect/skel does not exist and un-able to create"
			tpresult UNRESOLVED
			return
		fi
		skel_created=0
	fi

#Create some files in /etc/skel 
	HERE_IS=$(pwd)
	file=1
	cd /etc/skel > /dev/null 2>&1
	if [ $? -eq 0 ]; then
		touch f1 f2 f3 > /dev/null 2>&1
		if [ $? -eq 0 ]; then
			file=0
		fi
	fi
	cd $HERE_IS > /dev/null 2>&1

#begin to test useradd -m
	USER_TO_ADD=vsx51
	useradd -m  $USER_TO_ADD > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		FAIL=Y
		tet_infoline "useradd -m FAILED"
	else
		user_home_dir=$(./uberpass -U -d $USER_TO_ADD)

		diff -r -b $user_home_dir /etc/skel > /dev/null 2>&1
		Exit_Stat=$?
		if [ $Exit_Stat -gt 1 ]; then
			tet_infoline "UNRESOLVED: diff -b -r might not be avialable to use."
			if [ $skel_created -eq 0 ]; then
				rm -fr /etc/skel > /dev/null 2>&1
			elif [ $file -eq 0 ]; then
				rm -f /etc/skel/f1 /etc/skel/f2 /etc/skel/f3 > /dev/null 2>&1
			fi

			userdel -r $USER_TO_ADD > /dev/null 2>&1
			if [ $? -ne 0 ]; then
				tet_infoline "WARNING: un-able to remove an added test user and/or his/her home_dir."
			fi
			tpresult UNRESOLVED
			return
		elif [ $Exit_Stat -eq 1 ]; then
			FAIL=Y
			tet_infoline "useradd -m FAILED: home dir and /etc/skell are not the same"
		elif [ $Exit_Stat -eq 0 ]; then
			tet_infoline "useradd -m PASSED."
		else
			tet_infoline "UNRESOLVED: 	Unknow exit status returned by diff -r -b $?"
			if [ $skel_created -eq 0 ]; then
				rm -fr /etc/skel > /dev/null 2>&1
			elif [ $file -eq 0 ]; then
				rm -f /etc/skel/f1 /etc/skel/f2 /etc/skel/f3 > /dev/null 2>&1
			fi

			userdel -r $USER_TO_ADD > /dev/null 2>&1
			if [ $? -ne 0 ]; then
				tet_infoline "WARNING: un-able to remove an added test user and/or his/her home_dir."
			fi
			tpresult UNRESOLVED
			return
		fi
	fi

	if [ $skel_created -eq 0 ]; then
		rm -fr /etc/skel > /dev/null 2>&1
	elif [ $file -eq 0 ]; then
		rm -f /etc/skel/f1 /etc/skel/f2 /etc/skel/f3 > /dev/null 2>&1
	fi

	userdel -r $USER_TO_ADD > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		tet_infoline "WARNING: un-able to remove an added test user and/or his/her home_dir."
	fi
	tpresult
}

startup() # startup function
{
     rm -f out.stdout out.stderr out.experr >/dev/null 2>&1
}


cleanup() # clean-up function
{
     rm -f out.stdout out.stderr out.experr >/dev/null 2>&1
}

# source common shell functions

. $TET_EXECUTE/LIB/shfuncs.sh
. $TET_EXECUTE/LIB/usersgroups_funcs.sh



# execute shell test case manager - must be last line
. $TET_ROOT/lib/xpg3sh/tcm.sh
