|
NAMEApache::Vhosts::Common - Lib for common operations in vhosts inventory DESCRIPTIONThis package is meant to contain common functions used by OCS modules for Apache virtualhosts. For example, we could have two OCS modules:
At different times, these modules still would need to do the same things, such as parsing apache configuration files, reading and extracting information from a vhost dump, reading a x509 certificate with openssl, ... To avoid code duplication, the specific modules can call the functions contained in this common package. ExportsThe module exports the following functions:
readVhostsDump()Return an array of hashes with the virtualhosts found thanks to Apache's vhosts dump ("httpd -S" command). Return type The function returns a reference to an array of hashes. Process The function's workflow is as follows:
Return example [
{
'computedname' => "[httpd] myvhost.fr:80",
'port' => 80,
'srvname' => 'myvhost.fr',
'vhostfile' => '/etc/httpd/conf.d/10-myvhost.conf',
'vhostline' => 1,
'docroot' => '/nonexistent',
'ssl' => 0
},
{
'computedname' => "[httpd] myvhost.fr:443",
'port' => 443,
'srvname' => 'myvhost.fr',
'vhostfile' => '/etc/httpd/conf.d/10-myvhost.conf',
'vhostline' => 20,
'docroot' => '/nonexistent',
'ssl' => 0
}
]
Calling my $vhosts = readVhostsDump($httpd_bin, $httpd_conf_file, $logger);
readVhostConfFile()Enhance a virtualhost's information with elements found when parsing the vhost's configuration file. Return type The function returns nothing. It only operates on the (referenced) vhost hash it got in parameter. Process The function must read the apache configuration file in which the vhost gets defined (<VirtualHost> block). The path to the particular configuration file and the line number of the vhost declaration are known in the "vhostfile" and "vhostline" attributes, thanks to the vhost dump. The function's process, for the given vhost, is as follows:
Calling foreach my $vhost (@$vhosts) # Generally
{
readVhostConfFile($vhost, $httpd_basedir);
}
|