Skip to content

Commit a91fdb2

Browse files
author
daniel
committed
Log symlinks changed
1 parent a9b823d commit a91fdb2

File tree

6 files changed

+38
-11
lines changed

6 files changed

+38
-11
lines changed

install/sql/ispconfig3.sql

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,6 @@ CREATE TABLE `server_ip` (
524524

525525
-- --------------------------------------------------------
526526

527-
528527
CREATE TABLE `shell_user` (
529528
`shell_user_id` bigint(20) NOT NULL auto_increment,
530529
`sys_userid` int(11) NOT NULL default '0',
@@ -542,8 +541,10 @@ CREATE TABLE `shell_user` (
542541
`pgroup` varchar(255) default NULL,
543542
`shell` varchar(255) NOT NULL default '/bin/bash',
544543
`dir` varchar(255) default NULL,
544+
`chroot` varchar(255) NOT NULL,
545545
PRIMARY KEY (`shell_user_id`)
546-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
546+
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
547+
547548

548549
--
549550
-- Daten für Tabelle `shell_user`

interface/web/sites/form/shell_user.tform.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@
105105
'width' => '30',
106106
'maxlength' => '255'
107107
),
108+
'chroot' => array (
109+
'datatype' => 'VARCHAR',
110+
'formtype' => 'SELECT',
111+
'default' => '',
112+
'value' => array('' => 'None', 'jailkit' => 'Jailkit', 'ssh-chroot' => 'SSH Chroot')
113+
),
108114
'quota_size' => array (
109115
'datatype' => 'INTEGER',
110116
'formtype' => 'TEXT',

interface/web/sites/lib/lang/en_shell_user.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ $wb["server_id_txt"] = 'Server';
99
$wb["parent_domain_id_txt"] = 'Site';
1010
$wb["username_txt"] = 'Username';
1111
$wb["password_txt"] = 'Password';
12+
$wb["chroot_txt"] = 'Chroot Shell';
1213
$wb["quota_size_txt"] = 'Quota';
1314
$wb["active_txt"] = 'Active';
1415
$wb["username_error_empty"] = 'Username is empty.';

interface/web/sites/shell_user_edit.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,9 @@ function onAfterInsert() {
8080
$dir = $web["document_root"];
8181
$puser = $web["system_user"];
8282
$pgroup = $web["system_group"];
83+
$chroot = $web["chroot"];
8384

84-
$sql = "UPDATE shell_user SET server_id = $server_id, dir = '$dir', puser = '$puser', pgroup = '$pgroup' WHERE shell_user_id = ".$this->id;
85+
$sql = "UPDATE shell_user SET server_id = $server_id, dir = '$dir', puser = '$puser', pgroup = '$pgroup' chroot='$chroot' WHERE shell_user_id = ".$this->id;
8586
$app->db->query($sql);
8687

8788
}

interface/web/sites/templates/shell_user_edit.htm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
<td class="frmText11">{tmpl_var name='password_txt'}:</td>
2424
<td class="frmText11"><input name="password" type="password" class="text" value="{tmpl_var name='password'}" size="30" maxlength="255"></td>
2525
</tr>
26+
<tr>
27+
<td class="frmText11">{tmpl_var name='chroot_txt'}:</td>
28+
<td class="frmText11">
29+
<select name="chroot" class="text">
30+
{tmpl_var name='chroot'}
31+
</select>
32+
</td>
33+
</tr>
2634
<tr>
2735
<td class="frmText11">{tmpl_var name='quota_size_txt'}:</td>
2836
<td class="frmText11"><input name="quota_size" type="text" class="text" value="{tmpl_var name='quota_size'}" size="7" maxlength="7"></td>

server/plugins-available/apache2_plugin.inc.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,17 @@ function update($event_name,$data) {
218218

219219
// Remove the symlink for the site, if site is renamed
220220
if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) {
221-
if(is_dir('/var/log/ispconfig/httpd/'.$data["old"]["domain"])) exec('rm -rf /var/log/ispconfig/httpd/'.$data["old"]["domain"]);
222-
if(is_link($data["old"]["document_root"]."/log")) unlink($data["old"]["document_root"]."/log");
221+
if(is_dir($data["old"]["document_root"]."/log")) exec('rm -rf '.$data["old"]["document_root"]."/log");
222+
if(is_link('/var/log/ispconfig/httpd/'.$data["old"]["domain"])) unlink('/var/log/ispconfig/httpd/'.$data["old"]["domain"]);
223223
}
224224

225225
// Create the symlink for the logfiles
226-
if(!is_dir('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data["new"]["domain"]);
227-
if(!is_link($data["new"]["document_root"]."/log")) {
228-
exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log");
229-
$app->log("Creating Symlink: ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log",LOGLEVEL_DEBUG);
226+
if(!is_dir($data["new"]["document_root"]."/log")) exec('mkdir -p '.$data["new"]["document_root"]."/log");
227+
if(!is_link('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) {
228+
exec("ln -s ".$data["new"]["document_root"]."/log /var/log/ispconfig/httpd/".$data["new"]["domain"]);
229+
$app->log("Creating Symlink: ln -s ".$data["new"]["document_root"]."/log /var/log/ispconfig/httpd/".$data["new"]["domain"],LOGLEVEL_DEBUG);
230230
}
231-
232-
231+
233232
// Get the client ID
234233
$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["new"]["sys_groupid"]));
235234
$client_id = intval($client["client_id"]);
@@ -462,6 +461,17 @@ function delete($event_name,$data) {
462461

463462
$docroot = escapeshellcmd($data["old"]["document_root"]);
464463
if($docroot != '' && !stristr($docroot,'..')) exec("rm -rf $docroot");
464+
465+
//remove the php fastgi starter script if available
466+
if ($data["old"]["php"] == "fast-cgi")
467+
{
468+
$fastcgi_starter_path = str_replace("[system_user]",$data["old"]["system_user"],$web_config["fastcgi_starter_path"]);
469+
if (is_dir($fastcgi_starter_path))
470+
{
471+
exec("rm -rf $fastcgi_starter_path");
472+
}
473+
}
474+
465475
$app->log("Removing website: $docroot",LOGLEVEL_DEBUG);
466476

467477
// Delete the symlinks for the sites

0 commit comments

Comments
 (0)