Skip to content

Commit 61cbec7

Browse files
committed
Remove undeclared modules instead of throwing an error in remote API client add function.
1 parent fdfa05a commit 61cbec7

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

interface/lib/classes/remoting_lib.inc.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,17 @@ function ispconfig_sysuser_add($params, $insert_id){
296296
if(!isset($params['modules'])) {
297297
$modules = $conf['interface_modules_enabled'];
298298
} else {
299-
// Check if modules are allowed
300-
$allowed_modules = explode(',', $conf['interface_modules_enabled']);
301299
$modules = $params['modules'];
302-
foreach(explode(',', $modules) as $module) {
300+
301+
// Check if modules are allowed and remove unknown modules
302+
$allowed_modules = explode(',', $conf['interface_modules_enabled']);
303+
$modules_array = explode(',', $modules);
304+
foreach($modules_array as $key => $module) {
303305
if(!in_array($module, $allowed_modules)) {
304-
throw new SoapFault('Invalid modules', 'Module '.$module.' is not allowed.');
306+
unset($modules_array[$key]);
305307
}
306308
}
309+
$modules = implode(',', $modules_array);
307310
}
308311
if(isset($params['limit_client']) && $params['limit_client'] > 0) {
309312
$modules .= ',client';
@@ -332,13 +335,23 @@ function ispconfig_sysuser_add($params, $insert_id){
332335
}
333336

334337
function ispconfig_sysuser_update($params, $client_id){
335-
global $app;
338+
global $app, $conf;
336339
$username = $params["username"];
337340
$clear_password = $params["password"];
338341
$language = $params['language'];
339342
$modules = $params['modules'];
340343
$client_id = $app->functions->intval($client_id);
341344

345+
// Check if modules are allowed and remove unknown modules
346+
$allowed_modules = explode(',', $conf['interface_modules_enabled']);
347+
$modules_array = explode(',', $modules);
348+
foreach($modules_array as $key => $module) {
349+
if(!in_array($module, $allowed_modules)) {
350+
unset($modules_array[$key]);
351+
}
352+
}
353+
$modules = implode(',', $modules_array);
354+
342355
if(!isset($params['_ispconfig_pw_crypted']) || $params['_ispconfig_pw_crypted'] != 1) $password = $app->auth->crypt_password(stripslashes($clear_password));
343356
else $password = $clear_password;
344357
$params = array($username);

0 commit comments

Comments
 (0)