Revision 4d775dd0
Added by Ermal LUÇI over 14 years ago
etc/inc/xmlrpc.inc | ||
---|---|---|
109 | 109 |
function xmlrpc_auth(&$params) { |
110 | 110 |
global $config; |
111 | 111 |
|
112 |
if (!is_array($config['system']['user'])) |
|
112 |
if (!is_array($config['system']['user'])) { |
|
113 |
array_shift($params); |
|
114 |
unset($params['xmlrpcauth']); |
|
113 | 115 |
return false; |
114 |
if (!isset($config['system']['user'][0]['password'])) |
|
116 |
} |
|
117 |
if (!isset($config['system']['user'][0]['password'])) { |
|
118 |
array_shift($params); |
|
119 |
unset($params['xmlrpcauth']); |
|
115 | 120 |
return false; |
121 |
} |
|
116 | 122 |
|
117 | 123 |
$localpass = $config['system']['user'][0]['password']; |
118 | 124 |
if(crypt($params[0], $localpass) == $localpass) { |
119 | 125 |
array_shift($params); |
126 |
unset($params['xmlrpcauth']); |
|
120 | 127 |
return true; |
121 | 128 |
} else if(crypt($params['xmlrpcauth'], $localpass) == $localpass) { |
129 |
array_shift($params); |
|
122 | 130 |
unset($params['xmlrpcauth']); |
123 | 131 |
return true; |
124 | 132 |
} |
125 |
unset($params['xmlrpcauth']); |
|
126 | 133 |
|
134 |
array_shift($params); |
|
135 |
unset($params['xmlrpcauth']); |
|
127 | 136 |
return false; |
128 | 137 |
} |
129 | 138 |
|
usr/local/www/xmlrpc.php | ||
---|---|---|
159 | 159 |
if(!xmlrpc_auth($params)) |
160 | 160 |
return $xmlrpc_g['return']['authfail']; |
161 | 161 |
$vipbackup = array(); |
162 |
if (isset($params[1]['virtualip'])) {
|
|
162 |
if (isset($params[0]['virtualip'])) {
|
|
163 | 163 |
if(is_array($config['virtualip']['vip'])) { |
164 | 164 |
foreach ($config['virtualip']['vip'] as $vip) |
165 | 165 |
interface_vip_bring_down($vip); |
... | ... | |
169 | 169 |
// For vip section, first keep items sent from the master |
170 | 170 |
$config = array_merge($config, $params[0]); |
171 | 171 |
// Then add ipalias and proxyarp types already defined on the backup |
172 |
foreach ($vipbackup as $vip) { |
|
173 |
if (($vip['mode'] == 'ipalias') || ($vip['mode'] == 'proxyarp')) |
|
174 |
$config['virtualip']['vip'][]=$vip ; |
|
172 |
if (is_array($vipbackup)) { |
|
173 |
foreach ($vipbackup as $vip) { |
|
174 |
if (($vip['mode'] == 'ipalias') || ($vip['mode'] == 'proxyarp')) |
|
175 |
$config['virtualip']['vip'][]=$vip ; |
|
176 |
} |
|
175 | 177 |
} |
176 | 178 |
$mergedkeys = implode(",", array_keys($params[0])); |
177 | 179 |
write_config(sprintf(gettext("Merged in config (%s sections) from XMLRPC client."),$mergedkeys)); |
... | ... | |
219 | 221 |
$params = xmlrpc_params_to_php($raw_params); |
220 | 222 |
if(!xmlrpc_auth($params)) |
221 | 223 |
return $xmlrpc_g['return']['authfail']; |
222 |
if (isset($params[1]['virtualip'])) {
|
|
224 |
if (isset($params[0]['virtualip'])) {
|
|
223 | 225 |
if(is_array($config['virtualip']['vip'])) { |
224 | 226 |
foreach ($config['virtualip']['vip'] as $vip) |
225 | 227 |
interface_vip_bring_down($vip); |
Also available in: Unified diff
Be consistent on shifting array during authentication. Also check for array to avoid strange errors.