Home | History | Annotate | Download | only in sssd
      1 #! /bin/sh
      2 
      3 #  Copyright (c) 2012 FUJITSU LIMITED
      4 #
      5 #  This program is free software;  you can redistribute it and/or modify
      6 #  it under the terms of the GNU General Public License as published by
      7 #  the Free Software Foundation; either version 2 of the License, or
      8 #  (at your option) any later version.
      9 #
     10 #  This program is distributed in the hope that it will be useful,
     11 #  but WITHOUT ANY WARRANTY;  without even the implied warranty of
     12 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
     13 #  the GNU General Public License for more details.
     14 #
     15 #  You should have received a copy of the GNU General Public License
     16 #  along with this program;  if not, write to the Free Software
     17 #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     18 #
     19 # Description:  Test override_homedir in the configuration file.
     20 # Author:       Peng Haitao <penght (at] cn.fujitsu.com>
     21 # History:      2012/02/17 - Created.
     22 #
     23 
     24 . ./sssd-lib.sh || exit 1
     25 
     26 sssd_case1()
     27 {
     28 	export TST_COUNT=1
     29 
     30 	tst_resm TINFO "test override_homedir with absolute path in [nss]"
     31 
     32 	# Create the configuration file specific to this test case.
     33 	make_config_file
     34 	sed -i -e "/\[nss\]/ a\override_homedir = $LTPTMP" $CONFIG_FILE
     35 	sleep 1
     36 
     37 	getent passwd $username@LOCAL | grep "$LTPTMP" >/dev/null 2>&1
     38 	if [ $? -eq 0 ]; then
     39 		tst_resm TFAIL "sssd: user home dir should be not $LTPTMP."
     40 		: $(( TFAILCNT += 1 ))
     41 		return $TFAILCNT
     42 	fi
     43 
     44 	restart_sssd_daemon
     45 
     46 	getent passwd $username@LOCAL | grep "$LTPTMP" >/dev/null 2>&1
     47 	if [ $? -eq 0 ]; then
     48 		tst_resm TPASS "sssd: user home dir is $LTPTMP."
     49 	else
     50 		tst_resm TFAIL "sssd: user home dir should be $LTPTMP."
     51 		: $(( TFAILCNT += 1 ))
     52 		return $TFAILCNT
     53 	fi
     54 
     55 	return 0
     56 }
     57 
     58 sssd_case2()
     59 {
     60 	export TST_COUNT=2
     61 
     62 	tst_resm TINFO "test override_homedir with template in [domain/LOCAL]"
     63 
     64 	# Create the configuration file specific to this test case.
     65 	make_config_file
     66 	sed -i -e "/\[domain\/LOCAL\]/ a\override_homedir = $LTPTMP/%u_%U@%d" \
     67 		   $CONFIG_FILE
     68 	sleep 1
     69 
     70 	uid=`id -u $username`
     71 	home_dir="$LTPTMP/${username}_$uid@LOCAL"
     72 	getent passwd $username@LOCAL | grep "$home_dir" >/dev/null 2>&1
     73 	if [ $? -eq 0 ]; then
     74 		tst_resm TFAIL "sssd: user home dir should be not $home_dir."
     75 		: $(( TFAILCNT += 1 ))
     76 		return $TFAILCNT
     77 	fi
     78 
     79 	restart_sssd_daemon
     80 
     81 	getent passwd $username@LOCAL | grep "$home_dir" >/dev/null 2>&1
     82 	if [ $? -eq 0 ]; then
     83 		tst_resm TPASS "sssd: user home dir is $home_dir."
     84 	else
     85 		tst_resm TFAIL "sssd: user home dir should be $home_dir."
     86 		: $(( TFAILCNT += 1 ))
     87 		return $TFAILCNT
     88 	fi
     89 
     90 	return 0
     91 }
     92 
     93 sssd_case3()
     94 {
     95 	export TST_COUNT=3
     96 
     97 	tst_resm TINFO "test override_homedir with absolute path in [nss]"
     98 
     99 	# Create the configuration file specific to this test case.
    100 	make_config_file
    101 	sed -i -e "/\[nss\]/ a\override_homedir = $LTPTMP/%f" $CONFIG_FILE
    102 	sleep 1
    103 
    104 	home_dir="$LTPTMP/$username@LOCAL"
    105 	getent passwd $username@LOCAL | grep "$home_dir" >/dev/null 2>&1
    106 	if [ $? -eq 0 ]; then
    107 		tst_resm TFAIL "sssd: user home dir should be not $home_dir."
    108 		: $(( TFAILCNT += 1 ))
    109 		return $TFAILCNT
    110 	fi
    111 
    112 	restart_sssd_daemon
    113 
    114 	getent passwd $username@LOCAL | grep "$home_dir" >/dev/null 2>&1
    115 	if [ $? -eq 0 ]; then
    116 		tst_resm TPASS "sssd: user home dir is $home_dir."
    117 	else
    118 		tst_resm TFAIL "sssd: user home dir should be $home_dir."
    119 		: $(( TFAILCNT += 1 ))
    120 		return $TFAILCNT
    121 	fi
    122 
    123 	return 0
    124 }
    125 
    126 export TST_TOTAL=3
    127 export TCID=sssd01
    128 
    129 TFAILCNT=0
    130 username="sssd_test_user"
    131 
    132 make_config_file
    133 # make sure config file is OK
    134 sleep 1
    135 restart_sssd_daemon
    136 sss_useradd $username
    137 
    138 for i in $(seq 1 $TST_TOTAL); do
    139 	sssd_case$i
    140 done
    141 
    142 sss_userdel $username
    143 cleanup ${TFAILCNT:=0}
    144