|
1 |
#!/usr/share/ucs-test/runner bash |
1 |
#!/usr/share/ucs-test/runner bash |
2 |
## desc: Check wether many parallel smbclient authentifications are possible |
2 |
## desc: Check whether several parallel smbclient authentifications are possible |
3 |
## exposure: safe |
3 |
## exposure: safe |
4 |
## packages: |
4 |
## packages: |
5 |
## - screen |
5 |
## - screen |
|
23 |
#Parameters for configuration: |
23 |
#Parameters for configuration: |
24 |
# smbauth_totalRounds: amount of rounds (default=3) |
24 |
# smbauth_totalRounds: amount of rounds (default=3) |
25 |
# |
25 |
# |
26 |
# smbauth_amountPerRound: amount of authentifications per round (default=8) |
26 |
# smbauth_amountPerRound: amount of authentifications per round (default=10) |
27 |
# |
27 |
# |
28 |
# smbauth_roundTime: defines the time in which all authentifications in one |
28 |
# smbauth_roundTime: defines the time in which all authentifications in one |
29 |
# round are triggered (default=5) |
29 |
# round are triggered (default=1) |
30 |
# |
30 |
# |
31 |
# $smbauth_delay: delay between each round (default=10) |
31 |
# $smbauth_delay: delay between each round (default=1) |
32 |
|
32 |
|
33 |
trap cleanup INT TERM EXIT |
33 |
trap cleanup INT TERM EXIT |
34 |
|
34 |
|
|
47 |
then |
47 |
then |
48 |
amountPerRound=$smbauth_amountPerRound |
48 |
amountPerRound=$smbauth_amountPerRound |
49 |
else |
49 |
else |
50 |
amountPerRound=8 |
50 |
amountPerRound=10 |
51 |
fi |
51 |
fi |
52 |
|
52 |
|
53 |
#the total number of authentifications |
53 |
#the total number of authentifications |
|
58 |
then |
58 |
then |
59 |
roundTime=$smbauth_roundTime |
59 |
roundTime=$smbauth_roundTime |
60 |
else |
60 |
else |
61 |
roundTime=5 |
61 |
roundTime=1 |
62 |
fi |
62 |
fi |
63 |
|
63 |
|
64 |
#delay between each round |
64 |
#delay between each round |
|
66 |
then |
66 |
then |
67 |
delay=$smbauth_delay |
67 |
delay=$smbauth_delay |
68 |
else |
68 |
else |
69 |
delay=10 |
69 |
delay=1 |
70 |
fi |
70 |
fi |
71 |
|
71 |
|
72 |
SHARE_HOST="$ldap_master" |
|
|
73 |
SHARE_POSITION="cn=$ldap_master,cn=shares,$ldap_base" |
74 |
|
75 |
#create user |
72 |
#create user |
76 |
username=`user_randomname` |
73 |
username=`user_randomname` |
77 |
password=univention |
74 |
password=univention |
|
80 |
share_create $share_name /$share_name |
77 |
share_create $share_name /$share_name |
81 |
share_dn=`univention-directory-manager shares/share list --filter sambaName="$share_name" | sed -ne 's/^DN: //p'` |
78 |
share_dn=`univention-directory-manager shares/share list --filter sambaName="$share_name" | sed -ne 's/^DN: //p'` |
82 |
udm shares/share modify --dn=$share_dn --set sambaPublic=1 |
79 |
udm shares/share modify --dn=$share_dn --set sambaPublic=1 |
83 |
sleep 10 |
80 |
sleep 20 |
84 |
|
81 |
|
85 |
|
82 |
|
86 |
function create_screenconfig |
83 |
function create_screenconfig |
|
105 |
let i=0 |
102 |
let i=0 |
106 |
while [ $i -lt $amountPerRound ] |
103 |
while [ $i -lt $amountPerRound ] |
107 |
do |
104 |
do |
108 |
screen -S smbclients_$screenIndex -p $authIndex -X stuff "smbclient -U $username%$password //`dig +short ${ldap_master}`/$share_name"`echo -ne '\015'` & |
105 |
screen -S smbclients_$screenIndex -p $authIndex -X stuff "smbclient -U "$username%$password" //$ldap_master/$share_name"$'\n' & |
109 |
echo Nr. $i |
106 |
echo Nr. $i |
110 |
|
107 |
|
111 |
sleep ${delayArray[$i]} |
108 |
if [ $roundIndex != $totalRounds ]; then |
|
|
109 |
sleep ${delayArray[$i]} |
110 |
fi |
112 |
|
111 |
|
113 |
let i=$i+1 |
112 |
let i=$i+1 |
114 |
let authIndex=$authIndex+1 |
113 |
let authIndex=$authIndex+1 |
|
137 |
sum=0 |
136 |
sum=0 |
138 |
sum2=0 |
137 |
sum2=0 |
139 |
|
138 |
|
140 |
#create a random number für every authentification at startup |
139 |
#create a random number für every authentification at startup |
141 |
for ((j=0;j<amountPerRound;j++)) |
140 |
for ((j=0;j<amountPerRound;j++)) |
142 |
do |
141 |
do |
143 |
delayArray[$j]=$[($RANDOM%9999+1)] |
142 |
delayArray[$j]=$(($RANDOM%9999+1)) |
144 |
delayArray[$j]=`echo "scale=5;${delayArray[j]}/10000" | bc` |
143 |
delayArray[$j]=`echo "scale=5;${delayArray[j]}/10000" | bc` |
145 |
# echo "nr $j: ${delayArray[$j]}" |
|
|
146 |
sum=`echo "scale=5;$sum+${delayArray[$j]}" | bc` |
144 |
sum=`echo "scale=5;$sum+${delayArray[$j]}" | bc` |
147 |
done |
145 |
done |
148 |
# echo $sum |
|
|
149 |
|
146 |
|
150 |
#adapt numbers so that the sum of them equals $startTime, hence authentifications start in this time interval |
147 |
#adjust numbers so that the sum of them equals $startTime, |
|
|
148 |
#hence authentifications start in this time interval |
151 |
for ((j=0;j<amountPerRound;j++)) |
149 |
for ((j=0;j<amountPerRound;j++)) |
152 |
do |
150 |
do |
153 |
delayArray[$j]=`echo "scale=5;${delayArray[$j]}/$sum*$roundTime" | bc` |
151 |
delayArray[$j]=`echo "scale=5;${delayArray[$j]}/$sum*$roundTime" | bc` |
154 |
#echo "nr $j: ${delayArray[$j]}" |
|
|
155 |
|
152 |
|
156 |
sum2=`echo "scale=5;$sum2+${delayArray[$j]}" | bc` |
153 |
sum2=`echo "scale=5;$sum2+${delayArray[$j]}" | bc` |
157 |
done |
154 |
done |
158 |
# echo $sum2 |
|
|
159 |
|
160 |
} |
155 |
} |
161 |
|
156 |
|
162 |
function cleanup |
157 |
function cleanup |
|
198 |
do |
193 |
do |
199 |
create_screenconfig $round_nr |
194 |
create_screenconfig $round_nr |
200 |
done |
195 |
done |
201 |
sleep 14 |
|
|
202 |
|
196 |
|
203 |
screenIndex=0 |
197 |
screenIndex=0 |
204 |
roundIndex=0 |
198 |
roundIndex=0 |
|
216 |
|
210 |
|
217 |
if [ "$result" != "$amount" ] |
211 |
if [ "$result" != "$amount" ] |
218 |
then |
212 |
then |
219 |
fail_test 1 "Only $result of $amount authentifications have been successful" |
213 |
fail_test 1 "Only $result of $amount authentifications have been successful" |
220 |
fi |
214 |
fi |
221 |
|
215 |
|
222 |
|
216 |
|