Commit 552178ef authored by marknl's avatar marknl

FS#1491 - Option to use relative symlinks for websites

parent a5fe2742
......@@ -354,6 +354,12 @@ $form["tabs"]['web'] = array(
'width' => '40',
'maxlength' => '255'
),
'website_symlinks_rel' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'value' => array(0 => 'n',1 => 'y')
),
'vhost_conf_dir' => array(
'datatype' => 'VARCHAR',
'formtype' => 'TEXT',
......
......@@ -5,6 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website basedir';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Jailkit chroot app sections';
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
$wb['getmail_config_dir_txt'] = 'Getmail config dir';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Aplicações Jailkit chroot (Sessões)
$wb['jailkit_chroot_app_programs_txt'] = 'Aplicações Jailkit em ambiente chroot';
$wb['website_path_txt'] = 'Caminho do Website';
$wb['website_symlinks_txt'] = 'Website symlinks: link simbólico';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website basedir: Diretório base ';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost diretório de configuração ativo';
......
......@@ -5,6 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrootované aplikace';
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrootované aplikace';
$wb['website_path_txt'] = 'Website cesta';
$wb['website_symlinks_txt'] = 'Website symlinky';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website config adresář';
$wb['vhost_conf_dir_txt'] = 'Vhost config adresář';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled adresář';
......
......@@ -5,6 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted Anwendungen';
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted Anwendungen';
$wb['website_path_txt'] = 'Website Pfad';
$wb['website_symlinks_txt'] = 'Website Symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
$wb['getmail_config_dir_txt'] = 'Getmail config dir';
......
......@@ -5,6 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted applications';
$wb['website_path_txt'] = 'Διαδρομή Website';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Βασικός φάκελος Website';
$wb['vhost_conf_dir_txt'] = 'Φάκελος ρυθμίσεων Vhost';
$wb['vhost_conf_enabled_dir_txt'] = 'Φάκελος ρυθμίσεων (ενεργών) Vhost';
......
......@@ -13,6 +13,7 @@ $wb["jailkit_chroot_app_programs_txt"] = 'Jailkit chrooted applications';
$wb["jailkit_chroot_cron_programs_txt"] = 'Jailkit cron chrooted applications';
$wb["website_path_txt"] = 'Website path';
$wb["website_symlinks_txt"] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb["website_basedir_txt"] = 'Website basedir';
$wb["vhost_conf_dir_txt"] = 'Vhost config dir';
$wb["vhost_conf_enabled_dir_txt"] = 'Vhost config enabled dir';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Secciones de aplicación Jailkit chroo
$wb['jailkit_chroot_app_programs_txt'] = 'Aplicaciones Jailkit chrooted';
$wb['website_path_txt'] = 'Ruta del sitio web';
$wb['website_symlinks_txt'] = 'Enlaces simbólicos del sitio web';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Directorio de configuración de vhost';
$wb['vhost_conf_enabled_dir_txt'] = 'Directorio de configuración de vhost activados';
$wb['getmail_config_dir_txt'] = 'Directorio de configuración de Getmail';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Jailkit chroot-ohjelmaosiot';
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted-ohjelmat';
$wb['website_path_txt'] = 'Verkkotunnuksen kotihakemisto';
$wb['website_symlinks_txt'] = 'Verkkotunnuksen symmetriset linkit';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Virtuaalipalvelimen asetuskansio';
$wb['vhost_conf_enabled_dir_txt'] = 'Virtuaalipalvelimen käyttöönottokansio';
$wb['getmail_config_dir_txt'] = 'Getmail-asetuskansio';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Sections des applications chrootées J
$wb['jailkit_chroot_app_programs_txt'] = 'Applications chrootées Jailkit';
$wb['website_path_txt'] = 'Chemin du site web';
$wb['website_symlinks_txt'] = 'Liens symboliques du site web';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Répertoire de configuration des VHosts';
$wb['vhost_conf_enabled_dir_txt'] = 'Répertoire de configuration des VHosts actifs';
$wb['getmail_config_dir_txt'] = 'Répertoire de configuration de Getmail';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Jailkit chroot app sections';
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
$wb['getmail_config_dir_txt'] = 'Getmail config dir';
......
......@@ -5,6 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = 'Jailkit aplikasi yang ter-chroot';
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit aplikasi cron yang ter-chroot';
$wb['website_path_txt'] = 'Path situs web';
$wb['website_symlinks_txt'] = 'Symlink Situs web';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Basedir Situs web';
$wb['vhost_conf_dir_txt'] = 'Direktori konfigurasi vhost';
$wb['vhost_conf_enabled_dir_txt'] = 'Direktori konfigurasi vhost yang aktif';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Jailkit chroot app sections';
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
$wb['getmail_config_dir_txt'] = 'Getmail config dir';
......
......@@ -5,6 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = '利用可能アプリケーション';
$wb['jailkit_chroot_cron_programs_txt'] = 'cron での利用可能アプリケーション';
$wb['website_path_txt'] = 'ウェブサイトのパス';
$wb['website_symlinks_txt'] = 'ウェブサイトのシンボリックリンク';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'ウェブサイトのベースディレクトリ';
$wb['vhost_conf_dir_txt'] = 'バーチャルホスト設定ディレクトリ';
$wb['vhost_conf_enabled_dir_txt'] = 'バーチャルホスト設定ディレクトリ(有効)';
......
......@@ -5,6 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applicaties';
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted applicaties';
$wb['website_path_txt'] = 'Website pad';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Maak relative symlinks';
$wb['website_basedir_txt'] = 'Website basedir';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
......
......@@ -5,6 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = 'Ścieżki aplikacji roota Jailkit';
$wb['jailkit_chroot_cron_programs_txt'] = 'Aplikacje cron roota Jailkit';
$wb['website_path_txt'] = 'Adres strony WWW';
$wb['website_symlinks_txt'] = 'Symulowany link strony WWW';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Ścieżka bazowa strony WWW';
$wb['vhost_conf_dir_txt'] = 'Ścieżka do konfiguracyji wirtualnego serwera';
$wb['vhost_conf_enabled_dir_txt'] = 'Ścieżka do aktywnej konfiguracyji Vhost';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Aplicações Jailkit chroot (Sessões)
$wb['jailkit_chroot_app_programs_txt'] = 'Aplicações Jailkit em ambiente chroot';
$wb['website_path_txt'] = 'Pasta do Website';
$wb['website_symlinks_txt'] = 'Website symlinks: link simbólico';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website basedir: pasta base ';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost pasta de configuração activo';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Jailkit chroot app sections';
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website basedir';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Раздел программы Jailki
$wb['jailkit_chroot_app_programs_txt'] = 'Программы Jailkit chrooted';
$wb['website_path_txt'] = 'Путь web-сайта';
$wb['website_symlinks_txt'] = 'Симлинки Web-сайта';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Папка конфига Vhost';
$wb['vhost_conf_enabled_dir_txt'] = 'Папка конфига включенного Vhost';
$wb['getmail_config_dir_txt'] = 'Папка конфига Getmail';
......
......@@ -4,6 +4,7 @@ $wb['jailkit_chroot_app_sections_txt'] = 'Jailkit chroot app sections';
$wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['website_path_txt'] = 'Website path';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
$wb['getmail_config_dir_txt'] = 'Getmail config dir';
......
......@@ -5,6 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted aplikácia';
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted aplikácia';
$wb['website_path_txt'] = 'Website cesta';
$wb['website_symlinks_txt'] = 'Website symlinky';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website základny adresár';
$wb['vhost_conf_dir_txt'] = 'Vhost konfig adresár';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost konfig odblokovaný adresár';
......
......@@ -5,6 +5,7 @@ $wb['jailkit_chroot_app_programs_txt'] = 'Jailkit chrooted applications';
$wb['jailkit_chroot_cron_programs_txt'] = 'Jailkit cron chrooted applications';
$wb['website_path_txt'] = 'Website yolu';
$wb['website_symlinks_txt'] = 'Website symlinks';
$wb['website_symlinks_rel_txt'] = 'Make relative symlinks';
$wb['website_basedir_txt'] = 'Website klasörü';
$wb['vhost_conf_dir_txt'] = 'Vhost config dir';
$wb['vhost_conf_enabled_dir_txt'] = 'Vhost config enabled dir';
......
......@@ -17,6 +17,12 @@
<label for="website_symlinks">{tmpl_var name='website_symlinks_txt'}</label>
<input name="website_symlinks" id="website_symlinks" value="{tmpl_var name='website_symlinks'}" size="40" maxlength="255" type="text" class="textInput" />
</div>
<div class="ctrlHolder">
<label for="website_symlinks_rel">{tmpl_var name='website_symlinks_rel_txt'}</label>
<div class="multiField">
{tmpl_var name='website_symlinks_rel'}
</div>
</div>
<div class="ctrlHolder">
<label for="vhost_conf_dir">{tmpl_var name='vhost_conf_dir_txt'}</label>
<input name="vhost_conf_dir" id="vhost_conf_dir" value="{tmpl_var name='vhost_conf_dir'}" size="40" maxlength="255" type="text" class="textInput" />
......
......@@ -357,7 +357,13 @@ class apache2_plugin {
// 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');
// exec("ln -s /var/log/ispconfig/httpd/".$data["new"]["domain"]." ".$data["new"]["document_root"]."/log");
if ($web_config["website_symlinks_rel"] == 'y') {
$this->create_relative_link("/var/log/ispconfig/httpd/".$data["new"]["domain"], $data["new"]["document_root"]."/log");
} else {
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);
}
/*
......@@ -413,7 +419,13 @@ class apache2_plugin {
}
// create the symlinks, if not exist
if(!is_link($tmp_symlink)) {
exec('ln -s '.escapeshellcmd($data['new']['document_root']).'/ '.escapeshellcmd($tmp_symlink));
// exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink));
if ($web_config["website_symlinks_rel"] == 'y') {
$this->create_relative_link(escapeshellcmd($data["new"]["document_root"]), escapeshellcmd($tmp_symlink));
} else {
exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink));
}
$app->log('Creating symlink: ln -s '.$data['new']['document_root'].'/ '.$tmp_symlink,LOGLEVEL_DEBUG);
}
}
......@@ -1458,6 +1470,31 @@ class apache2_plugin {
}
}
public function create_relative_link($f, $t) {
// $from already exists
$from = realpath($f);
// realpath requires the traced file to exist - so, lets touch it first, then remove
@unlink($t); touch($t);
$to = realpath($t);
@unlink($t);
// Remove from the left side matching path elements from $from and $to
// and get path elements counts
$a1 = explode('/', $from); $a2 = explode('/', $to);
for ($c = 0; $a1[$c] == $a2[$c]; $c++) {
unset($a1[$c]); unset($a2[$c]);
}
$cfrom = implode('/', $a1);
// Check if a path is fully a subpath of another - no way to create symlink in the case
if (count($a1) == 0 || count($a2) == 0) return false;
// Add ($cnt_to-1) number of "../" elements to left side of $cfrom
for ($c = 0; $c < (count($a2)-1); $c++) { $cfrom = '../'.$cfrom; }
return symlink($cfrom, $to);
}
} // end class
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment