- added possibility to run perl-scripts (if allowed by admin) via directory-options

- for use in lighttpd you have to add "mod_cgi" to the modules-list (and maybe patch lighttpd-cron if perl is not installed in /usr/bin)
This commit is contained in:
Michael Kaufmann (d00p)
2010-07-22 06:02:38 +00:00
parent edc7a91519
commit d1d772f790
21 changed files with 209 additions and 16 deletions

View File

@@ -803,19 +803,41 @@ class apache
if(is_dir($row_diroptions['path']))
{
$cperlenabled = customerHasPerlEnabled($row_diroptions['customerid']);
$this->diroptions_data[$diroptions_filename].= '<Directory "' . $row_diroptions['path'] . '">' . "\n";
if(isset($row_diroptions['options_indexes'])
&& $row_diroptions['options_indexes'] == '1')
{
$this->diroptions_data[$diroptions_filename].= ' Options +Indexes' . "\n";
$this->diroptions_data[$diroptions_filename].= ' Options +Indexes';
// add perl options if enabled
if($cperlenabled
&& isset($row_diroptions['options_cgi'])
&& $row_diroptions['options_cgi'] == '1')
{
$this->diroptions_data[$diroptions_filename].= ' ExecCGI -MultiViews +SymLinksIfOwnerMatch'."\n";
} else {
$this->diroptions_data[$diroptions_filename].= "\n";
}
fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options +Indexes' . "\n");
}
if(isset($row_diroptions['options_indexes'])
&& $row_diroptions['options_indexes'] == '0')
{
$this->diroptions_data[$diroptions_filename].= ' Options -Indexes' . "\n";
$this->diroptions_data[$diroptions_filename].= ' Options -Indexes';
// add perl options if enabled
if($cperlenabled
&& isset($row_diroptions['options_cgi'])
&& $row_diroptions['options_cgi'] == '1')
{
$this->diroptions_data[$diroptions_filename].= ' ExecCGI -MultiViews +SymLinksIfOwnerMatch'."\n";
} else {
$this->diroptions_data[$diroptions_filename].= "\n";
}
fwrite($this->debugHandler, ' cron_tasks: Task3 - Setting Options -Indexes' . "\n");
}
@@ -837,6 +859,17 @@ class apache
$this->diroptions_data[$diroptions_filename].= ' ErrorDocument 500 ' . $row_diroptions['error500path'] . "\n";
}
if($cperlenabled
&& isset($row_diroptions['options_cgi'])
&& $row_diroptions['options_cgi'] == '1')
{
$this->diroptions_data[$diroptions_filename].= ' AllowOverride None' . "\n";
$this->diroptions_data[$diroptions_filename].= ' AddHandler cgi-script .cgi .pl' . "\n";
$this->diroptions_data[$diroptions_filename].= ' Order allow,deny' . "\n";
$this->diroptions_data[$diroptions_filename].= ' Allow from all' . "\n";
fwrite($this->debugHandler, ' cron_tasks: Task3 - Enabling perl execution' . "\n");
}
if(count($row_diroptions['htpasswds']) > 0)
{
$htpasswd_filename = makeCorrectFile($this->settings['system']['apacheconf_htpasswddir'] . '/' . $row_diroptions['customerid'] . '-' . md5($row_diroptions['path']) . '.htpasswd');

View File

@@ -531,6 +531,22 @@ class lighttpd
{
$path_options = $error_string;
}
if(customerHasPerlEnabled($domain['customerid'])
&& $row['options_cgi'] != '0')
{
$path = makeCorrectDir(substr($row['path'], strlen($domain['documentroot']) - 1));
mkDirWithCorrectOwnership($domain['documentroot'], $row['path'], $domain['guid'], $domain['guid']);
// We need to remove the last slash, otherwise the regex wouldn't work
$path = substr($path, 0, -1);
$path_options.= ' $HTTP["url"] =~ "^' . $path . '($|/)" {' . "\n";
$path_options.= "\t" . 'cgi.assign = (' . "\n";
$path_options.= "\t\t" . '".pl" => "/usr/bin/perl",' . "\n";
$path_options.= "\t\t" . '".cgi" => "/usr/bin/perl"' . "\n";
$path_options.= "\t" . ')' . "\n";
$path_options.= ' }' . "\n\n";
}
}
return $path_options;