diff --git a/install/sql/incremental/upd_dev_collection.sql b/install/sql/incremental/upd_dev_collection.sql index d18440fa94bce00cb09082baf33c6c8e2f2584ee..1a2f2e9c532f89a1ef89b7b88e5d2ec468c2be4d 100644 --- a/install/sql/incremental/upd_dev_collection.sql +++ b/install/sql/incremental/upd_dev_collection.sql @@ -1,2 +1,3 @@ +ALTER TABLE `server_php` ADD `php_cli_binary` varchar(255) DEFAULT NULL AFTER `php_fpm_socket_dir`; INSERT IGNORE INTO `dns_ssl_ca` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `active`, `ca_name`, `ca_issue`, `ca_wildcard`, `ca_iodef`, `ca_critical`) VALUES -(NULL, 1, 1, 'riud', 'riud', '', 'Y', 'Amazon Trust Services', 'amazontrust.com', 'Y', '', 0); \ No newline at end of file +(NULL, 1, 1, 'riud', 'riud', '', 'Y', 'Amazon Trust Services', 'amazontrust.com', 'Y', '', 0); diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql index 01c2e2d86724b754e022cf158e919d3ed972fb03..169cdc5568f6f200cc0a863e785ef492494c10d6 100644 --- a/install/sql/ispconfig3.sql +++ b/install/sql/ispconfig3.sql @@ -1461,6 +1461,7 @@ CREATE TABLE `server_php` ( `php_fpm_ini_dir` varchar(255) DEFAULT NULL, `php_fpm_pool_dir` varchar(255) DEFAULT NULL, `php_fpm_socket_dir` varchar(255) DEFAULT NULL, + `php_cli_binary` varchar(255) DEFAULT NULL, `active` enum('n','y') NOT NULL DEFAULT 'y', `sortprio` int(20) NOT NULL DEFAULT 100, PRIMARY KEY (`server_php_id`) diff --git a/interface/lib/classes/validate_cron.inc.php b/interface/lib/classes/validate_cron.inc.php index 888fdd5cb718c2d084aa6db8a49b2851cd03aedd..be28a87d4cef120a8bad0a68efbfb5a2edb4a50e 100644 --- a/interface/lib/classes/validate_cron.inc.php +++ b/interface/lib/classes/validate_cron.inc.php @@ -45,15 +45,40 @@ class validate_cron { Validator function to check if a given cron command is in correct form (url only). */ function command_format($field_name, $field_value, $validator) { + global $app, $page; + if(preg_match("'^(\w+):\/\/'", $field_value, $matches)) { + //* Add the {DOMAIN} placeholder to the validation process + if(preg_match("/{DOMAIN}/", $field_value)) { + + if(isset($app->remoting_lib->primary_id)) { + $cronjob = $app->remoting_lib->dataRecord; + } else { + $cronjob = $page->dataRecord; + } + + if($cronjob['parent_domain_id'] > 0) { + $parent_domain = $app->db->queryOneRecord("SELECT `domain` FROM `web_domain` WHERE `domain_id` = ?", $cronjob['parent_domain_id']); + } + + $trans = array( + '{DOMAIN}' => $parent_domain['domain'] + ); + + $field_value = strtr($field_value, $trans); + + } $parsed = parse_url($field_value); + if($parsed === false) return $this->get_error($validator['errmsg']); if($parsed["scheme"] != "http" && $parsed["scheme"] != "https") return $this->get_error($validator['errmsg']); + if(preg_match("'^([a-z0-9][a-z0-9\-]{0,62}\.)+([A-Za-z0-9\-]{2,63})$'i", $parsed["host"]) == false) return $this->get_error($validator['errmsg']); + - if(preg_match("'^([a-z0-9][a-z0-9_\-]{0,62}\.)+([A-Za-z0-9\-]{2,63})$'i", $parsed["host"]) == false) return $this->get_error($validator['errmsg']); } + if(strpos($field_value, "\n") !== false || strpos($field_value, "\r") !== false || strpos($field_value, chr(0)) !== false) { return $this->get_error($validator['errmsg']); } diff --git a/interface/web/admin/form/server_php.tform.php b/interface/web/admin/form/server_php.tform.php index 67f22cbeb43277931f7451d89a135319b13de5c7..a77a719f20bed41e77cf360549b6445980084d2e 100644 --- a/interface/web/admin/form/server_php.tform.php +++ b/interface/web/admin/form/server_php.tform.php @@ -248,6 +248,30 @@ $form["tabs"]['php_fpm'] = array( //################################# ) ); +$form["tabs"]['php_cli'] = array ( +'title' => "PHP-CLI settings", +'width' => 80, +'template' => "templates/server_php_cli_edit.htm", +'fields' => array( + //################################# + // Begin Datatable fields + //################################# + 'php_cli_binary' => array( + 'datatype' => 'VARCHAR', + 'formtype' => 'TEXT', + 'filters' => array( + 0 => array( 'event' => 'SAVE', + 'type' => 'STRIPTAGS'), + 1 => array( 'event' => 'SAVE', + 'type' => 'STRIPNL') + ), + 'default' => '', + 'value' => '', + 'width' => '40', + 'maxlength' => '255' + ), +) +); $form["tabs"]['php_sort'] = array ( 'title' => "PHP Sort Priority", 'width' => 80, diff --git a/interface/web/admin/lib/lang/ar_server_php.lng b/interface/web/admin/lib/lang/ar_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/ar_server_php.lng +++ b/interface/web/admin/lib/lang/ar_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/bg_server_php.lng b/interface/web/admin/lib/lang/bg_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/bg_server_php.lng +++ b/interface/web/admin/lib/lang/bg_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/br_server_php.lng b/interface/web/admin/lib/lang/br_server_php.lng index 791db7e3ec70cde55a0ac003fb7738f64942020e..cb1b93acc32442a1830e0e03a79b741f5953b9c4 100644 --- a/interface/web/admin/lib/lang/br_server_php.lng +++ b/interface/web/admin/lib/lang/br_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'O nome não pode ser modificado.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/ca_server_php.lng b/interface/web/admin/lib/lang/ca_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/ca_server_php.lng +++ b/interface/web/admin/lib/lang/ca_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/cn_server_php.lng b/interface/web/admin/lib/lang/cn_server_php.lng index 80571fb1947cfbb38329f6f693f7553391197ca5..102bcc1fbf94070a94e14f2c7731845f4ec25be4 100644 --- a/interface/web/admin/lib/lang/cn_server_php.lng +++ b/interface/web/admin/lib/lang/cn_server_php.lng @@ -17,4 +17,9 @@ $wb['php_fpm_socket_dir_txt'] = 'PHP-FPM套接字目录'; $wb['active_txt'] = '激活'; $wb['php_in_use_error'] = '此PHP版本正在使用中。'; $wb['php_name_in_use_error'] = '名称无法更改。'; +$wb['PHP Sort Priority'] = 'Priority'; +$wb['sortprio_txt'] = 'Priority'; +$wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/cz_server_php.lng b/interface/web/admin/lib/lang/cz_server_php.lng index 64909284298ba7f655b2c7a33e68e299a7620b6c..eb16414a31dafcf8a7132808ea484700c6800261 100644 --- a/interface/web/admin/lib/lang/cz_server_php.lng +++ b/interface/web/admin/lib/lang/cz_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/de_server_php.lng b/interface/web/admin/lib/lang/de_server_php.lng index 4100957b9d336884d26b935487bc1f8a79c48344..a63e90d80c6d650f500088c40224f48666c3ec87 100644 --- a/interface/web/admin/lib/lang/de_server_php.lng +++ b/interface/web/admin/lib/lang/de_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'Der Name kann nicht geändert werden.'; $wb['PHP Sort Priority'] = 'Priorität'; $wb['sortprio_txt'] = 'Sorting Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP Version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI-Einstellungen'; +$wb['php_cli_binary_txt'] = 'Pfad zur PHP-CLI Binary'; ?> diff --git a/interface/web/admin/lib/lang/dk_server_php.lng b/interface/web/admin/lib/lang/dk_server_php.lng index e9b42a51334a4f9868e6d9eee0099ea398194d9c..b43202ae41abdd0ec6b4b2e6773a3b6d309dc514 100644 --- a/interface/web/admin/lib/lang/dk_server_php.lng +++ b/interface/web/admin/lib/lang/dk_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/el_server_php.lng b/interface/web/admin/lib/lang/el_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/el_server_php.lng +++ b/interface/web/admin/lib/lang/el_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/en_server_php.lng b/interface/web/admin/lib/lang/en_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/en_server_php.lng +++ b/interface/web/admin/lib/lang/en_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/es_server_php.lng b/interface/web/admin/lib/lang/es_server_php.lng index e75aa0e4e472095332f3994c901787fd4ae6f120..ff81b3ae90fa99c6327f1ffd3a3fc651807c1789 100644 --- a/interface/web/admin/lib/lang/es_server_php.lng +++ b/interface/web/admin/lib/lang/es_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/fi_server_php.lng b/interface/web/admin/lib/lang/fi_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/fi_server_php.lng +++ b/interface/web/admin/lib/lang/fi_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/fr_server_php.lng b/interface/web/admin/lib/lang/fr_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/fr_server_php.lng +++ b/interface/web/admin/lib/lang/fr_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/hr_server_php.lng b/interface/web/admin/lib/lang/hr_server_php.lng index 9db79d4f9b727891c49319105f3ba293d3b452d3..57c44ae53cba58fc7f3df36dfc8e09e534103c33 100644 --- a/interface/web/admin/lib/lang/hr_server_php.lng +++ b/interface/web/admin/lib/lang/hr_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/hu_server_php.lng b/interface/web/admin/lib/lang/hu_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/hu_server_php.lng +++ b/interface/web/admin/lib/lang/hu_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/id_server_php.lng b/interface/web/admin/lib/lang/id_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/id_server_php.lng +++ b/interface/web/admin/lib/lang/id_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/it_server_php.lng b/interface/web/admin/lib/lang/it_server_php.lng index d4feb7cb0c3232c8aec6c8048c5a437dd5abd3e5..76c97e8adc09a1c471f5461077ff70e4161f0d0b 100644 --- a/interface/web/admin/lib/lang/it_server_php.lng +++ b/interface/web/admin/lib/lang/it_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'Il nome non può essere cambiato.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/ja_server_php.lng b/interface/web/admin/lib/lang/ja_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/ja_server_php.lng +++ b/interface/web/admin/lib/lang/ja_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/nl_server_php.lng b/interface/web/admin/lib/lang/nl_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/nl_server_php.lng +++ b/interface/web/admin/lib/lang/nl_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/pl_server_php.lng b/interface/web/admin/lib/lang/pl_server_php.lng index d86e2cf01ff0d53b779b690c8f072c6adf927ed4..c43dd727cb651640e342baac74dcac028baee45e 100644 --- a/interface/web/admin/lib/lang/pl_server_php.lng +++ b/interface/web/admin/lib/lang/pl_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/pt_server_php.lng b/interface/web/admin/lib/lang/pt_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/pt_server_php.lng +++ b/interface/web/admin/lib/lang/pt_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/ro_server_php.lng b/interface/web/admin/lib/lang/ro_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/ro_server_php.lng +++ b/interface/web/admin/lib/lang/ro_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/ru_server_php.lng b/interface/web/admin/lib/lang/ru_server_php.lng index ca1a8147a3e1739267f95d5db2577fa8e64a50b4..6644018b3a531addcce8b23b470bc058f57d1f8a 100644 --- a/interface/web/admin/lib/lang/ru_server_php.lng +++ b/interface/web/admin/lib/lang/ru_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/se_server_php.lng b/interface/web/admin/lib/lang/se_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/se_server_php.lng +++ b/interface/web/admin/lib/lang/se_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/sk_server_php.lng b/interface/web/admin/lib/lang/sk_server_php.lng index 4d71bb50b7269cea5394e2df229b5d94d42bcb5c..89b357cdbccd594701c970bed0d520904e972ba1 100644 --- a/interface/web/admin/lib/lang/sk_server_php.lng +++ b/interface/web/admin/lib/lang/sk_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/lib/lang/tr_server_php.lng b/interface/web/admin/lib/lang/tr_server_php.lng index 914d28f167314f3fc6b10ec070f44cd4fa4f1a03..447b3ab20bd4f558d77bd10f5343e179f451f2a2 100644 --- a/interface/web/admin/lib/lang/tr_server_php.lng +++ b/interface/web/admin/lib/lang/tr_server_php.lng @@ -20,4 +20,6 @@ $wb['php_name_in_use_error'] = 'The name can not be changed.'; $wb['PHP Sort Priority'] = 'Priority'; $wb['sortprio_txt'] = 'Priority'; $wb['sortprio_long_txt'] = 'Priority of PHP version in the PHP version select box
Default PHP has prio 0 if enabled
Lower value is higher priority'; +$wb['PHP-CLI settings'] = 'PHP-CLI settings'; +$wb['php_cli_binary_txt'] = 'Path to the PHP CLI binary'; ?> diff --git a/interface/web/admin/templates/server_php_cli_edit.htm b/interface/web/admin/templates/server_php_cli_edit.htm new file mode 100644 index 0000000000000000000000000000000000000000..72e26bd4b8bf7cd2d56e64001cf03b9bb3b638f0 --- /dev/null +++ b/interface/web/admin/templates/server_php_cli_edit.htm @@ -0,0 +1,10 @@ +
+ +
+ + + +
+ + +
diff --git a/interface/web/sites/ajax_get_json.php b/interface/web/sites/ajax_get_json.php index f1d8433c8abbe3ec8ef00c8c18b9d0247c784809..5cbf4729a3aa810d8a21ea2f9e254fd7d69c6610 100644 --- a/interface/web/sites/ajax_get_json.php +++ b/interface/web/sites/ajax_get_json.php @@ -248,7 +248,52 @@ if($type == 'getclientssldata'){ $json = $app->functions->json_encode($client); } -//} +if($type == 'getcronplaceholders') { + + $web_docroot_client = ''; + + if($web_id > 0) { + + $web = $app->db->queryOneRecord("SELECT wd.sys_groupid, wd.domain, wd.document_root, sp.php_cli_binary + FROM web_domain wd + LEFT JOIN server_php sp ON wd.server_php_id = sp.server_php_id + WHERE wd.domain_id = ?", $web_id); + + $php_cli_binary = $web['php_cli_binary']; + $domain = $web['domain']; + + $domain_owner = $app->db->queryOneRecord("SELECT limit_cron_type FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $web["sys_groupid"]); + + //* True if the site is assigned to a client + if(isset($domain_owner["limit_cron_type"])) { + if($domain_owner["limit_cron_type"] == 'full') { + $cron_type = 'full'; + } else { + $cron_type = 'chrooted'; + } + } else { + //* True if the site is assigned to the admin + $cron_type = 'full'; + } + + if($cron_type != 'chrooted') { + $web_docroot_client = $web['document_root']; + } + } + + $web_docroot_client .= '/web'; + + if(empty($web['php_cli_binary'])) { + $php_cli_binary = "/usr/bin/php"; + } + + $json = json_encode(array( + 'php_cli_binary' => $php_cli_binary, + 'docroot_client' => $web_docroot_client, + //'cron_type' => $cron_type, + 'domain' => $domain + )); +} header('Content-type: application/json'); echo $json; diff --git a/interface/web/sites/cron_edit.php b/interface/web/sites/cron_edit.php index 62f338f33f30f6e60502cd9e02398fb2f7e961e8..34ed6eb32aa0f3312b8ef5089000315ef765f39c 100644 --- a/interface/web/sites/cron_edit.php +++ b/interface/web/sites/cron_edit.php @@ -78,6 +78,36 @@ class page_action extends tform_actions { $app->tpl->setVar("edit_disabled", 0); } + $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `domain`, `document_root`, `hd_quota`, `php_cli_binary` + FROM `web_domain` + LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id + WHERE `domain_id` = ?", $this->dataRecord["parent_domain_id"]); + + $php_cli_binary = $parent_domain['php_cli_binary']; + $domain = $parent_domain['domain']; + + if($this->dataRecord['type'] != 'chrooted') { + $web_docroot_client = $parent_domain['document_root']; + } else { + $web_docroot_client = ''; + } + + if(empty($parent_domain['php_cli_binary'])) { + $php_cli_binary = "/usr/bin/php"; + } + + if(empty($parent_domain['domain'])) { + $domain = $app->tform->wordbook["domain_not_selected_placeholder_txt"]; + } + + // web folder is hardcoded to /web: + $web_docroot_client .= '/web'; + + // Example values for placeholders. + $app->tpl->setVar("php_cli_binary", $php_cli_binary); + $app->tpl->setVar("docroot_client", $web_docroot_client); + $app->tpl->setVar("domain", $domain); + parent::onShowEnd(); } @@ -129,6 +159,7 @@ class page_action extends tform_actions { } } + parent::onSubmit(); } @@ -148,7 +179,7 @@ class page_action extends tform_actions { $has_error = true; } } - + if($client["limit_cron_type"] == 'url' && $this->dataRecord["type"] != 'url') { $app->error($app->tform->wordbook["limit_cron_url_txt"]); $has_error = true; @@ -178,7 +209,7 @@ class page_action extends tform_actions { $has_error = true; } } - + if($client["limit_cron_type"] == 'url' && $this->dataRecord["type"] != 'url') { $app->error($app->tform->wordbook["limit_cron_url_txt"]); $has_error = true; diff --git a/interface/web/sites/lib/lang/ar_cron.lng b/interface/web/sites/lib/lang/ar_cron.lng index 5cdf5ee15f86892a3bec44533013d44f13f27349..fb114d1a5b71f64f697de6acd18515e71f74f454 100644 --- a/interface/web/sites/lib/lang/ar_cron.lng +++ b/interface/web/sites/lib/lang/ar_cron.lng @@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; ?> diff --git a/interface/web/sites/lib/lang/bg_cron.lng b/interface/web/sites/lib/lang/bg_cron.lng index 2ab58ec6d2204368a6409c0e8ad2f71827843dde..c4877f897254df2ce1da6ab81ba162cc7f206c45 100644 --- a/interface/web/sites/lib/lang/bg_cron.lng +++ b/interface/web/sites/lib/lang/bg_cron.lng @@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; ?> diff --git a/interface/web/sites/lib/lang/br_cron.lng b/interface/web/sites/lib/lang/br_cron.lng index 19aa1e96dcbd200488ae1ba8d8dcac71d299efce..bf26c58310f2385ed1f24ca6d30cdeb919a49d10 100644 --- a/interface/web/sites/lib/lang/br_cron.lng +++ b/interface/web/sites/lib/lang/br_cron.lng @@ -24,3 +24,4 @@ $wb['log_output_txt'] = 'Gravar saída do log'; $wb['limit_cron_url_txt'] = 'Somente URL no Cron. Por favor insira uma URL iniciando com https:// como um comando no Cron.'; $wb['command_error_empty'] = 'Comando a executar está vazio.'; $wb['Cron Job'] = 'Tarefas no Cron'; +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/ca_cron.lng b/interface/web/sites/lib/lang/ca_cron.lng index 4124abd16a464de53b30aa6d4b24e477773275f6..8d04a71e03b191516277e365dee06e72ca0058e2 100644 --- a/interface/web/sites/lib/lang/ca_cron.lng +++ b/interface/web/sites/lib/lang/ca_cron.lng @@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'Cron de type URL seulement. Merci d\'introduire une $wb['command_error_empty'] = 'Le champ Commande à exécuter est vide.'; $wb['command_hint_txt'] = 'par exemple /var/www/clients/clientX/webY/monscript.sh ou https://www.mondomaine.com/chemin/script.php, vous pouvez utiliser la constante [web_root] qui sera remplacée par /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Journaliser la sortie du cron'; +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; ?> diff --git a/interface/web/sites/lib/lang/cn_cron.lng b/interface/web/sites/lib/lang/cn_cron.lng index 5b517d762eb48da540eb59d3b360be85c3f8a24d..f689a930cfdb40db0fbf6636cda7b3f39b70de0f 100644 --- a/interface/web/sites/lib/lang/cn_cron.lng +++ b/interface/web/sites/lib/lang/cn_cron.lng @@ -23,4 +23,5 @@ $wb['command_hint_txt'] = '例如,/var/www/clients/clientX/webY/myscript.sh $wb['log_output_txt'] = '记录输出'; $wb['limit_cron_url_txt'] = '仅限 URL 计划任务。请将以 https:// 开头的 URL 作为计划任务命令输入。'; $wb['command_error_empty'] = '命令为空。'; +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; ?> diff --git a/interface/web/sites/lib/lang/cz_cron.lng b/interface/web/sites/lib/lang/cz_cron.lng index 8588408041d25f700ce85e6a77518dc823aaebe6..5144015d6f0d13bd1e7ffe182bb095da8034b5f0 100644 --- a/interface/web/sites/lib/lang/cz_cron.lng +++ b/interface/web/sites/lib/lang/cz_cron.lng @@ -23,3 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or http://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/de_cron.lng b/interface/web/sites/lib/lang/de_cron.lng index 535f7e7dca8a9b3fae443da5c63c81b2dab49225..81f1f61e7d67f396f8a6bb979c9ef9ca78120f27 100644 --- a/interface/web/sites/lib/lang/de_cron.lng +++ b/interface/web/sites/lib/lang/de_cron.lng @@ -19,8 +19,10 @@ $wb['run_wday_error_format'] = 'Das Format für Wochentage ist nicht korrekt.'; $wb['command_error_format'] = 'Das Format für den Befehl ist nicht korrekt. Beachten Sie, dass bei einem URL Aufruf nur http und https erlaubt ist.'; $wb['unknown_fieldtype_error'] = 'Es wurde ein unbekanntes Feld verwendet.'; $wb['server_id_error_empty'] = 'Die Server-ID ist leer.'; -$wb['command_hint_txt'] = 'z. B. /var/www/clients/clientX/webY/myscript.sh oder https://www.mydomain.com/path/script.php. Der Platzhalter [web_root] wird durch /var/www/clients/clientX/webY/web ersetzt.'; +$wb['command_hint_txt'] = 'z.B. /var/www/clients/clientX/webY/myscript.sh oder https://www.mydomain.com/path/script.php, können Sie die obigen Platzhalter einfügen, die dann durch ihren Wert ersetzt werden. Bewegen Sie den Mauszeiger über die Variable, um den erwarteten Wert zu sehen.'; $wb['log_output_txt'] = 'Ausgabe loggen'; $wb['limit_cron_url_txt'] = 'Es sind nur URL cronjobs möglich. Der Cron-Befehl muss mit https:// beginnen.'; $wb['command_error_empty'] = 'Befehl ist leer.'; -?> +$wb['variables_txt'] = 'Variablen'; +$wb['domain_not_selected_placeholder_txt'] = 'Bitte wähle eine Domain aus'; + diff --git a/interface/web/sites/lib/lang/dk_cron.lng b/interface/web/sites/lib/lang/dk_cron.lng index ac290d40765caaa669ac2a332d7bd466cc1b9a4f..798cb4ea49d403e080c51e1642a3c291fddcaf56 100644 --- a/interface/web/sites/lib/lang/dk_cron.lng +++ b/interface/web/sites/lib/lang/dk_cron.lng @@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command er tom.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/el_cron.lng b/interface/web/sites/lib/lang/el_cron.lng index 9efec9d5ff03b1e23b6ad562711710d926a30b7b..fe4985443050025fd4d0b6ece2a40a4ea10a3949 100644 --- a/interface/web/sites/lib/lang/el_cron.lng +++ b/interface/web/sites/lib/lang/el_cron.lng @@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/en_cron.lng b/interface/web/sites/lib/lang/en_cron.lng index 871d4a292e767fc4356678bc3552bdb4d65a777c..ecd146deea118dd1713a20bc7ff1d9bc6a44fe04 100644 --- a/interface/web/sites/lib/lang/en_cron.lng +++ b/interface/web/sites/lib/lang/en_cron.lng @@ -19,8 +19,9 @@ $wb['run_wday_error_format'] = 'Invalid format for days of the week.'; $wb['command_error_format'] = 'Invalid command format. Please note that in case of an url call only http/https is allowed.'; $wb['unknown_fieldtype_error'] = 'An unknown field type has been used.'; $wb['server_id_error_empty'] = 'The server ID is empty.'; -$wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; +$wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can include the placeholders above that will be replaced with their value. Hover over the variable to see it\'s expected value.'; $wb['log_output_txt'] = 'Log output'; $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with https:// as cron command.'; $wb['command_error_empty'] = 'Command is empty.'; -?> \ No newline at end of file +$wb['variables_txt'] = 'Variables'; +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/es_cron.lng b/interface/web/sites/lib/lang/es_cron.lng index c8e2d567b409bee60aff97942bd975d86283581a..ccf7753b68c66ea3eadb221b28e38d2fbfce0c93 100644 --- a/interface/web/sites/lib/lang/es_cron.lng +++ b/interface/web/sites/lib/lang/es_cron.lng @@ -23,4 +23,4 @@ $wb['run_wday_txt'] = 'Días de la semana'; $wb['server_id_error_empty'] = 'La ID del servidor está vacía.'; $wb['server_id_txt'] = 'Servidor'; $wb['unknown_fieldtype_error'] = 'Se ha usado un tipo de campo desconocido.'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/fi_cron.lng b/interface/web/sites/lib/lang/fi_cron.lng index cb019571b45a3c4df86c8b09a4c768cf23bcc559..b45f2e8849632f4637c9b19eb6549ae60ef93b8a 100644 --- a/interface/web/sites/lib/lang/fi_cron.lng +++ b/interface/web/sites/lib/lang/fi_cron.lng @@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; + diff --git a/interface/web/sites/lib/lang/fr_cron.lng b/interface/web/sites/lib/lang/fr_cron.lng index 4124abd16a464de53b30aa6d4b24e477773275f6..407b246a11458bcd8d8d6f1d54a8a4c56c0756b1 100644 --- a/interface/web/sites/lib/lang/fr_cron.lng +++ b/interface/web/sites/lib/lang/fr_cron.lng @@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'Cron de type URL seulement. Merci d\'introduire une $wb['command_error_empty'] = 'Le champ Commande à exécuter est vide.'; $wb['command_hint_txt'] = 'par exemple /var/www/clients/clientX/webY/monscript.sh ou https://www.mondomaine.com/chemin/script.php, vous pouvez utiliser la constante [web_root] qui sera remplacée par /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Journaliser la sortie du cron'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; + diff --git a/interface/web/sites/lib/lang/hr_cron.lng b/interface/web/sites/lib/lang/hr_cron.lng index 6ae8d6d3b886c1d656ca519cbc72bf73a19bd185..a847d94087b46838a2238639a5fd372c61fda397 100644 --- a/interface/web/sites/lib/lang/hr_cron.lng +++ b/interface/web/sites/lib/lang/hr_cron.lng @@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'Samo za URL cron. Unesite URL koji počinje sa http $wb['command_error_empty'] = 'Naredba je prazna.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; + diff --git a/interface/web/sites/lib/lang/hu_cron.lng b/interface/web/sites/lib/lang/hu_cron.lng index 29d3f87be32143436156eecc0180a89d4d4e96e2..fce63b11f03e4cdae57d11fd11b4df07491f808b 100644 --- a/interface/web/sites/lib/lang/hu_cron.lng +++ b/interface/web/sites/lib/lang/hu_cron.lng @@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; + diff --git a/interface/web/sites/lib/lang/id_cron.lng b/interface/web/sites/lib/lang/id_cron.lng index d5e94fae214d190d521716f918492918d847549a..c001dfb28f7cc1bb4a89754e09eb5ec2d3e87ea0 100644 --- a/interface/web/sites/lib/lang/id_cron.lng +++ b/interface/web/sites/lib/lang/id_cron.lng @@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; + diff --git a/interface/web/sites/lib/lang/it_cron.lng b/interface/web/sites/lib/lang/it_cron.lng index ee38450186d2b0fcc92669cf560f27986c89f86e..7227cab4e669e648362735d9c21fe77dc836cfe7 100644 --- a/interface/web/sites/lib/lang/it_cron.lng +++ b/interface/web/sites/lib/lang/it_cron.lng @@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'Solo URL cron. Per cortesia inserire una URL che in $wb['command_error_empty'] = 'Command vuoto.'; $wb['command_hint_txt'] = 'esempio: /var/www/clients/clientX/webY/myscript.sh o https://www.mydomain.com/path/script.php, puoi usare [web_root] come sostitutivo che viene rimpiazzato da /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; + diff --git a/interface/web/sites/lib/lang/ja_cron.lng b/interface/web/sites/lib/lang/ja_cron.lng index 5cdf5ee15f86892a3bec44533013d44f13f27349..cb02ffe8c6050d18f982c2dbef1bae981f351031 100644 --- a/interface/web/sites/lib/lang/ja_cron.lng +++ b/interface/web/sites/lib/lang/ja_cron.lng @@ -23,4 +23,5 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; + diff --git a/interface/web/sites/lib/lang/nl_cron.lng b/interface/web/sites/lib/lang/nl_cron.lng index c79a3c2a0da826ce4e2411c5f0462e3ccc1f1f50..587cb4d5ce2e018db671311b0eb0f5dee31a3abe 100644 --- a/interface/web/sites/lib/lang/nl_cron.lng +++ b/interface/web/sites/lib/lang/nl_cron.lng @@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'Geen domein geselecteerd'; diff --git a/interface/web/sites/lib/lang/pl_cron.lng b/interface/web/sites/lib/lang/pl_cron.lng index d5f60d3e348910547383657db85987ccdf27e91c..7212a3a2133d6544cbc4644eb49fdc1d30099aa8 100644 --- a/interface/web/sites/lib/lang/pl_cron.lng +++ b/interface/web/sites/lib/lang/pl_cron.lng @@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/pt_cron.lng b/interface/web/sites/lib/lang/pt_cron.lng index 618f47fc8b005592a90e88ef790dd618bd00c17b..a6b06a5305529e32bcfc7aec4c0ef160afc2fd03 100644 --- a/interface/web/sites/lib/lang/pt_cron.lng +++ b/interface/web/sites/lib/lang/pt_cron.lng @@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/ro_cron.lng b/interface/web/sites/lib/lang/ro_cron.lng index 5cdf5ee15f86892a3bec44533013d44f13f27349..8a8d2aa79f1ab6474e0a4df29216d864fde903af 100644 --- a/interface/web/sites/lib/lang/ro_cron.lng +++ b/interface/web/sites/lib/lang/ro_cron.lng @@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/ru_cron.lng b/interface/web/sites/lib/lang/ru_cron.lng index 46a5a7dac837bf1db29361e9542857fbc0522ce8..1774ba5c646c82fa5e75dfd015cff75bce772567 100644 --- a/interface/web/sites/lib/lang/ru_cron.lng +++ b/interface/web/sites/lib/lang/ru_cron.lng @@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'Только URL может быть в задан $wb['command_error_empty'] = 'Команда отсутствует.'; $wb['command_hint_txt'] = 'Например, /var/www/clients/clientX/webY/myscript.sh или https://www.mydomain.com/path/script.php, Вы можете использовать заполнитель [web_root], который заменяется на /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Журнал вывода'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/se_cron.lng b/interface/web/sites/lib/lang/se_cron.lng index de4cb1f9cb5829f91a7e36e25eec2e161b9dfe0d..7ecf078210314d98c407f3a3072e501b8fc82e68 100644 --- a/interface/web/sites/lib/lang/se_cron.lng +++ b/interface/web/sites/lib/lang/se_cron.lng @@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Kommandofältet är tomt.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/sk_cron.lng b/interface/web/sites/lib/lang/sk_cron.lng index f510b7e0ad42dce007412d03e3b4c46a33c9dcdf..7c9341d8138c3d844039fe7219dad7af6e37bd3a 100644 --- a/interface/web/sites/lib/lang/sk_cron.lng +++ b/interface/web/sites/lib/lang/sk_cron.lng @@ -23,4 +23,4 @@ $wb['limit_cron_url_txt'] = 'URL cron only. Please enter a URL starting with htt $wb['command_error_empty'] = 'Command is empty.'; $wb['command_hint_txt'] = 'e.g. /var/www/clients/clientX/webY/myscript.sh or https://www.mydomain.com/path/script.php, you can use [web_root] placeholder that is replaced by /var/www/clients/clientX/webY/web.'; $wb['log_output_txt'] = 'Log output'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/lib/lang/tr_cron.lng b/interface/web/sites/lib/lang/tr_cron.lng index 6e971521845456f9d453f124742bddaa068c3db7..c41267b9228b97f27152418ca91421bcd8e1f945 100644 --- a/interface/web/sites/lib/lang/tr_cron.lng +++ b/interface/web/sites/lib/lang/tr_cron.lng @@ -23,4 +23,4 @@ $wb['command_hint_txt'] = 'Örnek: /var/www/clients/musteriX/webY/betigim.sh ya $wb['log_output_txt'] = 'Günlük çıktısı'; $wb['limit_cron_url_txt'] = 'Yalnız İnternet adresli zamanlanmış görev kullanılabilir. Lütfen zamanlanmış görev komutu olarak https:// ile başlayan bir İnternet adresi yazın.'; $wb['command_error_empty'] = 'Komut boş olamaz.'; -?> +$wb['domain_not_selected_placeholder_txt'] = 'No domain selected'; diff --git a/interface/web/sites/templates/cron_edit.htm b/interface/web/sites/templates/cron_edit.htm index 2c0f22ddb92728b2ef061a0eea1923cfe5ad0c77..68bc8669ca6a466918e249df84c296d210a4daa3 100644 --- a/interface/web/sites/templates/cron_edit.htm +++ b/interface/web/sites/templates/cron_edit.htm @@ -1,5 +1,6 @@
+
+
@@ -51,7 +53,11 @@
-

{tmpl_var name='command_hint_txt'}

+ {tmpl_var name='variables_txt'}: + {SITE_PHP}, + {DOCROOT_CLIENT}, + {DOMAIN} +

{tmpl_var name='command_hint_txt'}

@@ -66,11 +72,36 @@ {tmpl_var name='active'}
- -
+ + + diff --git a/interface/web/sites/templates/cron_list.htm b/interface/web/sites/templates/cron_list.htm index fbca26a84418c983c48e52b76ec4baea6c1863bb..7597e073d4e4c878699e06334e54b108457fcb54 100644 --- a/interface/web/sites/templates/cron_list.htm +++ b/interface/web/sites/templates/cron_list.htm @@ -5,12 +5,12 @@

{tmpl_var name="toolsarea_head_txt"}

- + - - - + + +

@@ -55,7 +55,7 @@ diff --git a/interface/web/sites/web_vhost_domain_edit.php b/interface/web/sites/web_vhost_domain_edit.php index 81d65f2d84f72210c64a4cf230667de21917973f..ca8550f0faeb951b166f635a63c269630c57887e 100644 --- a/interface/web/sites/web_vhost_domain_edit.php +++ b/interface/web/sites/web_vhost_domain_edit.php @@ -1450,6 +1450,25 @@ class page_action extends tform_actions { global $app, $conf; if(isset($this->dataRecord['folder_directive_snippets'])) $app->db->query("UPDATE web_domain SET folder_directive_snippets = ? WHERE domain_id = ?", $this->dataRecord['folder_directive_snippets'], $this->id); + + // Triggers an update of the website's cronjobs and shell users when the PHP version is changed + if(isset($this->dataRecord['server_php_id']) && $this->oldDataRecord['server_php_id'] != $this->dataRecord['server_php_id']) { + $cronjob_list = $app->db->queryAllRecords("SELECT * FROM cron WHERE parent_domain_id = ? and active = 'y'", $this->dataRecord['id']); + if(is_array($cronjob_list)) { + foreach($cronjob_list as $cronjob) { + // Only update cronjobs with placeholders + if(preg_match("/([\{][a-zA-Z_\-0-9]+[\}]|[\[][a-zA-Z_\-0-9]+[\]])/", $cronjob['command'])) { + $app->db->datalogUpdate('cron', $cronjob, 'id', $cronjob['id'], true); + } + } + } + $shelluser_list = $app->db->queryAllRecords("SELECT * FROM shell_user WHERE parent_domain_id = ? and active = 'y'", $this->dataRecord['id']); + if(is_array($shelluser_list)) { + foreach($shelluser_list as $shelluser) { + $app->db->datalogUpdate('shell_user', $shelluser, 'shell_user_id', $shelluser['shell_user_id'], true); + } + } + } } function validateDefaultFastcgiPhpVersion() { diff --git a/server/conf/bash.bashrc.master b/server/conf/bash.bashrc.master index edcaf7dc586023ae17faba1aa0f594690c27cf1c..b6577569de360c662fb727b565f4b7c01f780150 100644 --- a/server/conf/bash.bashrc.master +++ b/server/conf/bash.bashrc.master @@ -12,7 +12,6 @@ fi ## Change machine hostname to site domain ## export HOSTNAME= - @@ -62,4 +61,3 @@ fi #alias la='ls -A' #alias l='ls -CF' - diff --git a/server/conf/bashrc_user_deb.master b/server/conf/bashrc_user_deb.master new file mode 100644 index 0000000000000000000000000000000000000000..10b4b94da275d55a0cd9c1519412367dc49dbe20 --- /dev/null +++ b/server/conf/bashrc_user_deb.master @@ -0,0 +1,137 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + #alias grep='grep --color=auto' + #alias fgrep='fgrep --color=auto' + #alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias l='ls -CF' + + + +# Overwrite the PHP cli binaries by using $PATH: +export PATH=:$PATH + + +alias php="" + + + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + + +# Source custom bashrc files +if [ -d ~/.bashrc.d ] +then + for brc in ~/.bashrc.d/* + do + if [ -f "$brc" ]; then + . "$brc" + fi + done +fi + +unset brc diff --git a/server/conf/bashrc_user_generic.master b/server/conf/bashrc_user_generic.master new file mode 100644 index 0000000000000000000000000000000000000000..563ebefdb2f359244c25cb0249c0be1d61d94302 --- /dev/null +++ b/server/conf/bashrc_user_generic.master @@ -0,0 +1,35 @@ + +## Hack for Jailkit User to change back to the logged in user ## +if [ -n "$LOGNAME" ]; then + if [ "$LOGNAME" != $USER ]; then + export HOME=$LOGNAME + export USER=$LOGNAME + export USERNAME=$LOGNAME + cd $HOME + fi +fi + +## Change machine hostname to site domain ## +export HOSTNAME= + + + +# Overwrite the PHP cli binaries by using $PATH: +export PATH=:$PATH + + +alias php="" + + +# Source custom bashrc files +if [ -d ~/.bashrc.d ] +then + for brc in ~/.bashrc.d/* + do + if [ -f "$brc" ]; then + . "$brc" + fi + done +fi + +unset brc diff --git a/server/conf/bashrc_user_redhat.master b/server/conf/bashrc_user_redhat.master new file mode 100644 index 0000000000000000000000000000000000000000..e88235b4262d52e19180ac791c0fdcce033f7dca --- /dev/null +++ b/server/conf/bashrc_user_redhat.master @@ -0,0 +1,56 @@ +# .bashrc + + +export TERM=xterm + + +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc +fi + + +## Hack for Jailkit User to change back to the logged in user ## +if [ -n "$LOGNAME" ]; then + if [ "$LOGNAME" != $USER ]; then + export HOME=$LOGNAME + export USER=$LOGNAME + export USERNAME=$LOGNAME + cd $HOME + fi +fi + +## Change machine hostname to site domain ## +export HOSTNAME= + + + +# Overwrite the PHP cli binaries by using $PATH: +export PATH=:$PATH + + +alias php="" + + +# User specific environment +if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]] +then + PATH="$HOME/.local/bin:$HOME/bin:$PATH" +fi +export PATH + +# Uncomment the following line if you don't like systemctl's auto-paging feature: +# export SYSTEMD_PAGER= + +# Source custom bashrc files +if [ -d ~/.bashrc.d ] +then + for brc in ~/.bashrc.d/* + do + if [ -f "$brc" ]; then + . "$brc" + fi + done +fi + +unset brc diff --git a/server/lib/classes/cron.d/600-jailkit_maintenance.inc.php b/server/lib/classes/cron.d/600-jailkit_maintenance.inc.php index e38ee58210fe329c1ef0c9b91804f70615528441..ec4b76e0805563e3fc88eff7631041f22c2f5c3c 100644 --- a/server/lib/classes/cron.d/600-jailkit_maintenance.inc.php +++ b/server/lib/classes/cron.d/600-jailkit_maintenance.inc.php @@ -42,12 +42,12 @@ class cronjob_jailkit_maintenance extends cronjob { $jailkit_config = $app->getconf->get_server_config($conf['server_id'], 'jailkit'); if (isset($this->jailkit_config) && isset($this->jailkit_config['jailkit_hardlinks'])) { if ($this->jailkit_config['jailkit_hardlinks'] == 'yes') { - $options = array('hardlink'); + $global_options = array('hardlink'); } elseif ($this->jailkit_config['jailkit_hardlinks'] == 'no') { - $options = array(); + $global_options = array(); } } else { - $options = array('allow_hardlink'); + $global_options = array('allow_hardlink'); } // force all jails to update every 2 weeks @@ -65,7 +65,12 @@ class cronjob_jailkit_maintenance extends cronjob { // limit the number of jails we update at one time according to time of day $num_jails_to_update = (date('H') < 6) ? 25 : 3; - $sql = "SELECT domain_id, domain, document_root, system_user, system_group, php_fpm_chroot, jailkit_chroot_app_sections, jailkit_chroot_app_programs, delete_unused_jailkit, last_jailkit_hash FROM web_domain WHERE type = 'vhost' AND (last_jailkit_update IS NULL OR last_jailkit_update < (NOW() - INTERVAL 24 HOUR)) AND server_id = ? ORDER by last_jailkit_update LIMIT ?"; + $sql = "SELECT domain_id, domain, document_root, system_user, system_group, php_fpm_chroot, jailkit_chroot_app_sections, jailkit_chroot_app_programs, delete_unused_jailkit, last_jailkit_hash, `php_cli_binary` + FROM web_domain + LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id + WHERE type = 'vhost' AND (last_jailkit_update IS NULL OR last_jailkit_update < (NOW() - INTERVAL 24 HOUR)) AND web_domain.server_id = ? and domain_id=57 + ORDER by last_jailkit_update + LIMIT ?"; $records = $app->db->queryAllRecords($sql, $conf['server_id'], $num_jails_to_update); foreach($records as $rec) { @@ -74,6 +79,9 @@ class cronjob_jailkit_maintenance extends cronjob { continue; } + $options = $global_options; + $options['php_cli_binary'] = $rec['php_cli_binary']; + //$app->log('Beginning jailkit maintenance for domain '.$rec['domain'].' at '.$rec['document_root'], LOGLEVEL_DEBUG); print 'Beginning jailkit maintenance for domain '.$rec['domain'].' at '.$rec['document_root']."\n"; diff --git a/server/lib/classes/system.inc.php b/server/lib/classes/system.inc.php index b2c6357d8f1d31a4755d2e1a9c7f90acce615ad6..a995f36562941390e824c1adc49395d7af195ef6 100644 --- a/server/lib/classes/system.inc.php +++ b/server/lib/classes/system.inc.php @@ -2064,7 +2064,7 @@ class system{ function _getinitcommand($servicename, $action, $init_script_directory = '', $check_service) { global $conf, $app; - + // upstart /* removed upstart support - deprecated if(is_executable('/sbin/initctl')){ @@ -2072,7 +2072,7 @@ class system{ if(intval($retval['retval']) == 0) return 'service '.$servicename.' '.$action; } */ - + if(!in_array($action,array('start','stop','restart','reload','force-reload'))) { $app->log('Invalid init command action '.$action,LOGLEVEL_WARN); return false; @@ -2081,10 +2081,10 @@ class system{ //* systemd (now default in all supported OS) if(is_executable('/bin/systemd') || is_executable('/usr/bin/systemctl')){ $app->log('Trying to use Systemd to restart service',LOGLEVEL_DEBUG); - + //* Test service name via regex if(preg_match('/[a-zA-Z0-9\.\-\_]/',$servicename)) { - + //* Test if systemd service is enabled if ($check_service) { $this->exec_safe("systemctl is-enabled ? 2>&1", $servicename); @@ -2092,7 +2092,7 @@ class system{ } else { $app->log('Systemd service '.$servicename.' not found or not enabled.',LOGLEVEL_DEBUG); } - + //* Return service command if ($ret_val == 0 || !$check_service) { return 'systemctl '.$action.' '.$servicename.'.service'; @@ -2108,69 +2108,69 @@ class system{ //* sysvinit fallback $app->log('Using init script to restart service',LOGLEVEL_DEBUG); - + //* Get init script directory if($init_script_directory == '') $init_script_directory = $conf['init_scripts']; if(substr($init_script_directory, -1) === '/') $init_script_directory = substr($init_script_directory, 0, -1); $init_script_directory = realpath($init_script_directory); - + //* Check init script dir if(!is_dir($init_script_directory)) { $app->log('Init script directory '.$init_script_directory.' not found',LOGLEVEL_WARN); return false; } - + //* Forbidden init script paths if(substr($init_script_directory,0,4) == '/var' || substr($init_script_directory,0,4) == '/tmp') { $app->log('Do not put init scripts in /var or /tmp folder.',LOGLEVEL_WARN); return false; } - + //* Check init script dir owner if(fileowner($init_script_directory) !== 0) { $app->log('Init script directory '.$init_script_directory.' not owned by root user',LOGLEVEL_WARN); return false; } - + $full_init_script_path = realpath($init_script_directory.'/'.$servicename); - + //** Gentoo, keep symlink as init script, but do some checks - if(file_exists('/etc/gentoo-release')) { + if(file_exists('/etc/gentoo-release')) { //* check if init script is symlink - if(is_link($init_script_directory.'/'.$servicename)) { + if(is_link($init_script_directory.'/'.$servicename)) { //* Check init script owner (realpath, symlink is checked later) if(fileowner($full_init_script_path) !== 0) { $app->log('Init script '.$full_init_script_path.' not owned by root user',LOGLEVEL_WARN); return false; } - + //* full path is symlink $full_init_script_path_symlink = $init_script_directory.'/'.$servicename; - + //* check if realpath matches symlink if(strpos($full_init_script_path_symlink,$full_init_script_path) == 0) { $full_init_script_path = $full_init_script_path_symlink; } } } - + if($full_init_script_path == '') { $app->log('No init script, we quit here.',LOGLEVEL_WARN); return false; } - + //* Check init script if(!is_file($full_init_script_path)) { $app->log('Init script '.$full_init_script_path.' not found',LOGLEVEL_WARN); return false; } - + //* Check init script owner if(fileowner($full_init_script_path) !== 0) { $app->log('Init script '.$full_init_script_path.' not owned by root user',LOGLEVEL_WARN); return false; } - + if($check_service && is_executable($full_init_script_path)) { return $full_init_script_path.' '.$action; } @@ -2358,6 +2358,27 @@ class system{ } } + public function get_os_type() { + global $app; + + + $dist = "undetected"; + + if(file_exists('/etc/redhat-release') && (filesize('/etc/redhat-release') > 0)) { + $dist = "redhat"; + } elseif(file_exists('/etc/debian_version') && (filesize('/etc/debian_version') > 0)) { + $dist = "debian"; + } elseif(strstr(trim(file_get_contents('/etc/issue')), 'Ubuntu') || (is_file('/etc/os-release') && stristr(file_get_contents('/etc/os-release'), 'Ubuntu'))) { + $dist = "ubuntu"; + } elseif(file_exists('/etc/SuSE-release') && (filesize('/etc/SuSE-release') > 0)) { + $dist = "suse"; + } elseif(file_exists('/etc/gentoo-release') && (filesize('/etc/gentoo-release') > 0)) { + $dist = "gentoo"; + } + + return $dist; + } + public function is_allowed_path($path) { global $app; @@ -2808,11 +2829,27 @@ $app->log("update_jailkit_chroot: removing deprecated directory which jk_update $this->chmod($home_dir . '/var/tmp', 0770, true); } - // TODO: Set /usr/bin/php symlink to php version of the website. - // - // Currently server_php does not have a field for the cli path; - // we can guess/determing according to OS-specific conventions or add that field. - // Then symlink /usr/bin/php (or correct OS-specific path) to that location. + if (!empty($options['php_cli_binary'])) { + if(!file_exists($home_dir . '/' . $options['php_cli_binary'])) { + $app->log("The PHP cli binary " . $options['php_cli_binary'] . " is not available in the jail of the web " . $this->web['domain'] . " / SSH/SFTP user: " . $this->username . ". Check your Jailkit setup!", LOGLEVEL_DEBUG); + $tpl->setVar('use_php_path', false); + $tpl->setVar('use_php_alias', false); + if(is_link($home_dir . '/etc/alternatives/php')) + { + unlink($home_dir . '/etc/alternatives/php'); + } + } else { + if($app->system->get_os_type() == "debian" || $app->system->get_os_type() == "ubuntu") { + $app->log("update_jailkit_chroot: setting alternatives/php to " . $options['php_cli_binary'], LOGLEVEL_DEBUG); + if(is_link($home_dir . '/etc/alternatives/php') || is_file($home_dir . '/etc/alternatives/php')) + { + unlink($home_dir . '/etc/alternatives/php'); + } + symlink($options['php_cli_binary'], $home_dir . '/etc/alternatives/php'); + } + + } + } // search for any hardlinked files which are now missing if (!(in_array('hardlink', $opts) || in_array('allow_hardlink', $options))) { diff --git a/server/plugins-available/cron_jailkit_plugin.inc.php b/server/plugins-available/cron_jailkit_plugin.inc.php index ea3cb2d04ff27431e4bd89a5960fcda0ac0383f7..4b50b561d5019680e21a58395395289974ac4e43 100644 --- a/server/plugins-available/cron_jailkit_plugin.inc.php +++ b/server/plugins-available/cron_jailkit_plugin.inc.php @@ -77,7 +77,8 @@ class cron_jailkit_plugin { } //* get data from web - $parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); + $parent_domain = $app->db->queryOneRecord("SELECT * FROM web_domain LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id WHERE domain_id = ?", $data["new"]["parent_domain_id"]); + if(!$parent_domain["domain_id"]) { $app->log("Parent domain not found", LOGLEVEL_WARN); return 0; @@ -92,6 +93,8 @@ class cron_jailkit_plugin { $this->parent_domain = $parent_domain; + $this->cronjob_id = $data['new']['id']; + $app->uses('system'); if($app->system->is_user($parent_domain['system_user'])) { @@ -121,6 +124,8 @@ class cron_jailkit_plugin { $this->_add_jailkit_user(); + $this->_setup_php_jailkit(); + $command .= 'usermod -U ? 2>/dev/null'; $app->system->exec_safe($command, $parent_domain["system_user"]); @@ -145,8 +150,10 @@ class cron_jailkit_plugin { $app->log("Parent domain not set", LOGLEVEL_WARN); return 0; } + //* get data from web - $parent_domain = $app->db->queryOneRecord("SELECT * FROM `web_domain` WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); + $parent_domain = $app->db->queryOneRecord("SELECT * FROM web_domain LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id WHERE domain_id = ?", $data["new"]["parent_domain_id"]); + if(!$parent_domain["domain_id"]) { $app->log("Parent domain not found", LOGLEVEL_WARN); return 0; @@ -161,6 +168,8 @@ class cron_jailkit_plugin { $this->parent_domain = $parent_domain; + $this->cronjob_id = $data['new']['id']; + if($app->system->is_user($parent_domain['system_user'])) { @@ -189,6 +198,8 @@ class cron_jailkit_plugin { $this->_add_jailkit_user(); + $this->_setup_php_jailkit(); + $this->_update_website_security_level(); $app->system->web_folder_protection($parent_domain['document_root'], true); @@ -231,6 +242,8 @@ class cron_jailkit_plugin { { global $app, $conf; + $app->load('tpl'); + if (isset($this->jailkit_config) && isset($this->jailkit_config['jailkit_hardlinks'])) { if ($this->jailkit_config['jailkit_hardlinks'] == 'yes') { $options = array('hardlink'); @@ -253,33 +266,15 @@ class cron_jailkit_plugin { // check if the chroot environment is created yet if not create it with a list of program sections from the config if (!is_dir($this->parent_domain['document_root'].'/etc/jailkit')) { + $app->system->create_jailkit_chroot($this->parent_domain['document_root'], $this->jailkit_config['jailkit_chroot_app_sections'], $options); $app->log("Added jailkit chroot", LOGLEVEL_DEBUG); $this->_add_jailkit_programs($options); - $app->load('tpl'); - - $tpl = new tpl(); - $tpl->newTemplate("bash.bashrc.master"); - - $tpl->setVar('jailkit_chroot', true); - $tpl->setVar('domain', $this->parent_domain['domain']); - $tpl->setVar('home_dir', $this->_get_home_dir("")); - - $bashrc = $this->parent_domain['document_root'].'/etc/bash.bashrc'; - if(@is_file($bashrc) || @is_link($bashrc)) unlink($bashrc); - - $app->system->file_put_contents($bashrc, $tpl->grab()); - unset($tpl); - - $app->log('Added bashrc script: '.$bashrc, LOGLEVEL_DEBUG); - $tpl = new tpl(); $tpl->newTemplate('motd.master'); - $tpl->setVar('domain', $this->parent_domain['domain']); - $motd = $this->parent_domain['document_root'].'/var/run/motd'; if(@is_file($motd) || @is_link($motd)) unlink($motd); @@ -303,6 +298,7 @@ class cron_jailkit_plugin { } $app->system->update_jailkit_chroot($this->parent_domain['document_root'], $sections, $programs, $options); + } // this gets last_jailkit_update out of sync with master db, but that is ok, @@ -373,6 +369,75 @@ class cron_jailkit_plugin { } } + function _setup_php_jailkit() { + global $app; + + // Create .bashrc file + $app->load('tpl'); + + $tpl = new tpl(); + + if($app->system->get_os_type() == "debian" || $app->system->get_os_type() == "ubuntu") { + $tpl->newTemplate("bashrc_user_deb.master"); + } elseif($app->system->get_os_type() == "redhat") { + $tpl->newTemplate("bashrc_user_redhat.master"); + } else { + $tpl->newTemplate("bashrc_user_generic.master"); + } + + // Predefine some template vars + $tpl->setVar('jailkit_chroot', 'y'); + $tpl->setVar('domain', $this->parent_domain['domain']); + $tpl->setVar('home_dir', $this->_get_home_dir("")); + + $tpl->setVar('use_php_path', false); + $tpl->setVar('use_php_alias', false); + + $php_bin_dir = dirname($this->parent_domain['php_cli_binary']); + + if(($this->parent_domain['server_php_id'] > 0) && !empty($this->parent_domain['php_cli_binary'])) { + if(preg_match('/^(\/usr\/(s)?bin|\/(s)?bin)/', $php_bin_dir)) { + $tpl->setVar('use_php_path', false); + $tpl->setVar('use_php_alias', true); + $tpl->setVar('php_alias', $this->parent_domain['php_cli_binary']); + } else { + $tpl->setVar('use_php_path', true); + $tpl->setVar('use_php_alias', false); + $tpl->setVar('php_bin_dir', $php_bin_dir); + } + + if(!file_exists($this->parent_domain['document_root'] . '/' . $this->parent_domain['php_cli_binary'])) { + $app->log("The PHP cli binary " . $this->parent_domain['php_cli_binary'] . " is not available in the jail of the web " . $this->parent_domain['domain'] . " / cronjob_id: " . $this->cronjob_id . ". Check your Jailkit setup!", LOGLEVEL_DEBUG); + $tpl->setVar('use_php_path', false); + $tpl->setVar('use_php_alias', false); + if(is_link($this->parent_domain['document_root'] . '/etc/alternatives/php')) + { + unlink($this->parent_domain['document_root'] . '/etc/alternatives/php'); + } + } else { + if($app->system->get_os_type() == "debian" || $app->system->get_os_type() == "ubuntu") { + if(is_link($this->parent_domain['document_root'] . '/etc/alternatives/php') || is_file($this->parent_domain['document_root'] . '/etc/alternatives/php')) + { + unlink($this->parent_domain['document_root'] . '/etc/alternatives/php'); + symlink($this->parent_domain['php_cli_binary'], $this->parent_domain['document_root'] . '/etc/alternatives/php'); + } else { + symlink($this->parent_domain['php_cli_binary'], $this->parent_domain['document_root'] . '/etc/alternatives/php'); + } + } + } + } + + $bashrc = $this->parent_domain['document_root'] . '/home/' .$this->parent_domain['system_user'] . '/.bashrc'; + + if(@is_file($bashrc) || @is_link($bashrc)) unlink($bashrc); + file_put_contents($bashrc, $tpl->grab()); + $app->log("Added bashrc script: " . $bashrc, LOGLEVEL_DEBUG); + + unset($tpl); + + } + + private function _delete_jailkit_if_unused($parent_domain_id) { global $app, $conf; diff --git a/server/plugins-available/cron_plugin.inc.php b/server/plugins-available/cron_plugin.inc.php index f8b16b96cbdf3032bef3971bb16317684320fda2..c4fb02d9e2f20d47549944d5b88d6e7e2277f150 100644 --- a/server/plugins-available/cron_plugin.inc.php +++ b/server/plugins-available/cron_plugin.inc.php @@ -93,7 +93,10 @@ class cron_plugin { } //* get data from web - $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `document_root`, `hd_quota` FROM `web_domain` WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); + $parent_domain = $app->db->queryOneRecord("SELECT `domain_id`, `system_user`, `system_group`, `domain`, `document_root`, `hd_quota`, `php_cli_binary` + FROM `web_domain` + LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id + WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); if(!$parent_domain["domain_id"]) { $app->log("Parent domain not found", LOGLEVEL_WARN); return 0; @@ -171,6 +174,7 @@ class cron_plugin { $this->parent_domain = $parent_domain; + $this->_write_crontab(); $this->action = ''; @@ -207,6 +211,7 @@ class cron_plugin { $app->uses("getconf"); $cron_config = $app->getconf->get_server_config($conf["server_id"], 'cron'); + $web_config = $app->getconf->get_server_config($conf["server_id"], 'web'); //* try to find customer's mail address @@ -220,7 +225,10 @@ class cron_plugin { $chr_cmd_count = 0; //* read all active cron jobs from database and write them to file - $cron_jobs = $app->db->queryAllRecords("SELECT c.`run_min`, c.`run_hour`, c.`run_mday`, c.`run_month`, c.`run_wday`, c.`command`, c.`type`, c.`log`, `web_domain`.`domain` as `domain` FROM `cron` as c INNER JOIN `web_domain` ON `web_domain`.`domain_id` = c.`parent_domain_id` WHERE c.`parent_domain_id` = ? AND c.`active` = 'y'", $this->parent_domain["domain_id"]); + $cron_jobs = $app->db->queryAllRecords("SELECT c.`id`, c.`run_min`, c.`run_hour`, c.`run_mday`, c.`run_month`, c.`run_wday`, c.`command`, c.`type`, c.`log`, `web_domain`.`domain` as `domain` + FROM `cron` as c + INNER JOIN `web_domain` ON `web_domain`.`domain_id` = c.`parent_domain_id` + WHERE c.`parent_domain_id` = ? AND c.`active` = 'y'", $this->parent_domain["domain_id"]); if($cron_jobs && count($cron_jobs) > 0) { foreach($cron_jobs as $job) { if($job['run_month'] == '@reboot') { @@ -229,6 +237,7 @@ class cron_plugin { $cron_line = str_replace(" ", "", $job['run_min']) . "\t" . str_replace(" ", "", $job['run_hour']) . "\t" . str_replace(" ", "", $job['run_mday']) . "\t" . str_replace(" ", "", $job['run_month']) . "\t" . str_replace(" ", "", $job['run_wday']); } + $web_domain = $this->parent_domain['domain']; $log_target = ""; $log_wget_target = '/dev/null'; $log_root = ''; @@ -240,8 +249,16 @@ class cron_plugin { $log_wget_target = $log_root . '/cron_wget.log'; } + + $cron_line .= "\t{$this->parent_domain['system_user']}"; //* running as user if($job['type'] == 'url') { + $trans = array( + '{DOMAIN}' => $web_domain + ); + + $job['command'] = strtr($job['command'], $trans); + $cron_line .= "\t{$cron_config['wget']} --no-check-certificate --user-agent='Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0' -q -t 1 -T 7200 -O " . $log_wget_target . " " . escapeshellarg($job['command']) . " " . $log_target; } else { if(strpos($job['command'], "\n") !== false || strpos($job['command'], "\r") !== false || strpos($job['command'], chr(0)) !== false) { @@ -249,18 +266,43 @@ class cron_plugin { continue; } - $web_root = ''; + $web_docroot_client = ''; + + // web folder is hardcoded to /web: + $web_folder = '/web'; + if($job['type'] == 'chrooted') { if(substr($job['command'], 0, strlen($this->parent_domain['document_root'])) == $this->parent_domain['document_root']) { //* delete the unneeded path part $job['command'] = substr($job['command'], strlen($this->parent_domain['document_root'])); } } else { - $web_root = $this->parent_domain['document_root']; + $web_docroot_client = $this->parent_domain['document_root']; } - $web_root .= '/web'; - $job['command'] = str_replace('[web_root]', $web_root, $job['command']); + if(empty($this->parent_domain['php_cli_binary'])) { + // PHP cli binary not set or default was selected, fallback to "/usr/bin/php" + $web_php_cli = '/usr/bin/php'; + $app->log("PHP CLI binary not set for the website\'s selected PHP version or Default was selected. Fall back to \"/usr/bin/php\" for cronjob id " . $job['id'], LOGLEVEL_DEBUG); + if($job['type'] == 'chrooted') { + if(!file_exists($this->parent_domain['document_root'] . $web_php_cli)) { + $app->log("The PHP cli binary " . $web_php_cli . " is not available in the jail of the web " . $web_domain . " / cronjob_id: " . $job['id'] . ". Check your Jailkit setup!", LOGLEVEL_DEBUG); + } + } + } else { + $web_php_cli = $this->parent_domain['php_cli_binary']; + } + + $web_docroot_client .= $web_folder; + + $trans = array( + '[web_root]' => $web_docroot_client, + '{DOCROOT_CLIENT}' => $web_docroot_client, + '{DOMAIN}' => $web_domain, + '{SITE_PHP}' => $web_php_cli + ); + + $job['command'] = strtr($job['command'], $trans); $cron_line .= "\t"; //if($job['type'] != 'chrooted' && substr($job['command'], 0, 1) != "/") $cron_line .= $this->parent_domain['document_root'].'/'; diff --git a/server/plugins-available/shelluser_base_plugin.inc.php b/server/plugins-available/shelluser_base_plugin.inc.php index 5bbda0e13dc36eed4db5045d868393a3f1f777cf..953f6aa52d600c9f2de92abe4a82cb6ed51de65d 100755 --- a/server/plugins-available/shelluser_base_plugin.inc.php +++ b/server/plugins-available/shelluser_base_plugin.inc.php @@ -80,7 +80,12 @@ class shelluser_base_plugin { } //* Check if the resulting path is inside the docroot - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain + LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id + WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); + + $this->web = $web; + if(substr($data['new']['dir'],0,strlen($web['document_root'])) != $web['document_root']) { $app->log('Directory of the shell user is outside of website docroot.',LOGLEVEL_WARN); return false; @@ -133,9 +138,18 @@ class shelluser_base_plugin { $app->system->chown($homedir,$data['new']['puser'],false); $app->system->chgrp($homedir,$data['new']['pgroup'],false); } + $command = 'useradd -d ? -g ? -o'; // non unique $command .= ' -s ? -u ? ?'; $app->system->exec_safe($command, $homedir, $data['new']['pgroup'], $data['new']['shell'], $uid, $data['new']['username']); + + //* Create .bashrc.d directory + if(!is_dir($homedir.'/.bashrc.d')){ + $app->file->mkdirs($homedir.'/.bashrc.d', '0750'); + $app->system->chown($homedir.'/.bashrc.d', $data['new']['username']); + $app->system->chgrp($homedir.'/.bashrc.d', $data['new']['pgroup']); + } + $app->log("Executed command: ".$command, LOGLEVEL_DEBUG); $app->log("Added shelluser: ".$data['new']['username'], LOGLEVEL_DEBUG); @@ -167,11 +181,27 @@ class shelluser_base_plugin { $app->system->chmod($homedir.'/.profile', 0644); $app->system->chown($homedir.'/.profile', $data['new']['username']); $app->system->chgrp($homedir.'/.profile', $data['new']['pgroup']); + $profile_content = "if [ -f ~/.bashrc ] +then + . ~/.bashrc +fi + +"; + $app->system->file_put_contents($homedir.'/.profile', $profile_content); + + //* Create .bashrc.d directory + if(!is_dir($homedir.'/.bashrc.d')){ + $app->file->mkdirs($homedir.'/.bashrc.d', '0750'); + $app->system->chown($homedir.'/.bashrc.d', $data['new']['username']); + $app->system->chgrp($homedir.'/.bashrc.d', $data['new']['pgroup']); + } + + $this->_add_user_bashrc(); // Create symlinks for conveniance, SFTP user should not land in an empty dir. - symlink('../../web', $homedir.'/web'); - symlink('../../log', $homedir.'/log'); - symlink('../../private', $homedir.'/private'); + if(!is_link($homedir.'/web')) symlink('../../web', $homedir.'/web'); + if(!is_link($homedir.'/log')) symlink('../../log', $homedir.'/log'); + if(!is_link($homedir.'/private')) symlink('../../private', $homedir.'/private'); //* Disable shell user temporarily if we use jailkit if($data['new']['chroot'] == 'jailkit') { @@ -202,7 +232,12 @@ class shelluser_base_plugin { } //* Check if the resulting path is inside the docroot - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); + $web = $app->db->queryOneRecord("SELECT * FROM web_domain + LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id + WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); + + $this->web = $web; + if(substr($data['new']['dir'],0,strlen($web['document_root'])) != $web['document_root']) { $app->log('Directory of the shell user is outside of website docroot.',LOGLEVEL_WARN); return false; @@ -288,7 +323,7 @@ class shelluser_base_plugin { if(!is_file($data['new']['dir']).'/.bash_history') { $app->system->touch($homedir.'/.bash_history'); $app->system->chmod($homedir.'/.bash_history', 0750); - $app->system->chown($homedir.'/.bash_history', $data['new']['username']); + $app->system->chown($homedir.'/.bash_history', $data['new']['puser']); $app->system->chgrp($homedir.'/.bash_history', $data['new']['pgroup']); } @@ -296,10 +331,26 @@ class shelluser_base_plugin { if(!is_file($data['new']['dir']).'/.profile') { $app->system->touch($homedir.'/.profile'); $app->system->chmod($homedir.'/.profile', 0644); - $app->system->chown($homedir.'/.profile', $data['new']['username']); + $app->system->chown($homedir.'/.profile', $data['new']['puser']); $app->system->chgrp($homedir.'/.profile', $data['new']['pgroup']); + $profile_content = "if [ -f ~/.bashrc ] +then + . ~/.bashrc +fi + +"; + $app->system->file_put_contents($homedir.'/.profile', $profile_content); + } + + //* Create .bashrc.d directory + if(!is_dir($homedir.'/.bashrc.d')){ + $app->file->mkdirs($homedir.'/.bashrc.d', '0750'); + $app->system->chown($homedir.'/.bashrc.d', $data['new']['puser']); + $app->system->chgrp($homedir.'/.bashrc.d', $data['new']['pgroup']); } + $this->_add_user_bashrc(); + //* Add webfolder protection again $app->system->web_folder_protection($web['document_root'], true); } else { @@ -537,6 +588,57 @@ class shelluser_base_plugin { } + function _add_user_bashrc() { + global $app; + + // Create .bashrc file + $app->load('tpl'); + + + $tpl = new tpl(); + + // Predefine some template vars + $tpl->setVar('jailkit_chroot', 'n'); + $tpl->setVar('use_php_path', false); + $tpl->setVar('use_php_alias', false); + + if($app->system->get_os_type() == "debian" || $app->system->get_os_type() == "ubuntu") { + $tpl->newTemplate("bashrc_user_deb.master"); + } elseif($app->system->get_os_type() == "redhat") { + $tpl->newTemplate("bashrc_user_redhat.master"); + } else { + $tpl->newTemplate("bashrc_user_generic.master"); + } + + $php_bin_dir = dirname($this->web['php_cli_binary']); + + if(($this->web['server_php_id'] > 0) && !empty($this->web['php_cli_binary'])) { + if(preg_match('/^(\/usr\/(s)?bin|\/(s)?bin)/', $php_bin_dir)) { + $tpl->setVar('use_php_path', false); + $tpl->setVar('use_php_alias', true); + $tpl->setVar('php_alias', $this->web['php_cli_binary']); + } else { + $tpl->setVar('use_php_path', true); + $tpl->setVar('use_php_alias', false); + $tpl->setVar('php_bin_dir', $php_bin_dir); + } + + } elseif(($this->web['server_php_id'] > 0) && empty($this->web['php_cli_binary'])) { + $app->log("The PHP cli binary is not set for the selected PHP version. Affected web: " . $this->web['domain'], LOGLEVEL_DEBUG); + } + + $bashrc = $this->data['new']['dir'] . '/home/' . $this->data['new']['username'] . '/.bashrc'; + + if(@is_file($bashrc) || @is_link($bashrc)) unlink($bashrc); + + file_put_contents($bashrc, $tpl->grab()); + $app->system->chown($bashrc, $this->data['new']['username']); + $app->system->chgrp($bashrc, $this->data['new']['pgroup']); + $app->log("Added bashrc script: " . $bashrc, LOGLEVEL_DEBUG); + unset($tpl); + + } + } // end class ?> diff --git a/server/plugins-available/shelluser_jailkit_plugin.inc.php b/server/plugins-available/shelluser_jailkit_plugin.inc.php index fc37727ad770423348deefd2602b7304beaa500e..912f33c2e087fa763107b432c586e58a2e07bafa 100755 --- a/server/plugins-available/shelluser_jailkit_plugin.inc.php +++ b/server/plugins-available/shelluser_jailkit_plugin.inc.php @@ -82,7 +82,12 @@ class shelluser_jailkit_plugin { } - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); + + $web = $app->db->queryOneRecord("SELECT * FROM web_domain LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); + + $this->web = $web; + + $this->username = $data['new']['username']; if(!$app->system->is_allowed_user($data['new']['username'], false, false) || !$app->system->is_allowed_user($data['new']['puser'], true, true) @@ -136,6 +141,8 @@ class shelluser_jailkit_plugin { //* call the ssh-rsa update function $this->_setup_ssh_rsa(); + $this->_setup_php_jailkit(); + $app->system->usermod($data['new']['username'], 0, 0, '', '/usr/sbin/jk_chrootsh', '', ''); //* Unlock user @@ -190,7 +197,13 @@ class shelluser_jailkit_plugin { } if($app->system->is_user($data['new']['puser'])) { - $web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']); + + + $web = $app->db->queryOneRecord("SELECT * FROM web_domain LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); + + $this->web = $web; + + $this->username = $data['new']['username']; // Get the UID of the parent user $uid = intval($app->system->getuid($data['new']['puser'])); @@ -223,6 +236,8 @@ class shelluser_jailkit_plugin { $this->_add_jailkit_user(); + $this->_setup_php_jailkit(); + //* call the ssh-rsa update function $this->_setup_ssh_rsa(); @@ -315,6 +330,8 @@ class shelluser_jailkit_plugin { { global $app, $conf; + $app->load('tpl'); + if (isset($this->jailkit_config) && isset($this->jailkit_config['jailkit_hardlinks'])) { if ($this->jailkit_config['jailkit_hardlinks'] == 'yes') { $options = array('hardlink'); @@ -327,7 +344,10 @@ class shelluser_jailkit_plugin { $options = array('allow_hardlink'); } - $web = $app->db->queryOneRecord("SELECT domain, last_jailkit_hash FROM web_domain WHERE domain_id = ?", $this->data['new']["parent_domain_id"]); + $web = $app->db->queryOneRecord("SELECT `domain`, `last_jailkit_hash`, `php_cli_binary` FROM web_domain + LEFT JOIN server_php ON web_domain.server_php_id = server_php.server_php_id + WHERE `domain_id` = ?", $data["new"]["parent_domain_id"]); + $last_updated = preg_split('/[\s,]+/', $this->jailkit_config['jailkit_chroot_app_sections'] .' '.$this->jailkit_config['jailkit_chroot_app_programs'] @@ -346,23 +366,6 @@ class shelluser_jailkit_plugin { $this->_add_jailkit_programs($options); - $app->load('tpl'); - - $tpl = new tpl(); - $tpl->newTemplate("bash.bashrc.master"); - - $tpl->setVar('jailkit_chroot', true); - $tpl->setVar('domain', $web['domain']); - $tpl->setVar('home_dir', $this->_get_home_dir("")); - - $bashrc = $this->data['new']['dir'].'/etc/bash.bashrc'; - if(@is_file($bashrc) || @is_link($bashrc)) unlink($bashrc); - - file_put_contents($bashrc, $tpl->grab()); - unset($tpl); - - $app->log("Added bashrc script: ".$bashrc, LOGLEVEL_DEBUG); - $tpl = new tpl(); $tpl->newTemplate("motd.master"); @@ -389,8 +392,11 @@ class shelluser_jailkit_plugin { foreach ($records as $record) { $options[] = 'skip='.$record['web_folder']; } + $options['php_cli_binary'] = $web['php_cli_binary']; $app->system->update_jailkit_chroot($this->data['new']['dir'], $sections, $programs, $options); + + } // this gets last_jailkit_update out of sync with master db, but that is ok, @@ -457,13 +463,13 @@ class shelluser_jailkit_plugin { $app->system->chown($this->data['new']['dir'].$jailkit_chroot_userhome, $this->data['new']['username']); $app->system->chgrp($this->data['new']['dir'].$jailkit_chroot_userhome, $this->data['new']['pgroup']); - $app->log("Added created jailkit user home in : ".$this->data['new']['dir'].$jailkit_chroot_userhome, LOGLEVEL_DEBUG); + $app->log("Added created jailkit user home in: ".$this->data['new']['dir'].$jailkit_chroot_userhome, LOGLEVEL_DEBUG); if(!is_dir($this->data['new']['dir'].$jailkit_chroot_puserhome)) mkdir($this->data['new']['dir'].$jailkit_chroot_puserhome, 0750, true); $app->system->chown($this->data['new']['dir'].$jailkit_chroot_puserhome, $this->data['new']['puser']); $app->system->chgrp($this->data['new']['dir'].$jailkit_chroot_puserhome, $this->data['new']['pgroup']); - $app->log("Added jailkit parent user home in : ".$this->data['new']['dir'].$jailkit_chroot_puserhome, LOGLEVEL_DEBUG); + $app->log("Added jailkit parent user home in: ".$this->data['new']['dir'].$jailkit_chroot_puserhome, LOGLEVEL_DEBUG); } @@ -675,6 +681,72 @@ class shelluser_jailkit_plugin { $app->db->query("UPDATE `web_domain` SET `last_jailkit_update` = NOW(), `last_jailkit_hash` = NULL WHERE `document_root` = ?", $parent_domain['document_root']); } + + + function _setup_php_jailkit() { + global $app; + + $app->uses('system'); + + // Create .bashrc file + $app->load('tpl'); + + $tpl = new tpl(); + + // Predefine some template vars + $tpl->setVar('jailkit_chroot', 'y'); + $tpl->setVar('domain', $this->web['domain']); + $tpl->setVar('home_dir', $this->_get_home_dir("")); + $tpl->setVar('use_php_path', false); + $tpl->setVar('use_php_alias', false); + + if($app->system->get_os_type() == "debian" || $app->system->get_os_type() == "ubuntu") { + $tpl->newTemplate("bashrc_user_deb.master"); + } elseif($app->system->get_os_type() == "redhat") { + $tpl->newTemplate("bashrc_user_redhat.master"); + } else { + $tpl->newTemplate("bashrc_user_generic.master"); + } + + + $php_bin_dir = dirname($this->web['php_cli_binary']); + + if(($this->web['server_php_id'] > 0) && !empty($this->web['php_cli_binary'])) { + if($app->system->get_os_type() != "debian" || $app->system->get_os_type() != "ubuntu") { + if(preg_match('/^(\/usr\/(s)?bin|\/(s)?bin)/', $php_bin_dir)) { + $tpl->setVar('use_php_path', false); + $tpl->setVar('use_php_alias', true); + $tpl->setVar('php_alias', $this->web['php_cli_binary']); + } else { + $tpl->setVar('use_php_path', true); + $tpl->setVar('use_php_alias', false); + $tpl->setVar('php_bin_dir', $php_bin_dir); + } + } + + if(!file_exists($this->web['document_root'] . '/' . $this->web['php_cli_binary'])) { + $app->log("The PHP cli binary " . $this->web['php_cli_binary'] . " is not available in the jail of the web " . $this->web['domain'] . " / SSH/SFTP user: " . $this->username . ". Check your Jailkit setup!", LOGLEVEL_DEBUG); + $tpl->setVar('use_php_path', false); + $tpl->setVar('use_php_alias', false); + } + } + + $bashrc = $this->web['document_root'] . '/home/' . $this->data['new']['username'] . '/.bashrc'; + + if(@is_file($bashrc) || @is_link($bashrc)) unlink($bashrc); + file_put_contents($bashrc, $tpl->grab()); + $app->system->chown($bashrc, $this->data['new']['username']); + $app->system->chgrp($bashrc, $this->data['new']['pgroup']); + + $app->log("Added bashrc script: " . $bashrc, LOGLEVEL_DEBUG); + + unset($tpl); + + + + + } + } // end class ?>
{tmpl_var name="run_wday"} {tmpl_var name="command"} -
+