Commit af8f1ba1 authored by tbrehm's avatar tbrehm
Browse files

Added support for shell users in the interface and fixed several strict syntax issues.

parent df52d4b3
......@@ -34,6 +34,14 @@ a2enmod rewrite
apt-get install pure-ftpd-common pure-ftpd-mysql quota quotatool
Edit the file /etc/default/pure-ftpd-common
vi /etc/default/pure-ftpd-common
and change the start mode from inetd to standalone. Then execute:
/etc/init.d/openbsd-inetd restart
5) Install mydns
......
......@@ -522,7 +522,7 @@ class installer_base {
exec("chmod 600 $config_dir/$configfile");
exec("chown root:root $config_dir/$configfile");
// **enable chrooting
exec('mkdir -p '.$config_dir.'/conf/ChrootEveryone');
//exec('mkdir -p '.$config_dir.'/conf/ChrootEveryone');
exec('echo "yes" > '.$config_dir.'/conf/ChrootEveryone');
}
......
<?php
$wb["server_id_txt"] = 'Server';
$wb["ip_address_txt"] = 'IP Address';
$wb["virtualhost_txt"] = 'Virtualhost';
$wb["virtualhost_txt"] = 'HTTP NameVirtualHost';
$wb["ip_err"] = 'IP address invalid';
$wb["btn_save_txt"] = 'Save';
$wb["btn_cancel_txt"] = 'Cancel';
......
......@@ -98,7 +98,7 @@ class page_action extends tform_actions {
}
// password changed
if($this->dataRecord["password"] != '') {
if(isset($this->dataRecord["password"]) && $this->dataRecord["password"] != '') {
$password = addslashes($this->dataRecord["password"]);
$client_id = $this->id;
$sql = "UPDATE sys_user SET passwort = md5('$password') WHERE client_id = $client_id";
......
......@@ -526,6 +526,20 @@ $form["tabs"]['limits'] = array (
'rows' => '',
'cols' => ''
),
'limit_shell_user' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'ISINT',
'errmsg'=> 'limit_shell_user_error_notint'),
),
'default' => '-1',
'value' => '',
'separator' => '',
'width' => '10',
'maxlength' => '10',
'rows' => '',
'cols' => ''
),
'default_dnsserver' => array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
......
......@@ -53,6 +53,6 @@ $wb["limit_ftp_user_txt"] = 'Max. number of FTP users';
$wb["default_dnsserver_txt"] = 'Default DNS Server';
$wb["limit_dns_zone_txt"] = 'Max. number of DNS zones';
$wb["limit_dns_record_txt"] = 'Max. number DNS records';
$wb["limit_shell_user_txt"] = 'Max. number of Shell users';
?>
\ No newline at end of file
......@@ -90,6 +90,10 @@
<td class="frmText11" width="280">{tmpl_var name='limit_ftp_user_txt'}:</td>
<td class="frmText11" width="220"><input name="limit_ftp_user" type="text" class="text" value="{tmpl_var name='limit_ftp_user'}" size="10" maxlength="10"></td>
</tr>
<tr>
<td class="frmText11" width="280">{tmpl_var name='limit_shell_user_txt'}:</td>
<td class="frmText11" width="220"><input name="limit_shell_user" type="text" class="text" value="{tmpl_var name='limit_shell_user'}" size="10" maxlength="10"></td>
</tr>
<tr>
<td><h2>DNS</h2></td>
</tr>
......
<?php
/*
Form Definition
Tabledefinition
Datatypes:
- INTEGER (Forces the input to Int)
- DOUBLE
- CURRENCY (Formats the values to currency notation)
- VARCHAR (no format check, maxlength: 255)
- TEXT (no format check)
- DATE (Dateformat, automatic conversion to timestamps)
Formtype:
- TEXT (Textfield)
- TEXTAREA (Textarea)
- PASSWORD (Password textfield, input is not shown when edited)
- SELECT (Select option field)
- RADIO
- CHECKBOX
- CHECKBOXARRAY
- FILE
VALUE:
- Wert oder Array
Hint:
The ID field of the database table is not part of the datafield definition.
The ID field must be always auto incement (int or bigint).
*/
$form["title"] = "Shell User";
$form["description"] = "";
$form["name"] = "shell_user";
$form["action"] = "shell_user_edit.php";
$form["db_table"] = "shell_user";
$form["db_table_idx"] = "shell_user_id";
$form["db_history"] = "yes";
$form["tab_default"] = "shell";
$form["list_default"] = "shell_user_list.php";
$form["auth"] = 'yes'; // yes / no
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
$form["tabs"]['shell'] = array (
'title' => "Shell User",
'width' => 100,
'template' => "templates/shell_user_edit.htm",
'fields' => array (
##################################
# Begin Datatable fields
##################################
'server_id' => array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
'value' => ''
),
'parent_domain_id' => array (
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'default' => '',
'datasource' => array ( 'type' => 'SQL',
'querystring' => "SELECT domain_id,domain FROM web_domain WHERE type = 'vhost' AND {AUTHSQL} ORDER BY domain",
'keyfield'=> 'domain_id',
'valuefield'=> 'domain'
),
'value' => ''
),
'username' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'username_error_empty'),
1 => array ( 'type' => 'UNIQUE',
'errmsg'=> 'username_error_unique'),
2 => array ( 'type' => 'REGEX',
'regex' => '/^[\w\.\-]{1,64}$/',
'errmsg'=> 'username_error_regex'),
),
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'password' => array (
'datatype' => 'VARCHAR',
'formtype' => 'PASSWORD',
'encryption' => 'CRYPT',
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'quota_size' => array (
'datatype' => 'INTEGER',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'quota_size_error_empty'),
),
'default' => '-1',
'value' => '',
'width' => '7',
'maxlength' => '7'
),
'active' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'y',
'value' => array(0 => 'n',1 => 'y')
),
##################################
# ENDE Datatable fields
##################################
)
);
if($_SESSION["s"]["user"]["typ"] == 'admin') {
$form["tabs"]['advanced'] = array (
'title' => "Options",
'width' => 100,
'template' => "templates/shell_user_advanced.htm",
'fields' => array (
##################################
# Begin Datatable fields
##################################
'uid' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'uid_error_empty'),
),
'default' => '0',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'gid' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'uid_error_empty'),
),
'default' => '0',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'shell' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'default' => '/bin/bash',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
'dir' => array (
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
'errmsg'=> 'directory_error_empty'),
),
'default' => '',
'value' => '',
'width' => '30',
'maxlength' => '255'
),
##################################
# ENDE Datatable fields
##################################
)
);
}
?>
\ No newline at end of file
......@@ -63,7 +63,7 @@ class page_action extends tform_actions {
$client_group_id = $_SESSION["s"]["user"]["default_group"];
$client = $app->db->queryOneRecord("SELECT limit_ftp_user FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
// Check if the user may add another maildomain.
// Check if the user may add another ftp user.
if($client["limit_ftp_user"] >= 0) {
$tmp = $app->db->queryOneRecord("SELECT count(ftp_user_id) as number FROM ftp_user WHERE sys_groupid = $client_group_id");
if($tmp["number"] >= $client["limit_ftp_user"]) {
......
<?php
$wb["uid_txt"] = 'Web Username';
$wb["gid_txt"] = 'Group';
$wb["shell_txt"] = 'Shell';
$wb["dir_txt"] = 'Dir';
$wb["btn_save_txt"] = 'Save';
$wb["btn_cancel_txt"] = 'Cancel';
$wb["server_id_txt"] = 'Server';
$wb["parent_domain_id_txt"] = 'Site';
$wb["username_txt"] = 'Username';
$wb["password_txt"] = 'Password';
$wb["quota_size_txt"] = 'Quota';
$wb["active_txt"] = 'Active';
?>
\ No newline at end of file
<?php
$wb["list_head_txt"] = 'Shell User';
$wb["active_txt"] = 'Active';
$wb["server_id_txt"] = 'Server';
$wb["parent_domain_id_txt"] = 'Site';
$wb["username_txt"] = 'Username';
$wb["page_txt"] = 'Page';
$wb["page_of_txt"] = 'of';
$wb["page_next_txt"] = 'Next';
$wb["page_back_txt"] = 'Back';
$wb["delete_txt"] = 'Delete';
$wb["filter_txt"] = 'Filter';
$wb["add_new_record_txt"] = 'Add new Shell-User';
?>
\ No newline at end of file
......@@ -28,7 +28,7 @@ $module["nav"][] = array( 'title' => 'Websites',
'open' => 1,
'items' => $items);
// aufrumen
// clean up
unset($items);
/*
......@@ -44,7 +44,23 @@ $module["nav"][] = array( 'title' => 'FTP',
'open' => 1,
'items' => $items);
// aufrumen
// clean up
unset($items);
/*
FTP User menu
*/
$items[] = array( 'title' => "Shell-User",
'target' => 'content',
'link' => 'sites/shell_user_list.php');
$module["nav"][] = array( 'title' => 'Shell',
'open' => 1,
'items' => $items);
// clean up
unset($items);
......
<?php
/*
Datatypes:
- INTEGER
- DOUBLE
- CURRENCY
- VARCHAR
- TEXT
- DATE
*/
// Name of the list
$liste["name"] = "shell_user";
// Database table
$liste["table"] = "shell_user";
// Index index field of the database table
$liste["table_idx"] = "shell_user_id";
// Search Field Prefix
$liste["search_prefix"] = "search_";
// Records per page
$liste["records_per_page"] = 15;
// Script File of the list
$liste["file"] = "shell_user_list.php";
// Script file of the edit form
$liste["edit_file"] = "shell_user_edit.php";
// Script File of the delete script
$liste["delete_file"] = "shell_user_del.php";
// Paging Template
$liste["paging_tpl"] = "templates/paging.tpl.htm";
// Enable auth
$liste["auth"] = "yes";
/*****************************************************
* Suchfelder
*****************************************************/
$liste["item"][] = array( 'field' => "active",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "=",
'prefix' => "",
'suffix' => "",
'width' => "",
'value' => array('y' => "Yes",'n' => "No"));
$liste["item"][] = array( 'field' => "server_id",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'datasource' => array ( 'type' => 'SQL',
'querystring' => 'SELECT server_id,server_name FROM server WHERE {AUTHSQL} ORDER BY server_name',
'keyfield'=> 'server_id',
'valuefield'=> 'server_name'
),
'width' => "",
'value' => "");
$liste["item"][] = array( 'field' => "parent_domain_id",
'datatype' => "VARCHAR",
'formtype' => "SELECT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'datasource' => array ( 'type' => 'SQL',
'querystring' => "SELECT domain_id,domain FROM web_domain WHERE type = 'vhost' AND {AUTHSQL} ORDER BY domain",
'keyfield'=> 'domain_id',
'valuefield'=> 'domain'
),
'width' => "",
'value' => "");
$liste["item"][] = array( 'field' => "username",
'datatype' => "VARCHAR",
'formtype' => "TEXT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'width' => "",
'value' => "");
?>
\ No newline at end of file
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/shell_user.list.php";
$tform_def_file = "form/shell_user.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Checke Berechtigungen für Modul
if(!stristr($_SESSION["s"]["user"]["modules"],'sites')) {
header("Location: ../index.php");
exit;
}
$app->uses("tform_actions");
$app->tform_actions->onDelete();
?>
\ No newline at end of file
<?php
/*
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/******************************************
* Begin Form configuration
******************************************/
$tform_def_file = "form/shell_user.tform.php";
/******************************************
* End Form configuration
******************************************/
require_once('../../lib/config.inc.php');
require_once('../../lib/app.inc.php');
// Checking module permissions
if(!stristr($_SESSION["s"]["user"]["modules"],'sites')) {
header("Location: ../index.php");
exit;
}
// Loading classes
$app->uses('tpl,tform,tform_actions');
$app->load('tform_actions');
class page_action extends tform_actions {
function onShowNew() {
global $app, $conf;
// we will check only users, not admins
if($_SESSION["s"]["user"]["typ"] == 'user') {
// Get the limits of the client
$client_group_id = $_SESSION["s"]["user"]["default_group"];
$client = $app->db->queryOneRecord("SELECT limit_ftp_user FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = $client_group_id");
// Check if the user may add another shell user.
if($client["limit_shell_user"] >= 0) {
$tmp = $app->db->queryOneRecord("SELECT count(shell_user_id) as number FROM shell_user WHERE sys_groupid = $client_group_id");
if($tmp["number"] >= $client["limit_shell_user"]) {
$app->error($app->tform->wordbook["limit_shell_user_txt"]);
}
}
}
parent::onShowNew();
}
function onAfterInsert() {
global $app, $conf;
$web = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".intval($this->dataRecord["parent_domain_id"]));
$server_id = $web["server_id"];
$dir = $web["document_root"];
$uid = $web["system_user"];
$gid = $web["system_group"];
$sql = "UPDATE shell_user SET server_id = $server_id, dir = '$dir', uid = '$uid', gid = '$gid' WHERE shell_user_id = ".$this->id;
$app->db->query($sql);
}
function onAfterUpdate() {
global $app, $conf;