Debian Codegraph @

mysql-test/suite/auth_sec/include/password_require_current_non_priv_user.inc

raw
1 ###############################################################################
2 # #
3 # This script checks the ALTER USER|SET PASSWORD ... REPLACE ... SQL #
4 # for non privileged user. #
5 # #
6 # This include file expects, two users 'priv_usr' and 'non_priv_usr' #
7 # already created before it is called. It does not drop the users. #
8 # #
9 # It expect the following two variables to be set #
10 # 1. $NON_PRIV_USER : user which will not be granted the update privileges #
11 # #
12 # 2. $CURRENT_PASSWORD_REQUIRE : What clause was used to create #
13 # the $NON_PRIV_USER #
14 # CURRENT ~ PASSWORD REQUIRE CURRENT #
15 # OPTIONAL ~ PASSWORD REQUIRE CURRENT OPTIONAL #
16 # DEFAULT ~ PASSWORD REQUIRE CURRENT DEFAULT #
17 # #
18 # It also needs following two password variables: #
19 # 3. $PWRD_1: A password which is used to create $NON_PRIV_USER user. #
20 # #
21 ###############################################################################
22
23 # If required parameters are not set then throw error and exit.
24 --let PARAM_PERL_QUIT=0
25 if ($NON_PRIV_USER == '')
26 {
27 --let VARIABLE_NAME = NON_PRIV_USER
28 --let PARAM_PERL_QUIT=1
29 }
30
31 if ($CURRENT_PASSWORD_REQUIRE == '')
32 {
33 --let VARIABLE_NAME = CURRENT_PASSWORD_REQUIRE
34 --let PARAM_PERL_QUIT=1
35 }
36
37 --perl
38 $variable_name = "$ENV{VARIABLE_NAME}";
39 die "Error: password_require_current.inc: input variable $variable_name is missing!"
40 if ($ENV{PARAM_PERL_QUIT} == 1);
41 EOF
42
43 --let $TEMP_PWRD = pwd2
44 --let $WRONG_PWRD = P&(*^_)D
45
46 --echo
47 --echo #------------------------------------------------------------------------
48 --echo # Non priv user changing his own password
49 --echo #------------------------------------------------------------------------
50 connect(con1,localhost,$NON_PRIV_USER,$PWRD_1,);
51
52 --echo
53 --echo # REPLACE clause is not specified
54 if($CURRENT_PASSWORD_REQUIRE == 'CURRENT')
55 {
56 --error ER_MISSING_CURRENT_PASSWORD
57 eval SET PASSWORD='$TEMP_PWRD';
58 --error ER_MISSING_CURRENT_PASSWORD
59 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD';
60 --error ER_MISSING_CURRENT_PASSWORD
61 eval ALTER USER user() IDENTIFIED BY '$PWRD_1';
62 --error ER_MISSING_CURRENT_PASSWORD
63 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1';
64 }
65 if($CURRENT_PASSWORD_REQUIRE == 'OPTIONAL')
66 {
67 eval SET PASSWORD='$TEMP_PWRD';
68 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD';
69 eval ALTER USER user() IDENTIFIED BY '$PWRD_1';
70 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1';
71 }
72 if($CURRENT_PASSWORD_REQUIRE == 'DEFAULT')
73 {
74 eval SET PASSWORD='$TEMP_PWRD';
75 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD';
76 eval ALTER USER user() IDENTIFIED BY '$PWRD_1';
77 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1';
78 }
79
80 --echo
81 --echo # Incorrect password specified in the REPLACE clause
82 if($CURRENT_PASSWORD_REQUIRE == 'CURRENT')
83 {
84 --error ER_INCORRECT_CURRENT_PASSWORD
85 eval SET PASSWORD='$TEMP_PWRD' REPLACE '$WRONG_PWRD' ;
86 --error ER_INCORRECT_CURRENT_PASSWORD
87 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD' REPLACE '$WRONG_PWRD';
88 --error ER_INCORRECT_CURRENT_PASSWORD
89 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$WRONG_PWRD';
90 --error ER_INCORRECT_CURRENT_PASSWORD
91 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$TEMP_PWRD' REPLACE '$WRONG_PWRD';
92 }
93 if($CURRENT_PASSWORD_REQUIRE == 'OPTIONAL')
94 {
95 --error ER_INCORRECT_CURRENT_PASSWORD
96 eval SET PASSWORD='$TEMP_PWRD' REPLACE '$WRONG_PWRD' ;
97 --error ER_INCORRECT_CURRENT_PASSWORD
98 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD' REPLACE '$WRONG_PWRD';
99 --error ER_INCORRECT_CURRENT_PASSWORD
100 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$WRONG_PWRD';
101 --error ER_INCORRECT_CURRENT_PASSWORD
102 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$WRONG_PWRD';
103 }
104 if($CURRENT_PASSWORD_REQUIRE == 'DEFAULT')
105 {
106 --error ER_INCORRECT_CURRENT_PASSWORD
107 eval SET PASSWORD='$TEMP_PWRD' REPLACE '' ;
108 --error ER_INCORRECT_CURRENT_PASSWORD
109 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD' REPLACE '$WRONG_PWRD';
110 --error ER_INCORRECT_CURRENT_PASSWORD
111 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$WRONG_PWRD';
112 --error ER_INCORRECT_CURRENT_PASSWORD
113 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$WRONG_PWRD';
114 }
115
116 --echo
117 --echo # Correct password specified in the REPLACE clause
118 if($CURRENT_PASSWORD_REQUIRE == 'CURRENT')
119 {
120 eval SET PASSWORD='$TEMP_PWRD' REPLACE '$PWRD_1';
121 eval SET PASSWORD for $NON_PRIV_USER='$PWRD_1' REPLACE '$TEMP_PWRD';
122 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$PWRD_1';
123 eval ALTER USER IF EXISTS $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$TEMP_PWRD';
124 }
125 if($CURRENT_PASSWORD_REQUIRE == 'OPTIONAL')
126 {
127 eval SET PASSWORD='$TEMP_PWRD' REPLACE '$PWRD_1';
128 eval SET PASSWORD for $NON_PRIV_USER='$PWRD_1' REPLACE '$TEMP_PWRD';
129 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$PWRD_1';
130 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$TEMP_PWRD';
131 }
132 if($CURRENT_PASSWORD_REQUIRE == 'DEFAULT')
133 {
134 eval SET PASSWORD='$TEMP_PWRD' REPLACE '$PWRD_1';
135 eval SET PASSWORD for $NON_PRIV_USER='$PWRD_1' REPLACE '$TEMP_PWRD';
136 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$PWRD_1';
137 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$TEMP_PWRD';
138 }
139 connection default;
140 disconnect con1;
141
142 --echo
143 --echo # Now test with Global server variable ON
144 SET @@global.password_require_current=ON;
145
146 --echo
147 --echo #------------------------------------------------------------------------
148 --echo # Non priv user changing his own password
149 --echo #------------------------------------------------------------------------
150 connect(con1,localhost,$NON_PRIV_USER,$PWRD_1,);
151
152 --echo
153 --echo # REPLACE clause is not specified
154 if($CURRENT_PASSWORD_REQUIRE == 'CURRENT')
155 {
156 --error ER_MISSING_CURRENT_PASSWORD
157 eval SET PASSWORD='$TEMP_PWRD';
158 --error ER_MISSING_CURRENT_PASSWORD
159 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD';
160 --error ER_MISSING_CURRENT_PASSWORD
161 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD';
162 --error ER_MISSING_CURRENT_PASSWORD
163 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$TEMP_PWRD';
164 }
165 if($CURRENT_PASSWORD_REQUIRE == 'OPTIONAL')
166 {
167 eval SET PASSWORD='$TEMP_PWRD';
168 eval SET PASSWORD for $NON_PRIV_USER='$PWRD_1';
169 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD';
170 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1';
171 }
172 if($CURRENT_PASSWORD_REQUIRE == 'DEFAULT')
173 {
174 --error ER_MISSING_CURRENT_PASSWORD
175 eval SET PASSWORD='$TEMP_PWRD';
176 --error ER_MISSING_CURRENT_PASSWORD
177 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD';
178 --error ER_MISSING_CURRENT_PASSWORD
179 eval ALTER USER user() IDENTIFIED BY '$PWRD_1';
180 --error ER_MISSING_CURRENT_PASSWORD
181 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1';
182 }
183
184 --echo
185 --echo # Incorrect password specified in the REPLACE clause
186 --error ER_INCORRECT_CURRENT_PASSWORD
187 if($CURRENT_PASSWORD_REQUIRE == 'CURRENT')
188 {
189 --error ER_INCORRECT_CURRENT_PASSWORD
190 eval SET PASSWORD='$TEMP_PWRD' REPLACE '$WRONG_PWRD' ;
191 --error ER_INCORRECT_CURRENT_PASSWORD
192 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD' REPLACE '$WRONG_PWRD';
193 --error ER_INCORRECT_CURRENT_PASSWORD
194 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$WRONG_PWRD';
195 --error ER_INCORRECT_CURRENT_PASSWORD
196 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$WRONG_PWRD';
197 }
198 if($CURRENT_PASSWORD_REQUIRE == 'OPTIONAL')
199 {
200 --error ER_INCORRECT_CURRENT_PASSWORD
201 eval SET PASSWORD='$TEMP_PWRD' REPLACE '$WRONG_PWRD' ;
202 --error ER_INCORRECT_CURRENT_PASSWORD
203 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD' REPLACE '$WRONG_PWRD';
204 --error ER_INCORRECT_CURRENT_PASSWORD
205 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$WRONG_PWRD';
206 --error ER_INCORRECT_CURRENT_PASSWORD
207 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$WRONG_PWRD';
208 }
209 if($CURRENT_PASSWORD_REQUIRE == 'DEFAULT')
210 {
211 --error ER_INCORRECT_CURRENT_PASSWORD
212 eval SET PASSWORD='$TEMP_PWRD' REPLACE '' ;
213 --error ER_INCORRECT_CURRENT_PASSWORD
214 eval SET PASSWORD for $NON_PRIV_USER='$TEMP_PWRD' REPLACE '$WRONG_PWRD';
215 --error ER_INCORRECT_CURRENT_PASSWORD
216 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$WRONG_PWRD';
217 --error ER_INCORRECT_CURRENT_PASSWORD
218 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$WRONG_PWRD';
219 }
220
221 --echo
222 --echo # Correct password specified in the REPLACE clause
223 if($CURRENT_PASSWORD_REQUIRE == 'CURRENT')
224 {
225 eval SET PASSWORD='$TEMP_PWRD' REPLACE '$PWRD_1';
226 eval SET PASSWORD for $NON_PRIV_USER='$PWRD_1' REPLACE '$TEMP_PWRD';
227 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$PWRD_1';
228 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$TEMP_PWRD';
229 }
230 if($CURRENT_PASSWORD_REQUIRE == 'OPTIONAL')
231 {
232 eval SET PASSWORD='$TEMP_PWRD' REPLACE '$PWRD_1';
233 eval SET PASSWORD for $NON_PRIV_USER='$PWRD_1' REPLACE '$TEMP_PWRD';
234 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$PWRD_1';
235 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$TEMP_PWRD';
236 }
237 if($CURRENT_PASSWORD_REQUIRE == 'DEFAULT')
238 {
239 eval SET PASSWORD='$TEMP_PWRD' REPLACE '$PWRD_1';
240 eval SET PASSWORD for $NON_PRIV_USER='$PWRD_1' REPLACE '$TEMP_PWRD';
241 eval ALTER USER user() IDENTIFIED BY '$TEMP_PWRD' REPLACE '$PWRD_1';
242 eval ALTER USER $NON_PRIV_USER IDENTIFIED BY '$PWRD_1' REPLACE '$TEMP_PWRD';
243 }
244
245 connection default;
246 disconnect con1;
247
248 --echo
249 --echo # Reset the Global server variable to OFF
250 SET @@global.password_require_current=OFF;
251 --echo