From a91fdb2f9c8705d68bff3c5ec3037d7ba5490512 Mon Sep 17 00:00:00 2001
From: daniel <daniel@ispconfig3>
Date: Thu, 05 Jun 2008 16:45:15 -0400
Subject: [PATCH] Log symlinks changed 

---
 install/sql/ispconfig3.sql                        |    5 +++--
 server/plugins-available/apache2_plugin.inc.php   |   26 ++++++++++++++++++--------
 interface/web/sites/shell_user_edit.php           |    3 ++-
 interface/web/sites/form/shell_user.tform.php     |    6 ++++++
 interface/web/sites/lib/lang/en_shell_user.lng    |    1 +
 interface/web/sites/templates/shell_user_edit.htm |    8 ++++++++
 6 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/install/sql/ispconfig3.sql b/install/sql/ispconfig3.sql
index 4ba1cf6..a716547 100644
--- a/install/sql/ispconfig3.sql
+++ b/install/sql/ispconfig3.sql
@@ -524,7 +524,6 @@
 
 -- --------------------------------------------------------
 
-
 CREATE TABLE `shell_user` (
   `shell_user_id` bigint(20) NOT NULL auto_increment,
   `sys_userid` int(11) NOT NULL default '0',
@@ -542,8 +541,10 @@
   `pgroup` varchar(255) default NULL,
   `shell` varchar(255) NOT NULL default '/bin/bash',
   `dir` varchar(255) default NULL,
+  `chroot` varchar(255) NOT NULL,
   PRIMARY KEY  (`shell_user_id`)
-) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;
+
 
 -- 
 -- Daten f�r Tabelle `shell_user`
diff --git a/interface/web/sites/form/shell_user.tform.php b/interface/web/sites/form/shell_user.tform.php
index 3b79613..d9766a5 100644
--- a/interface/web/sites/form/shell_user.tform.php
+++ b/interface/web/sites/form/shell_user.tform.php
@@ -105,6 +105,12 @@
 			'width'		=> '30',
 			'maxlength'	=> '255'
 		),
+		'chroot' => array (
+			'datatype'	=> 'VARCHAR',
+			'formtype'	=> 'SELECT',
+			'default'	=> '',
+			'value'		=> array('' => 'None', 'jailkit' => 'Jailkit', 'ssh-chroot' => 'SSH Chroot')
+		),
 		'quota_size' => array (
 			'datatype'	=> 'INTEGER',
 			'formtype'	=> 'TEXT',
diff --git a/interface/web/sites/lib/lang/en_shell_user.lng b/interface/web/sites/lib/lang/en_shell_user.lng
index 510ddd4..ef9ed88 100644
--- a/interface/web/sites/lib/lang/en_shell_user.lng
+++ b/interface/web/sites/lib/lang/en_shell_user.lng
@@ -9,6 +9,7 @@
 $wb["parent_domain_id_txt"] = 'Site';
 $wb["username_txt"] = 'Username';
 $wb["password_txt"] = 'Password';
+$wb["chroot_txt"] = 'Chroot Shell';
 $wb["quota_size_txt"] = 'Quota';
 $wb["active_txt"] = 'Active';
 $wb["username_error_empty"] = 'Username is empty.';
diff --git a/interface/web/sites/shell_user_edit.php b/interface/web/sites/shell_user_edit.php
index 633ef46..629977e 100644
--- a/interface/web/sites/shell_user_edit.php
+++ b/interface/web/sites/shell_user_edit.php
@@ -80,8 +80,9 @@
 		$dir = $web["document_root"];
 		$puser = $web["system_user"];
 		$pgroup = $web["system_group"];
+		$chroot = $web["chroot"];
 		
-		$sql = "UPDATE shell_user SET server_id = $server_id, dir = '$dir', puser = '$puser', pgroup = '$pgroup' WHERE shell_user_id = ".$this->id;
+		$sql = "UPDATE shell_user SET server_id = $server_id, dir = '$dir', puser = '$puser', pgroup = '$pgroup' chroot='$chroot' WHERE shell_user_id = ".$this->id;
 		$app->db->query($sql);
 		
 	}
diff --git a/interface/web/sites/templates/shell_user_edit.htm b/interface/web/sites/templates/shell_user_edit.htm
index 16d2d97..5960efc 100644
--- a/interface/web/sites/templates/shell_user_edit.htm
+++ b/interface/web/sites/templates/shell_user_edit.htm
@@ -24,6 +24,14 @@
     <td class="frmText11"><input name="password" type="password" class="text" value="{tmpl_var name='password'}" size="30" maxlength="255"></td>
   </tr>
   <tr>
+    <td class="frmText11">{tmpl_var name='chroot_txt'}:</td>
+    <td class="frmText11">
+		<select name="chroot" class="text">
+			{tmpl_var name='chroot'}
+		</select>
+	</td>
+  </tr>
+  <tr>
     <td class="frmText11">{tmpl_var name='quota_size_txt'}:</td>
     <td class="frmText11"><input name="quota_size" type="text" class="text" value="{tmpl_var name='quota_size'}" size="7" maxlength="7"></td>
   </tr>
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 445f30e..98fcfd0 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -218,18 +218,17 @@
 		
 		// Remove the symlink for the site, if site is renamed
 		if($this->action == 'update' && $data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"]) {
-			if(is_dir('/var/log/ispconfig/httpd/'.$data["old"]["domain"])) exec('rm -rf /var/log/ispconfig/httpd/'.$data["old"]["domain"]);
-			if(is_link($data["old"]["document_root"]."/log")) unlink($data["old"]["document_root"]."/log");
+			if(is_dir($data["old"]["document_root"]."/log")) exec('rm -rf '.$data["old"]["document_root"]."/log");
+			if(is_link('/var/log/ispconfig/httpd/'.$data["old"]["domain"])) unlink('/var/log/ispconfig/httpd/'.$data["old"]["domain"]);
 		}
 		
 		// Create the symlink for the logfiles
-		if(!is_dir('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) exec('mkdir -p /var/log/ispconfig/httpd/'.$data["new"]["domain"]);
-		if(!is_link($data["new"]["document_root"]."/log")) {
-			exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log");
-			$app->log("Creating Symlink: ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log",LOGLEVEL_DEBUG);
+		if(!is_dir($data["new"]["document_root"]."/log")) exec('mkdir -p '.$data["new"]["document_root"]."/log");
+		if(!is_link('/var/log/ispconfig/httpd/'.$data["new"]["domain"])) {
+			exec("ln -s ".$data["new"]["document_root"]."/log /var/log/ispconfig/httpd/".$data["new"]["domain"]);
+			$app->log("Creating Symlink: ln -s ".$data["new"]["document_root"]."/log /var/log/ispconfig/httpd/".$data["new"]["domain"],LOGLEVEL_DEBUG);
 		}
-		
-		
+	
 		// Get the client ID
 		$client = $app->db->queryOneRecord("SELECT client_id FROM sys_group WHERE sys_group.groupid = ".intval($data["new"]["sys_groupid"]));
 		$client_id = intval($client["client_id"]);
@@ -462,6 +461,17 @@
 		
 		$docroot = escapeshellcmd($data["old"]["document_root"]);
 		if($docroot != '' && !stristr($docroot,'..')) exec("rm -rf $docroot");
+		
+		//remove the php fastgi starter script if available
+		if ($data["old"]["php"] == "fast-cgi")
+		{
+			$fastcgi_starter_path = str_replace("[system_user]",$data["old"]["system_user"],$web_config["fastcgi_starter_path"]);
+			if (is_dir($fastcgi_starter_path))
+			{
+					exec("rm -rf $fastcgi_starter_path");
+			}
+		}
+		
 		$app->log("Removing website: $docroot",LOGLEVEL_DEBUG);
 		
 		// Delete the symlinks for the sites

--
Gitblit v1.9.1