
13th May 2009, 08:17
|
|
Senior Member
|
|
Join Date: Apr 2009
Location: Switzerland
Posts: 208
Thanks: 6
Thanked 2 Times in 2 Posts
|
|
automatic webmail link
Hi till
Hi all
I want when I create a new site, that ISPConfig automatic set a Symlink to
/var/www/webmail in the webpart of the new customer.
So that I do not must everytime set the symlink.
thanks for ideas.
admins
|

13th May 2009, 09:11
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,897
Thanks: 693
Thanked 4,190 Times in 3,208 Posts
|
|
E.g. you can write a plugin for that.
|

13th May 2009, 09:16
|
|
Senior Member
|
|
Join Date: Apr 2009
Location: Switzerland
Posts: 208
Thanks: 6
Thanked 2 Times in 2 Posts
|
|
How could I do this?
Could you do this for me? Is this a big work?
Thanks
admins
|

30th May 2009, 18:25
|
|
Senior Member
|
|
Join Date: Sep 2006
Posts: 100
Thanks: 3
Thanked 1 Time in 1 Post
|
|
I would like this feature also. thanks.
|

3rd June 2009, 21:35
|
|
HowtoForge Supporter
|
|
Join Date: Apr 2007
Location: Helsinki
Posts: 374
Thanks: 24
Thanked 36 Times in 24 Posts
|
|
Friends, please.
If You want Falco or Till to work for You, You should at least pay them for their work.
Just my humble opinion. I find it difficult to get people to work free for me (or if they do, the deadlines are just horrible.)
|

4th June 2009, 09:13
|
|
Senior Member
|
|
Join Date: Jul 2007
Location: Koblenz, Germany
Posts: 290
Thanks: 12
Thanked 100 Times in 58 Posts
|
|
I got a plugin ready for this.
Just copy the content to a file
Code:
/usr/local/ispconfig/server/plugins-available/webmail_symlink_plugin.inc.php
and create a symlink in plugins-enabled
Code:
ln -s /usr/local/ispconfig/server/plugins-available/webmail_symlink_plugin.inc.php /usr/local/ispconfig/server/plugins-enabled/webmail_symlink_plugin.inc.php
Please note: the symlink is automatically removed / not created if suphp is enabled for this website as suphp doesn't allow symlinks outside the docroot.
PHP Code:
<?php
/*
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Modification (c) 2009, Marius Cramer, pixcept KG
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.
*/
class webmail_symlink_plugin {
var $plugin_name = 'webmail_symlink_plugin';
var $class_name = 'webmail_symlink_plugin';
var $action;
//* This function is called during ispconfig installation to determine
// if a symlink shall be created for this plugin.
function onInstall() {
global $conf;
if($conf['services']['web'] == true) {
return true;
} else {
return false;
}
}
/*
This function is called when the plugin is loaded
*/
function onLoad() {
global $app;
/*
Register for the events
*/
$app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert');
$app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update');
}
function insert($event_name,$data) {
global $app, $conf;
$this->action = 'insert';
// just run the update function
$this->update($event_name,$data);
}
function update($event_name,$data) {
global $app, $conf;
if($this->action != 'insert') $this->action = 'update';
if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
$old_parent_domain_id = intval($data["old"]["parent_domain_id"]);
$new_parent_domain_id = intval($data["new"]["parent_domain_id"]);
// If the parent_domain_id has been chenged, we will have to update the old site as well.
if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) {
$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'");
$data["new"] = $tmp;
$data["old"] = $tmp;
$this->action = 'update';
$this->update($event_name,$data);
}
// This is not a vhost, so we need to update the parent record instead.
$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'");
$data["new"] = $tmp;
$data["old"] = $tmp;
$this->action = 'update';
}
if($data["new"]["document_root"] == '') {
$app->log("document_root not set",LOGLEVEL_WARN);
return 0;
}
if(!is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web");
if($data["new"]["php"] == "suphp") {
if(is_link($data["new"]["document_root"]."/web/webmail")) exec("rm -f ".$data["new"]["document_root"]."/web/webmail");
} else {
if(!is_link($data["new"]["document_root"]."/web/webmail")) exec("ln -s /var/www/webmail ".$data["new"]["document_root"]."/web/webmail");
else exec("ln -sf /var/www/webmail ".$data["new"]["document_root"]."/web/webmail");
}
}
} // end class
?>
|
|
The Following 4 Users Say Thank You to Croydon For This Useful Post:
|
|

4th June 2009, 09:43
|
|
Super Moderator
|
|
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 31,897
Thanks: 693
Thanked 4,190 Times in 3,208 Posts
|
|
Thank you very much for the plugin!
Also the combination php as cgi + suexec or php-fcgi + suexec might have the same problem as suphp if the scripts for the webmail application are not within /var/www or do not belong to the admin user of the site, so it might be a good idea to exclude these combinations also from symlinking?
|

4th June 2009, 09:47
|
|
Senior Member
|
|
Join Date: Jul 2007
Location: Koblenz, Germany
Posts: 290
Thanks: 12
Thanked 100 Times in 58 Posts
|
|
Quote:
Originally Posted by till
Thank you very much for the plugin!
Also the combination php as cgi + suexec or php-fcgi + suexec might have the same problem as suphp if the scripts for the webmail application are not within /var/www or do not belong to the admin user of the site, so it might be a good idea to exclude these combinations also from symlinking?
|
I tested the plugin with a site with cgi, fast-cgi, modphp enabled and had no problems yet. But maybe you are right that there are some functions that would not work correctly. I am really not sure about that.
edit: sorry, you are right! i didn't set the suexec option so you are right. with that enabled there might be problems. I'll change the plugin.
Last edited by Croydon; 4th June 2009 at 10:05.
Reason: missed something
|

4th June 2009, 10:10
|
|
Senior Member
|
|
Join Date: Jul 2007
Location: Koblenz, Germany
Posts: 290
Thanks: 12
Thanked 100 Times in 58 Posts
|
|
Here is the updated plugin.
Symlink is now disabled when - suPHP is used
- CGI is used with suexec
- Fast-CGI is used with suexec
PHP Code:
<?php
/*
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Modification (c) 2009, Marius Cramer, pixcept KG
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.
*/
class webmail_symlink_plugin {
var $plugin_name = 'webmail_symlink_plugin';
var $class_name = 'webmail_symlink_plugin';
var $action;
//* This function is called during ispconfig installation to determine
// if a symlink shall be created for this plugin.
function onInstall() {
global $conf;
if($conf['services']['web'] == true) {
return true;
} else {
return false;
}
}
/*
This function is called when the plugin is loaded
*/
function onLoad() {
global $app;
/*
Register for the events
*/
$app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert');
$app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update');
}
function insert($event_name,$data) {
global $app, $conf;
$this->action = 'insert';
// just run the update function
$this->update($event_name,$data);
}
function update($event_name,$data) {
global $app, $conf;
if($this->action != 'insert') $this->action = 'update';
if($data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
$old_parent_domain_id = intval($data["old"]["parent_domain_id"]);
$new_parent_domain_id = intval($data["new"]["parent_domain_id"]);
// If the parent_domain_id has been chenged, we will have to update the old site as well.
if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) {
$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'");
$data["new"] = $tmp;
$data["old"] = $tmp;
$this->action = 'update';
$this->update($event_name,$data);
}
// This is not a vhost, so we need to update the parent record instead.
$tmp = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'");
$data["new"] = $tmp;
$data["old"] = $tmp;
$this->action = 'update';
}
if($data["new"]["document_root"] == '') {
$app->log("document_root not set",LOGLEVEL_WARN);
return 0;
}
$symlink = true;
if($data["new"]["php"] == "suphp") $symlink = false;
elseif($data["new"]["php"] == "cgi" && $data["new"]["suexec"] == "y") $symlink = false;
elseif($data["new"]["php"] == "fast-cgi" && $data["new"]["suexec"] == "y") $symlink = false;
if(!is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web");
if($symlink == false) {
if(is_link($data["new"]["document_root"]."/web/webmail")) exec("rm -f ".$data["new"]["document_root"]."/web/webmail");
} else {
if(!is_link($data["new"]["document_root"]."/web/webmail")) exec("ln -s /var/www/webmail ".$data["new"]["document_root"]."/web/webmail");
else exec("ln -sf /var/www/webmail ".$data["new"]["document_root"]."/web/webmail");
}
}
} // end class
?>
|
|
The Following 5 Users Say Thank You to Croydon For This Useful Post:
|
|

14th June 2009, 20:41
|
|
Junior Member
|
|
Join Date: Nov 2008
Location: Minnesota
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Hi, I just tried this and when I try to access any of the websites I create and go to the webmail directory, I get a 403 forbidden...did I do something wrong?
for example, I have site1.something.com, and site2.something.com...when I go to site1.something.com/webmail I get a 403 forbidden (in site2 as well). The symlinks are in the web directories of both the sites, but I still get the 403. Also, when I login via FTP it says that webmail is a broken link, but I suspect this to be normal, as my ftp login cannot see into other directories on the system.
Any words of wisdom?
Thanks in advance
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT +2. The time now is 14:33.
|
Recent comments
8 hours 45 min ago
15 hours 26 min ago
19 hours 17 min ago
20 hours 55 min ago
1 day 5 hours ago
1 day 14 hours ago
1 day 15 hours ago
1 day 19 hours ago
1 day 23 hours ago
1 day 23 hours ago