tbrehm
2012-04-16 84569173c9a21ebab5ecdb662d9b4fb98b7c336b
Fixed: FS#2176 - collision between shell/ftp accounts and client accounts named webXX is not checked
6 files modified
46 ■■■■■ changed files
interface/lib/classes/validate_client.inc.php 30 ●●●●● patch | view | raw | blame | history
interface/web/client/client_edit.php 2 ●●● patch | view | raw | blame | history
interface/web/client/form/client.tform.php 6 ●●●● patch | view | raw | blame | history
interface/web/client/form/reseller.tform.php 6 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en_client.lng 1 ●●●● patch | view | raw | blame | history
interface/web/client/lib/lang/en_reseller.lng 1 ●●●● patch | view | raw | blame | history
interface/lib/classes/validate_client.inc.php
@@ -65,6 +65,36 @@
        }
    }
    
    function username_collision($field_name, $field_value, $validator) {
        global $app;
        if(isset($app->remoting_lib->primary_id)) {
            $client_id = $app->remoting_lib->primary_id;
        } else {
            $client_id = $app->tform->primary_id;
        }
        $app->uses('getconf');
        $global_config = $app->getconf->get_global_config('sites');
        if(substr($field_value,0,3) == 'web' &&
          ($global_config['ftpuser_prefix'] == '[CLIENTNAME]' ||
           $global_config['ftpuser_prefix'] == '' ||
           $global_config['shelluser_prefix'] == '[CLIENTNAME]' ||
           $global_config['shelluser_prefix'] == '' )) {
            $errmsg = $validator['errmsg'];
            if(isset($app->tform->wordbook[$errmsg])) {
                return $app->tform->wordbook[$errmsg]."<br>\r\n";
            } else {
                return $errmsg."<br>\r\n";
            }
        }
    }
    
    
    
interface/web/client/client_edit.php
@@ -1,6 +1,6 @@
<?php
/*
Copyright (c) 2005 - 2008, Till Brehm, projektfarm Gmbh
Copyright (c) 2005 - 2012, Till Brehm, projektfarm Gmbh, ISPConfig UG
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
interface/web/client/form/client.tform.php
@@ -126,7 +126,11 @@
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                        2 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_collision',
                                                        'errmsg'=> 'username_error_collision'),
                                        3 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
interface/web/client/form/reseller.tform.php
@@ -126,7 +126,11 @@
                                                        'class' => 'validate_client',
                                                        'function' => 'username_unique',
                                                        'errmsg'=> 'username_error_unique'),
                                        2 => array (    'type'    => 'REGEX',
                                        2 => array (    'type'    => 'CUSTOM',
                                                        'class' => 'validate_client',
                                                        'function' => 'username_collision',
                                                        'errmsg'=> 'username_error_collision'),
                                        3 => array (    'type'    => 'REGEX',
                                                        'regex' => '/^[\w\.\-\_]{0,64}$/',
                                                        'errmsg'=> 'username_error_regex'),
                                        ),
interface/web/client/lib/lang/en_client.lng
@@ -109,4 +109,5 @@
$wb["limit_openvz_vm_error_notint"] = 'The virtual server limit must be a number.';
$wb["web_php_options_notempty"] = 'No PHP option(s) selected. Select at least one PHP option.';
$wb["ssh_chroot_notempty"] = 'No SSH chroot option selected. Select at least one SSH option.';
$wb["username_error_collision"] = 'The username may not start with the word - web -';
?>
interface/web/client/lib/lang/en_reseller.lng
@@ -108,4 +108,5 @@
$wb["limit_openvz_vm_error_notint"] = 'The virtual server limit must be a number.';
$wb["web_php_options_notempty"] = 'No PHP option(s) selected. Select at least one PHP option.';
$wb["ssh_chroot_notempty"] = 'No SSH chroot option selected. Select at least one SSH option.';
$wb["username_error_collision"] = 'The username may not start with the word - web -';
?>